[feedback]适配沉浸式模式

This commit is contained in:
renwj
2022-03-30 11:49:38 +08:00
parent 5646f5425e
commit c35e240ad8
3 changed files with 15 additions and 3 deletions

View File

@@ -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
}

View File

@@ -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 {

View File

@@ -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;
}
}