From a06cddd52cb1a9096a0f3ca27450faaf8f1e4a71 Mon Sep 17 00:00:00 2001 From: Siavash Date: Sat, 23 Dec 2023 15:54:04 +0330 Subject: [PATCH] CHANGELOG: Fixed QS footer actions layout margins --- .github/edit2MakeNewCanary | 2 +- .../modpacks/systemui/QSFooterManager.java | 23 +++++++++++++------ 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/edit2MakeNewCanary b/.github/edit2MakeNewCanary index 04ad0604c..65aeddb0b 100644 --- a/.github/edit2MakeNewCanary +++ b/.github/edit2MakeNewCanary @@ -1 +1 @@ -Editing this file will trigger the build script for a new canary.. \ No newline at end of file +Editing this file will trigger the build script for a new canary. \ No newline at end of file diff --git a/app/src/main/java/sh/siava/pixelxpert/modpacks/systemui/QSFooterManager.java b/app/src/main/java/sh/siava/pixelxpert/modpacks/systemui/QSFooterManager.java index b84db02c0..052ad9b74 100644 --- a/app/src/main/java/sh/siava/pixelxpert/modpacks/systemui/QSFooterManager.java +++ b/app/src/main/java/sh/siava/pixelxpert/modpacks/systemui/QSFooterManager.java @@ -37,7 +37,7 @@ public class QSFooterManager extends XposedModPack { private static final String listenPackage = Constants.SYSTEM_UI_PACKAGE; private static boolean customQSFooterTextEnabled = false; private static String customText = ""; - private Object QSFV; + private Object QSFooterView; private final StringFormatter stringFormatter = new StringFormatter(); private TextView mChargingIndicator; @@ -45,6 +45,7 @@ public class QSFooterManager extends XposedModPack { private boolean mQSOpen = false; private static boolean ChargingInfoOnQSEnabled = false; private LinearLayout mQSFooterContainer; + private Boolean mIsComposeFooterAction = null; public void updatePrefs(String... Key) { @@ -74,7 +75,7 @@ public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Th hookAllConstructors(QSFooterViewClass, new XC_MethodHook() { @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { - QSFV = param.thisObject; + QSFooterView = param.thisObject; } }); @@ -107,11 +108,19 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { }); hookAllMethods(QSContainerImplClass, "updateResources", new XC_MethodHook() { + @SuppressLint("DiscouragedApi") @Override protected void afterHookedMethod(MethodHookParam param) throws Throwable { FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) mQSFooterContainer.getLayoutParams(); - lp.leftMargin = -1*getIntField(param.thisObject, "mTilesPageMargin"); - lp.rightMargin = lp.leftMargin; + if(mIsComposeFooterAction == null) + { + mIsComposeFooterAction = ((View)param.thisObject).findViewById(mContext.getResources().getIdentifier("qs_footer_actions", "id", mContext.getPackageName())).getClass().getName().contains("Compose"); + } + int margin = mIsComposeFooterAction + ? -1 * getIntField(param.thisObject, "mTilesPageMargin") + : 0; + lp.leftMargin = margin; + lp.rightMargin = margin; } }); @@ -165,9 +174,9 @@ private void createQSBatteryIndicator(FrameLayout QSContainerImpl) { private void setQSFooterText() { try { if (customQSFooterTextEnabled) { - TextView mBuildText = (TextView) getObjectField(QSFV, "mBuildText"); + TextView mBuildText = (TextView) getObjectField(QSFooterView, "mBuildText"); - setObjectField(QSFV, + setObjectField(QSFooterView, "mShouldShowBuildText", customText.trim().length() > 0); @@ -176,7 +185,7 @@ private void setQSFooterText() { mBuildText.setSelected(true); }); } else { - callMethod(QSFV, + callMethod(QSFooterView, "setBuildText"); } } catch (Throwable ignored) {