mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 13:49:13 +00:00
add more compose previews, and make them work better
This commit is contained in:
parent
1b5a793690
commit
e55b375f90
43 changed files with 425 additions and 193 deletions
|
@ -16,11 +16,13 @@ import android.graphics.Typeface;
|
|||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.ContextThemeWrapper;
|
||||
import android.view.inputmethod.EditorInfo;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.StringRes;
|
||||
|
||||
import helium314.keyboard.compat.ConfigurationCompatKt;
|
||||
import helium314.keyboard.keyboard.KeyboardActionListener;
|
||||
import helium314.keyboard.latin.AudioAndHapticFeedbackManager;
|
||||
import helium314.keyboard.latin.InputAttributes;
|
||||
|
@ -239,6 +241,14 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
|
|||
}
|
||||
}
|
||||
|
||||
/** convenience function for the rare situations where we need to load settings but may not have a keyboard */
|
||||
public void loadSettings(final Context context) {
|
||||
if (mSettingsValues != null) return;
|
||||
final Locale locale = ConfigurationCompatKt.locale(context.getResources().getConfiguration());
|
||||
final InputAttributes inputAttributes = new InputAttributes(new EditorInfo(), false, context.getPackageName());
|
||||
loadSettings(context, locale, inputAttributes);
|
||||
}
|
||||
|
||||
public void loadSettings(final Context context, final Locale locale,
|
||||
@NonNull final InputAttributes inputAttributes) {
|
||||
mSettingsValuesLock.lock();
|
||||
|
|
|
@ -26,12 +26,10 @@ public final class DeviceProtectedUtils {
|
|||
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return prefs;
|
||||
}
|
||||
Context deviceProtectedContext = getDeviceProtectedContext(context);
|
||||
if (deviceProtectedContext == null) { // not relevant in practice, but happens when compose previews access shared preferences
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
return prefs;
|
||||
}
|
||||
final Context deviceProtectedContext = getDeviceProtectedContext(context);
|
||||
prefs = PreferenceManager.getDefaultSharedPreferences(deviceProtectedContext);
|
||||
if (prefs.getAll() == null)
|
||||
return prefs; // happens for compose previews
|
||||
if (prefs.getAll().isEmpty()) {
|
||||
Log.i(TAG, "Device encrypted storage is empty, copying values from credential encrypted storage");
|
||||
deviceProtectedContext.moveSharedPreferencesFrom(context, android.preference.PreferenceManager.getDefaultSharedPreferencesName(context));
|
||||
|
@ -42,7 +40,9 @@ public final class DeviceProtectedUtils {
|
|||
// keep this private to avoid accidental use of device protected context anywhere in the app
|
||||
private static Context getDeviceProtectedContext(final Context context) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.N) return context;
|
||||
return context.isDeviceProtectedStorage() ? context : context.createDeviceProtectedStorageContext();
|
||||
final Context ctx = context.isDeviceProtectedStorage() ? context : context.createDeviceProtectedStorageContext();
|
||||
if (ctx == null) return context; // happens for compose previews
|
||||
else return ctx;
|
||||
}
|
||||
|
||||
public static File getFilesDir(final Context context) {
|
||||
|
|
|
@ -20,6 +20,7 @@ import helium314.keyboard.latin.R
|
|||
import helium314.keyboard.latin.common.FileUtils
|
||||
import helium314.keyboard.latin.common.decodeBase36
|
||||
import helium314.keyboard.latin.common.encodeBase36
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.LayoutType.Companion.folder
|
||||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
|
@ -84,6 +85,8 @@ object LayoutUtilsCustom {
|
|||
}
|
||||
|
||||
fun checkLayout(layoutContent: String, context: Context): Boolean {
|
||||
if (Settings.getValues() == null)
|
||||
Settings.getInstance().loadSettings(context)
|
||||
val params = KeyboardParams()
|
||||
params.mId = KeyboardLayoutSet.getFakeKeyboardId(KeyboardId.ELEMENT_ALPHABET)
|
||||
params.mPopupKeyTypes.add(POPUP_KEYS_LAYOUT)
|
||||
|
|
|
@ -9,7 +9,7 @@ import java.util.Locale
|
|||
fun <T> runInLocale(context: Context, locale: Locale, run: (Context) -> T): T {
|
||||
val config = Configuration(context.resources.configuration)
|
||||
config.setLocale(locale)
|
||||
val localeContext = context.createConfigurationContext(config)
|
||||
val localeContext = context.createConfigurationContext(config) ?: context
|
||||
return run(localeContext)
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import android.view.inputmethod.InputMethodSubtype
|
|||
import android.widget.Toast
|
||||
import androidx.core.app.LocaleManagerCompat
|
||||
import androidx.core.content.edit
|
||||
import helium314.keyboard.compat.locale
|
||||
import helium314.keyboard.keyboard.KeyboardSwitcher
|
||||
import helium314.keyboard.latin.RichInputMethodManager
|
||||
import helium314.keyboard.latin.common.Constants.Separators
|
||||
|
@ -104,11 +105,15 @@ object SubtypeSettings {
|
|||
|
||||
fun reloadSystemLocales(context: Context) {
|
||||
systemLocales.clear()
|
||||
try {
|
||||
val localeList = LocaleManagerCompat.getSystemLocales(context)
|
||||
(0 until localeList.size()).forEach {
|
||||
val locale = localeList[it]
|
||||
if (locale != null) systemLocales.add(locale)
|
||||
}
|
||||
} catch (_: Throwable) {
|
||||
systemLocales.add(context.resources.configuration.locale())
|
||||
}
|
||||
systemSubtypes.clear()
|
||||
}
|
||||
|
||||
|
|
|
@ -67,7 +67,7 @@ fun layoutFilePicker(
|
|||
@Composable
|
||||
fun dictionaryFilePicker(mainLocale: Locale?): ManagedActivityResultLauncher<Intent, ActivityResult> {
|
||||
val ctx = LocalContext.current
|
||||
val cachedDictionaryFile = File(ctx.cacheDir.path + File.separator + "temp_dict")
|
||||
val cachedDictionaryFile = File(ctx.cacheDir?.path + File.separator + "temp_dict")
|
||||
var done by remember { mutableStateOf(false) }
|
||||
val picker = filePicker { uri ->
|
||||
cachedDictionaryFile.delete()
|
||||
|
|
|
@ -5,6 +5,7 @@ import androidx.annotation.StringRes
|
|||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
|
@ -49,6 +50,8 @@ fun DefaultButton(isDefault: Boolean, onClick: () -> Unit) {
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
Column(horizontalAlignment = Alignment.CenterHorizontally) {
|
||||
NextScreenIcon()
|
||||
SearchIcon()
|
||||
|
@ -58,3 +61,5 @@ private fun Preview() {
|
|||
DefaultButton(false) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
18
app/src/main/java/helium314/keyboard/settings/Preview.kt
Normal file
18
app/src/main/java/helium314/keyboard/settings/Preview.kt
Normal file
|
@ -0,0 +1,18 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
package helium314.keyboard.settings
|
||||
|
||||
import android.content.Context
|
||||
import helium314.keyboard.keyboard.internal.KeyboardIconsSet
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
|
||||
// file is meant for making compose previews work
|
||||
|
||||
fun initPreview(context: Context) {
|
||||
Settings.init(context)
|
||||
SubtypeSettings.init(context)
|
||||
SettingsActivity.settingsContainer = SettingsContainer(context)
|
||||
KeyboardIconsSet.instance.loadIcons(context)
|
||||
}
|
||||
|
||||
const val previewDark = true
|
|
@ -1,3 +1,4 @@
|
|||
// SPDX-License-Identifier: GPL-3.0-only
|
||||
package helium314.keyboard.settings
|
||||
|
||||
import android.content.Context
|
||||
|
@ -202,13 +203,23 @@ fun WelcomeWizard(
|
|||
}
|
||||
}
|
||||
|
||||
@Preview(
|
||||
// content cut off on real device, but not here... great?
|
||||
device = "spec:orientation=landscape,width=400dp,height=780dp"
|
||||
)
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(true) {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
WelcomeWizard({}) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview(
|
||||
// content cut off on real device, but not here... great?
|
||||
device = "spec:orientation=landscape,width=400dp,height=780dp"
|
||||
)
|
||||
@Composable
|
||||
private fun WidePreview() {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
WelcomeWizard({}) { }
|
||||
}
|
||||
|
|
|
@ -33,6 +33,8 @@ import com.github.skydoves.colorpicker.compose.AlphaSlider
|
|||
import com.github.skydoves.colorpicker.compose.BrightnessSlider
|
||||
import com.github.skydoves.colorpicker.compose.HsvColorPicker
|
||||
import com.github.skydoves.colorpicker.compose.rememberColorPickerController
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun ColorPickerDialog(
|
||||
|
@ -144,5 +146,16 @@ fun ColorPickerDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
ColorPickerDialog({}, -0x0f4488aa, "color name", {})
|
||||
}
|
||||
}
|
||||
|
||||
// for some reason this is cut of while both previews are shown
|
||||
@Preview(device = "spec:orientation=landscape,width=400dp,height=780dp")
|
||||
@Composable
|
||||
private fun WidePreview() {
|
||||
Theme(previewDark) {
|
||||
ColorPickerDialog({}, -0x0f4488aa, "color name", {})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -54,8 +54,10 @@ import helium314.keyboard.settings.EditButton
|
|||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.SettingsDestination
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.filePicker
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import helium314.keyboard.settings.screens.SaveThoseColors
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.serialization.SerializationException
|
||||
|
@ -277,6 +279,7 @@ private fun loadColorString(colorString: String, prefs: SharedPreferences): Bool
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
ColorThemePickerDialog(
|
||||
onDismissRequest = {},
|
||||
setting = Setting(LocalContext.current, "", R.string.settings) {},
|
||||
|
@ -284,3 +287,4 @@ private fun Preview() {
|
|||
isNight = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
// taken from StreetComplete
|
||||
/** Slight specialization of an alert dialog: AlertDialog with OK and Cancel button. Both buttons
|
||||
|
@ -39,6 +41,7 @@ fun ConfirmationDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreviewConfirmDialog() {
|
||||
Theme(previewDark) {
|
||||
ConfirmationDialog(
|
||||
onDismissRequest = { },
|
||||
onConfirmed = {},
|
||||
|
@ -47,3 +50,4 @@ private fun PreviewConfirmDialog() {
|
|||
content = { Text(stringResource(R.string.disable_personalized_dicts_message)) }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,6 +42,9 @@ import helium314.keyboard.latin.R
|
|||
import helium314.keyboard.latin.customIconNames
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import helium314.keyboard.settings.screens.GetIcon
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
|
@ -178,9 +181,11 @@ fun CustomizeIconsDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
KeyboardIconsSet.instance.loadIcons(LocalContext.current)
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
CustomizeIconsDialog(
|
||||
prefKey = "",
|
||||
onDismissRequest = { },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,6 +22,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.em
|
||||
import helium314.keyboard.compat.locale
|
||||
|
@ -31,7 +32,9 @@ import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
|||
import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
||||
import helium314.keyboard.latin.utils.createDictionaryTextAnnotated
|
||||
import helium314.keyboard.settings.DeleteButton
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dictionaryFilePicker
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import helium314.keyboard.settings.screens.getUserAndInternalDictionaries
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -97,3 +100,11 @@ fun DictionaryDialog(
|
|||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
DictionaryDialog({}, Locale.ENGLISH)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,9 @@ package helium314.keyboard.settings.dialogs
|
|||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun InfoDialog(
|
||||
|
@ -18,3 +21,11 @@ fun InfoDialog(
|
|||
confirmButtonText = null
|
||||
)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
InfoDialog("message") { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -17,16 +17,21 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.platform.LocalDensity
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.utils.LayoutType
|
||||
import helium314.keyboard.latin.utils.LayoutUtilsCustom
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.SettingsSubtype
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.settings.CloseIcon
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import kotlinx.coroutines.Job
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -114,3 +119,13 @@ fun LayoutEditDialog(
|
|||
|
||||
// the job is here (outside the composable to make sure old jobs are canceled
|
||||
private var errorJob: Job? = null
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
val content = LocalContext.current.assets.open("layouts/main/dvorak.json").reader().readText()
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
LayoutEditDialog({}, LayoutType.MAIN, "qwerty", locale = Locale.ENGLISH, startContent = content) { true }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,9 +48,11 @@ import helium314.keyboard.settings.DeleteButton
|
|||
import helium314.keyboard.settings.EditButton
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.layoutFilePicker
|
||||
import helium314.keyboard.settings.layoutIntent
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun LayoutPickerDialog(
|
||||
|
@ -211,9 +213,11 @@ private fun LayoutItemRow(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
LayoutPickerDialog(
|
||||
onDismissRequest = {},
|
||||
setting = Setting(LocalContext.current, "", R.string.settings) {},
|
||||
layoutType = LayoutType.SYMBOLS
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,6 +25,8 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
// taken from StreetComplete
|
||||
@Composable
|
||||
|
@ -100,6 +102,7 @@ fun <T: Any> ListPickerDialog(
|
|||
@Composable
|
||||
private fun PreviewListPickerDialog() {
|
||||
val items = remember { (0..<5).toList() }
|
||||
Theme(previewDark) {
|
||||
ListPickerDialog(
|
||||
onDismissRequest = {},
|
||||
items = items,
|
||||
|
@ -109,3 +112,4 @@ private fun PreviewListPickerDialog() {
|
|||
getItemName = { "Item $it" },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -24,6 +24,8 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
// modified version of ListPickerDialog for selecting multiple items
|
||||
@Composable
|
||||
|
@ -83,6 +85,7 @@ fun <T: Any> MultiListPickerDialog(
|
|||
@Composable
|
||||
private fun Preview() {
|
||||
val items = remember { (0..<5).toList() }
|
||||
Theme(previewDark) {
|
||||
MultiListPickerDialog(
|
||||
onDismissRequest = {},
|
||||
items = items,
|
||||
|
@ -92,3 +95,4 @@ private fun Preview() {
|
|||
getItemName = { "Item $it" },
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,6 @@ import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
|||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
|
|
|
@ -26,6 +26,8 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import sh.calvin.reorderable.ReorderableItem
|
||||
import sh.calvin.reorderable.rememberReorderableLazyListState
|
||||
|
||||
|
@ -93,6 +95,7 @@ fun <T: Any> ReorderDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
ReorderDialog(
|
||||
onConfirmed = {},
|
||||
onDismissRequest = {},
|
||||
|
@ -101,3 +104,4 @@ private fun Preview() {
|
|||
getKey = { it.toString() }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun SliderDialog(
|
||||
|
@ -70,6 +72,7 @@ fun SliderDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreviewSliderDialog() {
|
||||
Theme(previewDark) {
|
||||
SliderDialog(
|
||||
onDismissRequest = { },
|
||||
onDone = { },
|
||||
|
@ -79,3 +82,4 @@ private fun PreviewSliderDialog() {
|
|||
showDefault = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,6 +35,7 @@ import androidx.compose.ui.platform.LocalContext
|
|||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.keyboard.internal.KeyboardIconsSet
|
||||
import helium314.keyboard.keyboard.internal.keyboard_parser.POPUP_KEYS_ALL
|
||||
|
@ -72,8 +73,11 @@ import helium314.keyboard.latin.utils.mainLayoutName
|
|||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.DefaultButton
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.layoutFilePicker
|
||||
import helium314.keyboard.settings.layoutIntent
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import helium314.keyboard.settings.screens.GetIcon
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -496,3 +500,12 @@ fun <T>DropDownField(
|
|||
|
||||
private fun getAvailableSecondaryLocales(context: Context, mainLocale: Locale): List<Locale> =
|
||||
getDictionaryLocales(context).filter { it != mainLocale && it.script() == mainLocale.script() }
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
SubtypeDialog({}, SettingsSubtype(Locale.ENGLISH, "")) { }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,8 @@ import androidx.compose.ui.text.input.KeyboardType
|
|||
import androidx.compose.ui.text.input.TextFieldValue
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
// mostly taken from StreetComplete / SCEE
|
||||
/** Dialog with which to input text. OK button is only clickable if [checkTextValid] returns true. */
|
||||
|
@ -85,6 +87,7 @@ fun TextInputDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(previewDark) {
|
||||
TextInputDialog(
|
||||
onDismissRequest = {},
|
||||
onConfirmed = {},
|
||||
|
@ -94,3 +97,4 @@ private fun Preview() {
|
|||
textInputLabel = { Text("fill it") }
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.window.Dialog
|
||||
import androidx.compose.ui.window.DialogProperties
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun ThreeButtonAlertDialog(
|
||||
|
@ -98,7 +99,7 @@ fun ThreeButtonAlertDialog(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme {
|
||||
Theme(previewDark) {
|
||||
ThreeButtonAlertDialog(
|
||||
onDismissRequest = {},
|
||||
onConfirmed = { },
|
||||
|
|
|
@ -26,7 +26,6 @@ import androidx.compose.ui.unit.dp
|
|||
import helium314.keyboard.keyboard.internal.KeyboardIconsSet
|
||||
import helium314.keyboard.keyboard.internal.keyboard_parser.floris.KeyCode.checkAndConvertCode
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.ToolbarKey
|
||||
import helium314.keyboard.latin.utils.getCodeForToolbarKey
|
||||
import helium314.keyboard.latin.utils.getCodeForToolbarKeyLongClick
|
||||
|
@ -34,6 +33,9 @@ import helium314.keyboard.latin.utils.getStringResourceOrName
|
|||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.latin.utils.readCustomKeyCodes
|
||||
import helium314.keyboard.latin.utils.writeCustomKeyCodes
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import helium314.keyboard.settings.screens.GetIcon
|
||||
|
||||
@Composable
|
||||
|
@ -138,21 +140,22 @@ private fun ToolbarKeyCustomizer(
|
|||
)
|
||||
}
|
||||
|
||||
private fun checkCode(code: TextFieldValue) = runCatching {
|
||||
code.text.toIntOrNull()?.takeIf { it.checkAndConvertCode() <= Char.MAX_VALUE.code }
|
||||
}.getOrNull()
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewToolbarKeyCustomizer() {
|
||||
Settings.init(LocalContext.current)
|
||||
private fun PreviewToolbarKeyCustomizer() {
|
||||
initPreview(LocalContext.current)
|
||||
ToolbarKeyCustomizer(ToolbarKey.CUT) { }
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
fun PreviewToolbarKeysCustomizer() {
|
||||
Settings.init(LocalContext.current)
|
||||
KeyboardIconsSet.instance.loadIcons(LocalContext.current)
|
||||
private fun PreviewToolbarKeysCustomizer() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
ToolbarKeysCustomizer("") { }
|
||||
}
|
||||
|
||||
private fun checkCode(code: TextFieldValue) = runCatching {
|
||||
code.text.toIntOrNull()?.takeIf { it.checkAndConvertCode() <= Char.MAX_VALUE.code }
|
||||
}.getOrNull()
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ fun LoadGestureLibPreference(setting: Setting) {
|
|||
val ctx = LocalContext.current
|
||||
val prefs = ctx.protectedPrefs()
|
||||
val abi = Build.SUPPORTED_ABIS[0]
|
||||
val libFile = File(ctx.filesDir.absolutePath + File.separator + JniUtils.JNI_LIB_IMPORT_FILE_NAME)
|
||||
val libFile = File(ctx.filesDir?.absolutePath + File.separator + JniUtils.JNI_LIB_IMPORT_FILE_NAME)
|
||||
fun renameToLibFileAndRestart(file: File, checksum: String) {
|
||||
libFile.delete()
|
||||
// store checksum in default preferences (soo JniUtils)
|
||||
|
|
|
@ -29,6 +29,8 @@ import androidx.compose.ui.text.style.TextAlign
|
|||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
// partially taken from StreetComplete / SCEE
|
||||
|
||||
|
@ -105,6 +107,7 @@ fun Preference(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreferencePreview() {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
Column {
|
||||
PreferenceCategory("Preference Category")
|
||||
|
@ -164,3 +167,4 @@ private fun PreferencePreview() {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,6 +38,7 @@ import helium314.keyboard.settings.preferences.Preference
|
|||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
import java.text.SimpleDateFormat
|
||||
|
@ -177,7 +178,7 @@ fun createAboutSettings(context: Context) = listOf(
|
|||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
AboutScreen { }
|
||||
}
|
||||
|
|
|
@ -45,6 +45,7 @@ import helium314.keyboard.settings.dialogs.TextInputDialog
|
|||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.preferences.BackupRestorePreference
|
||||
import helium314.keyboard.settings.preferences.LoadGestureLibPreference
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun AdvancedSettingsScreen(
|
||||
|
@ -235,7 +236,7 @@ fun createAdvancedSettings(context: Context) = listOf(
|
|||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
AdvancedSettingsScreen { }
|
||||
}
|
||||
|
|
|
@ -23,7 +23,6 @@ import helium314.keyboard.latin.utils.Log
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.getStringResourceOrName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.preferences.ListPreference
|
||||
import helium314.keyboard.settings.SettingsWithoutKey
|
||||
import helium314.keyboard.settings.Setting
|
||||
|
@ -36,9 +35,11 @@ import helium314.keyboard.settings.Theme
|
|||
import helium314.keyboard.settings.dialogs.ColorThemePickerDialog
|
||||
import helium314.keyboard.settings.dialogs.CustomizeIconsDialog
|
||||
import helium314.keyboard.settings.dialogs.TextInputDialog
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.preferences.BackgroundImagePref
|
||||
import helium314.keyboard.settings.preferences.CustomFontPreference
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun AppearanceScreen(
|
||||
|
@ -307,8 +308,8 @@ fun createAppearanceSettings(context: Context) = listOf(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
AppearanceScreen { }
|
||||
}
|
||||
|
|
|
@ -61,6 +61,7 @@ import helium314.keyboard.settings.SearchScreen
|
|||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.ColorPickerDialog
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import kotlinx.serialization.Serializable
|
||||
import kotlinx.serialization.json.Json
|
||||
|
||||
|
@ -239,7 +240,7 @@ data class SaveThoseColors(val name: String? = null, val moreColors: Int, val co
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
Theme(true) {
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
ColorsScreen(false, null) { }
|
||||
}
|
||||
|
|
|
@ -18,15 +18,15 @@ import helium314.keyboard.latin.settings.DebugSettings
|
|||
import helium314.keyboard.latin.settings.DebugSettingsFragment
|
||||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.preferences.Preference
|
||||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.preferences.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.preferences.PreferenceCategory
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun DebugScreen(
|
||||
|
@ -111,8 +111,8 @@ private fun createDebugSettings(context: Context) = listOf(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
DebugScreen { }
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import androidx.compose.foundation.layout.Column
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -18,6 +19,7 @@ import androidx.compose.ui.Modifier
|
|||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.Dictionary
|
||||
import helium314.keyboard.latin.R
|
||||
|
@ -34,9 +36,12 @@ import helium314.keyboard.latin.utils.appendLink
|
|||
import helium314.keyboard.latin.utils.getDictionaryLocales
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.ConfirmationDialog
|
||||
import helium314.keyboard.settings.dialogs.DictionaryDialog
|
||||
import helium314.keyboard.settings.dictionaryFilePicker
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -138,3 +143,14 @@ fun getUserAndInternalDictionaries(context: Context, locale: Locale): Pair<List<
|
|||
}
|
||||
return userDicts to (best != null)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
DictionaryScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,17 +11,19 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.JniUtils
|
||||
import helium314.keyboard.latin.utils.Log
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.preferences.SliderPreference
|
||||
import helium314.keyboard.settings.preferences.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun GestureTypingScreen(
|
||||
|
@ -112,8 +114,9 @@ fun createGestureTypingSettings(context: Context) = listOf(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
JniUtils.sHaveGestureLib = true
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
GestureTypingScreen { }
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import androidx.compose.foundation.layout.Row
|
|||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Switch
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
|
@ -23,6 +24,7 @@ import androidx.compose.ui.Alignment
|
|||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.common.Constants.Separators
|
||||
|
@ -45,7 +47,10 @@ import helium314.keyboard.latin.utils.locale
|
|||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.SubtypeDialog
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import java.util.Locale
|
||||
|
||||
@Composable
|
||||
|
@ -167,3 +172,14 @@ private fun getSortedSubtypes(context: Context): List<InputMethodSubtype> {
|
|||
)
|
||||
return SubtypeSettings.getAllAvailableSubtypes().sortedWith(subtypeSortComparator)
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
LanguageScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -23,13 +23,14 @@ import helium314.keyboard.latin.utils.JniUtils
|
|||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.displayName
|
||||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.latin.utils.switchTo
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.preferences.Preference
|
||||
import helium314.keyboard.settings.preferences.PreferenceCategory
|
||||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun MainSettingsScreen(
|
||||
|
@ -146,7 +147,8 @@ fun MainSettingsScreen(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreviewScreen() {
|
||||
Theme(true) {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
MainSettingsScreen({}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {})
|
||||
}
|
||||
|
|
|
@ -8,12 +8,14 @@ import androidx.compose.foundation.layout.fillMaxWidth
|
|||
import androidx.compose.foundation.layout.heightIn
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.common.splitOnWhitespace
|
||||
|
@ -25,6 +27,9 @@ import helium314.keyboard.latin.utils.locale
|
|||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.SettingsDestination
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.previewDark
|
||||
import java.util.Locale
|
||||
import java.util.TreeSet
|
||||
|
||||
|
@ -83,3 +88,14 @@ fun getSortedDictionaryLocales(): TreeSet<Locale> {
|
|||
sortedLocales.addAll(getSystemLocales())
|
||||
return sortedLocales
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
PersonalDictionariesScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,7 +19,6 @@ import helium314.keyboard.latin.utils.SubtypeSettings
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.preferences.ListPreference
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.preferences.ReorderSwitchPreference
|
||||
|
@ -28,7 +27,9 @@ import helium314.keyboard.settings.SettingsActivity
|
|||
import helium314.keyboard.settings.preferences.SliderPreference
|
||||
import helium314.keyboard.settings.preferences.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun PreferencesScreen(
|
||||
|
@ -186,8 +187,8 @@ private val localesWithLocalizedNumberRow = listOf("ar", "bn", "fa", "gu", "hi",
|
|||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
PreferencesScreen { }
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
package helium314.keyboard.settings.screens
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.material3.Surface
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
|
@ -10,6 +11,7 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.latin.utils.LayoutType
|
||||
|
@ -22,8 +24,11 @@ import helium314.keyboard.latin.utils.prefs
|
|||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.LayoutPickerDialog
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.preferences.Preference
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun SecondaryLayoutScreen(
|
||||
|
@ -62,3 +67,14 @@ fun createLayoutSettings(context: Context) = LayoutType.entries.filter { it != L
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
SecondaryLayoutScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,7 +25,6 @@ import helium314.keyboard.latin.utils.Log
|
|||
import helium314.keyboard.latin.utils.getActivity
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.NextScreenIcon
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.preferences.ListPreference
|
||||
import helium314.keyboard.settings.SettingsWithoutKey
|
||||
import helium314.keyboard.settings.Setting
|
||||
|
@ -36,7 +35,9 @@ import helium314.keyboard.settings.SettingsDestination
|
|||
import helium314.keyboard.settings.preferences.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.ConfirmationDialog
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun TextCorrectionScreen(
|
||||
|
@ -203,8 +204,8 @@ fun createCorrectionSettings(context: Context) = listOf(
|
|||
@Preview
|
||||
@Composable
|
||||
private fun PreferencePreview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
Theme(true) {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
TextCorrectionScreen { }
|
||||
}
|
||||
|
|
|
@ -27,17 +27,16 @@ import helium314.keyboard.keyboard.internal.KeyboardIconsSet
|
|||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.settings.Defaults
|
||||
import helium314.keyboard.latin.settings.Settings
|
||||
import helium314.keyboard.settings.SettingsContainer
|
||||
import helium314.keyboard.settings.SettingsWithoutKey
|
||||
import helium314.keyboard.settings.Setting
|
||||
import helium314.keyboard.settings.preferences.Preference
|
||||
import helium314.keyboard.settings.preferences.ReorderSwitchPreference
|
||||
import helium314.keyboard.settings.SearchSettingsScreen
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.preferences.SwitchPreference
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.dialogs.ToolbarKeysCustomizer
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.keyboardNeedsReload
|
||||
import helium314.keyboard.settings.previewDark
|
||||
|
||||
@Composable
|
||||
fun ToolbarScreen(
|
||||
|
@ -102,18 +101,6 @@ fun createToolbarSettings(context: Context) = listOf(
|
|||
}
|
||||
)
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
SettingsActivity.settingsContainer = SettingsContainer(LocalContext.current)
|
||||
KeyboardIconsSet.instance.loadIcons(LocalContext.current)
|
||||
Theme(true) {
|
||||
Surface {
|
||||
ToolbarScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun KeyboardIconsSet.GetIcon(name: String?) {
|
||||
val ctx = LocalContext.current
|
||||
|
@ -127,3 +114,14 @@ fun KeyboardIconsSet.GetIcon(name: String?) {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Preview
|
||||
@Composable
|
||||
private fun Preview() {
|
||||
initPreview(LocalContext.current)
|
||||
Theme(previewDark) {
|
||||
Surface {
|
||||
ToolbarScreen { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue