Skip to content

Commit 57a904d

Browse files
committed
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
1 parent c3e8a84 commit 57a904d

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ class MainActivity : SimpleActivity() {
3232
private var mBus: Bus? = null
3333
private var mCameraImpl: MyCameraImpl? = null
3434
private var mIsFlashlightOn = false
35+
private var reTurnFlashlightOn = true
3536

3637
override fun onCreate(savedInstanceState: Bundle?) {
3738
super.onCreate(savedInstanceState)
@@ -42,6 +43,7 @@ class MainActivity : SimpleActivity() {
4243
changeIconColor(getContrastColor(), stroboscope_btn)
4344

4445
bright_display_btn.setOnClickListener {
46+
reTurnFlashlightOn = false
4547
startActivity(Intent(applicationContext, BrightDisplayActivity::class.java))
4648
}
4749

@@ -85,6 +87,11 @@ class MainActivity : SimpleActivity() {
8587

8688
requestedOrientation = if (config.forcePortraitMode) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else ActivityInfo.SCREEN_ORIENTATION_SENSOR
8789
invalidateOptionsMenu()
90+
91+
if(config.turnFlashlightOn && reTurnFlashlightOn){
92+
mCameraImpl!!.enableFlashlight()
93+
}
94+
reTurnFlashlightOn = true
8895
}
8996

9097
override fun onStart() {
@@ -141,10 +148,12 @@ class MainActivity : SimpleActivity() {
141148
}
142149

143150
private fun launchSettings() {
151+
reTurnFlashlightOn = false
144152
startActivity(Intent(applicationContext, SettingsActivity::class.java))
145153
}
146154

147155
private fun launchAbout() {
156+
reTurnFlashlightOn = false
148157
val licenses = LICENSE_OTTO
149158

150159
val faqItems = arrayListOf(

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ buildscript {
99
}
1010

1111
dependencies {
12-
classpath 'com.android.tools.build:gradle:3.6.1'
12+
classpath 'com.android.tools.build:gradle:3.6.3'
1313
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
1414

1515
// NOTE: Do not place your application dependencies here; they belong

0 commit comments

Comments
 (0)