diff --git a/app/build.gradle b/app/build.gradle index d593295..4d78e64 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -41,9 +41,9 @@ android { } dependencies { - implementation 'com.simplemobiletools:commons:3.18.8' + implementation 'com.simplemobiletools:commons:3.19.0' implementation 'com.squareup:otto:1.3.8' - implementation 'com.android.support.constraint:constraint-layout:1.0.2' + implementation 'com.android.support.constraint:constraint-layout:1.1.0' } Properties props = new Properties() diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt index cf5d051..4a18204 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/BrightDisplayActivity.kt @@ -1,5 +1,6 @@ package com.simplemobiletools.flashlight.activities +import android.content.pm.ActivityInfo import android.graphics.drawable.ColorDrawable import android.os.Bundle import android.view.WindowManager @@ -34,6 +35,10 @@ class BrightDisplayActivity : SimpleActivity() { super.onResume() window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON) toggleBrightness(true) + + if (config.forcePortrait) { + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + } } override fun onPause() { diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt index e645073..7695cc2 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/MainActivity.kt @@ -1,6 +1,7 @@ package com.simplemobiletools.flashlight.activities import android.content.Intent +import android.content.pm.ActivityInfo import android.os.Bundle import android.view.Menu import android.view.MenuItem @@ -68,6 +69,10 @@ class MainActivity : SimpleActivity() { if (stroboscope_bar.isInvisible()) { changeIconColor(config.backgroundColor.getContrastColor(), stroboscope_btn) } + + if (config.forcePortrait) { + requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT + } } override fun onStart() { diff --git a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/SettingsActivity.kt index b03fe8c..5dacd7e 100644 --- a/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/flashlight/activities/SettingsActivity.kt @@ -23,6 +23,7 @@ class SettingsActivity : SimpleActivity() { setupTurnFlashlightOn() setupBrightDisplay() setupStroboscope() + setupForcePortrait() updateTextColors(settings_holder) } @@ -73,4 +74,12 @@ class SettingsActivity : SimpleActivity() { config.stroboscope = settings_stroboscope.isChecked } } + + private fun setupForcePortrait() { + settings_force_portrait.isChecked = config.forcePortrait + settings_force_portrait_holder.setOnClickListener { + settings_force_portrait.toggle() + config.forcePortrait = settings_force_portrait.isChecked + } + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 4455dae..5124d0c 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -147,5 +147,28 @@ android:text="@string/show_stroboscope"/> + + + + + + diff --git a/build.gradle b/build.gradle index e6abf43..af56fd9 100644 --- a/build.gradle +++ b/build.gradle @@ -9,7 +9,7 @@ buildscript { } dependencies { - classpath 'com.android.tools.build:gradle:3.1.0' + classpath 'com.android.tools.build:gradle:3.1.1' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong