inactive virtual keys are now properly displayed as disabled
This commit is contained in:
parent
0a1aed88d5
commit
077aac9b1a
11 changed files with 110 additions and 8 deletions
|
|
@ -70,7 +70,7 @@ abstract public class CommandHandler extends VoiceHandler {
|
|||
|
||||
|
||||
public void addWord() {
|
||||
if (mInputMode.isNumeric() || voiceInputOps.isListening()) {
|
||||
if (voiceInputOps.isListening()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package io.github.sspanak.tt9.ime;
|
|||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.github.sspanak.tt9.ime.modes.ModeABC;
|
||||
import io.github.sspanak.tt9.ime.voice.VoiceInputOps;
|
||||
import io.github.sspanak.tt9.languages.Language;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
|
|
@ -12,6 +13,10 @@ abstract public class MainViewHandler extends HotkeyHandler {
|
|||
return mInputMode.getTextCase();
|
||||
}
|
||||
|
||||
public boolean isInputModeABC() {
|
||||
return mInputMode.getClass().equals(ModeABC.class);
|
||||
}
|
||||
|
||||
public boolean isInputModeNumeric() {
|
||||
return mInputMode.is123();
|
||||
}
|
||||
|
|
@ -28,6 +33,10 @@ abstract public class MainViewHandler extends HotkeyHandler {
|
|||
return mInputMode.is123() && inputType.isPhoneNumber();
|
||||
}
|
||||
|
||||
public boolean isVoiceInputActive() {
|
||||
return voiceInputOps != null && voiceInputOps.isListening();
|
||||
}
|
||||
|
||||
public boolean isVoiceInputMissing() {
|
||||
return !(new VoiceInputOps(this, null, null, null)).isAvailable();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,6 +57,9 @@ abstract class VoiceHandler extends TypingHandler {
|
|||
|
||||
|
||||
private void onVoiceInputStarted() {
|
||||
if (!mainView.isCommandPaletteShown()) {
|
||||
mainView.render(); // disable the function keys
|
||||
}
|
||||
statusBar.setText(voiceInputOps);
|
||||
}
|
||||
|
||||
|
|
@ -64,13 +67,16 @@ abstract class VoiceHandler extends TypingHandler {
|
|||
private void onVoiceInputStopped(String text) {
|
||||
onText(text, false);
|
||||
resetStatus();
|
||||
if (!mainView.isCommandPaletteShown()) {
|
||||
mainView.render(); // re-enable the function keys
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void onVoiceInputError(VoiceInputError error) {
|
||||
if (error.isIrrelevantToUser()) {
|
||||
Logger.i(LOG_TAG, "Ignoring voice input. " + error.debugMessage);
|
||||
resetStatus();
|
||||
resetStatus(); // re-enable the function keys
|
||||
} else {
|
||||
Logger.e(LOG_TAG, "Failed to listen. " + error.debugMessage);
|
||||
statusBar.setError(error.toString());
|
||||
|
|
@ -78,5 +84,9 @@ abstract class VoiceHandler extends TypingHandler {
|
|||
RequestPermissionDialog.show(this);
|
||||
}
|
||||
}
|
||||
|
||||
if (!mainView.isCommandPaletteShown()) {
|
||||
mainView.render(); // re-enable the function keys
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,14 @@ public class SoftBackspaceKey extends SoftKey {
|
|||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
|
||||
if (Characters.noEmojiSupported()) {
|
||||
return "Del";
|
||||
}
|
||||
|
||||
return LanguageKind.isRTL(tt9.getLanguage()) ? "⌦" : "⌫";
|
||||
return LanguageKind.isRTL(tt9 != null ? tt9.getLanguage() : null) ? "⌦" : "⌫";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,4 +39,13 @@ public class SoftFilterKey extends SoftKey {
|
|||
protected String getSubTitle() {
|
||||
return "FLTR";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isInputModeNumeric() && !tt9.isInputModeABC() && !tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -33,4 +33,12 @@ public class SoftInputModeKey extends SoftKey {
|
|||
protected boolean handleRelease() {
|
||||
return validateTT9Handler() && tt9.onKeyNextInputMode(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -149,9 +149,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
|
||||
int keyId = getId();
|
||||
|
||||
if (keyId == R.id.soft_key_add_word) { tt9.addWord(); return true; }
|
||||
if (keyId == R.id.soft_key_command_palette) return tt9.onKeyCommandPalette(false);
|
||||
if (keyId == R.id.soft_key_language) return tt9.onKeyNextLanguage(false);
|
||||
if (keyId == R.id.soft_key_settings) { tt9.showSettings(); return true; }
|
||||
if (keyId == R.id.soft_key_voice_input) { tt9.toggleVoiceInput(); return true; }
|
||||
|
||||
|
|
@ -167,6 +165,12 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
setTextColor(getTextColors().withAlpha(enabled ? 255 : 80));
|
||||
}
|
||||
|
||||
/**
|
||||
* getTitle
|
||||
* Generates the name of the key, for example: "OK", "Backspace", "1", etc...
|
||||
|
|
@ -186,7 +190,6 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* render
|
||||
* Sets the key label using "getTitle()" and "getSubtitle()" or if they both
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
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,23 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
public class SoftKeyNextLanguage extends SoftKey {
|
||||
public SoftKeyNextLanguage(Context context) { super(context); }
|
||||
public SoftKeyNextLanguage(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyNextLanguage(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
return validateTT9Handler() && tt9.onKeyNextLanguage(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isInputModeNumeric() && !tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -29,4 +29,13 @@ public class SoftOkKey extends SoftKey {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@
|
|||
android:layoutDirection="ltr"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKey
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyAddWord
|
||||
android:id="@+id/soft_key_add_word"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
|
|
@ -260,7 +260,7 @@
|
|||
android:layoutDirection="ltr"
|
||||
tools:ignore="HardcodedText">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKey
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyNextLanguage
|
||||
android:id="@+id/soft_key_language"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue