Skip to content

Commit b7450b8

Browse files
MiMoHoclaude
andcommitted
add setting to disable URL/email specific layout
When typing in a URL field the comma key becomes "/" and in an email field it becomes "@" (the variation_selector in functional_keys.json). This is intentional, but some users prefer a keyboard whose base layout never changes; currently the only way to keep the comma in these fields is a custom functional-keys layout (see #1573, #734). Add an "Adapt layout for URL and email fields" preference (default on, i.e. unchanged behaviour). When disabled, getKeyboardMode() returns TEXT for URI/email input types, so the normal layout and popups are used everywhere. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent b1c1cd2 commit b7450b8

6 files changed

Lines changed: 17 additions & 1 deletion

File tree

app/src/main/java/helium314/keyboard/keyboard/KeyboardLayoutSet.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ class KeyboardLayoutSet internal constructor(private val mContext: Context, priv
238238
}
239239
InputType.TYPE_CLASS_PHONE -> KeyboardMode.PHONE
240240
InputType.TYPE_CLASS_TEXT ->
241-
if (InputTypeUtils.isEmailVariation(variation)) KeyboardMode.EMAIL
241+
if (!Settings.getValues().mUrlEmailLayout) KeyboardMode.TEXT
242+
else if (InputTypeUtils.isEmailVariation(variation)) KeyboardMode.EMAIL
242243
else if (variation == InputType.TYPE_TEXT_VARIATION_URI) KeyboardMode.URL
243244
else KeyboardMode.TEXT
244245
else -> KeyboardMode.TEXT

app/src/main/java/helium314/keyboard/latin/settings/Defaults.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ object Defaults {
145145
const val PREF_POPUP_KEYS_HINT_ORDER = POPUP_KEYS_LABEL_DEFAULT
146146
const val PREF_SHOW_POPUP_HINTS = false
147147
const val PREF_SHOW_TLD_POPUP_KEYS = true
148+
const val PREF_URL_EMAIL_LAYOUT = true
148149
const val PREF_MORE_POPUP_KEYS = "main"
149150
const val PREF_SPACE_TO_CHANGE_LANG = true
150151
const val PREF_LANGUAGE_SWIPE_DISTANCE = 5

app/src/main/java/helium314/keyboard/latin/settings/Settings.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
160160
public static final String PREF_SHOW_POPUP_HINTS = "show_popup_hints";
161161
public static final String PREF_MORE_POPUP_KEYS = "more_popup_keys";
162162
public static final String PREF_SHOW_TLD_POPUP_KEYS = "show_tld_popup_keys";
163+
public static final String PREF_URL_EMAIL_LAYOUT = "url_email_layout";
163164

164165
public static final String PREF_SPACE_TO_CHANGE_LANG = "prefs_long_press_keyboard_to_change_lang";
165166
public static final String PREF_LANGUAGE_SWIPE_DISTANCE = "language_swipe_distance";

app/src/main/java/helium314/keyboard/latin/settings/SettingsValues.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ public class SettingsValues {
7373
public final boolean mShowsHints;
7474
public final boolean mShowsPopupHints;
7575
public final boolean mShowTldPopupKeys;
76+
public final boolean mUrlEmailLayout;
7677
public final boolean mSpaceForLangChange;
7778
public final boolean mShowsEmojiKey;
7879
public final boolean mVarToolbarDirection;
@@ -211,6 +212,7 @@ public SettingsValues(final Context context, final SharedPreferences prefs, fina
211212
mShowsHints = prefs.getBoolean(Settings.PREF_SHOW_HINTS, Defaults.PREF_SHOW_HINTS);
212213
mShowsPopupHints = prefs.getBoolean(Settings.PREF_SHOW_POPUP_HINTS, Defaults.PREF_SHOW_POPUP_HINTS);
213214
mShowTldPopupKeys = prefs.getBoolean(Settings.PREF_SHOW_TLD_POPUP_KEYS, Defaults.PREF_SHOW_TLD_POPUP_KEYS);
215+
mUrlEmailLayout = prefs.getBoolean(Settings.PREF_URL_EMAIL_LAYOUT, Defaults.PREF_URL_EMAIL_LAYOUT);
214216
mSpaceForLangChange = prefs.getBoolean(Settings.PREF_SPACE_TO_CHANGE_LANG, Defaults.PREF_SPACE_TO_CHANGE_LANG);
215217
mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, Defaults.PREF_SHOW_EMOJI_KEY);
216218
mVarToolbarDirection = mToolbarMode != ToolbarMode.HIDDEN && prefs.getBoolean(Settings.PREF_VARIABLE_TOOLBAR_DIRECTION, Defaults.PREF_VARIABLE_TOOLBAR_DIRECTION);

app/src/main/java/helium314/keyboard/settings/screens/PreferencesScreen.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ fun PreferencesScreen(
5050
Settings.PREF_POPUP_KEYS_ORDER,
5151
Settings.PREF_SHOW_POPUP_HINTS,
5252
Settings.PREF_SHOW_TLD_POPUP_KEYS,
53+
Settings.PREF_URL_EMAIL_LAYOUT,
5354
Settings.PREF_POPUP_ON,
5455
if (AudioAndHapticFeedbackManager.getInstance().hasVibrator())
5556
Settings.PREF_VIBRATE_ON else null,
@@ -109,6 +110,12 @@ fun createPreferencesSettings(context: Context) = listOf(
109110
) {
110111
SwitchPreference(it, Defaults.PREF_SHOW_TLD_POPUP_KEYS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
111112
},
113+
Setting(
114+
context, Settings.PREF_URL_EMAIL_LAYOUT, R.string.url_email_layout,
115+
R.string.url_email_layout_summary
116+
) {
117+
SwitchPreference(it, Defaults.PREF_URL_EMAIL_LAYOUT) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
118+
},
112119
Setting(context, Settings.PREF_SHOW_POPUP_HINTS, R.string.show_popup_hints, R.string.show_popup_hints_summary) {
113120
SwitchPreference(it, Defaults.PREF_SHOW_POPUP_HINTS) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
114121
},

app/src/main/res/values/strings.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,10 @@
323323
<string name="show_tld_popup_keys">Show TLD popup keys</string>
324324
<!-- Description of the setting to show TLD popup keys -->
325325
<string name="show_tld_popup_keys_summary">Replace period key popups with top level domains when typing URLs and email addresses</string>
326+
<!-- Title of the setting to adapt the keyboard layout in URL and email input fields -->
327+
<string name="url_email_layout">Adapt layout for URL and email fields</string>
328+
<!-- Description of the setting to adapt the keyboard layout in URL and email input fields -->
329+
<string name="url_email_layout_summary">Show a slash key in URL fields and an @ key in email fields (in place of the comma), and matching popup keys. Disable to always keep the normal layout.</string>
326330
<!-- Names of the popup key classes -->
327331
<string name="popup_keys_number" tools:keep="@string/popup_keys_number">Number row</string>
328332
<string name="popup_keys_language" translatable="false" tools:keep="@string/popup_keys_language">@string/subtype_locale</string>

0 commit comments

Comments
 (0)