fixed missing virtual key labels on devices with no emoji support
This commit is contained in:
parent
077aac9b1a
commit
390085e4b3
12 changed files with 109 additions and 25 deletions
|
|
@ -15,9 +15,10 @@ public class SettingsStore extends SettingsUI {
|
|||
public final static int DICTIONARY_IMPORT_PROGRESS_UPDATE_TIME = 250; // ms
|
||||
public final static byte SLOW_QUERY_TIME = 50; // ms
|
||||
public final static int SOFT_KEY_REPEAT_DELAY = 40; // ms
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE = 0.55f;
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_SIZE = 0.72f;
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_SIZE = 0.8f;
|
||||
public final static int SOFT_KEY_TITLE_SIZE = 18; // sp
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE = 0.55f;
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE = 0.72f;
|
||||
public final static float SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE = 0.8f;
|
||||
public final static int SUGGESTIONS_MAX = 20;
|
||||
public final static int SUGGESTIONS_MIN = 8;
|
||||
public final static int SUGGESTIONS_SELECT_ANIMATION_DURATION = 66;
|
||||
|
|
|
|||
|
|
@ -4,8 +4,8 @@ import android.content.Context;
|
|||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
import io.github.sspanak.tt9.util.Characters;
|
||||
|
||||
public class SoftBackspaceKey extends SoftKey {
|
||||
|
||||
|
|
@ -44,16 +44,21 @@ public class SoftBackspaceKey extends SoftKey {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNoEmojiTitle() {
|
||||
return R.string.virtual_key_del;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTitle() {
|
||||
return LanguageKind.isRTL(tt9 != null ? tt9.getLanguage() : null) ? "⌦" : "⌫";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
if (tt9 != null) {
|
||||
setEnabled(!tt9.isVoiceInputActive());
|
||||
}
|
||||
|
||||
if (Characters.noEmojiSupported()) {
|
||||
return "Del";
|
||||
}
|
||||
|
||||
return LanguageKind.isRTL(tt9 != null ? tt9.getLanguage() : null) ? "⌦" : "⌫";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,10 @@ 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.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.util.Characters;
|
||||
|
||||
public class SoftCommandKey extends SoftNumberKey {
|
||||
public SoftCommandKey(Context context) { super(context);}
|
||||
public SoftCommandKey(Context context, AttributeSet attrs) { super(context, attrs);}
|
||||
|
|
@ -13,15 +17,23 @@ public class SoftCommandKey extends SoftNumberKey {
|
|||
return getNumber(getId()) + "";
|
||||
}
|
||||
|
||||
|
||||
private String getTextSubTitle(int resId) {
|
||||
setTextSize(SettingsStore.SOFT_KEY_TITLE_SIZE);
|
||||
return getContext().getString(resId);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSubTitle() {
|
||||
int number = getNumber(getId());
|
||||
|
||||
boolean noIconSupport = Characters.noEmojiSupported();
|
||||
|
||||
switch (number) {
|
||||
case 0:
|
||||
return "⌨";
|
||||
return noIconSupport ? getTextSubTitle(R.string.virtual_key_change_keyboard) : "⌨";
|
||||
case 1:
|
||||
return "⚙";
|
||||
return noIconSupport ? getTextSubTitle(R.string.virtual_key_settings) : "⚙";
|
||||
case 2:
|
||||
return "+";
|
||||
case 3:
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ public class SoftFilterKey extends SoftKey {
|
|||
public SoftFilterKey(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); setFontSize(); }
|
||||
|
||||
private void setFontSize() {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE / 0.85f;
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_SIZE / 0.85f;
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE / 0.85f;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -3,6 +3,8 @@ package io.github.sspanak.tt9.ui.main.keys;
|
|||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
|
||||
public class SoftInputModeKey extends SoftKey {
|
||||
public SoftInputModeKey(Context context) {
|
||||
super(context);
|
||||
|
|
@ -28,12 +30,16 @@ public class SoftInputModeKey extends SoftKey {
|
|||
return false;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean handleRelease() {
|
||||
return validateTT9Handler() && tt9.onKeyNextInputMode(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getNoEmojiTitle() {
|
||||
return R.string.virtual_key_input_mode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render() {
|
||||
super.render();
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@ import androidx.core.content.ContextCompat;
|
|||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.util.Characters;
|
||||
import io.github.sspanak.tt9.util.Logger;
|
||||
|
||||
public class SoftKey extends androidx.appcompat.widget.AppCompatButton implements View.OnTouchListener, View.OnLongClickListener {
|
||||
|
|
@ -24,8 +25,8 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
|
||||
protected TraditionalT9 tt9;
|
||||
|
||||
protected float complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE;
|
||||
protected float complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_SIZE;
|
||||
protected float complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
protected float complexLabelSubTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_SUB_TITLE_RELATIVE_SIZE;
|
||||
|
||||
private boolean hold = false;
|
||||
private boolean repeat = false;
|
||||
|
|
@ -179,6 +180,13 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* getNoEmojiTitle
|
||||
* Generates a text representation of the key title, when emojis are not supported and getTitle()
|
||||
* is meant to return an emoji.
|
||||
*/
|
||||
protected int getNoEmojiTitle() { return 0; }
|
||||
|
||||
/**
|
||||
* getSubTitle
|
||||
* Generates a String describing what the key does.
|
||||
|
|
@ -190,6 +198,18 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a meaningful key title depending on the current emoji support.
|
||||
*/
|
||||
private String getTitleCompat() {
|
||||
if (Characters.noEmojiSupported() && getNoEmojiTitle() > 0) {
|
||||
setTextSize(SettingsStore.SOFT_KEY_TITLE_SIZE);
|
||||
return getContext().getString(getNoEmojiTitle());
|
||||
} else {
|
||||
return getTitle();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* render
|
||||
* Sets the key label using "getTitle()" and "getSubtitle()" or if they both
|
||||
|
|
@ -200,7 +220,7 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
* have their font size adjusted to fit inside the key.
|
||||
*/
|
||||
public void render() {
|
||||
String title = getTitle();
|
||||
String title = getTitleCompat();
|
||||
String subtitle = getSubTitle();
|
||||
|
||||
if (title == null) {
|
||||
|
|
@ -216,8 +236,8 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
sb.append('\n');
|
||||
sb.append(subtitle);
|
||||
|
||||
float padding = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE;
|
||||
if (complexLabelTitleSize == SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_SIZE) {
|
||||
float padding = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
if (complexLabelTitleSize == SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE) {
|
||||
padding /= 10;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,17 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
|
||||
public class SoftKeyCommandPalette extends SoftKey {
|
||||
public SoftKeyCommandPalette(Context context) { super(context); }
|
||||
public SoftKeyCommandPalette(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeyCommandPalette(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
@Override
|
||||
protected int getNoEmojiTitle() {
|
||||
return R.string.virtual_key_command_palette;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
package io.github.sspanak.tt9.ui.main.keys;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
|
||||
public class SoftKeySettings extends SoftKey {
|
||||
public SoftKeySettings(Context context) { super(context); }
|
||||
public SoftKeySettings(Context context, AttributeSet attrs) { super(context, attrs); }
|
||||
public SoftKeySettings(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); }
|
||||
|
||||
|
||||
@Override
|
||||
protected int getNoEmojiTitle() {
|
||||
return R.string.virtual_key_settings;
|
||||
}
|
||||
}
|
||||
|
|
@ -60,10 +60,10 @@ public class SoftNumberKey extends SoftKey {
|
|||
int number = getNumber(getId());
|
||||
|
||||
if (tt9 != null && !tt9.isInputModeNumeric() && LanguageKind.isArabic(tt9.getLanguage())) {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_SIZE;
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_ARABIC_TITLE_RELATIVE_SIZE;
|
||||
return tt9.getLanguage().getKeyNumber(number);
|
||||
} else {
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_SIZE;
|
||||
complexLabelTitleSize = SettingsStore.SOFT_KEY_COMPLEX_LABEL_TITLE_RELATIVE_SIZE;
|
||||
return String.valueOf(number);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@
|
|||
android:layoutDirection="ltr"
|
||||
tools:ignore="HardcodedText,KeyboardInaccessibleWidget">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKey
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeySettings
|
||||
android:id="@+id/soft_key_settings"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
|
|
@ -131,7 +131,6 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="@dimen/numpad_control_key_layout_weight"
|
||||
android:text="⌫"
|
||||
android:textSize="@dimen/soft_key_icon_size" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@
|
|||
android:orientation="horizontal"
|
||||
tools:ignore="HardcodedText,KeyboardInaccessibleWidget">
|
||||
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKey
|
||||
<io.github.sspanak.tt9.ui.main.keys.SoftKeyCommandPalette
|
||||
android:id="@+id/soft_key_command_palette"
|
||||
style="@android:style/Widget.Holo.Button.Borderless"
|
||||
android:layout_width="0dp"
|
||||
|
|
|
|||
|
|
@ -166,6 +166,12 @@
|
|||
<string name="char_newline">New Line</string>
|
||||
<string name="char_space">Space</string>
|
||||
|
||||
<string name="virtual_key_change_keyboard" translatable="false">Kbd</string>
|
||||
<string name="virtual_key_command_palette" translatable="false">Cmd</string>
|
||||
<string name="virtual_key_del" translatable="false">Del</string>
|
||||
<string name="virtual_key_input_mode" translatable="false">Mode</string>
|
||||
<string name="virtual_key_settings" translatable="false">Cfg</string>
|
||||
|
||||
<string name="voice_input_listening">Speak</string>
|
||||
<string name="voice_input_stopping">Turning off the microphone…</string>
|
||||
<string name="voice_input_mic_permission_is_needed">You must allow the microphone permission to use voice input.</string>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue