From b596f20110da7e5fdf22f5e9bb6735597b1bd53e Mon Sep 17 00:00:00 2001 From: DHD2280 Date: Thu, 25 Apr 2024 21:15:32 +0200 Subject: [PATCH] Fixes for OOS 13 --- .../oxygencustomizer/utils/PreferenceHelper.java | 2 +- .../hooks/systemui/statusbar/StatusbarClock.java | 14 +++++++++++++- .../hooks/systemui/statusbar/StatusbarIcons.java | 10 ++++++++-- .../hooks/systemui/statusbar/StatusbarMods.java | 2 +- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java index 26aa696d6..b2014a9c3 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java @@ -535,7 +535,7 @@ public static String getSummary(Context fragmentCompat, @NonNull String key) { String.valueOf(instance.mPreferences.getSliderInt("quick_settings_tiles_vertical_columns", 4)); // Statusbar - case "status_bar_clock_size" -> instance.mPreferences.getSliderInt("status_bar_clock_size", 14) + "sp"; + case "status_bar_clock_size" -> instance.mPreferences.getSliderInt("status_bar_clock_size", 12) + "sp"; case "status_bar_clock_auto_hide_hduration" -> fragmentCompat.getString(R.string.status_bar_clock_auto_hide_hdur_summary) + "\n" + instance.mPreferences.getSliderInt("status_bar_clock_auto_hide_hduration", 60) + " " + diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java index 03171874e..1054ee5f5 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarClock.java @@ -19,6 +19,7 @@ import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs; import static it.dhd.oxygencustomizer.xposed.hooks.systemui.OpUtils.getPrimaryColor; import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.dp2px; +import static it.dhd.oxygencustomizer.xposed.utils.ViewHelper.setMargins; import android.annotation.SuppressLint; import android.app.ActivityManager; @@ -560,14 +561,25 @@ else if (chipUseGradient) setupChip(); } + @SuppressLint("RtlHardcoded") private void setupChip() { if (clockChip) { - mClockView.setPadding(dp2px(mContext, 1), 0, dp2px(mContext, 1), 0); + mClockView.setPadding(dp2px(mContext, 8), dp2px(mContext, 2), dp2px(mContext, 8), dp2px(mContext, 2)); + mClockView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; mClockView.setBackground(mClockChipDrawale); } else { mClockView.setPadding(0, 0, 0, 0); + mClockView.getLayoutParams().height = ViewGroup.LayoutParams.MATCH_PARENT; mClockView.setBackground(null); } + switch (mClockDatePosition) { + case POSITION_LEFT -> mClockView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL); + case POSITION_CENTER -> mClockView.setGravity(Gravity.CENTER_VERTICAL); + case POSITION_RIGHT -> mClockView.setGravity(Gravity.RIGHT | Gravity.CENTER_VERTICAL); + } + mClockView.setTextAlignment(View.TEXT_ALIGNMENT_CENTER); + mClockView.requestLayout(); + if (mCenteredIconArea != null) mCenteredIconArea.requestLayout(); } private void updateShowClock() { diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java index 3bdc91b6b..cc24ef650 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarIcons.java @@ -9,6 +9,7 @@ import static it.dhd.oxygencustomizer.xposed.XPrefs.Xprefs; import android.content.Context; +import android.os.Build; import de.robv.android.xposed.XC_MethodHook; import de.robv.android.xposed.callbacks.XC_LoadPackage; @@ -32,7 +33,12 @@ public void updatePrefs(String... Key) { @Override public void handleLoadPackage(XC_LoadPackage.LoadPackageParam lpparam) throws Throwable { try { - Class OplusPhoneStatusBarPolicyExImpl = findClass("com.oplus.systemui.statusbar.phone.OplusPhoneStatusBarPolicyExImpl", lpparam.classLoader); + Class OplusPhoneStatusBarPolicyExImpl; + try { + OplusPhoneStatusBarPolicyExImpl = findClass("com.oplus.systemui.statusbar.phone.OplusPhoneStatusBarPolicyExImpl", lpparam.classLoader); + } catch (Throwable t) { + OplusPhoneStatusBarPolicyExImpl = findClass("com.oplusos.systemui.statusbar.phone.PhoneStatusBarPolicyEx", lpparam.classLoader); + } // private final void updateBluetoothIcon(int i, int i2, CharSequence charSequence, boolean z) { findAndHookMethod(OplusPhoneStatusBarPolicyExImpl, "updateBluetoothIcon", @@ -46,7 +52,7 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { if (!enabled || !hideBluetooth) return; - Object bluetoothController = getObjectField(param.thisObject, "bluetoothController"); + Object bluetoothController = getObjectField(param.thisObject, Build.VERSION.SDK_INT >= 34 ? "bluetoothController" : "mBluetooth"); boolean connected = (boolean) callMethod(bluetoothController, "isBluetoothConnected"); if (!connected) diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java index d6fc9974b..9208646cd 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/StatusbarMods.java @@ -512,7 +512,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } }); try { - DrawableSize = findClass("com.android.systemui.util.drawable.DrawableSize", lpparam.classLoader); + DrawableSize = findClassIfExists("com.android.systemui.util.drawable.DrawableSize", lpparam.classLoader); } catch (Throwable ignored) {} Class StatusBarIconView = findClass("com.android.systemui.statusbar.StatusBarIconView", lpparam.classLoader); findAndHookMethod(StatusBarIconView,