cleanup flash implementation

- fix issues with brightness control
- add separate classes for Android 5 and Android 6+ for simplicity
- properly cleanup camera in onDestory and also when stroboscope/flashlight mode are disabled
This commit is contained in:
darthpaul
2022-11-14 19:17:00 +00:00
parent 87b678e4bb
commit 98c0f0578e
5 changed files with 120 additions and 163 deletions

View File

@ -9,7 +9,6 @@ import android.graphics.drawable.LayerDrawable
import android.os.Bundle
import android.view.WindowManager
import android.widget.ImageView
import androidx.core.view.isVisible
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.LICENSE_EVENT_BUS
import com.simplemobiletools.commons.helpers.PERMISSION_CAMERA
@ -183,7 +182,7 @@ class MainActivity : SimpleActivity() {
private fun setupCameraImpl() {
mCameraImpl = MyCameraImpl.newInstance(this, object : CameraTorchListener {
override fun onTorchEnabled(isEnabled: Boolean) {
if (mCameraImpl?.supportsBrightnessControl() == true) {
if (mCameraImpl!!.supportsBrightnessControl()) {
brightness_bar.beVisibleIf(isEnabled)
}
}