Skip to content
Merged
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
4 changes: 0 additions & 4 deletions app/src/keyboards/java/be/scri/services/GeneralKeyboardIME.kt
Original file line number Diff line number Diff line change
Expand Up @@ -651,10 +651,6 @@ abstract class GeneralKeyboardIME(
return isActionSearch || isUriType || hasSearchHint
}

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

override fun isFloatingKeyEnabled(): Boolean = PreferencesHelper.getIsFloatingKeyEnabled(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
Submodule i18n updated 1 files
+2 −2 i18n/locales/en-US.json
4 changes: 0 additions & 4 deletions app/src/main/java/be/scri/helpers/KeyboardBase.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,6 @@ class KeyboardBase {
fun isSearchBar(): Boolean

fun isFloatingModeActive(): Boolean

fun isClipboardKeyEnabled(): Boolean

fun isFloatingKeyEnabled(): Boolean
}

/** Horizontal gap default for all rows */
Expand Down
52 changes: 0 additions & 52 deletions app/src/main/java/be/scri/helpers/PreferencesHelper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@ 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"
private const val FLOATING_KEY_ON_KEYBOARD = "floating_key_on_keyboard"

/**
* Sets the translation source language for a given language.
Expand Down Expand Up @@ -536,56 +534,6 @@ 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)
}

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

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

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

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

val floatingKeyOnKeyboardState =
remember {
mutableStateOf(
PreferencesHelper.getIsFloatingKeyEnabled(context, language),
)
}
val wordByWordDeletionState =
remember {
mutableStateOf(
Expand Down Expand Up @@ -167,24 +154,6 @@ fun LanguageSettingsScreen(
shouldDisableAccentCharacter,
)
},
toggleClipboardKeyOnKeyboard = clipboardKeyOnKeyboardState.value,
onToggleClipboardKeyOnKeyboard = { isEnabled ->
clipboardKeyOnKeyboardState.value = isEnabled
PreferencesHelper.setClipboardKeyPreference(
context,
language,
isEnabled,
)
},
toggleFloatingKeyOnKeyboard = floatingKeyOnKeyboardState.value,
onToggleFloatingKeyOnKeyboard = { isEnabled ->
floatingKeyOnKeyboardState.value = isEnabled
PreferencesHelper.setFloatingKeyPreference(
context,
language,
isEnabled,
)
},
onCurrencySelect = onCurrencySelect,
),
)
Expand Down Expand Up @@ -374,17 +343,12 @@ private fun getFunctionalityListData(settings: FunctionalitySettings): List<Scri
*
* @return A list of [ScribeItem]s to be displayed in the UI.
*/
@Suppress("LongParameterList", "UnusedParameter")
private fun getLayoutListData(
language: String,
togglePeriodAndCommaState: Boolean,
onTogglePeriodAndComma: (Boolean) -> Unit,
toggleDisableAccentCharacter: Boolean,
onToggleDisableAccentCharacter: (Boolean) -> Unit,
toggleClipboardKeyOnKeyboard: Boolean,
onToggleClipboardKeyOnKeyboard: (Boolean) -> Unit,
toggleFloatingKeyOnKeyboard: Boolean,
onToggleFloatingKeyOnKeyboard: (Boolean) -> Unit,
onCurrencySelect: () -> Unit,
): List<ScribeItem> {
val list: MutableList<ScribeItem> = mutableListOf()
Expand All @@ -411,14 +375,6 @@ private fun getLayoutListData(
),
)

list.add(
ScribeItem.SwitchItem(
title = R.string.i18n_app_settings_keyboard_layout_floating_on_keyboard,
desc = R.string.i18n_app_settings_keyboard_layout_floating_on_keyboard_description,
state = toggleFloatingKeyOnKeyboard,
onToggle = onToggleFloatingKeyOnKeyboard,
),
)
list.add(
ScribeItem.ClickableItem(
title = R.string.i18n_app_settings_keyboard_layout_default_currency,
Expand Down
12 changes: 12 additions & 0 deletions app/src/main/java/be/scri/views/KeyboardView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1151,6 +1151,18 @@ class KeyboardView
key.icon = resources.getDrawable(drawableId)
key.icon!!.applyColorFilter(mTextColor)
} else {
if (code == KeyboardBase.KEYCODE_FLOAT_TOGGLE) {
val isFloating =
(context as? KeyboardBase.KeyboardContextProvider)?.isFloatingModeActive() == true ||
(mPopupParent?.context as? KeyboardBase.KeyboardContextProvider)?.isFloatingModeActive() == true
val floatIconRes =
if (isFloating) {
R.drawable.ic_keyboard_dismiss
} else {
R.drawable.ic_float_keyboard
}
key.icon = resources.getDrawable(floatIconRes, context.theme)
}
val isIconOnlyKey =
code == KEYCODE_DELETE ||
code == KEYCODE_SHIFT ||
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/drawable/ic_keyboard_dismiss.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/theme_scribe_blue"
android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6l-6,-6L7.41,8.59z"/>
android:fillColor="#FFFFFFFF"
android:pathData="M19,3H5C3.9,3 3,3.9 3,5v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2V5C21,3.9 20.1,3 19,3z M19,19H5V5h14V19z M16.59,8.59L12,13.17L7.41,8.59L6,10l6,6l6,-6L16.59,8.59z"/>
</vector>

4 changes: 0 additions & 4 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,5 @@
<string name="drag_keyboard">Drag keyboard</string>
<string name="clipboard">Clipboard</string>
<string name="floating_keyboard">Floating keyboard</string>
<string name="i18n.app.settings.keyboard.layout.clipboard_on_keyboard">Clipboard key on keyboard</string>
<string name="i18n.app.settings.keyboard.layout.clipboard_on_keyboard_description">Include a key to access the clipboard on the main keyboard.</string>
<string name="i18n.app.settings.keyboard.layout.floating_on_keyboard">Floating key on keyboard</string>
<string name="i18n.app.settings.keyboard.layout.floating_on_keyboard_description">Include a key to float the keyboard UI on the main keyboard.</string>
</resources>

Loading