Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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()
}
Expand All @@ -103,4 +112,4 @@ private fun VolumePanelScreenPreview() {
PreviewComposable {
VolumePanelScreen(null)
}
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand All @@ -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<Float, Any>? = null
Expand Down Expand Up @@ -77,19 +81,23 @@ 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)
)
}
}

override fun handleLoadPackage(packageParam: PackageParam) {
hookDimenOffsets()
hookFloatingVolumeSliderBackground()
hookTileCornerRadius()
hookSliderTrack()
hookSliderThumb()
Expand Down Expand Up @@ -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()
Expand All @@ -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()
}
Expand Down Expand Up @@ -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"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1093,8 +1093,9 @@
<string name="hide_qs_slider_thumb_title">Hide Slider Thumb</string>
<string name="hide_qs_slider_thumb_desc">Brightness slider</string>
<string name="section_title_volume_shape">Shape &amp; Slider</string>
<string name="volume_corner_radius_offset_title">Corner Radius</string>
<string name="volume_corner_radius_offset_desc">Dialog, buttons and sliders</string>
<string name="volume_dialog_radius_title">Dialog Radius</string>
<string name="volume_track_radius_title">Track Radius</string>
<string name="volume_ringer_button_radius_title">Ringer Button Radius</string>
<string name="hide_volume_slider_thumb_title">Hide Slider Thumb</string>
<string name="hide_volume_slider_thumb_desc">Volume sliders</string>
<string name="lock_screen">Lock Screen</string>
Expand Down
Loading