mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 15:32:48 +00:00
remove clipboard and settings keys while device is locked
fixes #271 only works with new parser, so issue still applies with some layouts
This commit is contained in:
parent
b2ae020d7e
commit
5a15e4f8f2
5 changed files with 20 additions and 22 deletions
|
@ -70,7 +70,7 @@ public final class KeyboardId {
|
||||||
public final int mMode;
|
public final int mMode;
|
||||||
public final int mElementId;
|
public final int mElementId;
|
||||||
public final EditorInfo mEditorInfo;
|
public final EditorInfo mEditorInfo;
|
||||||
public final boolean mClobberSettingsKey;
|
public final boolean mDeviceLocked;
|
||||||
public final boolean mNumberRowEnabled;
|
public final boolean mNumberRowEnabled;
|
||||||
public final boolean mLanguageSwitchKeyEnabled;
|
public final boolean mLanguageSwitchKeyEnabled;
|
||||||
public final boolean mEmojiKeyEnabled;
|
public final boolean mEmojiKeyEnabled;
|
||||||
|
@ -88,7 +88,7 @@ public final class KeyboardId {
|
||||||
mMode = params.mMode;
|
mMode = params.mMode;
|
||||||
mElementId = elementId;
|
mElementId = elementId;
|
||||||
mEditorInfo = params.mEditorInfo;
|
mEditorInfo = params.mEditorInfo;
|
||||||
mClobberSettingsKey = params.mNoSettingsKey;
|
mDeviceLocked = params.mDeviceLocked;
|
||||||
mNumberRowEnabled = params.mNumberRowEnabled;
|
mNumberRowEnabled = params.mNumberRowEnabled;
|
||||||
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
|
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
|
||||||
mEmojiKeyEnabled = params.mEmojiKeyEnabled;
|
mEmojiKeyEnabled = params.mEmojiKeyEnabled;
|
||||||
|
@ -108,7 +108,7 @@ public final class KeyboardId {
|
||||||
id.mWidth,
|
id.mWidth,
|
||||||
id.mHeight,
|
id.mHeight,
|
||||||
id.passwordInput(),
|
id.passwordInput(),
|
||||||
id.mClobberSettingsKey,
|
id.mDeviceLocked,
|
||||||
id.mHasShortcutKey,
|
id.mHasShortcutKey,
|
||||||
id.mNumberRowEnabled,
|
id.mNumberRowEnabled,
|
||||||
id.mLanguageSwitchKeyEnabled,
|
id.mLanguageSwitchKeyEnabled,
|
||||||
|
@ -131,7 +131,7 @@ public final class KeyboardId {
|
||||||
&& other.mWidth == mWidth
|
&& other.mWidth == mWidth
|
||||||
&& other.mHeight == mHeight
|
&& other.mHeight == mHeight
|
||||||
&& other.passwordInput() == passwordInput()
|
&& other.passwordInput() == passwordInput()
|
||||||
&& other.mClobberSettingsKey == mClobberSettingsKey
|
&& other.mDeviceLocked == mDeviceLocked
|
||||||
&& other.mHasShortcutKey == mHasShortcutKey
|
&& other.mHasShortcutKey == mHasShortcutKey
|
||||||
&& other.mNumberRowEnabled == mNumberRowEnabled
|
&& other.mNumberRowEnabled == mNumberRowEnabled
|
||||||
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
||||||
|
@ -202,7 +202,7 @@ public final class KeyboardId {
|
||||||
actionName(imeAction()),
|
actionName(imeAction()),
|
||||||
(navigateNext() ? " navigateNext" : ""),
|
(navigateNext() ? " navigateNext" : ""),
|
||||||
(navigatePrevious() ? " navigatePrevious" : ""),
|
(navigatePrevious() ? " navigatePrevious" : ""),
|
||||||
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
|
(mDeviceLocked ? " deviceLocked" : ""),
|
||||||
(passwordInput() ? " passwordInput" : ""),
|
(passwordInput() ? " passwordInput" : ""),
|
||||||
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
||||||
(mNumberRowEnabled ? " numberRowEnabled" : ""),
|
(mNumberRowEnabled ? " numberRowEnabled" : ""),
|
||||||
|
|
|
@ -6,10 +6,12 @@
|
||||||
|
|
||||||
package org.dslul.openboard.inputmethod.keyboard;
|
package org.dslul.openboard.inputmethod.keyboard;
|
||||||
|
|
||||||
|
import android.app.KeyguardManager;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.res.Resources;
|
import android.content.res.Resources;
|
||||||
import android.content.res.TypedArray;
|
import android.content.res.TypedArray;
|
||||||
import android.content.res.XmlResourceParser;
|
import android.content.res.XmlResourceParser;
|
||||||
|
import android.os.Build;
|
||||||
import android.text.InputType;
|
import android.text.InputType;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.util.SparseArray;
|
import android.util.SparseArray;
|
||||||
|
@ -36,11 +38,9 @@ import java.lang.ref.SoftReference;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.FORCE_ASCII;
|
||||||
import static org.dslul.openboard.inputmethod.latin.common.Constants.ImeOption.NO_SETTINGS_KEY;
|
|
||||||
|
|
||||||
import androidx.annotation.NonNull;
|
import androidx.annotation.NonNull;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import androidx.core.os.UserManagerCompat;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class represents a set of keyboard layouts. Each of them represents a different keyboard
|
* This class represents a set of keyboard layouts. Each of them represents a different keyboard
|
||||||
|
@ -105,7 +105,7 @@ public final class KeyboardLayoutSet {
|
||||||
EditorInfo mEditorInfo;
|
EditorInfo mEditorInfo;
|
||||||
boolean mIsPasswordField;
|
boolean mIsPasswordField;
|
||||||
boolean mVoiceInputKeyEnabled;
|
boolean mVoiceInputKeyEnabled;
|
||||||
boolean mNoSettingsKey;
|
boolean mDeviceLocked;
|
||||||
boolean mNumberRowEnabled;
|
boolean mNumberRowEnabled;
|
||||||
boolean mLanguageSwitchKeyEnabled;
|
boolean mLanguageSwitchKeyEnabled;
|
||||||
boolean mEmojiKeyEnabled;
|
boolean mEmojiKeyEnabled;
|
||||||
|
@ -270,13 +270,14 @@ public final class KeyboardLayoutSet {
|
||||||
// TODO: Consolidate those with {@link InputAttributes}.
|
// TODO: Consolidate those with {@link InputAttributes}.
|
||||||
params.mEditorInfo = editorInfo;
|
params.mEditorInfo = editorInfo;
|
||||||
params.mIsPasswordField = InputTypeUtils.isPasswordInputType(editorInfo.inputType);
|
params.mIsPasswordField = InputTypeUtils.isPasswordInputType(editorInfo.inputType);
|
||||||
params.mNoSettingsKey = InputAttributes.inPrivateImeOptions(
|
|
||||||
mPackageName, NO_SETTINGS_KEY, editorInfo);
|
|
||||||
|
|
||||||
// When the device is still unlocked, features like showing the IME setting app need to
|
// When the device is still locked, features like showing the IME setting app need to
|
||||||
// be locked down.
|
// be locked down.
|
||||||
if (!UserManagerCompat.isUserUnlocked(context)) {
|
final KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||||
params.mNoSettingsKey = true;
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
|
||||||
|
params.mDeviceLocked = km.isDeviceLocked();
|
||||||
|
} else {
|
||||||
|
params.mDeviceLocked = km.isKeyguardLocked();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -518,14 +518,17 @@ class SimpleKeyboardParser(private val params: KeyboardParams, private val conte
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCommaMoreKeys(): Array<String> {
|
private fun getCommaMoreKeys(): Array<String> {
|
||||||
val keys = mutableListOf("!icon/clipboard_normal_key|!code/key_clipboard")
|
val keys = mutableListOf<String>()
|
||||||
|
if (!params.mId.mDeviceLocked)
|
||||||
|
keys.add("!icon/clipboard_normal_key|!code/key_clipboard")
|
||||||
if (!params.mId.mEmojiKeyEnabled)
|
if (!params.mId.mEmojiKeyEnabled)
|
||||||
keys.add("!icon/emoji_normal_key|!code/key_emoji")
|
keys.add("!icon/emoji_normal_key|!code/key_emoji")
|
||||||
if (!params.mId.mLanguageSwitchKeyEnabled)
|
if (!params.mId.mLanguageSwitchKeyEnabled)
|
||||||
keys.add("!icon/language_switch_key|!code/key_language_switch")
|
keys.add("!icon/language_switch_key|!code/key_language_switch")
|
||||||
if (!params.mId.mOneHandedModeEnabled)
|
if (!params.mId.mOneHandedModeEnabled)
|
||||||
keys.add("!icon/start_onehanded_mode_key|!code/key_start_onehanded")
|
keys.add("!icon/start_onehanded_mode_key|!code/key_start_onehanded")
|
||||||
keys.add("!icon/settings_key|!code/key_settings")
|
if (!params.mId.mDeviceLocked)
|
||||||
|
keys.add("!icon/settings_key|!code/key_settings")
|
||||||
return keys.toTypedArray()
|
return keys.toTypedArray()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -566,7 +566,7 @@ public class XmlKeyboardParser implements AutoCloseable {
|
||||||
final boolean passwordInputMatched = matchBoolean(caseAttr,
|
final boolean passwordInputMatched = matchBoolean(caseAttr,
|
||||||
R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
|
R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
|
||||||
final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
|
final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
|
||||||
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
R.styleable.Keyboard_Case_clobberSettingsKey, id.mDeviceLocked);
|
||||||
final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
|
final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
|
||||||
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
||||||
final boolean numberRowEnabledMatched = matchBoolean(caseAttr,
|
final boolean numberRowEnabledMatched = matchBoolean(caseAttr,
|
||||||
|
|
|
@ -38,12 +38,6 @@ public final class Constants {
|
||||||
*/
|
*/
|
||||||
public static final String NO_MICROPHONE = "noMicrophoneKey";
|
public static final String NO_MICROPHONE = "noMicrophoneKey";
|
||||||
|
|
||||||
/**
|
|
||||||
* The private IME option used to indicate that no settings key should be shown for a given
|
|
||||||
* text field.
|
|
||||||
*/
|
|
||||||
public static final String NO_SETTINGS_KEY = "noSettingsKey";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The private IME option used to indicate that the given text field needs ASCII code points
|
* The private IME option used to indicate that the given text field needs ASCII code points
|
||||||
* input.
|
* input.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue