https://github.com/samyak2403/flashlightmine
FlashlightMine is an Android application that allows users to toggle their device flashlight using a button or by shaking the device. The app provides a simple and interactive UI for this purpose.
https://github.com/samyak2403/flashlightmine
amdroid android android-application app application flashlig flashlight flashlight-app flashlight-application freeapps kotlin-android kotlin-multiplatform samyak2403 samyakkamble
Last synced: 2 months ago
JSON representation
FlashlightMine is an Android application that allows users to toggle their device flashlight using a button or by shaking the device. The app provides a simple and interactive UI for this purpose.
- Host: GitHub
- URL: https://github.com/samyak2403/flashlightmine
- Owner: samyak2403
- License: mit
- Created: 2025-01-19T04:17:29.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2026-01-30T13:12:01.000Z (5 months ago)
- Last Synced: 2026-01-30T23:09:05.213Z (5 months ago)
- Topics: amdroid, android, android-application, app, application, flashlig, flashlight, flashlight-app, flashlight-application, freeapps, kotlin-android, kotlin-multiplatform, samyak2403, samyakkamble
- Language: Kotlin
- Homepage:
- Size: 12.6 MB
- Stars: 7
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# FlashlightMine

[
](https://f-droid.org/packages/com.samyak2403.flashlightmine)
[
](https://apt.izzysoft.de/fdroid/index/apk/com.samyak2403.flashlightmine)
[
](https://github.com/samyak2403/FlashLightmine/releases/latest)
FlashlightMine is an Android application that allows users to toggle their device flashlight using a button or by shaking the device. The app provides a simple and interactive UI for this purpose.
## Features
- **Flashlight Control**: Turn the flashlight ON/OFF with a button.
- **Pull Rope Interaction**: Drag the lightbulb or line like a pull-cord switch to toggle the flashlight with realistic spring animations.
- **Shake Detection**: Shake your device to toggle the flashlight.
- **Interactive Tutorial**: A spotlight tutorial guides first-time users on how to use the pull-to-toggle feature.
- **Dynamic UI**:
- Changes the background color and light bulb icon based on flashlight status.
- Updates the status bar color dynamically.
- Applies dynamic tint to UI elements for better visual feedback.
- **Snackbar Notifications**: Inform users about additional functionalities.
## Screenshots
## Getting Started
### Prerequisites
- Android Studio installed on your computer.
- A device with a flashlight and accelerometer sensor (or an emulator with simulated hardware).
### Installation
1. Clone this repository:
```bash
git clone https://github.com/samyak2403/FlashLightmine.git
```
2. Open the project in Android Studio.
3. Build and run the project on a compatible Android device or emulator.
## Code Overview
### MainActivity
The primary activity handles the following:
1. **Flashlight Control**:
- Toggles the flashlight using the `CameraManager` API.
- Updates the UI to reflect the flashlight status.
2. **Pull Rope Animation**:
- Implements a drag-and-release mechanic using `OnTouchListener`.
- Uses `SpringAnimation` for realistic bounce-back effects.
- Stretches the rope (`line_5`) and moves the lightbulb in sync for a fluid physics-based feel.
3. **Showcase Tutorial**:
- Displays a feature discovery overlay using `TapTargetView` on the first launch.
4. **Shake Listener**:
- Uses the accelerometer sensor to detect device shakes.
- Toggles the flashlight if a shake is detected above the threshold (2.5 G).
5. **Dynamic UI Updates**:
- Changes background color and status dynamically.
- Updates the tint of decorative ellipses based on flashlight state.
### Key Functions
- `toggleFlashlight()`: Toggles the flashlight and updates the UI.
- `setupPullRopeAnimation()`: Configures touch listeners and physics-based animations for the pull-cord interaction.
- `snapBackWithSpring()`: Handles the spring snap-back animation for the rope and bulb.
- `showTutorialIfFirstLaunch()`: Checks shared preferences to display the onboarding tutorial once.
- `setupShakeListener()`: Registers a sensor listener to detect shakes.
- `setEllipsesTint(isFlashlightOn: Boolean)`: Updates the tint of UI ellipses.
## Dependencies
This app uses the following Android libraries:
- [Material Components](https://material.io/develop/android) for Snackbar and UI design.
- [Camera2 API](https://developer.android.com/reference/android/hardware/camera2/package-summary) for flashlight control.
- [Dynamic Animation](https://developer.android.com/jetpack/androidx/releases/dynamicanimation) for spring physics animations.
- [TapTargetView](https://github.com/KeepSafe/TapTargetView) for feature discovery tutorials.
## Permissions
Add the following permissions in your `AndroidManifest.xml` file:
```xml
```
## How to Use
1. Launch the app.
2. **Pull the Rope**: specificially, drag the lightbulb down and release it to toggle the flashlight.
3. Tap the ON/OFF button to toggle the flashlight.
4. Shake your device to toggle the flashlight dynamically.
## Future Enhancements
- Add customization for shake sensitivity.
- Include more dynamic animations for better user interaction.
## Author
[Samyak Kamble](https://github.com/samyak2403/)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.