mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-05-17 07:22:45 +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 mElementId;
|
||||
public final EditorInfo mEditorInfo;
|
||||
public final boolean mClobberSettingsKey;
|
||||
public final boolean mDeviceLocked;
|
||||
public final boolean mNumberRowEnabled;
|
||||
public final boolean mLanguageSwitchKeyEnabled;
|
||||
public final boolean mEmojiKeyEnabled;
|
||||
|
@ -88,7 +88,7 @@ public final class KeyboardId {
|
|||
mMode = params.mMode;
|
||||
mElementId = elementId;
|
||||
mEditorInfo = params.mEditorInfo;
|
||||
mClobberSettingsKey = params.mNoSettingsKey;
|
||||
mDeviceLocked = params.mDeviceLocked;
|
||||
mNumberRowEnabled = params.mNumberRowEnabled;
|
||||
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
|
||||
mEmojiKeyEnabled = params.mEmojiKeyEnabled;
|
||||
|
@ -108,7 +108,7 @@ public final class KeyboardId {
|
|||
id.mWidth,
|
||||
id.mHeight,
|
||||
id.passwordInput(),
|
||||
id.mClobberSettingsKey,
|
||||
id.mDeviceLocked,
|
||||
id.mHasShortcutKey,
|
||||
id.mNumberRowEnabled,
|
||||
id.mLanguageSwitchKeyEnabled,
|
||||
|
@ -131,7 +131,7 @@ public final class KeyboardId {
|
|||
&& other.mWidth == mWidth
|
||||
&& other.mHeight == mHeight
|
||||
&& other.passwordInput() == passwordInput()
|
||||
&& other.mClobberSettingsKey == mClobberSettingsKey
|
||||
&& other.mDeviceLocked == mDeviceLocked
|
||||
&& other.mHasShortcutKey == mHasShortcutKey
|
||||
&& other.mNumberRowEnabled == mNumberRowEnabled
|
||||
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
|
||||
|
@ -202,7 +202,7 @@ public final class KeyboardId {
|
|||
actionName(imeAction()),
|
||||
(navigateNext() ? " navigateNext" : ""),
|
||||
(navigatePrevious() ? " navigatePrevious" : ""),
|
||||
(mClobberSettingsKey ? " clobberSettingsKey" : ""),
|
||||
(mDeviceLocked ? " deviceLocked" : ""),
|
||||
(passwordInput() ? " passwordInput" : ""),
|
||||
(mHasShortcutKey ? " hasShortcutKey" : ""),
|
||||
(mNumberRowEnabled ? " numberRowEnabled" : ""),
|
||||
|
|
|
@ -6,10 +6,12 @@
|
|||
|
||||
package org.dslul.openboard.inputmethod.keyboard;
|
||||
|
||||
import android.app.KeyguardManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.content.res.TypedArray;
|
||||
import android.content.res.XmlResourceParser;
|
||||
import android.os.Build;
|
||||
import android.text.InputType;
|
||||
import android.util.Log;
|
||||
import android.util.SparseArray;
|
||||
|
@ -36,11 +38,9 @@ import java.lang.ref.SoftReference;
|
|||
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.NO_SETTINGS_KEY;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.os.UserManagerCompat;
|
||||
|
||||
/**
|
||||
* 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;
|
||||
boolean mIsPasswordField;
|
||||
boolean mVoiceInputKeyEnabled;
|
||||
boolean mNoSettingsKey;
|
||||
boolean mDeviceLocked;
|
||||
boolean mNumberRowEnabled;
|
||||
boolean mLanguageSwitchKeyEnabled;
|
||||
boolean mEmojiKeyEnabled;
|
||||
|
@ -270,13 +270,14 @@ public final class KeyboardLayoutSet {
|
|||
// TODO: Consolidate those with {@link InputAttributes}.
|
||||
params.mEditorInfo = editorInfo;
|
||||
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.
|
||||
if (!UserManagerCompat.isUserUnlocked(context)) {
|
||||
params.mNoSettingsKey = true;
|
||||
final KeyguardManager km = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
|
||||
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> {
|
||||
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)
|
||||
keys.add("!icon/emoji_normal_key|!code/key_emoji")
|
||||
if (!params.mId.mLanguageSwitchKeyEnabled)
|
||||
keys.add("!icon/language_switch_key|!code/key_language_switch")
|
||||
if (!params.mId.mOneHandedModeEnabled)
|
||||
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()
|
||||
}
|
||||
|
||||
|
|
|
@ -566,7 +566,7 @@ public class XmlKeyboardParser implements AutoCloseable {
|
|||
final boolean passwordInputMatched = matchBoolean(caseAttr,
|
||||
R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
|
||||
final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
|
||||
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
|
||||
R.styleable.Keyboard_Case_clobberSettingsKey, id.mDeviceLocked);
|
||||
final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
|
||||
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
|
||||
final boolean numberRowEnabledMatched = matchBoolean(caseAttr,
|
||||
|
|
|
@ -38,12 +38,6 @@ public final class Constants {
|
|||
*/
|
||||
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
|
||||
* input.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue