slightly faster device hacks by detecting the device make and model only once
This commit is contained in:
parent
7a00f0ee3a
commit
6d34082209
4 changed files with 18 additions and 37 deletions
|
|
@ -11,8 +11,14 @@ import android.view.KeyEvent;
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
|
|
||||||
public class HardwareInfo {
|
public class HardwareInfo {
|
||||||
|
public static final boolean IS_CAT_S22_FLIP = Build.MANUFACTURER.equals("Cat") && Build.MODEL.contains("S22");
|
||||||
|
public static final boolean IS_LG_X100S = Build.MANUFACTURER.equals("LGE") && Build.MODEL.contains("X100S");
|
||||||
|
public static final boolean IS_QIN_F21 = Build.MANUFACTURER.equals("DuoQin") && Build.MODEL.contains("F21");
|
||||||
public static final boolean IS_SAMSUNG = Build.MANUFACTURER.equals("samsung") || Build.MANUFACTURER.equals("Samsung") || Build.MANUFACTURER.equals("SAMSUNG");
|
public static final boolean IS_SAMSUNG = Build.MANUFACTURER.equals("samsung") || Build.MANUFACTURER.equals("Samsung") || Build.MANUFACTURER.equals("SAMSUNG");
|
||||||
|
public static final boolean IS_SONIM = Build.MANUFACTURER.equals("Sonimtech");
|
||||||
|
public static final boolean IS_XIAOMI = Build.MANUFACTURER.equals("Xiaomi");
|
||||||
|
|
||||||
|
private static Boolean NO_TOUCH_SCREEN = null;
|
||||||
|
|
||||||
private static Resources resources;
|
private static Resources resources;
|
||||||
|
|
||||||
|
|
@ -54,7 +60,7 @@ public class HardwareInfo {
|
||||||
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
|
||||||
if (isXiaomi()) {
|
if (IS_XIAOMI) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -68,37 +74,15 @@ public class HardwareInfo {
|
||||||
|
|
||||||
|
|
||||||
public static boolean noTouchScreen(Context context) {
|
public static boolean noTouchScreen(Context context) {
|
||||||
return !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
|
if (NO_TOUCH_SCREEN == null) {
|
||||||
}
|
NO_TOUCH_SCREEN = !context.getPackageManager().hasSystemFeature(PackageManager.FEATURE_TOUCHSCREEN);
|
||||||
|
}
|
||||||
|
return NO_TOUCH_SCREEN;
|
||||||
public static boolean isCatS22Flip() {
|
|
||||||
return Build.MANUFACTURER.equals("Cat") && Build.MODEL.contains("S22");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isLgX100S() {
|
|
||||||
return Build.MANUFACTURER.equals("LGE") && Build.MODEL.contains("X100S");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isQinF21() {
|
|
||||||
return Build.MANUFACTURER.equals("DuoQin") && Build.MODEL.contains("F21");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSonim() {
|
|
||||||
return Build.MANUFACTURER.equals("Sonimtech");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static boolean isSonimGen2(Context context) {
|
public static boolean isSonimGen2(Context context) {
|
||||||
return isSonim() && DeviceInfo.AT_LEAST_ANDROID_11 && noTouchScreen(context);
|
return IS_SONIM && DeviceInfo.AT_LEAST_ANDROID_11 && noTouchScreen(context);
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public static boolean isXiaomi() {
|
|
||||||
return Build.MANUFACTURER.equals("Xiaomi");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@ public class InputType extends StandardInputType {
|
||||||
public boolean isLgX100SDialer() {
|
public boolean isLgX100SDialer() {
|
||||||
int imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_ENTER_ACTION;
|
int imeOptions = EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_ENTER_ACTION;
|
||||||
return
|
return
|
||||||
DeviceInfo.isLgX100S()
|
DeviceInfo.IS_LG_X100S
|
||||||
&& isAppField("com.android.contacts", EditorInfo.TYPE_CLASS_PHONE)
|
&& isAppField("com.android.contacts", EditorInfo.TYPE_CLASS_PHONE)
|
||||||
&& ((field.imeOptions & imeOptions) == imeOptions);
|
&& ((field.imeOptions & imeOptions) == imeOptions);
|
||||||
}
|
}
|
||||||
|
|
@ -132,7 +132,7 @@ public class InputType extends StandardInputType {
|
||||||
*/
|
*/
|
||||||
boolean isSonimSearchField(int action) {
|
boolean isSonimSearchField(int action) {
|
||||||
return
|
return
|
||||||
DeviceInfo.isSonim() &&
|
DeviceInfo.IS_SONIM &&
|
||||||
field != null && (field.packageName.startsWith("com.android") || field.packageName.startsWith("com.sonim"))
|
field != null && (field.packageName.startsWith("com.android") || field.packageName.startsWith("com.sonim"))
|
||||||
&& (field.imeOptions & EditorInfo.IME_MASK_ACTION) == action
|
&& (field.imeOptions & EditorInfo.IME_MASK_ACTION) == action
|
||||||
&& (
|
&& (
|
||||||
|
|
|
||||||
|
|
@ -52,8 +52,8 @@ class SettingsHacks extends BaseSettings {
|
||||||
* and on <a href="https://github.com/sspanak/tt9/issues/399">CAT S22</a>.
|
* and on <a href="https://github.com/sspanak/tt9/issues/399">CAT S22</a>.
|
||||||
*/
|
*/
|
||||||
public int getKeyPadDebounceTime() {
|
public int getKeyPadDebounceTime() {
|
||||||
int defaultTime = DeviceInfo.isCatS22Flip() ? 50 : 0;
|
int defaultTime = DeviceInfo.IS_CAT_S22_FLIP ? 50 : 0;
|
||||||
defaultTime = DeviceInfo.isQinF21() ? 20 : defaultTime;
|
defaultTime = DeviceInfo.IS_QIN_F21 ? 20 : defaultTime;
|
||||||
return getStringifiedInt("pref_key_pad_debounce_time", defaultTime);
|
return getStringifiedInt("pref_key_pad_debounce_time", defaultTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ public class SettingsUI extends SettingsTyping {
|
||||||
public final static int NUMPAD_SHAPE_LONG_SPACE = 2;
|
public final static int NUMPAD_SHAPE_LONG_SPACE = 2;
|
||||||
|
|
||||||
private final int DEFAULT_LAYOUT;
|
private final int DEFAULT_LAYOUT;
|
||||||
private final boolean DEFAULT_STATUS_ICON;
|
|
||||||
|
|
||||||
public final static int MIN_WIDTH_PERCENT = 50;
|
public final static int MIN_WIDTH_PERCENT = 50;
|
||||||
private int DEFAULT_WIDTH_LANDSCAPE = 0;
|
private int DEFAULT_WIDTH_LANDSCAPE = 0;
|
||||||
|
|
@ -41,8 +40,6 @@ public class SettingsUI extends SettingsTyping {
|
||||||
} else {
|
} else {
|
||||||
DEFAULT_LAYOUT = LAYOUT_TRAY;
|
DEFAULT_LAYOUT = LAYOUT_TRAY;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFAULT_STATUS_ICON = DeviceInfo.isQinF21();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean areArrowKeysHidden() {
|
public boolean areArrowKeysHidden() {
|
||||||
|
|
@ -54,7 +51,7 @@ public class SettingsUI extends SettingsTyping {
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isStatusIconEnabled() {
|
public boolean isStatusIconEnabled() {
|
||||||
return prefs.getBoolean("pref_status_icon", DEFAULT_STATUS_ICON);
|
return prefs.getBoolean("pref_status_icon", DeviceInfo.IS_QIN_F21);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getDarkTheme() {
|
public boolean getDarkTheme() {
|
||||||
|
|
@ -118,7 +115,7 @@ public class SettingsUI extends SettingsTyping {
|
||||||
public boolean isNumpadShapeV() { return getNumpadShape() == NUMPAD_SHAPE_V; }
|
public boolean isNumpadShapeV() { return getNumpadShape() == NUMPAD_SHAPE_V; }
|
||||||
|
|
||||||
public int getSettingsFontSize() {
|
public int getSettingsFontSize() {
|
||||||
int defaultSize = DeviceInfo.isQinF21() || DeviceInfo.isLgX100S() ? FONT_SIZE_LARGE : FONT_SIZE_DEFAULT;
|
int defaultSize = DeviceInfo.IS_QIN_F21 || DeviceInfo.IS_LG_X100S ? FONT_SIZE_LARGE : FONT_SIZE_DEFAULT;
|
||||||
return getStringifiedInt("pref_font_size", defaultSize);
|
return getStringifiedInt("pref_font_size", defaultSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue