Skip to content

Commit

Permalink
add BottomSheeBrowserMenuFragment to replace BrowserMenuDialog
Browse files Browse the repository at this point in the history
avoid using BottomSheetDialog, create a DialogFragment for showing Home
Menu
  • Loading branch information
walkingice committed Mar 29, 2022
1 parent eeaa327 commit a539106
Show file tree
Hide file tree
Showing 5 changed files with 386 additions and 345 deletions.
14 changes: 8 additions & 6 deletions app/src/main/java/org/mozilla/focus/activity/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ import org.mozilla.rocket.landing.NavigationModel
import org.mozilla.rocket.landing.OrientationState
import org.mozilla.rocket.landing.PortraitComponent
import org.mozilla.rocket.landing.PortraitStateModel
import org.mozilla.rocket.menu.BottomSheetBrowserMenuFragment
import org.mozilla.rocket.menu.BottomSheetHomeMenuFragment
import org.mozilla.rocket.menu.BrowserMenuDialog
import org.mozilla.rocket.periodic.FirstLaunchWorker
import org.mozilla.rocket.periodic.PeriodicReceiver
import org.mozilla.rocket.privately.PrivateMode
Expand Down Expand Up @@ -133,7 +133,6 @@ class MainActivity :
private lateinit var downloadIndicatorViewModel: DownloadIndicatorViewModel
private var promotionModel: PromotionModel? = null

private lateinit var browserMenu: BrowserMenuDialog
private var myshotOnBoardingDialog: Dialog? = null

private lateinit var screenNavigator: ScreenNavigator
Expand Down Expand Up @@ -347,7 +346,9 @@ class MainActivity :
showHomeMenu.observe(this@MainActivity) {
BottomSheetHomeMenuFragment.show(supportFragmentManager)
}
showBrowserMenu.observe(this@MainActivity, Observer { browserMenu.show() })
showBrowserMenu.observe(this@MainActivity) {
BottomSheetBrowserMenuFragment.show(supportFragmentManager)
}
showNewTab.observe(
this@MainActivity,
Observer {
Expand Down Expand Up @@ -690,7 +691,7 @@ class MainActivity :

private fun dismissAllMenus() {
BottomSheetHomeMenuFragment.dismiss(supportFragmentManager)
browserMenu.dismiss()
BottomSheetBrowserMenuFragment.dismiss(supportFragmentManager)
visibleBrowserFragment?.run { dismissAllMenus() }
getListPanelFragment()?.dismissAllowingStateLoss()
myshotOnBoardingDialog?.run {
Expand Down Expand Up @@ -853,7 +854,7 @@ class MainActivity :
@VisibleForTesting
@UiThread
fun showMyShotOnBoarding() {
val view = browserMenu.findViewById<View>(R.id.menu_screenshots)
val view = BottomSheetBrowserMenuFragment.getScreenshotMenuButton(supportFragmentManager)
view?.post {
myshotOnBoardingDialog = DialogUtils.showMyShotOnBoarding(
this@MainActivity,
Expand All @@ -869,7 +870,6 @@ class MainActivity :
)
chromeViewModel.onMyShotOnBoardingDisplayed()
}
browserMenu.show()
}

private fun checkInAppUpdate() {
Expand Down Expand Up @@ -1011,13 +1011,15 @@ class MainActivity :
context: Context
) {
when (f.tag) {
BottomSheetBrowserMenuFragment.TAG,
BottomSheetHomeMenuFragment.TAG ->
portraitStateModel.request(PortraitComponent.BottomMenu)
}
}

override fun onFragmentDetached(fm: FragmentManager, f: Fragment) {
when (f.tag) {
BottomSheetBrowserMenuFragment.TAG,
BottomSheetHomeMenuFragment.TAG ->
portraitStateModel.cancelRequest(PortraitComponent.BottomMenu)
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/org/mozilla/rocket/di/AppComponent.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ import org.mozilla.rocket.home.HomeFragment
import org.mozilla.rocket.home.di.HomeModule
import org.mozilla.rocket.home.topsites.domain.GetTopSitesUseCase
import org.mozilla.rocket.home.topsites.ui.AddNewTopSitesFragment
import org.mozilla.rocket.menu.BottomSheetBrowserMenuFragment
import org.mozilla.rocket.menu.BottomSheetHomeMenuFragment
import org.mozilla.rocket.menu.BrowserMenuDialog
import org.mozilla.rocket.menu.PrivateBrowserMenuDialog
import org.mozilla.rocket.privately.PrivateModeActivity
import org.mozilla.rocket.privately.home.PrivateHomeFragment
Expand Down Expand Up @@ -92,7 +92,7 @@ interface AppComponent {
fun inject(privateHomeFragment: PrivateHomeFragment)
fun inject(urlInputFragment: UrlInputFragment)
fun inject(homeMenuFragment: BottomSheetHomeMenuFragment)
fun inject(browserMenuDialog: BrowserMenuDialog)
fun inject(browserMenuFragment: BottomSheetBrowserMenuFragment)
fun inject(privateBrowserMenuDialog: PrivateBrowserMenuDialog)
fun inject(browsingHistoryFragment: BrowsingHistoryFragment)
fun inject(privateModeActivity: PrivateModeActivity)
Expand Down
Loading

0 comments on commit a539106

Please sign in to comment.