diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 4a3e58c396..05279743b4 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -70,6 +70,7 @@ class HomeFragment : Fragment() { tabsComponent = TabsComponent( view.homeContainer, bus, + (activity as HomeActivity).browsingModeManager.isPrivate, TabsState(sessionManager.sessions.map { it.toSessionViewState(it == sessionManager.selectedSession) }) ) sessionsComponent = SessionsComponent(view.homeContainer, bus) @@ -168,6 +169,7 @@ class HomeFragment : Fragment() { (activity as AppCompatActivity).supportActionBar?.hide() } + @SuppressWarnings("ComplexMethod") override fun onStart() { super.onStart() if (isAdded) { @@ -188,6 +190,9 @@ class HomeFragment : Fragment() { requireComponents.core.sessionManager.remove(session) } } + is TabsAction.CloseAll -> { + requireComponents.useCases.tabsUseCases.removeAllTabsOfType.invoke(it.private) + } } } diff --git a/app/src/main/java/org/mozilla/fenix/home/tabs/TabsComponent.kt b/app/src/main/java/org/mozilla/fenix/home/tabs/TabsComponent.kt index e69df8ea3e..a74713a3bc 100644 --- a/app/src/main/java/org/mozilla/fenix/home/tabs/TabsComponent.kt +++ b/app/src/main/java/org/mozilla/fenix/home/tabs/TabsComponent.kt @@ -17,6 +17,7 @@ import org.mozilla.fenix.mvi.ViewState class TabsComponent( private val container: ViewGroup, bus: ActionBusFactory, + private val isPrivate: Boolean, override var initialState: TabsState = TabsState(listOf()) ) : UIComponent( @@ -30,7 +31,7 @@ class TabsComponent( } } - override fun initView() = TabsUIView(container, actionEmitter, changesObservable) + override fun initView() = TabsUIView(container, actionEmitter, changesObservable, isPrivate) val tabList: RecyclerView get() = uiView.view.tabs_list as RecyclerView @@ -48,6 +49,7 @@ fun Session.toSessionViewState(selected: Boolean): SessionViewState { sealed class TabsAction : Action { object Archive : TabsAction() + data class CloseAll(val private: Boolean) : TabsAction() data class Select(val sessionId: String) : TabsAction() data class Close(val sessionId: String) : TabsAction() } diff --git a/app/src/main/java/org/mozilla/fenix/home/tabs/TabsUIView.kt b/app/src/main/java/org/mozilla/fenix/home/tabs/TabsUIView.kt index ee2597ff8b..021591e562 100644 --- a/app/src/main/java/org/mozilla/fenix/home/tabs/TabsUIView.kt +++ b/app/src/main/java/org/mozilla/fenix/home/tabs/TabsUIView.kt @@ -27,7 +27,8 @@ import org.mozilla.fenix.mvi.UIView class TabsUIView( container: ViewGroup, actionEmitter: Observer, - changesObservable: Observable + changesObservable: Observable, + private val isPrivate: Boolean ) : UIView(container, actionEmitter, changesObservable) { @@ -65,6 +66,10 @@ class TabsUIView( this.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null) } + delete_session_button.setOnClickListener { + actionEmitter.onNext(TabsAction.CloseAll(true)) + } + save_session_button.setOnClickListener { actionEmitter.onNext(TabsAction.Archive) } @@ -73,10 +78,11 @@ class TabsUIView( override fun updateView() = Consumer { tabsAdapter.sessions = it.sessions + val sessionButton = if (isPrivate) view.delete_session_button else view.save_session_button (if (it.sessions.isEmpty()) View.GONE else View.VISIBLE).also { visibility -> view.tabs_header.visibility = visibility - view.save_session_button.visibility = visibility + sessionButton.visibility = visibility } } diff --git a/app/src/main/res/drawable/ic_delete.xml b/app/src/main/res/drawable/ic_delete.xml index 26cc6d19b3..82f72afe1e 100644 --- a/app/src/main/res/drawable/ic_delete.xml +++ b/app/src/main/res/drawable/ic_delete.xml @@ -1,3 +1,7 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index c9cf92a576..f2907182eb 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -34,6 +34,7 @@ #544CD9 #6D6D6E #4a4671 + #e5e5ea #ad3bff #242251 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52c0d3baa3..a87eccfeaa 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -23,8 +23,6 @@ Private Sessions tabs. While this doesn\'t make you anonymous to websites or your internet service provider, it makes it easier to keep what you do online private from anyone else who uses this device.\n\nCommon myths about private browsing - - Delete Session @@ -172,6 +170,8 @@ people before profit. Our mission: keep the Internet open and accessible to all. Save Session + + Delete Session Delete