allow showing all moreKeys

This commit is contained in:
Helium314 2023-09-10 00:20:21 +02:00
parent 850f75585b
commit 79badf93b1
7 changed files with 46 additions and 42 deletions

View file

@ -61,6 +61,10 @@ public final class KeyboardTextsSet {
mResourceLocale = SubtypeLocaleUtils.NO_LANGUAGE.equals(locale.toString()) ? null : locale; mResourceLocale = SubtypeLocaleUtils.NO_LANGUAGE.equals(locale.toString()) ? null : locale;
mResourcePackageName = resourcePackageName; mResourcePackageName = resourcePackageName;
mTextsTables.clear(); mTextsTables.clear();
if (Settings.getInstance().getCurrent().mShowAllMoreKeys) {
mTextsTables.add(KeyboardTextsTable.getTextsTable(new Locale(SubtypeLocaleUtils.NO_LANGUAGE)));
return;
}
mTextsTables.add(KeyboardTextsTable.getTextsTable(locale)); mTextsTables.add(KeyboardTextsTable.getTextsTable(locale));
if (locale != RichInputMethodManager.getInstance().getCurrentSubtypeLocale()) if (locale != RichInputMethodManager.getInstance().getCurrentSubtypeLocale())
return; // emojiCategory calls this several times with "zz" locale return; // emojiCategory calls this several times with "zz" locale

View file

@ -27,6 +27,7 @@ import android.os.Bundle;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference; import androidx.preference.Preference;
import org.dslul.openboard.inputmethod.keyboard.KeyboardLayoutSet;
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager; import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver; import org.dslul.openboard.inputmethod.latin.SystemBroadcastReceiver;
@ -160,6 +161,8 @@ public final class AdvancedSettingsFragment extends SubScreenFragment {
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) { if (key.equals(Settings.PREF_SHOW_SETUP_WIZARD_ICON)) {
SystemBroadcastReceiver.toggleAppIcon(requireContext()); SystemBroadcastReceiver.toggleAppIcon(requireContext());
} else if (key.equals(Settings.PREF_SHOW_ALL_MORE_KEYS)) {
KeyboardLayoutSet.onKeyboardThemeChanged();
} }
} }
} }

View file

@ -88,39 +88,28 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE = "show_suggestions_setting"; public static final String PREF_SHOW_SUGGESTIONS_SETTING_OBSOLETE = "show_suggestions_setting";
public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions"; public static final String PREF_SHOW_SUGGESTIONS = "show_suggestions";
public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "pref_key_use_personalized_dicts"; public static final String PREF_KEY_USE_PERSONALIZED_DICTS = "pref_key_use_personalized_dicts";
public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = public static final String PREF_KEY_USE_DOUBLE_SPACE_PERIOD = "pref_key_use_double_space_period";
"pref_key_use_double_space_period"; public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE = "pref_key_block_potentially_offensive";
public static final String PREF_BLOCK_POTENTIALLY_OFFENSIVE =
"pref_key_block_potentially_offensive";
public static final boolean ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS =
Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT;
public static final boolean SHOULD_SHOW_LXX_SUGGESTION_UI = public static final boolean SHOULD_SHOW_LXX_SUGGESTION_UI =
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
public static final String PREF_LANGUAGE_SWITCH_KEY = public static final String PREF_LANGUAGE_SWITCH_KEY = "pref_language_switch_key";
"pref_language_switch_key"; public static final String PREF_SHOW_EMOJI_KEY = "pref_show_emoji_key";
public static final String PREF_SHOW_EMOJI_KEY = public static final String PREF_SHOW_CLIPBOARD_KEY = "pref_show_clipboard_key";
"pref_show_emoji_key";
public static final String PREF_SHOW_CLIPBOARD_KEY =
"pref_show_clipboard_key";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles"; public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard"; public static final String PREF_ENABLE_SPLIT_KEYBOARD = "pref_split_keyboard";
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";
public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "pref_autospace_after_punctuation"; public static final String PREF_AUTOSPACE_AFTER_PUNCTUATION = "pref_autospace_after_punctuation";
public static final String PREF_ALWAYS_INCOGNITO_MODE = public static final String PREF_ALWAYS_INCOGNITO_MODE = "pref_always_incognito_mode";
"pref_always_incognito_mode";
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 = "pref_vibration_duration_settings";
"pref_vibration_duration_settings";
public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume"; public static final String PREF_KEYPRESS_SOUND_VOLUME = "pref_keypress_sound_volume";
public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout"; public static final String PREF_KEY_LONGPRESS_TIMEOUT = "pref_key_longpress_timeout";
public static final String PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY = public static final String PREF_ENABLE_EMOJI_ALT_PHYSICAL_KEY = "pref_enable_emoji_alt_physical_key";
"pref_enable_emoji_alt_physical_key";
public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail"; public static final String PREF_GESTURE_PREVIEW_TRAIL = "pref_gesture_preview_trail";
public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = public static final String PREF_GESTURE_FLOATING_PREVIEW_TEXT = "pref_gesture_floating_preview_text";
"pref_gesture_floating_preview_text";
public static final String PREF_SHOW_SETUP_WIZARD_ICON = "pref_show_setup_wizard_icon"; public static final String PREF_SHOW_SETUP_WIZARD_ICON = "pref_show_setup_wizard_icon";
public static final String PREF_ONE_HANDED_MODE = "pref_one_handed_mode_enabled"; public static final String PREF_ONE_HANDED_MODE = "pref_one_handed_mode_enabled";
@ -128,10 +117,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal"; public static final String PREF_KEY_IS_INTERNAL = "pref_key_is_internal";
public static final String PREF_ENABLE_METRICS_LOGGING = "pref_enable_metrics_logging"; public static final String PREF_SHOW_NUMBER_ROW = "pref_show_number_row";
public static final String PREF_SHOW_NUMBER_ROW =
"pref_show_number_row";
public static final String PREF_SHOW_HINTS = "pref_show_hints"; public static final String PREF_SHOW_HINTS = "pref_show_hints";
@ -147,6 +133,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_ENABLED_INPUT_STYLES = "pref_enabled_input_styles"; public static final String PREF_ENABLED_INPUT_STYLES = "pref_enabled_input_styles";
public static final String PREF_SELECTED_INPUT_STYLE = "pref_selected_input_style"; public static final String PREF_SELECTED_INPUT_STYLE = "pref_selected_input_style";
public static final String PREF_USE_SYSTEM_LOCALES = "pref_use_system_locales"; public static final String PREF_USE_SYSTEM_LOCALES = "pref_use_system_locales";
public static final String PREF_SHOW_ALL_MORE_KEYS = "pref_show_all_more_keys";
public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "pref_dont_show_missing_dict_dialog"; public static final String PREF_DONT_SHOW_MISSING_DICTIONARY_DIALOG = "pref_dont_show_missing_dict_dialog";

View file

@ -23,6 +23,7 @@ import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
import android.view.inputmethod.InputMethodSubtype;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
@ -89,6 +90,7 @@ public class SettingsValues {
public final boolean mOneHandedModeEnabled; public final boolean mOneHandedModeEnabled;
public final int mOneHandedModeGravity; public final int mOneHandedModeGravity;
public final boolean mNarrowKeyGaps; public final boolean mNarrowKeyGaps;
public final boolean mShowAllMoreKeys;
public final List<Locale> mSecondaryLocales; public final List<Locale> mSecondaryLocales;
// Use bigrams to predict the next word when there is no input for it yet // Use bigrams to predict the next word when there is no input for it yet
public final boolean mBigramPredictionEnabled; public final boolean mBigramPredictionEnabled;
@ -101,7 +103,6 @@ public class SettingsValues {
public final boolean mShowAppIcon; public final boolean mShowAppIcon;
public final boolean mIsShowAppIconSettingInPreferences; public final boolean mIsShowAppIconSettingInPreferences;
public final boolean mCloudSyncEnabled; public final boolean mCloudSyncEnabled;
public final boolean mEnableMetricsLogging;
public final boolean mShouldShowLxxSuggestionUi; public final boolean mShouldShowLxxSuggestionUi;
// Use split layout for keyboard. // Use split layout for keyboard.
public final boolean mIsSplitKeyboardEnabled; public final boolean mIsSplitKeyboardEnabled;
@ -180,7 +181,6 @@ public class SettingsValues {
mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res); mBigramPredictionEnabled = readBigramPredictionEnabled(prefs, res);
mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout); mDoubleSpacePeriodTimeout = res.getInteger(R.integer.config_double_space_period_timeout);
mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration()); mHasHardwareKeyboard = Settings.readHasHardwareKeyboard(res.getConfiguration());
mEnableMetricsLogging = prefs.getBoolean(Settings.PREF_ENABLE_METRICS_LOGGING, true);
mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false); mIsSplitKeyboardEnabled = prefs.getBoolean(Settings.PREF_ENABLE_SPLIT_KEYBOARD, false);
mScreenMetrics = Settings.readScreenMetrics(res); mScreenMetrics = Settings.readScreenMetrics(res);
@ -250,7 +250,9 @@ public class SettingsValues {
mClipboardHistoryRetentionTime = Settings.readClipboardHistoryRetentionTime(prefs, res); mClipboardHistoryRetentionTime = Settings.readClipboardHistoryRetentionTime(prefs, res);
mOneHandedModeEnabled = Settings.readOneHandedModeEnabled(prefs); mOneHandedModeEnabled = Settings.readOneHandedModeEnabled(prefs);
mOneHandedModeGravity = Settings.readOneHandedModeGravity(prefs); mOneHandedModeGravity = Settings.readOneHandedModeGravity(prefs);
mSecondaryLocales = Settings.getSecondaryLocales(prefs, SubtypeSettingsKt.getSelectedSubtype(prefs).getLocale()); final InputMethodSubtype selectedSubtype = SubtypeSettingsKt.getSelectedSubtype(prefs);
mSecondaryLocales = Settings.getSecondaryLocales(prefs, selectedSubtype.getLocale());
mShowAllMoreKeys = selectedSubtype.isAsciiCapable() && prefs.getBoolean(Settings.PREF_SHOW_ALL_MORE_KEYS, false);
mColors = Settings.getColorsForCurrentTheme(context, prefs); mColors = Settings.getColorsForCurrentTheme(context, prefs);
@ -260,10 +262,6 @@ public class SettingsValues {
mNarrowKeyGaps = prefs.getBoolean(Settings.PREF_NARROW_KEY_GAPS, true); mNarrowKeyGaps = prefs.getBoolean(Settings.PREF_NARROW_KEY_GAPS, true);
} }
public boolean isMetricsLoggingEnabled() {
return mEnableMetricsLogging;
}
public boolean isApplicationSpecifiedCompletionsOn() { public boolean isApplicationSpecifiedCompletionsOn() {
return mInputAttributes.mApplicationSpecifiedCompletionOn; return mInputAttributes.mApplicationSpecifiedCompletionOn;
} }

View file

@ -16,13 +16,11 @@
package org.dslul.openboard.inputmethod.latin.utils; package org.dslul.openboard.inputmethod.latin.utils;
import android.os.Build;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import org.dslul.openboard.inputmethod.annotations.UsedForTesting; import org.dslul.openboard.inputmethod.annotations.UsedForTesting;
import org.dslul.openboard.inputmethod.compat.InputMethodSubtypeCompatUtils;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.common.StringUtils; import org.dslul.openboard.inputmethod.latin.common.StringUtils;
@ -66,13 +64,17 @@ public final class AdditionalSubtypeUtils {
localeString, keyboardLayoutSetName, isAsciiCapable, isEmojiCapable); localeString, keyboardLayoutSetName, isAsciiCapable, isEmojiCapable);
final int platformVersionIndependentSubtypeId = final int platformVersionIndependentSubtypeId =
getPlatformVersionIndependentSubtypeId(localeString, keyboardLayoutSetName); getPlatformVersionIndependentSubtypeId(localeString, keyboardLayoutSetName);
// NOTE: In KitKat and later, InputMethodSubtypeBuilder#setIsAsciiCapable is also available. return new InputMethodSubtype.InputMethodSubtypeBuilder()
// TODO: Use InputMethodSubtypeBuilder#setIsAsciiCapable when appropriate. .setSubtypeNameResId(nameId)
return new InputMethodSubtype(nameId, .setSubtypeIconResId(R.drawable.ic_ime_switcher_dark)
R.drawable.ic_ime_switcher_dark, localeString, KEYBOARD_MODE, .setSubtypeLocale(localeString)
platformVersionDependentExtraValues, .setSubtypeMode(KEYBOARD_MODE)
false /* isAuxiliary */, false /* overrideImplicitlyEnabledSubtype */, .setSubtypeExtraValue(platformVersionDependentExtraValues)
platformVersionIndependentSubtypeId); .setIsAuxiliary(false)
.setOverridesImplicitlyEnabledSubtype(false)
.setSubtypeId(platformVersionIndependentSubtypeId)
.setIsAsciiCapable(isAsciiCapable)
.build();
} }
public static InputMethodSubtype createDummyAdditionalSubtype( public static InputMethodSubtype createDummyAdditionalSubtype(
@ -111,7 +113,7 @@ public final class AdditionalSubtypeUtils {
if (subtype != null) if (subtype != null)
subtypesList.add(subtype); subtypesList.add(subtype);
} }
return subtypesList.toArray(new InputMethodSubtype[subtypesList.size()]); return subtypesList.toArray(new InputMethodSubtype[0]);
} }
// use string created with getPrefSubtype // use string created with getPrefSubtype
@ -191,7 +193,7 @@ public final class AdditionalSubtypeUtils {
extraValueItems.add(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" + extraValueItems.add(UNTRANSLATABLE_STRING_IN_SUBTYPE_NAME + "=" +
SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(keyboardLayoutSetName)); SubtypeLocaleUtils.getKeyboardLayoutSetDisplayName(keyboardLayoutSetName));
} }
if (isEmojiCapable && Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { if (isEmojiCapable) {
extraValueItems.add(EMOJI_CAPABLE); extraValueItems.add(EMOJI_CAPABLE);
} }
extraValueItems.add(IS_ADDITIONAL_SUBTYPE); extraValueItems.add(IS_ADDITIONAL_SUBTYPE);

View file

@ -191,6 +191,10 @@
<string name="autospace_after_punctuation">Autospace after punctuation</string> <string name="autospace_after_punctuation">Autospace after punctuation</string>
<!-- Description for "insert_more_spaces" option. --> <!-- Description for "insert_more_spaces" option. -->
<string name="autospace_after_punctuation_summary">Automatically insert space after punctuation when typing a new word</string> <string name="autospace_after_punctuation_summary">Automatically insert space after punctuation when typing a new word</string>
<!-- Preferences item for showing all available keys in long-press popup -->
<string name="show_all_more_keys_title">Show all keys in popup</string>
<!-- Description for "show_all_more_keys" option. -->
<string name="show_all_more_keys_summary">When using a latin keyboard, more characters are available on long-pressing a key</string>
<!-- Preferences item for disabling word learning --> <!-- Preferences item for disabling word learning -->
<string name="prefs_force_incognito_mode">Force incognito mode</string> <string name="prefs_force_incognito_mode">Force incognito mode</string>
<!-- Description for "prefs_force_incognito_mode" option. --> <!-- Description for "prefs_force_incognito_mode" option. -->

View file

@ -82,6 +82,12 @@
android:summary="@string/autospace_after_punctuation_summary" android:summary="@string/autospace_after_punctuation_summary"
android:defaultValue="false" /> android:defaultValue="false" />
<SwitchPreferenceCompat
android:key="pref_show_all_more_keys"
android:title="@string/show_all_more_keys_title"
android:summary="@string/show_all_more_keys_summary"
android:defaultValue="false" />
<Preference <Preference
android:key="load_gesture_library" android:key="load_gesture_library"
android:title="@string/load_gesture_library" android:title="@string/load_gesture_library"