1
0
Fork 0

fixed virtual keyboard mirroring issues when a RTL locale is in use

This commit is contained in:
sspanak 2024-02-10 21:05:33 +02:00 committed by Dimo Karaivanov
parent f704dab97c
commit 520891a1d5
4 changed files with 28 additions and 8 deletions

View file

@ -12,7 +12,8 @@
<LinearLayout
android:id="@+id/status_bar_container"
android:layout_width="fill_parent"
android:layout_height="@dimen/numpad_candidate_height">
android:layout_height="@dimen/numpad_candidate_height"
android:layoutDirection="ltr">
<io.github.sspanak.tt9.ui.main.keys.SoftKey
android:id="@+id/soft_key_left_arrow"
@ -28,8 +29,9 @@
<FrameLayout
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="fill_parent">
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView
android:id="@+id/status_bar"
android:layout_width="match_parent"
@ -43,6 +45,7 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:layoutDirection="locale"
android:orientation="horizontal"
android:scrollbars="none" />
</FrameLayout>
@ -65,6 +68,7 @@
android:id="@+id/separator_candidates_bottom"
style="@style/numRowSeparator" />
<!-- Keypad Wrapper -->
<LinearLayout
android:id="@+id/main_soft_keys"
android:layout_width="match_parent"
@ -72,9 +76,11 @@
android:orientation="vertical"
android:paddingBottom="@dimen/numpad_padding_bottom">
<!-- Row 1 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/numpad_key_height"
android:layoutDirection="ltr"
tools:ignore="HardcodedText,KeyboardInaccessibleWidget">
<io.github.sspanak.tt9.ui.main.keys.SoftKey
@ -90,6 +96,7 @@
android:id="@+id/separator_1_1"
style="@style/numSeparator" />
<!-- Digits 1-3 -->
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_1"
style="@android:style/Widget.Holo.Button.Borderless"
@ -128,9 +135,11 @@
</LinearLayout>
<!-- Row 2 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/numpad_key_height"
android:layoutDirection="ltr"
tools:ignore="HardcodedText">
<io.github.sspanak.tt9.ui.main.keys.SoftKey
@ -146,6 +155,7 @@
android:id="@+id/separator_2_1"
style="@style/numSeparator" />
<!-- Digits 4-6 -->
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_4"
style="@android:style/Widget.Holo.Button.Borderless"
@ -184,9 +194,11 @@
</LinearLayout>
<!-- Row 3 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/numpad_key_height"
android:layoutDirection="ltr"
tools:ignore="HardcodedText">
<io.github.sspanak.tt9.ui.main.keys.SoftKeyInputMode
@ -202,6 +214,7 @@
android:id="@+id/separator_3_1"
style="@style/numSeparator" />
<!-- Digits 7-9 -->
<io.github.sspanak.tt9.ui.main.keys.SoftNumberKey
android:id="@+id/soft_key_7"
style="@android:style/Widget.Holo.Button.Borderless"
@ -241,7 +254,7 @@
</LinearLayout>
<!-- Row 4 -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="@dimen/numpad_key_height"
@ -293,7 +306,7 @@
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="@dimen/numpad_control_key_layout_weight"
android:text="@android:string/ok"
android:text="OK"
tools:ignore="ButtonOrder" />
</LinearLayout>

View file

@ -161,6 +161,10 @@ public class Language {
return getKeyCharacters(2, false).contains("а");
}
public boolean isRTL() {
return isArabic() || isHebrew();
}
public boolean isGreek() {
return getKeyCharacters(2, false).contains("α");
}

View file

@ -42,6 +42,6 @@ public class SoftBackspaceKey extends SoftKey {
}
Language language = getCurrentLanguage();
return language != null && (language.isArabic() || language.isHebrew()) ? "" : "";
return language != null && language.isRTL() ? "" : "";
}
}

View file

@ -142,11 +142,14 @@ public class SoftKey extends androidx.appcompat.widget.AppCompatButton implement
int keyId = getId();
boolean multiplePress = lastPressedKey == keyId;
Language language = getCurrentLanguage();
boolean isRTL = language != null && language.isRTL();
if (keyId == R.id.soft_key_add_word) return tt9.onKeyAddWord(false);
if (keyId == R.id.soft_key_filter_suggestions) return tt9.onKeyFilterSuggestions(false, multiplePress);
if (keyId == R.id.soft_key_clear_filter) return tt9.onKeyFilterClear(false);
if (keyId == R.id.soft_key_left_arrow) return tt9.onKeyScrollSuggestion(false, true);
if (keyId == R.id.soft_key_right_arrow) return tt9.onKeyScrollSuggestion(false, false);
if (keyId == R.id.soft_key_left_arrow) return tt9.onKeyScrollSuggestion(false, !isRTL);
if (keyId == R.id.soft_key_right_arrow) return tt9.onKeyScrollSuggestion(false, isRTL);
if (keyId == R.id.soft_key_language) return tt9.onKeyNextLanguage(false);
if (keyId == R.id.soft_key_ok) return tt9.onOK();
if (keyId == R.id.soft_key_settings) return tt9.onKeyShowSettings(false);