added the TAB key
This commit is contained in:
parent
47c846ca39
commit
3cda6b9bb3
11 changed files with 92 additions and 37 deletions
|
|
@ -90,6 +90,10 @@ public abstract class HotkeyHandler extends CommandHandler {
|
|||
return onKeyScrollSuggestion(validateOnly, false);
|
||||
}
|
||||
|
||||
if (keyCode == settings.getKeyTab()) {
|
||||
return onTab(validateOnly);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
@ -241,4 +245,23 @@ public abstract class HotkeyHandler extends CommandHandler {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public boolean onTab(boolean validateOnly) {
|
||||
if (shouldBeOff()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (validateOnly) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (inputType.isMultilineText()) {
|
||||
return onText("\t", validateOnly);
|
||||
} else {
|
||||
textField.sendDownUpKeyEvents(KeyEvent.KEYCODE_TAB);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -102,15 +102,16 @@ public class Mode123 extends ModePassthrough {
|
|||
/**
|
||||
* shouldIgnoreText
|
||||
* Since this is a numeric mode, we allow typing only numbers and:
|
||||
* 1. In numeric fields, we must allow math chars
|
||||
* 2. In dialer fields, we must allow various punctuation chars, because they are used as dialing shortcuts
|
||||
* at least in Japan.
|
||||
* More info and discussion: <a href="https://github.com/sspanak/tt9/issues/241">issue 241 on Github</a>.
|
||||
* 1. TAB
|
||||
* 2. Math chars for numeric fields
|
||||
* 3. Various punctuation chars for dialer fields, because they are used as dialing shortcuts
|
||||
* at least in Japan. More info and discussion: <a href="https://github.com/sspanak/tt9/issues/241">issue 241 on Github</a>.
|
||||
*/
|
||||
@Override public boolean shouldIgnoreText(String text) {
|
||||
return
|
||||
text == null
|
||||
|| text.length() != 1
|
||||
|| text.charAt(0) == 9
|
||||
|| !(
|
||||
(text.charAt(0) > 31 && text.charAt(0) < 65)
|
||||
|| (text.charAt(0) > 90 && text.charAt(0) < 97)
|
||||
|
|
|
|||
|
|
@ -74,7 +74,8 @@ public class Hotkeys {
|
|||
previousSuggestion,
|
||||
nextSuggestion,
|
||||
KeyEvent.KEYCODE_POUND,
|
||||
-KeyEvent.KEYCODE_POUND // negative means "hold"
|
||||
-KeyEvent.KEYCODE_POUND, // negative means "hold"
|
||||
KeyEvent.KEYCODE_UNKNOWN // unassigned
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public class HotkeysScreen extends BaseScreenFragment {
|
|||
findPreference(SectionKeymap.ITEM_NEXT_SUGGESTION),
|
||||
findPreference(SectionKeymap.ITEM_NEXT_INPUT_MODE),
|
||||
findPreference(SectionKeymap.ITEM_NEXT_LANGUAGE),
|
||||
findPreference(SectionKeymap.ITEM_TAB),
|
||||
};
|
||||
SectionKeymap section = new SectionKeymap(Arrays.asList(dropDowns), activity);
|
||||
section.populate().activate();
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ public class SectionKeymap {
|
|||
public static final String ITEM_NEXT_SUGGESTION = "key_next_suggestion";
|
||||
public static final String ITEM_NEXT_INPUT_MODE = "key_next_input_mode";
|
||||
public static final String ITEM_NEXT_LANGUAGE = "key_next_language";
|
||||
public static final String ITEM_TAB = "key_tab";
|
||||
|
||||
private final Hotkeys hotkeys;
|
||||
private final Collection<DropDownPreference> items;
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ class SettingsHotkeys extends SettingsHacks {
|
|||
int previousSuggestion,
|
||||
int nextSuggestion,
|
||||
int nextInputMode,
|
||||
int nextLanguage
|
||||
int nextLanguage,
|
||||
int tab
|
||||
) {
|
||||
prefsEditor
|
||||
.putString(SectionKeymap.ITEM_BACKSPACE, String.valueOf(backspace))
|
||||
|
|
@ -31,6 +32,7 @@ class SettingsHotkeys extends SettingsHacks {
|
|||
.putString(SectionKeymap.ITEM_NEXT_SUGGESTION, String.valueOf(nextSuggestion))
|
||||
.putString(SectionKeymap.ITEM_NEXT_INPUT_MODE, String.valueOf(nextInputMode))
|
||||
.putString(SectionKeymap.ITEM_NEXT_LANGUAGE, String.valueOf(nextLanguage))
|
||||
.putString(SectionKeymap.ITEM_TAB, String.valueOf(tab))
|
||||
.putBoolean("hotkeys_v2_initialized", true)
|
||||
.apply();
|
||||
}
|
||||
|
|
@ -65,4 +67,7 @@ class SettingsHotkeys extends SettingsHacks {
|
|||
public int getKeyCommandPalette() {
|
||||
return getFunctionKey(SectionKeymap.ITEM_COMMAND_PALETTE);
|
||||
}
|
||||
public int getKeyTab() {
|
||||
return getFunctionKey(SectionKeymap.ITEM_TAB);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,27 +0,0 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SoftKeyAddWord extends SoftKey {
|
||||
public SoftKeyAddWord(Context context) { super(context); }
|
||||
public SoftKeyAddWord(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyAddWord(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
if (validateTT9Handler()) {
|
||||
tt9.addWord();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,47 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.ui.Vibration;
|
||||
|
||||
public class SoftKeyLF2 extends SoftKey {
|
||||
public SoftKeyLF2(Context context) { super(context); }
|
||||
public SoftKeyLF2(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyLF2(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
@Override
|
||||
protected void handleHold() {
|
||||
if (!validateTT9Handler()) {
|
||||
return;
|
||||
}
|
||||
|
||||
preventRepeat();
|
||||
vibrate(Vibration.getHoldVibration());
|
||||
tt9.addWord();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
return validateTT9Handler() && tt9.onTab(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return "+";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubTitle() {
|
||||
return getContext().getString(R.string.key_tab).toUpperCase();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -57,14 +57,12 @@
|
|||
android:layout_height="@dimen/numpad_key_height"
|
||||
android:layoutDirection="ltr">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyAddWord
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyLF2
|
||||
android:id="@+id/soft_key_add_word"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="@dimen/numpad_control_key_layout_weight"
|
||||
android:text="+"
|
||||
android:textStyle="bold" />
|
||||
android:layout_weight="@dimen/numpad_control_key_layout_weight" />
|
||||
|
||||
<View
|
||||
android:id="@+id/separator_2_1"
|
||||
|
|
|
|||
|
|
@ -157,6 +157,7 @@
|
|||
<string name="key_menu" translatable="false">Menu</string>
|
||||
<string name="key_soft_left" translatable="false">Left Func</string>
|
||||
<string name="key_soft_right" translatable="false">Right Func</string>
|
||||
<string name="key_tab" translatable="false">Tab</string>
|
||||
<string name="key_volume_mute">Volume Mute</string>
|
||||
<string name="key_volume_down">Volume Down</string>
|
||||
<string name="key_volume_up">Volume Up</string>
|
||||
|
|
|
|||
|
|
@ -34,6 +34,10 @@
|
|||
app:key="key_next_input_mode"
|
||||
app:title="@string/function_next_mode" />
|
||||
|
||||
<DropDownPreference
|
||||
app:key="key_tab"
|
||||
app:title="@string/key_tab" />
|
||||
|
||||
<Preference
|
||||
app:key="reset_keys"
|
||||
app:title="@string/function_reset_keys_title" />
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue