Force incognito mode option

This commit is contained in:
dslul 2020-09-27 16:41:15 +02:00
parent 6498de22cd
commit 075efd1573
10 changed files with 18 additions and 79 deletions

View file

@ -152,9 +152,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
final Keyboard newKeyboard = mKeyboardLayoutSet.getKeyboard(keyboardId); final Keyboard newKeyboard = mKeyboardLayoutSet.getKeyboard(keyboardId);
keyboardView.setKeyboard(newKeyboard); keyboardView.setKeyboard(newKeyboard);
mCurrentInputView.setKeyboardTopPadding(newKeyboard.mTopPadding); mCurrentInputView.setKeyboardTopPadding(newKeyboard.mTopPadding);
keyboardView.setKeyPreviewPopupEnabled( keyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn);
currentSettingsValues.mKeyPreviewPopupOn,
currentSettingsValues.mKeyPreviewPopupDismissDelay);
keyboardView.setKeyPreviewAnimationParams( keyboardView.setKeyPreviewAnimationParams(
currentSettingsValues.mHasCustomKeyPreviewAnimationParams, currentSettingsValues.mHasCustomKeyPreviewAnimationParams,
currentSettingsValues.mKeyPreviewShowUpStartXScale, currentSettingsValues.mKeyPreviewShowUpStartXScale,

View file

@ -412,10 +412,9 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
* Enables or disables the key preview popup. This is a popup that shows a magnified * Enables or disables the key preview popup. This is a popup that shows a magnified
* version of the depressed key. By default the preview is enabled. * version of the depressed key. By default the preview is enabled.
* @param previewEnabled whether or not to enable the key feedback preview * @param previewEnabled whether or not to enable the key feedback preview
* @param delay the delay after which the preview is dismissed
*/ */
public void setKeyPreviewPopupEnabled(final boolean previewEnabled, final int delay) { public void setKeyPreviewPopupEnabled(final boolean previewEnabled) {
mKeyPreviewDrawParams.setPopupEnabled(previewEnabled, delay); mKeyPreviewDrawParams.setPopupEnabled(previewEnabled);
} }
/** /**
@ -508,10 +507,7 @@ public final class MainKeyboardView extends KeyboardView implements DrawingProxy
private void dismissKeyPreview(@Nonnull final Key key) { private void dismissKeyPreview(@Nonnull final Key key) {
if (isHardwareAccelerated()) { if (isHardwareAccelerated()) {
mKeyPreviewChoreographer.dismissKeyPreview(key); mKeyPreviewChoreographer.dismissKeyPreview(key);
return;
} }
// TODO: Implement preference option to control key preview method and duration.
mTimerHandler.postDismissKeyPreview(key, mKeyPreviewDrawParams.getLingerTimeout());
} }
public void setSlidingKeyInputPreviewEnabled(final boolean enabled) { public void setSlidingKeyInputPreviewEnabled(final boolean enabled) {

View file

@ -32,7 +32,6 @@ public final class KeyPreviewDrawParams {
public final int mPreviewOffset; public final int mPreviewOffset;
public final int mPreviewHeight; public final int mPreviewHeight;
public final int mPreviewBackgroundResId; public final int mPreviewBackgroundResId;
private int mLingerTimeout;
private boolean mShowPopup = true; private boolean mShowPopup = true;
// The graphical geometry of the key preview. // The graphical geometry of the key preview.
@ -67,8 +66,6 @@ public final class KeyPreviewDrawParams {
R.styleable.MainKeyboardView_keyPreviewHeight, 0); R.styleable.MainKeyboardView_keyPreviewHeight, 0);
mPreviewBackgroundResId = mainKeyboardViewAttr.getResourceId( mPreviewBackgroundResId = mainKeyboardViewAttr.getResourceId(
R.styleable.MainKeyboardView_keyPreviewBackground, 0); R.styleable.MainKeyboardView_keyPreviewBackground, 0);
mLingerTimeout = mainKeyboardViewAttr.getInt(
R.styleable.MainKeyboardView_keyPreviewLingerTimeout, 0);
} }
public void setVisibleOffset(final int previewVisibleOffset) { public void setVisibleOffset(final int previewVisibleOffset) {
@ -100,19 +97,14 @@ public final class KeyPreviewDrawParams {
return mVisibleHeight; return mVisibleHeight;
} }
public void setPopupEnabled(final boolean enabled, final int lingerTimeout) { public void setPopupEnabled(final boolean enabled) {
mShowPopup = enabled; mShowPopup = enabled;
mLingerTimeout = lingerTimeout;
} }
public boolean isPopupEnabled() { public boolean isPopupEnabled() {
return mShowPopup; return mShowPopup;
} }
public int getLingerTimeout() {
return mLingerTimeout;
}
public void setAnimationParams(final boolean hasCustomAnimationParams, public void setAnimationParams(final boolean hasCustomAnimationParams,
final float showUpStartXScale, final float showUpStartYScale, final int showUpDuration, final float showUpStartXScale, final float showUpStartYScale, final int showUpDuration,
final float dismissEndXScale, final float dismissEndYScale, final int dismissDuration) { final float dismissEndXScale, final float dismissEndYScale, final int dismissDuration) {

View file

@ -1014,8 +1014,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
mainKeyboardView.setMainDictionaryAvailability( mainKeyboardView.setMainDictionaryAvailability(
mDictionaryFacilitator.hasAtLeastOneInitializedMainDictionary()); mDictionaryFacilitator.hasAtLeastOneInitializedMainDictionary());
mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn, mainKeyboardView.setKeyPreviewPopupEnabled(currentSettingsValues.mKeyPreviewPopupOn);
currentSettingsValues.mKeyPreviewPopupDismissDelay);
mainKeyboardView.setSlidingKeyInputPreviewEnabled( mainKeyboardView.setSlidingKeyInputPreviewEnabled(
currentSettingsValues.mSlidingKeyInputPreviewEnabled); currentSettingsValues.mSlidingKeyInputPreviewEnabled);
mainKeyboardView.setGestureHandlingEnabledByUser( mainKeyboardView.setGestureHandlingEnabledByUser(

View file

@ -62,53 +62,17 @@ public final class AdvancedSettingsFragment extends SubScreenFragment {
removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS); removePreference(Settings.PREF_VIBRATION_DURATION_SETTINGS);
} }
// TODO: consolidate key preview dismiss delay with the key preview animation parameters.
if (!Settings.readFromBuildConfigIfToShowKeyPreviewPopupOption(res)) {
removePreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
} else {
// TODO: Cleanup this setup.
final ListPreference keyPreviewPopupDismissDelay =
(ListPreference) findPreference(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
final String popupDismissDelayDefaultValue = Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout));
keyPreviewPopupDismissDelay.setEntries(new String[] {
res.getString(R.string.key_preview_popup_dismiss_no_delay),
res.getString(R.string.key_preview_popup_dismiss_default_delay),
});
keyPreviewPopupDismissDelay.setEntryValues(new String[] {
"0",
popupDismissDelayDefaultValue
});
if (null == keyPreviewPopupDismissDelay.getValue()) {
keyPreviewPopupDismissDelay.setValue(popupDismissDelayDefaultValue);
}
keyPreviewPopupDismissDelay.setEnabled(
Settings.readKeyPreviewPopupEnabled(prefs, res));
}
setupKeypressVibrationDurationSettings(); setupKeypressVibrationDurationSettings();
setupKeypressSoundVolumeSettings(); setupKeypressSoundVolumeSettings();
setupKeyLongpressTimeoutSettings(); setupKeyLongpressTimeoutSettings();
refreshEnablingsOfKeypressSoundAndVibrationSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings();
} }
@Override
public void onResume() {
super.onResume();
final SharedPreferences prefs = getPreferenceManager().getSharedPreferences();
updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
}
@Override @Override
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
final Resources res = getResources(); if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) {
if (key.equals(Settings.PREF_POPUP_ON)) {
setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Settings.readKeyPreviewPopupEnabled(prefs, res));
} else if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) {
SystemBroadcastReceiver.toggleAppIcon(getActivity()); SystemBroadcastReceiver.toggleAppIcon(getActivity());
} }
updateListPreferenceSummaryToCurrentValue(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY);
refreshEnablingsOfKeypressSoundAndVibrationSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings();
} }

View file

@ -84,11 +84,6 @@ public final class PreferencesSettingsFragment extends SubScreenFragment {
@Override @Override
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
final Resources res = getResources();
if (key.equals(Settings.PREF_POPUP_ON)) {
setPreferenceEnabled(Settings.PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Settings.readKeyPreviewPopupEnabled(prefs, res));
}
refreshEnablingsOfKeypressSoundAndVibrationSettings(); refreshEnablingsOfKeypressSoundAndVibrationSettings();
} }

View file

@ -83,9 +83,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale"; public static final String PREF_KEYBOARD_HEIGHT_SCALE = "pref_keyboard_height_scale";
public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad"; public static final String PREF_SPACE_TRACKPAD = "pref_space_trackpad";
public static final String PREF_DELETE_SWIPE = "pref_delete_swipe"; public static final String PREF_DELETE_SWIPE = "pref_delete_swipe";
// TODO: consolidate key preview dismiss delay with the key preview animation parameters. public static final String PREF_ALWAYS_INCOGNITO_MODE =
public static final String PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY = "pref_always_incognito_mode";
"pref_key_preview_popup_dismiss_delay";
public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction"; public static final String PREF_BIGRAM_PREDICTIONS = "next_word_prediction";
public static final String PREF_GESTURE_INPUT = "gesture_input"; public static final String PREF_GESTURE_INPUT = "gesture_input";
public static final String PREF_VIBRATION_DURATION_SETTINGS = public static final String PREF_VIBRATION_DURATION_SETTINGS =
@ -262,11 +261,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
return prefs.getBoolean(PREF_POPUP_ON, defaultKeyPreviewPopup); return prefs.getBoolean(PREF_POPUP_ON, defaultKeyPreviewPopup);
} }
public static int readKeyPreviewPopupDismissDelay(final SharedPreferences prefs, public static boolean readAlwaysIncognitoMode(final SharedPreferences prefs) {
final Resources res) { return prefs.getBoolean(PREF_ALWAYS_INCOGNITO_MODE, true);
return Integer.parseInt(prefs.getString(PREF_KEY_PREVIEW_POPUP_DISMISS_DELAY,
Integer.toString(res.getInteger(
R.integer.config_key_preview_linger_timeout))));
} }
public static String readPrefAdditionalSubtypes(final SharedPreferences prefs, public static String readPrefAdditionalSubtypes(final SharedPreferences prefs,

View file

@ -101,7 +101,6 @@ public class SettingsValues {
// Deduced settings // Deduced settings
public final int mKeypressVibrationDuration; public final int mKeypressVibrationDuration;
public final float mKeypressSoundVolume; public final float mKeypressSoundVolume;
public final int mKeyPreviewPopupDismissDelay;
private final boolean mAutoCorrectEnabled; private final boolean mAutoCorrectEnabled;
public final float mAutoCorrectionThreshold; public final float mAutoCorrectionThreshold;
public final float mPlausibilityThreshold; public final float mPlausibilityThreshold;
@ -169,7 +168,6 @@ public class SettingsValues {
mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res); mKeyLongpressTimeout = Settings.readKeyLongpressTimeout(prefs, res);
mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res); mKeypressVibrationDuration = Settings.readKeypressVibrationDuration(prefs, res);
mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res); mKeypressSoundVolume = Settings.readKeypressSoundVolume(prefs, res);
mKeyPreviewPopupDismissDelay = Settings.readKeyPreviewPopupDismissDelay(prefs, res);
mEnableEmojiAltPhysicalKey = prefs.getBoolean( mEnableEmojiAltPhysicalKey = prefs.getBoolean(
Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true); Settings.PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY, true);
mShowAppIcon = Settings.readShowSetupWizardIcon(prefs, context); mShowAppIcon = Settings.readShowSetupWizardIcon(prefs, context);
@ -188,7 +186,7 @@ public class SettingsValues {
//&& !mInputAttributes.mInputTypeNoAutoCorrect; //&& !mInputAttributes.mInputTypeNoAutoCorrect;
mSuggestionsEnabledPerUserSettings = !mInputAttributes.mIsPasswordField && mSuggestionsEnabledPerUserSettings = !mInputAttributes.mIsPasswordField &&
readSuggestionsEnabled(prefs); readSuggestionsEnabled(prefs);
mIncognitoModeEnabled = mInputAttributes.mNoLearning; mIncognitoModeEnabled = Settings.readAlwaysIncognitoMode(prefs) || mInputAttributes.mNoLearning;
mIsInternal = Settings.isInternal(prefs); mIsInternal = Settings.isInternal(prefs);
mHasCustomKeyPreviewAnimationParams = prefs.getBoolean( mHasCustomKeyPreviewAnimationParams = prefs.getBoolean(
DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false); DebugSettings.PREF_HAS_CUSTOM_KEY_PREVIEW_ANIMATION_PARAMS, false);
@ -412,8 +410,6 @@ public class SettingsValues {
sb.append("" + mKeypressVibrationDuration); sb.append("" + mKeypressVibrationDuration);
sb.append("\n mKeypressSoundVolume = "); sb.append("\n mKeypressSoundVolume = ");
sb.append("" + mKeypressSoundVolume); sb.append("" + mKeypressSoundVolume);
sb.append("\n mKeyPreviewPopupDismissDelay = ");
sb.append("" + mKeyPreviewPopupDismissDelay);
sb.append("\n mAutoCorrectEnabled = "); sb.append("\n mAutoCorrectEnabled = ");
sb.append("" + mAutoCorrectEnabled); sb.append("" + mAutoCorrectEnabled);
sb.append("\n mAutoCorrectionThreshold = "); sb.append("\n mAutoCorrectionThreshold = ");

View file

@ -607,4 +607,6 @@ Tip: You can download and remove dictionaries by going to <b>Languages &
<string name="delete_swipe_summary">Perform a swipe from the delete key to select and remove bigger portions of text at once</string> <string name="delete_swipe_summary">Perform a swipe from the delete key to select and remove bigger portions of text at once</string>
<string name="space_trackpad_summary">Swipe on the spacebar to move the cursor</string> <string name="space_trackpad_summary">Swipe on the spacebar to move the cursor</string>
<string name="more_keys_strip_description">More keys</string> <string name="more_keys_strip_description">More keys</string>
<string name="prefs_force_incognito_mode">Force incognito mode</string>
<string name="prefs_force_incognito_mode_summary">Disable learning of new words</string>
</resources> </resources>

View file

@ -19,10 +19,11 @@
xmlns:latin="http://schemas.android.com/apk/res-auto" xmlns:latin="http://schemas.android.com/apk/res-auto"
android:title="@string/settings_screen_advanced" android:title="@string/settings_screen_advanced"
android:key="screen_advanced"> android:key="screen_advanced">
<!-- TODO: consolidate key preview dismiss delay with the key preview animation parameters. --> <CheckBoxPreference
<ListPreference android:key="pref_always_incognito_mode"
android:key="pref_key_preview_popup_dismiss_delay" android:title="@string/prefs_force_incognito_mode"
android:title="@string/key_preview_popup_dismiss_delay" /> android:summary="@string/prefs_force_incognito_mode_summary"
android:defaultValue="false" />
<org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference <org.dslul.openboard.inputmethod.latin.settings.SeekBarDialogPreference
android:key="pref_vibration_duration_settings" android:key="pref_vibration_duration_settings"
android:title="@string/prefs_keypress_vibration_duration_settings" android:title="@string/prefs_keypress_vibration_duration_settings"