Skip to content

Commit

Permalink
feat:增加安全区标记
Browse files Browse the repository at this point in the history
  • Loading branch information
Petterpx committed Nov 25, 2024
1 parent 7845ef6 commit 8280145
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,12 @@ class FxAppHelper(
@JvmSynthetic
internal var editTextIds: List<Int>?,
@JvmSynthetic
internal var isEnableSafeArea: Boolean,
@JvmSynthetic
internal var isEnableKeyBoardAdapt: Boolean = false,
/** 显示悬浮窗的Activity生命周期回调 */
@JvmSynthetic
internal val fxLifecycleExpand: IFxProxyTagActivityLifecycle?,

@JvmSynthetic
internal val fxAskPermissionInterceptor: IFxPermissionInterceptor?,
) : FxBasisHelper() {
Expand Down Expand Up @@ -78,6 +79,7 @@ class FxAppHelper(
private var editTextIds: List<Int>? = null
private var isEnableKeyBoardAdapt: Boolean = false
private var scopeEnum: FxScopeType = FxScopeType.APP
private var isEnableSafeArea: Boolean = true
private var fxLifecycleExpand: IFxProxyTagActivityLifecycle? = null
private var askPermissionInterceptor: IFxPermissionInterceptor? = null
private var whiteInsertList: MutableList<String> = mutableListOf()
Expand Down Expand Up @@ -134,6 +136,12 @@ class FxAppHelper(
return this
}

/** 是否启用安全区,即禁止浮窗在状态栏与导航栏展示,仅限App浮窗有效 */
fun setEnableSafeArea(isEnable: Boolean): Builder {
isEnableSafeArea = isEnable
return this
}

/**
* 启用键盘适配,启用System浮窗将支持键盘弹出与关闭
* @param isEnable 是否启用
Expand Down Expand Up @@ -220,6 +228,7 @@ class FxAppHelper(
isEnableAllInstall,
scopeEnum,
editTextIds,
isEnableSafeArea,
isEnableKeyBoardAdapt,
fxLifecycleExpand,
askPermissionInterceptor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,9 @@ class FxAppPlatformProvider(
return false
}
if (_internalView == null) {
initWindowsInsetsListener()
helper.updateNavigationBar(act)
helper.updateStatsBar(act)
_internalView = FxDefaultContainerView(helper, helper.context)
_internalView?.initView()
checkOrInitSafeArea(act)
attach(act)
}
return true
Expand Down Expand Up @@ -142,18 +140,21 @@ class FxAppPlatformProvider(
_containerGroup = null
}

private fun initWindowsInsetsListener() {
val fxView = _internalView ?: return
ViewCompat.setOnApplyWindowInsetsListener(fxView, windowsInsetsListener)
fxView.requestApplyInsets()
}

private fun checkRegisterAppLifecycle() {
if (!helper.enableFx || _lifecycleImp != null) return
_lifecycleImp = FxAppLifecycleImp(helper, control)
helper.context.registerActivityLifecycleCallbacks(_lifecycleImp)
}

private fun checkOrInitSafeArea(act: Activity) {
if (!helper.isEnableSafeArea) return
helper.updateStatsBar(act)
helper.updateNavigationBar(act)
val fxView = _internalView ?: return
ViewCompat.setOnApplyWindowInsetsListener(fxView, windowsInsetsListener)
fxView.requestApplyInsets()
}

private fun clearWindowsInsetsListener() {
val managerView = _internalView ?: return
ViewCompat.setOnApplyWindowInsetsListener(managerView, null)
Expand Down

0 comments on commit 8280145

Please sign in to comment.