|
@@ -6,7 +6,13 @@ import android.graphics.Color
|
|
|
import android.os.Build
|
|
import android.os.Build
|
|
|
import android.os.Bundle
|
|
import android.os.Bundle
|
|
|
import android.util.DisplayMetrics
|
|
import android.util.DisplayMetrics
|
|
|
-import android.view.*
|
|
|
|
|
|
|
+import android.view.Gravity
|
|
|
|
|
+import android.view.View
|
|
|
|
|
+import android.view.ViewGroup
|
|
|
|
|
+import android.view.WindowInsets
|
|
|
|
|
+import android.view.WindowInsetsController
|
|
|
|
|
+import android.view.WindowManager
|
|
|
|
|
+import android.view.WindowMetrics
|
|
|
import android.widget.FrameLayout
|
|
import android.widget.FrameLayout
|
|
|
import androidx.annotation.ColorInt
|
|
import androidx.annotation.ColorInt
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
@@ -54,14 +60,13 @@ val WindowManager.windowSize: DisplayMetrics
|
|
|
return displayMetrics
|
|
return displayMetrics
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+@Suppress("DEPRECATION")
|
|
|
fun Activity.fullScreen() {
|
|
fun Activity.fullScreen() {
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
|
|
|
window.setDecorFitsSystemWindows(true)
|
|
window.setDecorFitsSystemWindows(true)
|
|
|
}
|
|
}
|
|
|
- @Suppress("DEPRECATION")
|
|
|
|
|
window.decorView.systemUiVisibility =
|
|
window.decorView.systemUiVisibility =
|
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN or View.SYSTEM_UI_FLAG_LAYOUT_STABLE
|
|
|
- @Suppress("DEPRECATION")
|
|
|
|
|
window.clearFlags(
|
|
window.clearFlags(
|
|
|
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
|
|
WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
|
|
|
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
|
or WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION
|
|
@@ -72,6 +77,7 @@ fun Activity.fullScreen() {
|
|
|
/**
|
|
/**
|
|
|
* 设置状态栏颜色
|
|
* 设置状态栏颜色
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Suppress("DEPRECATION")
|
|
|
fun Activity.setStatusBarColorAuto(
|
|
fun Activity.setStatusBarColorAuto(
|
|
|
@ColorInt color: Int,
|
|
@ColorInt color: Int,
|
|
|
isTransparent: Boolean,
|
|
isTransparent: Boolean,
|
|
@@ -124,6 +130,7 @@ fun Activity.setLightStatusBar(isLightBar: Boolean) {
|
|
|
/**
|
|
/**
|
|
|
* 设置导航栏颜色
|
|
* 设置导航栏颜色
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Suppress("DEPRECATION")
|
|
|
fun Activity.setNavigationBarColorAuto(@ColorInt color: Int) {
|
|
fun Activity.setNavigationBarColorAuto(@ColorInt color: Int) {
|
|
|
val isLightBor = ColorUtils.isColorLight(color)
|
|
val isLightBor = ColorUtils.isColorLight(color)
|
|
|
window.navigationBarColor = color
|
|
window.navigationBarColor = color
|