Skip to content

Conversation

@yoyo53
Copy link

@yoyo53 yoyo53 commented Dec 29, 2025

This commit adds a new user setting to fix devices where the flashlight ignores brightness level changes when using turnOnTorchWithStrengthLevel().

Problem:
On some Android devices, calling turnOnTorchWithStrengthLevel() when the torch is off results in the torch turning on at default brightness instead of the requested level. The Quick Settings tile was particularly affected, always activating at default level instead of the configured preferred level.

Solution:

  • Added new 'Fix brightness control' setting (disabled by default)
  • When enabled and torch is OFF, the code now calls setTorchMode(true) before turnOnTorchWithStrengthLevel() to ensure the level is applied correctly
  • Optimization: Pre-activation only happens when torch is currently off, avoiding unnecessary flickering when changing levels during active use

Changes:

  • Safe.kt: Added TORCH_PREACTIVATION constant
  • strings.xml: Added user-friendly setting strings
  • preferences.xml: Added switch preference in Flashlight controls category
  • Camera.kt: Refactored sendLightLevel() methods to accept preactivate parameter
  • MainActivity.kt: Load and pass setting to all torch activation calls
  • SettingsTile.kt: Read setting and apply pre-activation logic
  • VolumeButtonService.kt: Read setting and pass to Camera.sendLightLevel()

The setting is automatically reloaded in onResume() so changes take effect immediately without requiring app restart.

…issues

This commit adds a new user setting to fix devices where the flashlight
ignores brightness level changes when using turnOnTorchWithStrengthLevel().

Problem:
On some Android devices, calling turnOnTorchWithStrengthLevel() when the
torch is off results in the torch turning on at default brightness instead
of the requested level. The Quick Settings tile was particularly affected,
always activating at default level instead of the configured preferred level.

Solution:
- Added new 'Fix brightness control' setting (disabled by default)
- When enabled and torch is OFF, the code now calls setTorchMode(true) before
  turnOnTorchWithStrengthLevel() to ensure the level is applied correctly
- Optimization: Pre-activation only happens when torch is currently off,
  avoiding unnecessary flickering when changing levels during active use

Changes:
- Safe.kt: Added TORCH_PREACTIVATION constant
- strings.xml: Added user-friendly setting strings
- preferences.xml: Added switch preference in Flashlight controls category
- Camera.kt: Refactored sendLightLevel() methods to accept preactivate parameter
- MainActivity.kt: Load and pass setting to all torch activation calls
- SettingsTile.kt: Read setting and apply pre-activation logic
- VolumeButtonService.kt: Read setting and pass to Camera.sendLightLevel()

The setting is automatically reloaded in onResume() so changes take effect
immediately without requiring app restart.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant