Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
The Tor Project
Applications
android-components
Commits
6d8e7ad4
Commit
6d8e7ad4
authored
Jul 07, 2021
by
mcarare
Committed by
mergify[bot]
Jul 09, 2021
Browse files
For #9554: Use WindowInsetsControllerCompat to avoid null controllers.
parent
e3ca7638
Changes
1
Hide whitespace changes
Inline
Side-by-side
components/support/ktx/src/main/java/mozilla/components/support/ktx/android/view/Window.kt
View file @
6d8e7ad4
...
...
@@ -8,7 +8,6 @@ import android.os.Build
import
android.os.Build.VERSION.SDK_INT
import
android.view.Window
import
androidx.annotation.ColorInt
import
androidx.core.view.ViewCompat
import
androidx.core.view.WindowInsetsControllerCompat
import
mozilla.components.support.utils.ColorUtils.isDark
...
...
@@ -17,7 +16,7 @@ import mozilla.components.support.utils.ColorUtils.isDark
* If the color is light enough, a light status bar with dark icons will be used.
*/
fun
Window
.
setStatusBarTheme
(
@ColorInt
color
:
Int
)
{
getWindowInsetsController
()
?
.
isAppearanceLightStatusBars
=
getWindowInsetsController
().
isAppearanceLightStatusBars
=
isDark
(
color
)
statusBarColor
=
color
}
...
...
@@ -27,7 +26,7 @@ fun Window.setStatusBarTheme(@ColorInt color: Int) {
* If the color is light enough, a light navigation bar with dark icons will be used.
*/
fun
Window
.
setNavigationBarTheme
(
@ColorInt
color
:
Int
)
{
getWindowInsetsController
()
?
.
isAppearanceLightNavigationBars
=
getWindowInsetsController
().
isAppearanceLightNavigationBars
=
isDark
(
color
)
if
(
SDK_INT
>=
Build
.
VERSION_CODES
.
P
)
{
...
...
@@ -39,6 +38,6 @@ fun Window.setNavigationBarTheme(@ColorInt color: Int) {
/**
* Retrieves a {@link WindowInsetsControllerCompat} for the top-level window decor view.
*/
fun
Window
.
getWindowInsetsController
():
WindowInsetsControllerCompat
?
{
return
ViewCompat
.
get
WindowInsetsController
(
this
.
decorView
)
fun
Window
.
getWindowInsetsController
():
WindowInsetsControllerCompat
{
return
WindowInsetsController
Compat
(
this
,
this
.
decorView
)
}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment