diff --git a/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedBackgroundChip.java b/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedBackgroundChip.java index 07c89f085..b64572c4c 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedBackgroundChip.java +++ b/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedBackgroundChip.java @@ -95,17 +95,17 @@ protected void onCreate(Bundle savedInstanceState) { updateColorPreview(); // Status icons chip - if (Build.VERSION.SDK_INT >= 33) { - binding.statusiconsChipContainer.setVisibility(View.GONE); - RPrefs.putBoolean(QSPANEL_STATUSICONSBG_SWITCH, false); - } - binding.enableStatusIconsChip.setChecked(RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false)); binding.enableStatusIconsChip.setOnCheckedChangeListener((buttonView, isChecked) -> { RPrefs.putBoolean(QSPANEL_STATUSICONSBG_SWITCH, isChecked); new Handler(Looper.getMainLooper()).postDelayed(() -> { OverlayUtil.enableOverlay("IconifyComponentIXCC.overlay"); - SystemUtil.doubleToggleDarkMode(); + + if (Build.VERSION.SDK_INT >= 33) { + SystemUtil.handleSystemUIRestart(); + } else { + SystemUtil.doubleToggleDarkMode(); + } }, SWITCH_ANIMATION_DELAY); }); binding.statusIconsChip.setOnClickListener(v -> binding.enableStatusIconsChip.toggle()); @@ -177,7 +177,7 @@ private void addItemStatusIcons(ArrayList pack) { list.setOnClickListener(v -> { RPrefs.putInt(CHIP_QSSTATUSICONS_STYLE, finalI); refreshBackgroundStatusIcons(); - if (RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false)) { + if (RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) && Build.VERSION.SDK_INT < 33) { new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY); } }); diff --git a/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedOthers.java b/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedOthers.java index 6fb6805b4..59c565db6 100644 --- a/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedOthers.java +++ b/app/src/main/java/com/drdisagree/iconify/ui/activities/XposedOthers.java @@ -9,6 +9,7 @@ import static com.drdisagree.iconify.common.Preferences.HIDE_LOCKSCREEN_STATUSBAR; import static com.drdisagree.iconify.common.Preferences.HIDE_STATUS_ICONS_SWITCH; import static com.drdisagree.iconify.common.Preferences.QSPANEL_HIDE_CARRIER; +import static com.drdisagree.iconify.common.Preferences.QSPANEL_STATUSICONSBG_SWITCH; import android.annotation.SuppressLint; import android.os.Build; @@ -89,7 +90,8 @@ protected void onCreate(Bundle savedInstanceState) { // Fixed status icons if (Build.VERSION.SDK_INT >= 33) { - binding.statusIconsContainer.setVisibility(View.GONE); + binding.enableFixedStatusIconsContainer.setVisibility(View.GONE); + ((View) binding.statusIconsSideMarginSeekbar.getParent()).setVisibility(View.GONE); RPrefs.putBoolean(FIXED_STATUS_ICONS_SWITCH, false); } @@ -97,16 +99,25 @@ protected void onCreate(Bundle savedInstanceState) { binding.enableFixedStatusIcons.setOnCheckedChangeListener((buttonView, isChecked) -> { RPrefs.putBoolean(FIXED_STATUS_ICONS_SWITCH, isChecked); if (!isChecked) FabricatedUtil.disableOverlay("quickQsOffsetHeight"); - else if (RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0) > 32) - FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0)) + "dp"); + else if (RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8) > 32) + FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8)) + "dp"); - new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + if (Build.VERSION.SDK_INT >= 33) { + SystemUtil.handleSystemUIRestart(); + } else { + SystemUtil.doubleToggleDarkMode(); + } + }, SWITCH_ANIMATION_DELAY); }); + binding.enableFixedStatusIconsContainer.setOnClickListener(v -> binding.enableFixedStatusIcons.toggle()); // Status icons top margin - binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0) + "dp"); - binding.statusIconsTopMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0)); - final int[] topMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 0)}; + binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8) + "dp"); + binding.statusIconsTopMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8)); + binding.statusIconsTopMarginSeekbar.setEnabled(Build.VERSION.SDK_INT >= 33 ? RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) : RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)); + if (Build.VERSION.SDK_INT >= 33) binding.statusIconsTopMarginSeekbar.setValueTo(200); + final int[] topMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8)}; binding.statusIconsTopMarginSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() { @Override public void onStartTrackingTouch(@NonNull Slider slider) { @@ -117,9 +128,12 @@ public void onStopTrackingTouch(@NonNull Slider slider) { topMarginStatusIcons[0] = (int) slider.getValue(); binding.statusIconsTopMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + topMarginStatusIcons[0] + "dp"); RPrefs.putInt(FIXED_STATUS_ICONS_TOPMARGIN, topMarginStatusIcons[0]); - if (RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) { - FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (48 + topMarginStatusIcons[0]) + "dp"); - new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY); + if (Build.VERSION.SDK_INT >= 33 ? RPrefs.getBoolean(QSPANEL_STATUSICONSBG_SWITCH, false) : RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) { + if (Build.VERSION.SDK_INT < 33) { + FabricatedUtil.buildAndEnableOverlay(FRAMEWORK_PACKAGE, "quickQsOffsetHeight", "dimen", "quick_qs_offset_height", (40 + topMarginStatusIcons[0]) + "dp"); + + new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY); + } } } }); @@ -127,6 +141,7 @@ public void onStopTrackingTouch(@NonNull Slider slider) { // Status icons side margin binding.statusIconsSideMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0) + "dp"); binding.statusIconsSideMarginSeekbar.setValue(RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0)); + binding.statusIconsSideMarginSeekbar.setEnabled(RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)); final int[] sideMarginStatusIcons = {RPrefs.getInt(FIXED_STATUS_ICONS_SIDEMARGIN, 0)}; binding.statusIconsSideMarginSeekbar.addOnSliderTouchListener(new Slider.OnSliderTouchListener() { @Override @@ -139,7 +154,13 @@ public void onStopTrackingTouch(@NonNull Slider slider) { binding.statusIconsSideMarginOutput.setText(getResources().getString(R.string.opt_selected) + ' ' + sideMarginStatusIcons[0] + "dp"); RPrefs.putInt(FIXED_STATUS_ICONS_SIDEMARGIN, sideMarginStatusIcons[0]); if (RPrefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false)) { - new Handler(Looper.getMainLooper()).postDelayed(SystemUtil::doubleToggleDarkMode, SWITCH_ANIMATION_DELAY); + new Handler(Looper.getMainLooper()).postDelayed(() -> { + if (Build.VERSION.SDK_INT >= 33) { + SystemUtil.handleSystemUIRestart(); + } else { + SystemUtil.doubleToggleDarkMode(); + } + }, SWITCH_ANIMATION_DELAY); } } }); diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/mods/BackgroundChip.java b/app/src/main/java/com/drdisagree/iconify/xposed/mods/BackgroundChip.java index dd925482b..9b8e030c8 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/mods/BackgroundChip.java +++ b/app/src/main/java/com/drdisagree/iconify/xposed/mods/BackgroundChip.java @@ -4,6 +4,7 @@ import static com.drdisagree.iconify.common.Preferences.CHIP_QSSTATUSICONS_STYLE; import static com.drdisagree.iconify.common.Preferences.CHIP_STATUSBAR_CLOCKBG_STYLE; import static com.drdisagree.iconify.common.Preferences.FIXED_STATUS_ICONS_SWITCH; +import static com.drdisagree.iconify.common.Preferences.FIXED_STATUS_ICONS_TOPMARGIN; import static com.drdisagree.iconify.common.Preferences.HEADER_CLOCK_SWITCH; import static com.drdisagree.iconify.common.Preferences.HIDE_STATUS_ICONS_SWITCH; import static com.drdisagree.iconify.common.Preferences.QSPANEL_STATUSICONSBG_SWITCH; @@ -12,6 +13,8 @@ import static com.drdisagree.iconify.common.Preferences.STATUSBAR_CLOCK_COLOR_OPTION; import static com.drdisagree.iconify.config.XPrefs.Xprefs; import static com.drdisagree.iconify.xposed.HookRes.resparams; +import static com.drdisagree.iconify.xposed.utils.ViewHelper.dp2px; +import static de.robv.android.xposed.XposedBridge.hookAllMethods; import static de.robv.android.xposed.XposedBridge.log; import static de.robv.android.xposed.XposedHelpers.callMethod; import static de.robv.android.xposed.XposedHelpers.callStaticMethod; @@ -22,6 +25,7 @@ import android.annotation.SuppressLint; import android.content.Context; +import android.content.res.Configuration; import android.content.res.Resources; import android.graphics.Color; import android.graphics.PorterDuff; @@ -58,6 +62,7 @@ public class BackgroundChip extends ModPack implements IXposedHookLoadPackage { boolean hideStatusIcons = false; boolean mShowQSStatusIconsBg = false; boolean showHeaderClock = false; + int topMarginStatusIcons = 8; int QSStatusIconsChipStyle = 0; int statusBarClockChipStyle = 0; int statusBarClockColorOption = 0; @@ -68,6 +73,7 @@ public class BackgroundChip extends ModPack implements IXposedHookLoadPackage { private View mRightClockView = null; private Class DependencyClass = null; private Class DarkIconDispatcherClass = null; + private final LinearLayout mQsStatusIconsContainer = new LinearLayout(mContext); public BackgroundChip(Context context) { super(context); @@ -86,13 +92,17 @@ public void updatePrefs(String... Key) { showHeaderClock = Xprefs.getBoolean(HEADER_CLOCK_SWITCH, false); hideStatusIcons = Xprefs.getBoolean(HIDE_STATUS_ICONS_SWITCH, false); fixedStatusIcons = Xprefs.getBoolean(FIXED_STATUS_ICONS_SWITCH, false); + topMarginStatusIcons = Xprefs.getInt(FIXED_STATUS_ICONS_TOPMARGIN, 8); if (Key.length > 0) { if (Objects.equals(Key[0], STATUSBAR_CLOCKBG_SWITCH) || Objects.equals(Key[0], CHIP_STATUSBAR_CLOCKBG_STYLE) || Objects.equals(Key[0], STATUSBAR_CLOCK_COLOR_OPTION) || Objects.equals(Key[0], STATUSBAR_CLOCK_COLOR_CODE)) updateStatusBarClock(); if (Objects.equals(Key[0], QSPANEL_STATUSICONSBG_SWITCH) || Objects.equals(Key[0], CHIP_STATUSBAR_CLOCKBG_STYLE) || Objects.equals(Key[0], HEADER_CLOCK_SWITCH) || Objects.equals(Key[0], HIDE_STATUS_ICONS_SWITCH) || Objects.equals(Key[0], FIXED_STATUS_ICONS_SWITCH)) - setQSStatusIconsBg(); + setQSStatusIconsBgA12(); + + if (Objects.equals(Key[0], CHIP_QSSTATUSICONS_STYLE) || Objects.equals(Key[0], FIXED_STATUS_ICONS_TOPMARGIN)) + updateStatusIcons(); } } @@ -184,67 +194,61 @@ protected void afterHookedMethod(MethodHookParam param) { } }); - setQSStatusIconsBg(); - } - - private void setQSStatusIconsBg() { - XC_InitPackageResources.InitPackageResourcesParam ourResparam = resparams.get(SYSTEMUI_PACKAGE); - if (ourResparam == null) return; + if (Build.VERSION.SDK_INT >= 33) { + final Class QuickStatusBarHeader = findClass(SYSTEMUI_PACKAGE + ".qs.QuickStatusBarHeader", lpparam.classLoader); - if (Build.VERSION.SDK_INT < 33) { - ourResparam.res.hookLayout(SYSTEMUI_PACKAGE, "layout", "quick_qs_status_icons", new XC_LayoutInflated() { + hookAllMethods(QuickStatusBarHeader, "onFinishInflate", new XC_MethodHook() { @Override - public void handleLayoutInflated(XC_LayoutInflated.LayoutInflatedParam liparam) { + protected void afterHookedMethod(MethodHookParam param) { if (!mShowQSStatusIconsBg || hideStatusIcons) return; - if (!fixedStatusIcons) { - try { - @SuppressLint("DiscouragedApi") LinearLayout statusIcons = liparam.view.findViewById(liparam.res.getIdentifier("statusIcons", "id", mContext.getPackageName())); - LinearLayout statusIconContainer = (LinearLayout) statusIcons.getParent(); + FrameLayout mQuickStatusBarHeader = (FrameLayout) param.thisObject; + LinearLayout mIconContainer = (LinearLayout) getObjectField(param.thisObject, "mIconContainer"); + LinearLayout mBatteryRemainingIcon = (LinearLayout) getObjectField(param.thisObject, "mBatteryRemainingIcon"); - ((FrameLayout.LayoutParams) statusIconContainer.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; - statusIconContainer.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, mContext.getResources().getDisplayMetrics()); - statusIconContainer.requestLayout(); + LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + layoutParams.setMargins(0, dp2px(mContext, topMarginStatusIcons), 0, 0); - int paddingTopBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, mContext.getResources().getDisplayMetrics()); - int paddingStartEnd = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, mContext.getResources().getDisplayMetrics()); - statusIconContainer.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); + mQsStatusIconsContainer.setLayoutParams(layoutParams); + mQsStatusIconsContainer.setGravity(Gravity.CENTER); + mQsStatusIconsContainer.setOrientation(LinearLayout.HORIZONTAL); - setStatusIconsBackgroundChip(statusIconContainer); - } catch (Throwable throwable) { - log(TAG + throwable); - } + if (mQsStatusIconsContainer.getParent() != null) { + ((ViewGroup) mQsStatusIconsContainer.getParent()).removeView(mQsStatusIconsContainer); } - } - }); - ourResparam.res.hookLayout(SYSTEMUI_PACKAGE, "layout", "quick_status_bar_header_date_privacy", new XC_LayoutInflated() { - @Override - public void handleLayoutInflated(LayoutInflatedParam liparam) { - if (!mShowQSStatusIconsBg || hideStatusIcons) return; + if (mQsStatusIconsContainer.getChildCount() > 0) { + mQsStatusIconsContainer.removeAllViews(); + } - if (fixedStatusIcons) { - try { - @SuppressLint("DiscouragedApi") LinearLayout statusIcons = liparam.view.findViewById(liparam.res.getIdentifier("statusIcons", "id", mContext.getPackageName())); - if (statusIcons != null) { - LinearLayout statusIconContainer = (LinearLayout) statusIcons.getParent(); + layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); + ((ViewGroup) mIconContainer.getParent()).removeView(mIconContainer); + mIconContainer.setLayoutParams(layoutParams); + mIconContainer.getLayoutParams().height = dp2px(mContext, 28); - int paddingTopBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, mContext.getResources().getDisplayMetrics()); - int paddingStartEnd = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, mContext.getResources().getDisplayMetrics()); - statusIconContainer.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); + ((ViewGroup) mBatteryRemainingIcon.getParent()).removeView(mBatteryRemainingIcon); - setStatusIconsBackgroundChip(statusIconContainer); - } - } catch (Throwable throwable) { - log(TAG + throwable); - } - } + mQsStatusIconsContainer.addView(mIconContainer); + mQsStatusIconsContainer.addView(mBatteryRemainingIcon); + + mQuickStatusBarHeader.addView(mQsStatusIconsContainer, mQuickStatusBarHeader.getChildCount() - 1); + ((FrameLayout.LayoutParams) mQsStatusIconsContainer.getLayoutParams()).gravity = Gravity.TOP | Gravity.END; + + updateStatusIcons(); + } + }); + + hookAllMethods(QuickStatusBarHeader, "updateResources", new XC_MethodHook() { + @Override + protected void afterHookedMethod(MethodHookParam param) { + updateStatusIcons(); } }); } + + setQSStatusIconsBgA12(); } - @SuppressLint("DiscouragedApi") private void updateStatusBarClock() { if (!mShowSBClockBg) return; @@ -257,35 +261,26 @@ private void updateStatusBarClock() { updateClockView(mRightClockView, clockPaddingStartEnd, clockPaddingTop, clockPaddingStartEnd, clockPaddingBottom, Gravity.END | Gravity.CENTER); } - private void updateClockView(View clockView, int start, int top, int end, int bottom, int gravity) { - if (clockView != null) { - clockView.setPadding(start, top, end, bottom); - setStatusBarBackgroundChip(clockView); + private void updateStatusIcons() { + if (!mShowQSStatusIconsBg || mQsStatusIconsContainer.getChildCount() == 0) return; - if (statusBarClockColorOption == 0) { - ((TextView) clockView).getPaint().setXfermode(null); - callMethod(callStaticMethod(DependencyClass, "get", DarkIconDispatcherClass), "addDarkReceiver", clockView); - } else if (statusBarClockColorOption == 1) { - ((TextView) clockView).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); - } else if (statusBarClockColorOption == 2) { - ((TextView) clockView).getPaint().setXfermode(null); - callMethod(callStaticMethod(DependencyClass, "get", DarkIconDispatcherClass), "removeDarkReceiver", clockView); - ((TextView) clockView).setTextColor(statusBarClockColorCode); - } + int paddingTopBottom = dp2px(mContext, 4); + int paddingStartEnd = dp2px(mContext, 12); - try { - ((LinearLayout.LayoutParams) clockView.getLayoutParams()).gravity = gravity; - } catch (Throwable t) { - ((FrameLayout.LayoutParams) clockView.getLayoutParams()).gravity = gravity; - } + setStatusIconsBackgroundChip(mQsStatusIconsContainer); + mQsStatusIconsContainer.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); + ((FrameLayout.LayoutParams) mQsStatusIconsContainer.getLayoutParams()).setMargins(0, dp2px(mContext, topMarginStatusIcons), 0, 0); + mQsStatusIconsContainer.requestLayout(); - ((TextView) clockView).setIncludeFontPadding(false); - clockView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; - clockView.setForegroundGravity(Gravity.CENTER); + Configuration config = mContext.getResources().getConfiguration(); + if (config.orientation == Configuration.ORIENTATION_LANDSCAPE) { + mQsStatusIconsContainer.setVisibility(View.GONE); + } else { + mQsStatusIconsContainer.setVisibility(View.VISIBLE); } } - private void setStatusBarBackgroundChip(View view) { + private void setSBClockBackgroundChip(View view) { try { Context pc = mContext.createPackageContext(BuildConfig.APPLICATION_ID, Context.CONTEXT_IGNORE_SECURITY); Resources res = pc.getResources(); @@ -357,4 +352,89 @@ private void setStatusIconsBackgroundChip(LinearLayout layout) { log(TAG + throwable); } } + + private void updateClockView(View clockView, int start, int top, int end, int bottom, int gravity) { + if (clockView != null) { + clockView.setPadding(start, top, end, bottom); + setSBClockBackgroundChip(clockView); + + if (statusBarClockColorOption == 0) { + ((TextView) clockView).getPaint().setXfermode(null); + callMethod(callStaticMethod(DependencyClass, "get", DarkIconDispatcherClass), "addDarkReceiver", clockView); + } else if (statusBarClockColorOption == 1) { + ((TextView) clockView).getPaint().setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); + } else if (statusBarClockColorOption == 2) { + ((TextView) clockView).getPaint().setXfermode(null); + callMethod(callStaticMethod(DependencyClass, "get", DarkIconDispatcherClass), "removeDarkReceiver", clockView); + ((TextView) clockView).setTextColor(statusBarClockColorCode); + } + + try { + ((LinearLayout.LayoutParams) clockView.getLayoutParams()).gravity = gravity; + } catch (Throwable t) { + ((FrameLayout.LayoutParams) clockView.getLayoutParams()).gravity = gravity; + } + + ((TextView) clockView).setIncludeFontPadding(false); + clockView.getLayoutParams().height = ViewGroup.LayoutParams.WRAP_CONTENT; + clockView.setForegroundGravity(Gravity.CENTER); + } + } + + private void setQSStatusIconsBgA12() { + if (Build.VERSION.SDK_INT >= 33) return; + + XC_InitPackageResources.InitPackageResourcesParam ourResparam = resparams.get(SYSTEMUI_PACKAGE); + if (ourResparam == null) return; + + ourResparam.res.hookLayout(SYSTEMUI_PACKAGE, "layout", "quick_qs_status_icons", new XC_LayoutInflated() { + @Override + public void handleLayoutInflated(XC_LayoutInflated.LayoutInflatedParam liparam) { + if (!mShowQSStatusIconsBg || hideStatusIcons) return; + + if (!fixedStatusIcons) { + try { + @SuppressLint("DiscouragedApi") LinearLayout statusIcons = liparam.view.findViewById(liparam.res.getIdentifier("statusIcons", "id", mContext.getPackageName())); + LinearLayout statusIconContainer = (LinearLayout) statusIcons.getParent(); + + ((FrameLayout.LayoutParams) statusIconContainer.getLayoutParams()).gravity = Gravity.CENTER_VERTICAL | Gravity.END; + statusIconContainer.getLayoutParams().height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 28, mContext.getResources().getDisplayMetrics()); + statusIconContainer.requestLayout(); + + int paddingTopBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, mContext.getResources().getDisplayMetrics()); + int paddingStartEnd = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, mContext.getResources().getDisplayMetrics()); + statusIconContainer.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); + + setStatusIconsBackgroundChip(statusIconContainer); + } catch (Throwable throwable) { + log(TAG + throwable); + } + } + } + }); + + ourResparam.res.hookLayout(SYSTEMUI_PACKAGE, "layout", "quick_status_bar_header_date_privacy", new XC_LayoutInflated() { + @Override + public void handleLayoutInflated(LayoutInflatedParam liparam) { + if (!mShowQSStatusIconsBg || hideStatusIcons) return; + + if (fixedStatusIcons) { + try { + @SuppressLint("DiscouragedApi") LinearLayout statusIcons = liparam.view.findViewById(liparam.res.getIdentifier("statusIcons", "id", mContext.getPackageName())); + if (statusIcons != null) { + LinearLayout statusIconContainer = (LinearLayout) statusIcons.getParent(); + + int paddingTopBottom = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 2, mContext.getResources().getDisplayMetrics()); + int paddingStartEnd = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8, mContext.getResources().getDisplayMetrics()); + statusIconContainer.setPadding(paddingStartEnd, paddingTopBottom, paddingStartEnd, paddingTopBottom); + + setStatusIconsBackgroundChip(statusIconContainer); + } + } catch (Throwable throwable) { + log(TAG + throwable); + } + } + } + }); + } } diff --git a/app/src/main/res/layout/activity_xposed_others.xml b/app/src/main/res/layout/activity_xposed_others.xml index ed23f11a0..93f4bd91a 100644 --- a/app/src/main/res/layout/activity_xposed_others.xml +++ b/app/src/main/res/layout/activity_xposed_others.xml @@ -303,7 +303,7 @@ android:layout_gravity="center_horizontal" android:layout_marginTop="4dp" android:stepSize="1" - android:value="0" + android:value="8" android:valueFrom="0" android:valueTo="48" />