71 lines
2.7 KiB
Markdown
71 lines
2.7 KiB
Markdown
# Countdown Timer
|
|
|
|
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 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
|
|
- **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
|
|
|
|
### Prerequisites
|
|
- Android Studio (Ladybug or newer recommended)
|
|
- JDK 17
|
|
- An Android device or emulator running API level 24 or higher.
|
|
|
|
### Building the App
|
|
To build the debug APK from the command line:
|
|
```bash
|
|
./gradlew assembleDebug
|
|
```
|
|
|
|
### 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; 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
|
|
```
|