1
0
Fork 0

added numpad separators and imporved the overall readability

This commit is contained in:
sspanak 2023-04-18 13:30:41 +03:00 committed by Dimo Karaivanov
parent eb67ab18ea
commit e5cf2f1fce
7 changed files with 87 additions and 17 deletions

View file

@ -52,6 +52,10 @@
android:text="⚙" android:text="⚙"
android:textSize="@dimen/soft_key_icon_size" /> android:textSize="@dimen/soft_key_icon_size" />
<View
android:id="@+id/separator_1_1"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey <io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_1" android:id="@+id/soft_key_1"
style="@android:style/Widget.Holo.Button.Borderless" style="@android:style/Widget.Holo.Button.Borderless"
@ -76,6 +80,10 @@
android:layout_weight="1" android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<View
android:id="@+id/separator_1_2"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftBackspaceKey <io.github.sspanak.tt9.ui.main.keys.SoftBackspaceKey
android:id="@+id/soft_key_backspace" android:id="@+id/soft_key_backspace"
style="@android:style/Widget.Holo.Button.Borderless" style="@android:style/Widget.Holo.Button.Borderless"
@ -83,8 +91,7 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="⌫" android:text="⌫"
android:textSize="@dimen/soft_key_icon_size" android:textSize="@dimen/soft_key_icon_size" />
tools:ignore="HardcodedText" />
</LinearLayout> </LinearLayout>
@ -99,7 +106,12 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="+WORD" /> android:text=""
android:textStyle="bold" />
<View
android:id="@+id/separator_2_1"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey <io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_4" android:id="@+id/soft_key_4"
@ -125,6 +137,10 @@
android:layout_weight="1" android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<View
android:id="@+id/separator_2_2"
style="@style/numSeparator" />
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
@ -143,7 +159,12 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="MODE" /> android:text="⌨️"
android:textSize="@dimen/soft_key_icon_size" />
<View
android:id="@+id/separator_3_1"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey <io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_7" android:id="@+id/soft_key_7"
@ -169,6 +190,10 @@
android:layout_weight="1" android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<View
android:id="@+id/separator_3_2"
style="@style/numSeparator" />
<View <View
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="0dp" android:layout_height="0dp"
@ -188,9 +213,11 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="match_parent"
android:layout_weight="1" android:layout_weight="1"
android:text="🌐" android:text="🌐" />
android:textSize="@dimen/soft_key_icon_size"
tools:ignore="HardcodedText" /> <View
android:id="@+id/separator_4_1"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftPunctuationKey <io.github.sspanak.tt9.ui.main.keys.SoftPunctuationKey
android:id="@+id/soft_key_punctuation_1" android:id="@+id/soft_key_punctuation_1"
@ -216,6 +243,10 @@
android:layout_weight="1" android:layout_weight="1"
android:textAppearance="@style/TextAppearance.AppCompat.Large" /> android:textAppearance="@style/TextAppearance.AppCompat.Large" />
<View
android:id="@+id/separator_4_2"
style="@style/numSeparator" />
<io.github.sspanak.tt9.ui.main.keys.SoftKey <io.github.sspanak.tt9.ui.main.keys.SoftKey
android:id="@+id/soft_key_ok" android:id="@+id/soft_key_ok"
style="@android:style/Widget.Holo.Button.Borderless" style="@android:style/Widget.Holo.Button.Borderless"

View file

@ -9,6 +9,7 @@
<color name="candidate_separator">#888888</color> <color name="candidate_separator">#888888</color>
<color name="numpad_background">#E7F0E7</color> <color name="numpad_background">#E7F0E7</color>
<color name="numpad_separator">#CCC</color>
<!-- Dark theme --> <!-- Dark theme -->
<color name="dark_button_text">#C0C0C0</color> <color name="dark_button_text">#C0C0C0</color>
@ -18,4 +19,5 @@
<color name="dark_candidate_selected">#555555</color> <color name="dark_candidate_selected">#555555</color>
<color name="dark_numpad_background">#353835</color> <color name="dark_numpad_background">#353835</color>
<color name="dark_numpad_separator">#555</color>
</resources> </resources>

View file

@ -6,4 +6,9 @@
<item name="android:layout_marginBottom">1dp</item> <item name="android:layout_marginBottom">1dp</item>
<item name="android:layout_marginTop">1dp</item> <item name="android:layout_marginTop">1dp</item>
</style> </style>
<style name="numSeparator">
<item name="android:layout_height">match_parent</item>
<item name="android:layout_width">1dp</item>
</style>
</resources> </resources>

View file

@ -6,6 +6,7 @@ import android.view.ViewGroup;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import io.github.sspanak.tt9.R; import io.github.sspanak.tt9.R;
import io.github.sspanak.tt9.ime.TraditionalT9; import io.github.sspanak.tt9.ime.TraditionalT9;
@ -32,6 +33,18 @@ class MainLayoutNumpad extends BaseMainLayout {
for (SoftKey key : getKeys()) { for (SoftKey key : getKeys()) {
key.setDarkTheme(darkEnabled); key.setDarkTheme(darkEnabled);
} }
// separators
int separatorColor = ContextCompat.getColor(
view.getContext(),
darkEnabled ? R.color.dark_numpad_separator : R.color.numpad_separator
);
for (View separator : getSeparators()) {
if (separator != null) {
separator.setBackgroundColor(separatorColor);
}
}
} }
@Override @Override
@ -61,4 +74,18 @@ class MainLayoutNumpad extends BaseMainLayout {
return keys; return keys;
} }
protected ArrayList<View> getSeparators() {
// it's fine... it's shorter, faster and easier to read than searching with 3 nested loops
return new ArrayList<>(Arrays.asList(
view.findViewById(R.id.separator_1_1),
view.findViewById(R.id.separator_1_2),
view.findViewById(R.id.separator_2_1),
view.findViewById(R.id.separator_2_2),
view.findViewById(R.id.separator_3_1),
view.findViewById(R.id.separator_3_2),
view.findViewById(R.id.separator_4_1),
view.findViewById(R.id.separator_4_2)
));
}
} }

View file

@ -18,6 +18,8 @@ import io.github.sspanak.tt9.ime.TraditionalT9;
public class SoftKey extends androidx.appcompat.widget.AppCompatButton implements View.OnTouchListener { public class SoftKey extends androidx.appcompat.widget.AppCompatButton implements View.OnTouchListener {
protected TraditionalT9 tt9; protected TraditionalT9 tt9;
protected float COMPLEX_LABEL_TITLE_SIZE = 0.55f;
protected float COMPLEX_LABEL_SUB_TITLE_SIZE = 0.8f;
public SoftKey(Context context) { public SoftKey(Context context) {
super(context); super(context);
@ -77,19 +79,21 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
} }
/** /**
* getTitle
* Generates the name of the key, for example: "OK", "Backspace", "1", etc... * Generates the name of the key, for example: "OK", "Backspace", "1", etc...
*/ */
protected String getKeyNameLabel() { protected String getTitle() {
return null; return null;
} }
/** /**
* getSubTitle
* Generates a String describing what the key does. * Generates a String describing what the key does.
* For example: "ABC" for 2-key; "" for Backspace key, "" for Settings key, and so on. * For example: "ABC" for 2-key; "" for Backspace key, "" for Settings key, and so on.
* *
* The function label is optional. * The sub title label is optional.
*/ */
protected String getKeyFunctionLabel() { protected String getSubTitle() {
return null; return null;
} }
@ -103,8 +107,8 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
* have their font size adjusted to fit inside the key. * have their font size adjusted to fit inside the key.
*/ */
public void render() { public void render() {
String name = getKeyNameLabel(); String name = getTitle();
String func = getKeyFunctionLabel(); String func = getSubTitle();
if (name == null) { if (name == null) {
return; return;
@ -117,9 +121,9 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
sb.append('\n'); sb.append('\n');
sb.append(func); sb.append(func);
sb.setSpan(new RelativeSizeSpan(0.55f), 0, 2, Spanned.SPAN_INCLUSIVE_INCLUSIVE); sb.setSpan(new RelativeSizeSpan(COMPLEX_LABEL_TITLE_SIZE), 0, 2, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
sb.setSpan(new StyleSpan(Typeface.ITALIC), 0, 2, Spanned.SPAN_EXCLUSIVE_INCLUSIVE); sb.setSpan(new StyleSpan(Typeface.ITALIC), 0, 2, Spanned.SPAN_EXCLUSIVE_INCLUSIVE);
sb.setSpan(new RelativeSizeSpan(0.75f), 1, sb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE); sb.setSpan(new RelativeSizeSpan(COMPLEX_LABEL_SUB_TITLE_SIZE), 1, sb.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
setText(sb); setText(sb);
} }

View file

@ -59,12 +59,12 @@ public class SoftNumberKey extends SoftKey {
} }
@Override @Override
protected String getKeyNameLabel() { protected String getTitle() {
return String.valueOf(getNumber(getId())); return String.valueOf(getNumber(getId()));
} }
@Override @Override
protected String getKeyFunctionLabel() { protected String getSubTitle() {
if (tt9 == null || tt9.getSettings().getInputMode() == InputMode.MODE_123) { if (tt9 == null || tt9.getSettings().getInputMode() == InputMode.MODE_123) {
return null; return null;
} }
@ -79,6 +79,7 @@ public class SoftNumberKey extends SoftKey {
} }
if (number == 0) { if (number == 0) {
COMPLEX_LABEL_SUB_TITLE_SIZE = 1;
return ""; return "";
} }

View file

@ -39,7 +39,7 @@ public class SoftPunctuationKey extends SoftKey {
} }
@Override @Override
protected String getKeyNameLabel() { protected String getTitle() {
int keyId = getId(); int keyId = getId();
if (tt9.getSettings().getInputMode() == InputMode.MODE_123) { if (tt9.getSettings().getInputMode() == InputMode.MODE_123) {