mirror of
https://github.com/ironfox-oss/IronFox.git
synced 2026-01-26 15:03:43 -05:00
151 lines
7.4 KiB
Diff
151 lines
7.4 KiB
Diff
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/tabstrip/TabStripFeatureFlag.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/tabstrip/TabStripFeatureFlag.kt
|
|
index ffa40b19a0..4aa70b57b2 100644
|
|
--- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/tabstrip/TabStripFeatureFlag.kt
|
|
+++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/browser/tabstrip/TabStripFeatureFlag.kt
|
|
@@ -6,24 +6,24 @@ package org.mozilla.fenix.browser.tabstrip
|
|
|
|
import android.content.Context
|
|
import mozilla.components.support.ktx.android.content.doesDeviceHaveHinge
|
|
-import org.mozilla.fenix.nimbus.FxNimbus
|
|
+import org.mozilla.fenix.ext.settings
|
|
import org.mozilla.fenix.utils.isLargeScreenSize
|
|
|
|
/**
|
|
* Returns true if the tab strip is enabled.
|
|
*/
|
|
fun Context.isTabStripEnabled(): Boolean =
|
|
- tabStripExperimentEnabled() && (isTabStripEligible() || tabStripExperimentForceEnabled())
|
|
+ settings().isTabStripEnabled
|
|
|
|
-private fun tabStripExperimentEnabled(): Boolean = FxNimbus.features.tabStrip.value().enabled
|
|
+//private fun tabStripExperimentEnabled(): Boolean = FxNimbus.features.tabStrip.value().enabled
|
|
|
|
-private fun tabStripExperimentForceEnabled(): Boolean =
|
|
- FxNimbus.features.tabStrip.value().allowOnAllDevices
|
|
+//private fun tabStripExperimentForceEnabled(): Boolean =
|
|
+// FxNimbus.features.tabStrip.value().allowOnAllDevices
|
|
|
|
/**
|
|
* Returns true if the the device has the prerequisites to enable the tab strip.
|
|
*/
|
|
-private fun Context.isTabStripEligible(): Boolean =
|
|
+fun Context.isTabStripEligible(): Boolean =
|
|
// Tab Strip is currently disabled on foldable devices, while we work on improving the
|
|
// Homescreen / Toolbar / Browser screen to better support the feature. There is also
|
|
// an emulator bug that causes the doesDeviceHaveHinge check to return true on emulators,
|
|
diff --git a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt
|
|
index c1428b2898..2b2832d991 100644
|
|
--- a/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt
|
|
+++ b/mobile/android/fenix/app/src/main/java/org/mozilla/fenix/settings/CustomizationFragment.kt
|
|
@@ -9,9 +9,9 @@ import android.os.Build.VERSION.SDK_INT
|
|
import android.os.Bundle
|
|
import androidx.appcompat.app.AppCompatDelegate
|
|
import androidx.preference.Preference
|
|
-import androidx.preference.PreferenceCategory
|
|
+//import androidx.preference.PreferenceCategory
|
|
import androidx.preference.PreferenceFragmentCompat
|
|
-import androidx.preference.PreferenceScreen
|
|
+//import androidx.preference.PreferenceScreen
|
|
import androidx.preference.SwitchPreference
|
|
import org.mozilla.fenix.FeatureFlags
|
|
import org.mozilla.fenix.GleanMetrics.AppTheme
|
|
@@ -55,21 +55,42 @@ class CustomizationFragment : PreferenceFragmentCompat() {
|
|
bindAutoBatteryTheme()
|
|
setupRadioGroups()
|
|
val tabletAndTabStripEnabled = requireContext().isTabStripEnabled()
|
|
- if (tabletAndTabStripEnabled) {
|
|
- val preferenceScreen: PreferenceScreen =
|
|
- requirePreference(R.string.pref_key_customization_preference_screen)
|
|
- val toolbarPrefCategory: PreferenceCategory =
|
|
- requirePreference(R.string.pref_key_customization_category_toolbar)
|
|
- preferenceScreen.removePreference(toolbarPrefCategory)
|
|
- } else {
|
|
- setupToolbarCategory()
|
|
- }
|
|
+// if (tabletAndTabStripEnabled) {
|
|
+// val preferenceScreen: PreferenceScreen =
|
|
+// requirePreference(R.string.pref_key_customization_preference_screen)
|
|
+// val toolbarPrefCategory: PreferenceCategory =
|
|
+// requirePreference(R.string.pref_key_customization_category_toolbar)
|
|
+// preferenceScreen.removePreference(toolbarPrefCategory)
|
|
+// } else {
|
|
+// setupToolbarCategory()
|
|
+// }
|
|
+ updateToolbarCategoryBasedOnTabStrip(tabletAndTabStripEnabled)
|
|
+ setupTabStripCategory()
|
|
|
|
// if tab strip is enabled, swipe toolbar to switch tabs should not be enabled so the
|
|
// preference is not shown
|
|
setupGesturesCategory(isSwipeToolbarToSwitchTabsVisible = !tabletAndTabStripEnabled)
|
|
}
|
|
|
|
+ private fun updateToolbarCategoryBasedOnTabStrip(
|
|
+ tabStripEnabled: Boolean,
|
|
+ ) {
|
|
+ val topPreference = requirePreference<RadioButtonPreference>(R.string.pref_key_toolbar_top)
|
|
+ val bottomPreference = requirePreference<RadioButtonPreference>(R.string.pref_key_toolbar_bottom)
|
|
+ val tabStripMessagePref = findPreference<Preference>(getString(R.string.pref_key_tab_strip_message))
|
|
+
|
|
+ topPreference.isEnabled = !tabStripEnabled
|
|
+ bottomPreference.isEnabled = !tabStripEnabled
|
|
+ tabStripMessagePref?.isVisible = tabStripEnabled
|
|
+
|
|
+ if (tabStripEnabled && !topPreference.isChecked) {
|
|
+ topPreference.setCheckedWithoutClickListener(true)
|
|
+ bottomPreference.setCheckedWithoutClickListener(false)
|
|
+ } else {
|
|
+ setupToolbarCategory()
|
|
+ }
|
|
+ }
|
|
+
|
|
private fun setupRadioGroups() {
|
|
addToRadioGroup(
|
|
radioLightTheme,
|
|
@@ -153,6 +174,20 @@ class CustomizationFragment : PreferenceFragmentCompat() {
|
|
addToRadioGroup(topPreference, bottomPreference)
|
|
}
|
|
|
|
+ private fun setupTabStripCategory() {
|
|
+ val tabStripSwitch = requirePreference<SwitchPreference>(R.string.pref_key_tab_strip_show)
|
|
+ val context = requireContext()
|
|
+
|
|
+ tabStripSwitch.isChecked = context.settings().isTabStripEnabled
|
|
+
|
|
+ tabStripSwitch.setOnPreferenceChangeListener { _, newValue ->
|
|
+ val enabled = newValue as Boolean
|
|
+ context.settings().isTabStripEnabled = enabled
|
|
+ updateToolbarCategoryBasedOnTabStrip(enabled)
|
|
+ true
|
|
+ }
|
|
+ }
|
|
+
|
|
private fun setupGesturesCategory(isSwipeToolbarToSwitchTabsVisible: Boolean) {
|
|
requirePreference<SwitchPreference>(R.string.pref_key_website_pull_to_refresh).apply {
|
|
isVisible = FeatureFlags.PULL_TO_REFRESH_ENABLED
|
|
diff --git a/mobile/android/fenix/app/src/main/res/xml/customization_preferences.xml b/mobile/android/fenix/app/src/main/res/xml/customization_preferences.xml
|
|
index a24d1b7b2b..8949710ec1 100644
|
|
--- a/mobile/android/fenix/app/src/main/res/xml/customization_preferences.xml
|
|
+++ b/mobile/android/fenix/app/src/main/res/xml/customization_preferences.xml
|
|
@@ -43,6 +43,21 @@
|
|
<org.mozilla.fenix.settings.RadioButtonPreference
|
|
android:key="@string/pref_key_toolbar_bottom"
|
|
android:title="@string/preference_bottom_toolbar" />
|
|
+ <androidx.preference.Preference
|
|
+ android:key="@string/pref_key_tab_strip_message"
|
|
+ android:title=""
|
|
+ android:summary="@string/preference_toolbar_pref_disabled_explanation"
|
|
+ android:enabled="false"
|
|
+ android:selectable="false" />
|
|
+ </androidx.preference.PreferenceCategory>
|
|
+
|
|
+ <androidx.preference.PreferenceCategory
|
|
+ android:layout="@layout/preference_cat_style"
|
|
+ android:title="@string/preferences_tab_strip"
|
|
+ app:iconSpaceReserved="false">
|
|
+ <androidx.preference.SwitchPreference
|
|
+ android:key="@string/pref_key_tab_strip_show"
|
|
+ android:title="@string/preference_tab_strip_show" />
|
|
</androidx.preference.PreferenceCategory>
|
|
|
|
<androidx.preference.PreferenceCategory
|