1
0
Fork 0

the default layout is 'small' only if the phone has no separate Backspace key

This commit is contained in:
sspanak 2024-11-13 18:43:05 +02:00 committed by Dimo Karaivanov
parent 9c9dd489fc
commit f3c701fd55
2 changed files with 22 additions and 10 deletions

View file

@ -18,6 +18,10 @@ public class DeviceInfo {
return context.getResources().getDisplayMetrics().heightPixels; return context.getResources().getDisplayMetrics().heightPixels;
} }
public static boolean noBackspaceKey(Context context) {
return !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_DEL) && !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_CLEAR);
}
public static boolean noKeyboard(Context context) { public static boolean noKeyboard(Context context) {
// all Xiaomi phones are only touchscreen, but some of them report they have a keyboard // all Xiaomi phones are only touchscreen, but some of them report they have a keyboard
// See: https://github.com/sspanak/tt9/issues/549 // See: https://github.com/sspanak/tt9/issues/549

View file

@ -19,15 +19,30 @@ public class SettingsUI extends SettingsTyping {
public final static int LAYOUT_SMALL = 3; public final static int LAYOUT_SMALL = 3;
public final static int LAYOUT_NUMPAD = 4; public final static int LAYOUT_NUMPAD = 4;
private final int DEFAULT_LAYOUT;
private final boolean DEFAULT_STATUS_ICON;
SettingsUI(Context context) { super(context); }
SettingsUI(Context context) {
super(context);
if (DeviceInfo.noKeyboard(context)) {
DEFAULT_LAYOUT = LAYOUT_NUMPAD;
} else if (DeviceInfo.noBackspaceKey(context) && !DeviceInfo.noTouchScreen(context)) {
DEFAULT_LAYOUT = LAYOUT_SMALL;
} else {
DEFAULT_LAYOUT = LAYOUT_TRAY;
}
DEFAULT_STATUS_ICON = DeviceInfo.isQinF21();
}
public boolean getAddWordsNoConfirmation() { public boolean getAddWordsNoConfirmation() {
return prefs.getBoolean("add_word_no_confirmation", false); return prefs.getBoolean("add_word_no_confirmation", false);
} }
public boolean isStatusIconEnabled() { public boolean isStatusIconEnabled() {
return prefs.getBoolean("pref_status_icon", DeviceInfo.isQinF21()); return prefs.getBoolean("pref_status_icon", DEFAULT_STATUS_ICON);
} }
public boolean getDarkTheme() { public boolean getDarkTheme() {
@ -84,14 +99,7 @@ public class SettingsUI extends SettingsTyping {
} }
public int getMainViewLayout() { public int getMainViewLayout() {
int defaultLayout = LAYOUT_SMALL; return getStringifiedInt("pref_layout_type", DEFAULT_LAYOUT);
if (DeviceInfo.noTouchScreen(context)) {
defaultLayout = LAYOUT_TRAY;
} else if (DeviceInfo.noKeyboard(context)) {
defaultLayout = LAYOUT_NUMPAD;
}
return getStringifiedInt("pref_layout_type", defaultLayout);
} }
public boolean isMainLayoutNumpad() { return getMainViewLayout() == LAYOUT_NUMPAD; } public boolean isMainLayoutNumpad() { return getMainViewLayout() == LAYOUT_NUMPAD; }