Turn flashlight on at startup bug resolved

Turn flashlight on at startup preferece is chosen and user navigates away to other app and coming back to this appthen flashlight will be turned on again. This regards to  issue #71
This commit is contained in:
Indrajeet Meena 2020-05-25 17:33:21 +05:30
parent c3e8a84367
commit 57a904d6be
2 changed files with 10 additions and 1 deletions

View File

@ -32,6 +32,7 @@ class MainActivity : SimpleActivity() {
private var mBus: Bus? = null
private var mCameraImpl: MyCameraImpl? = null
private var mIsFlashlightOn = false
private var reTurnFlashlightOn = true
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -42,6 +43,7 @@ class MainActivity : SimpleActivity() {
changeIconColor(getContrastColor(), stroboscope_btn)
bright_display_btn.setOnClickListener {
reTurnFlashlightOn = false
startActivity(Intent(applicationContext, BrightDisplayActivity::class.java))
}
@ -85,6 +87,11 @@ class MainActivity : SimpleActivity() {
requestedOrientation = if (config.forcePortraitMode) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else ActivityInfo.SCREEN_ORIENTATION_SENSOR
invalidateOptionsMenu()
if(config.turnFlashlightOn && reTurnFlashlightOn){
mCameraImpl!!.enableFlashlight()
}
reTurnFlashlightOn = true
}
override fun onStart() {
@ -141,10 +148,12 @@ class MainActivity : SimpleActivity() {
}
private fun launchSettings() {
reTurnFlashlightOn = false
startActivity(Intent(applicationContext, SettingsActivity::class.java))
}
private fun launchAbout() {
reTurnFlashlightOn = false
val licenses = LICENSE_OTTO
val faqItems = arrayListOf(

View File

@ -9,7 +9,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong