Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up some left over code after update to getIcon #3827

Merged
merged 1 commit into from
Aug 31, 2023
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 @@ -154,18 +154,16 @@ fun getDomainList(
if (!domainIsEmpty) {
listBuilder.addItem(
GridItem.Builder().apply {
if (icon != null) {
setImage(
CarIcon.Builder(
IconicsDrawable(carContext, icon)
.apply {
sizeDp = 64
}.toAndroidIconCompat()
)
.setTint(CarColor.DEFAULT)
.build()
setImage(
CarIcon.Builder(
IconicsDrawable(carContext, icon)
.apply {
sizeDp = 64
}.toAndroidIconCompat()
)
}
.setTint(CarColor.DEFAULT)
.build()
)
}
.setTitle(friendlyDomain)
.setOnClickListener {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.utils.sizeDp
import com.mikepenz.iconics.utils.toAndroidIconCompat
import io.homeassistant.companion.android.common.R
Expand Down Expand Up @@ -164,7 +163,7 @@ class EntityGridVehicleScreen(
Log.i(TAG, "Grid limit ($gridLimit) reached, not adding more entities (${entities.size}) for $title ")
return@forEachIndexed
}
val icon = entity.getIcon(carContext) ?: CommunityMaterial.Icon.cmd_cloud_question
val icon = entity.getIcon(carContext)
val gridItem =
GridItem.Builder()
.setLoading(false)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.utils.sizeDp
import com.mikepenz.iconics.utils.toAndroidIconCompat
import io.homeassistant.companion.android.common.R
Expand Down Expand Up @@ -93,7 +92,7 @@ class MapVehicleScreen(
Log.i(TAG, "Grid limit ($gridLimit) reached, not adding any more navigation entities (${entities.size})")
return@forEachIndexed
}
val icon = pair.first.getIcon(carContext) ?: CommunityMaterial.Icon.cmd_account
val icon = pair.first.getIcon(carContext)
gridBuilder.addItem(
GridItem.Builder()
.setTitle(pair.first.friendlyName)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import androidx.wear.watchface.complications.data.ShortTextComplicationData
import androidx.wear.watchface.complications.datasource.ComplicationRequest
import androidx.wear.watchface.complications.datasource.SuspendingComplicationDataSourceService
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.utils.colorInt
import dagger.hilt.android.AndroidEntryPoint
import io.homeassistant.companion.android.common.R
Expand Down Expand Up @@ -69,7 +68,7 @@ class EntityStateDataSourceService : SuspendingComplicationDataSourceService() {
null
}

val icon = entity.getIcon(applicationContext) ?: CommunityMaterial.Icon.cmd_bookmark
val icon = entity.getIcon(applicationContext)
val iconBitmap = IconicsDrawable(this, icon).apply {
colorInt = Color.WHITE
}.toBitmap()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun MainConfigView(
modifier = Modifier.fillMaxWidth(),
icon = {
Image(
asset = iconBitmap ?: CommunityMaterial.Icon.cmd_bookmark,
asset = iconBitmap,
colorFilter = ColorFilter.tint(wearColorPalette.onSurface)
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ fun MainView(
.fillMaxWidth(),
icon = {
Image(
asset = getIcon(cached?.icon, favoriteEntityID.split(".")[0], context) ?: CommunityMaterial.Icon.cmd_bookmark,
asset = getIcon(cached?.icon, favoriteEntityID.split(".")[0], context),
colorFilter = ColorFilter.tint(wearColorPalette.onSurface)
)
},
Expand Down Expand Up @@ -272,7 +272,7 @@ fun MainView(
"",
domain,
context
)?.let { Image(asset = it) }
).let { Image(asset = it) }
},
label = {
Text(text = mainViewModel.stringForDomain(domain)!!)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import androidx.wear.compose.material.Text
import androidx.wear.compose.material.ToggleChip
import androidx.wear.compose.material.ToggleChipDefaults
import com.mikepenz.iconics.compose.Image
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import io.homeassistant.companion.android.common.data.integration.Entity
import io.homeassistant.companion.android.common.data.integration.getIcon
import io.homeassistant.companion.android.home.MainViewModel
Expand Down Expand Up @@ -100,7 +99,7 @@ private fun FavoriteToggleChip(
.fillMaxWidth(),
appIcon = {
Image(
asset = iconBitmap ?: CommunityMaterial.Icon.cmd_bookmark,
asset = iconBitmap,
colorFilter = ColorFilter.tint(wearColorPalette.onSurface)
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ fun SetShortcutsTileView(
.fillMaxWidth(),
icon = {
Image(
iconBitmap ?: CommunityMaterial.Icon.cmd_bookmark,
iconBitmap,
colorFilter = ColorFilter.tint(Color.White)
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import androidx.wear.tiles.TileService
import com.google.common.util.concurrent.ListenableFuture
import com.mikepenz.iconics.IconicsColor
import com.mikepenz.iconics.IconicsDrawable
import com.mikepenz.iconics.typeface.library.community.material.CommunityMaterial
import com.mikepenz.iconics.utils.backgroundColor
import com.mikepenz.iconics.utils.colorInt
import com.mikepenz.iconics.utils.sizeDp
Expand Down Expand Up @@ -117,7 +116,7 @@ class ShortcutsTile : TileService() {
entity.icon,
entity.domain,
this@ShortcutsTile
) ?: CommunityMaterial.Icon.cmd_bookmark
)
val iconBitmap = IconicsDrawable(this@ShortcutsTile, iconIIcon).apply {
colorInt = Color.WHITE
sizeDp = iconSize.roundToInt()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ fun stringForDomain(domain: String, context: Context): String? =
)
)[domain]?.let { context.getString(it) }

fun getIcon(icon: String?, domain: String, context: Context): IIcon? {
fun getIcon(icon: String?, domain: String, context: Context): IIcon {
val simpleEntity = Entity(
"$domain.ha_android_placeholder",
"",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private fun ChooseEntityChip(
.fillMaxWidth(),
icon = {
Image(
asset = iconBitmap ?: CommunityMaterial.Icon.cmd_bookmark,
asset = iconBitmap,
colorFilter = ColorFilter.tint(Color.White)
)
},
Expand Down