From 1dcf0f531a441fa759647f7e32c5a8fd4d8a02b2 Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Fri, 6 Sep 2024 00:11:57 +0600 Subject: [PATCH] Fix header image overlapping other custom elements Signed-off-by: DrDisagree --- .../iconify/xposed/modules/HeaderClockA14.kt | 27 ++++++++++++++++--- .../iconify/xposed/modules/HeaderImage.kt | 5 +++- .../iconify/xposed/modules/OpQsHeader.kt | 26 ++++++++++++++++-- 3 files changed, 52 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderClockA14.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderClockA14.kt index 8e977e63e..c11318b65 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderClockA14.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderClockA14.kt @@ -52,6 +52,7 @@ import com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_TOPMARGIN import com.drdisagree.iconify.common.Preferences.HIDE_STATUS_ICONS_SWITCH import com.drdisagree.iconify.common.Preferences.ICONIFY_HEADER_CLOCK_TAG import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG +import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_TAG import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_SWITCH import com.drdisagree.iconify.common.Preferences.QSPANEL_HIDE_CARRIER import com.drdisagree.iconify.common.Resources @@ -294,9 +295,18 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) { addView(mQsIconsContainer) } - (mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer) - mQuickStatusBarHeader!!.addView(mQsHeaderContainer, -1) + val headerImageAvailable = mQuickStatusBarHeader!!.findViewWithTag( + ICONIFY_QS_HEADER_CONTAINER_TAG + ) + mQuickStatusBarHeader!!.addView( + mQsHeaderContainer, + if (headerImageAvailable == null) { + -1 + } else { + mQuickStatusBarHeader!!.indexOfChild(headerImageAvailable) + 1 + } + ) handleOldHeaderView(param) @@ -323,8 +333,19 @@ class HeaderClockA14(context: Context?) : ModPack(context!!) { mQsHeaderContainerShade.visibility = View.VISIBLE } else { if (mQsHeaderContainer.parent != mQuickStatusBarHeader) { + val headerImageAvailable = + mQuickStatusBarHeader!!.findViewWithTag( + ICONIFY_QS_HEADER_CONTAINER_TAG + ) (mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer) - mQuickStatusBarHeader?.addView(mQsHeaderContainer, 0) + mQuickStatusBarHeader?.addView( + mQsHeaderContainer, + if (headerImageAvailable == null) { + 0 + } else { + mQuickStatusBarHeader!!.indexOfChild(headerImageAvailable) + 1 + } + ) } mQsHeaderContainerShade.visibility = View.GONE } diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderImage.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderImage.kt index 8a6631217..2fd46e636 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderImage.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/HeaderImage.kt @@ -28,6 +28,7 @@ import com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_LANDSCAPE_SWITCH import com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_OVERLAP import com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_SWITCH import com.drdisagree.iconify.common.Preferences.HEADER_IMAGE_ZOOMTOFIT +import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_TAG import com.drdisagree.iconify.xposed.ModPack import com.drdisagree.iconify.xposed.modules.utils.ViewHelper.toPx import com.drdisagree.iconify.xposed.utils.XPrefs.Xprefs @@ -126,7 +127,9 @@ class HeaderImage(context: Context?) : ModPack(context!!) { hookAllMethods(quickStatusBarHeader, "onFinishInflate", object : XC_MethodHook() { override fun afterHookedMethod(param: MethodHookParam) { val mQuickStatusBarHeader = param.thisObject as FrameLayout - mQsHeaderLayout = FadingEdgeLayout(mContext) + mQsHeaderLayout = FadingEdgeLayout(mContext).apply { + tag = ICONIFY_QS_HEADER_CONTAINER_TAG + } val layoutParams = LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, TypedValue.applyDimension( diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/OpQsHeader.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/OpQsHeader.kt index 933b96e86..9daf4bc0a 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/OpQsHeader.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/OpQsHeader.kt @@ -51,6 +51,7 @@ import com.drdisagree.iconify.BuildConfig import com.drdisagree.iconify.common.Const.FRAMEWORK_PACKAGE import com.drdisagree.iconify.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_SHADE_TAG +import com.drdisagree.iconify.common.Preferences.ICONIFY_QS_HEADER_CONTAINER_TAG import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_BLUR_LEVEL import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_EXPANSION_Y import com.drdisagree.iconify.common.Preferences.OP_QS_HEADER_SWITCH @@ -400,7 +401,17 @@ class OpQsHeader(context: Context?) : ModPack(context!!) { } (mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer) - mQuickStatusBarHeader!!.addView(mQsHeaderContainer, -1) + val headerImageAvailable = mQuickStatusBarHeader!!.findViewWithTag( + ICONIFY_QS_HEADER_CONTAINER_TAG + ) + mQuickStatusBarHeader!!.addView( + mQsHeaderContainer, + if (headerImageAvailable == null) { + -1 + } else { + mQuickStatusBarHeader!!.indexOfChild(headerImageAvailable) + 1 + } + ) val relativeLayout = RelativeLayout(mContext).apply { layoutParams = RelativeLayout.LayoutParams( @@ -479,8 +490,19 @@ class OpQsHeader(context: Context?) : ModPack(context!!) { mQsHeaderContainerShade.visibility = View.VISIBLE } else { if (mQsHeaderContainer.parent != mQuickStatusBarHeader) { + val headerImageAvailable = + mQuickStatusBarHeader!!.findViewWithTag( + ICONIFY_QS_HEADER_CONTAINER_TAG + ) (mQsHeaderContainer.parent as? ViewGroup)?.removeView(mQsHeaderContainer) - mQuickStatusBarHeader?.addView(mQsHeaderContainer, -1) + mQuickStatusBarHeader?.addView( + mQsHeaderContainer, + if (headerImageAvailable == null) { + 0 + } else { + mQuickStatusBarHeader!!.indexOfChild(headerImageAvailable) + 1 + } + ) } mQsHeaderContainerShade.visibility = View.GONE }