Skip to content

Commit

Permalink
For mozilla-mobile#17770: Reorder new tab 3dot menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Kate Glazko authored and Kate Glazko committed Feb 20, 2021
1 parent 6270c8d commit 52c2b40
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 26 deletions.
79 changes: 54 additions & 25 deletions app/src/main/java/org/mozilla/fenix/home/HomeMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import mozilla.components.browser.menu.BrowserMenuHighlight
import mozilla.components.browser.menu.ext.getHighlight
import mozilla.components.browser.menu.item.BrowserMenuDivider
import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
import mozilla.components.browser.menu.item.BrowserMenuImageSwitch
import mozilla.components.browser.menu.item.BrowserMenuImageText
import mozilla.components.concept.sync.AccountObserver
import mozilla.components.concept.sync.AuthType
import mozilla.components.concept.sync.OAuthAccount
import mozilla.components.support.ktx.android.content.getColorFromAttr
import org.mozilla.fenix.FeatureFlags
import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarMenu
import org.mozilla.fenix.experiments.ExperimentBranch
import org.mozilla.fenix.experiments.Experiments
import org.mozilla.fenix.ext.components
Expand All @@ -38,6 +41,7 @@ class HomeMenu(
private val onHighlightPresent: (BrowserMenuHighlight) -> Unit = {}
) {
sealed class Item {
data class RequestDesktop(val isChecked: Boolean) : Item()
object WhatsNew : Item()
object Help : Item()
object AddonsManager : Item()
Expand Down Expand Up @@ -106,6 +110,8 @@ class HomeMenu(
else -> R.drawable.ic_bookmark_filled
}
}
context.getDrawable(bookmarksIcon)?.setVisible(false, true)

val bookmarksItem = BrowserMenuImageText(
context.getString(R.string.library_bookmarks),
bookmarksIcon,
Expand Down Expand Up @@ -137,7 +143,7 @@ class HomeMenu(
}

val addons = BrowserMenuImageText(
context.getString(R.string.browser_menu_add_ons),
context.getString(R.string.browser_menu_extensions),
R.drawable.ic_addons_extensions,
primaryTextColor
) {
Expand All @@ -152,14 +158,6 @@ class HomeMenu(
onItemTapped.invoke(Item.Settings)
}

val syncedTabsItem = BrowserMenuImageText(
context.getString(R.string.library_synced_tabs),
R.drawable.ic_synced_tabs,
primaryTextColor
) {
onItemTapped.invoke(Item.SyncedTabs)
}

val helpItem = BrowserMenuImageText(
context.getString(R.string.browser_menu_help),
R.drawable.ic_help,
Expand All @@ -186,24 +184,55 @@ class HomeMenu(

val settings = context.components.settings

val menuItems = listOfNotNull(
if (settings.shouldDeleteBrowsingDataOnQuit) quitItem else null,
settingsItem,
BrowserMenuDivider(),
if (settings.syncedTabsInTabsTray) null else syncedTabsItem,
bookmarksItem,
historyItem,
downloadsItem,
BrowserMenuDivider(),
addons,
BrowserMenuDivider(),
whatsNewItem,
helpItem,
accountAuthItem
).also { items ->
items.getHighlight()?.let { onHighlightPresent(it) }
val desktopSiteItem = BrowserMenuImageSwitch(
imageResource = R.drawable.ic_desktop,
label = context.getString(R.string.browser_menu_desktop_site),
initialState = {
false
}
) { checked ->
onItemTapped.invoke(Item.RequestDesktop(checked))
}

val menuItems =
if (!FeatureFlags.toolbarMenuFeature) {
listOfNotNull(
if (settings.shouldDeleteBrowsingDataOnQuit) quitItem else null,
bookmarksItem,
historyItem,
downloadsItem,
BrowserMenuDivider(),
addons,
BrowserMenuDivider(),
whatsNewItem,
helpItem,
accountAuthItem,
settingsItem,
BrowserMenuDivider()
).also { items ->
items.getHighlight()?.let { onHighlightPresent(it) }
}
}

else {
listOfNotNull(
BrowserMenuDivider(),
settingsItem,
helpItem,
whatsNewItem,
BrowserMenuDivider(),
desktopSiteItem,
BrowserMenuDivider(),
accountAuthItem,
addons,
downloadsItem,
historyItem,
bookmarksItem
).also { items ->
items.getHighlight()?.let { onHighlightPresent(it) }
}
}

if (shouldUseBottomToolbar) {
menuItems.reversed()
} else {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/drawable/ic_bookmark_filled.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
android:viewportHeight="24"
>
<path
android:fillColor="?primaryText"
android:pathData="M6.749,21.248C6.4234,21.2471 6.1142,21.1054 5.9008,20.8595C5.6875,20.6136 5.5909,20.2874 5.636,19.965L6.414,14.4L2.674,10.38C2.3928,10.0785 2.2991,9.6474 2.4296,9.2564C2.5601,8.8654 2.8941,8.5771 3.3,8.505L8.529,7.57L10.993,2.624C11.1833,2.242 11.5733,2.0006 12,2.0006C12.4267,2.0006 12.8167,2.242 13.007,2.624L15.471,7.57L20.7,8.5C21.1057,8.5724 21.4394,8.8608 21.5697,9.2518C21.7,9.6427 21.6062,10.0737 21.325,10.375L17.586,14.4L18.364,19.968C18.4229,20.3853 18.2434,20.8005 17.8991,21.0434C17.5547,21.2864 17.1034,21.3164 16.73,21.121L12,18.654L7.269,21.119C7.1087,21.2035 6.9302,21.2478 6.749,21.248Z"
Expand Down

0 comments on commit 52c2b40

Please sign in to comment.