mirror of
https://github.com/SimpleMobileTools/Simple-Flashlight.git
synced 2025-06-05 21:59:19 +02:00
add a toggle for turning flashlight on at startup
This commit is contained in:
@ -127,8 +127,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
|
|
||||||
private fun setupCameraImpl() {
|
private fun setupCameraImpl() {
|
||||||
mCameraImpl = MyCameraImpl.newInstance(this)
|
mCameraImpl = MyCameraImpl.newInstance(this)
|
||||||
|
if (config.turnFlashlightOn) {
|
||||||
mCameraImpl!!.enableFlashlight()
|
mCameraImpl!!.enableFlashlight()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupStroboscope() {
|
private fun setupStroboscope() {
|
||||||
stroboscope_btn.setOnClickListener {
|
stroboscope_btn.setOnClickListener {
|
||||||
|
@ -20,6 +20,7 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
|
|
||||||
setupCustomizeColors()
|
setupCustomizeColors()
|
||||||
setupUseEnglish()
|
setupUseEnglish()
|
||||||
|
setupTurnFlashlightOn()
|
||||||
setupBrightDisplay()
|
setupBrightDisplay()
|
||||||
setupStroboscope()
|
setupStroboscope()
|
||||||
updateTextColors(settings_holder)
|
updateTextColors(settings_holder)
|
||||||
@ -41,6 +42,14 @@ class SettingsActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun setupTurnFlashlightOn() {
|
||||||
|
settings_turn_flashlight_on.isChecked = config.turnFlashlightOn
|
||||||
|
settings_turn_flashlight_on_holder.setOnClickListener {
|
||||||
|
settings_turn_flashlight_on.toggle()
|
||||||
|
config.turnFlashlightOn = settings_turn_flashlight_on.isChecked
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun setupBrightDisplay() {
|
private fun setupBrightDisplay() {
|
||||||
settings_bright_display.isChecked = config.brightDisplay
|
settings_bright_display.isChecked = config.brightDisplay
|
||||||
settings_bright_display_holder.setOnClickListener {
|
settings_bright_display_holder.setOnClickListener {
|
||||||
|
@ -15,4 +15,8 @@ class Config(context: Context) : BaseConfig(context) {
|
|||||||
var stroboscope: Boolean
|
var stroboscope: Boolean
|
||||||
get() = prefs.getBoolean(STROBOSCOPE, true)
|
get() = prefs.getBoolean(STROBOSCOPE, true)
|
||||||
set(stroboscope) = prefs.edit().putBoolean(STROBOSCOPE, stroboscope).apply()
|
set(stroboscope) = prefs.edit().putBoolean(STROBOSCOPE, stroboscope).apply()
|
||||||
|
|
||||||
|
var turnFlashlightOn: Boolean
|
||||||
|
get() = prefs.getBoolean(TURN_FLASHLIGHT_ON, false)
|
||||||
|
set(turnFlashlightOn) = prefs.edit().putBoolean(TURN_FLASHLIGHT_ON, turnFlashlightOn).apply()
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,8 @@
|
|||||||
package com.simplemobiletools.flashlight.helpers
|
package com.simplemobiletools.flashlight.helpers
|
||||||
|
|
||||||
val BRIGHT_DISPLAY = "bright_display"
|
const val BRIGHT_DISPLAY = "bright_display"
|
||||||
val STROBOSCOPE = "stroboscope"
|
const val STROBOSCOPE = "stroboscope"
|
||||||
val IS_ENABLED = "is_enabled"
|
const val TURN_FLASHLIGHT_ON = "turn_flashlight_on"
|
||||||
val TOGGLE = "toggle"
|
const val IS_ENABLED = "is_enabled"
|
||||||
val TOGGLE_WIDGET_UI = "toggle_widget_ui"
|
const val TOGGLE = "toggle"
|
||||||
|
const val TOGGLE_WIDGET_UI = "toggle_widget_ui"
|
||||||
|
@ -50,6 +50,26 @@
|
|||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
|
<RelativeLayout
|
||||||
|
android:id="@+id/settings_turn_flashlight_on_holder"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="@dimen/medium_margin"
|
||||||
|
android:background="?attr/selectableItemBackground"
|
||||||
|
android:padding="@dimen/activity_margin">
|
||||||
|
|
||||||
|
<com.simplemobiletools.commons.views.MySwitchCompat
|
||||||
|
android:id="@+id/settings_turn_flashlight_on"
|
||||||
|
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/turn_flashlight_on"/>
|
||||||
|
|
||||||
|
</RelativeLayout>
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/settings_bright_display_holder"
|
android:id="@+id/settings_bright_display_holder"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
Reference in New Issue
Block a user