Implement flashlight state persistence with camera timing fix
Add comprehensive flashlight state persistence functionality to maintain flashlight on/off state across app
sessions and activity lifecycle events.
Key Changes:
• Add flashlight preference constants and helper methods in Constants.java and PreferencesHelper.java
• Implement automatic state saving when flashlight is toggled via toggleFlashlight() method
• Add loadFlashlightSettings() method with detailed logging for state restoration debugging
• Fix critical timing issue by moving flashlight restoration from onResume() to bindPreviewUseCase()
• Ensure flashlight state loads after camera is properly bound and flash unit is available
• Add comprehensive debug logging throughout save/restore operations for troubleshooting
Technical Details:
• Flashlight state now persists in SharedPreferences using SHARED_PREFERENCES_FLASHLIGHT_ENABLED key
• State restoration occurs after camera.bindToLifecycle() completes to ensure flash unit availability
• Enhanced error handling and logging for camera torch operations and preference access
• Maintains consistent behavior with existing capture zone persistence patterns
Result: Flashlight toggle state now properly persists across app restarts, activity pauses, and navigation events,
providing seamless user experience with maintained lighting preferences.