Merge pull request #111 from im-indrajeet/master

Turn flashlight on at startup  bug resolved
This commit is contained in:
Tibor Kaputa 2020-08-20 10:24:13 +02:00 committed by GitHub
commit ba780f4c70
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 0 deletions

View File

@ -36,6 +36,7 @@ class MainActivity : SimpleActivity() {
private var mBus: EventBus? = null private var mBus: EventBus? = null
private var mCameraImpl: MyCameraImpl? = null private var mCameraImpl: MyCameraImpl? = null
private var mIsFlashlightOn = false private var mIsFlashlightOn = false
private var reTurnFlashlightOn = true
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -46,6 +47,7 @@ class MainActivity : SimpleActivity() {
changeIconColor(getContrastColor(), stroboscope_btn) changeIconColor(getContrastColor(), stroboscope_btn)
bright_display_btn.setOnClickListener { bright_display_btn.setOnClickListener {
reTurnFlashlightOn = false
startActivity(Intent(applicationContext, BrightDisplayActivity::class.java)) startActivity(Intent(applicationContext, BrightDisplayActivity::class.java))
} }
@ -89,6 +91,13 @@ class MainActivity : SimpleActivity() {
requestedOrientation = if (config.forcePortraitMode) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else ActivityInfo.SCREEN_ORIENTATION_SENSOR requestedOrientation = if (config.forcePortraitMode) ActivityInfo.SCREEN_ORIENTATION_PORTRAIT else ActivityInfo.SCREEN_ORIENTATION_SENSOR
invalidateOptionsMenu() invalidateOptionsMenu()
if(config.turnFlashlightOn && reTurnFlashlightOn) {
mCameraImpl!!.enableFlashlight()
}
reTurnFlashlightOn = true
checkShortcuts() checkShortcuts()
} }
@ -146,10 +155,12 @@ class MainActivity : SimpleActivity() {
} }
private fun launchSettings() { private fun launchSettings() {
reTurnFlashlightOn = false
startActivity(Intent(applicationContext, SettingsActivity::class.java)) startActivity(Intent(applicationContext, SettingsActivity::class.java))
} }
private fun launchAbout() { private fun launchAbout() {
reTurnFlashlightOn = false
val licenses = LICENSE_EVENT_BUS val licenses = LICENSE_EVENT_BUS
val faqItems = arrayListOf( val faqItems = arrayListOf(