|
|
@ -202,7 +202,7 @@ class HomeFragment : Fragment() {
|
|
|
|
registerCollectionStorageObserver = ::registerCollectionStorageObserver,
|
|
|
|
registerCollectionStorageObserver = ::registerCollectionStorageObserver,
|
|
|
|
scrollToTheTop = ::scrollToTheTop,
|
|
|
|
scrollToTheTop = ::scrollToTheTop,
|
|
|
|
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt,
|
|
|
|
showDeleteCollectionPrompt = ::showDeleteCollectionPrompt,
|
|
|
|
openSettingsScreen = :: openSettingsScreen
|
|
|
|
openSettingsScreen = ::openSettingsScreen
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
updateLayout(view)
|
|
|
|
updateLayout(view)
|
|
|
@ -277,7 +277,8 @@ class HomeFragment : Fragment() {
|
|
|
|
// TODO remove when viewLifecycleOwner is fixed
|
|
|
|
// TODO remove when viewLifecycleOwner is fixed
|
|
|
|
val context = context ?: return@launch
|
|
|
|
val context = context ?: return@launch
|
|
|
|
|
|
|
|
|
|
|
|
val iconSize = context.resources.getDimensionPixelSize(R.dimen.preference_icon_drawable_size)
|
|
|
|
val iconSize =
|
|
|
|
|
|
|
|
context.resources.getDimensionPixelSize(R.dimen.preference_icon_drawable_size)
|
|
|
|
|
|
|
|
|
|
|
|
val searchEngine = context.components.search.provider.getDefaultEngine(context)
|
|
|
|
val searchEngine = context.components.search.provider.getDefaultEngine(context)
|
|
|
|
val searchIcon = BitmapDrawable(context.resources, searchEngine.icon)
|
|
|
|
val searchIcon = BitmapDrawable(context.resources, searchEngine.icon)
|
|
|
@ -336,7 +337,8 @@ class HomeFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
|
|
if (onboarding.userHasBeenOnboarded()) {
|
|
|
|
if (onboarding.userHasBeenOnboarded()) {
|
|
|
|
homeFragmentStore.dispatch(
|
|
|
|
homeFragmentStore.dispatch(
|
|
|
|
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode)))
|
|
|
|
HomeFragmentAction.ModeChange(Mode.fromBrowsingMode(newMode))
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -355,12 +357,14 @@ class HomeFragment : Fragment() {
|
|
|
|
val context = requireContext()
|
|
|
|
val context = requireContext()
|
|
|
|
val components = context.components
|
|
|
|
val components = context.components
|
|
|
|
|
|
|
|
|
|
|
|
homeFragmentStore.dispatch(HomeFragmentAction.Change(
|
|
|
|
homeFragmentStore.dispatch(
|
|
|
|
collections = components.core.tabCollectionStorage.cachedTabCollections,
|
|
|
|
HomeFragmentAction.Change(
|
|
|
|
mode = currentMode.getCurrentMode(),
|
|
|
|
collections = components.core.tabCollectionStorage.cachedTabCollections,
|
|
|
|
tabs = getListOfSessions().toTabs(),
|
|
|
|
mode = currentMode.getCurrentMode(),
|
|
|
|
topSites = components.core.topSiteStorage.cachedTopSites
|
|
|
|
tabs = getListOfSessions().toTabs(),
|
|
|
|
))
|
|
|
|
topSites = components.core.topSiteStorage.cachedTopSites
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
requireComponents.backgroundServices.accountManager.register(currentMode, owner = this)
|
|
|
|
requireComponents.backgroundServices.accountManager.register(currentMode, owner = this)
|
|
|
|
requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
|
|
|
|
requireComponents.backgroundServices.accountManager.register(object : AccountObserver {
|
|
|
@ -377,7 +381,8 @@ class HomeFragment : Fragment() {
|
|
|
|
}, owner = this)
|
|
|
|
}, owner = this)
|
|
|
|
|
|
|
|
|
|
|
|
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
|
|
|
if (context.settings().showPrivateModeContextualFeatureRecommender &&
|
|
|
|
browsingModeManager.mode.isPrivate) {
|
|
|
|
browsingModeManager.mode.isPrivate
|
|
|
|
|
|
|
|
) {
|
|
|
|
recommendPrivateBrowsingShortcut()
|
|
|
|
recommendPrivateBrowsingShortcut()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -517,7 +522,8 @@ class HomeFragment : Fragment() {
|
|
|
|
// Otherwise, we will encounter an activity token error.
|
|
|
|
// Otherwise, we will encounter an activity token error.
|
|
|
|
privateBrowsingButton.post {
|
|
|
|
privateBrowsingButton.post {
|
|
|
|
privateBrowsingRecommend.showAsDropDown(
|
|
|
|
privateBrowsingRecommend.showAsDropDown(
|
|
|
|
privateBrowsingButton, 0, CFR_Y_OFFSET, Gravity.TOP or Gravity.END)
|
|
|
|
privateBrowsingButton, 0, CFR_Y_OFFSET, Gravity.TOP or Gravity.END
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -528,7 +534,9 @@ class HomeFragment : Fragment() {
|
|
|
|
homeFragmentStore.dispatch(
|
|
|
|
homeFragmentStore.dispatch(
|
|
|
|
HomeFragmentAction.ModeChange(
|
|
|
|
HomeFragmentAction.ModeChange(
|
|
|
|
mode = currentMode.getCurrentMode(),
|
|
|
|
mode = currentMode.getCurrentMode(),
|
|
|
|
tabs = getListOfSessions().toTabs()))
|
|
|
|
tabs = getListOfSessions().toTabs()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -633,10 +641,16 @@ class HomeFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
|
|
private fun removeAllTabsWithUndo(listOfSessionsToDelete: Sequence<Session>, private: Boolean) {
|
|
|
|
private fun removeAllTabsWithUndo(listOfSessionsToDelete: Sequence<Session>, private: Boolean) {
|
|
|
|
homeFragmentStore.dispatch(HomeFragmentAction.TabsChange(emptyList()))
|
|
|
|
homeFragmentStore.dispatch(HomeFragmentAction.TabsChange(emptyList()))
|
|
|
|
|
|
|
|
listOfSessionsToDelete.forEach {
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.addSession(
|
|
|
|
|
|
|
|
it.id
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
val deleteOperation: (suspend () -> Unit) = {
|
|
|
|
val deleteOperation: (suspend () -> Unit) = {
|
|
|
|
listOfSessionsToDelete.forEach {
|
|
|
|
listOfSessionsToDelete.forEach {
|
|
|
|
sessionManager.remove(it)
|
|
|
|
sessionManager.remove(it)
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.removeSession(it.id)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
deleteAllSessionsJob = deleteOperation
|
|
|
|
deleteAllSessionsJob = deleteOperation
|
|
|
@ -651,6 +665,11 @@ class HomeFragment : Fragment() {
|
|
|
|
view!!,
|
|
|
|
view!!,
|
|
|
|
snackbarMessage,
|
|
|
|
snackbarMessage,
|
|
|
|
getString(R.string.snackbar_deleted_undo), {
|
|
|
|
getString(R.string.snackbar_deleted_undo), {
|
|
|
|
|
|
|
|
listOfSessionsToDelete.forEach {
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.removeSession(
|
|
|
|
|
|
|
|
it.id
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
if (private) {
|
|
|
|
if (private) {
|
|
|
|
requireComponents.analytics.metrics.track(Event.PrivateBrowsingSnackbarUndoTapped)
|
|
|
|
requireComponents.analytics.metrics.track(Event.PrivateBrowsingSnackbarUndoTapped)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -664,11 +683,13 @@ class HomeFragment : Fragment() {
|
|
|
|
|
|
|
|
|
|
|
|
private fun removeTabWithUndo(sessionId: String, private: Boolean) {
|
|
|
|
private fun removeTabWithUndo(sessionId: String, private: Boolean) {
|
|
|
|
val sessionManager = requireComponents.core.sessionManager
|
|
|
|
val sessionManager = requireComponents.core.sessionManager
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.addSession(sessionId)
|
|
|
|
val deleteOperation: (suspend () -> Unit) = {
|
|
|
|
val deleteOperation: (suspend () -> Unit) = {
|
|
|
|
sessionManager.findSessionById(sessionId)
|
|
|
|
sessionManager.findSessionById(sessionId)
|
|
|
|
?.let { session ->
|
|
|
|
?.let { session ->
|
|
|
|
pendingSessionDeletion = null
|
|
|
|
pendingSessionDeletion = null
|
|
|
|
sessionManager.remove(session)
|
|
|
|
sessionManager.remove(session)
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.removeSession(sessionId)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -684,6 +705,7 @@ class HomeFragment : Fragment() {
|
|
|
|
view!!,
|
|
|
|
view!!,
|
|
|
|
snackbarMessage,
|
|
|
|
snackbarMessage,
|
|
|
|
getString(R.string.snackbar_deleted_undo), {
|
|
|
|
getString(R.string.snackbar_deleted_undo), {
|
|
|
|
|
|
|
|
requireComponents.core.pendingSessionDeletionManager.removeSession(sessionId)
|
|
|
|
pendingSessionDeletion = null
|
|
|
|
pendingSessionDeletion = null
|
|
|
|
emitSessionChanges()
|
|
|
|
emitSessionChanges()
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -777,8 +799,12 @@ class HomeFragment : Fragment() {
|
|
|
|
border?.visibility = View.GONE
|
|
|
|
border?.visibility = View.GONE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onAnimationStart(animation: Animator?) { /* noop */ }
|
|
|
|
override fun onAnimationStart(animation: Animator?) { /* noop */
|
|
|
|
override fun onAnimationRepeat(animation: Animator?) { /* noop */ }
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onAnimationRepeat(animation: Animator?) { /* noop */
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
override fun onAnimationEnd(animation: Animator?) {
|
|
|
|
override fun onAnimationEnd(animation: Animator?) {
|
|
|
|
border?.animate()?.alpha(0.0F)?.setStartDelay(ANIM_ON_SCREEN_DELAY)
|
|
|
|
border?.animate()?.alpha(0.0F)?.setStartDelay(ANIM_ON_SCREEN_DELAY)
|
|
|
|
?.setDuration(FADE_ANIM_DURATION)
|
|
|
|
?.setDuration(FADE_ANIM_DURATION)
|
|
|
|