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 @@ -45,8 +45,8 @@ sealed interface Action {
}

data class DimWallpaper(val dimAmount: Float = 0f) : Action {
override val title: Int = R.string.diy_action_dim_wallpaper
override val icon: Int = R.drawable.rounded_mobile_screensaver_24
override val title: Int get() = R.string.diy_action_dim_wallpaper
override val icon: Int get() = R.drawable.rounded_mobile_screensaver_24
override val permissions: List<String> = listOf("shizuku", "root")
override val isConfigurable: Boolean = true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import com.sameerasw.essentials.ui.components.containers.RoundedCardContainer
import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenu
import com.sameerasw.essentials.ui.components.menus.SegmentedDropdownMenuItem
import com.sameerasw.essentials.utils.HapticUtil
import androidx.compose.ui.platform.LocalContext

@OptIn(ExperimentalFoundationApi::class)
@Composable
Expand Down Expand Up @@ -167,8 +168,17 @@ fun AutomationItem(
.fillMaxHeight(),
verticalAlignment = Alignment.CenterVertically
) {
val context = LocalContext.current
val validatedIcon = remember(icon) {
try {
if (context.resources.getResourceTypeName(icon) == "drawable") icon
else R.drawable.rounded_do_not_disturb_on_24
} catch (e: Exception) {
R.drawable.rounded_do_not_disturb_on_24
}
}
Icon(
painter = painterResource(id = icon),
painter = painterResource(id = validatedIcon),
contentDescription = null,
modifier = Modifier.size(24.dp),
tint = MaterialTheme.colorScheme.onSecondaryContainer
Expand Down Expand Up @@ -281,8 +291,18 @@ fun ActionItem(
modifier = Modifier.padding(12.dp),
verticalAlignment = Alignment.CenterVertically
) {
val context = LocalContext.current
val iconId = action?.icon ?: R.drawable.rounded_do_not_disturb_on_24
val validatedIcon = remember(iconId) {
try {
if (context.resources.getResourceTypeName(iconId) == "drawable") iconId
else R.drawable.rounded_do_not_disturb_on_24
} catch (e: Exception) {
R.drawable.rounded_do_not_disturb_on_24
}
}
Icon(
painter = painterResource(id = action?.icon ?: R.drawable.rounded_do_not_disturb_on_24),
painter = painterResource(id = validatedIcon),
contentDescription = null,
modifier = Modifier.size(24.dp),
tint = MaterialTheme.colorScheme.onSurface
Expand Down