diff --git a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java index e168d63e..04fc5630 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/Constants.java @@ -217,6 +217,8 @@ public static class QsTilesCustomization { public static final String QS_BRIGHTNESS_SLIDER_COLOR = "brightness_slider_color"; public static final String QS_BRIGHTNESS_SLIDER_BACKGROUND_ENABLED = "brightness_slider_background_color_enabled"; public static final String QS_BRIGHTNESS_SLIDER_BACKGROUND_COLOR = "brightness_slider_background_color"; + public static final String QS_SLIDERS_REMOVE_BLUR = "qs_sliders_remove_blur"; + public static final String QS_SLIDERS_BLEND_COLOR = "qs_slider_blend_color"; public static final String QS_TILE_ANIMATION_STYLE = "qs_tile_animation_style"; public static final String QS_TILE_ANIMATION_INTERPOLATOR = "qs_tile_animation_interpolator"; public static final String QS_TILE_ANIMATION_DURATION = "qs_tile_animation_duration"; @@ -250,6 +252,8 @@ public static class QsTilesCustomization { QS_BRIGHTNESS_SLIDER_COLOR, QS_BRIGHTNESS_SLIDER_BACKGROUND_ENABLED, QS_BRIGHTNESS_SLIDER_BACKGROUND_COLOR, + QS_SLIDERS_REMOVE_BLUR, + QS_SLIDERS_BLEND_COLOR, QS_TILE_HIGHTLIGHT_RADIUS, QS_TILE_HIGHTLIGHT_RADIUS_TOP_LEFT, QS_TILE_HIGHTLIGHT_RADIUS_TOP_RIGHT, 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 52462051..1eb8eaca 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/utils/PreferenceHelper.java @@ -132,11 +132,14 @@ import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_TINT; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_URI; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsHeaderImage.QS_HEADER_IMAGE_ZOOM_TO_FIT; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_BRIGHTNESS_SLIDER_CUSTOMIZE; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_BLUR_AMOUNT; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_FILTER; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_TINT_AMOUNT; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_TINT_COLOR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_SHOW_ALBUM_ART; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_SLIDERS_BLEND_COLOR; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_SLIDERS_REMOVE_BLUR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_DURATION; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_INTERPOLATOR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_STYLE; @@ -184,6 +187,7 @@ import java.util.Collections; import java.util.List; +import it.dhd.oneplusui.preference.OplusPreferenceCategory; import it.dhd.oneplusui.preference.OplusSliderPreference; import it.dhd.oneplusui.preference.OplusSwitchPreference; import it.dhd.oxygencustomizer.BuildConfig; @@ -406,6 +410,10 @@ public static boolean isVisible(String key) { case "brightness_slider_background_color" -> { return instance.mPreferences.getBoolean("brightness_slider_background_color_enabled", false); } + case QS_SLIDERS_REMOVE_BLUR, + QS_SLIDERS_BLEND_COLOR -> { + return Build.VERSION.SDK_INT >= 35; + } case QS_TILE_ANIMATION_INTERPOLATOR, QS_TILE_ANIMATION_DURATION -> { return !instance.mPreferences.getString(QS_TILE_ANIMATION_STYLE, "0").equals("0"); @@ -891,7 +899,7 @@ public static boolean isEnabled(String key) { !instance.mPreferences.getBoolean(QS_TILE_LABELS_CUSTOM_COLOR_ENABLED, false); case QS_TILE_LABELS_CUSTOM_COLOR_ENABLED -> !instance.mPreferences.getBoolean(QS_TILE_HIDE_LABELS, false); - + case QS_SLIDERS_BLEND_COLOR-> !instance.mPreferences.getBoolean(QS_SLIDERS_REMOVE_BLUR, false); // Lockscreen Widgets case LOCKSCREEN_WIDGETS_DEVICE_WIDGET_CUSTOM_COLOR_SWITCH, LOCKSCREEN_WIDGETS_DEVICE_WIDGET_TEXT_COLOR, @@ -1235,6 +1243,17 @@ public static void setupPreference(Preference preference) { ((OplusSwitchPreference) preference).setChecked(true); } } + case "qs_sliders_cat" -> { + if (Build.VERSION.SDK_INT >= 35) { + preference.setTitle(preference.getContext().getString(R.string.qs_sliders)); + } + } + case QS_BRIGHTNESS_SLIDER_CUSTOMIZE -> { + if (Build.VERSION.SDK_INT >= 35) { + preference.setTitle(preference.getContext().getString(R.string.customize_qs_sliders_title)); + } + } + } } catch (Throwable ignored) { } diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java index dc9d4d88..b1e26595 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/statusbar/QsTileCustomization.java @@ -18,6 +18,8 @@ import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_TINT_AMOUNT; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_ART_TINT_COLOR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_MEDIA_SHOW_ALBUM_ART; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_SLIDERS_BLEND_COLOR; +import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_SLIDERS_REMOVE_BLUR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ACTIVE_COLOR; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ACTIVE_COLOR_ENABLED; import static it.dhd.oxygencustomizer.utils.Constants.Preferences.QsTilesCustomization.QS_TILE_ANIMATION_DURATION; @@ -84,7 +86,10 @@ import androidx.palette.graphics.Palette; import androidx.viewpager.widget.ViewPager; +import java.lang.reflect.InvocationTargetException; + import de.robv.android.xposed.XC_MethodHook; +import de.robv.android.xposed.XposedBridge; import de.robv.android.xposed.callbacks.XC_LoadPackage; import it.dhd.oxygencustomizer.utils.Constants; import it.dhd.oxygencustomizer.xposed.XposedMods; @@ -114,7 +119,7 @@ public class QsTileCustomization extends XposedMods { private static final String listenerPackage = Constants.Packages.SYSTEM_UI; private final int STATE_ACTIVE = 2; private final int STATE_INACTIVE = 1; - private Object mPersonalityManager = null; + private static Object mPersonalityManager = null; // Qs Tile Colors private int qsInactiveColor, qsActiveColor, qsDisabledColor; @@ -130,8 +135,17 @@ public class QsTileCustomization extends XposedMods { private int qsLabelsColor; // Brightness Slider + private Class ForegroundBlurParam = null; private boolean qsBrightnessSliderCustomize, qsBrightnessBackgroundCustomize; private int qsBrightnessSliderColorMode, qsBrightnessSliderColor, qsBrightnessBackgroundColor; + private final int SLIDER_PROGRESS = 0; + private final int SLIDER_BACKGROUND = 1; + private boolean sliderRemoveBlur = false; + private int sliderBlendColor = -1; + private final int BLEND_LUMINOSITY_COLOR_DODGE = 1; + private final int BLEND_COLOR_DODGE_LUMINOSITY = 2; + private final int BLEND_OVERLAY_LUMINOSITY = 3; + private final int BLEND_LUMINOSITY_OVERLAY = 4; // QS Media Tile private ImageView mCoverImg = null; @@ -199,6 +213,8 @@ public void updatePrefs(String... Key) { qsBrightnessSliderColor = Xprefs.getInt(QS_BRIGHTNESS_SLIDER_COLOR, getPrimaryColor(mContext)); qsBrightnessBackgroundCustomize = Xprefs.getBoolean(QS_BRIGHTNESS_SLIDER_BACKGROUND_ENABLED, false); qsBrightnessBackgroundColor = Xprefs.getInt(QS_BRIGHTNESS_SLIDER_BACKGROUND_COLOR, Color.TRANSPARENT); + sliderRemoveBlur = Xprefs.getBoolean(QS_SLIDERS_REMOVE_BLUR, false); + sliderBlendColor = Integer.parseInt(Xprefs.getString(QS_SLIDERS_BLEND_COLOR, "0")); // Labels qsLabelsHide = Xprefs.getBoolean(QS_TILE_HIDE_LABELS, false); @@ -403,7 +419,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { } if (Build.VERSION.SDK_INT >= 35) { - hookSliders(lpparam); + hookSliders(); } try { @@ -604,7 +620,10 @@ private Bitmap getFilteredArt(Bitmap art) { return finalArt; } - private void hookSliders(XC_LoadPackage.LoadPackageParam lpparam) { + private void hookSliders() { + + ForegroundBlurParam = ReflectedClass.of("com.oplus.posteffect.ForegroundBlurParam").getClazz(); + ReflectedClass OplusQsVerticalSeekBar = ReflectedClass.of("com.oplus.systemui.qs.base.seek.OplusQsVerticalSeekBar"); // Run on sysui start @@ -612,34 +631,31 @@ private void hookSliders(XC_LoadPackage.LoadPackageParam lpparam) { .before("createActiveTrackBlurParams") .run(param -> { if (!qsBrightnessSliderCustomize) return; - param.setResult( - callMethod( - param.thisObject, - "createForegroundBlurParams", - isNeedSeparateDarkThemeColor(mContext), - qsBrightnessSliderColorMode == 2 ? qsBrightnessSliderColor : getPrimaryColor(mContext), - qsBrightnessSliderColorMode == 2 ? qsBrightnessSliderColor : getPrimaryColor(mContext) - ) - ); + + Object ForegroundParams = getForegroundBlur(SLIDER_PROGRESS); + + param.setResult(ForegroundParams); }); OplusQsVerticalSeekBar .before("createInactiveTrackBlurParams") .run(param -> { if (!qsBrightnessBackgroundCustomize) return; - param.setResult( - callMethod( - param.thisObject, - "createForegroundBlurParams", - isNeedSeparateDarkThemeColor(mContext), - qsBrightnessBackgroundColor, - qsBrightnessBackgroundColor - ) - ); + Object ForegroundParams = getForegroundBlur(SLIDER_BACKGROUND); + + param.setResult(ForegroundParams); +// param.setResult( +// callMethod( +// param.thisObject, +// "createForegroundBlurParams", +// isNeedSeparateDarkThemeColor(mContext), +// qsBrightnessBackgroundColor, +// qsBrightnessBackgroundColor +// ) +// ); }); // now hook when update colors -// getTwoFeature // public final void drawForegroundBlur(Canvas canvas, Paint paint, ForegroundBlurParam foregroundBlurParam, Path path) { OplusQsVerticalSeekBar .before("drawForegroundBlur") @@ -650,9 +666,8 @@ private void hookSliders(XC_LoadPackage.LoadPackageParam lpparam) { if (foregroundBlurParam == activeTrackParam) { // draw active color // TODO: check if we need to draw active color - if (!qsBrightnessSliderCustomize) return; Object newForeground; - if (qsBrightnessSliderColorMode == 0) { + if (!qsBrightnessSliderCustomize || qsBrightnessSliderColorMode == 0) { newForeground = callMethod(param.thisObject, "createActiveTrackBlurParams"); param.args[2] = newForeground; } else { @@ -681,6 +696,17 @@ private void hookSliders(XC_LoadPackage.LoadPackageParam lpparam) { } + private int getBlendMode() { + if (sliderRemoveBlur) return 0; + return switch (sliderBlendColor) { + case 0 -> BLEND_LUMINOSITY_COLOR_DODGE; + case 1 -> BLEND_COLOR_DODGE_LUMINOSITY; + case 2 -> BLEND_OVERLAY_LUMINOSITY; + case 3 -> BLEND_LUMINOSITY_OVERLAY; + default -> SystemUtils.isDarkMode() ? BLEND_LUMINOSITY_OVERLAY : BLEND_LUMINOSITY_COLOR_DODGE; + }; + } + private void setupOtherViews(View parent, int color) { if (parent == null) return; @@ -781,14 +807,14 @@ public boolean listensTo(String packageName) { return listenerPackage.equals(packageName); } - private void notifyQsUpdate() { + public static void notifyQsUpdate() { if (mPersonalityManager == null) return; int currentShape = 0; try { currentShape = (int) callMethod(mPersonalityManager, "getLastShapeType"); } catch (Throwable t) { - log("Oxygen Customizer - QsTileCustomization error: " + t.getMessage()); + XposedBridge.log("Oxygen Customizer - QsTileCustomization error: " + t.getMessage()); } callMethod(mPersonalityManager, "notifyListener", currentShape); } @@ -906,4 +932,19 @@ private Shape getTileShape(boolean isHighlight) { null, null); } + private Object getForegroundBlur(int type) throws NoSuchMethodException, InvocationTargetException, IllegalAccessException, InstantiationException { + + return switch (type) { + case SLIDER_PROGRESS -> + ForegroundBlurParam.getConstructor(int.class, int.class, int.class) + .newInstance(getBlendMode(), + qsBrightnessSliderColorMode == 2 ? qsBrightnessSliderColor : getPrimaryColor(mContext), + qsBrightnessSliderColorMode == 2 ? qsBrightnessSliderColor : getPrimaryColor(mContext)); + case SLIDER_BACKGROUND -> + ForegroundBlurParam.getConstructor(int.class, int.class, int.class) + .newInstance(getBlendMode(), qsBrightnessBackgroundColor, qsBrightnessBackgroundColor); + default -> null; + }; + } + } diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 8d6d4c29..1cdd0888 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -103,6 +103,21 @@ 2 + + @string/default_value + @string/blur_luminosity_color_dodge + @string/blur_color_dodge_luminosity + @string/blur_overlay_luminosity + @string/blur_luminosity_overlay + + + -1 + 0 + 1 + 2 + 3 + + @string/gesture_override_back_hold_mode_default @string/gesture_override_back_hold_mode_per_side diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4cda0262..568f032e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -431,9 +431,17 @@ Customize Subtitle Color QS Subtitle Color Brightness Slider + QS Sliders Customize Brightness Slider - Brightness Slider Color Mode + Customize QS Sliders + Slider Color Mode Customize background color + Remove Blur + Blur Mode + Luminosity - Color Dodge + Color Dodge - Luminosity + Overlay - Luminosity + Luminosity - Overlay Custom QS Tile Radius diff --git a/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml b/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml index d0c012ef..a91fb9b2 100644 --- a/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml +++ b/app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml @@ -275,6 +275,7 @@ @@ -317,5 +318,21 @@ app:cpv_showAlphaSlider="true" app:iconSpaceReserved="false" /> + + + + \ No newline at end of file