mirror of
				https://github.com/SimpleMobileTools/Simple-Camera.git
				synced 2025-06-27 09:02:59 +02:00 
			
		
		
		
	remember the last flashlight state
This commit is contained in:
		| @@ -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(); | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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"; | ||||
| } | ||||
|   | ||||
| @@ -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); | ||||
|   | ||||
		Reference in New Issue
	
	Block a user