add WeatherSmallWidget and WeatherHorizontalWidget to AndroidManifest and WeatherWidgetUpdater

This commit is contained in:
PranshulGG committed 2026-06-10 16:09:07 +05:30
1 parent b2fa8ede42
commit cd91bd3705
2 files changed
+51

No files matched your search

+28
View File
@@ -96,6 +96,34 @@
android:name="android.appwidget.provider"
android:resource="@xml/summary_widget_info" />
</receiver>
<receiver
android:name=".widgets.weathersmall.WeatherSmallWidgetReceiver"
android:label="Weather Small"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/weather_widget_small_info" />
</receiver>
<receiver
android:name=".widgets.weatherhorizontal.WeatherHorizontalWidgetReceiver"
android:label="Weather"
android:exported="true">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
</intent-filter>
<meta-data
android:name="android.appwidget.provider"
android:resource="@xml/weather_widget_horizontal_info" />
</receiver>
</application>
</manifest>
@@ -8,6 +8,10 @@ import com.pranshulgg.weather_master_app.widgets.WeatherWidgetStateJson
import com.pranshulgg.weather_master_app.widgets.pill.WidgetPill
import com.pranshulgg.weather_master_app.widgets.summary.SummaryWidget
import com.pranshulgg.weather_master_app.widgets.weather.WeatherWidget
import com.pranshulgg.weather_master_app.widgets.weatherhorizontal.WeatherHorizontalWidget
import com.pranshulgg.weather_master_app.widgets.weatherhorizontal.ui.WeatherWidgetHorizontal
import com.pranshulgg.weather_master_app.widgets.weathersmall.WeatherSmallWidget
import com.pranshulgg.weather_master_app.widgets.weathersmall.ui.WeatherWidgetSmall
class WeatherWidgetUpdater(
private val context: Context
@@ -16,6 +20,9 @@ class WeatherWidgetUpdater(
private val widget = WeatherWidget()
private val pill = WidgetPill()
private val summary = SummaryWidget()
private val widgetSmall = WeatherSmallWidget()
private val widgetHorizontal = WeatherHorizontalWidget()
suspend fun update(json: String) {
@@ -25,6 +32,8 @@ class WeatherWidgetUpdater(
val widgetIds = manager.getGlanceIds(WeatherWidget::class.java)
val pillIds = manager.getGlanceIds(WidgetPill::class.java)
val summaryIds = manager.getGlanceIds(SummaryWidget::class.java)
val widgetSmallIds = manager.getGlanceIds(WeatherSmallWidget::class.java)
val widgetHorizontalIds = manager.getGlanceIds(WeatherHorizontalWidget::class.java)
widgetIds.forEach {
updateAppWidgetState(context, WeatherWidgetStateDefinition, it) {
@@ -46,5 +55,19 @@ class WeatherWidgetUpdater(
}
summary.update(context, it)
}
widgetSmallIds.forEach {
updateAppWidgetState(context, WeatherWidgetStateDefinition, it) {
WeatherWidgetStateJson(json)
}
widgetSmall.update(context, it)
}
widgetHorizontalIds.forEach {
updateAppWidgetState(context, WeatherWidgetStateDefinition, it) {
WeatherWidgetStateJson(json)
}
widgetHorizontal.update(context, it)
}
}
}