adding a setting item for toggling sos button visibility

This commit is contained in:
tibbi 2019-08-20 21:08:51 +02:00
parent 72dba0fa85
commit 1e20314694
4 changed files with 37 additions and 0 deletions

View File

@ -28,6 +28,7 @@ class SettingsActivity : SimpleActivity() {
setupTurnFlashlightOn()
setupBrightDisplay()
setupStroboscope()
setupSOS()
setupForcePortrait()
updateTextColors(settings_holder)
}
@ -88,6 +89,14 @@ class SettingsActivity : SimpleActivity() {
}
}
private fun setupSOS() {
settings_sos.isChecked = config.sos
settings_sos_holder.setOnClickListener {
settings_sos.toggle()
config.sos = settings_sos.isChecked
}
}
private fun setupForcePortrait() {
settings_force_portrait.isChecked = config.forcePortraitMode
settings_force_portrait_holder.setOnClickListener {

View File

@ -17,6 +17,10 @@ class Config(context: Context) : BaseConfig(context) {
get() = prefs.getBoolean(STROBOSCOPE, true)
set(stroboscope) = prefs.edit().putBoolean(STROBOSCOPE, stroboscope).apply()
var sos: Boolean
get() = prefs.getBoolean(SOS, true)
set(sos) = prefs.edit().putBoolean(SOS, sos).apply()
var turnFlashlightOn: Boolean
get() = prefs.getBoolean(TURN_FLASHLIGHT_ON, false)
set(turnFlashlightOn) = prefs.edit().putBoolean(TURN_FLASHLIGHT_ON, turnFlashlightOn).apply()

View File

@ -10,3 +10,4 @@ const val TOGGLE_WIDGET_UI = "toggle_widget_ui"
const val STROBOSCOPE_FREQUENCY = "stroboscope_frequency"
const val STROBOSCOPE_PROGRESS = "stroboscope_progress"
const val FORCE_PORTRAIT_MODE = "force_portrait_mode"
const val SOS = "sos"

View File

@ -167,6 +167,29 @@
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_sos_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingLeft="@dimen/normal_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingRight="@dimen/normal_margin"
android:paddingBottom="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MySwitchCompat
android:id="@+id/settings_sos"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@null"
android:clickable="false"
android:paddingStart="@dimen/medium_margin"
android:text="@string/show_sos"
app:switchPadding="@dimen/medium_margin"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_force_portrait_holder"
android:layout_width="match_parent"