parent
b23ee38082
commit
718c211a86
|
@ -92,6 +92,11 @@ open class RadioButtonPreference @JvmOverloads constructor(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun setCheckedWithoutClickListener(isChecked: Boolean) {
|
||||||
|
updateRadioValue(isChecked)
|
||||||
|
toggleRadioGroups()
|
||||||
|
}
|
||||||
|
|
||||||
private fun updateRadioValue(isChecked: Boolean) {
|
private fun updateRadioValue(isChecked: Boolean) {
|
||||||
persistBoolean(isChecked)
|
persistBoolean(isChecked)
|
||||||
radioButton?.isChecked = isChecked
|
radioButton?.isChecked = isChecked
|
||||||
|
|
|
@ -10,6 +10,7 @@ import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.metrics.Event
|
import org.mozilla.fenix.components.metrics.Event
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import org.mozilla.fenix.ext.getPreferenceKey
|
import org.mozilla.fenix.ext.getPreferenceKey
|
||||||
|
import org.mozilla.fenix.ext.settings
|
||||||
import org.mozilla.fenix.ext.showToolbar
|
import org.mozilla.fenix.ext.showToolbar
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -45,6 +46,9 @@ class ToolbarSettingsFragment : PreferenceFragmentCompat() {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
topPreference.setCheckedWithoutClickListener(!requireContext().settings().shouldUseBottomToolbar)
|
||||||
|
bottomPreference.setCheckedWithoutClickListener(requireContext().settings().shouldUseBottomToolbar)
|
||||||
|
|
||||||
topPreference.addToRadioGroup(bottomPreference)
|
topPreference.addToRadioGroup(bottomPreference)
|
||||||
bottomPreference.addToRadioGroup(topPreference)
|
bottomPreference.addToRadioGroup(topPreference)
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
|
|
||||||
package org.mozilla.fenix.utils
|
package org.mozilla.fenix.utils
|
||||||
|
|
||||||
|
import android.accessibilityservice.AccessibilityServiceInfo.CAPABILITY_CAN_PERFORM_GESTURES
|
||||||
import android.app.Application
|
import android.app.Application
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.content.Context.MODE_PRIVATE
|
import android.content.Context.MODE_PRIVATE
|
||||||
|
@ -205,9 +206,7 @@ class Settings private constructor(
|
||||||
|
|
||||||
val shouldUseFixedTopToolbar: Boolean
|
val shouldUseFixedTopToolbar: Boolean
|
||||||
get() {
|
get() {
|
||||||
val accessibilityManager =
|
return touchExplorationIsEnabled || switchServiceIsEnabled
|
||||||
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
|
|
||||||
return accessibilityManager?.isTouchExplorationEnabled ?: false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var shouldDeleteBrowsingDataOnQuit by booleanPreference(
|
var shouldDeleteBrowsingDataOnQuit by booleanPreference(
|
||||||
|
@ -217,9 +216,37 @@ class Settings private constructor(
|
||||||
|
|
||||||
var shouldUseBottomToolbar by booleanPreference(
|
var shouldUseBottomToolbar by booleanPreference(
|
||||||
appContext.getPreferenceKey(R.string.pref_key_toolbar_bottom),
|
appContext.getPreferenceKey(R.string.pref_key_toolbar_bottom),
|
||||||
default = true
|
// Default accessibility users to top toolbar
|
||||||
|
default = !touchExplorationIsEnabled && !switchServiceIsEnabled
|
||||||
)
|
)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check each active accessibility service to see if it can perform gestures, if any can,
|
||||||
|
* then it is *likely* a switch service is enabled. We are assuming this to be the case based on #7486
|
||||||
|
*/
|
||||||
|
private val switchServiceIsEnabled: Boolean
|
||||||
|
get() {
|
||||||
|
val accessibilityManager =
|
||||||
|
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
|
||||||
|
|
||||||
|
accessibilityManager?.getEnabledAccessibilityServiceList(0)?.let { activeServices ->
|
||||||
|
for (service in activeServices) {
|
||||||
|
if (service.capabilities.and(CAPABILITY_CAN_PERFORM_GESTURES) == 1) {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
private val touchExplorationIsEnabled: Boolean
|
||||||
|
get() {
|
||||||
|
val accessibilityManager =
|
||||||
|
appContext.getSystemService(Context.ACCESSIBILITY_SERVICE) as? AccessibilityManager
|
||||||
|
return accessibilityManager?.isTouchExplorationEnabled ?: false
|
||||||
|
}
|
||||||
|
|
||||||
val toolbarSettingString: String
|
val toolbarSettingString: String
|
||||||
get() = when {
|
get() = when {
|
||||||
shouldUseBottomToolbar -> appContext.getString(R.string.preference_bottom_toolbar)
|
shouldUseBottomToolbar -> appContext.getString(R.string.preference_bottom_toolbar)
|
||||||
|
|
|
@ -4,11 +4,9 @@
|
||||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
android:defaultValue="false"
|
|
||||||
android:key="@string/pref_key_toolbar_top"
|
android:key="@string/pref_key_toolbar_top"
|
||||||
android:title="@string/preference_top_toolbar" />
|
android:title="@string/preference_top_toolbar" />
|
||||||
<org.mozilla.fenix.settings.RadioButtonPreference
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
||||||
android:defaultValue="true"
|
|
||||||
android:key="@string/pref_key_toolbar_bottom"
|
android:key="@string/pref_key_toolbar_bottom"
|
||||||
android:title="@string/preference_bottom_toolbar" />
|
android:title="@string/preference_bottom_toolbar" />
|
||||||
</PreferenceScreen>
|
</PreferenceScreen>
|
||||||
|
|
Loading…
Reference in New Issue