Add favorites widget
This commit is contained in:
@@ -24,6 +24,7 @@ sealed class Widget {
|
||||
"weather" -> WeatherWidget
|
||||
"music" -> MusicWidget
|
||||
"calendar" -> CalendarWidget
|
||||
"favorites" -> FavoritesWidget
|
||||
else -> null
|
||||
}
|
||||
} else {
|
||||
@@ -132,6 +133,24 @@ object CalendarWidget : Widget() {
|
||||
}
|
||||
}
|
||||
|
||||
object FavoritesWidget : Widget() {
|
||||
override fun loadLabel(context: Context): String {
|
||||
return context.getString(R.string.widget_name_favorites)
|
||||
}
|
||||
|
||||
override fun toDatabaseEntity(position: Int): WidgetEntity {
|
||||
return WidgetEntity(
|
||||
type = WidgetType.INTERNAL.value,
|
||||
data = "favorites",
|
||||
height = -1,
|
||||
position = position
|
||||
)
|
||||
}
|
||||
|
||||
override val isConfigurable: Boolean = false
|
||||
}
|
||||
|
||||
|
||||
class ExternalWidget(
|
||||
var height: Int,
|
||||
val widgetId: Int,
|
||||
|
||||
@@ -14,6 +14,7 @@ interface WidgetRepository {
|
||||
fun removeWidget(widget: Widget)
|
||||
fun setWidgetHeight(widget: Widget, newHeight: Int)
|
||||
fun isCalendarWidgetEnabled(): Flow<Boolean>
|
||||
fun isFavoritesWidgetEnabled(): Flow<Boolean>
|
||||
}
|
||||
|
||||
internal class WidgetRepositoryImpl(
|
||||
@@ -30,7 +31,7 @@ internal class WidgetRepositoryImpl(
|
||||
}
|
||||
|
||||
override fun getInternalWidgets(): List<Widget> {
|
||||
return listOf(WeatherWidget, MusicWidget, CalendarWidget)
|
||||
return listOf(WeatherWidget, MusicWidget, CalendarWidget, FavoritesWidget)
|
||||
}
|
||||
|
||||
|
||||
@@ -81,4 +82,8 @@ internal class WidgetRepositoryImpl(
|
||||
return database.widgetDao().exists("internal", "calendar")
|
||||
}
|
||||
|
||||
override fun isFavoritesWidgetEnabled(): Flow<Boolean> {
|
||||
return database.widgetDao().exists("internal", "favorites")
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user