added a setting for 0-key double press function
This commit is contained in:
parent
363f9611f7
commit
88797898d8
13 changed files with 107 additions and 5 deletions
|
|
@ -87,9 +87,9 @@ public class ModePredictive extends InputMode {
|
|||
reset();
|
||||
word = String.valueOf(key);
|
||||
} else if (key == 0 && repeat > 0) {
|
||||
// repeat "0" to type spaces
|
||||
// repeat "0" is a shortcut for the preferred character (default: space)
|
||||
reset();
|
||||
word = " ";
|
||||
word = settings.getDoubleZeroChar();
|
||||
} else {
|
||||
// words
|
||||
super.reset();
|
||||
|
|
|
|||
|
|
@ -208,6 +208,7 @@ public class SettingsStore {
|
|||
|
||||
public boolean getAutoSpace() { return prefs.getBoolean("auto_space", false); }
|
||||
public boolean getAutoTextCase() { return prefs.getBoolean("auto_text_case", true); }
|
||||
public String getDoubleZeroChar() { return prefs.getString("pref_double_zero_char", " "); }
|
||||
|
||||
|
||||
/************* internal settings *************/
|
||||
|
|
|
|||
|
|
@ -0,0 +1,67 @@
|
|||
package io.github.sspanak.tt9.preferences.items;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import androidx.preference.DropDownPreference;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import io.github.sspanak.tt9.Logger;
|
||||
import io.github.sspanak.tt9.R;
|
||||
|
||||
public class ItemSelectZeroKeyCharacter {
|
||||
public static final String NAME = "pref_double_zero_char";
|
||||
|
||||
private final DropDownPreference item;
|
||||
private final LinkedHashMap<String, String> KEYS = new LinkedHashMap<>();
|
||||
|
||||
public ItemSelectZeroKeyCharacter(DropDownPreference dropDown, Context context) {
|
||||
this.item = dropDown;
|
||||
|
||||
Resources resources = context.getResources();
|
||||
|
||||
KEYS.put(" ", resources.getString(R.string.char_space));
|
||||
KEYS.put("\n", resources.getString(R.string.char_newline));
|
||||
KEYS.put(".", resources.getString(R.string.char_dot));
|
||||
}
|
||||
|
||||
|
||||
public ItemSelectZeroKeyCharacter populate() {
|
||||
if (item == null) {
|
||||
Logger.w("tt9/ItemSelectZeroKeyChar.populate", "Cannot populate a NULL item. Ignoring.");
|
||||
return this;
|
||||
}
|
||||
|
||||
item.setEntries(KEYS.values().toArray(new CharSequence[0]));
|
||||
item.setEntryValues(KEYS.keySet().toArray(new CharSequence[0]));
|
||||
previewSelection(item.getValue());
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
public ItemSelectZeroKeyCharacter activate() {
|
||||
if (item == null) {
|
||||
Logger.w("tt9/ItemSelectZeroKeyChar.activate", "Cannot set a click listener a NULL item. Ignoring.");
|
||||
return this;
|
||||
}
|
||||
|
||||
item.setOnPreferenceChangeListener((preference, newChar) -> {
|
||||
((DropDownPreference) preference).setValue(newChar.toString());
|
||||
previewSelection(newChar.toString());
|
||||
return true;
|
||||
});
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
private void previewSelection(String newChar) {
|
||||
if (item == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
item.setSummary(KEYS.get(newChar));
|
||||
}
|
||||
}
|
||||
|
|
@ -6,6 +6,7 @@ import io.github.sspanak.tt9.BuildConfig;
|
|||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemLoadDictionary;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemSelectLanguage;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemSelectZeroKeyCharacter;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemToggleDarkTheme;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemTruncateDictionary;
|
||||
import io.github.sspanak.tt9.preferences.PreferencesActivity;
|
||||
|
|
@ -33,9 +34,10 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
createDictionarySection();
|
||||
createAppearanceSection();
|
||||
createAboutSection();
|
||||
createAppearanceSection();
|
||||
createDictionarySection();
|
||||
createPredictiveModeSection();
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -70,6 +72,11 @@ public class MainSettingsScreen extends BaseScreenFragment {
|
|||
}
|
||||
|
||||
|
||||
private void createPredictiveModeSection() {
|
||||
(new ItemSelectZeroKeyCharacter(findPreference(ItemSelectZeroKeyCharacter.NAME), activity)).populate().activate();
|
||||
}
|
||||
|
||||
|
||||
private void createAboutSection() {
|
||||
Preference vi = findPreference("version_info");
|
||||
if (vi != null) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue