Reverted to older method to set Light navigation bar and status bar
This commit is contained in:
parent
9e00965103
commit
8b79d84614
1 changed files with 29 additions and 12 deletions
|
@ -5,12 +5,13 @@ import android.app.ActivityManager
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.os.Build
|
import android.os.Build
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
import androidx.annotation.ColorInt
|
import androidx.annotation.ColorInt
|
||||||
import androidx.appcompat.widget.Toolbar
|
import androidx.appcompat.widget.Toolbar
|
||||||
import androidx.core.view.WindowInsetsControllerCompat
|
|
||||||
import code.name.monkey.appthemehelper.util.ColorUtil
|
import code.name.monkey.appthemehelper.util.ColorUtil
|
||||||
import code.name.monkey.appthemehelper.util.TintHelper
|
import code.name.monkey.appthemehelper.util.TintHelper
|
||||||
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
|
||||||
|
import code.name.monkey.appthemehelper.util.VersionUtils
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Karim Abou Zeid (kabouzeid)
|
* @author Karim Abou Zeid (kabouzeid)
|
||||||
|
@ -24,21 +25,33 @@ object ATH {
|
||||||
) > since
|
) > since
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Deprecation")
|
||||||
fun setLightStatusBar(activity: Activity, enabled: Boolean) {
|
fun setLightStatusBar(activity: Activity, enabled: Boolean) {
|
||||||
activity.window.apply {
|
if (VersionUtils.hasMarshmallow()) {
|
||||||
WindowInsetsControllerCompat(
|
val decorView = activity.window.decorView
|
||||||
this,
|
val systemUiVisibility = decorView.systemUiVisibility
|
||||||
decorView
|
if (enabled) {
|
||||||
).isAppearanceLightStatusBars = enabled
|
decorView.systemUiVisibility =
|
||||||
|
systemUiVisibility or View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
|
||||||
|
} else {
|
||||||
|
decorView.systemUiVisibility =
|
||||||
|
systemUiVisibility and View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR.inv()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Suppress("Deprecation")
|
||||||
fun setLightNavigationBar(activity: Activity, enabled: Boolean) {
|
fun setLightNavigationBar(activity: Activity, enabled: Boolean) {
|
||||||
activity.window.apply {
|
if (VersionUtils.hasOreo()) {
|
||||||
WindowInsetsControllerCompat(
|
val decorView = activity.window.decorView
|
||||||
this,
|
var systemUiVisibility = decorView.systemUiVisibility
|
||||||
decorView
|
systemUiVisibility = if (enabled) {
|
||||||
).isAppearanceLightNavigationBars = enabled
|
systemUiVisibility or SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR
|
||||||
|
} else {
|
||||||
|
systemUiVisibility and SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR.inv()
|
||||||
|
}
|
||||||
|
decorView.systemUiVisibility = systemUiVisibility
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +80,11 @@ object ATH {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
toolbar.setBackgroundColor(color)
|
toolbar.setBackgroundColor(color)
|
||||||
ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(activity, toolbar, color)
|
ToolbarContentTintHelper.setToolbarContentColorBasedOnToolbarColor(
|
||||||
|
activity,
|
||||||
|
toolbar,
|
||||||
|
color
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun setTaskDescriptionColorAuto(activity: Activity) {
|
fun setTaskDescriptionColorAuto(activity: Activity) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue