Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ abstract class GeneralKeyboardIME(
return isActionSearch || isUriType || hasSearchHint
}

override fun isClipboardKeyEnabled(): Boolean = PreferencesHelper.getIsClipboardKeyEnabled(this, language)

private fun loadLanguageData() {
val languageAlias = getLanguageAlias(language)
dataContract = dbManagers.getLanguageContract(languageAlias)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/assets/i18n
4 changes: 3 additions & 1 deletion app/src/main/java/be/scri/helpers/KeyboardBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class KeyboardBase {
val keyboardLetters: Int

fun isSearchBar(): Boolean

fun isClipboardKeyEnabled(): Boolean
}

/** Horizontal gap default for all rows */
Expand Down Expand Up @@ -659,7 +661,7 @@ class KeyboardBase {
}
}

if (currentKeyboardMode == keyboardLettersMode && mKeys != null) {
if (currentKeyboardMode == keyboardLettersMode && mKeys != null && provider?.isClipboardKeyEnabled() == true) {
val spaceKey = mKeys!!.find { it?.code == 32 }
val commaKey = mKeys!!.find { it?.code == ','.code }
val row = mRows.lastOrNull()
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/be/scri/helpers/PreferencesHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ object PreferencesHelper {
private const val DEFAULT_CURRENCY = "default_currency"
private const val HOLD_FOR_ALT_KEYS = "hold_for_alt_keys"
private const val INCREASE_TEXT_SIZE = "increase_text_size"
private const val CLIPBOARD_KEY_ON_KEYBOARD = "clipboard_key_on_keyboard"

/**
* Sets the translation source language for a given language.
Expand Down Expand Up @@ -534,6 +535,31 @@ object PreferencesHelper {
return sharedPref.getBoolean(getLanguageSpecificPreferenceKey(HOLD_FOR_ALT_KEYS, language), true)
}

/**
* Sets the preference for showing or hiding the clipboard key on the keyboard.
*/
fun setClipboardKeyPreference(
context: Context,
language: String,
enabled: Boolean,
) {
val sharedPref = context.getSharedPreferences(SCRIBE_PREFS, Context.MODE_PRIVATE)
sharedPref.edit {
putBoolean(getLanguageSpecificPreferenceKey(CLIPBOARD_KEY_ON_KEYBOARD, language), enabled)
}
}

/**
* Retrieves whether the clipboard key is enabled on the keyboard for a given language.
*/
fun getIsClipboardKeyEnabled(
context: Context,
language: String,
): Boolean {
val sharedPref = context.getSharedPreferences(SCRIBE_PREFS, Context.MODE_PRIVATE)
return sharedPref.getBoolean(getLanguageSpecificPreferenceKey(CLIPBOARD_KEY_ON_KEYBOARD, language), true)
}

/**
* Resets the application hints, marking them as not shown in the shared preferences.
*
Expand Down
26 changes: 26 additions & 0 deletions app/src/main/java/be/scri/ui/screens/LanguageSettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,13 @@ fun LanguageSettingsScreen(
)
}

val clipboardKeyOnKeyboardState =
remember {
mutableStateOf(
PreferencesHelper.getIsClipboardKeyEnabled(context, language),
)
}

val wordByWordDeletionState =
remember {
mutableStateOf(
Expand Down Expand Up @@ -154,6 +161,15 @@ fun LanguageSettingsScreen(
shouldDisableAccentCharacter,
)
},
toggleClipboardKeyOnKeyboard = clipboardKeyOnKeyboardState.value,
onToggleClipboardKeyOnKeyboard = { isEnabled ->
clipboardKeyOnKeyboardState.value = isEnabled
PreferencesHelper.setClipboardKeyPreference(
context,
language,
isEnabled,
)
},
onCurrencySelect = onCurrencySelect,
),
)
Expand Down Expand Up @@ -350,6 +366,8 @@ private fun getLayoutListData(
onTogglePeriodAndComma: (Boolean) -> Unit,
toggleDisableAccentCharacter: Boolean,
onToggleDisableAccentCharacter: (Boolean) -> Unit,
toggleClipboardKeyOnKeyboard: Boolean,
onToggleClipboardKeyOnKeyboard: (Boolean) -> Unit,
onCurrencySelect: () -> Unit,
): List<ScribeItem> {
val list: MutableList<ScribeItem> = mutableListOf()
Expand All @@ -375,6 +393,14 @@ private fun getLayoutListData(
onToggle = onTogglePeriodAndComma,
),
)
list.add(
ScribeItem.SwitchItem(
title = R.string.i18n_app_settings_keyboard_layout_clipboard_on_keyboard,
desc = R.string.i18n_app_settings_keyboard_layout_clipboard_on_keyboard_description,
state = toggleClipboardKeyOnKeyboard,
onToggle = onToggleClipboardKeyOnKeyboard,
),
)
list.add(
ScribeItem.ClickableItem(
title = R.string.i18n_app_settings_keyboard_layout_default_currency,
Expand Down
Loading
Loading