Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
No issue: Removes feature flags for delete data (#5738) (#5741)
Browse files Browse the repository at this point in the history
  • Loading branch information
sblatz committed Oct 2, 2019
1 parent f8bb389 commit 2132d9a
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 59 deletions.
11 changes: 0 additions & 11 deletions app/src/main/java/org/mozilla/fenix/FeatureFlags.kt
Expand Up @@ -45,17 +45,6 @@ object FeatureFlags {
*/
val etpCategories = nightly or debug

/**
* Granular data deletion provides additional choices on the Delete Browsing Data
* setting screen for cookies, cached images and files, and site permissions.
*/
val granularDataDeletion = nightly or debug

/**
* Gives option in Settings to Delete Browsing Data on new menu option Quit
*/
val deleteDataOnQuit = nightly or debug

/**
* Gives option in Settings to disable auto play media
*/
Expand Down
Expand Up @@ -30,7 +30,6 @@ import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.concept.sync.Profile
import org.mozilla.fenix.BrowserDirection
import org.mozilla.fenix.Config
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.FenixApplication
import org.mozilla.fenix.HomeActivity
import org.mozilla.fenix.R
Expand Down Expand Up @@ -105,14 +104,6 @@ class SettingsFragment : PreferenceFragmentCompat(), AccountObserver {
isVisible = false
}
}

if (FeatureFlags.deleteDataOnQuit) {
findPreference<Preference>(
getPreferenceKey(R.string.pref_key_delete_browsing_data_on_quit_preference)
)?.apply {
isVisible = true
}
}
}

override fun onCreatePreferences(savedInstanceState: Bundle?, rootKey: String?) {
Expand Down
Expand Up @@ -10,7 +10,6 @@ import kotlinx.coroutines.delay
import kotlinx.coroutines.withContext
import mozilla.components.concept.engine.Engine
import mozilla.components.feature.tab.collections.TabCollection
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.ext.components
import kotlin.coroutines.CoroutineContext

Expand All @@ -36,14 +35,7 @@ class DefaultDeleteBrowsingDataController(
}

override suspend fun deleteBrowsingData() {
if (FeatureFlags.granularDataDeletion) {
deleteHistoryAndDOMStorages()
} else {
withContext(coroutineContext) {
context.components.core.engine.clearData(Engine.BrowsingData.all())
}
context.components.core.historyStorage.deleteEverything()
}
deleteHistoryAndDOMStorages()
}

override suspend fun deleteHistoryAndDOMStorages() {
Expand Down
Expand Up @@ -22,7 +22,6 @@ import kotlinx.coroutines.launch
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.feature.tab.collections.TabCollection
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.components.FenixSnackbar
import org.mozilla.fenix.components.metrics.Event
Expand Down Expand Up @@ -61,16 +60,7 @@ class DeleteBrowsingDataFragment : Fragment() {
})
}

if (!FeatureFlags.granularDataDeletion) {
// Disabling the disabled state until we have APIs to decide
// if there is data to delete for all categories
getCheckboxes().forEach {
it.onCheckListener = { _ -> updateCheckboxState() }
}
} else {
// Otherwise, all checkboxes should default to checked state
getCheckboxes().forEach { it.isChecked = true }
}
getCheckboxes().forEach { it.isChecked = true }

view.delete_data?.setOnClickListener {
askToDelete()
Expand Down Expand Up @@ -161,7 +151,7 @@ class DeleteBrowsingDataFragment : Fragment() {
.setText(resources.getString(R.string.preferences_delete_browsing_data_snackbar))
.show()

if (popAfter || FeatureFlags.granularDataDeletion) viewLifecycleOwner.lifecycleScope.launch(
if (popAfter) viewLifecycleOwner.lifecycleScope.launch(
Dispatchers.Main
) {
findNavController().popBackStack(R.id.homeFragment, false)
Expand All @@ -177,21 +167,13 @@ class DeleteBrowsingDataFragment : Fragment() {
updateSitePermissions()
}

private fun updateCheckboxState() {
val enabled = getCheckboxes().any { it.isChecked }

view?.delete_data?.isEnabled = enabled
view?.delete_data?.alpha = if (enabled) ENABLED_ALPHA else DISABLED_ALPHA
}

private fun updateTabCount() {
view?.open_tabs_item?.apply {
val openTabs = requireComponents.core.sessionManager.sessions.size
subtitleView.text = resources.getString(
R.string.preferences_delete_browsing_data_tabs_subtitle,
openTabs
)
if (!FeatureFlags.granularDataDeletion) isEnabled = openTabs > 0
}
}

Expand All @@ -207,7 +189,6 @@ class DeleteBrowsingDataFragment : Fragment() {
R.string.preferences_delete_browsing_data_browsing_data_subtitle,
historyCount
)
if (!FeatureFlags.granularDataDeletion) isEnabled = historyCount > 0
}
}
}
Expand All @@ -226,7 +207,6 @@ class DeleteBrowsingDataFragment : Fragment() {
R.string.preferences_delete_browsing_data_collections_subtitle,
collectionsCount
)
if (!FeatureFlags.granularDataDeletion) isEnabled = collectionsCount > 0
}
}
}
Expand All @@ -246,18 +226,14 @@ class DeleteBrowsingDataFragment : Fragment() {

private fun getCheckboxes(): List<DeleteBrowsingDataItem> {
val fragmentView = view!!
val originalList = listOf(
return listOf(
fragmentView.open_tabs_item,
fragmentView.browsing_data_item,
fragmentView.collections_item
)
@Suppress("ConstantConditionIf")
val granularList = if (FeatureFlags.granularDataDeletion) listOf(
fragmentView.collections_item,
fragmentView.cookies_item,
fragmentView.cached_files_item,
fragmentView.site_permissions_item
) else emptyList()
return originalList + granularList
)
}

companion object {
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/xml/preferences.xml
Expand Up @@ -75,7 +75,6 @@
android:key="@string/pref_key_delete_browsing_data"
android:title="@string/preferences_delete_browsing_data" />
<androidx.preference.Preference
app:isPreferenceVisible="false"
android:icon="@drawable/ic_exit"
android:key="@string/pref_key_delete_browsing_data_on_quit_preference"
android:title="@string/preferences_delete_browsing_data_on_quit" />
Expand Down

0 comments on commit 2132d9a

Please sign in to comment.