Skip to content

Commit

Permalink
CHANGELOG: Added qs sliders blur options for OOS15
Browse files Browse the repository at this point in the history
Signed-off-by: DHD2280 <[email protected]>
  • Loading branch information
DHD2280 committed Jan 5, 2025
1 parent 5383514 commit e376a0a
Show file tree
Hide file tree
Showing 6 changed files with 132 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -403,7 +419,7 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable {
}

if (Build.VERSION.SDK_INT >= 35) {
hookSliders(lpparam);
hookSliders();
}

try {
Expand Down Expand Up @@ -604,42 +620,42 @@ 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
OplusQsVerticalSeekBar
.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")
Expand All @@ -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 {
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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;
};
}

}
15 changes: 15 additions & 0 deletions app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,21 @@
<item>2</item>
</string-array>

<string-array name="qs_slider_blur_entries">
<item>@string/default_value</item>
<item>@string/blur_luminosity_color_dodge</item>
<item>@string/blur_color_dodge_luminosity</item>
<item>@string/blur_overlay_luminosity</item>
<item>@string/blur_luminosity_overlay</item>
</string-array>
<string-array name="qs_slider_blur_values">
<item>-1</item>
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>

<string-array name="gesture_holdback_mode_entries">
<item>@string/gesture_override_back_hold_mode_default</item>
<item>@string/gesture_override_back_hold_mode_per_side</item>
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -431,9 +431,17 @@
<string name="quick_settings_tiles_customize_labels_subtitle">Customize Subtitle Color</string>
<string name="quick_settings_tiles_customize_labels_subtitle_color">QS Subtitle Color</string>
<string name="brightness_slider">Brightness Slider</string>
<string name="qs_sliders">QS Sliders</string>
<string name="customize_brightness_slider_title">Customize Brightness Slider</string>
<string name="brightness_slider_progress_color_title">Brightness Slider Color Mode</string>
<string name="customize_qs_sliders_title">Customize QS Sliders</string>
<string name="brightness_slider_progress_color_title">Slider Color Mode</string>
<string name="brightness_slider_background_color_title">Customize background color</string>
<string name="qs_sliders_remove_blur">Remove Blur</string>
<string name="blur_mode">Blur Mode</string>
<string name="blur_luminosity_color_dodge">Luminosity - Color Dodge</string>
<string name="blur_color_dodge_luminosity">Color Dodge - Luminosity</string>
<string name="blur_overlay_luminosity">Overlay - Luminosity</string>
<string name="blur_luminosity_overlay">Luminosity - Overlay</string>

<!-- QS Tile Radius -->
<string name="qs_tiles_custom_radius">Custom QS Tile Radius</string>
Expand Down
17 changes: 17 additions & 0 deletions app/src/main/res/xml/quick_settings_tiles_customizations_prefs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,7 @@
</it.dhd.oneplusui.preference.OplusPreferenceCategory>

<it.dhd.oneplusui.preference.OplusPreferenceCategory
android:key="qs_sliders_cat"
android:title="@string/brightness_slider"
app:iconSpaceReserved="false">

Expand Down Expand Up @@ -317,5 +318,21 @@
app:cpv_showAlphaSlider="true"
app:iconSpaceReserved="false" />

<it.dhd.oneplusui.preference.OplusSwitchPreference
android:defaultValue="false"
android:key="qs_sliders_remove_blur"
android:summaryOff="@string/general_off"
android:summaryOn="@string/general_on"
android:title="@string/qs_sliders_remove_blur" />

<it.dhd.oneplusui.preference.OplusMenuPreference
android:defaultValue="0"
android:entries="@array/qs_slider_blur_entries"
android:entryValues="@array/qs_slider_blur_values"
android:key="qs_slider_blend_color"
android:title="@string/blur_mode"
app:iconSpaceReserved="false"
app:useSimpleSummaryProvider="true" />

</it.dhd.oneplusui.preference.OplusPreferenceCategory>
</PreferenceScreen>

0 comments on commit e376a0a

Please sign in to comment.