diff --git a/app/src/main/java/com/drdisagree/iconify/data/keys/XposedKey.kt b/app/src/main/java/com/drdisagree/iconify/data/keys/XposedKey.kt index b44ced126..97b4a471f 100644 --- a/app/src/main/java/com/drdisagree/iconify/data/keys/XposedKey.kt +++ b/app/src/main/java/com/drdisagree/iconify/data/keys/XposedKey.kt @@ -327,5 +327,7 @@ enum class XposedKey(override val default: Any?) : Key { VOLUME_PANEL_APP_VOLUME(false), VOLUME_PANEL_MULTI_AUDIO_FOCUS(false), VOLUME_CORNER_RADIUS_OFFSET(0f), + VOLUME_TRACK_CORNER_RADIUS_OFFSET(0f), + VOLUME_RINGER_BUTTON_CORNER_RADIUS_OFFSET(0f), HIDE_VOLUME_SLIDER_THUMB(false), -} \ No newline at end of file +} diff --git a/app/src/main/java/com/drdisagree/iconify/features/xposed/volumepanel/screens/VolumePanelScreen.kt b/app/src/main/java/com/drdisagree/iconify/features/xposed/volumepanel/screens/VolumePanelScreen.kt index 70278b667..a61c7b82f 100644 --- a/app/src/main/java/com/drdisagree/iconify/features/xposed/volumepanel/screens/VolumePanelScreen.kt +++ b/app/src/main/java/com/drdisagree/iconify/features/xposed/volumepanel/screens/VolumePanelScreen.kt @@ -17,6 +17,12 @@ import com.drdisagree.iconify.data.keys.XposedKey import com.drdisagree.iconify.features.common.viewmodels.SystemActionViewModel import kotlin.math.roundToInt +private val radiusSliders = listOf( + XposedKey.VOLUME_CORNER_RADIUS_OFFSET to R.string.volume_dialog_radius_title, + XposedKey.VOLUME_TRACK_CORNER_RADIUS_OFFSET to R.string.volume_track_radius_title, + XposedKey.VOLUME_RINGER_BUTTON_CORNER_RADIUS_OFFSET to R.string.volume_ringer_button_radius_title, +) + val volumePanelPreferences = preferenceScreen { category { switch( @@ -45,19 +51,20 @@ val volumePanelPreferences = preferenceScreen { } category(title = stringRes(R.string.section_title_volume_shape)) { - slider( - key = XposedKey.VOLUME_CORNER_RADIUS_OFFSET, - title = stringRes(R.string.volume_corner_radius_offset_title), - summary = { stringRes(R.string.volume_corner_radius_offset_desc) }, - min = -50f, - max = 50f, - valueLabel = { value -> - val offset = value.roundToInt() - if (offset > 0) "+${offset}dp" else "${offset}dp" - }, - showResetButton = true, - isVisible = { Build.VERSION.SDK_INT >= 36 }, - ) + radiusSliders.forEach { (key, title) -> + slider( + key = key, + title = stringRes(title), + min = -50f, + max = 50f, + valueLabel = { value -> + val offset = value.roundToInt() + if (offset > 0) "+${offset}dp" else "${offset}dp" + }, + showResetButton = true, + isVisible = { Build.VERSION.SDK_INT >= 36 }, + ) + } switch( key = XposedKey.HIDE_VOLUME_SLIDER_THUMB, @@ -78,6 +85,8 @@ fun VolumePanelScreen( XposedKey.VOLUME_PANEL_SAFETY_WARNING.name, XposedKey.VOLUME_PANEL_APP_VOLUME.name, XposedKey.VOLUME_CORNER_RADIUS_OFFSET.name, + XposedKey.VOLUME_TRACK_CORNER_RADIUS_OFFSET.name, + XposedKey.VOLUME_RINGER_BUTTON_CORNER_RADIUS_OFFSET.name, XposedKey.HIDE_VOLUME_SLIDER_THUMB.name -> { systemActionViewModel?.shouldRestartSystemUI() } @@ -103,4 +112,4 @@ private fun VolumePanelScreenPreview() { PreviewComposable { VolumePanelScreen(null) } -} \ No newline at end of file +} diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/misc/ComposeShapes.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/misc/ComposeShapes.kt index 8dc88c0e6..04c5fe91c 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/misc/ComposeShapes.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/misc/ComposeShapes.kt @@ -1,5 +1,6 @@ package com.drdisagree.iconify.xposed.modules.misc +import android.annotation.SuppressLint import android.content.Context import android.graphics.drawable.Drawable import android.graphics.drawable.DrawableWrapper @@ -12,6 +13,7 @@ import com.drdisagree.iconify.xposed.ModPack import com.drdisagree.iconify.xposed.core.PackageParam import com.drdisagree.iconify.xposed.core.compose.ComposeToolkit import com.drdisagree.iconify.xposed.core.hook.hookMethodMatchPattern +import com.drdisagree.iconify.xposed.core.layout.hookLayout import com.drdisagree.iconify.xposed.core.hook.proceedWithArgs import com.drdisagree.iconify.xposed.core.reflect.callMethodSilently import com.drdisagree.iconify.xposed.core.reflect.findClass @@ -33,6 +35,8 @@ class ComposeShapes(context: Context) : ModPack(context) { private var inactiveIconCornerRadiusOffset = 0f private var footerButtonsCornerRadiusOffset = 0f private var notificationCornerRadiusOffset = 0f + private var volumeDialogCornerRadiusOffset = 0f + private var volumeRingerButtonCornerRadiusOffset = 0f private var qsSliderStyle = SliderStyle() private var volumeSliderStyle = SliderStyle() private var pillShapeCache: Pair? = null @@ -77,12 +81,15 @@ class ComposeShapes(context: Context) : ModPack(context) { footerButtonsCornerRadiusOffset = getFloat(XposedKey.QS_FOOTER_BUTTONS_CORNER_RADIUS_OFFSET) notificationCornerRadiusOffset = getFloat(XposedKey.NOTIFICATION_CORNER_RADIUS_OFFSET) + volumeDialogCornerRadiusOffset = getFloat(XposedKey.VOLUME_CORNER_RADIUS_OFFSET) + volumeRingerButtonCornerRadiusOffset = + getFloat(XposedKey.VOLUME_RINGER_BUTTON_CORNER_RADIUS_OFFSET) qsSliderStyle = SliderStyle( cornerRadiusOffset = getFloat(XposedKey.QS_BRIGHTNESS_SLIDER_CORNER_RADIUS_OFFSET), hideThumb = getBoolean(XposedKey.HIDE_QS_SLIDER_THUMB) ) volumeSliderStyle = SliderStyle( - cornerRadiusOffset = getFloat(XposedKey.VOLUME_CORNER_RADIUS_OFFSET), + cornerRadiusOffset = getFloat(XposedKey.VOLUME_TRACK_CORNER_RADIUS_OFFSET), hideThumb = getBoolean(XposedKey.HIDE_VOLUME_SLIDER_THUMB) ) } @@ -90,6 +97,7 @@ class ComposeShapes(context: Context) : ModPack(context) { override fun handleLoadPackage(packageParam: PackageParam) { hookDimenOffsets() + hookFloatingVolumeSliderBackground() hookTileCornerRadius() hookSliderTrack() hookSliderThumb() @@ -170,6 +178,26 @@ class ComposeShapes(context: Context) : ModPack(context) { return shape } + @SuppressLint("DiscouragedApi") + private fun hookFloatingVolumeSliderBackground() { + val resources = mContext.resources + if (resources.getIdentifier(VOLUME_FLOATING_SLIDER_RADIUS_DIMEN, "dimen", SYSTEMUI_PACKAGE) != 0) return + if (resources.getIdentifier(VOLUME_FLOATING_SLIDER_LAYOUT, "layout", SYSTEMUI_PACKAGE) == 0) return + + hookLayout() + .packageName(SYSTEMUI_PACKAGE) + .resource("layout", VOLUME_FLOATING_SLIDER_LAYOUT) + .suppressError() + .run { param -> + val offset = volumeDialogCornerRadiusOffset + if (offset == 0f) return@run + + val background = param.view.background?.mutate() as? GradientDrawable ?: return@run + val offsetPx = offset * param.res.displayMetrics.density + background.cornerRadius = (background.cornerRadius + offsetPx).coerceAtLeast(0f) + } + } + private fun hookDimenOffsets() { val dimenHook = ResourceHookManager .hookDimen() @@ -182,9 +210,10 @@ class ComposeShapes(context: Context) : ModPack(context) { NOTIFICATION_RADIUS_DIMENS.forEach { dimenHook.addOffset(it) { notificationCornerRadiusOffset } } - VOLUME_RADIUS_DIMENS.forEach { - dimenHook.addOffset(it) { volumeSliderStyle.cornerRadiusOffset } + VOLUME_DIALOG_RADIUS_DIMENS.forEach { + dimenHook.addOffset(it) { volumeDialogCornerRadiusOffset } } + dimenHook.addOffset(VOLUME_RINGER_BUTTON_RADIUS_DIMEN) { volumeRingerButtonCornerRadiusOffset } dimenHook.apply() } @@ -465,13 +494,17 @@ class ComposeShapes(context: Context) : ModPack(context) { private const val INACTIVE_ICON_RADIUS_DIMEN = "common_tile_default_inactive_icon_corner_radius" private const val ICON_SHAPE_LABEL = "Icon" - private val VOLUME_RADIUS_DIMENS = listOf( + private val VOLUME_DIALOG_RADIUS_DIMENS = listOf( "volume_dialog_background_corner_radius", "volume_dialog_background_square_corner_radius", "volume_dialog_floating_slider_background_corner_radius", - "volume_dialog_horizontal_background_corner_radius", - "volume_dialog_ringer_selected_button_background_radius" + "volume_dialog_horizontal_background_corner_radius" ) + private const val VOLUME_FLOATING_SLIDER_RADIUS_DIMEN = + "volume_dialog_floating_slider_background_corner_radius" + private const val VOLUME_FLOATING_SLIDER_LAYOUT = "volume_dialog_slider_floating" + private const val VOLUME_RINGER_BUTTON_RADIUS_DIMEN = + "volume_dialog_ringer_selected_button_background_radius" private const val ROUNDED_CORNER_SHAPE_CLASS = "androidx.compose.foundation.shape.RoundedCornerShape" private const val CORNER_SIZE_CLASS = "androidx.compose.foundation.shape.CornerSize" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 4d623dc40..b4ddc4b6c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1093,8 +1093,9 @@ Hide Slider Thumb Brightness slider Shape & Slider - Corner Radius - Dialog, buttons and sliders + Dialog Radius + Track Radius + Ringer Button Radius Hide Slider Thumb Volume sliders Lock Screen