Tweak camera control active state: true if not unavailable (#2871)

- Set the thumbnail template for the camera control to active as long as the camera isn't unavailable and the app was able to download an image, to show the camera image more often and better match the frontend.
This commit is contained in:
Joris Pelgröm 2022-09-10 21:18:45 +02:00 committed by GitHub
parent 6756e21112
commit 6a0ffd82b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -20,6 +20,7 @@ import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withContext
import kotlinx.coroutines.withTimeoutOrNull
import java.net.URL
import java.util.Locale
import java.util.concurrent.TimeUnit
import io.homeassistant.companion.android.common.R as commonR
@ -39,7 +40,7 @@ object CameraControl : HaControl {
"idle" -> context.getString(commonR.string.state_idle)
"recording" -> context.getString(commonR.string.state_recording)
"streaming" -> context.getString(commonR.string.state_streaming)
else -> entity.state
else -> entity.state.capitalize(Locale.getDefault())
}
)
@ -54,7 +55,7 @@ object CameraControl : HaControl {
control.setControlTemplate(
ThumbnailTemplate(
entity.entityId,
entity.state != "idle",
entity.state != "unavailable" && image != null,
icon,
context.getString(commonR.string.widget_camera_contentdescription)
)