|
|
|
@ -9,7 +9,6 @@ import android.os.Bundle
|
|
|
|
|
import android.view.View
|
|
|
|
|
import androidx.appcompat.app.AlertDialog
|
|
|
|
|
import androidx.fragment.app.Fragment
|
|
|
|
|
import androidx.lifecycle.Observer
|
|
|
|
|
import androidx.lifecycle.lifecycleScope
|
|
|
|
|
import androidx.navigation.fragment.findNavController
|
|
|
|
|
import kotlinx.android.synthetic.main.fragment_delete_browsing_data.*
|
|
|
|
@ -18,7 +17,6 @@ import kotlinx.coroutines.Dispatchers
|
|
|
|
|
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.R
|
|
|
|
|
import org.mozilla.fenix.components.FenixSnackbar
|
|
|
|
|
import org.mozilla.fenix.components.metrics.Event
|
|
|
|
@ -28,7 +26,6 @@ import org.mozilla.fenix.ext.showToolbar
|
|
|
|
|
@SuppressWarnings("TooManyFunctions")
|
|
|
|
|
class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_data) {
|
|
|
|
|
private lateinit var sessionObserver: SessionManager.Observer
|
|
|
|
|
private var tabCollections: List<TabCollection> = listOf()
|
|
|
|
|
private lateinit var controller: DeleteBrowsingDataController
|
|
|
|
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
|
@ -45,12 +42,6 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
requireComponents.core.sessionManager.register(sessionObserver, owner = this)
|
|
|
|
|
requireComponents.core.tabCollectionStorage.apply {
|
|
|
|
|
getCollections().observe(this@DeleteBrowsingDataFragment, Observer {
|
|
|
|
|
this@DeleteBrowsingDataFragment.tabCollections = it
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
getCheckboxes().forEach {
|
|
|
|
|
it.onCheckListener = { _ -> updateDeleteButton() }
|
|
|
|
|
}
|
|
|
|
@ -111,7 +102,6 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
when (i) {
|
|
|
|
|
OPEN_TABS_INDEX -> controller.deleteTabs()
|
|
|
|
|
HISTORY_INDEX -> controller.deleteBrowsingData()
|
|
|
|
|
COLLECTIONS_INDEX -> controller.deleteCollections(tabCollections)
|
|
|
|
|
COOKIES_INDEX -> controller.deleteCookies()
|
|
|
|
|
CACHED_INDEX -> controller.deleteCachedFiles()
|
|
|
|
|
PERMS_INDEX -> controller.deleteSitePermissions()
|
|
|
|
@ -165,7 +155,6 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
private fun updateItemCounts() {
|
|
|
|
|
updateTabCount()
|
|
|
|
|
updateHistoryCount()
|
|
|
|
|
updateCollectionsCount()
|
|
|
|
|
updateCookies()
|
|
|
|
|
updateCachedImagesAndFiles()
|
|
|
|
|
updateSitePermissions()
|
|
|
|
@ -198,24 +187,6 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun updateCollectionsCount() {
|
|
|
|
|
view?.browsing_data_item?.subtitleView?.text = ""
|
|
|
|
|
|
|
|
|
|
viewLifecycleOwner.lifecycleScope.launch(Dispatchers.IO) {
|
|
|
|
|
val collectionsCount =
|
|
|
|
|
requireComponents.core.tabCollectionStorage.getTabCollectionsCount()
|
|
|
|
|
launch(Dispatchers.Main) {
|
|
|
|
|
view?.collections_item?.apply {
|
|
|
|
|
subtitleView.text =
|
|
|
|
|
resources.getString(
|
|
|
|
|
R.string.preferences_delete_browsing_data_collections_subtitle,
|
|
|
|
|
collectionsCount
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun updateCookies() {
|
|
|
|
|
// NO OP until we have GeckoView methods to count cookies
|
|
|
|
|
}
|
|
|
|
@ -233,12 +204,12 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
return listOf(
|
|
|
|
|
fragmentView.open_tabs_item,
|
|
|
|
|
fragmentView.browsing_data_item,
|
|
|
|
|
fragmentView.collections_item,
|
|
|
|
|
fragmentView.cookies_item,
|
|
|
|
|
fragmentView.cached_files_item,
|
|
|
|
|
fragmentView.site_permissions_item
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// If coming from Open Tab -> Settings, pop back to Home
|
|
|
|
|
// If coming from Home -> Settings, pop back to Settings
|
|
|
|
|
private fun returnToDeletionOrigin() {
|
|
|
|
@ -286,9 +257,8 @@ class DeleteBrowsingDataFragment : Fragment(R.layout.fragment_delete_browsing_da
|
|
|
|
|
|
|
|
|
|
private const val OPEN_TABS_INDEX = 0
|
|
|
|
|
private const val HISTORY_INDEX = 1
|
|
|
|
|
private const val COLLECTIONS_INDEX = 2
|
|
|
|
|
private const val COOKIES_INDEX = 3
|
|
|
|
|
private const val CACHED_INDEX = 4
|
|
|
|
|
private const val PERMS_INDEX = 5
|
|
|
|
|
private const val COOKIES_INDEX = 2
|
|
|
|
|
private const val CACHED_INDEX = 3
|
|
|
|
|
private const val PERMS_INDEX = 4
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|