Skip to content

oktayx/PilBox

Repository files navigation

Pil Box

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.

Features

  • 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

Screenshots

Widget (Normal) Widget (Low Battery)
White text on dark background Red text on dark red background

Requirements

  • Android 7.0 (API 24) or higher
  • Android Studio (for building)

Tech Stack

  • 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

Project Structure

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

Getting Started

Build & Install

./gradlew assembleDebug
./gradlew installDebug

Add the Widget

  1. Long-press an empty area on your home screen
  2. Tap Widgets
  3. Find Pil Box and drag it to your home screen
  4. Customize colors, font size, and label text
  5. Tap Save

Test Battery Changes (Emulator)

# 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 reset

The widget updates every 60 seconds automatically, or immediately when the battery level changes.

Customization

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.

Languages

Language Code Status
English en Default
Turkish tr Full support

License

This project is for personal use.

About

A minimal, accessible Android home screen battery widget with customizable fonts and colors.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages