For #12287: Add feature flag for Synced Tabs in tabs tray
parent
b54b743d83
commit
f92485d1e8
|
@ -20,14 +20,11 @@ object FeatureFlags {
|
|||
const val loginsEdit = true
|
||||
|
||||
/**
|
||||
* Enable tab sync feature
|
||||
* Shows Synced Tabs in the tabs tray.
|
||||
*
|
||||
* Tracking issue: https://github.com/mozilla-mobile/fenix/issues/13892
|
||||
*/
|
||||
const val syncedTabs = true
|
||||
|
||||
/**
|
||||
* Enables new tab tray pref
|
||||
*/
|
||||
val tabTray = Config.channel.isNightlyOrDebug
|
||||
val syncedTabsInTabsTray = Config.channel.isNightlyOrDebug
|
||||
|
||||
/**
|
||||
* Enables viewing tab history
|
||||
|
|
|
@ -32,7 +32,6 @@ import mozilla.components.service.fxa.sync.GlobalSyncableStoreProvider
|
|||
import mozilla.components.service.sync.logins.SyncableLoginsStorage
|
||||
import mozilla.components.support.utils.RunWhenReadyQueue
|
||||
import org.mozilla.fenix.Config
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.metrics.Event
|
||||
import org.mozilla.fenix.components.metrics.MetricController
|
||||
|
@ -85,11 +84,8 @@ class BackgroundServices(
|
|||
)
|
||||
|
||||
@VisibleForTesting
|
||||
val supportedEngines = if (FeatureFlags.syncedTabs) {
|
||||
val supportedEngines =
|
||||
setOf(SyncEngine.History, SyncEngine.Bookmarks, SyncEngine.Passwords, SyncEngine.Tabs)
|
||||
} else {
|
||||
setOf(SyncEngine.History, SyncEngine.Bookmarks, SyncEngine.Passwords)
|
||||
}
|
||||
private val syncConfig = SyncConfig(supportedEngines, syncPeriodInMinutes = 240L) // four hours
|
||||
|
||||
init {
|
||||
|
@ -98,11 +94,8 @@ class BackgroundServices(
|
|||
GlobalSyncableStoreProvider.configureStore(SyncEngine.History to historyStorage)
|
||||
GlobalSyncableStoreProvider.configureStore(SyncEngine.Bookmarks to bookmarkStorage)
|
||||
GlobalSyncableStoreProvider.configureStore(SyncEngine.Passwords to passwordsStorage)
|
||||
|
||||
if (FeatureFlags.syncedTabs) {
|
||||
GlobalSyncableStoreProvider.configureStore(SyncEngine.Tabs to remoteTabsStorage)
|
||||
}
|
||||
}
|
||||
|
||||
private val telemetryAccountObserver = TelemetryAccountObserver(
|
||||
context.settings(),
|
||||
|
|
|
@ -24,7 +24,6 @@ import mozilla.components.browser.state.selector.findTab
|
|||
import mozilla.components.browser.state.store.BrowserStore
|
||||
import mozilla.components.concept.storage.BookmarksStorage
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
|
@ -177,12 +176,14 @@ class DefaultToolbarMenu(
|
|||
?.browsingModeManager?.mode == BrowsingMode.Normal
|
||||
val shouldDeleteDataOnQuit = context.components.settings
|
||||
.shouldDeleteBrowsingDataOnQuit
|
||||
val syncedTabsInTabsTray = context.components.settings
|
||||
.syncedTabsInTabsTray
|
||||
|
||||
val menuItems = listOfNotNull(
|
||||
if (FeatureFlags.viewDownloads) downloadsItem else null,
|
||||
historyItem,
|
||||
bookmarksItem,
|
||||
if (FeatureFlags.syncedTabs) syncedTabs else null,
|
||||
if (syncedTabsInTabsTray) null else syncedTabs,
|
||||
settings,
|
||||
if (shouldDeleteDataOnQuit) deleteDataOnQuit else null,
|
||||
BrowserMenuDivider(),
|
||||
|
|
|
@ -21,7 +21,6 @@ import mozilla.components.concept.sync.AccountObserver
|
|||
import mozilla.components.concept.sync.AuthType
|
||||
import mozilla.components.concept.sync.OAuthAccount
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.settings
|
||||
|
@ -167,7 +166,7 @@ class HomeMenu(
|
|||
if (settings.shouldDeleteBrowsingDataOnQuit) quitItem else null,
|
||||
settingsItem,
|
||||
BrowserMenuDivider(),
|
||||
if (FeatureFlags.syncedTabs) syncedTabsItem else null,
|
||||
if (settings.syncedTabsInTabsTray) null else syncedTabsItem,
|
||||
bookmarksItem,
|
||||
historyItem,
|
||||
if (FeatureFlags.viewDownloads) downloadsItem else null,
|
||||
|
|
|
@ -36,5 +36,11 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
|
|||
isChecked = context.settings().waitToShowPageUntilFirstPaint
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
|
||||
requirePreference<SwitchPreference>(R.string.pref_key_synced_tabs_tabs_tray).apply {
|
||||
isVisible = FeatureFlags.syncedTabsInTabsTray
|
||||
isChecked = context.settings().syncedTabsInTabsTray
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import mozilla.components.service.fxa.sync.SyncStatusObserver
|
|||
import mozilla.components.service.fxa.sync.getLastSynced
|
||||
import mozilla.components.support.ktx.android.content.getColorFromAttr
|
||||
import mozilla.components.support.ktx.android.util.dpToPx
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.FenixSnackbar
|
||||
import org.mozilla.fenix.components.StoreProvider
|
||||
|
@ -271,9 +270,8 @@ class AccountSettingsFragment : PreferenceFragmentCompat() {
|
|||
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Passwords) { true }
|
||||
}
|
||||
requirePreference<CheckBoxPreference>(R.string.pref_key_sync_tabs).apply {
|
||||
isVisible = FeatureFlags.syncedTabs
|
||||
isEnabled = syncEnginesStatus.containsKey(SyncEngine.Tabs)
|
||||
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Tabs) { FeatureFlags.syncedTabs }
|
||||
isChecked = syncEnginesStatus.getOrElse(SyncEngine.Tabs) { true }
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import mozilla.components.browser.storage.sync.Tab
|
|||
import mozilla.components.feature.syncedtabs.SyncedTabsFeature
|
||||
import mozilla.components.support.base.feature.ViewBoundFeatureWrapper
|
||||
import org.mozilla.fenix.BrowserDirection
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.components
|
||||
|
@ -22,6 +23,11 @@ import org.mozilla.fenix.library.LibraryPageFragment
|
|||
class SyncedTabsFragment : LibraryPageFragment<Tab>() {
|
||||
private val syncedTabsFeature = ViewBoundFeatureWrapper<SyncedTabsFeature>()
|
||||
|
||||
init {
|
||||
// Sanity-check: Remove this class when the feature flag is always enabled.
|
||||
FeatureFlags.syncedTabsInTabsTray
|
||||
}
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
container: ViewGroup?,
|
||||
|
|
|
@ -19,6 +19,7 @@ import kotlinx.coroutines.launch
|
|||
import mozilla.components.browser.storage.sync.SyncedDeviceTabs
|
||||
import mozilla.components.browser.storage.sync.Tab
|
||||
import mozilla.components.feature.syncedtabs.view.SyncedTabsView
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.sync.ext.toAdapterItem
|
||||
import org.mozilla.fenix.sync.ext.toStringRes
|
||||
|
@ -42,6 +43,9 @@ class SyncedTabsLayout @JvmOverloads constructor(
|
|||
synced_tabs_list.adapter = adapter
|
||||
|
||||
synced_tabs_pull_to_refresh.setOnRefreshListener { listener?.onRefresh() }
|
||||
|
||||
// Sanity-check: Remove this class when the feature flag is always enabled.
|
||||
FeatureFlags.syncedTabsInTabsTray
|
||||
}
|
||||
|
||||
override fun onError(error: SyncedTabsView.ErrorType) {
|
||||
|
|
|
@ -145,6 +145,7 @@ class TabTrayView(
|
|||
|
||||
setTopOffset(startingInLandscape)
|
||||
|
||||
if (view.context.settings().syncedTabsInTabsTray) {
|
||||
syncedTabsFeature.set(
|
||||
feature = SyncedTabsFeature(
|
||||
context = container.context,
|
||||
|
@ -157,6 +158,7 @@ class TabTrayView(
|
|||
owner = lifecycleOwner,
|
||||
view = view
|
||||
)
|
||||
}
|
||||
|
||||
val concatAdapter = ConcatAdapter(tabsAdapter)
|
||||
view.tabsTray.apply {
|
||||
|
|
|
@ -109,6 +109,12 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||
featureFlag = FeatureFlags.waitUntilPaintToDraw
|
||||
)
|
||||
|
||||
var syncedTabsInTabsTray by featureFlagPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_synced_tabs_tabs_tray),
|
||||
default = false,
|
||||
featureFlag = FeatureFlags.syncedTabsInTabsTray
|
||||
)
|
||||
|
||||
var forceEnableZoom by booleanPreference(
|
||||
appContext.getPreferenceKey(R.string.pref_key_accessibility_force_enable_zoom),
|
||||
default = false
|
||||
|
|
|
@ -179,6 +179,8 @@
|
|||
|
||||
<string name="pref_key_wait_first_paint" translatable="false">pref_key_wait_first_paint</string>
|
||||
|
||||
<string name="pref_key_synced_tabs_tabs_tray" translatable="false">pref_key_synced_tabs_tabs_tray</string>
|
||||
|
||||
<string name="pref_key_debug_settings" translatable="false">pref_key_debug_settings</string>
|
||||
|
||||
<string name="pref_key_open_tabs_count" translatable="false">pref_key_open_tabs_count</string>
|
||||
|
|
|
@ -36,6 +36,8 @@
|
|||
<string name="preferences_debug_settings_use_new_search_experience">Use New Search Experience</string>
|
||||
<!-- Label for the wait until first paint preference -->
|
||||
<string name="preferences_debug_settings_wait_first_paint">Wait Until First Paint To Show Page Content</string>
|
||||
<!-- Label for showing Synced Tabs in the tabs tray -->
|
||||
<string name="preferences_debug_synced_tabs_tabs_tray">Show Synced Tabs in the tabs tray</string>
|
||||
|
||||
<!-- Content description (not visible, for screen readers etc.) used to announce [LinkTextView]. -->
|
||||
<string name="link_text_view_type_announcement" translatable="false">link</string>
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
|
||||
<CheckBoxPreference
|
||||
android:defaultValue="false"
|
||||
app:isPreferenceVisible="false"
|
||||
android:key="@string/pref_key_sync_tabs"
|
||||
android:layout="@layout/checkbox_left_preference"
|
||||
android:title="@string/preferences_sync_tabs_2"/>
|
||||
|
|
|
@ -14,4 +14,9 @@
|
|||
android:key="@string/pref_key_wait_first_paint"
|
||||
android:title="@string/preferences_debug_settings_wait_first_paint"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/pref_key_synced_tabs_tabs_tray"
|
||||
android:title="@string/preferences_debug_synced_tabs_tabs_tray"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceScreen>
|
||||
|
|
Loading…
Reference in New Issue