added numpad separators and imporved the overall readability
This commit is contained in:
parent
eb67ab18ea
commit
e5cf2f1fce
7 changed files with 87 additions and 17 deletions
|
|
@ -6,6 +6,7 @@ import android.view.ViewGroup;
|
|||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.github.sspanak.tt9.R;
|
||||
import io.github.sspanak.tt9.ime.TraditionalT9;
|
||||
|
|
@ -32,6 +33,18 @@ class MainLayoutNumpad extends BaseMainLayout {
|
|||
for (SoftKey key : getKeys()) {
|
||||
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
|
||||
|
|
@ -61,4 +74,18 @@ class MainLayoutNumpad extends BaseMainLayout {
|
|||
|
||||
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)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ import io.github.sspanak.tt9.ime.TraditionalT9;
|
|||
|
||||
public class SoftKey extends androidx.appcompat.widget.AppCompatButton implements View.OnTouchListener {
|
||||
protected TraditionalT9 tt9;
|
||||
protected float COMPLEX_LABEL_TITLE_SIZE = 0.55f;
|
||||
protected float COMPLEX_LABEL_SUB_TITLE_SIZE = 0.8f;
|
||||
|
||||
public SoftKey(Context 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...
|
||||
*/
|
||||
protected String getKeyNameLabel() {
|
||||
protected String getTitle() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* getSubTitle
|
||||
* Generates a String describing what the key does.
|
||||
* 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;
|
||||
}
|
||||
|
||||
|
|
@ -103,8 +107,8 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
* have their font size adjusted to fit inside the key.
|
||||
*/
|
||||
public void render() {
|
||||
String name = getKeyNameLabel();
|
||||
String func = getKeyFunctionLabel();
|
||||
String name = getTitle();
|
||||
String func = getSubTitle();
|
||||
|
||||
if (name == null) {
|
||||
return;
|
||||
|
|
@ -117,9 +121,9 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
|
|||
sb.append('\n');
|
||||
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 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ public class SoftNumberKey extends SoftKey {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getKeyNameLabel() {
|
||||
protected String getTitle() {
|
||||
return String.valueOf(getNumber(getId()));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getKeyFunctionLabel() {
|
||||
protected String getSubTitle() {
|
||||
if (tt9 == null || tt9.getSettings().getInputMode() == InputMode.MODE_123) {
|
||||
return null;
|
||||
}
|
||||
|
|
@ -79,6 +79,7 @@ public class SoftNumberKey extends SoftKey {
|
|||
}
|
||||
|
||||
if (number == 0) {
|
||||
COMPLEX_LABEL_SUB_TITLE_SIZE = 1;
|
||||
return "␣";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ public class SoftPunctuationKey extends SoftKey {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getKeyNameLabel() {
|
||||
protected String getTitle() {
|
||||
int keyId = getId();
|
||||
|
||||
if (tt9.getSettings().getInputMode() == InputMode.MODE_123) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue