1
0
Fork 0

xiaomi keyboard hack

This commit is contained in:
sspanak 2024-06-25 17:20:37 +03:00 committed by Dimo Karaivanov
parent b833197f51
commit dfa837dce9
2 changed files with 17 additions and 4 deletions

View file

@ -10,11 +10,17 @@ import android.view.KeyEvent;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
public class DeviceInfo { public class DeviceInfo {
private static Boolean isRobo = null;
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
// See: https://github.com/sspanak/tt9/issues/549
if (DeviceInfo.isXiaomi()) {
return true;
}
Configuration configuration = context.getResources().getConfiguration();
return return
context.getResources().getConfiguration().keyboard == Configuration.KEYBOARD_NOKEYS (configuration.keyboard == Configuration.KEYBOARD_NOKEYS || configuration.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES)
&& !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_STAR) && !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_STAR)
&& !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POUND); && !KeyCharacterMap.deviceHasKey(KeyEvent.KEYCODE_POUND);
} }
@ -43,6 +49,10 @@ public class DeviceInfo {
return isSonim() && Build.VERSION.SDK_INT == Build.VERSION_CODES.R && noTouchScreen(context); return isSonim() && Build.VERSION.SDK_INT == Build.VERSION_CODES.R && noTouchScreen(context);
} }
public static boolean isXiaomi() {
return Build.MANUFACTURER.equals("Xiaomi");
}
@NonNull @NonNull
@Override @Override
public String toString() { public String toString() {

View file

@ -42,6 +42,7 @@ public class InputType extends StandardInputType {
public boolean isDumbPhoneDialer(Context context) { public boolean isDumbPhoneDialer(Context context) {
// the inputType is not always TYPE_CLASS_PHONE on all devices, so we must not filter by that.
return field.packageName.endsWith(".dialer") && !DeviceInfo.noKeyboard(context); return field.packageName.endsWith(".dialer") && !DeviceInfo.noKeyboard(context);
} }
@ -133,8 +134,10 @@ public class InputType extends StandardInputType {
* <a href="https://github.com/sspanak/tt9/issues/46">the initial GitHub issue about Qin F21 Pro+</a> * <a href="https://github.com/sspanak/tt9/issues/46">the initial GitHub issue about Qin F21 Pro+</a>
* <a href="https://github.com/sspanak/tt9/pull/326">the PR about calculators</a> * <a href="https://github.com/sspanak/tt9/pull/326">the PR about calculators</a>
* <a href="https://github.com/sspanak/tt9/issues/300">Dialer not detected correctly on LG X100S</a> * <a href="https://github.com/sspanak/tt9/issues/300">Dialer not detected correctly on LG X100S</a>
* [NO ISSUE] On touchscreen-only phones, in the Dialer app, we can't switch to passthrough, because * [NO ISSUE] On touchscreen-only phones, in the Dialer app, we mustn't switch to passthrough, because
* they don't have a physical keyboard. * they don't have a physical keyboard.
* <a href="https://github.com/sspanak/tt9/issues/538">Beeps on CAT S22 Flip</a>
* <a href="https://github.com/sspanak/tt9/issues/549">The UI does not appear on Xiaomi Redmi 12c</a>
*/ */
protected boolean isSpecialNumeric(Context context) { protected boolean isSpecialNumeric(Context context) {
return return