feat: option to hide letters for a specific languages
This commit is contained in:
parent
58e7818907
commit
0430b9a3a3
5 changed files with 67 additions and 0 deletions
|
|
@ -1,6 +1,13 @@
|
|||
package io.github.sspanak.tt9.preferences.screens.appearance;
|
||||
|
||||
import androidx.preference.MultiSelectListPreference;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Set;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.languages.Language;
|
||||
import io.github.sspanak.tt9.languages.LanguageCollection;
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemSwitch;
|
||||
|
|
@ -20,6 +27,7 @@ public class AppearanceScreen extends BaseScreenFragment {
|
|||
createMainSection();
|
||||
createHacksSection();
|
||||
resetFontSize(true);
|
||||
populateHiddenLanguages();
|
||||
}
|
||||
|
||||
private void createMainSection() {
|
||||
|
|
@ -80,4 +88,32 @@ public class AppearanceScreen extends BaseScreenFragment {
|
|||
item.populate().enableClickHandler();
|
||||
}
|
||||
}
|
||||
|
||||
private void populateHiddenLanguages() {
|
||||
MultiSelectListPreference hiddenLanguagesPref = findPreference("pref_hidden_languages");
|
||||
if (hiddenLanguagesPref == null)
|
||||
return;
|
||||
|
||||
ArrayList<Language> allLanguages = LanguageCollection.getAll(true);
|
||||
if (allLanguages.isEmpty())
|
||||
return;
|
||||
|
||||
Set<Integer> hiddenLanguages = activity.getSettings().getHiddenLanguages();
|
||||
hiddenLanguages.addAll(activity.getSettings().getEnabledLanguageIds());
|
||||
ArrayList<Integer> languageOrder = new ArrayList<>(hiddenLanguages);
|
||||
|
||||
String[] entries = new String[languageOrder.size()];
|
||||
for (Language lang : allLanguages) {
|
||||
int idx = languageOrder.indexOf(lang.getId());
|
||||
if (idx != -1)
|
||||
entries[idx] = lang.getName();
|
||||
}
|
||||
|
||||
String[] entryValues = new String[languageOrder.size()];
|
||||
for (int i = 0; i < languageOrder.size(); ++i)
|
||||
entryValues[i] = String.valueOf(languageOrder.get(i));
|
||||
|
||||
hiddenLanguagesPref.setEntries(entries);
|
||||
hiddenLanguagesPref.setEntryValues(entryValues);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ import android.view.Gravity;
|
|||
|
||||
import androidx.appcompat.app.AppCompatDelegate;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.github.sspanak.tt9.BuildConfig;
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
|
|
@ -157,6 +160,17 @@ public class SettingsUI extends SettingsTyping {
|
|||
prefsEditor.apply();
|
||||
}
|
||||
|
||||
public Set<Integer> getHiddenLanguages() {
|
||||
HashSet<Integer> out = new HashSet<>();
|
||||
Set<String> hiddenLanguages = prefs.getStringSet("pref_hidden_languages", null);
|
||||
|
||||
if (hiddenLanguages != null)
|
||||
for (String v : hiddenLanguages)
|
||||
out.add(Integer.parseInt(v));
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
public int getMainViewLayout() {
|
||||
return getStringifiedInt("pref_layout_type", DEFAULT_LAYOUT);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,12 +1,16 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.PreferenceManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||
|
|
@ -36,6 +40,9 @@ public class SoftKeyNumber2to9 extends SoftKeyNumber {
|
|||
@Override
|
||||
protected String getTitle() {
|
||||
if (tt9 != null && !tt9.isInputModeNumeric()) {
|
||||
Language language = tt9.getLanguage();
|
||||
if (language != null && tt9.getSettings().getHiddenLanguages().contains(language.getId()))
|
||||
return getLocalizedNumber(getNumber(getId()));
|
||||
return getKeyChars(tt9, getNumber(getId()));
|
||||
} else {
|
||||
return getLocalizedNumber(getNumber(getId()));
|
||||
|
|
|
|||
|
|
@ -277,4 +277,8 @@
|
|||
<string name="voice_input_error_no_network">No Internet connection</string>
|
||||
<string name="voice_input_error_not_available">Voice input is not available</string>
|
||||
<string name="pref_hack_precalculate_navbar_height">Recalculate Bottom Padding</string>
|
||||
|
||||
<string-array name="pref_hidden_languages_defaults" translatable="false" />
|
||||
<string name="pref_hidden_languages_title">Hide letters</string>
|
||||
<string name="pref_hidden_languages_summary">Hide letters from keyboard for specified languages</string>
|
||||
</resources>
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@
|
|||
app:title="@string/pref_drag_resize"
|
||||
app:summary="@string/pref_drag_resize_summary" />
|
||||
|
||||
<MultiSelectListPreference
|
||||
app:key="pref_hidden_languages"
|
||||
app:summary="@string/pref_hidden_languages_summary"
|
||||
app:title="@string/pref_hidden_languages_title"
|
||||
app:defaultValue="@array/pref_hidden_languages_defaults" />
|
||||
|
||||
<PreferenceCategory app:title="@string/pref_category_geometry">
|
||||
<DropDownPreference
|
||||
app:key="pref_numpad_shape"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue