For #5442 - Show Delete Browsing Data on Quit option in home menu
parent
841b06b02f
commit
40e6284aef
|
@ -93,6 +93,7 @@ import org.mozilla.fenix.mvi.getAutoDisposeObservable
|
||||||
import org.mozilla.fenix.mvi.getManagedEmitter
|
import org.mozilla.fenix.mvi.getManagedEmitter
|
||||||
import org.mozilla.fenix.onboarding.FenixOnboarding
|
import org.mozilla.fenix.onboarding.FenixOnboarding
|
||||||
import org.mozilla.fenix.settings.SupportUtils
|
import org.mozilla.fenix.settings.SupportUtils
|
||||||
|
import org.mozilla.fenix.settings.deletebrowsingdata.deleteAndQuit
|
||||||
import org.mozilla.fenix.share.ShareTab
|
import org.mozilla.fenix.share.ShareTab
|
||||||
import org.mozilla.fenix.utils.FragmentPreDrawManager
|
import org.mozilla.fenix.utils.FragmentPreDrawManager
|
||||||
import org.mozilla.fenix.utils.allowUndo
|
import org.mozilla.fenix.utils.allowUndo
|
||||||
|
@ -677,6 +678,12 @@ class HomeFragment : Fragment() {
|
||||||
from = BrowserDirection.FromHome
|
from = BrowserDirection.FromHome
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
HomeMenu.Item.Quit -> activity?.let { activity ->
|
||||||
|
deleteAndQuit(
|
||||||
|
activity,
|
||||||
|
lifecycleScope
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import mozilla.components.browser.menu.item.BrowserMenuHighlightableItem
|
||||||
import mozilla.components.browser.menu.item.BrowserMenuImageText
|
import mozilla.components.browser.menu.item.BrowserMenuImageText
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.theme.ThemeManager
|
import org.mozilla.fenix.theme.ThemeManager
|
||||||
|
import org.mozilla.fenix.utils.Settings
|
||||||
import org.mozilla.fenix.whatsnew.WhatsNew
|
import org.mozilla.fenix.whatsnew.WhatsNew
|
||||||
|
|
||||||
class HomeMenu(
|
class HomeMenu(
|
||||||
|
@ -22,12 +23,13 @@ class HomeMenu(
|
||||||
object Help : Item()
|
object Help : Item()
|
||||||
object Settings : Item()
|
object Settings : Item()
|
||||||
object Library : Item()
|
object Library : Item()
|
||||||
|
object Quit : Item()
|
||||||
}
|
}
|
||||||
|
|
||||||
val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
|
val menuBuilder by lazy { BrowserMenuBuilder(menuItems) }
|
||||||
|
|
||||||
private val menuItems by lazy {
|
private val menuItems by lazy {
|
||||||
listOf(
|
val items = mutableListOf(
|
||||||
BrowserMenuImageText(
|
BrowserMenuImageText(
|
||||||
context.getString(R.string.browser_menu_settings),
|
context.getString(R.string.browser_menu_settings),
|
||||||
R.drawable.ic_settings,
|
R.drawable.ic_settings,
|
||||||
|
@ -58,7 +60,10 @@ class HomeMenu(
|
||||||
R.drawable.ic_whats_new,
|
R.drawable.ic_whats_new,
|
||||||
highlight = BrowserMenuHighlightableItem.Highlight(
|
highlight = BrowserMenuHighlightableItem.Highlight(
|
||||||
startImageResource = R.drawable.ic_whats_new_notification,
|
startImageResource = R.drawable.ic_whats_new_notification,
|
||||||
backgroundResource = ThemeManager.resolveAttribute(R.attr.selectableItemBackground, context),
|
backgroundResource = ThemeManager.resolveAttribute(
|
||||||
|
R.attr.selectableItemBackground,
|
||||||
|
context
|
||||||
|
),
|
||||||
colorResource = R.color.whats_new_notification_color
|
colorResource = R.color.whats_new_notification_color
|
||||||
),
|
),
|
||||||
isHighlighted = { WhatsNew.shouldHighlightWhatsNew(context) }
|
isHighlighted = { WhatsNew.shouldHighlightWhatsNew(context) }
|
||||||
|
@ -66,5 +71,19 @@ class HomeMenu(
|
||||||
onItemTapped.invoke(Item.WhatsNew)
|
onItemTapped.invoke(Item.WhatsNew)
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (Settings.getInstance(context).shouldDeleteBrowsingDataOnQuit) {
|
||||||
|
items.add(
|
||||||
|
BrowserMenuImageText(
|
||||||
|
context.getString(R.string.delete_browsing_data_on_quit_action),
|
||||||
|
R.drawable.ic_exit,
|
||||||
|
ThemeManager.resolveAttribute(R.attr.primaryText, context)
|
||||||
|
) {
|
||||||
|
onItemTapped.invoke(Item.Quit)
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
items
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue