From 5a89f47522a0c573ce4a08d7836c5a310758f09a Mon Sep 17 00:00:00 2001 From: DrDisagree Date: Thu, 21 Sep 2023 13:27:33 +0600 Subject: [PATCH] Fix indication text position while using depth wallpaper --- .../iconify/xposed/mods/DepthWallpaper.java | 29 ++++++++++++++++++- .../iconify/xposed/mods/LockscreenClock.java | 27 ++++++++++++++++- 2 files changed, 54 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/DepthWallpaper.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/DepthWallpaper.java index fa004e643..024badfb0 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/DepthWallpaper.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/DepthWallpaper.java @@ -11,10 +11,13 @@ import android.graphics.ImageDecoder; import android.graphics.drawable.Drawable; import android.os.Environment; +import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.FrameLayout; import android.widget.ImageView; +import android.widget.LinearLayout; +import android.widget.TextView; import com.drdisagree.iconify.xposed.ModPack; @@ -66,6 +69,25 @@ protected void afterHookedMethod(MethodHookParam param) { container.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ((ViewGroup.MarginLayoutParams) container.getLayoutParams()).bottomMargin = 0; + // Create a new layout for the indication text views + LinearLayout mIndicationView = new LinearLayout(mContext); + LinearLayout.LayoutParams mIndicationViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + int bottomMargin = mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_indication_margin_bottom", "dimen", mContext.getPackageName())); + mIndicationViewParams.setMargins(0, 0, 0, bottomMargin); + mIndicationViewParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; + mIndicationView.setOrientation(LinearLayout.VERTICAL); + mIndicationView.setLayoutParams(mIndicationViewParams); + + // Add the indication text views to the new layout + TextView mTopIndicationView = container.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text", "id", mContext.getPackageName())); + TextView mLockScreenIndicationView = container.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text_bottom", "id", mContext.getPackageName())); + + ((ViewGroup) mTopIndicationView.getParent()).removeView(mTopIndicationView); + ((ViewGroup) mLockScreenIndicationView.getParent()).removeView(mLockScreenIndicationView); + mIndicationView.addView(mTopIndicationView); + mIndicationView.addView(mLockScreenIndicationView); + container.addView(mIndicationView); + // Get the depth wallpaper layout String depth_wall_tag = "iconify_depth_wallpaper"; mDepthWallpaperLayout = container.findViewWithTag(depth_wall_tag); @@ -76,7 +98,12 @@ protected void afterHookedMethod(MethodHookParam param) { mDepthWallpaperLayout.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mDepthWallpaperLayout.setTag(depth_wall_tag); - container.addView(mDepthWallpaperLayout, 0); + FrameLayout mIndicationArea = new FrameLayout(mContext); + FrameLayout.LayoutParams mIndicationAreaParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + mIndicationArea.setLayoutParams(mIndicationAreaParams); + + mIndicationArea.addView(mDepthWallpaperLayout, 0); + container.addView(mIndicationArea, 0); } mDepthWallpaperBackground = new ImageView(mContext); diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/LockscreenClock.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/LockscreenClock.java index 9cc148dea..5d1ae2e3f 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/LockscreenClock.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/LockscreenClock.java @@ -31,6 +31,7 @@ import android.widget.GridLayout; import android.widget.LinearLayout; import android.widget.RelativeLayout; +import android.widget.TextView; import com.drdisagree.iconify.xposed.ModPack; import com.drdisagree.iconify.xposed.utils.LockscreenClockStyles; @@ -126,6 +127,25 @@ protected void afterHookedMethod(MethodHookParam param) { container.getLayoutParams().width = ViewGroup.LayoutParams.MATCH_PARENT; ((ViewGroup.MarginLayoutParams) container.getLayoutParams()).bottomMargin = 0; + // Create a new layout for the indication text views + LinearLayout mIndicationView = new LinearLayout(mContext); + LinearLayout.LayoutParams mIndicationViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); + int bottomMargin = mContext.getResources().getDimensionPixelSize(mContext.getResources().getIdentifier("keyguard_indication_margin_bottom", "dimen", mContext.getPackageName())); + mIndicationViewParams.setMargins(0, 0, 0, bottomMargin); + mIndicationViewParams.gravity = Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL; + mIndicationView.setOrientation(LinearLayout.VERTICAL); + mIndicationView.setLayoutParams(mIndicationViewParams); + + // Add the indication text views to the new layout + TextView mTopIndicationView = container.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text", "id", mContext.getPackageName())); + TextView mLockScreenIndicationView = container.findViewById(mContext.getResources().getIdentifier("keyguard_indication_text_bottom", "id", mContext.getPackageName())); + + container.removeView(mTopIndicationView); + container.removeView(mLockScreenIndicationView); + mIndicationView.addView(mTopIndicationView); + mIndicationView.addView(mLockScreenIndicationView); + container.addView(mIndicationView); + // Get the depth wallpaper layout String depth_wall_tag = "iconify_depth_wallpaper"; mClockViewContainer = container.findViewWithTag(depth_wall_tag); @@ -136,7 +156,12 @@ protected void afterHookedMethod(MethodHookParam param) { mClockViewContainer.setLayoutParams(new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); mClockViewContainer.setTag(depth_wall_tag); - container.addView(mClockViewContainer, 0); + FrameLayout mIndicationArea = new FrameLayout(mContext); + FrameLayout.LayoutParams mIndicationAreaParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); + mIndicationArea.setLayoutParams(mIndicationAreaParams); + + mIndicationArea.addView(mClockViewContainer, 0); + container.addView(mIndicationArea, 0); } registerClockUpdater();