For #23808 - Add secret setting for enabling Task Continuity feature
This commit is contained in:
parent
5153cee0e0
commit
15c58b7261
|
@ -53,5 +53,11 @@ class SecretSettingsFragment : PreferenceFragmentCompat() {
|
|||
isChecked = context.settings().nimbusUsePreview
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
|
||||
requirePreference<SwitchPreference>(R.string.pref_key_enable_task_continuity).apply {
|
||||
isVisible = true
|
||||
isChecked = context.settings().enableTaskContinuityEnhancements
|
||||
onPreferenceChangeListener = SharedPreferenceUpdater()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,14 +6,15 @@ package org.mozilla.fenix.tabstray.ext
|
|||
|
||||
import mozilla.components.browser.storage.sync.SyncedDeviceTabs
|
||||
import mozilla.components.browser.toolbar.MAX_URI_LENGTH
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.tabstray.syncedtabs.SyncedTabsListItem
|
||||
|
||||
/**
|
||||
* Converts a list of [SyncedDeviceTabs] into a list of [SyncedTabsListItem].
|
||||
*/
|
||||
fun List<SyncedDeviceTabs>.toComposeList(): List<SyncedTabsListItem> = asSequence().flatMap { (device, tabs) ->
|
||||
if (FeatureFlags.taskContinuityFeature) {
|
||||
fun List<SyncedDeviceTabs>.toComposeList(
|
||||
taskContinuityEnabled: Boolean,
|
||||
): List<SyncedTabsListItem> = asSequence().flatMap { (device, tabs) ->
|
||||
if (taskContinuityEnabled) {
|
||||
val deviceTabs = if (tabs.isEmpty()) {
|
||||
emptyList()
|
||||
} else {
|
||||
|
|
|
@ -48,7 +48,6 @@ import androidx.compose.ui.unit.dp
|
|||
import androidx.compose.ui.unit.sp
|
||||
import mozilla.components.browser.storage.sync.TabEntry
|
||||
import mozilla.components.feature.syncedtabs.view.SyncedTabsView
|
||||
import org.mozilla.fenix.FeatureFlags
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.compose.PrimaryText
|
||||
import org.mozilla.fenix.compose.SecondaryText
|
||||
|
@ -63,14 +62,18 @@ import mozilla.components.browser.storage.sync.Tab as SyncTab
|
|||
*/
|
||||
@OptIn(ExperimentalFoundationApi::class)
|
||||
@Composable
|
||||
fun SyncedTabsList(syncedTabs: List<SyncedTabsListItem>, onTabClick: (SyncTab) -> Unit) {
|
||||
fun SyncedTabsList(
|
||||
syncedTabs: List<SyncedTabsListItem>,
|
||||
taskContinuityEnabled: Boolean,
|
||||
onTabClick: (SyncTab) -> Unit,
|
||||
) {
|
||||
val listState = rememberLazyListState()
|
||||
|
||||
LazyColumn(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
state = listState,
|
||||
) {
|
||||
if (FeatureFlags.taskContinuityFeature) {
|
||||
if (taskContinuityEnabled) {
|
||||
syncedTabs.forEach { syncedTabItem ->
|
||||
when (syncedTabItem) {
|
||||
is SyncedTabsListItem.DeviceSection -> {
|
||||
|
@ -341,7 +344,8 @@ private fun SyncedTabsListPreview() {
|
|||
FirefoxTheme {
|
||||
Box(Modifier.background(FirefoxTheme.colors.layer1)) {
|
||||
SyncedTabsList(
|
||||
getFakeSyncedTabList(),
|
||||
syncedTabs = getFakeSyncedTabList(),
|
||||
taskContinuityEnabled = true,
|
||||
) {
|
||||
println("Tab clicked")
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ import mozilla.components.support.base.observer.Observable
|
|||
import mozilla.components.support.base.observer.ObserverRegistry
|
||||
import org.mozilla.fenix.NavGraphDirections
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.tabstray.FloatingActionButtonBinding
|
||||
import org.mozilla.fenix.tabstray.TabsTrayAction
|
||||
import org.mozilla.fenix.tabstray.TabsTrayStore
|
||||
|
@ -90,7 +91,13 @@ class SyncedTabsIntegration(
|
|||
}
|
||||
|
||||
override fun displaySyncedTabs(syncedTabs: List<SyncedDeviceTabs>) {
|
||||
store.dispatch(TabsTrayAction.UpdateSyncedTabs(syncedTabs.toComposeList()))
|
||||
store.dispatch(
|
||||
TabsTrayAction.UpdateSyncedTabs(
|
||||
syncedTabs.toComposeList(
|
||||
context.settings().enableTaskContinuityEnhancements
|
||||
)
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -8,6 +8,7 @@ import android.view.View
|
|||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import mozilla.components.lib.state.ext.observeAsComposableState
|
||||
import org.mozilla.fenix.ext.settings
|
||||
import org.mozilla.fenix.tabstray.NavigationInteractor
|
||||
import org.mozilla.fenix.tabstray.TabsTrayStore
|
||||
import org.mozilla.fenix.tabstray.TabsTrayState
|
||||
|
@ -33,7 +34,8 @@ class SyncedTabsPageViewHolder(
|
|||
FirefoxTheme {
|
||||
SyncedTabsList(
|
||||
syncedTabs = tabs ?: emptyList(),
|
||||
onTabClick = navigationInteractor::onSyncedTabClicked
|
||||
taskContinuityEnabled = composeView.context.settings().enableTaskContinuityEnhancements,
|
||||
onTabClick = navigationInteractor::onSyncedTabClicked,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1299,4 +1299,13 @@ class Settings(private val appContext: Context) : PreferencesHolder {
|
|||
default = false,
|
||||
featureFlag = FeatureFlags.contileFeature,
|
||||
)
|
||||
|
||||
/**
|
||||
* Indicates if the Task Continuity enhancements are enabled.
|
||||
*/
|
||||
var enableTaskContinuityEnhancements by featureFlagPreference(
|
||||
key = appContext.getPreferenceKey(R.string.pref_key_enable_task_continuity),
|
||||
default = false,
|
||||
featureFlag = FeatureFlags.taskContinuityFeature,
|
||||
)
|
||||
}
|
||||
|
|
|
@ -204,6 +204,8 @@
|
|||
<string name="pref_key_enable_top_frecent_sites" translatable="false">pref_key_top_frecent_sites</string>
|
||||
<!-- Whether or not the sponsored shortcuts are shown along with the top recent sites shortcuts -->
|
||||
<string name="pref_key_enable_contile" translatable="false">pref_key_enable_contile</string>
|
||||
<!-- Whether or not the Task Continuity enhancements are shown -->
|
||||
<string name="pref_key_enable_task_continuity" translatable="false">pref_key_enable_task_continuity</string>
|
||||
|
||||
<!-- A value of `true` means the PWA dialog has been showed or user already has PWAs installed -->
|
||||
<string name="pref_key_user_knows_about_pwa" translatable="false">pref_key_user_knows_about_pwa</string>
|
||||
|
|
|
@ -43,6 +43,8 @@
|
|||
<string name="preferences_nimbus_experiments">Nimbus Experiments</string>
|
||||
<!-- Label for using the nimbus collections preview -->
|
||||
<string name="preferences_nimbus_use_preview_collection">Use Nimbus Preview Collection (requires restart)</string>
|
||||
<!-- Label for enabling the Task Continuity feature -->
|
||||
<string name="preferences_debug_settings_task_continuity" translatable="false">Enable Task Continuity</string>
|
||||
|
||||
<!-- A secret menu option in the tabs tray for making a tab inactive for testing. -->
|
||||
<string name="inactive_tabs_menu_item">Make inactive</string>
|
||||
|
|
|
@ -25,4 +25,9 @@
|
|||
android:key="@string/pref_key_nimbus_use_preview"
|
||||
android:title="@string/preferences_nimbus_use_preview_collection"
|
||||
app:iconSpaceReserved="false" />
|
||||
<SwitchPreference
|
||||
android:defaultValue="false"
|
||||
android:key="@string/pref_key_enable_task_continuity"
|
||||
android:title="@string/preferences_debug_settings_task_continuity"
|
||||
app:iconSpaceReserved="false" />
|
||||
</PreferenceScreen>
|
||||
|
|
|
@ -82,7 +82,7 @@ class SyncedDeviceTabsTest {
|
|||
@Test
|
||||
fun `GIVEN two synced devices WHEN the compose list is generated THEN two device section is returned`() {
|
||||
val syncedDeviceList = listOf(oneTabDevice, twoTabDevice)
|
||||
val listData = syncedDeviceList.toComposeList()
|
||||
val listData = syncedDeviceList.toComposeList(taskContinuityEnabled = true)
|
||||
|
||||
assertEquals(2, listData.count())
|
||||
assertTrue(listData[0] is SyncedTabsListItem.DeviceSection)
|
||||
|
@ -94,7 +94,7 @@ class SyncedDeviceTabsTest {
|
|||
@Test
|
||||
fun `GIVEN one synced device with no tabs WHEN the compose list is generated THEN one device with an empty tabs list is returned`() {
|
||||
val syncedDeviceList = listOf(noTabDevice)
|
||||
val listData = syncedDeviceList.toComposeList()
|
||||
val listData = syncedDeviceList.toComposeList(taskContinuityEnabled = true)
|
||||
|
||||
assertEquals(1, listData.count())
|
||||
assertTrue(listData[0] is SyncedTabsListItem.DeviceSection)
|
||||
|
|
Loading…
Reference in New Issue