fixed the suggestions orientation when typing in RTL languages
This commit is contained in:
parent
6a279838f9
commit
aa828070c6
5 changed files with 59 additions and 19 deletions
|
|
@ -261,7 +261,7 @@ public abstract class HotkeyHandler extends CommandHandler {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
backward = isSystemRTL != backward;
|
backward = isLanguageRTL != backward;
|
||||||
scrollSuggestions(backward);
|
scrollSuggestions(backward);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
@ -279,6 +279,7 @@ public abstract class HotkeyHandler extends CommandHandler {
|
||||||
|
|
||||||
suggestionOps.cancelDelayedAccept();
|
suggestionOps.cancelDelayedAccept();
|
||||||
nextLang();
|
nextLang();
|
||||||
|
detectRTL();
|
||||||
|
|
||||||
// for languages that do not have ABC or Predictive, make sure we remain in valid state
|
// for languages that do not have ABC or Predictive, make sure we remain in valid state
|
||||||
if (!mInputMode.changeLanguage(mLanguage)) {
|
if (!mInputMode.changeLanguage(mLanguage)) {
|
||||||
|
|
@ -288,6 +289,7 @@ public abstract class HotkeyHandler extends CommandHandler {
|
||||||
|
|
||||||
getSuggestions(null);
|
getSuggestions(null);
|
||||||
statusBar.setText(mInputMode);
|
statusBar.setText(mInputMode);
|
||||||
|
suggestionOps.setRTL(isLanguageRTL);
|
||||||
mainView.render();
|
mainView.render();
|
||||||
if (!suggestionOps.isEmpty() || settings.isMainLayoutStealth()) {
|
if (!suggestionOps.isEmpty() || settings.isMainLayoutStealth()) {
|
||||||
UI.toastShortSingle(this, mInputMode.getClass().getSimpleName(), mInputMode.toString());
|
UI.toastShortSingle(this, mInputMode.getClass().getSimpleName(), mInputMode.toString());
|
||||||
|
|
|
||||||
|
|
@ -10,16 +10,24 @@ import io.github.sspanak.tt9.util.Clipboard;
|
||||||
import io.github.sspanak.tt9.util.Ternary;
|
import io.github.sspanak.tt9.util.Ternary;
|
||||||
|
|
||||||
abstract public class TextEditingHandler extends VoiceHandler {
|
abstract public class TextEditingHandler extends VoiceHandler {
|
||||||
protected boolean isSystemRTL;
|
protected boolean isLanguageRTL;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean onStart(InputConnection connection, EditorInfo field) {
|
protected boolean onStart(InputConnection connection, EditorInfo field) {
|
||||||
isSystemRTL = LanguageKind.isRTL(LanguageCollection.getDefault());
|
detectRTL();
|
||||||
|
suggestionOps.setRTL(isLanguageRTL);
|
||||||
return super.onStart(connection, field);
|
return super.onStart(connection, field);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void detectRTL() {
|
||||||
|
isLanguageRTL = LanguageKind.isRTL(
|
||||||
|
LanguageCollection.getLanguage(settings.getInputLanguage())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
protected boolean onNumber(int key, boolean hold, int repeat) {
|
protected boolean onNumber(int key, boolean hold, int repeat) {
|
||||||
if (!shouldBeOff() && mainView.isTextEditingPaletteShown()) {
|
if (!shouldBeOff() && mainView.isTextEditingPaletteShown()) {
|
||||||
onCommand(key);
|
onCommand(key);
|
||||||
|
|
@ -48,22 +56,22 @@ abstract public class TextEditingHandler extends VoiceHandler {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
textSelection.selectNextChar(!isSystemRTL);
|
textSelection.selectNextChar(!isLanguageRTL);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
textSelection.clear();
|
textSelection.clear();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
textSelection.selectNextChar(isSystemRTL);
|
textSelection.selectNextChar(isLanguageRTL);
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
textSelection.selectNextWord(!isSystemRTL);
|
textSelection.selectNextWord(!isLanguageRTL);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
textSelection.selectAll();
|
textSelection.selectAll();
|
||||||
break;
|
break;
|
||||||
case 6:
|
case 6:
|
||||||
textSelection.selectNextWord(isSystemRTL);
|
textSelection.selectNextWord(isLanguageRTL);
|
||||||
break;
|
break;
|
||||||
case 7:
|
case 7:
|
||||||
textSelection.cut(textField);
|
textSelection.cut(textField);
|
||||||
|
|
|
||||||
|
|
@ -29,6 +29,11 @@ public class SuggestionOps {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setRTL(boolean yes) {
|
||||||
|
suggestionBar.setRTL(yes);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setTextField(@Nullable TextField textField) {
|
public void setTextField(@Nullable TextField textField) {
|
||||||
this.textField = textField;
|
this.textField = textField;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -143,6 +143,11 @@ public class SuggestionsBar {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setRTL(boolean yes) {
|
||||||
|
mView.setLayoutDirection(yes ? View.LAYOUT_DIRECTION_RTL : View.LAYOUT_DIRECTION_LTR);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public void setSuggestions(List<String> newSuggestions, int initialSel, boolean containsGenerated) {
|
public void setSuggestions(List<String> newSuggestions, int initialSel, boolean containsGenerated) {
|
||||||
ecoSetBackground(newSuggestions);
|
ecoSetBackground(newSuggestions);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -151,17 +151,21 @@
|
||||||
|
|
||||||
<!-- The keyboard itself -->
|
<!-- The keyboard itself -->
|
||||||
<style name="TTheme.Numpad" parent="TTheme.Keyboard">
|
<style name="TTheme.Numpad" parent="TTheme.Keyboard">
|
||||||
<item name="android:layout_width">0dp</item>
|
|
||||||
<item name="android:layout_height">wrap_content</item>
|
|
||||||
<item name="android:orientation">vertical</item>
|
|
||||||
<item name="layout_constraintEnd_toEndOf">parent</item>
|
<item name="layout_constraintEnd_toEndOf">parent</item>
|
||||||
<item name="layout_constraintStart_toStartOf">parent</item>
|
<item name="layout_constraintStart_toStartOf">parent</item>
|
||||||
<item name="layout_constraintTop_toTopOf">parent</item>
|
<item name="layout_constraintTop_toTopOf">parent</item>
|
||||||
|
<item name="android:layoutDirection">ltr</item>
|
||||||
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
<item name="android:layout_width">0dp</item>
|
||||||
|
<item name="android:orientation">vertical</item>
|
||||||
<item name="android:paddingBottom">@dimen/numpad_padding_bottom</item>
|
<item name="android:paddingBottom">@dimen/numpad_padding_bottom</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
<!-- Status Bar -->
|
<!--*******************************************
|
||||||
|
Numpad Status Bar
|
||||||
|
*******************************************-->
|
||||||
|
|
||||||
<style name="TTheme.Numpad.StatusBar.Wrapper" parent="">
|
<style name="TTheme.Numpad.StatusBar.Wrapper" parent="">
|
||||||
<item name="android:layout_height">@dimen/numpad_suggestion_height</item>
|
<item name="android:layout_height">@dimen/numpad_suggestion_height</item>
|
||||||
<item name="android:layout_width">0dp</item>
|
<item name="android:layout_width">0dp</item>
|
||||||
|
|
@ -179,7 +183,11 @@
|
||||||
<item name="android:textSize">@dimen/numpad_suggestion_font_size</item>
|
<item name="android:textSize">@dimen/numpad_suggestion_font_size</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Key Columns -->
|
|
||||||
|
<!--*******************************************
|
||||||
|
Numpad Columns
|
||||||
|
*******************************************-->
|
||||||
|
|
||||||
<style name="TTheme.Numpad.Column" parent="">
|
<style name="TTheme.Numpad.Column" parent="">
|
||||||
<item name="android:layout_width">0dp</item>
|
<item name="android:layout_width">0dp</item>
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
|
|
@ -191,6 +199,11 @@
|
||||||
<item name="android:layout_weight">@dimen/numpad_function_key_layout_weight</item>
|
<item name="android:layout_weight">@dimen/numpad_function_key_layout_weight</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
|
||||||
|
<!--*******************************************
|
||||||
|
Numpad Key Overlays
|
||||||
|
*******************************************-->
|
||||||
|
|
||||||
<!-- Key Overlay (allows for a central icon and corner labels or icons) -->
|
<!-- Key Overlay (allows for a central icon and corner labels or icons) -->
|
||||||
<style name="TTheme.Numpad.Key.Overlay.Wrapper" parent="">
|
<style name="TTheme.Numpad.Key.Overlay.Wrapper" parent="">
|
||||||
<item name="android:layout_height">@dimen/numpad_key_height</item>
|
<item name="android:layout_height">@dimen/numpad_key_height</item>
|
||||||
|
|
@ -199,6 +212,13 @@
|
||||||
<item name="android:padding">0dp</item>
|
<item name="android:padding">0dp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<style name="TTheme.Numpad.Key.Overlay.Element" parent="">
|
||||||
|
<item name="android:layout_height">match_parent</item>
|
||||||
|
<item name="android:layout_width">match_parent</item>
|
||||||
|
<item name="android:translationZ">@dimen/numpad_key_overlay_z</item>
|
||||||
|
</style>
|
||||||
|
|
||||||
|
<!-- Overlay: Central Icon -->
|
||||||
<style name="TTheme.Numpad.Key.Overlay.Icon" parent="">
|
<style name="TTheme.Numpad.Key.Overlay.Icon" parent="">
|
||||||
<item name="android:layout_height">wrap_content</item>
|
<item name="android:layout_height">wrap_content</item>
|
||||||
<item name="android:layout_width">wrap_content</item>
|
<item name="android:layout_width">wrap_content</item>
|
||||||
|
|
@ -208,12 +228,7 @@
|
||||||
<item name="android:tint">@color/keyboard_text_color</item>
|
<item name="android:tint">@color/keyboard_text_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<style name="TTheme.Numpad.Key.Overlay.Element" parent="">
|
<!-- Overlay: Hold Icon -->
|
||||||
<item name="android:layout_height">match_parent</item>
|
|
||||||
<item name="android:layout_width">match_parent</item>
|
|
||||||
<item name="android:translationZ">@dimen/numpad_key_overlay_z</item>
|
|
||||||
</style>
|
|
||||||
|
|
||||||
<style name="TTheme.Numpad.Key.Overlay.HoldIcon.Wrapper" parent="TTheme.Numpad.Key.Overlay.Element">
|
<style name="TTheme.Numpad.Key.Overlay.HoldIcon.Wrapper" parent="TTheme.Numpad.Key.Overlay.Element">
|
||||||
<item name="android:gravity">top|right</item>
|
<item name="android:gravity">top|right</item>
|
||||||
<item name="android:paddingRight">3dp</item>
|
<item name="android:paddingRight">3dp</item>
|
||||||
|
|
@ -227,6 +242,7 @@
|
||||||
<item name="android:tint">@color/key_fn_alternative_color</item>
|
<item name="android:tint">@color/key_fn_alternative_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Overlay: Hold Text -->
|
||||||
<style name="TTheme.Numpad.Key.Overlay.Text" parent="TTheme.Numpad.Key.Overlay.Element">
|
<style name="TTheme.Numpad.Key.Overlay.Text" parent="TTheme.Numpad.Key.Overlay.Element">
|
||||||
<item name="android:textSize">@dimen/numpad_key_overlay_text_size</item>
|
<item name="android:textSize">@dimen/numpad_key_overlay_text_size</item>
|
||||||
<item name="android:textColor">@color/key_fn_alternative_color</item>
|
<item name="android:textColor">@color/key_fn_alternative_color</item>
|
||||||
|
|
@ -241,6 +257,7 @@
|
||||||
<item name="android:textColor">@color/key_num_alternative_color</item>
|
<item name="android:textColor">@color/key_num_alternative_color</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
|
<!-- Overlay: Side Text -->
|
||||||
<style name="TTheme.Numpad.Key.Overlay.Text.Top" parent="TTheme.Numpad.Key.Overlay.Text">
|
<style name="TTheme.Numpad.Key.Overlay.Text.Top" parent="TTheme.Numpad.Key.Overlay.Text">
|
||||||
<item name="android:gravity">top|center</item>
|
<item name="android:gravity">top|center</item>
|
||||||
<item name="android:layout_marginTop">@dimen/numpad_key_overlay_side_text_margin</item>
|
<item name="android:layout_marginTop">@dimen/numpad_key_overlay_side_text_margin</item>
|
||||||
|
|
@ -261,7 +278,10 @@
|
||||||
<item name="android:layout_marginLeft">@dimen/numpad_key_overlay_side_text_margin</item>
|
<item name="android:layout_marginLeft">@dimen/numpad_key_overlay_side_text_margin</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- General Purpose Key -->
|
|
||||||
|
<!--*******************************************
|
||||||
|
Numpad Keys
|
||||||
|
*******************************************-->
|
||||||
<style name="TTheme.Numpad.Key" parent="Widget.MaterialComponents.Button">
|
<style name="TTheme.Numpad.Key" parent="Widget.MaterialComponents.Button">
|
||||||
<item name="android:layout_width">match_parent</item>
|
<item name="android:layout_width">match_parent</item>
|
||||||
<item name="android:layout_height">@dimen/numpad_key_height</item>
|
<item name="android:layout_height">@dimen/numpad_key_height</item>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue