A minimal Android home screen widget that displays the current battery percentage. Designed with accessibility in mind — large, high-contrast fonts and fully customizable colors.
- Battery percentage widget — always visible on your home screen
- Customizable font size — adjustable from 36sp to 120sp via seek bar
- Customizable colors — separate color pickers for text, background, and icon tint
- Low battery mode — automatically switches to alternate colors when battery drops to 20% or below
- Transparent background — option to make the widget background fully transparent
- Custom widget label — editable text displayed on the widget (localized)
- Language support — English (default) and Turkish, follows phone language
- Accessibility — content descriptions for TalkBack, high-contrast defaults, large touch targets
- Auto-refresh — updates every 60 seconds via AlarmManager + instant updates on battery change events
- Resizable widget — starts as 1×1, resizable in both directions
- Multiple instances — each widget instance can have its own settings
| Widget (Normal) | Widget (Low Battery) |
|---|---|
| White text on dark background | Red text on dark red background |
- Android 7.0 (API 24) or higher
- Android Studio (for building)
- Language: Kotlin
- Build: Gradle 8.2 with Kotlin DSL
- Min SDK: 24 (covers 99.2% of devices)
- Target SDK: 34
- Architecture: AppWidgetProvider + RemoteViews, SharedPreferences for per-widget settings
app/src/main/java/com/napptune/pilbox/
├── BatteryWidgetProvider.kt # Widget lifecycle, rendering, AlarmManager scheduling
├── BatteryReceiver.kt # Reads battery level from sticky broadcast
├── WidgetConfigureActivity.kt # Configuration screen (colors, font, label)
├── WidgetPreferences.kt # Per-widget SharedPreferences wrapper
├── ColorPickerDialog.kt # Reusable color picker (presets + RGB sliders)
└── MainActivity.kt # Launcher activity with setup instructions
./gradlew assembleDebug
./gradlew installDebug- Long-press an empty area on your home screen
- Tap Widgets
- Find Pil Box and drag it to your home screen
- Customize colors, font size, and label text
- Tap Save
# Set battery to 15%
adb shell dumpsys battery set level 15
# Set battery to 100%
adb shell dumpsys battery set level 100
# Reset to real readings
adb shell dumpsys battery resetThe widget updates every 60 seconds automatically, or immediately when the battery level changes.
When placing the widget, a configuration screen lets you adjust:
| Setting | Description | Default |
|---|---|---|
| Font Size | Battery percentage text size | 24sp |
| Text Color | Percentage text color (normal) | White |
| Background Color | Widget background (normal) | Semi-transparent black |
| Icon Color | Battery icon tint (normal) | White |
| Transparent Background | Removes background color | Off |
| Low Battery Text Color | Text color at ≤20% | Red |
| Low Battery Background | Background color at ≤20% | Semi-transparent dark red |
| Low Battery Icon Color | Icon tint at ≤20% | Red |
Tap the widget at any time to reopen the configuration screen.
| Language | Code | Status |
|---|---|---|
| English | en |
Default |
| Turkish | tr |
Full support |
This project is for personal use.