fixes for previous commit

This commit is contained in:
Yuriy Liskov
2018-04-23 00:04:11 +03:00
parent b3afc8e7f2
commit d05415fb65
2 changed files with 19 additions and 9 deletions

View File

@@ -124,25 +124,33 @@ public class LeanbackKeyboardView extends FrameLayout {
}
private CharSequence getSpecialLowerCase(CharSequence label) {
String realLabel = label.toString();
if (realLabel.contains("|")) {
String[] labels = realLabel.split("\\|");
return labels[0];
String[] labels = splitLabels(label);
if (labels != null) {
return labels[0]; // lower case char
}
return label.toString().toLowerCase();
}
private CharSequence getSpecialUpperCase(CharSequence label) {
String realLabel = label.toString();
if (realLabel.contains("|")) {
String[] labels = realLabel.split("\\|");
return labels[1];
String[] labels = splitLabels(label);
if (labels != null) {
return labels[1]; // upper case char
}
return label.toString().toUpperCase();
}
private String[] splitLabels(CharSequence label) {
String realLabel = label.toString();
String[] labels = realLabel.split("\\|");
return labels.length == 2 ? labels : null; // remember, we encoding two chars
}
@SuppressLint("NewApi")
private ImageView createKeyImageView(final int keyIndex) {
Rect padding = mPadding;

View File

@@ -17,7 +17,9 @@
<Key android:codes="-5" android:keyEdgeFlags="right" android:keyLabel="@string/keyboardview_keycode_delete" android:keyIcon="@drawable/ic_ime_delete" />
</Row>
<Row>
<Key android:popupKeyboard="@xml/accent_q_th" android:keyLabel="ฝ" android:keyEdgeFlags="left" />
<!-- NOTE: example of adding different chars to uppercase/lowercase states -->
<!-- format is: android:keyLabel="lower_char|upper_char" e.g. android:keyLabel="ฝ|๒" -->
<Key android:popupKeyboard="@xml/accent_q_th" android:keyLabel="ฝ|๒" android:keyEdgeFlags="left" />
<Key android:popupKeyboard="@xml/accent_w_th" android:keyLabel="๒" />
<Key android:popupKeyboard="@xml/accent_e_th" android:keyLabel="๓" />
<Key android:popupKeyboard="@xml/accent_r_th" android:keyLabel="ู" />