mirror of
https://github.com/florisboard/florisboard.git
synced 2024-09-20 03:52:18 +02:00
Add user dictionary preferences
This commit is contained in:
parent
dfec1f3804
commit
dcd20e4b73
@ -51,6 +51,7 @@ class PrefHelper(
|
|||||||
val clipboard = Clipboard(this)
|
val clipboard = Clipboard(this)
|
||||||
val correction = Correction(this)
|
val correction = Correction(this)
|
||||||
val devtools = Devtools(this)
|
val devtools = Devtools(this)
|
||||||
|
val dictionary = Dictionary(this)
|
||||||
val gestures = Gestures(this)
|
val gestures = Gestures(this)
|
||||||
val glide = Glide(this)
|
val glide = Glide(this)
|
||||||
val internal = Internal(this)
|
val internal = Internal(this)
|
||||||
@ -240,6 +241,25 @@ class PrefHelper(
|
|||||||
set(v) = prefHelper.setPref(SHOW_HEAP_MEMORY_STATS, v)
|
set(v) = prefHelper.setPref(SHOW_HEAP_MEMORY_STATS, v)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wrapper class for dictionary preferences.
|
||||||
|
*/
|
||||||
|
class Dictionary(private val prefHelper: PrefHelper) {
|
||||||
|
companion object {
|
||||||
|
const val ENABLE_SYSTEM_USER_DICTIONARY = "suggestion__enable_system_user_dictionary"
|
||||||
|
const val MANAGE_SYSTEM_USER_DICTIONARY = "suggestion__manage_system_user_dictionary"
|
||||||
|
const val ENABLE_INTERNAL_USER_DICTIONARY = "suggestion__enable_internal_user_dictionary"
|
||||||
|
const val MANAGE_INTERNAL_USER_DICTIONARY = "suggestion__manage_internal_user_dictionary"
|
||||||
|
}
|
||||||
|
|
||||||
|
var enableSystemUserDictionary: Boolean
|
||||||
|
get() = prefHelper.getPref(ENABLE_SYSTEM_USER_DICTIONARY, true)
|
||||||
|
set(v) = prefHelper.setPref(ENABLE_SYSTEM_USER_DICTIONARY, v)
|
||||||
|
var enableInternalUserDictionary: Boolean
|
||||||
|
get() = prefHelper.getPref(ENABLE_INTERNAL_USER_DICTIONARY, true)
|
||||||
|
set(v) = prefHelper.setPref(ENABLE_INTERNAL_USER_DICTIONARY, v)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Wrapper class for gestures preferences.
|
* Wrapper class for gestures preferences.
|
||||||
*/
|
*/
|
||||||
|
@ -60,7 +60,7 @@ class TypingFragment : SettingsMainActivity.SettingsFragment() {
|
|||||||
.beginTransaction()
|
.beginTransaction()
|
||||||
.replace(
|
.replace(
|
||||||
binding.prefsFrame.id,
|
binding.prefsFrame.id,
|
||||||
SettingsMainActivity.PrefFragment.createFromResource(R.xml.prefs_typing)
|
TypingInnerFragment()
|
||||||
)
|
)
|
||||||
.commit()
|
.commit()
|
||||||
|
|
||||||
|
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2021 Patrick Goldinger
|
||||||
|
*
|
||||||
|
* 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 dev.patrickgold.florisboard.settings.fragments
|
||||||
|
|
||||||
|
import android.content.Intent
|
||||||
|
import android.os.Bundle
|
||||||
|
import androidx.preference.Preference
|
||||||
|
import androidx.preference.PreferenceFragmentCompat
|
||||||
|
import dev.patrickgold.florisboard.R
|
||||||
|
import dev.patrickgold.florisboard.ime.core.PrefHelper
|
||||||
|
|
||||||
|
class TypingInnerFragment : PreferenceFragmentCompat() {
|
||||||
|
companion object {
|
||||||
|
private const val USER_DICTIONARY_SETTINGS_INTENT_ACTION: String =
|
||||||
|
"android.settings.USER_DICTIONARY_SETTINGS"
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
|
||||||
|
addPreferencesFromResource(R.xml.prefs_typing)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun onPreferenceTreeClick(preference: Preference?): Boolean {
|
||||||
|
return when (preference?.key) {
|
||||||
|
PrefHelper.Dictionary.MANAGE_SYSTEM_USER_DICTIONARY -> {
|
||||||
|
val intent = Intent(USER_DICTIONARY_SETTINGS_INTENT_ACTION)
|
||||||
|
startActivity(intent)
|
||||||
|
true
|
||||||
|
}
|
||||||
|
PrefHelper.Dictionary.MANAGE_INTERNAL_USER_DICTIONARY -> {
|
||||||
|
// NYI
|
||||||
|
true
|
||||||
|
}
|
||||||
|
else -> super.onPreferenceTreeClick(preference)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -240,6 +240,15 @@
|
|||||||
<string translatable="false" name="pref__suggestion__display_mode__classic" comment="Preference value">Classic (3 columns)</string>
|
<string translatable="false" name="pref__suggestion__display_mode__classic" comment="Preference value">Classic (3 columns)</string>
|
||||||
<string translatable="false" name="pref__suggestion__display_mode__dynamic" comment="Preference value">Dynamic width</string>
|
<string translatable="false" name="pref__suggestion__display_mode__dynamic" comment="Preference value">Dynamic width</string>
|
||||||
<string translatable="false" name="pref__suggestion__display_mode__dynamic_scrollable" comment="Preference value">Dynamic width & scrollable</string>
|
<string translatable="false" name="pref__suggestion__display_mode__dynamic_scrollable" comment="Preference value">Dynamic width & scrollable</string>
|
||||||
|
<string name="pref__dictionary__title" comment="Preference group title">Dictionary</string>
|
||||||
|
<string name="pref__dictionary__enable_system_user_dictionary__label" comment="Preference title">Enable system user dictionary</string>
|
||||||
|
<string name="pref__dictionary__enable_system_user_dictionary__summary" comment="Preference summary">Suggest words stored in the system user dictionary</string>
|
||||||
|
<string name="pref__dictionary__manage_system_user_dictionary__label" comment="Preference title">Manage system user dictionary</string>
|
||||||
|
<string name="pref__dictionary__manage_system_user_dictionary__summary" comment="Preference summary">Add, view, and remove entries for the system user dictionary</string>
|
||||||
|
<string name="pref__dictionary__enable_internal_user_dictionary__label" comment="Preference title">Enable internal user dictionary</string>
|
||||||
|
<string name="pref__dictionary__enable_internal_user_dictionary__summary" comment="Preference summary">Suggest words stored in the internal user dictionary</string>
|
||||||
|
<string name="pref__dictionary__manage_internal_user_dictionary__label" comment="Preference title">Manage internal user dictionary</string>
|
||||||
|
<string name="pref__dictionary__manage_internal_user_dictionary__summary" comment="Preference summary">Add, view, and remove entries for the internal user dictionary</string>
|
||||||
<string name="pref__correction__title" comment="Preference group title">Corrections</string>
|
<string name="pref__correction__title" comment="Preference group title">Corrections</string>
|
||||||
<string name="pref__correction__auto_capitalization__label" comment="Preference title">Auto-capitalization</string>
|
<string name="pref__correction__auto_capitalization__label" comment="Preference title">Auto-capitalization</string>
|
||||||
<string name="pref__correction__auto_capitalization__summary" comment="Preference summary">Capitalize words based on the current input context</string>
|
<string name="pref__correction__auto_capitalization__summary" comment="Preference summary">Capitalize words based on the current input context</string>
|
||||||
|
@ -69,6 +69,42 @@
|
|||||||
|
|
||||||
</PreferenceCategory>
|
</PreferenceCategory>
|
||||||
|
|
||||||
|
<PreferenceCategory
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:title="@string/pref__dictionary__title">
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
app:dependency="suggestion__enabled"
|
||||||
|
app:key="suggestion__enable_system_user_dictionary"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:title="@string/pref__dictionary__enable_system_user_dictionary__label"
|
||||||
|
app:summary="@string/pref__dictionary__enable_system_user_dictionary__summary"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:dependency="suggestion__enable_system_user_dictionary"
|
||||||
|
app:key="suggestion__manage_system_user_dictionary"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:title="@string/pref__dictionary__manage_system_user_dictionary__label"
|
||||||
|
app:summary="@string/pref__dictionary__manage_system_user_dictionary__summary"/>
|
||||||
|
|
||||||
|
<SwitchPreferenceCompat
|
||||||
|
android:defaultValue="true"
|
||||||
|
app:dependency="suggestion__enabled"
|
||||||
|
app:key="suggestion__enable_internal_user_dictionary"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:title="@string/pref__dictionary__enable_internal_user_dictionary__label"
|
||||||
|
app:summary="@string/pref__dictionary__enable_internal_user_dictionary__summary"/>
|
||||||
|
|
||||||
|
<Preference
|
||||||
|
app:dependency="suggestion__enable_internal_user_dictionary"
|
||||||
|
app:key="suggestion__manage_internal_user_dictionary"
|
||||||
|
app:iconSpaceReserved="false"
|
||||||
|
app:title="@string/pref__dictionary__manage_internal_user_dictionary__label"
|
||||||
|
app:summary="@string/pref__dictionary__manage_internal_user_dictionary__summary"/>
|
||||||
|
|
||||||
|
</PreferenceCategory>
|
||||||
|
|
||||||
<PreferenceCategory
|
<PreferenceCategory
|
||||||
app:iconSpaceReserved="false"
|
app:iconSpaceReserved="false"
|
||||||
app:title="@string/pref__correction__title">
|
app:title="@string/pref__correction__title">
|
||||||
|
Loading…
Reference in New Issue
Block a user