Skip to content
Snippets Groups Projects
Commit 03a028a9 authored by Aleksandras Kostarevas's avatar Aleksandras Kostarevas
Browse files

Fix some icons being untinted, add haptic vibration setting

parent 25229530
No related branches found
No related tags found
1 merge request!7Merge model-metadata to master
...@@ -130,44 +130,30 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch ...@@ -130,44 +130,30 @@ class BasicThemeProvider(val context: Context, val overrideColorScheme: ColorSch
colors[R.styleable.Keyboard_Key_keyPreviewTextColor] = onSecondary colors[R.styleable.Keyboard_Key_keyPreviewTextColor] = onSecondary
colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onBackgroundHalf colors[R.styleable.MainKeyboardView_languageOnSpacebarTextColor] = onBackgroundHalf
drawables[R.styleable.Keyboard_iconDeleteKey] = AppCompatResources.getDrawable( val overrideDrawable: (Int, Int, Int) -> Unit = { a, b, color ->
context, drawables[a] = AppCompatResources.getDrawable(
R.drawable.delete context,
)!!.apply { b
setTint(onBackground) )!!.apply {
} setTint(color)
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)
} }
drawables[R.styleable.Keyboard_iconShiftKey] = AppCompatResources.getDrawable( // No good replacements for these cons yet, but we set them anyway for setTint
context, overrideDrawable(R.styleable.Keyboard_iconEnterKey, R.drawable.sym_keyboard_return_lxx_light, onPrimary)
R.drawable.shift overrideDrawable(R.styleable.Keyboard_iconGoKey, R.drawable.sym_keyboard_go_lxx_light, onPrimary)
)!!.apply { overrideDrawable(R.styleable.Keyboard_iconNextKey, R.drawable.sym_keyboard_next_lxx_light, onPrimary)
setTint(onBackground) 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, overrideDrawable(R.styleable.Keyboard_iconDeleteKey, R.drawable.delete, onBackground)
R.drawable.shiftshifted overrideDrawable(R.styleable.Keyboard_iconSettingsKey, R.drawable.settings, onBackground)
)!!.apply { overrideDrawable(R.styleable.Keyboard_iconEmojiActionKey, R.drawable.smile, onPrimary)
setTint(onBackground) 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 primaryKeyboardColor = background
......
package org.futo.inputmethod.latin.uix.settings.pages package org.futo.inputmethod.latin.uix.settings.pages
import android.preference.PreferenceManager
import androidx.compose.runtime.Composable 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.platform.LocalContext
import androidx.compose.ui.res.booleanResource import androidx.compose.ui.res.booleanResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview 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.NavHostController
import androidx.navigation.compose.rememberNavController 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.R
import org.futo.inputmethod.latin.settings.Settings 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.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.ScreenTitle
import org.futo.inputmethod.latin.uix.settings.ScrollableList 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.SettingToggleDataStore
import org.futo.inputmethod.latin.uix.settings.SettingToggleSharedPrefs 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 @Preview
@Composable @Composable
fun TypingScreen(navController: NavHostController = rememberNavController()) { fun TypingScreen(navController: NavHostController = rememberNavController()) {
val context = LocalContext.current 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 { ScrollableList {
ScreenTitle("Typing Preferences", showBack = true, navController) ScreenTitle("Typing Preferences", showBack = true, navController)
...@@ -62,6 +91,6 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) { ...@@ -62,6 +91,6 @@ fun TypingScreen(navController: NavHostController = rememberNavController()) {
default = false 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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment