add setting when to switch to main keyboard view

fixes #546
This commit is contained in:
Helium314 2024-07-10 17:23:10 +02:00
parent a3bc3b56ff
commit bee51de8a5
8 changed files with 57 additions and 7 deletions

View file

@ -268,6 +268,8 @@ class ClipboardHistoryView @JvmOverloads constructor(
val clipContent = clipboardHistoryManager?.getHistoryEntryContent(clipId)
keyboardActionListener?.onTextInput(clipContent?.content.toString())
keyboardActionListener?.onReleaseKey(KeyCode.NOT_SPECIFIED, false)
if (Settings.getInstance().current.mAlphaAfterClipHistoryEntry)
keyboardActionListener?.onCodeInput(KeyCode.ALPHA, Constants.NOT_A_COORDINATE, Constants.NOT_A_COORDINATE, false)
}
override fun onClipboardHistoryEntryAdded(at: Int) {

View file

@ -340,6 +340,8 @@ public final class EmojiPalettesView extends LinearLayout
mKeyboardActionListener.onCodeInput(code, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
}
mKeyboardActionListener.onReleaseKey(code, false);
if (Settings.getInstance().getCurrent().mAlphaAfterEmojiInEmojiView)
mKeyboardActionListener.onCodeInput(KeyCode.ALPHA, NOT_A_COORDINATE, NOT_A_COORDINATE, false);
}
public void setHardwareAcceleratedDrawingEnabled(final boolean enabled) {

View file

@ -782,17 +782,11 @@ public final class KeyboardState {
|| code == KeyCode.MULTIPLE_CODE_POINTS)) {
mSwitchState = SWITCH_STATE_SYMBOL;
}
// Switch back to alpha keyboard mode if user types one or more non-space/enter
// characters followed by a space/enter.
if (isSpaceOrEnter(code)) {
toggleAlphabetAndSymbols(autoCapsFlags, recapitalizeMode);
mPrevSymbolsKeyboardWasShifted = false;
}
break;
case SWITCH_STATE_SYMBOL:
// Switch back to alpha keyboard mode if user types one or more non-space/enter
// characters followed by a space/enter.
if (isSpaceOrEnter(code)) {
if (isSpaceOrEnter(code) && Settings.getInstance().getCurrent().mAlphaAfterSymbolAndSpace) {
toggleAlphabetAndSymbols(autoCapsFlags, recapitalizeMode);
mPrevSymbolsKeyboardWasShifted = false;
}

View file

@ -149,6 +149,11 @@ class AdvancedSettingsFragment : SubScreenFragment() {
customCurrencyDialog()
true
}
findPreference<Preference>("switch_after")?.setOnPreferenceClickListener {
switchToMainDialog()
true
}
}
override fun onStart() {
@ -485,6 +490,31 @@ class AdvancedSettingsFragment : SubScreenFragment() {
d.show()
}
private fun switchToMainDialog() {
val checked = booleanArrayOf(
sharedPreferences.getBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, true),
sharedPreferences.getBoolean(Settings.PREF_ABC_AFTER_EMOJI, false),
sharedPreferences.getBoolean(Settings.PREF_ABC_AFTER_CLIP, false),
)
val titles = arrayOf(
requireContext().getString(R.string.after_symbol_and_space),
requireContext().getString(R.string.after_emoji),
requireContext().getString(R.string.after_clip),
)
AlertDialog.Builder(requireContext())
.setTitle(R.string.switch_keyboard_after)
.setMultiChoiceItems(titles, checked) { _, i, b -> checked[i] = b }
.setNegativeButton(android.R.string.cancel, null)
.setPositiveButton(android.R.string.ok) { _, _ ->
sharedPreferences.edit {
putBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, checked[0])
putBoolean(Settings.PREF_ABC_AFTER_EMOJI, checked[1])
putBoolean(Settings.PREF_ABC_AFTER_CLIP, checked[2])
}
}
.show()
}
private fun setupKeyLongpressTimeoutSettings() {
val prefs = sharedPreferences
findPreference<SeekBarDialogPreference>(Settings.PREF_KEY_LONGPRESS_TIMEOUT)?.setInterface(object : ValueProxy {

View file

@ -156,6 +156,9 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
public static final String PREF_AUTO_SHOW_TOOLBAR = "auto_show_toolbar";
public static final String PREF_AUTO_HIDE_TOOLBAR = "auto_hide_toolbar";
public static final String PREF_CLIPBOARD_TOOLBAR_KEYS = "clipboard_toolbar_keys";
public static final String PREF_ABC_AFTER_EMOJI = "abc_after_emoji";
public static final String PREF_ABC_AFTER_CLIP = "abc_after_clip";
public static final String PREF_ABC_AFTER_SYMBOL_SPACE = "abc_after_symbol_space";
// Emoji
public static final String PREF_EMOJI_RECENT_KEYS = "emoji_recent_keys";

View file

@ -111,6 +111,9 @@ public class SettingsValues {
public final float mBottomPaddingScale;
public final boolean mAutoShowToolbar;
public final boolean mAutoHideToolbar;
public final boolean mAlphaAfterEmojiInEmojiView;
public final boolean mAlphaAfterClipHistoryEntry;
public final boolean mAlphaAfterSymbolAndSpace;
// From the input box
@NonNull
@ -252,6 +255,9 @@ public class SettingsValues {
mAutoShowToolbar = prefs.getBoolean(Settings.PREF_AUTO_SHOW_TOOLBAR, false);
mAutoHideToolbar = readSuggestionsEnabled(prefs) && prefs.getBoolean(Settings.PREF_AUTO_HIDE_TOOLBAR, false);
mHasCustomFunctionalLayout = CustomLayoutUtilsKt.hasCustomFunctionalLayout(selectedSubtype, context);
mAlphaAfterEmojiInEmojiView = prefs.getBoolean(Settings.PREF_ABC_AFTER_EMOJI, false);
mAlphaAfterClipHistoryEntry = prefs.getBoolean(Settings.PREF_ABC_AFTER_CLIP, false);
mAlphaAfterSymbolAndSpace = prefs.getBoolean(Settings.PREF_ABC_AFTER_SYMBOL_SPACE, true);
}
public boolean isApplicationSpecifiedCompletionsOn() {