|
@@ -18,6 +18,7 @@ package com.afollestad.materialdialogs.bottomsheets
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.app.Activity
|
|
|
import android.content.Context
|
|
|
+import android.graphics.Color
|
|
|
import android.graphics.drawable.GradientDrawable
|
|
|
import android.os.Build.VERSION.SDK_INT
|
|
|
import android.view.LayoutInflater
|
|
@@ -25,7 +26,7 @@ import android.view.View.GONE
|
|
|
import android.view.ViewGroup
|
|
|
import android.view.Window
|
|
|
import android.view.WindowManager.LayoutParams
|
|
|
-import android.view.WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS
|
|
|
+import androidx.annotation.ColorInt
|
|
|
import androidx.coordinatorlayout.widget.CoordinatorLayout
|
|
|
import com.afollestad.materialdialogs.DialogBehavior
|
|
|
import com.afollestad.materialdialogs.LayoutMode
|
|
@@ -102,17 +103,22 @@ class BottomSheet(
|
|
|
creatingActivity: Activity
|
|
|
) {
|
|
|
val activityWindow = creatingActivity.window!!
|
|
|
- if (SDK_INT >= 19) {
|
|
|
- dialogWindow.addFlags(FLAG_TRANSLUCENT_STATUS)
|
|
|
+ if (SDK_INT >= 21) {
|
|
|
+ dialogWindow.statusBarColor = activityWindow.statusBarColor.darkenColor()
|
|
|
}
|
|
|
if (SDK_INT >= 21) {
|
|
|
- dialogWindow.apply {
|
|
|
- statusBarColor = activityWindow.statusBarColor
|
|
|
- navigationBarColor = activityWindow.navigationBarColor
|
|
|
- }
|
|
|
+ dialogWindow.navigationBarColor = activityWindow.navigationBarColor
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @ColorInt fun Int.darkenColor(factor: Float = 0.5f): Int {
|
|
|
+ val color = this
|
|
|
+ return Color.HSVToColor(FloatArray(3).apply {
|
|
|
+ Color.colorToHSV(color, this)
|
|
|
+ this[2] *= factor
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
private fun setupBottomSheetBehavior() {
|
|
|
bottomSheetBehavior = BottomSheetBehavior.from(bottomSheetView)
|
|
|
.apply {
|