Loading app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsAdapter.kt +3 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import org.mozilla.fenix.exceptions.viewholders.ExceptionsDeleteButtonViewHolder import org.mozilla.fenix.exceptions.viewholders.ExceptionsHeaderViewHolder import org.mozilla.fenix.exceptions.viewholders.ExceptionsListItemViewHolder Loading @@ -16,7 +17,7 @@ import org.mozilla.fenix.exceptions.viewholders.ExceptionsListItemViewHolder sealed class AdapterItem { object DeleteButton : AdapterItem() object Header : AdapterItem() data class Item(val item: ExceptionsItem) : AdapterItem() data class Item(val item: TrackingProtectionException) : AdapterItem() } /** Loading @@ -31,7 +32,7 @@ class ExceptionsAdapter( * Change the list of items that are displayed. * Header and footer items are added to the list as well. */ fun updateData(exceptions: List<ExceptionsItem>) { fun updateData(exceptions: List<TrackingProtectionException>) { val adapterItems = mutableListOf<AdapterItem>() adapterItems.add(AdapterItem.Header) exceptions.mapTo(adapterItems) { AdapterItem.Item(it) } Loading app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt +3 −3 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import kotlinx.android.synthetic.main.fragment_exceptions.view.* import kotlinx.coroutines.ExperimentalCoroutinesApi import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import mozilla.components.feature.session.TrackingProtectionUseCases import mozilla.components.lib.state.ext.consumeFrom import org.mozilla.fenix.BrowserDirection Loading Loading @@ -74,7 +75,7 @@ class ExceptionsFragment : Fragment() { reloadExceptions() } private fun deleteOneItem(item: ExceptionsItem) { private fun deleteOneItem(item: TrackingProtectionException) { // We can't currently delete one item in this Exceptions list with a URL with the GV API // See https://github.com/mozilla-mobile/android-components/issues/4699 Log.e("Remove one exception", "$item") Loading @@ -92,8 +93,7 @@ class ExceptionsFragment : Fragment() { private fun reloadExceptions() { trackingProtectionUseCases.fetchExceptions { resultList -> val exceptionsList = resultList.map { ExceptionsItem(it) } exceptionsStore.dispatch(ExceptionsFragmentAction.Change(exceptionsList)) exceptionsStore.dispatch(ExceptionsFragmentAction.Change(resultList)) } } } app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStore.kt +4 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package org.mozilla.fenix.exceptions import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import mozilla.components.lib.state.Action import mozilla.components.lib.state.State import mozilla.components.lib.state.Store Loading @@ -12,7 +13,7 @@ import mozilla.components.lib.state.Store * Class representing an exception item * @property url Host of the exception */ data class ExceptionsItem(val url: String) data class ExceptionItem(override val url: String) : TrackingProtectionException /** * The [Store] for holding the [ExceptionsFragmentState] and applying [ExceptionsFragmentAction]s. Loading @@ -24,14 +25,14 @@ class ExceptionsFragmentStore(initialState: ExceptionsFragmentState) : * Actions to dispatch through the `ExceptionsStore` to modify `ExceptionsState` through the reducer. */ sealed class ExceptionsFragmentAction : Action { data class Change(val list: List<ExceptionsItem>) : ExceptionsFragmentAction() data class Change(val list: List<TrackingProtectionException>) : ExceptionsFragmentAction() } /** * The state for the Exceptions Screen * @property items List of exceptions to display */ data class ExceptionsFragmentState(val items: List<ExceptionsItem>) : State data class ExceptionsFragmentState(val items: List<TrackingProtectionException>) : State /** * The ExceptionsState Reducer. Loading app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsInteractor.kt +4 −2 Original line number Diff line number Diff line Loading @@ -4,13 +4,15 @@ package org.mozilla.fenix.exceptions import mozilla.components.concept.engine.content.blocking.TrackingProtectionException /** * Interactor for the exceptions screen * Provides implementations for the ExceptionsViewInteractor */ class ExceptionsInteractor( private val learnMore: () -> Unit, private val deleteOne: (ExceptionsItem) -> Unit, private val deleteOne: (TrackingProtectionException) -> Unit, private val deleteAll: () -> Unit ) : ExceptionsViewInteractor { override fun onLearnMore() { Loading @@ -21,7 +23,7 @@ class ExceptionsInteractor( deleteAll.invoke() } override fun onDeleteOne(item: ExceptionsItem) { override fun onDeleteOne(item: TrackingProtectionException) { deleteOne.invoke(item) } } app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt +2 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.main.component_exceptions.view.* import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import org.mozilla.fenix.R /** Loading @@ -34,7 +35,7 @@ interface ExceptionsViewInteractor { /** * Called whenever one exception item is deleted */ fun onDeleteOne(item: ExceptionsItem) fun onDeleteOne(item: TrackingProtectionException) } /** Loading Loading
app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsAdapter.kt +3 −2 Original line number Diff line number Diff line Loading @@ -9,6 +9,7 @@ import android.view.ViewGroup import androidx.recyclerview.widget.DiffUtil import androidx.recyclerview.widget.ListAdapter import androidx.recyclerview.widget.RecyclerView import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import org.mozilla.fenix.exceptions.viewholders.ExceptionsDeleteButtonViewHolder import org.mozilla.fenix.exceptions.viewholders.ExceptionsHeaderViewHolder import org.mozilla.fenix.exceptions.viewholders.ExceptionsListItemViewHolder Loading @@ -16,7 +17,7 @@ import org.mozilla.fenix.exceptions.viewholders.ExceptionsListItemViewHolder sealed class AdapterItem { object DeleteButton : AdapterItem() object Header : AdapterItem() data class Item(val item: ExceptionsItem) : AdapterItem() data class Item(val item: TrackingProtectionException) : AdapterItem() } /** Loading @@ -31,7 +32,7 @@ class ExceptionsAdapter( * Change the list of items that are displayed. * Header and footer items are added to the list as well. */ fun updateData(exceptions: List<ExceptionsItem>) { fun updateData(exceptions: List<TrackingProtectionException>) { val adapterItems = mutableListOf<AdapterItem>() adapterItems.add(AdapterItem.Header) exceptions.mapTo(adapterItems) { AdapterItem.Item(it) } Loading
app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt +3 −3 Original line number Diff line number Diff line Loading @@ -12,6 +12,7 @@ import android.view.ViewGroup import androidx.fragment.app.Fragment import kotlinx.android.synthetic.main.fragment_exceptions.view.* import kotlinx.coroutines.ExperimentalCoroutinesApi import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import mozilla.components.feature.session.TrackingProtectionUseCases import mozilla.components.lib.state.ext.consumeFrom import org.mozilla.fenix.BrowserDirection Loading Loading @@ -74,7 +75,7 @@ class ExceptionsFragment : Fragment() { reloadExceptions() } private fun deleteOneItem(item: ExceptionsItem) { private fun deleteOneItem(item: TrackingProtectionException) { // We can't currently delete one item in this Exceptions list with a URL with the GV API // See https://github.com/mozilla-mobile/android-components/issues/4699 Log.e("Remove one exception", "$item") Loading @@ -92,8 +93,7 @@ class ExceptionsFragment : Fragment() { private fun reloadExceptions() { trackingProtectionUseCases.fetchExceptions { resultList -> val exceptionsList = resultList.map { ExceptionsItem(it) } exceptionsStore.dispatch(ExceptionsFragmentAction.Change(exceptionsList)) exceptionsStore.dispatch(ExceptionsFragmentAction.Change(resultList)) } } }
app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragmentStore.kt +4 −3 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package org.mozilla.fenix.exceptions import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import mozilla.components.lib.state.Action import mozilla.components.lib.state.State import mozilla.components.lib.state.Store Loading @@ -12,7 +13,7 @@ import mozilla.components.lib.state.Store * Class representing an exception item * @property url Host of the exception */ data class ExceptionsItem(val url: String) data class ExceptionItem(override val url: String) : TrackingProtectionException /** * The [Store] for holding the [ExceptionsFragmentState] and applying [ExceptionsFragmentAction]s. Loading @@ -24,14 +25,14 @@ class ExceptionsFragmentStore(initialState: ExceptionsFragmentState) : * Actions to dispatch through the `ExceptionsStore` to modify `ExceptionsState` through the reducer. */ sealed class ExceptionsFragmentAction : Action { data class Change(val list: List<ExceptionsItem>) : ExceptionsFragmentAction() data class Change(val list: List<TrackingProtectionException>) : ExceptionsFragmentAction() } /** * The state for the Exceptions Screen * @property items List of exceptions to display */ data class ExceptionsFragmentState(val items: List<ExceptionsItem>) : State data class ExceptionsFragmentState(val items: List<TrackingProtectionException>) : State /** * The ExceptionsState Reducer. Loading
app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsInteractor.kt +4 −2 Original line number Diff line number Diff line Loading @@ -4,13 +4,15 @@ package org.mozilla.fenix.exceptions import mozilla.components.concept.engine.content.blocking.TrackingProtectionException /** * Interactor for the exceptions screen * Provides implementations for the ExceptionsViewInteractor */ class ExceptionsInteractor( private val learnMore: () -> Unit, private val deleteOne: (ExceptionsItem) -> Unit, private val deleteOne: (TrackingProtectionException) -> Unit, private val deleteAll: () -> Unit ) : ExceptionsViewInteractor { override fun onLearnMore() { Loading @@ -21,7 +23,7 @@ class ExceptionsInteractor( deleteAll.invoke() } override fun onDeleteOne(item: ExceptionsItem) { override fun onDeleteOne(item: TrackingProtectionException) { deleteOne.invoke(item) } }
app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsView.kt +2 −1 Original line number Diff line number Diff line Loading @@ -14,6 +14,7 @@ import androidx.core.view.isVisible import androidx.recyclerview.widget.LinearLayoutManager import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.main.component_exceptions.view.* import mozilla.components.concept.engine.content.blocking.TrackingProtectionException import org.mozilla.fenix.R /** Loading @@ -34,7 +35,7 @@ interface ExceptionsViewInteractor { /** * Called whenever one exception item is deleted */ fun onDeleteOne(item: ExceptionsItem) fun onDeleteOne(item: TrackingProtectionException) } /** Loading