Available widgets
Nimaz includes four main widgets:Prayer times widget
Display all five daily prayer times with countdown to next prayer
Next prayer widget
Show the upcoming prayer time with live countdown
Hijri date widget
Display today’s Hijri date with Gregorian date reference
Prayer tracker widget
Interactive widget to track completed prayers for the day
Widget architecture
All widgets follow a consistent architecture pattern:Jetpack Glance framework
Widgets are built using Jetpack Glance, which provides:- Composable UI similar to Jetpack Compose
- State management for widget data
- Automatic updates and refresh mechanisms
- Support for dynamic theming and styling
Component structure
Each widget consists of these core components:Widget class
Extends
GlanceAppWidget and defines the UI composable. Located at widget/{name}/{Name}Widget.kt.Widget receiver
Extends
GlanceAppWidgetReceiver and handles Android system callbacks. Registered in AndroidManifest.xml.State management
Widgets use a sealed interface pattern for state:Widget update mechanism
Periodic updates
Widgets use WorkManager for periodic data updates:- Default interval: 15 minutes (minimum allowed by WorkManager)
- Triggered on widget enable, system boot, and data changes
- Battery-efficient with system job scheduling
Live countdown updates
For widgets with countdown timers (Prayer Times and Next Prayer), a special update mechanism provides minute-by-minute updates:The countdown update mechanism uses
setInexactRepeating() for battery efficiency. This means updates may be slightly delayed but will be close to every minute.WidgetUpdateScheduler.kt at widget/WidgetUpdateScheduler.kt:20 for the full implementation.
Adding widgets to your home screen
Users can add widgets through the standard Android widget picker:Widget configuration
Widgets automatically reflect your app settings:- Location: Uses your configured location for prayer time calculations
- Calculation method: Respects your chosen calculation method
- Time format: Displays times in 12-hour or 24-hour format based on app settings
- Hijri date adjustment: Applies any Hijri date adjustments you’ve configured
Widgets inherit all settings from the main app. Changes to location, calculation method, or other settings will automatically reflect in widgets after their next update cycle.
Theming and colors
Widgets use Material You dynamic theming where available:- Background:
R.color.widget_background - Primary text:
R.color.widget_text - Secondary text:
R.color.widget_text_secondary - Accent color:
R.color.widget_primary
Data sources
Widgets fetch data from the app’s local database:- Prayer times: Calculated times stored in Room database
- Prayer records: User’s prayer completion status
- Hijri dates: Calculated dates with user adjustments
WidgetEntryPoint Hilt entry point to access DAOs:
Troubleshooting
Widget shows “Tap to setup”
This appears when:- Prayer times haven’t been calculated yet
- Location permission not granted
- No location configured in the app
Widget not updating
Possible causes:- Battery optimization restricting background work
- App data cleared
- System killing background processes
Countdown showing wrong time
This can happen if:- System time zone changed
- Device date/time is incorrect
- Prayer times need recalculation
Next steps
Explore the individual widget documentation:- Prayer times widget - Comprehensive daily prayer schedule
- Next prayer widget - Quick glance at upcoming prayer
- Hijri date widget - Islamic calendar on your home screen
- Prayer tracker widget - Interactive prayer completion tracking