[feedback]适配沉浸式模式
This commit is contained in:
@@ -25,6 +25,7 @@ import com.mogo.eagle.core.utilcode.kotlin.lifeCycleScope
|
||||
import com.mogo.eagle.core.utilcode.kotlin.shape
|
||||
import com.mogo.eagle.core.utilcode.reminder.Reminder
|
||||
import com.mogo.eagle.core.utilcode.reminder.api.impl.PopupWindowReminder
|
||||
import com.mogo.eagle.core.utilcode.util.BarUtils
|
||||
import com.mogo.eagle.core.utilcode.util.WindowUtils
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -66,8 +67,9 @@ internal fun Context.toast(text: CharSequence, duration: Long = 2, unit: TimeUni
|
||||
}
|
||||
|
||||
@SuppressLint("ClickableViewAccessibility")
|
||||
internal fun Context.pop(content: View, width: Int, height: Int, key: String, fitSystemWindow: Boolean = true, onOuterViewClicked:((focus: View) -> Unit)? = null): () -> Unit {
|
||||
internal fun Context.pop(content: View, width: Int, height: Int, key: String, onOuterViewClicked:((focus: View) -> Unit)? = null): () -> Unit {
|
||||
val activity = (this as? FragmentActivity) ?: throw IllegalStateException("please use Activity to trigger pop show.")
|
||||
val isImmersiveMode = BarUtils.isImmersiveMode(activity)
|
||||
var tempReminder: PopupWindowReminder? = null
|
||||
activity.lifecycleScope.launchWhenResumed {
|
||||
val pop = PopupWindow(width, height).also {
|
||||
@@ -128,7 +130,7 @@ internal fun Context.pop(content: View, width: Int, height: Int, key: String, fi
|
||||
}
|
||||
|
||||
override fun show() {
|
||||
pop.showAtLocation(activity.window.decorView, Gravity.START, 0, if (fitSystemWindow) WindowUtils.getStatusBarHeight(activity) else 0)
|
||||
pop.showAtLocation(activity.window.decorView, Gravity.START, 0, if (isImmersiveMode) 0 else BarUtils.getStatusBarHeight())
|
||||
}
|
||||
override fun isOverride(): Boolean = false
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ internal class FeedBackView : ConstraintLayout {
|
||||
transitionTo(0)
|
||||
} else {
|
||||
editOutRect.run {
|
||||
transitionTo(-( it - top + height() + 300.PX))
|
||||
transitionTo(-( it - top + height() + 228.PX))
|
||||
}
|
||||
}
|
||||
}.also {
|
||||
|
||||
@@ -733,4 +733,14 @@ public final class BarUtils {
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 当前Activity是否是沉浸式模式
|
||||
*/
|
||||
public static boolean isImmersiveMode(Activity activity) {
|
||||
Window window = activity.getWindow();
|
||||
View decor = window.getDecorView();
|
||||
int systemUiVisibility = decor.getSystemUiVisibility();
|
||||
return (systemUiVisibility & View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN) != 0;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user