added an input handling mode debug option
This commit is contained in:
parent
282a9ae8ed
commit
c0c95dedb9
5 changed files with 71 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ import java.util.HashMap;
|
|||
import io.github.sspanak.tt9.Logger;
|
||||
import io.github.sspanak.tt9.ime.helpers.Key;
|
||||
import io.github.sspanak.tt9.preferences.SettingsStore;
|
||||
import io.github.sspanak.tt9.preferences.screens.debug.ItemInputHandlingMode;
|
||||
|
||||
|
||||
abstract class KeyPadHandler extends InputMethodService {
|
||||
|
|
@ -121,6 +122,12 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (settings.getInputHandlingMode() == ItemInputHandlingMode.RETURN_FALSE) {
|
||||
return false;
|
||||
} else if (settings.getInputHandlingMode() == ItemInputHandlingMode.CALL_SUPER) {
|
||||
return super.onKeyDown(keyCode, event);
|
||||
}
|
||||
|
||||
if (shouldBeOff()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -160,6 +167,12 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
|
||||
@Override
|
||||
public boolean onKeyLongPress(int keyCode, KeyEvent event) {
|
||||
if (settings.getInputHandlingMode() == ItemInputHandlingMode.RETURN_FALSE) {
|
||||
return false;
|
||||
} else if (settings.getInputHandlingMode() == ItemInputHandlingMode.CALL_SUPER) {
|
||||
return super.onKeyLongPress(keyCode, event);
|
||||
}
|
||||
|
||||
if (shouldBeOff()) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -200,6 +213,12 @@ abstract class KeyPadHandler extends InputMethodService {
|
|||
return true;
|
||||
}
|
||||
|
||||
if (settings.getInputHandlingMode() == ItemInputHandlingMode.RETURN_FALSE) {
|
||||
return false;
|
||||
} else if (settings.getInputHandlingMode() == ItemInputHandlingMode.CALL_SUPER) {
|
||||
return super.onKeyUp(keyCode, event);
|
||||
}
|
||||
|
||||
if (shouldBeOff()) {
|
||||
return false;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import java.util.Set;
|
|||
import io.github.sspanak.tt9.Logger;
|
||||
import io.github.sspanak.tt9.ime.modes.InputMode;
|
||||
import io.github.sspanak.tt9.languages.LanguageCollection;
|
||||
import io.github.sspanak.tt9.preferences.screens.debug.ItemInputHandlingMode;
|
||||
import io.github.sspanak.tt9.preferences.screens.hotkeys.SectionKeymap;
|
||||
|
||||
|
||||
|
|
@ -278,6 +279,14 @@ public class SettingsStore {
|
|||
}
|
||||
}
|
||||
|
||||
public int getInputHandlingMode() {
|
||||
try {
|
||||
return Integer.parseInt(prefs.getString("pref_input_handling_mode", String.valueOf(ItemInputHandlingMode.NORMAL)));
|
||||
} catch (NumberFormatException ignored) {
|
||||
return ItemInputHandlingMode.NORMAL;
|
||||
}
|
||||
}
|
||||
|
||||
public final static int DELETE_WORDS_SEARCH_DELAY = 500; // ms
|
||||
public final static int DICTIONARY_AUTO_LOAD_COOLDOWN_TIME = 120000; // ms
|
||||
public final static int DICTIONARY_IMPORT_BATCH_SIZE = 5000; // words
|
||||
|
|
|
|||
|
|
@ -33,7 +33,8 @@ public class DebugScreen extends BaseScreenFragment {
|
|||
|
||||
@Override
|
||||
protected void onCreate() {
|
||||
intiLogLevelDropDown();
|
||||
(new ItemLogLevel(findPreference(ItemLogLevel.NAME))).populate().preview().enableClickHandler();
|
||||
(new ItemInputHandlingMode(findPreference(ItemInputHandlingMode.NAME), activity.settings)).populate().preview().enableClickHandler();
|
||||
initSystemLogsSwitch();
|
||||
enableLogsCopy();
|
||||
|
||||
|
|
@ -42,10 +43,6 @@ public class DebugScreen extends BaseScreenFragment {
|
|||
printLogs(includeSystemLogs);
|
||||
}
|
||||
|
||||
private void intiLogLevelDropDown() {
|
||||
(new ItemLogLevel(findPreference(ItemLogLevel.NAME))).populate().preview().enableClickHandler();
|
||||
}
|
||||
|
||||
private void initSystemLogsSwitch() {
|
||||
SwitchPreferenceCompat systemLogs = findPreference(SYSTEM_LOGS_SWITCH);
|
||||
if (systemLogs != null) {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,35 @@
|
|||
package io.github.sspanak.tt9.preferences.screens.debug;
|
||||
|
||||
import androidx.preference.DropDownPreference;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
import io.github.sspanak.tt9.preferences.SettingsStore;
|
||||
import io.github.sspanak.tt9.preferences.items.ItemDropDown;
|
||||
|
||||
public class ItemInputHandlingMode extends ItemDropDown {
|
||||
public static final int NORMAL = 0;
|
||||
public static final int RETURN_FALSE = 1;
|
||||
public static final int CALL_SUPER = 2;
|
||||
|
||||
public static final String NAME = "pref_input_handling_mode";
|
||||
|
||||
private SettingsStore settings;
|
||||
|
||||
ItemInputHandlingMode(DropDownPreference item, SettingsStore settings) {
|
||||
super(item);
|
||||
this.settings = settings;
|
||||
}
|
||||
|
||||
public ItemInputHandlingMode populate() {
|
||||
LinkedHashMap<Integer, String> values = new LinkedHashMap<>();
|
||||
values.put(NORMAL, "Normal");
|
||||
values.put(RETURN_FALSE, "Return False");
|
||||
values.put(CALL_SUPER, "Call Super");
|
||||
|
||||
super.populate(values);
|
||||
super.setValue(String.valueOf(settings.getInputHandlingMode()));
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -7,6 +7,12 @@
|
|||
app:layout="@layout/pref_text"
|
||||
app:title="@string/pref_category_usage_stats" />
|
||||
|
||||
<DropDownPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_input_handling_mode"
|
||||
app:layout="@layout/pref_dropdown"
|
||||
app:title="Keypad Handling Mode" />
|
||||
|
||||
<DropDownPreference
|
||||
app:iconSpaceReserved="false"
|
||||
app:key="pref_log_level"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue