diff --git a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt index 41b0e1372..21b0ef8eb 100644 --- a/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt +++ b/java/src/org/futo/inputmethod/latin/uix/BasicThemeProvider.kt @@ -130,44 +130,30 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch colors[R.styleable.Keyboard_Key_keyPreviewTextColor] = onSecondary colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onBackgroundHalf - drawables[R.styleable.Keyboard_iconDeleteKey] = AppCompatResources.getDrawable( - context, - R.drawable.delete - )!!.apply { - setTint(onBackground) - } - drawables[R.styleable.Keyboard_iconSettingsKey] = AppCompatResources.getDrawable( - context, - R.drawable.settings - )!!.apply { - setTint(onPrimary) - } - drawables[R.styleable.Keyboard_iconEnterKey] = AppCompatResources.getDrawable( - context, - R.drawable.sym_keyboard_return_lxx_light - )!!.apply { - setTint(onPrimary) - } - drawables[R.styleable.Keyboard_iconLanguageSwitchKey] = AppCompatResources.getDrawable( - context, - R.drawable.globe - )!!.apply { - setTint(onBackground) + val overrideDrawable: (Int, Int, Int) -> Unit = { a, b, color -> + drawables[a] = AppCompatResources.getDrawable( + context, + b + )!!.apply { + setTint(color) + } } - drawables[R.styleable.Keyboard_iconShiftKey] = AppCompatResources.getDrawable( - context, - R.drawable.shift - )!!.apply { - setTint(onBackground) - } + // No good replacements for these cons yet, but we set them anyway for setTint + overrideDrawable(R.styleable.Keyboard_iconEnterKey, R.drawable.sym_keyboard_return_lxx_light, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconGoKey, R.drawable.sym_keyboard_go_lxx_light, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconNextKey, R.drawable.sym_keyboard_next_lxx_light, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconDoneKey, R.drawable.sym_keyboard_done_lxx_light, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconPreviousKey, R.drawable.sym_keyboard_previous_lxx_light, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconSearchKey, R.drawable.sym_keyboard_search_lxx_light, onPrimary) - drawables[R.styleable.Keyboard_iconShiftKeyShifted] = AppCompatResources.getDrawable( - context, - R.drawable.shiftshifted - )!!.apply { - setTint(onBackground) - } + overrideDrawable(R.styleable.Keyboard_iconDeleteKey, R.drawable.delete, onBackground) + overrideDrawable(R.styleable.Keyboard_iconSettingsKey, R.drawable.settings, onBackground) + overrideDrawable(R.styleable.Keyboard_iconEmojiActionKey, R.drawable.smile, onPrimary) + overrideDrawable(R.styleable.Keyboard_iconEmojiNormalKey, R.drawable.smile, onBackground) + overrideDrawable(R.styleable.Keyboard_iconLanguageSwitchKey, R.drawable.globe, onBackground) + overrideDrawable(R.styleable.Keyboard_iconShiftKey, R.drawable.shift, onBackground) + overrideDrawable(R.styleable.Keyboard_iconShiftKeyShifted, R.drawable.shiftshifted, onBackground) primaryKeyboardColor = background diff --git a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt index 95438a9ba..0c430a441 100644 --- a/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt +++ b/java/src/org/futo/inputmethod/latin/uix/settings/pages/Typing.kt @@ -1,24 +1,53 @@ package org.futo.inputmethod.latin.uix.settings.pages +import android.preference.PreferenceManager import androidx.compose.runtime.Composable +import androidx.compose.runtime.LaunchedEffect +import androidx.compose.runtime.remember import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.res.booleanResource import androidx.compose.ui.res.stringResource import androidx.compose.ui.tooling.preview.Preview +import androidx.core.content.edit +import androidx.datastore.preferences.core.intPreferencesKey import androidx.navigation.NavHostController import androidx.navigation.compose.rememberNavController +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext import org.futo.inputmethod.latin.R import org.futo.inputmethod.latin.settings.Settings +import org.futo.inputmethod.latin.settings.Settings.PREF_VIBRATION_DURATION_SETTINGS import org.futo.inputmethod.latin.uix.SHOW_EMOJI_SUGGESTIONS +import org.futo.inputmethod.latin.uix.SettingsKey import org.futo.inputmethod.latin.uix.settings.ScreenTitle import org.futo.inputmethod.latin.uix.settings.ScrollableList +import org.futo.inputmethod.latin.uix.settings.SettingRadio import org.futo.inputmethod.latin.uix.settings.SettingToggleDataStore import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs +import org.futo.inputmethod.latin.uix.settings.useDataStore +import org.futo.inputmethod.latin.uix.settings.useSharedPrefsBool + +val vibrationDurationSetting = SettingsKey( + intPreferencesKey("vibration_duration"), + -1 +) @Preview @Composable fun TypingScreen(navController: NavHostController = rememberNavController()) { val context = LocalContext.current + val (vibration, _) = useDataStore(key = vibrationDurationSetting.key, default = vibrationDurationSetting.default) + + LaunchedEffect(vibration) { + val sharedPrefs = PreferenceManager.getDefaultSharedPreferences(context) + withContext(Dispatchers.Main) { + sharedPrefs.edit { + putInt(PREF_VIBRATION_DURATION_SETTINGS, vibration) + } + } + } + ScrollableList { ScreenTitle("Typing Preferences", showBack = true, navController) @@ -62,6 +91,6 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) { default = false ) - // TODO: SeekBarDialogPreference pref_vibration_duration_settings etc + SettingRadio(title = "Vibration Duration", options = listOf(-1, 5, 10, 20, 40), optionNames = listOf("Default", "Low", "Medium", "High", "Higher"), setting = vibrationDurationSetting) } } \ No newline at end of file