mirror of
				https://github.com/SimpleMobileTools/Simple-Flashlight.git
				synced 2025-06-05 21:59:19 +02:00 
			
		
		
		
	fix(#165): fix flashlight status after coming back from camera app
This commit is contained in:
		| @@ -198,6 +198,10 @@ class MainActivity : SimpleActivity() { | ||||
|                     brightness_bar.beVisibleIf(isEnabled) | ||||
|                 } | ||||
|             } | ||||
|  | ||||
|             override fun onTorchUnavailable() { | ||||
|                 mCameraImpl!!.onCameraNotAvailable() | ||||
|             } | ||||
|         }) | ||||
|         if (config.turnFlashlightOn) { | ||||
|             mCameraImpl!!.enableFlashlight() | ||||
| @@ -300,7 +304,7 @@ class MainActivity : SimpleActivity() { | ||||
|     } | ||||
|  | ||||
|     private fun changeIconColor(color: Int, imageView: ImageView?) { | ||||
|         imageView!!.background.mutate().applyColorFilter(color) | ||||
|         imageView!!.background.applyColorFilter(color) | ||||
|     } | ||||
|  | ||||
|     @SuppressLint("NewApi") | ||||
|   | ||||
| @@ -21,6 +21,10 @@ internal class CameraFlash( | ||||
|         override fun onTorchModeChanged(cameraId: String, enabled: Boolean) { | ||||
|             cameraTorchListener?.onTorchEnabled(enabled) | ||||
|         } | ||||
|  | ||||
|         override fun onTorchModeUnavailable(cameraId: String) { | ||||
|             cameraTorchListener?.onTorchUnavailable() | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     init { | ||||
|   | ||||
| @@ -2,4 +2,6 @@ package com.simplemobiletools.flashlight.helpers | ||||
|  | ||||
| interface CameraTorchListener { | ||||
|     fun onTorchEnabled(isEnabled:Boolean) | ||||
|  | ||||
|     fun onTorchUnavailable() | ||||
| } | ||||
|   | ||||
| @@ -276,4 +276,8 @@ class MyCameraImpl private constructor(val context: Context, private var cameraT | ||||
|     fun updateBrightnessLevel(level: Int) { | ||||
|         cameraFlash!!.changeTorchBrightness(level) | ||||
|     } | ||||
|  | ||||
|     fun onCameraNotAvailable() { | ||||
|         disableFlashlight() | ||||
|     } | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user