diff --git a/app/src/main/java/com/simplemobiletools/camera/Config.java b/app/src/main/java/com/simplemobiletools/camera/Config.java index 0bd24020..8abd6a8f 100644 --- a/app/src/main/java/com/simplemobiletools/camera/Config.java +++ b/app/src/main/java/com/simplemobiletools/camera/Config.java @@ -78,4 +78,12 @@ public class Config { public void setLastUsedCamera(int cameraId) { mPrefs.edit().putInt(Constants.LAST_USED_CAMERA, cameraId).apply(); } + + public boolean getLastFlashlightState() { + return mPrefs.getBoolean(Constants.LAST_FLASHLIGHT_STATE, false); + } + + public void setLastFlashlightState(boolean enabled) { + mPrefs.edit().putBoolean(Constants.LAST_FLASHLIGHT_STATE, enabled).apply(); + } } diff --git a/app/src/main/java/com/simplemobiletools/camera/Constants.java b/app/src/main/java/com/simplemobiletools/camera/Constants.java index caa6f3f5..1c3813e3 100644 --- a/app/src/main/java/com/simplemobiletools/camera/Constants.java +++ b/app/src/main/java/com/simplemobiletools/camera/Constants.java @@ -15,4 +15,5 @@ public class Constants { public static final String MAX_RESOLUTION = "max_resolution"; public static final String MAX_VIDEO_RESOLUTION = "max_video_resolution"; public static final String LAST_USED_CAMERA = "last_used_camera"; + public static final String LAST_FLASHLIGHT_STATE = "last_flashlight_state"; } diff --git a/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java b/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java index 69dd1529..4c0c0377 100644 --- a/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java +++ b/app/src/main/java/com/simplemobiletools/camera/activities/MainActivity.java @@ -172,6 +172,7 @@ public class MainActivity extends SimpleActivity mIsInPhotoMode = true; mTimerHandler = new Handler(); mFadeHandler = new Handler(); + mIsFlashEnabled = mConfig.getLastFlashlightState(); setupPreviewImage(true); } @@ -270,11 +271,15 @@ public class MainActivity extends SimpleActivity private void disableFlash() { mPreview.disableFlash(); mToggleFlashBtn.setImageResource(R.mipmap.flash_off); + mIsFlashEnabled = false; + mConfig.setLastFlashlightState(mIsFlashEnabled); } private void enableFlash() { mPreview.enableFlash(); mToggleFlashBtn.setImageResource(R.mipmap.flash_on); + mIsFlashEnabled = true; + mConfig.setLastFlashlightState(mIsFlashEnabled); } @OnClick(R.id.shutter) @@ -547,6 +552,7 @@ public class MainActivity extends SimpleActivity if (mPreview.setCamera(mCurrCamera)) { hideNavigationBarIcons(); + checkFlash(); if (mSensorManager != null) { final Sensor accelerometer = mSensorManager.getDefaultSensor(Sensor.TYPE_ACCELEROMETER);