migrate preferences to androidx (bad state... wip)

This commit is contained in:
Helium314 2023-09-01 18:20:09 +02:00
parent 70a86d9326
commit 71187f4b32
26 changed files with 263 additions and 288 deletions

View file

@ -47,7 +47,6 @@ public class Colors {
private ColorStateList adjustedBackgroundStateList; private ColorStateList adjustedBackgroundStateList;
public static Colors newColors(String themeStyle, int accent, int background, int keyBackground, int functionalKey, int spaceBar, int keyText, int keyHintText) { public static Colors newColors(String themeStyle, int accent, int background, int keyBackground, int functionalKey, int spaceBar, int keyText, int keyHintText) {
Log.i("test1", "colors with style "+themeStyle);
if (themeStyle.equals(KeyboardTheme.THEME_STYLE_HOLO)) if (themeStyle.equals(KeyboardTheme.THEME_STYLE_HOLO))
return new HoloColors(accent, background, keyBackground, functionalKey, spaceBar, keyText, keyHintText); return new HoloColors(accent, background, keyBackground, functionalKey, spaceBar, keyText, keyHintText);
return new Colors(accent, background, keyBackground, functionalKey, spaceBar, keyText, keyHintText); return new Colors(accent, background, keyBackground, functionalKey, spaceBar, keyText, keyHintText);

View file

@ -14,18 +14,19 @@
* limitations under the License. * limitations under the License.
*/ */
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import org.dslul.openboard.inputmethod.latin.BuildConfig; import androidx.preference.Preference;
import org.dslul.openboard.inputmethod.latin.R;
/** import org.dslul.openboard.inputmethod.latin.BuildConfig;
import org.dslul.openboard.inputmethod.latin.R;
/**
* "About" sub screen. * "About" sub screen.
*/ */
public final class AboutFragment extends SubScreenFragment { public final class AboutFragment extends SubScreenFragment {
@Override @Override
public void onCreate(final Bundle icicle) { public void onCreate(final Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
@ -33,4 +34,4 @@
Preference versionPreference = findPreference("pref_key_version"); Preference versionPreference = findPreference("pref_key_version");
versionPreference.setSummary(BuildConfig.VERSION_NAME); versionPreference.setSummary(BuildConfig.VERSION_NAME);
} }
} }

View file

@ -24,9 +24,9 @@ import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager; import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;

View file

@ -21,12 +21,11 @@ import android.content.res.Configuration
import android.graphics.Color import android.graphics.Color
import android.os.Build import android.os.Build
import android.os.Bundle import android.os.Bundle
import android.preference.ListPreference
import android.preference.Preference
import android.preference.TwoStatePreference
import android.util.Log
import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AlertDialog
import androidx.core.content.edit import androidx.core.content.edit
import androidx.preference.ListPreference
import androidx.preference.Preference
import androidx.preference.TwoStatePreference
import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher import org.dslul.openboard.inputmethod.keyboard.KeyboardSwitcher
import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme import org.dslul.openboard.inputmethod.keyboard.KeyboardTheme
import org.dslul.openboard.inputmethod.latin.R import org.dslul.openboard.inputmethod.latin.R
@ -91,8 +90,9 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
setupTheme() setupTheme()
val widthDp = activity.resources.displayMetrics.widthPixels / activity.resources.displayMetrics.density val metrics = requireContext().resources.displayMetrics
val heightDp = activity.resources.displayMetrics.heightPixels / activity.resources.displayMetrics.density val widthDp = metrics.widthPixels / metrics.density
val heightDp = metrics.heightPixels / metrics.density
if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED || (min(widthDp, heightDp) < 600 && max(widthDp, heightDp) < 720)) { if (!ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED || (min(widthDp, heightDp) < 600 && max(widthDp, heightDp) < 720)) {
removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD) removePreference(Settings.PREF_ENABLE_SPLIT_KEYBOARD)
} }
@ -110,7 +110,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
override fun onPause() { override fun onPause() {
super.onPause() super.onPause()
// if (needsReload) // todo: until re-working settings, just always reload // if (needsReload) // todo: until re-working settings, just always reload
KeyboardSwitcher.getInstance().forceUpdateKeyboardTheme(activity) KeyboardSwitcher.getInstance().forceUpdateKeyboardTheme(requireContext())
needsReload = false needsReload = false
} }
@ -124,7 +124,6 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String) { override fun onSharedPreferenceChanged(prefs: SharedPreferences, key: String) {
super.onSharedPreferenceChanged(prefs, key) super.onSharedPreferenceChanged(prefs, key)
Log.i("test1", "changed pref $key to ${prefs.all.filter { it.key == key }}")
updateAfterPreferenceChanged() updateAfterPreferenceChanged()
} }
@ -135,29 +134,29 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
// show preference to allow choosing a night theme // show preference to allow choosing a night theme
// can't hide a preference, at least not without category or maybe some androidx things // can't hide a preference, at least not without category or maybe some androidx things
// -> just disable it instead (for now...) // -> just disable it instead (for now...)
isEnabled = sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) isEnabled = sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false)
} else } else
isEnabled = false isEnabled = false
val variant = sharedPreferences.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER) val variant = sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER)
val variants = KeyboardTheme.THEME_VARIANTS_DARK val variants = KeyboardTheme.THEME_VARIANTS_DARK
entries = variants.map { entries = variants.map {
// todo: this workaround get the same string as for "user" theme, maybe clarify that it's a separate theme // todo: this workaround get the same string as for "user" theme, maybe clarify that it's a separate theme
val name = if (it == "user_dark") "theme_name_user" else "theme_name_$it" val name = if (it == "user_dark") "theme_name_user" else "theme_name_$it"
val resId = resources.getIdentifier(name, "string", activity.packageName) val resId = resources.getIdentifier(name, "string", requireContext().packageName)
if (resId == 0) it else getString(resId) if (resId == 0) it else getString(resId)
}.toTypedArray() }.toTypedArray()
entryValues = variants entryValues = variants
value = variant value = variant
val name = if (variant == "user_dark") "theme_name_user" else "theme_name_$variant" val name = if (variant == "user_dark") "theme_name_user" else "theme_name_$variant"
val resId = resources.getIdentifier(name, "string", activity.packageName) val resId = resources.getIdentifier(name, "string", requireContext().packageName)
summary = if (resId == 0) variant else getString(resId) summary = if (resId == 0) variant else getString(resId)
} }
userColorsPref.apply { userColorsPref.apply {
isEnabled = KeyboardTheme.getIsCustom(selectedThemeId) isEnabled = KeyboardTheme.getIsCustom(selectedThemeId)
&& (sharedPreferences.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER && (sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER
|| (sharedPreferences.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER) == KeyboardTheme.THEME_USER_DARK || (sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARKER) == KeyboardTheme.THEME_USER_DARK
&& sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) && sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false)
)) ))
isEnabled = true isEnabled = true
} }
@ -187,14 +186,14 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
themeVariantPref.apply { themeVariantPref.apply {
entries = if (isLegacyFamily) variants // todo: translatable string for holo, not internal name entries = if (isLegacyFamily) variants // todo: translatable string for holo, not internal name
else variants.map { else variants.map {
val resId = resources.getIdentifier("theme_name_$it", "string", activity.packageName) val resId = resources.getIdentifier("theme_name_$it", "string", requireContext().packageName)
if (resId == 0) it else getString(resId) if (resId == 0) it else getString(resId)
}.toTypedArray() }.toTypedArray()
entryValues = variants entryValues = variants
value = variant ?: variants[0] value = variant ?: variants[0]
summary = if (isLegacyFamily) variant summary = if (isLegacyFamily) variant
else { else {
val resId = resources.getIdentifier("theme_name_$variant", "string", activity.packageName) val resId = resources.getIdentifier("theme_name_$variant", "string", requireContext().packageName)
if (resId == 0) variant else getString(resId) if (resId == 0) variant else getString(resId)
} }
} }
@ -205,12 +204,12 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
} }
dayNightPref?.apply { dayNightPref?.apply {
isEnabled = !isLegacyFamily isEnabled = !isLegacyFamily
isChecked = !isLegacyFamily && KeyboardTheme.getIsCustom(selectedThemeId) && sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) isChecked = !isLegacyFamily && KeyboardTheme.getIsCustom(selectedThemeId) && sharedPreferences!!.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false)
} }
} }
private fun setupTheme() { private fun setupTheme() {
themeFamilyPref = preferenceScreen.findPreference(Settings.PREF_THEME_STYLE) as ListPreference themeFamilyPref = preferenceScreen.findPreference(Settings.PREF_THEME_STYLE)!!
themeFamilyPref.apply { themeFamilyPref.apply {
entries = KeyboardTheme.THEME_STYLES entries = KeyboardTheme.THEME_STYLES
entryValues = KeyboardTheme.THEME_STYLES entryValues = KeyboardTheme.THEME_STYLES
@ -222,7 +221,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
} }
} }
// todo: remove! // todo: remove!
themeVariantPref = preferenceScreen.findPreference(Settings.PREF_THEME_VARIANT) as ListPreference themeVariantPref = preferenceScreen.findPreference(Settings.PREF_THEME_VARIANT)!!
themeVariantPref.apply { themeVariantPref.apply {
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value -> onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
summary = entries[entryValues.indexOfFirst { it == value }] summary = entries[entryValues.indexOfFirst { it == value }]
@ -230,9 +229,9 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
if (themeFamilyPref.value == KeyboardTheme.THEME_STYLE_MATERIAL) { if (themeFamilyPref.value == KeyboardTheme.THEME_STYLE_MATERIAL) {
// not so nice workaround, could be removed in the necessary re-work: new value seems // not so nice workaround, could be removed in the necessary re-work: new value seems
// to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now // to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now
if (value == sharedPreferences.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT)) if (value == sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT))
return@OnPreferenceChangeListener true // avoid infinite loop return@OnPreferenceChangeListener true // avoid infinite loop
sharedPreferences.edit { putString(Settings.PREF_THEME_VARIANT, value as String) } sharedPreferences!!.edit { putString(Settings.PREF_THEME_VARIANT, value as String) }
summary = entries[entryValues.indexOfFirst { it == value }] summary = entries[entryValues.indexOfFirst { it == value }]
needsReload = true needsReload = true
@ -242,13 +241,13 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
true true
} }
} }
keyBordersPref = preferenceScreen.findPreference(Settings.PREF_THEME_KEY_BORDERS) as TwoStatePreference keyBordersPref = preferenceScreen.findPreference(Settings.PREF_THEME_KEY_BORDERS)!!
keyBordersPref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value -> keyBordersPref.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
saveSelectedThemeId(keyBorders = value as Boolean) saveSelectedThemeId(keyBorders = value as Boolean)
updateThemePreferencesState(skipThemeFamily = true) updateThemePreferencesState(skipThemeFamily = true)
true true
} }
dayNightPref = preferenceScreen.findPreference(Settings.PREF_THEME_DAY_NIGHT) as? TwoStatePreference dayNightPref = preferenceScreen.findPreference(Settings.PREF_THEME_DAY_NIGHT)!!
dayNightPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value -> dayNightPref?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
updateThemePreferencesState(skipThemeFamily = true) updateThemePreferencesState(skipThemeFamily = true)
true true
@ -258,9 +257,9 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value -> onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, value ->
// not so nice workaround, could be removed in the necessary re-work: new value seems // not so nice workaround, could be removed in the necessary re-work: new value seems
// to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now // to be stored only after this method call, but we update the summary and user-defined color enablement in here -> store it now
if (value == sharedPreferences.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARK)) if (value == sharedPreferences!!.getString(Settings.PREF_THEME_VARIANT_NIGHT, KeyboardTheme.THEME_DARK))
return@OnPreferenceChangeListener true // avoid infinite loop return@OnPreferenceChangeListener true // avoid infinite loop
sharedPreferences.edit { putString(Settings.PREF_THEME_VARIANT_NIGHT, value as String) } sharedPreferences!!.edit { putString(Settings.PREF_THEME_VARIANT_NIGHT, value as String) }
summary = entries[entryValues.indexOfFirst { it == value }] summary = entries[entryValues.indexOfFirst { it == value }]
needsReload = true needsReload = true
@ -268,10 +267,10 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
true true
} }
} }
userColorsPref = preferenceScreen.findPreference(Settings.PREF_THEME_USER) userColorsPref = preferenceScreen.findPreference(Settings.PREF_THEME_USER)!!
userColorsPref.onPreferenceClickListener = Preference.OnPreferenceClickListener { _ -> userColorsPref.onPreferenceClickListener = Preference.OnPreferenceClickListener { _ ->
if (sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) && sharedPreferences.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER) if (sharedPreferences.getBoolean(Settings.PREF_THEME_DAY_NIGHT, false) && sharedPreferences.getString(Settings.PREF_THEME_VARIANT, KeyboardTheme.THEME_LIGHT) == KeyboardTheme.THEME_USER)
AlertDialog.Builder(activity) AlertDialog.Builder(requireContext())
.setMessage(R.string.day_or_night_colors) .setMessage(R.string.day_or_night_colors)
.setPositiveButton(R.string.day_or_night_night) { _, _ -> adjustColors(true)} .setPositiveButton(R.string.day_or_night_night) { _, _ -> adjustColors(true)}
.setNegativeButton(R.string.day_or_night_day) { _, _ -> adjustColors(false)} .setNegativeButton(R.string.day_or_night_day) { _, _ -> adjustColors(false)}
@ -282,7 +281,8 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
adjustColors(false) adjustColors(false)
true true
} }
preferenceScreen.findPreference(Settings.PREF_NARROW_KEY_GAPS)?.onPreferenceChangeListener = Preference.OnPreferenceChangeListener { _, _ -> preferenceScreen.findPreference<Preference>(Settings.PREF_NARROW_KEY_GAPS)?.onPreferenceChangeListener =
Preference.OnPreferenceChangeListener { _, _ ->
needsReload = true needsReload = true
true true
} }
@ -290,10 +290,10 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
private fun adjustColors(dark: Boolean) { private fun adjustColors(dark: Boolean) {
val items = listOf(R.string.select_color_background, R.string.select_color_key, R.string.select_color_key_hint, R.string.select_color_accent, R.string.select_color_key_background) val items = listOf(R.string.select_color_background, R.string.select_color_key, R.string.select_color_key_hint, R.string.select_color_accent, R.string.select_color_key_background)
.map { activity.getString(it) } .map { requireContext().getString(it) }
val itemsArray = if (keyBordersPref.isChecked) items.toTypedArray() val itemsArray = if (keyBordersPref.isChecked) items.toTypedArray()
else items.subList(0, 4).toTypedArray() else items.subList(0, 4).toTypedArray()
AlertDialog.Builder(activity) AlertDialog.Builder(requireContext())
.setPositiveButton(android.R.string.ok, null) .setPositiveButton(android.R.string.ok, null)
.setTitle(R.string.select_color_to_adjust) .setTitle(R.string.select_color_to_adjust)
.setItems(itemsArray) { _, i -> .setItems(itemsArray) { _, i ->
@ -314,7 +314,7 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
3 -> Settings.PREF_THEME_USER_COLOR_ACCENT to Color.BLUE 3 -> Settings.PREF_THEME_USER_COLOR_ACCENT to Color.BLUE
else -> Settings.PREF_THEME_USER_COLOR_KEYS to Color.LTGRAY else -> Settings.PREF_THEME_USER_COLOR_KEYS to Color.LTGRAY
} }
val d = ColorPickerDialog(activity, items[i], sharedPreferences, pref, default) { needsReload = true} val d = ColorPickerDialog(requireContext(), items[i], sharedPreferences, pref, default) { needsReload = true}
d.show() d.show()
} }
.show() .show()
@ -345,6 +345,10 @@ class AppearanceSettingsFragment : SubScreenFragment(), Preference.OnPreferenceC
}) })
} }
override fun onDisplayPreferenceDialog(preference: Preference) {
super.onDisplayPreferenceDialog(preference)
}
companion object { companion object {
private const val PERCENTAGE_FLOAT = 100.0f private const val PERCENTAGE_FLOAT = 100.0f
} }

View file

@ -26,10 +26,11 @@ import android.content.SharedPreferences;
import android.content.pm.PackageManager; import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import android.preference.SwitchPreference;
import android.text.TextUtils; import android.text.TextUtils;
import androidx.preference.Preference;
import androidx.preference.SwitchPreferenceCompat;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager; import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsUtil; import org.dslul.openboard.inputmethod.latin.permissions.PermissionsUtil;
@ -60,7 +61,7 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false; private static final boolean DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = false;
private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS = private static final boolean USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS =
DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS; DBG_USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS;
private SwitchPreference mLookupContactsPreference; private SwitchPreferenceCompat mLookupContactsPreference;
@Override @Override
public void onCreate(final Bundle icicle) { public void onCreate(final Bundle icicle) {
@ -74,13 +75,11 @@ public final class CorrectionSettingsFragment extends SubScreenFragment
findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY); findPreference(Settings.PREF_EDIT_PERSONAL_DICTIONARY);
final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent(); final Intent editPersonalDictionaryIntent = editPersonalDictionary.getIntent();
final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null final ResolveInfo ri = USE_INTERNAL_PERSONAL_DICTIONARY_SETTINGS ? null
: pm.resolveActivity( : pm.resolveActivity(editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
editPersonalDictionaryIntent, PackageManager.MATCH_DEFAULT_ONLY);
if (ri == null) { if (ri == null) {
overwriteUserDictionaryPreference(editPersonalDictionary); overwriteUserDictionaryPreference(editPersonalDictionary);
} }
mLookupContactsPreference = (SwitchPreference) findPreference( mLookupContactsPreference = (SwitchPreferenceCompat) findPreference(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY);
AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY);
refreshEnabledSettings(); refreshEnabledSettings();
} }

View file

@ -22,10 +22,10 @@ import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Bundle; import android.os.Bundle;
import android.os.Process; import android.os.Process;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener; import androidx.preference.Preference;
import android.preference.PreferenceGroup; import androidx.preference.PreferenceGroup;
import android.preference.TwoStatePreference; import androidx.preference.TwoStatePreference;
import org.dslul.openboard.inputmethod.latin.DictionaryDumpBroadcastReceiver; import org.dslul.openboard.inputmethod.latin.DictionaryDumpBroadcastReceiver;
import org.dslul.openboard.inputmethod.latin.DictionaryFacilitatorImpl; import org.dslul.openboard.inputmethod.latin.DictionaryFacilitatorImpl;
@ -41,7 +41,7 @@ import java.util.Locale;
* This settings sub screen handles a several preference options for debugging. * This settings sub screen handles a several preference options for debugging.
*/ */
public final class DebugSettingsFragment extends SubScreenFragment public final class DebugSettingsFragment extends SubScreenFragment
implements OnPreferenceClickListener { implements Preference.OnPreferenceClickListener {
private static final String PREF_KEY_DUMP_DICTS = "pref_key_dump_dictionaries"; private static final String PREF_KEY_DUMP_DICTS = "pref_key_dump_dictionaries";
private static final String PREF_KEY_DUMP_DICT_PREFIX = "pref_key_dump_dictionaries"; private static final String PREF_KEY_DUMP_DICT_PREFIX = "pref_key_dump_dictionaries";

View file

@ -3,12 +3,13 @@ package org.dslul.openboard.inputmethod.latin.settings
import android.content.Context import android.content.Context
import android.graphics.Rect import android.graphics.Rect
import android.graphics.Typeface import android.graphics.Typeface
import android.preference.Preference import android.os.Build
import android.text.Spannable import android.text.Spannable
import android.text.SpannableString import android.text.SpannableString
import android.text.SpannableStringBuilder import android.text.SpannableStringBuilder
import android.text.style.StyleSpan import android.text.style.StyleSpan
import android.util.AttributeSet import android.util.AttributeSet
import android.util.Log
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
@ -17,6 +18,9 @@ import androidx.core.view.doOnLayout
import androidx.core.view.isGone import androidx.core.view.isGone
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.core.widget.doAfterTextChanged import androidx.core.widget.doAfterTextChanged
import androidx.preference.Preference
import androidx.preference.PreferenceGroupAdapter
import androidx.preference.PreferenceViewHolder
import androidx.recyclerview.widget.RecyclerView import androidx.recyclerview.widget.RecyclerView
import org.dslul.openboard.inputmethod.latin.R import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
@ -24,7 +28,7 @@ import org.dslul.openboard.inputmethod.latin.utils.*
class LanguageFilterListPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs) { class LanguageFilterListPreference(context: Context, attrs: AttributeSet) : Preference(context, attrs) {
private var preferenceView: View? = null private lateinit var preferenceView: View
private val adapter = LanguageAdapter(emptyList(), context) private val adapter = LanguageAdapter(emptyList(), context)
private val sortedSubtypes = mutableListOf<MutableList<SubtypeInfo>>() private val sortedSubtypes = mutableListOf<MutableList<SubtypeInfo>>()
@ -32,15 +36,33 @@ class LanguageFilterListPreference(context: Context, attrs: AttributeSet) : Pref
adapter.fragment = newFragment adapter.fragment = newFragment
} }
override fun onBindView(view: View?) { override fun onBindViewHolder(holder: PreferenceViewHolder) {
super.onBindView(view) super.onBindViewHolder(holder)
preferenceView = view preferenceView = holder.itemView
preferenceView?.findViewById<RecyclerView>(R.id.language_list)?.adapter = adapter /* val a = holder.bindingAdapter as PreferenceGroupAdapter
val searchField = preferenceView?.findViewById<EditText>(R.id.search_field)!! preferenceManager.preferenceScreen
*/
preferenceView.findViewById<RecyclerView>(R.id.language_list)?.adapter = adapter
val searchField = preferenceView.findViewById<EditText>(R.id.search_field)!!
searchField.doAfterTextChanged { text -> searchField.doAfterTextChanged { text ->
adapter.list = sortedSubtypes.filter { it.first().displayName.startsWith(text.toString(), ignoreCase = true) } adapter.list = sortedSubtypes.filter { it.first().displayName.startsWith(text.toString(), ignoreCase = true) }
} }
view?.doOnLayout { // todo: why the fuck isn't the recyclerview scrolling after switching to androidx?
// looks like nothing can scroll inside!
// maybe just make it a list and add a note to the changelog with request for help
// first play around with weirdly nested (Nested)ScrollViews and layouts
val recycler = preferenceView.findViewById<RecyclerView>(R.id.language_list)
// recycler.isScrollContainer = true
// recycler.isNestedScrollingEnabled = true
// preferenceView.isScrollContainer = true
/* val windowFrame = Rect()
preferenceView.getWindowVisibleDisplayFrame(windowFrame) // rect the app has, we want the bottom (above screen bottom/navbar/keyboard)
val globalRect = Rect()
preferenceView.getGlobalVisibleRect(globalRect) // rect the view takes, we want the top (below the system language preference)
val newHeight = windowFrame.bottom - globalRect.top - preferenceView.findViewById<View>(R.id.search_container).height
preferenceView.layoutParams = preferenceView.layoutParams.apply { height = newHeight -250 }*/
/* preferenceView.doOnLayout {
// set correct height for recycler view, so there is no scrolling of the outside view happening // set correct height for recycler view, so there is no scrolling of the outside view happening
// not sure how, but probably this can also be achieved in xml... // not sure how, but probably this can also be achieved in xml...
val windowFrame = Rect() val windowFrame = Rect()
@ -52,7 +74,7 @@ class LanguageFilterListPreference(context: Context, attrs: AttributeSet) : Pref
val newHeight = windowFrame.bottom - globalRect.top - it.findViewById<View>(R.id.search_container).height val newHeight = windowFrame.bottom - globalRect.top - it.findViewById<View>(R.id.search_container).height
if (newHeight != recycler.layoutParams.height) if (newHeight != recycler.layoutParams.height)
recycler.layoutParams = recycler.layoutParams.apply { height = newHeight } recycler.layoutParams = recycler.layoutParams.apply { height = newHeight }
} }*/
} }
fun setLanguages(list: Collection<MutableList<SubtypeInfo>>, onlySystemLocales: Boolean) { fun setLanguages(list: Collection<MutableList<SubtypeInfo>>, onlySystemLocales: Boolean) {
@ -64,7 +86,6 @@ class LanguageFilterListPreference(context: Context, attrs: AttributeSet) : Pref
} }
@Suppress("Deprecation")
class LanguageAdapter(list: List<MutableList<SubtypeInfo>> = listOf(), context: Context) : class LanguageAdapter(list: List<MutableList<SubtypeInfo>> = listOf(), context: Context) :
RecyclerView.Adapter<LanguageAdapter.ViewHolder>() { RecyclerView.Adapter<LanguageAdapter.ViewHolder>() {
var onlySystemLocales = false var onlySystemLocales = false

View file

@ -20,7 +20,6 @@ import org.dslul.openboard.inputmethod.latin.utils.*
import java.io.File import java.io.File
import java.util.* import java.util.*
@Suppress("deprecation")
class LanguageSettingsDialog( class LanguageSettingsDialog(
context: Context, context: Context,
private val infos: MutableList<SubtypeInfo>, private val infos: MutableList<SubtypeInfo>,

View file

@ -6,8 +6,8 @@ import android.content.Intent
import android.content.SharedPreferences import android.content.SharedPreferences
import android.net.Uri import android.net.Uri
import android.os.Bundle import android.os.Bundle
import android.preference.TwoStatePreference
import android.view.inputmethod.InputMethodSubtype import android.view.inputmethod.InputMethodSubtype
import androidx.preference.SwitchPreferenceCompat
import org.dslul.openboard.inputmethod.latin.R import org.dslul.openboard.inputmethod.latin.R
import org.dslul.openboard.inputmethod.latin.common.LocaleUtils import org.dslul.openboard.inputmethod.latin.common.LocaleUtils
import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils import org.dslul.openboard.inputmethod.latin.utils.DictionaryInfoUtils
@ -15,20 +15,18 @@ import org.dslul.openboard.inputmethod.latin.utils.SubtypeLocaleUtils
import org.dslul.openboard.inputmethod.latin.utils.getDictionaryLocales import org.dslul.openboard.inputmethod.latin.utils.getDictionaryLocales
import java.util.Locale import java.util.Locale
@Suppress("Deprecation") // yes everything here is deprecated, but only work on this if really necessary
class LanguageSettingsFragment : SubScreenFragment() { class LanguageSettingsFragment : SubScreenFragment() {
private val sortedSubtypes = LinkedHashMap<String, MutableList<SubtypeInfo>>() private val sortedSubtypes = LinkedHashMap<String, MutableList<SubtypeInfo>>()
private val enabledSubtypes = mutableListOf<InputMethodSubtype>() private val enabledSubtypes = mutableListOf<InputMethodSubtype>()
private val systemLocales = mutableListOf<Locale>() private val systemLocales = mutableListOf<Locale>()
private val languageFilterListPreference by lazy { findPreference("pref_language_filter") as LanguageFilterListPreference } private val languageFilterListPreference by lazy { findPreference<LanguageFilterListPreference>("pref_language_filter")!! }
private val dictionaryLocales by lazy { getDictionaryLocales(activity).mapTo(HashSet()) { it.languageConsideringZZ() } } private val dictionaryLocales by lazy { getDictionaryLocales(requireContext()).mapTo(HashSet()) { it.languageConsideringZZ() } }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
addPreferencesFromResource(R.xml.prefs_screen_languages); addPreferencesFromResource(R.xml.prefs_screen_languages)
SubtypeLocaleUtils.init(activity) SubtypeLocaleUtils.init(requireContext())
enabledSubtypes.addAll(getEnabledSubtypes(sharedPreferences)) enabledSubtypes.addAll(getEnabledSubtypes(sharedPreferences))
systemLocales.addAll(getSystemLocales()) systemLocales.addAll(getSystemLocales())
@ -52,7 +50,7 @@ class LanguageSettingsFragment : SubScreenFragment() {
} }
private fun loadSubtypes() { private fun loadSubtypes() {
val systemOnly = (findPreference(Settings.PREF_USE_SYSTEM_LOCALES) as TwoStatePreference).isChecked val systemOnly = findPreference<SwitchPreferenceCompat>(Settings.PREF_USE_SYSTEM_LOCALES)!!.isChecked
sortedSubtypes.clear() sortedSubtypes.clear()
// list of all subtypes, any subtype added to sortedSubtypes will be removed to avoid duplicates // list of all subtypes, any subtype added to sortedSubtypes will be removed to avoid duplicates
val allSubtypes = getAllAvailableSubtypes().toMutableList() val allSubtypes = getAllAvailableSubtypes().toMutableList()
@ -115,7 +113,7 @@ class LanguageSettingsFragment : SubScreenFragment() {
} }
// add subtypes that have a dictionary // add subtypes that have a dictionary
val localesWithDictionary = DictionaryInfoUtils.getCachedDirectoryList(activity)?.mapNotNull { dir -> val localesWithDictionary = DictionaryInfoUtils.getCachedDirectoryList(requireContext())?.mapNotNull { dir ->
if (!dir.isDirectory) if (!dir.isDirectory)
return@mapNotNull null return@mapNotNull null
if (dir.list()?.any { it.endsWith(USER_DICTIONARY_SUFFIX) } == true) if (dir.list()?.any { it.endsWith(USER_DICTIONARY_SUFFIX) } == true)
@ -139,7 +137,7 @@ class LanguageSettingsFragment : SubScreenFragment() {
} }
private fun InputMethodSubtype.toSubtypeInfo(locale: Locale, isEnabled: Boolean = false) = private fun InputMethodSubtype.toSubtypeInfo(locale: Locale, isEnabled: Boolean = false) =
toSubtypeInfo(locale, activity, isEnabled, dictionaryLocales.contains(locale.languageConsideringZZ())) toSubtypeInfo(locale, requireContext(), isEnabled, dictionaryLocales.contains(locale.languageConsideringZZ()))
private fun List<SubtypeInfo>.addToSortedSubtypes() { private fun List<SubtypeInfo>.addToSortedSubtypes() {
forEach { forEach {

View file

@ -21,7 +21,8 @@ import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
import android.media.AudioManager; import android.media.AudioManager;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import androidx.preference.Preference;
import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager; import org.dslul.openboard.inputmethod.latin.AudioAndHapticFeedbackManager;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;

View file

@ -17,11 +17,14 @@
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.content.Context; import android.content.Context;
import android.preference.Preference;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.View; import android.view.View;
import android.widget.RadioButton; import android.widget.RadioButton;
import androidx.annotation.NonNull;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
/** /**
@ -72,8 +75,9 @@ public class RadioButtonPreference extends Preference {
} }
@Override @Override
protected void onBindView(final View view) { public void onBindViewHolder(@NonNull final PreferenceViewHolder holder) {
super.onBindView(view); super.onBindViewHolder(holder);
final View view = holder.itemView;
mRadioButton = view.findViewById(R.id.radio_button); mRadioButton = view.findViewById(R.id.radio_button);
mRadioButton.setChecked(mIsSelected); mRadioButton.setChecked(mIsSelected);
mRadioButton.setOnClickListener(mClickListener); mRadioButton.setOnClickListener(mClickListener);

View file

@ -16,20 +16,22 @@
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.res.TypedArray; import android.content.res.TypedArray;
import android.preference.DialogPreference;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.appcompat.app.AlertDialog;
import androidx.preference.Preference;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
public final class SeekBarDialogPreference extends DialogPreference public final class SeekBarDialogPreference extends Preference
implements SeekBar.OnSeekBarChangeListener { implements SeekBar.OnSeekBarChangeListener, DialogInterface.OnClickListener {
public interface ValueProxy { public interface ValueProxy {
int readValue(final String key); int readValue(final String key);
int readDefaultValue(final String key); int readDefaultValue(final String key);
@ -56,7 +58,6 @@ public final class SeekBarDialogPreference extends DialogPreference
mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0); mMinValue = a.getInt(R.styleable.SeekBarDialogPreference_minValue, 0);
mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0); mStepValue = a.getInt(R.styleable.SeekBarDialogPreference_stepValue, 0);
a.recycle(); a.recycle();
setDialogLayoutResource(R.layout.seek_bar_dialog);
} }
public void setInterface(final ValueProxy proxy) { public void setInterface(final ValueProxy proxy) {
@ -65,16 +66,6 @@ public final class SeekBarDialogPreference extends DialogPreference
setSummary(mValueProxy.getValueText(value)); setSummary(mValueProxy.getValueText(value));
} }
@Override
protected View onCreateDialogView() {
final View view = super.onCreateDialogView();
mSeekBar = view.findViewById(R.id.seek_bar_dialog_bar);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
mValueView = view.findViewById(R.id.seek_bar_dialog_value);
return view;
}
private int getProgressFromValue(final int value) { private int getProgressFromValue(final int value) {
return value - mMinValue; return value - mMinValue;
} }
@ -95,23 +86,32 @@ public final class SeekBarDialogPreference extends DialogPreference
return clipValue(getValueFromProgress(progress)); return clipValue(getValueFromProgress(progress));
} }
@Override private void onCreateDialogView(final View view) {
protected void onBindDialogView(final View view) { mSeekBar = view.findViewById(R.id.seek_bar_dialog_bar);
mSeekBar.setMax(mMaxValue - mMinValue);
mSeekBar.setOnSeekBarChangeListener(this);
mValueView = view.findViewById(R.id.seek_bar_dialog_value);
final int value = mValueProxy.readValue(getKey()); final int value = mValueProxy.readValue(getKey());
mValueView.setText(mValueProxy.getValueText(value)); mValueView.setText(mValueProxy.getValueText(value));
mSeekBar.setProgress(getProgressFromValue(clipValue(value))); mSeekBar.setProgress(getProgressFromValue(clipValue(value)));
} }
@Override @Override
protected void onPrepareDialogBuilder(final AlertDialog.Builder builder) { public void onClick() {
builder.setPositiveButton(android.R.string.ok, this) final View view = LayoutInflater.from(getContext()).inflate(R.layout.seek_bar_dialog, null);
final AlertDialog dialog = new AlertDialog.Builder(getContext())
.setTitle(getTitle())
.setView(view)
.setPositiveButton(android.R.string.ok, this)
.setNegativeButton(android.R.string.cancel, this) .setNegativeButton(android.R.string.cancel, this)
.setNeutralButton(R.string.button_default, this); .setNeutralButton(R.string.button_default, this)
.create();
dialog.setOnShowListener((d) -> onCreateDialogView(view));
dialog.show();
} }
@Override @Override
public void onClick(final DialogInterface dialog, final int which) { public void onClick(final DialogInterface dialog, final int which) {
super.onClick(dialog, which);
final String key = getKey(); final String key = getKey();
if (which == DialogInterface.BUTTON_NEUTRAL) { if (which == DialogInterface.BUTTON_NEUTRAL) {
final int value = mValueProxy.readDefaultValue(key); final int value = mValueProxy.readDefaultValue(key);

View file

@ -16,18 +16,20 @@
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.app.ActionBar; import static android.preference.PreferenceActivity.EXTRA_NO_HEADERS;
import static android.preference.PreferenceActivity.EXTRA_SHOW_FRAGMENT;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceActivity;
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager; import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
import org.dslul.openboard.inputmethod.latin.utils.FragmentUtils;
import org.dslul.openboard.inputmethod.latin.utils.NewDictionaryAdder; import org.dslul.openboard.inputmethod.latin.utils.NewDictionaryAdder;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.app.ActivityCompat; import androidx.core.app.ActivityCompat;
public final class SettingsActivity extends PreferenceActivity public final class SettingsActivity extends AppCompatActivity
implements ActivityCompat.OnRequestPermissionsResultCallback { implements ActivityCompat.OnRequestPermissionsResultCallback {
private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName(); private static final String DEFAULT_FRAGMENT = SettingsFragment.class.getName();
@ -42,7 +44,7 @@ public final class SettingsActivity extends PreferenceActivity
@Override @Override
protected void onCreate(final Bundle savedState) { protected void onCreate(final Bundle savedState) {
super.onCreate(savedState); super.onCreate(savedState);
final ActionBar actionBar = getActionBar(); final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) { if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true); actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true); actionBar.setHomeButtonEnabled(true);
@ -51,6 +53,9 @@ public final class SettingsActivity extends PreferenceActivity
if (Intent.ACTION_VIEW.equals(i.getAction()) && i.getData() != null) { if (Intent.ACTION_VIEW.equals(i.getAction()) && i.getData() != null) {
new NewDictionaryAdder(this, null).addDictionary(i.getData(), null); new NewDictionaryAdder(this, null).addDictionary(i.getData(), null);
} }
getSupportFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
} }
@Override @Override
@ -64,13 +69,9 @@ public final class SettingsActivity extends PreferenceActivity
return intent; return intent;
} }
@Override
public boolean isValidFragment(final String fragmentName) {
return FragmentUtils.isValidFragment(fragmentName);
}
@Override @Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) { public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
PermissionsManager.get(this).onRequestPermissionsResult(requestCode, permissions, grantResults); PermissionsManager.get(this).onRequestPermissionsResult(requestCode, permissions, grantResults);
} }
} }

View file

@ -16,22 +16,24 @@
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.app.ActionBar;
import android.app.Activity; import android.app.Activity;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.provider.Settings.Secure; import android.provider.Settings.Secure;
import android.view.Menu; import android.view.Menu;
import android.view.MenuInflater; import android.view.MenuInflater;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.inputmethod.InputMethodSubtype; import android.view.inputmethod.InputMethodSubtype;
import androidx.annotation.Nullable;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog; import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.Preference;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
import org.dslul.openboard.inputmethod.latin.BuildConfig; import org.dslul.openboard.inputmethod.latin.BuildConfig;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
@ -51,7 +53,7 @@ import java.util.ArrayList;
import java.util.zip.ZipEntry; import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
public final class SettingsFragment extends PreferenceFragment { public final class SettingsFragment extends PreferenceFragmentCompat {
// We don't care about menu grouping. // We don't care about menu grouping.
private static final int NO_MENU_GROUP = Menu.NONE; private static final int NO_MENU_GROUP = Menu.NONE;
// The first menu item id and order. // The first menu item id and order.
@ -66,10 +68,13 @@ public final class SettingsFragment extends PreferenceFragment {
public void onCreate(final Bundle icicle) { public void onCreate(final Bundle icicle) {
super.onCreate(icicle); super.onCreate(icicle);
setHasOptionsMenu(true); setHasOptionsMenu(true);
}
@Override
public void onCreatePreferences(@Nullable Bundle bundle, @Nullable String s) {
addPreferencesFromResource(R.xml.prefs); addPreferencesFromResource(R.xml.prefs);
final PreferenceScreen preferenceScreen = getPreferenceScreen(); final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.setTitle( preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
ApplicationUtils.getActivityTitleResId(getActivity(), SettingsActivity.class));
if (!JniUtils.sHaveGestureLib) { if (!JniUtils.sHaveGestureLib) {
final Preference gesturePreference = findPreference(Settings.SCREEN_GESTURE); final Preference gesturePreference = findPreference(Settings.SCREEN_GESTURE);
preferenceScreen.removePreference(gesturePreference); preferenceScreen.removePreference(gesturePreference);
@ -79,11 +84,14 @@ public final class SettingsFragment extends PreferenceFragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
final ActionBar actionBar = getActivity().getActionBar(); final Activity activity = getActivity();
if (activity instanceof AppCompatActivity) {
final ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
final CharSequence screenTitle = getPreferenceScreen().getTitle(); final CharSequence screenTitle = getPreferenceScreen().getTitle();
if (actionBar != null && screenTitle != null) { if (actionBar != null && screenTitle != null) {
actionBar.setTitle(screenTitle); actionBar.setTitle(screenTitle);
} }
}
// todo: got a crash because it wasn't initialized... // todo: got a crash because it wasn't initialized...
// but sometimes wrong languages are returned when not initializing on creation of LatinIME // but sometimes wrong languages are returned when not initializing on creation of LatinIME

View file

@ -16,7 +16,7 @@
package org.dslul.openboard.inputmethod.latin.settings; package org.dslul.openboard.inputmethod.latin.settings;
import android.app.ActionBar; import android.app.Activity;
import android.app.backup.BackupManager; import android.app.backup.BackupManager;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
@ -24,18 +24,21 @@ import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.PreferenceCategory;
import android.preference.PreferenceFragment;
import android.preference.PreferenceScreen;
import android.util.Log; import android.util.Log;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.preference.ListPreference;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
/** /**
* A base abstract class for a {@link PreferenceFragment} that implements a nested * A base abstract class for a {@link PreferenceFragmentCompat} that implements a nested
* {@link PreferenceScreen} of the main preference screen. * {@link PreferenceScreen} of the main preference screen.
*/ */
public abstract class SubScreenFragment extends PreferenceFragment public abstract class SubScreenFragment extends PreferenceFragmentCompat
implements OnSharedPreferenceChangeListener { implements OnSharedPreferenceChangeListener {
private OnSharedPreferenceChangeListener mSharedPreferenceChangeListener; private OnSharedPreferenceChangeListener mSharedPreferenceChangeListener;
@ -100,10 +103,9 @@ public abstract class SubScreenFragment extends PreferenceFragment
} }
@Override @Override
public void addPreferencesFromResource(final int preferencesResId) { public void onCreatePreferences(final Bundle savedInstanceState, final String s) {
super.addPreferencesFromResource(preferencesResId); // this must be overridden, but is useless, because it's called during onCreate
TwoStatePreferenceHelper.replaceCheckBoxPreferencesBySwitchPreferences( // so there is no possibility of calling setStorageDeviceProtected before this is called...
getPreferenceScreen());
} }
@Override @Override
@ -135,12 +137,15 @@ public abstract class SubScreenFragment extends PreferenceFragment
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
final ActionBar actionBar = getActivity().getActionBar(); final Activity activity = getActivity();
if (activity instanceof AppCompatActivity) {
final ActionBar actionBar = ((AppCompatActivity) activity).getSupportActionBar();
final CharSequence screenTitle = getPreferenceScreen().getTitle(); final CharSequence screenTitle = getPreferenceScreen().getTitle();
if (actionBar != null && screenTitle != null) { if (actionBar != null && screenTitle != null) {
actionBar.setTitle(screenTitle); actionBar.setTitle(screenTitle);
} }
} }
}
@Override @Override
public void onDestroy() { public void onDestroy() {
@ -153,4 +158,24 @@ public abstract class SubScreenFragment extends PreferenceFragment
public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) { public void onSharedPreferenceChanged(final SharedPreferences prefs, final String key) {
// This method may be overridden by an extended class. // This method may be overridden by an extended class.
} }
// for fixing the indent appearing with androidx preferences
// we don't have icons in subscreens, so we don't want indent
// should also be possible in xml, but didn't find a way to have it in a theme/style
@Override
public void setPreferenceScreen(PreferenceScreen preferenceScreen) {
super.setPreferenceScreen(preferenceScreen);
if (preferenceScreen == null) return;
int count = preferenceScreen.getPreferenceCount();
for (int i = 0; i < count; i++) {
final Preference pref = preferenceScreen.getPreference(i);
pref.setIconSpaceReserved(false);
if (pref instanceof PreferenceCategory) {
final int subPrefCount = ((PreferenceCategory) pref).getPreferenceCount();
for (int j = 0; j < subPrefCount; j++) {
((PreferenceCategory) pref).getPreference(j).setIconSpaceReserved(false);
}
}
}
}
} }

View file

@ -1,82 +0,0 @@
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dslul.openboard.inputmethod.latin.settings;
import android.os.Build;
import android.preference.CheckBoxPreference;
import android.preference.Preference;
import android.preference.PreferenceGroup;
import android.preference.SwitchPreference;
import java.util.ArrayList;
public class TwoStatePreferenceHelper {
private static final String EMPTY_TEXT = "";
private TwoStatePreferenceHelper() {
// This utility class is not publicly instantiable.
}
public static void replaceCheckBoxPreferencesBySwitchPreferences(final PreferenceGroup group) {
// The keyboard settings keeps using a CheckBoxPreference on KitKat or previous.
if (Build.VERSION.SDK_INT <= Build.VERSION_CODES.KITKAT) {
return;
}
// The keyboard settings starts using a SwitchPreference without switch on/off text on
// API versions newer than KitKat.
replaceAllCheckBoxPreferencesBySwitchPreferences(group);
}
private static void replaceAllCheckBoxPreferencesBySwitchPreferences(
final PreferenceGroup group) {
final ArrayList<Preference> preferences = new ArrayList<>();
final int count = group.getPreferenceCount();
for (int index = 0; index < count; index++) {
preferences.add(group.getPreference(index));
}
group.removeAll();
for (int index = 0; index < count; index++) {
final Preference preference = preferences.get(index);
if (preference instanceof CheckBoxPreference) {
addSwitchPreferenceBasedOnCheckBoxPreference((CheckBoxPreference)preference, group);
} else {
group.addPreference(preference);
if (preference instanceof PreferenceGroup) {
replaceAllCheckBoxPreferencesBySwitchPreferences((PreferenceGroup)preference);
}
}
}
}
static void addSwitchPreferenceBasedOnCheckBoxPreference(final CheckBoxPreference checkBox,
final PreferenceGroup group) {
final SwitchPreference switchPref = new SwitchPreference(checkBox.getContext());
switchPref.setTitle(checkBox.getTitle());
switchPref.setKey(checkBox.getKey());
switchPref.setOrder(checkBox.getOrder());
switchPref.setPersistent(checkBox.isPersistent());
switchPref.setEnabled(checkBox.isEnabled());
switchPref.setChecked(checkBox.isChecked());
switchPref.setSummary(checkBox.getSummary());
switchPref.setSummaryOn(checkBox.getSummaryOn());
switchPref.setSummaryOff(checkBox.getSummaryOff());
switchPref.setSwitchTextOn(EMPTY_TEXT);
switchPref.setSwitchTextOff(EMPTY_TEXT);
group.addPreference(switchPref);
switchPref.setDependency(checkBox.getDependency());
}
}

View file

@ -19,19 +19,19 @@ package org.dslul.openboard.inputmethod.latin.spellcheck;
import android.Manifest; import android.Manifest;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.os.Bundle; import android.os.Bundle;
import android.preference.PreferenceScreen;
import android.preference.SwitchPreference;
import android.text.TextUtils; import android.text.TextUtils;
import org.dslul.openboard.inputmethod.latin.R; import org.dslul.openboard.inputmethod.latin.R;
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager; import org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager;
import org.dslul.openboard.inputmethod.latin.permissions.PermissionsUtil; import org.dslul.openboard.inputmethod.latin.permissions.PermissionsUtil;
import org.dslul.openboard.inputmethod.latin.settings.SubScreenFragment; import org.dslul.openboard.inputmethod.latin.settings.SubScreenFragment;
import org.dslul.openboard.inputmethod.latin.settings.TwoStatePreferenceHelper;
import org.dslul.openboard.inputmethod.latin.utils.ApplicationUtils; import org.dslul.openboard.inputmethod.latin.utils.ApplicationUtils;
import static org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager.get; import static org.dslul.openboard.inputmethod.latin.permissions.PermissionsManager.get;
import androidx.preference.PreferenceScreen;
import androidx.preference.SwitchPreferenceCompat;
/** /**
* Preference screen. * Preference screen.
*/ */
@ -39,19 +39,16 @@ public final class SpellCheckerSettingsFragment extends SubScreenFragment
implements SharedPreferences.OnSharedPreferenceChangeListener, implements SharedPreferences.OnSharedPreferenceChangeListener,
PermissionsManager.PermissionsResultCallback { PermissionsManager.PermissionsResultCallback {
private SwitchPreference mLookupContactsPreference; private SwitchPreferenceCompat mLookupContactsPreference;
@Override @Override
public void onActivityCreated(final Bundle savedInstanceState) { public void onActivityCreated(final Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState); super.onActivityCreated(savedInstanceState);
addPreferencesFromResource(R.xml.spell_checker_settings); addPreferencesFromResource(R.xml.spell_checker_settings);
final PreferenceScreen preferenceScreen = getPreferenceScreen(); final PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId( preferenceScreen.setTitle(ApplicationUtils.getActivityTitleResId(getActivity(), SpellCheckerSettingsActivity.class));
getActivity(), SpellCheckerSettingsActivity.class));
TwoStatePreferenceHelper.replaceCheckBoxPreferencesBySwitchPreferences(preferenceScreen);
mLookupContactsPreference = (SwitchPreference) findPreference( mLookupContactsPreference = (SwitchPreferenceCompat) findPreference(AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY);
AndroidSpellCheckerService.PREF_USE_CONTACTS_KEY);
turnOffLookupContactsIfNoPermission(); turnOffLookupContactsIfNoPermission();
} }

View file

@ -4,7 +4,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:orientation="vertical"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="wrap_content">
<LinearLayout <LinearLayout
android:id="@+id/search_container" android:id="@+id/search_container"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -20,7 +20,7 @@
android:title="@string/settings_screen_advanced" android:title="@string/settings_screen_advanced"
android:key="screen_advanced"> android:key="screen_advanced">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_always_incognito_mode" android:key="pref_always_incognito_mode"
android:title="@string/prefs_force_incognito_mode" android:title="@string/prefs_force_incognito_mode"
android:summary="@string/prefs_force_incognito_mode_summary" android:summary="@string/prefs_force_incognito_mode_summary"
@ -33,21 +33,21 @@
latin:maxValue="@integer/config_max_longpress_timeout" latin:maxValue="@integer/config_max_longpress_timeout"
latin:stepValue="@integer/config_longpress_timeout_step" /> latin:stepValue="@integer/config_longpress_timeout_step" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="prefs_long_press_keyboard_to_change_lang" android:key="prefs_long_press_keyboard_to_change_lang"
android:title="@string/prefs_long_press_keyboard_to_change_lang" android:title="@string/prefs_long_press_keyboard_to_change_lang"
android:summary="@string/prefs_long_press_keyboard_to_change_lang_summary" android:summary="@string/prefs_long_press_keyboard_to_change_lang_summary"
android:persistent="true" android:persistent="true"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_enable_emoji_alt_physical_key" android:key="pref_enable_emoji_alt_physical_key"
android:title="@string/prefs_enable_emoji_alt_physical_key" android:title="@string/prefs_enable_emoji_alt_physical_key"
android:summary="@string/prefs_enable_emoji_alt_physical_key_summary" android:summary="@string/prefs_enable_emoji_alt_physical_key_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_setup_wizard_icon" android:key="pref_show_setup_wizard_icon"
android:title="@string/show_setup_wizard_icon" android:title="@string/show_setup_wizard_icon"
android:summary="@string/show_setup_wizard_icon_summary" android:summary="@string/show_setup_wizard_icon_summary"
@ -64,19 +64,19 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_experimental"> android:title="@string/settings_category_experimental">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_space_trackpad" android:key="pref_space_trackpad"
android:title="@string/space_trackpad" android:title="@string/space_trackpad"
android:summary="@string/space_trackpad_summary" android:summary="@string/space_trackpad_summary"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_delete_swipe" android:key="pref_delete_swipe"
android:title="@string/delete_swipe" android:title="@string/delete_swipe"
android:summary="@string/delete_swipe_summary" android:summary="@string/delete_swipe_summary"
android:defaultValue="true" /> android:defaultValue="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_autospace_after_punctuation" android:key="pref_autospace_after_punctuation"
android:title="@string/autospace_after_punctuation" android:title="@string/autospace_after_punctuation"
android:summary="@string/autospace_after_punctuation_summary" android:summary="@string/autospace_after_punctuation_summary"

View file

@ -32,11 +32,11 @@
android:key="theme_variant" android:key="theme_variant"
android:title="@string/theme_variant"/> android:title="@string/theme_variant"/>
<CheckBoxPreference <SwitchPreferenceCompat
android:key="theme_key_borders" android:key="theme_key_borders"
android:title="@string/key_borders"/> android:title="@string/key_borders"/>
<CheckBoxPreference <SwitchPreferenceCompat
android:key="theme_auto_day_night" android:key="theme_auto_day_night"
android:title="@string/day_night_mode" android:title="@string/day_night_mode"
android:summary="@string/day_night_mode_summary"/> android:summary="@string/day_night_mode_summary"/>
@ -50,7 +50,7 @@
android:title="@string/select_user_colors" android:title="@string/select_user_colors"
android:summary="@string/select_user_colors_summary"/> android:summary="@string/select_user_colors_summary"/>
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_navbar_color" android:key="pref_navbar_color"
android:title="@string/theme_navbar"/> android:title="@string/theme_navbar"/>
@ -59,19 +59,19 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_miscellaneous"> android:title="@string/settings_category_miscellaneous">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_split_keyboard" android:key="pref_split_keyboard"
android:title="@string/enable_split_keyboard" android:title="@string/enable_split_keyboard"
android:persistent="true" android:persistent="true"
android:defaultValue="false" /> android:defaultValue="false" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_resize_keyboard" android:key="pref_resize_keyboard"
android:title="@string/prefs_resize_keyboard" android:title="@string/prefs_resize_keyboard"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_narrow_key_gaps" android:key="pref_narrow_key_gaps"
android:title="@string/prefs_narrow_key_gaps" android:title="@string/prefs_narrow_key_gaps"
android:defaultValue="true" android:defaultValue="true"

View file

@ -27,14 +27,14 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_correction"> android:title="@string/settings_category_correction">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_key_block_potentially_offensive" android:key="pref_key_block_potentially_offensive"
android:title="@string/prefs_block_potentially_offensive_title" android:title="@string/prefs_block_potentially_offensive_title"
android:summary="@string/prefs_block_potentially_offensive_summary" android:summary="@string/prefs_block_potentially_offensive_summary"
android:defaultValue="@bool/config_block_potentially_offensive" android:defaultValue="@bool/config_block_potentially_offensive"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_key_auto_correction" android:key="pref_key_auto_correction"
android:title="@string/auto_correction" android:title="@string/auto_correction"
android:summary="@string/auto_correction_summary" android:summary="@string/auto_correction_summary"
@ -49,14 +49,14 @@
android:entryValues="@array/auto_correction_threshold_mode_indexes" android:entryValues="@array/auto_correction_threshold_mode_indexes"
android:defaultValue="@string/auto_correction_threshold_mode_index_modest" /> android:defaultValue="@string/auto_correction_threshold_mode_index_modest" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="auto_cap" android:key="auto_cap"
android:title="@string/auto_cap" android:title="@string/auto_cap"
android:summary="@string/auto_cap_summary" android:summary="@string/auto_cap_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_key_use_double_space_period" android:key="pref_key_use_double_space_period"
android:title="@string/use_double_space_period" android:title="@string/use_double_space_period"
android:summary="@string/use_double_space_period_summary" android:summary="@string/use_double_space_period_summary"
@ -68,35 +68,35 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_suggestions"> android:title="@string/settings_category_suggestions">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="show_suggestions" android:key="show_suggestions"
android:summary="@string/prefs_show_suggestions_summary" android:summary="@string/prefs_show_suggestions_summary"
android:title="@string/prefs_show_suggestions" android:title="@string/prefs_show_suggestions"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_key_use_personalized_dicts" android:key="pref_key_use_personalized_dicts"
android:title="@string/use_personalized_dicts" android:title="@string/use_personalized_dicts"
android:summary="@string/use_personalized_dicts_summary" android:summary="@string/use_personalized_dicts_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="next_word_prediction" android:key="next_word_prediction"
android:title="@string/bigram_prediction" android:title="@string/bigram_prediction"
android:summary="@string/bigram_prediction_summary" android:summary="@string/bigram_prediction_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_spellcheck_use_contacts" android:key="pref_spellcheck_use_contacts"
android:title="@string/use_contacts_dict" android:title="@string/use_contacts_dict"
android:summary="@string/use_contacts_dict_summary" android:summary="@string/use_contacts_dict_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_add_to_personal_dictionary" android:key="pref_add_to_personal_dictionary"
android:title="@string/add_to_personal_dictionary" android:title="@string/add_to_personal_dictionary"
android:summary="@string/add_to_personal_dictionary_summary" android:summary="@string/add_to_personal_dictionary_summary"

View file

@ -20,28 +20,28 @@
android:title="@string/prefs_debug_mode" android:title="@string/prefs_debug_mode"
android:key="english_ime_debug_settings" android:key="english_ime_debug_settings"
> >
<CheckBoxPreference <SwitchPreferenceCompat
android:key="debug_mode" android:key="debug_mode"
android:title="@string/prefs_debug_mode" android:title="@string/prefs_debug_mode"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="force_non_distinct_multitouch" android:key="force_non_distinct_multitouch"
android:title="@string/prefs_force_non_distinct_multitouch" android:title="@string/prefs_force_non_distinct_multitouch"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_should_show_lxx_suggestion_ui" android:key="pref_should_show_lxx_suggestion_ui"
android:title="@string/prefs_should_show_lxx_suggestion_ui" android:title="@string/prefs_should_show_lxx_suggestion_ui"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_sliding_key_input_preview" android:key="pref_sliding_key_input_preview"
android:title="@string/sliding_key_input_preview" android:title="@string/sliding_key_input_preview"
android:summary="@string/sliding_key_input_preview_summary" android:summary="@string/sliding_key_input_preview_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_has_custom_key_preview_animation_params" android:key="pref_has_custom_key_preview_animation_params"
android:title="@string/prefs_customize_key_preview_animation" android:title="@string/prefs_customize_key_preview_animation"
android:defaultValue="false" android:defaultValue="false"
@ -76,7 +76,7 @@
android:key="pref_key_preview_dismiss_duration" android:key="pref_key_preview_dismiss_duration"
android:title="@string/prefs_key_popup_dismiss_duration_settings" android:title="@string/prefs_key_popup_dismiss_duration_settings"
latin:maxValue="100" /> <!-- milliseconds --> latin:maxValue="100" /> <!-- milliseconds -->
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_resize_keyboard" android:key="pref_resize_keyboard"
android:title="@string/prefs_resize_keyboard" android:title="@string/prefs_resize_keyboard"
android:defaultValue="false" android:defaultValue="false"
@ -87,8 +87,8 @@
android:title="@string/prefs_keyboard_height_scale" android:title="@string/prefs_keyboard_height_scale"
latin:minValue="50" latin:minValue="50"
latin:maxValue="120" /> <!-- percentage --> latin:maxValue="120" /> <!-- percentage -->
<PreferenceCategory <SwitchPreferenceCompat
android:key="pref_key_dump_dictionaries" android:key="pref_key_dump_dictionaries"
android:title="@string/prefs_dump_dynamic_dicts"> android:title="@string/prefs_dump_dynamic_dicts">
</PreferenceCategory> </SwitchPreferenceCompat>
</PreferenceScreen> </PreferenceScreen>

View file

@ -18,20 +18,20 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/settings_screen_gesture" android:title="@string/settings_screen_gesture"
android:key="screen_gesture"> android:key="screen_gesture">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="gesture_input" android:key="gesture_input"
android:title="@string/gesture_input" android:title="@string/gesture_input"
android:summary="@string/gesture_input_summary" android:summary="@string/gesture_input_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_gesture_floating_preview_text" android:key="pref_gesture_floating_preview_text"
android:dependency="gesture_input" android:dependency="gesture_input"
android:title="@string/gesture_floating_preview_text" android:title="@string/gesture_floating_preview_text"
android:summary="@string/gesture_floating_preview_text_summary" android:summary="@string/gesture_floating_preview_text_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_gesture_preview_trail" android:key="pref_gesture_preview_trail"
android:dependency="gesture_input" android:dependency="gesture_input"
android:title="@string/gesture_preview_trail" android:title="@string/gesture_preview_trail"

View file

@ -4,7 +4,7 @@
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:title="@string/language_selection_title" android:title="@string/language_selection_title"
android:key="screen_languages"> android:key="screen_languages">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_use_system_locales" android:key="pref_use_system_locales"
android:title="@string/use_system_language_to_select_input_method_subtypes" android:title="@string/use_system_language_to_select_input_method_subtypes"
android:defaultValue="true" android:defaultValue="true"

View file

@ -20,14 +20,14 @@
<PreferenceCategory android:title="@string/settings_category_input"> <PreferenceCategory android:title="@string/settings_category_input">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_hints" android:key="pref_show_hints"
android:title="@string/show_hints" android:title="@string/show_hints"
android:summary="@string/show_hints_summary" android:summary="@string/show_hints_summary"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="vibrate_on" android:key="vibrate_on"
android:title="@string/vibrate_on_keypress" android:title="@string/vibrate_on_keypress"
android:defaultValue="@bool/config_default_vibration_enabled" android:defaultValue="@bool/config_default_vibration_enabled"
@ -38,7 +38,7 @@
android:title="@string/prefs_keypress_vibration_duration_settings" android:title="@string/prefs_keypress_vibration_duration_settings"
latin:maxValue="@integer/config_max_vibration_duration" /> latin:maxValue="@integer/config_max_vibration_duration" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="sound_on" android:key="sound_on"
android:title="@string/sound_on_keypress" android:title="@string/sound_on_keypress"
android:defaultValue="@bool/config_default_sound_enabled" android:defaultValue="@bool/config_default_sound_enabled"
@ -51,7 +51,7 @@
</PreferenceCategory> </PreferenceCategory>
<CheckBoxPreference <SwitchPreferenceCompat
android:key="popup_on" android:key="popup_on"
android:title="@string/popup_on_keypress" android:title="@string/popup_on_keypress"
android:defaultValue="@bool/config_default_key_preview_popup" android:defaultValue="@bool/config_default_key_preview_popup"
@ -60,32 +60,32 @@
<PreferenceCategory <PreferenceCategory
android:title="@string/settings_category_additional_keys"> android:title="@string/settings_category_additional_keys">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_number_row" android:key="pref_show_number_row"
android:title="@string/number_row" android:title="@string/number_row"
android:summary="@string/number_row_summary" android:summary="@string/number_row_summary"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_language_switch_key" android:key="pref_show_language_switch_key"
android:title="@string/show_language_switch_key" android:title="@string/show_language_switch_key"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_emoji_key" android:key="pref_show_emoji_key"
android:title="@string/show_emoji_key" android:title="@string/show_emoji_key"
android:defaultValue="false" android:defaultValue="false"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_voice_input_key" android:key="pref_voice_input_key"
android:title="@string/voice_input" android:title="@string/voice_input"
android:defaultValue="true" android:defaultValue="true"
android:persistent="true" /> android:persistent="true" />
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_show_clipboard_key" android:key="pref_show_clipboard_key"
android:title="@string/show_clipboard_key" android:title="@string/show_clipboard_key"
android:defaultValue="false" android:defaultValue="false"
@ -95,7 +95,7 @@
<PreferenceCategory android:title="@string/settings_category_clipboard_history"> <PreferenceCategory android:title="@string/settings_category_clipboard_history">
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_enable_clipboard_history" android:key="pref_enable_clipboard_history"
android:title="@string/enable_clipboard_history" android:title="@string/enable_clipboard_history"
android:summary="@string/enable_clipboard_history_summary" android:summary="@string/enable_clipboard_history_summary"

View file

@ -17,7 +17,7 @@
<PreferenceScreen <PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
> >
<CheckBoxPreference <SwitchPreferenceCompat
android:key="pref_spellcheck_use_contacts" android:key="pref_spellcheck_use_contacts"
android:title="@string/use_contacts_for_spellchecking_option_title" android:title="@string/use_contacts_for_spellchecking_option_title"
android:summary="@string/use_contacts_for_spellchecking_option_summary" android:summary="@string/use_contacts_for_spellchecking_option_summary"