File tree Expand file tree Collapse file tree
app/src/main/java/com/simplemobiletools/camera Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -78,4 +78,12 @@ public int getLastUsedCamera() {
7878 public void setLastUsedCamera (int cameraId ) {
7979 mPrefs .edit ().putInt (Constants .LAST_USED_CAMERA , cameraId ).apply ();
8080 }
81+
82+ public boolean getLastFlashlightState () {
83+ return mPrefs .getBoolean (Constants .LAST_FLASHLIGHT_STATE , false );
84+ }
85+
86+ public void setLastFlashlightState (boolean enabled ) {
87+ mPrefs .edit ().putBoolean (Constants .LAST_FLASHLIGHT_STATE , enabled ).apply ();
88+ }
8189}
Original file line number Diff line number Diff line change @@ -15,4 +15,5 @@ public class Constants {
1515 public static final String MAX_RESOLUTION = "max_resolution" ;
1616 public static final String MAX_VIDEO_RESOLUTION = "max_video_resolution" ;
1717 public static final String LAST_USED_CAMERA = "last_used_camera" ;
18+ public static final String LAST_FLASHLIGHT_STATE = "last_flashlight_state" ;
1819}
Original file line number Diff line number Diff line change @@ -172,6 +172,7 @@ private void initializeCamera() {
172172 mIsInPhotoMode = true ;
173173 mTimerHandler = new Handler ();
174174 mFadeHandler = new Handler ();
175+ mIsFlashEnabled = mConfig .getLastFlashlightState ();
175176 setupPreviewImage (true );
176177 }
177178
@@ -270,11 +271,15 @@ private void checkFlash() {
270271 private void disableFlash () {
271272 mPreview .disableFlash ();
272273 mToggleFlashBtn .setImageResource (R .mipmap .flash_off );
274+ mIsFlashEnabled = false ;
275+ mConfig .setLastFlashlightState (mIsFlashEnabled );
273276 }
274277
275278 private void enableFlash () {
276279 mPreview .enableFlash ();
277280 mToggleFlashBtn .setImageResource (R .mipmap .flash_on );
281+ mIsFlashEnabled = true ;
282+ mConfig .setLastFlashlightState (mIsFlashEnabled );
278283 }
279284
280285 @ OnClick (R .id .shutter )
@@ -547,6 +552,7 @@ private void resumeCameraItems() {
547552
548553 if (mPreview .setCamera (mCurrCamera )) {
549554 hideNavigationBarIcons ();
555+ checkFlash ();
550556
551557 if (mSensorManager != null ) {
552558 final Sensor accelerometer = mSensorManager .getDefaultSensor (Sensor .TYPE_ACCELEROMETER );
You can’t perform that action at this time.
0 commit comments