Skip to content

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.

License

Notifications You must be signed in to change notification settings

samyak2403/FlashLightmine

Repository files navigation

FlashlightMine

Get it on GitHub

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.
  • Shake Detection: Shake your device to toggle the flashlight.
  • 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 (e.g., shake detection).

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:

    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. Shake Listener:

    • Uses the accelerometer sensor to detect device shakes.
    • Toggles the flashlight if a shake is detected above the threshold (2.5 G).
  3. 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.
  • 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:

Permissions

Add the following permissions in your AndroidManifest.xml file:

<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.FLASHLIGHT" />

How to Use

  1. Launch the app.
  2. Tap the ON/OFF button to toggle the flashlight.
  3. 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

License

This project is licensed under the MIT License - see the LICENSE file for details.

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages