Migrate to Material symbols
This commit is contained in:
@@ -42,7 +42,6 @@ dependencies {
|
||||
implementation(libs.bundles.kotlin)
|
||||
implementation(libs.androidx.core)
|
||||
implementation(libs.androidx.appcompat)
|
||||
implementation(libs.androidx.compose.materialicons)
|
||||
implementation(libs.bundles.androidx.lifecycle)
|
||||
|
||||
implementation(libs.koin.android)
|
||||
|
||||
@@ -2,6 +2,7 @@ package de.mm20.launcher2.badges
|
||||
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.Log
|
||||
import androidx.annotation.DrawableRes
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
|
||||
sealed interface BadgeIcon {
|
||||
@@ -9,12 +10,12 @@ sealed interface BadgeIcon {
|
||||
value class Drawable(val drawable: android.graphics.drawable.Drawable): BadgeIcon
|
||||
|
||||
@JvmInline
|
||||
value class Vector(val imageVector: ImageVector): BadgeIcon
|
||||
value class Vector(@DrawableRes val iconRes: Int): BadgeIcon
|
||||
}
|
||||
|
||||
fun BadgeIcon(drawable: Drawable): BadgeIcon = BadgeIcon.Drawable(drawable)
|
||||
|
||||
fun BadgeIcon(imageVector: ImageVector): BadgeIcon = BadgeIcon.Vector(imageVector)
|
||||
fun BadgeIcon(@DrawableRes iconRes: Int): BadgeIcon = BadgeIcon.Vector(iconRes)
|
||||
|
||||
interface Badge {
|
||||
val number: Int?
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
package de.mm20.launcher2.badges.providers
|
||||
|
||||
import android.content.Context
|
||||
import androidx.compose.material.icons.Icons
|
||||
import de.mm20.launcher2.badges.Badge
|
||||
import de.mm20.launcher2.badges.BadgeIcon
|
||||
import de.mm20.launcher2.badges.MutableBadge
|
||||
import de.mm20.launcher2.search.File
|
||||
import de.mm20.launcher2.search.Searchable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.flow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
|
||||
class CloudBadgeProvider(
|
||||
private val context: Context
|
||||
): BadgeProvider {
|
||||
) : BadgeProvider {
|
||||
override fun getBadge(searchable: Searchable): Flow<Badge?> {
|
||||
if (searchable is File) {
|
||||
val iconResId = searchable.providerIconRes
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
package de.mm20.launcher2.badges.providers
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.VisibilityOff
|
||||
import de.mm20.launcher2.badges.Badge
|
||||
import de.mm20.launcher2.badges.BadgeIcon
|
||||
import de.mm20.launcher2.badges.R
|
||||
import de.mm20.launcher2.search.SavableSearchable
|
||||
import de.mm20.launcher2.search.Searchable
|
||||
import de.mm20.launcher2.searchable.SavableSearchableRepository
|
||||
@@ -36,7 +35,7 @@ class HiddenItemBadgeProvider(
|
||||
return hiddenItemKeys.map { keys ->
|
||||
if (searchable.key in keys) {
|
||||
Badge(
|
||||
icon = BadgeIcon(Icons.Rounded.VisibilityOff)
|
||||
icon = BadgeIcon(R.drawable.visibility_off_20px)
|
||||
)
|
||||
} else {
|
||||
null
|
||||
|
||||
@@ -1,11 +1,8 @@
|
||||
package de.mm20.launcher2.badges.providers
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.Lock
|
||||
import androidx.compose.material.icons.rounded.Work
|
||||
import de.mm20.launcher2.badges.Badge
|
||||
import de.mm20.launcher2.badges.BadgeIcon
|
||||
import de.mm20.launcher2.icons.PrivateSpace
|
||||
import de.mm20.launcher2.badges.R
|
||||
import de.mm20.launcher2.profiles.Profile
|
||||
import de.mm20.launcher2.profiles.ProfileManager
|
||||
import de.mm20.launcher2.search.AppShortcut
|
||||
@@ -22,7 +19,7 @@ class ProfileBadgeProvider : BadgeProvider, KoinComponent {
|
||||
private val profileManager: ProfileManager by inject()
|
||||
|
||||
override fun getBadge(searchable: Searchable): Flow<Badge?> = flow {
|
||||
val userHandle = when(searchable) {
|
||||
val userHandle = when (searchable) {
|
||||
is Application -> searchable.user
|
||||
is AppShortcut -> searchable.user
|
||||
else -> null
|
||||
@@ -30,7 +27,7 @@ class ProfileBadgeProvider : BadgeProvider, KoinComponent {
|
||||
if (userHandle != null) {
|
||||
emitAll(
|
||||
profileManager.getProfile(userHandle).map {
|
||||
when(it?.type) {
|
||||
when (it?.type) {
|
||||
Profile.Type.Work -> WorkProfile
|
||||
Profile.Type.Private -> PrivateProfile
|
||||
else -> null
|
||||
@@ -44,11 +41,11 @@ class ProfileBadgeProvider : BadgeProvider, KoinComponent {
|
||||
|
||||
companion object {
|
||||
private val WorkProfile = Badge(
|
||||
icon = BadgeIcon(Icons.Rounded.Work)
|
||||
icon = BadgeIcon(R.drawable.enterprise_20px)
|
||||
)
|
||||
|
||||
private val PrivateProfile = Badge(
|
||||
icon = BadgeIcon(Icons.Rounded.PrivateSpace)
|
||||
icon = BadgeIcon(R.drawable.encrypted_20px)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package de.mm20.launcher2.badges.providers
|
||||
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.rounded.HourglassBottom
|
||||
import de.mm20.launcher2.badges.Badge
|
||||
import de.mm20.launcher2.badges.BadgeIcon
|
||||
import de.mm20.launcher2.badges.MutableBadge
|
||||
@@ -9,7 +7,6 @@ import de.mm20.launcher2.badges.R
|
||||
import de.mm20.launcher2.search.Application
|
||||
import de.mm20.launcher2.search.Searchable
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.channelFlow
|
||||
import kotlinx.coroutines.flow.flowOf
|
||||
import org.koin.core.component.KoinComponent
|
||||
|
||||
@@ -17,7 +14,7 @@ class SuspendedAppsBadgeProvider : BadgeProvider, KoinComponent {
|
||||
|
||||
override fun getBadge(searchable: Searchable): Flow<Badge?> {
|
||||
return if (searchable is Application && searchable.isSuspended) {
|
||||
flowOf(MutableBadge(icon = BadgeIcon(Icons.Rounded.HourglassBottom)))
|
||||
flowOf(MutableBadge(icon = BadgeIcon(R.drawable.hourglass_bottom_20px)))
|
||||
} else {
|
||||
flowOf(null)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user