Updates per UX and PR feedback
parent
2b9efccfca
commit
758f4c13ec
|
@ -10,6 +10,7 @@ import kotlinx.coroutines.delay
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import mozilla.components.concept.engine.Engine
|
import mozilla.components.concept.engine.Engine
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.ext.components
|
import org.mozilla.fenix.ext.components
|
||||||
import kotlin.coroutines.CoroutineContext
|
import kotlin.coroutines.CoroutineContext
|
||||||
|
|
||||||
|
@ -34,7 +35,11 @@ class DefaultDeleteBrowsingDataController(
|
||||||
|
|
||||||
override suspend fun deleteBrowsingData() {
|
override suspend fun deleteBrowsingData() {
|
||||||
withContext(coroutineContext) {
|
withContext(coroutineContext) {
|
||||||
context.components.core.engine.clearData(Engine.BrowsingData.all())
|
if (FeatureFlags.granularDataDeletion) {
|
||||||
|
context.components.core.engine.clearData(Engine.BrowsingData.select(Engine.BrowsingData.DOM_STORAGES))
|
||||||
|
} else {
|
||||||
|
context.components.core.engine.clearData(Engine.BrowsingData.all())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
context.components.core.historyStorage.deleteEverything()
|
context.components.core.historyStorage.deleteEverything()
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,15 +15,12 @@ import androidx.fragment.app.Fragment
|
||||||
import androidx.lifecycle.Observer
|
import androidx.lifecycle.Observer
|
||||||
import androidx.lifecycle.lifecycleScope
|
import androidx.lifecycle.lifecycleScope
|
||||||
import androidx.navigation.fragment.findNavController
|
import androidx.navigation.fragment.findNavController
|
||||||
import androidx.paging.PagedList
|
|
||||||
import androidx.paging.toLiveData
|
|
||||||
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.*
|
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.*
|
||||||
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.view.*
|
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.view.*
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import mozilla.components.browser.session.Session
|
import mozilla.components.browser.session.Session
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.feature.sitepermissions.SitePermissions
|
|
||||||
import mozilla.components.feature.tab.collections.TabCollection
|
import mozilla.components.feature.tab.collections.TabCollection
|
||||||
import org.mozilla.fenix.FeatureFlags
|
import org.mozilla.fenix.FeatureFlags
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
|
@ -64,9 +61,17 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
getCheckboxes().forEach {
|
if (!FeatureFlags.granularDataDeletion) {
|
||||||
it.onCheckListener = { _ -> updateDeleteButton() }
|
// 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 }
|
||||||
}
|
}
|
||||||
|
|
||||||
view.delete_data?.setOnClickListener {
|
view.delete_data?.setOnClickListener {
|
||||||
askToDelete()
|
askToDelete()
|
||||||
}
|
}
|
||||||
|
@ -167,7 +172,7 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
updateSitePermissions()
|
updateSitePermissions()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateDeleteButton() {
|
private fun updateCheckboxState() {
|
||||||
val enabled = getCheckboxes().any { it.isChecked }
|
val enabled = getCheckboxes().any { it.isChecked }
|
||||||
|
|
||||||
view?.delete_data?.isEnabled = enabled
|
view?.delete_data?.isEnabled = enabled
|
||||||
|
@ -181,7 +186,7 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
R.string.preferences_delete_browsing_data_tabs_subtitle,
|
R.string.preferences_delete_browsing_data_tabs_subtitle,
|
||||||
openTabs
|
openTabs
|
||||||
)
|
)
|
||||||
isEnabled = openTabs > 0
|
if (!FeatureFlags.granularDataDeletion) isEnabled = openTabs > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +202,7 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
R.string.preferences_delete_browsing_data_browsing_data_subtitle,
|
R.string.preferences_delete_browsing_data_browsing_data_subtitle,
|
||||||
historyCount
|
historyCount
|
||||||
)
|
)
|
||||||
isEnabled = historyCount > 0
|
if (!FeatureFlags.granularDataDeletion) isEnabled = historyCount > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -216,7 +221,7 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
R.string.preferences_delete_browsing_data_collections_subtitle,
|
R.string.preferences_delete_browsing_data_collections_subtitle,
|
||||||
collectionsCount
|
collectionsCount
|
||||||
)
|
)
|
||||||
isEnabled = collectionsCount > 0
|
if (!FeatureFlags.granularDataDeletion) isEnabled = collectionsCount > 0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -231,16 +236,7 @@ class DeleteBrowsingDataFragment : Fragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateSitePermissions() {
|
private fun updateSitePermissions() {
|
||||||
val liveData =
|
// NO OP until we have GeckoView methods for cookies and cached files, for consistency
|
||||||
requireComponents.core.permissionStorage.getSitePermissionsPaged().toLiveData(1)
|
|
||||||
liveData.observe(
|
|
||||||
this,
|
|
||||||
object : Observer<PagedList<SitePermissions>> {
|
|
||||||
override fun onChanged(list: PagedList<SitePermissions>?) {
|
|
||||||
view?.site_permissions_item?.isEnabled = !list.isNullOrEmpty()
|
|
||||||
liveData.removeObserver(this)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getCheckboxes(): List<DeleteBrowsingDataItem> {
|
private fun getCheckboxes(): List<DeleteBrowsingDataItem> {
|
||||||
|
|
|
@ -74,7 +74,7 @@ class DefaultDeleteBrowsingDataControllerTest {
|
||||||
controller.deleteBrowsingData()
|
controller.deleteBrowsingData()
|
||||||
|
|
||||||
verify {
|
verify {
|
||||||
context.components.core.engine.clearData(Engine.BrowsingData.all())
|
context.components.core.engine.clearData(any())
|
||||||
context.components.core.historyStorage
|
context.components.core.historyStorage
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue