Remove autofill setting for incompatible devices

This commit is contained in:
J-Jamet
2020-03-06 17:29:48 +01:00
parent fc0c7b5708
commit ec5688a013
3 changed files with 6 additions and 10 deletions

View File

@@ -95,8 +95,8 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
setPreferencesFromResource(R.xml.preferences_form_filling, rootKey)
activity?.let { activity ->
val autoFillEnablePreference: SwitchPreference? = findPreference(getString(R.string.settings_autofill_enable_key))
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val autoFillEnablePreference: SwitchPreference? = findPreference(getString(R.string.settings_autofill_enable_key))
val autofillManager = activity.getSystemService(AutofillManager::class.java)
if (autofillManager != null && autofillManager.hasEnabledAutofillServices())
autoFillEnablePreference?.isChecked = autofillManager.hasEnabledAutofillServices()
@@ -143,13 +143,7 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
}
}
} else {
autoFillEnablePreference?.setOnPreferenceClickListener { preference ->
(preference as SwitchPreference).isChecked = false
val fragmentManager = fragmentManager!!
UnavailableFeatureDialogFragment.getInstance(Build.VERSION_CODES.O)
.show(fragmentManager, "unavailableFeatureDialog")
false
}
findPreference<Preference>(getString(R.string.autofill_key))?.isVisible = false
}
}
@@ -342,8 +336,8 @@ class NestedAppSettingsFragment : NestedSettingsFragment() {
activity?.let { activity ->
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
val autoFillEnablePreference: SwitchPreference? = findPreference(getString(R.string.settings_autofill_enable_key))
if (autoFillEnablePreference != null) {
findPreference<SwitchPreference?>(getString(R.string.settings_autofill_enable_key))?.let {
autoFillEnablePreference ->
val autofillManager = activity.getSystemService(AutofillManager::class.java)
autoFillEnablePreference.isChecked = autofillManager != null
&& autofillManager.hasEnabledAutofillServices()

View File

@@ -112,6 +112,7 @@
<bool name="clear_clipboard_notification_default" translatable="false">true</bool>
<string name="clipboard_timeout_key" translatable="false">clip_timeout_key</string>
<string name="clipboard_timeout_default" translatable="false">300000</string>
<string name="autofill_key" translatable="false">autofill_key</string>
<string name="autofill_explanation_key" translatable="false">autofill_explanation_key</string>
<string name="settings_autofill_enable_key" translatable="false">settings_autofill_enable_key</string>
<bool name="settings_autofill_enable_default" translatable="false">false</bool>

View File

@@ -66,6 +66,7 @@
</PreferenceCategory>
<PreferenceCategory
android:key="@string/autofill_key"
android:title="@string/autofill">
<Preference
android:key="@string/autofill_explanation_key"