mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-06-05 21:59:19 +02:00
add a toggle for forcing portrait mode, enabled by default
This commit is contained in:
@ -41,9 +41,9 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation 'com.simplemobiletools:commons:3.18.8'
|
implementation 'com.simplemobiletools:commons:3.19.0'
|
||||||
implementation 'com.squareup:otto:1.3.8'
|
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()
|
Properties props = new Properties()
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.simplemobiletools.flashlight.activities
|
package com.simplemobiletools.flashlight.activities
|
||||||
|
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.graphics.drawable.ColorDrawable
|
import android.graphics.drawable.ColorDrawable
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.WindowManager
|
import android.view.WindowManager
|
||||||
@ -34,6 +35,10 @@ class BrightDisplayActivity : SimpleActivity() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
|
||||||
toggleBrightness(true)
|
toggleBrightness(true)
|
||||||
|
|
||||||
|
if (config.forcePortrait) {
|
||||||
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.simplemobiletools.flashlight.activities
|
package com.simplemobiletools.flashlight.activities
|
||||||
|
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
|
import android.content.pm.ActivityInfo
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
@ -68,6 +69,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
if (stroboscope_bar.isInvisible()) {
|
if (stroboscope_bar.isInvisible()) {
|
||||||
changeIconColor(config.backgroundColor.getContrastColor(), stroboscope_btn)
|
changeIconColor(config.backgroundColor.getContrastColor(), stroboscope_btn)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (config.forcePortrait) {
|
||||||
|
requestedOrientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStart() {
|
override fun onStart() {
|
||||||
|
@ -23,6 +23,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
setupTurnFlashlightOn()
|
setupTurnFlashlightOn()
|
||||||
setupBrightDisplay()
|
setupBrightDisplay()
|
||||||
setupStroboscope()
|
setupStroboscope()
|
||||||
|
setupForcePortrait()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,4 +74,12 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
config.stroboscope = settings_stroboscope.isChecked
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -147,5 +147,28 @@
|
|||||||
android:text="@string/show_stroboscope"/>
|
android:text="@string/show_stroboscope"/>
|
||||||
|
|
||||||
</RelativeLayout>
|
</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>
|
</LinearLayout>
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
@ -9,7 +9,7 @@ buildscript {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
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"
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
|
Reference in New Issue
Block a user