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

Commit

Permalink
For #2834: Delete all Private Tabs redesign
Browse files Browse the repository at this point in the history
  • Loading branch information
jyeontaek committed Aug 16, 2019
1 parent 727457f commit b07cca0
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
package org.mozilla.fenix.components.toolbar

import android.content.Context
import android.graphics.PorterDuff
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.navigation.NavOptions
import androidx.navigation.Navigation
import androidx.navigation.fragment.FragmentNavigator
Expand All @@ -22,6 +24,7 @@ import mozilla.components.support.base.feature.LifecycleAwareFeature
import mozilla.components.support.ktx.android.view.hideKeyboard
import org.mozilla.fenix.R
import org.mozilla.fenix.ThemeManager
import org.mozilla.fenix.browser.BrowserFragmentDirections
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.nav
import org.mozilla.fenix.utils.Settings
Expand Down Expand Up @@ -53,6 +56,29 @@ class ToolbarIntegration(
return@run
}

if (isPrivate) {
val deleteIcon = context.getDrawable(R.drawable.ic_delete)
deleteIcon?.setColorFilter(
ContextCompat.getColor(
context,
ThemeManager.resolveAttribute(R.attr.primaryText, context)
), PorterDuff.Mode.SRC_IN
)
deleteIcon?.let {
val deleteSessions = BrowserToolbar.Button(
deleteIcon,
context.getString(R.string.private_browsing_delete_session),
listener = {
Navigation.findNavController(toolbar)
.navigate(BrowserFragmentDirections.actionBrowserFragmentToHomeFragment(
closeAllPrivateTabs = true
))
}
)
toolbar.addNavigationAction(deleteSessions)
}
}

val tabsAction = TabCounterToolbarButton(
sessionManager,
{
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,16 @@ class HomeFragment : Fragment(), AccountObserver {
(activity as AppCompatActivity).supportActionBar?.hide()

requireComponents.backgroundServices.accountManager.register(this, owner = this)

val closeAllPrivateTabs = arguments
?.let(HomeFragmentArgs.Companion::fromBundle)
?.let { it.closeAllPrivateTabs } ?: false

arguments = null

if (closeAllPrivateTabs) {
handleTabAction(TabAction.CloseAll(true))
}
}

override fun onStart() {
Expand Down
7 changes: 0 additions & 7 deletions app/src/main/res/layout/private_browsing_description.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,6 @@
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:orientation="vertical">
<TextView
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
android:textColor="?primaryText"
android:text="@string/private_browsing_title"
android:layout_marginBottom="8dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<TextView
android:id="@+id/private_session_description"
android:layout_width="match_parent"
Expand Down
4 changes: 4 additions & 0 deletions app/src/main/res/navigation/nav_graph.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
android:id="@+id/homeFragment"
android:name="org.mozilla.fenix.home.HomeFragment"
tools:layout="@layout/fragment_home">
<argument
android:name="closeAllPrivateTabs"
app:argType="boolean"
android:defaultValue="false" />
<action
android:id="@+id/action_homeFragment_to_turnOnSyncFragment"
app:destination="@+id/turnOnSyncFragment" />
Expand Down

0 comments on commit b07cca0

Please sign in to comment.