add a toggle for forcing portrait mode, enabled by default

This commit is contained in:
tibbi 2018-04-15 20:29:26 +02:00
parent 1c5b98b0cf
commit 2dc9c18163
6 changed files with 45 additions and 3 deletions

View File

@ -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()

View File

@ -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() {

View File

@ -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() {

View File

@ -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
}
}
}

View File

@ -147,5 +147,28 @@
android:text="@string/show_stroboscope"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_force_portrait_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/activity_margin"
android:paddingLeft="@dimen/normal_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_force_portrait"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingLeft="@dimen/medium_margin"
android:paddingStart="@dimen/medium_margin"
android:text="@string/force_portrait_mode"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -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