For #1487 Add "my library" menu category and items to home 3-dot menu
parent
05e871dd0c
commit
41c9b9e958
|
@ -43,6 +43,7 @@ import kotlinx.coroutines.Dispatchers.Main
|
|||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import mozilla.appservices.places.BookmarkRoot
|
||||
import mozilla.components.browser.menu.BrowserMenu
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
|
@ -664,12 +665,20 @@ class HomeFragment : Fragment() {
|
|||
HomeFragmentDirections.actionHomeFragmentToSettingsFragment()
|
||||
)
|
||||
}
|
||||
HomeMenu.Item.Library -> {
|
||||
HomeMenu.Item.Bookmarks -> {
|
||||
invokePendingDeleteJobs()
|
||||
hideOnboardingIfNeeded()
|
||||
nav(
|
||||
R.id.homeFragment,
|
||||
HomeFragmentDirections.actionHomeFragmentToLibraryFragment()
|
||||
HomeFragmentDirections.actionHomeFragmentToBookmarksFragment(BookmarkRoot.Mobile.id)
|
||||
)
|
||||
}
|
||||
HomeMenu.Item.History -> {
|
||||
invokePendingDeleteJobs()
|
||||
hideOnboardingIfNeeded()
|
||||
nav(
|
||||
R.id.homeFragment,
|
||||
HomeFragmentDirections.actionHomeFragmentToHistoryFragment()
|
||||
)
|
||||
}
|
||||
HomeMenu.Item.Help -> {
|
||||
|
|
|
@ -6,6 +6,7 @@ package org.mozilla.fenix.home
|
|||
|
||||
import android.content.Context
|
||||
import mozilla.components.browser.menu.BrowserMenuBuilder
|
||||
import mozilla.components.browser.menu.item.BrowserMenuCategory
|
||||
import mozilla.components.browser.menu.item.BrowserMenuDivider
|
||||
import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
|
||||
import mozilla.components.browser.menu.item.BrowserMenuImageText
|
||||
|
@ -23,6 +24,8 @@ class HomeMenu(
|
|||
object Help : Item()
|
||||
object Settings : Item()
|
||||
object Library : Item()
|
||||
object History : Item()
|
||||
object Bookmarks : Item()
|
||||
object Quit : Item()
|
||||
}
|
||||
|
||||
|
@ -30,6 +33,29 @@ class HomeMenu(
|
|||
|
||||
private val menuItems by lazy {
|
||||
val items = mutableListOf(
|
||||
BrowserMenuCategory(
|
||||
context.getString(R.string.browser_menu_your_library),
|
||||
textColorResource = ThemeManager.resolveAttribute(R.attr.menuCategoryText, context)
|
||||
),
|
||||
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.library_bookmarks),
|
||||
R.drawable.ic_bookmark_outline,
|
||||
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
) {
|
||||
onItemTapped.invoke(Item.Bookmarks)
|
||||
},
|
||||
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.library_history),
|
||||
R.drawable.ic_history,
|
||||
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
) {
|
||||
onItemTapped.invoke(Item.History)
|
||||
},
|
||||
|
||||
BrowserMenuDivider(),
|
||||
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.browser_menu_settings),
|
||||
R.drawable.ic_settings,
|
||||
|
@ -38,23 +64,6 @@ class HomeMenu(
|
|||
onItemTapped.invoke(Item.Settings)
|
||||
},
|
||||
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.browser_menu_your_library),
|
||||
R.drawable.ic_library,
|
||||
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
) {
|
||||
onItemTapped.invoke(Item.Library)
|
||||
},
|
||||
|
||||
BrowserMenuDivider(),
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.browser_menu_help),
|
||||
R.drawable.ic_help,
|
||||
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
) {
|
||||
onItemTapped.invoke(Item.Help)
|
||||
},
|
||||
|
||||
BrowserMenuHighlightableItem(
|
||||
context.getString(R.string.browser_menu_whats_new),
|
||||
R.drawable.ic_whats_new,
|
||||
|
@ -69,8 +78,17 @@ class HomeMenu(
|
|||
isHighlighted = { WhatsNew.shouldHighlightWhatsNew(context) }
|
||||
) {
|
||||
onItemTapped.invoke(Item.WhatsNew)
|
||||
},
|
||||
|
||||
BrowserMenuImageText(
|
||||
context.getString(R.string.browser_menu_help),
|
||||
R.drawable.ic_help,
|
||||
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||
) {
|
||||
onItemTapped.invoke(Item.Help)
|
||||
}
|
||||
)
|
||||
|
||||
)
|
||||
|
||||
if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) {
|
||||
items.add(
|
||||
|
|
|
@ -73,6 +73,12 @@
|
|||
<action
|
||||
android:id="@+id/action_homeFragment_to_libraryFragment"
|
||||
app:destination="@id/libraryFragment" />
|
||||
<action
|
||||
android:id="@+id/action_homeFragment_to_bookmarksFragment"
|
||||
app:destination="@id/bookmarkFragment" />
|
||||
<action
|
||||
android:id="@+id/action_homeFragment_to_historyFragment"
|
||||
app:destination="@id/historyFragment" />
|
||||
<action
|
||||
android:id="@+id/action_homeFragment_to_settingsFragment"
|
||||
app:destination="@id/settingsFragment" />
|
||||
|
|
|
@ -30,6 +30,8 @@
|
|||
<color name="toolbar_end_gradient_normal_theme">@color/toolbar_end_gradient_dark_theme</color>
|
||||
<color name="toolbar_divider_color_normal_theme">@color/toolbar_divider_color_dark_theme</color>
|
||||
<color name="fill_link_from_clipboard_normal_theme">@color/accent_on_dark_background_normal_theme</color>
|
||||
<color name="menu_category_normal_theme">@color/primary_text_normal_theme</color>
|
||||
|
||||
|
||||
<!-- Collection icons-->
|
||||
<color name="collection_icon_color_violet">@color/collection_icon_color_violet_dark_theme</color>
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
<attr name="scrimStart" format="reference"/>
|
||||
<attr name="scrimEnd" format="reference"/>
|
||||
<attr name="toolbarDivider" format="reference"/>
|
||||
<attr name="menuCategoryText" format="reference"/>
|
||||
|
||||
|
||||
<!-- Misc -->
|
||||
<attr name="homeBackground" format="reference"/>
|
||||
|
|
|
@ -86,6 +86,8 @@
|
|||
<color name="toolbar_end_gradient_private_theme">#383372</color>
|
||||
<color name="toolbar_divider_color_private_theme">#403760</color>
|
||||
<color name="fill_link_from_clipboard_private_theme">@color/accent_on_dark_background_private_theme</color>
|
||||
<color name="menu_category_private_theme">@color/primary_text_private_theme</color>
|
||||
|
||||
|
||||
<!-- Normal theme colors for light mode -->
|
||||
<color name="primary_text_normal_theme">@color/primary_text_light_theme</color>
|
||||
|
@ -112,6 +114,8 @@
|
|||
<color name="toolbar_end_gradient_normal_theme">@color/toolbar_end_gradient_light_theme</color>
|
||||
<color name="toolbar_divider_color_normal_theme">@color/toolbar_divider_color_light_theme</color>
|
||||
<color name="fill_link_from_clipboard_normal_theme">@color/fill_link_from_clipboard_light_theme</color>
|
||||
<color name="menu_category_normal_theme">@color/accent_light_theme</color>
|
||||
|
||||
|
||||
<!-- Bookmark buttons -->
|
||||
<color name="bookmark_favicon_background">#DFDFE3</color>
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<item name="toolbarEndGradient">@color/toolbar_end_gradient_normal_theme</item>
|
||||
<item name="toolbarDivider">@color/toolbar_divider_color_normal_theme</item>
|
||||
<item name="fillLinkFromClipboard">@color/fill_link_from_clipboard_normal_theme</item>
|
||||
<item name="menuCategoryText">@color/menu_category_normal_theme</item>
|
||||
|
||||
<!-- Drawables -->
|
||||
<item name="fenixLogo">@drawable/ic_logo_wordmark_normal</item>
|
||||
|
@ -134,6 +135,7 @@
|
|||
<item name="toolbarEndGradient">@color/toolbar_end_gradient_private_theme</item>
|
||||
<item name="toolbarDivider">@color/toolbar_divider_color_private_theme</item>
|
||||
<item name="fillLinkFromClipboard">@color/fill_link_from_clipboard_private_theme</item>
|
||||
<item name="menuCategoryText">@color/menu_category_private_theme</item>
|
||||
|
||||
<!-- Drawables -->
|
||||
<item name="fenixLogo">@drawable/ic_logo_wordmark_private</item>
|
||||
|
|
Loading…
Reference in New Issue