diff --git a/CLAUDE.md b/CLAUDE.md index ac81a92..aff759f 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -7,13 +7,13 @@ - **Run Unit Tests**: `./gradlew test` (if applicable) ## Code Style Guidelines -- **Language**: Kotlin 1.9+ +- **Language**: Kotlin 1.9.0 - **UI Framework**: Traditional Android View system (XML layouts), **not** Jetpack Compose. - **Naming Conventions**: - Classes: `PascalCase` (e.g., `CountdownDialog`) - Functions/Variables: `camelCase` (e.g., `startTimer()`) - Layout Files: `snake_case` (e.g., `activity_main.xml`) - - Resource IDs: `snake_case` (e.g., `btn_start`) + - Resource IDs: `camelCase` (e.g., `btnStart`, `cvCountdown`) - **Android Patterns**: Use `findViewById` for view binding in this project to maintain consistency with existing simple architecture. ## Architecture @@ -26,6 +26,7 @@ ## Critical Files Reference - `app/src/main/java/com/example/countdowntimer/MainActivity.kt`: Entry point and trigger for the timer. - `app/src/main/java/com/example/countdowntimer/CountdownDialog.kt`: Implementation of the countdown logic and `ToneGenerator` trigger. +- `app/src/main/java/com/example/countdowntimer/CountdownCanvasView.kt`: Custom view for the circular progress ring and countdown text. - `app/src/main/res/layout/activity_main.xml`: Main screen layout. - `app/src/main/res/layout/dialog_countdown.xml`: Timer dialog layout. - `app/build.gradle`: Build configuration, SDK versions (minSdk 24, targetSdk 34), and dependencies. diff --git a/README.md b/README.md index 06ea7a4..8d9a46b 100644 --- a/README.md +++ b/README.md @@ -3,12 +3,12 @@ A minimal Android application that demonstrates a simple countdown functionality with an audible alert. ## Description -The Countdown Timer app is a lightweight utility that launches a modal dialog to count down from 10 seconds. Once the timer reaches zero, the app plays a system error tone and closes the dialog. This project serves as a basic example of using `CountDownTimer`, `ToneGenerator`, and custom `Dialog` implementation in Android. +The Countdown Timer app is a lightweight utility that launches a modal dialog to count down from a user-selected duration (5s, 10s, 15s, or 30s). Once the timer reaches zero, the app plays a confirmation tone and vibration, then shows a dismiss button. This project serves as a basic example of using `CountDownTimer`, `ToneGenerator`, and custom `Dialog` implementation in Android. ## Key Features -- **Single-Action Interface**: A simple main screen with a start button. -- **Modal Countdown**: A non-cancelable dialog that prevents user interference during the countdown. -- **Audible Alert**: Integration with Android's `ToneGenerator` to play `TONE_SUP_ERROR` upon completion. +- **Selectable Duration**: A main screen with a duration picker (chip group) and a start button. +- **Modal Countdown**: A full-screen dialog with circular progress ring, stop/restart buttons, and a confirmation tone during the final 3 seconds. +- **Haptic Feedback**: Vibration on the last 3 seconds and on completion (configurable via shared preferences). - **Real-time Updates**: UI updates every second to reflect the remaining time. ## Getting Started @@ -25,19 +25,46 @@ To build the debug APK from the command line: ``` ### Running the App + +#### Via Android Studio 1. Open the project in Android Studio. 2. Select your target device/emulator. 3. Click the **Run** button or press `Shift + F10`. +#### Via ADB +First, ensure your device or emulator is connected (`adb devices`). Then install the debug APK and launch the app: + +```bash +# Install the debug APK +adb install -r app/build/outputs/apk/debug/app-debug.apk + +# Launch the app +adb shell am start -n com.example.countdowntimer.debug/com.example.countdowntimer.MainActivity +``` + +#### Taking a Screenshot via ADB +To capture a screenshot of the app from your host machine: + +```bash +# Take the screenshot on the device +adb shell screencap -p /sdcard/screenshot.png + +# Pull it to your host machine +adb pull /sdcard/screenshot.png screenshots/ +``` + ## Project Structure ```text app/ ├── src/ │ └── main/ │ ├── java/com/example/countdowntimer/ -│ │ ├── MainActivity.kt # Main entry point; launches the timer -│ │ └── CountdownDialog.kt # Logic for the 10s countdown and tone -│ ├── res/ # UI layouts and resources -│ └── AndroidManifest.xml # Application manifest -└── build.gradle # App-level build configuration +│ │ ├── MainActivity.kt # Main entry point; duration picker and timer trigger +│ │ ├── CountdownDialog.kt # Countdown logic, tone, and vibration +│ │ └── CountdownCanvasView.kt # Custom circular progress ring view +│ ├── res/layout/ # UI layouts +│ │ ├── activity_main.xml +│ │ └── dialog_countdown.xml +│ └── AndroidManifest.xml # Application manifest +└── build.gradle # App-level build configuration ``` diff --git a/app/src/main/res/drawable/ic_play_arrow_large.xml b/app/src/main/res/drawable/ic_play_arrow_large.xml new file mode 100644 index 0000000..4554905 --- /dev/null +++ b/app/src/main/res/drawable/ic_play_arrow_large.xml @@ -0,0 +1,10 @@ + + + diff --git a/app/src/main/res/drawable/outline_fire_check_24.xml b/app/src/main/res/drawable/outline_fire_check_24.xml new file mode 100644 index 0000000..0ea0d3e --- /dev/null +++ b/app/src/main/res/drawable/outline_fire_check_24.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index d14d7d1..e2376fa 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -22,7 +22,7 @@ app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" - app:layout_constraintWidth_percent="0.7"> + app:layout_constraintWidth_percent=".85"> + + + + + + + android:text="5s" + app:chipBackgroundColor="@color/chip_duration_bg" /> + android:minWidth="56dp" + android:text="10s" + app:chipBackgroundColor="@color/chip_duration_bg" /> + android:text="15s" + app:chipBackgroundColor="@color/chip_duration_bg" /> + android:text="30s" + app:chipBackgroundColor="@color/chip_duration_bg" />