diff --git a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/VolumePanel.java b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/VolumePanel.java index b56127bef..c7376f905 100644 --- a/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/VolumePanel.java +++ b/app/src/main/java/it/dhd/oxygencustomizer/xposed/hooks/systemui/VolumePanel.java @@ -15,7 +15,10 @@ import android.content.Context; import android.content.res.ColorStateList; import android.graphics.Color; +import android.graphics.ColorFilter; import android.graphics.PorterDuff; +import android.graphics.PorterDuffColorFilter; +import android.graphics.drawable.Drawable; import android.graphics.drawable.LayerDrawable; import android.view.View; import android.view.Gravity; @@ -24,6 +27,7 @@ import android.view.WindowManager; import android.widget.ImageView; +import androidx.appcompat.widget.AppCompatImageView; import androidx.core.graphics.ColorUtils; import java.util.List; @@ -40,9 +44,9 @@ public class VolumePanel extends XposedMods { private int mTimeOut; private int mDesiredTimeout; private boolean mDisableVolumeWarning; - private boolean customizeVolumeProgress, customizeVolumeIcon; - private boolean volumeProgressPrimary, volumeIconPrimary; - private int volumeProgressColor, volumeIconColor; + private boolean customizeVolumeProgress, customizeVolumeBg; + private boolean volumeProgressPrimary; + private int volumeProgressColor, volumeBgColor; private Object OVDI; private boolean sliderCustomizable = false; @@ -58,19 +62,17 @@ public void updatePrefs(String... Key) { mTimeOut = mDesiredTimeout * 1000; mDisableVolumeWarning = Xprefs.getBoolean("disable_volume_warning", false); customizeVolumeProgress = Xprefs.getBoolean("volume_panel_seekbar_color_enabled", false); - customizeVolumeIcon = Xprefs.getBoolean("volume_panel_icon_color_enabled", false); + customizeVolumeBg = Xprefs.getBoolean("volume_panel_seekbar_bg_color_enabled", false); volumeProgressPrimary = Xprefs.getBoolean("volume_panel_seekbar_link_primary", false); - volumeIconPrimary = Xprefs.getBoolean("volume_panel_icon_accent", false); volumeProgressColor = Xprefs.getInt("volume_panel_seekbar_color", 0); - volumeIconColor = Xprefs.getInt("volume_panel_icon_color", 0); + volumeBgColor = Xprefs.getInt("volume_panel_seekbar_bg_color", Color.GRAY); if (Key.length > 0) { if (Key[0].equals("volume_panel_seekbar_color_enabled") || Key[0].equals("volume_panel_seekbar_link_primary") || Key[0].equals("volume_panel_seekbar_color") || - Key[0].equals("volume_panel_icon_color_enabled") || - Key[0].equals("volume_panel_icon_accent") || - Key[0].equals("volume_panel_icon_color")) { + Key[0].equals("volume_panel_seekbar_bg_color_enabled") || + Key[0].equals("volume_panel_seekbar_bg_color")) { updateVolumePanel(); } } @@ -116,7 +118,15 @@ protected void beforeHookedMethod(MethodHookParam param) throws Throwable { } }); - + Class VolumeDialogImpl = findClass("com.android.systemui.volume.VolumeDialogImpl", lpparam.classLoader); + hookAllMethods(VolumeDialogImpl, "showSafetyWarningH", new XC_MethodHook() { + @Override + protected void beforeHookedMethod(MethodHookParam param) throws Throwable { + if (mDisableVolumeWarning) { + param.setResult(null); + } + } + }); hookAllConstructors(OplusVolumeDialogImpl, new XC_MethodHook() { @Override @@ -138,87 +148,10 @@ protected void afterHookedMethod(MethodHookParam param) throws Throwable { else callMethod(slider, "setProgressColor", ColorStateList.valueOf(volumeProgressColor)); } - - if (customizeVolumeIcon) { - ImageView icon = (ImageView) getObjectField(VolumeRow, "icon"); - int colorToApply = -1; - if (volumeIconPrimary) - colorToApply = getPrimaryColor(mContext); - else - colorToApply = volumeIconColor; - - if (colorToApply != -1) { - int fadeFilter = ColorUtils.blendARGB(Color.TRANSPARENT, colorToApply, 1.0f); - icon.setColorFilter(fadeFilter, PorterDuff.Mode.SRC_ATOP); - } - callMethod(icon, "setSupportImageTintList", ColorStateList.valueOf(colorToApply)); - callMethod(slider, "setIcon", icon); - } - - } - }); - - final XC_MethodHook volumeIconHook = new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - Object VolumeRow = param.args[0]; - Object slider = getObjectField(VolumeRow, "slider"); - - if (customizeVolumeIcon) { - ImageView icon = (ImageView) getObjectField(VolumeRow, "icon"); - int colorToApply = -1; - if (volumeIconPrimary) - colorToApply = getPrimaryColor(mContext); - else - colorToApply = volumeIconColor; - - if (colorToApply != -1) { - int fadeFilter = ColorUtils.blendARGB(Color.TRANSPARENT, colorToApply, 1.0f); - icon.setColorFilter(fadeFilter, PorterDuff.Mode.SRC_ATOP); - } - callMethod(icon, "setSupportImageTintList", ColorStateList.valueOf(colorToApply)); - callMethod(slider, "setIcon", icon); + if (customizeVolumeBg) { + callMethod(slider, "setSeekBarBackgroundColor", ColorStateList.valueOf(volumeBgColor)); } - } - }; - - Class VolumeSeekBarChangeListener = findClass("com.oplus.systemui.volume.OplusVolumeDialogImpl$VolumeSeekBarChangeListener", lpparam.classLoader); - hookAllConstructors(VolumeSeekBarChangeListener, new XC_MethodHook() { - @Override - protected void afterHookedMethod(MethodHookParam param) throws Throwable { - Object VolumeRow = getObjectField(param.thisObject, "mRow"); - - if (customizeVolumeIcon) { - ImageView icon = (ImageView) getObjectField(VolumeRow, "icon"); - if (icon == null) return; - int colorToApply = -1; - if (volumeIconPrimary) - colorToApply = getPrimaryColor(mContext); - else - colorToApply = volumeIconColor; - - if (colorToApply != -1) { - int fadeFilter = ColorUtils.blendARGB(Color.TRANSPARENT, colorToApply, 1.0f); - icon.setColorFilter(fadeFilter, PorterDuff.Mode.SRC_ATOP); - } - callMethod(icon, "setSupportImageTintList", ColorStateList.valueOf(colorToApply)); - } } - }); - - hookAllMethods(OplusVolumeDialogImpl, "updateVolumeRowH", volumeIconHook); - - hookAllMethods(OplusVolumeDialogImpl, "updateVolumeRowSliderH", volumeIconHook); - hookAllMethods(OplusVolumeDialogImpl, "updateVolumeRowTintH", volumeIconHook); - hookAllMethods(OplusVolumeDialogImpl, "refreshVisibleRow", volumeIconHook); - - Class VolumeDialogImpl = findClass("com.android.systemui.volume.VolumeDialogImpl", lpparam.classLoader); - hookAllMethods(VolumeDialogImpl, "showSafetyWarningH", new XC_MethodHook() { - @Override - protected void beforeHookedMethod(MethodHookParam param) throws Throwable { - if (mDisableVolumeWarning) { - param.setResult(null); - } } }); @@ -238,20 +171,8 @@ private void updateVolumePanel() { else callMethod(slider, "setProgressColor", ColorStateList.valueOf(volumeProgressColor)); } - - if (customizeVolumeIcon) { - ImageView icon = (ImageView) getObjectField(VolumeRow, "icon"); - int colorToApply = -1; - if (volumeIconPrimary) - colorToApply = getPrimaryColor(mContext); - else - colorToApply = volumeIconColor; - - if (colorToApply != -1) { - int fadeFilter = ColorUtils.blendARGB(Color.TRANSPARENT, colorToApply, 1.0f); - icon.setColorFilter(fadeFilter, PorterDuff.Mode.SRC_ATOP); - } - callMethod(slider, "setIcon", icon); + if (customizeVolumeBg) { + callMethod(slider, "setSeekBarBackgroundColor", ColorStateList.valueOf(volumeBgColor)); } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4bb885760..660c4271a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -727,6 +727,7 @@ Link Progress to primary color Customize Icon Color Link Icon to primary color + Custom Background Color Volume panel styles diff --git a/app/src/main/res/xml/volume_panel_customizations.xml b/app/src/main/res/xml/volume_panel_customizations.xml index 9c4d86d51..d72ba9183 100644 --- a/app/src/main/res/xml/volume_panel_customizations.xml +++ b/app/src/main/res/xml/volume_panel_customizations.xml @@ -28,27 +28,19 @@ app:iconSpaceReserved="false" android:defaultValue="0xffffffff" /> - + android:defaultValue="-7829368" />