1
0
Fork 0

For #4107 Make home screen fullscreen.

Add/Remove fullscreen flags in home fragment's onResume / onPause
Change homeLayout padding to include system bars height (status&navigation).
Change homeMenu orientation to UP to properly display menu.
Change home bottomBar background to transparent.
master
mcarare 2019-12-03 19:03:39 +02:00 committed by Emily Kager
parent 17731620e6
commit b6ba1a1611
2 changed files with 30 additions and 2 deletions

View File

@ -13,6 +13,8 @@ import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.Window
import android.view.WindowManager
import android.widget.Button
import android.widget.LinearLayout
import android.widget.PopupWindow
@ -210,9 +212,28 @@ class HomeFragment : Fragment() {
activity.themeManager.applyStatusBarTheme(activity)
setFragmentFullScreen(this.activity?.window, view.homeLayout)
return view
}
private fun setFragmentFullScreen(window: Window?, homeScreen: View) {
window?.decorView?.setOnApplyWindowInsetsListener { _, insets ->
homeScreen.setPadding(
homeScreen.paddingLeft,
homeScreen.paddingTop + insets.stableInsetTop,
homeScreen.paddingRight,
homeScreen.paddingBottom + insets.stableInsetBottom
)
window.decorView.setOnApplyWindowInsetsListener(null)
insets.consumeSystemWindowInsets()
}
}
@ExperimentalCoroutinesApi
@SuppressWarnings("LongMethod")
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
@ -249,7 +270,7 @@ class HomeFragment : Fragment() {
if (menu == null) {
menu = homeMenu?.menuBuilder?.build(requireContext())?.show(
anchor = it,
orientation = BrowserMenu.Orientation.DOWN,
orientation = BrowserMenu.Orientation.UP,
onDismiss = { menu = null }
)
} else {
@ -438,6 +459,8 @@ class HomeFragment : Fragment() {
override fun onResume() {
super.onResume()
this.activity?.window?.setFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS,
WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
hideToolbar()
}
@ -773,6 +796,11 @@ class HomeFragment : Fragment() {
}
}
override fun onPause() {
this.activity?.window?.clearFlags(WindowManager.LayoutParams.FLAG_LAYOUT_NO_LIMITS)
super.onPause()
}
companion object {
private const val NON_TAB_ITEM_NUM = 3
private const val ANIM_SCROLL_DELAY = 100L

View File

@ -140,7 +140,7 @@
<!-- Drawables -->
<item name="fenixLogo">@drawable/ic_logo_wordmark_private</item>
<item name="homeBackground">@drawable/private_home_background_gradient</item>
<item name="bottomBarBackground">@drawable/private_home_bottom_bar_background_gradient</item>
<item name="bottomBarBackground">@android:color/transparent</item>
<item name="privateBrowsingButtonBackground">@color/primary_text_private_theme</item>
<item name="privateBrowsingButtonAccent">@color/above_private_theme</item>
<item name="shieldLottieFile">@raw/shield_json_dark</item>