File tree Expand file tree Collapse file tree 5 files changed +42
-6
lines changed
kotlin/com/simplemobiletools/flashlight Expand file tree Collapse file tree 5 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,9 @@ class MainActivity : SimpleActivity() {
127127
128128 private fun setupCameraImpl () {
129129 mCameraImpl = MyCameraImpl .newInstance(this )
130- mCameraImpl!! .enableFlashlight()
130+ if (config.turnFlashlightOn) {
131+ mCameraImpl!! .enableFlashlight()
132+ }
131133 }
132134
133135 private fun setupStroboscope () {
Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ class SettingsActivity : SimpleActivity() {
2020
2121 setupCustomizeColors()
2222 setupUseEnglish()
23+ setupTurnFlashlightOn()
2324 setupBrightDisplay()
2425 setupStroboscope()
2526 updateTextColors(settings_holder)
@@ -41,6 +42,14 @@ class SettingsActivity : SimpleActivity() {
4142 }
4243 }
4344
45+ private fun setupTurnFlashlightOn () {
46+ settings_turn_flashlight_on.isChecked = config.turnFlashlightOn
47+ settings_turn_flashlight_on_holder.setOnClickListener {
48+ settings_turn_flashlight_on.toggle()
49+ config.turnFlashlightOn = settings_turn_flashlight_on.isChecked
50+ }
51+ }
52+
4453 private fun setupBrightDisplay () {
4554 settings_bright_display.isChecked = config.brightDisplay
4655 settings_bright_display_holder.setOnClickListener {
Original file line number Diff line number Diff line change @@ -15,4 +15,8 @@ class Config(context: Context) : BaseConfig(context) {
1515 var stroboscope: Boolean
1616 get() = prefs.getBoolean(STROBOSCOPE , true )
1717 set(stroboscope) = prefs.edit().putBoolean(STROBOSCOPE , stroboscope).apply ()
18+
19+ var turnFlashlightOn: Boolean
20+ get() = prefs.getBoolean(TURN_FLASHLIGHT_ON , false )
21+ set(turnFlashlightOn) = prefs.edit().putBoolean(TURN_FLASHLIGHT_ON , turnFlashlightOn).apply ()
1822}
Original file line number Diff line number Diff line change 11package com.simplemobiletools.flashlight.helpers
22
3- val BRIGHT_DISPLAY = " bright_display"
4- val STROBOSCOPE = " stroboscope"
5- val IS_ENABLED = " is_enabled"
6- val TOGGLE = " toggle"
7- val TOGGLE_WIDGET_UI = " toggle_widget_ui"
3+ const val BRIGHT_DISPLAY = " bright_display"
4+ const val STROBOSCOPE = " stroboscope"
5+ const val TURN_FLASHLIGHT_ON = " turn_flashlight_on"
6+ const val IS_ENABLED = " is_enabled"
7+ const val TOGGLE = " toggle"
8+ const val TOGGLE_WIDGET_UI = " toggle_widget_ui"
Original file line number Diff line number Diff line change 5050
5151 </RelativeLayout >
5252
53+ <RelativeLayout
54+ android : id =" @+id/settings_turn_flashlight_on_holder"
55+ android : layout_width =" match_parent"
56+ android : layout_height =" wrap_content"
57+ android : layout_marginTop =" @dimen/medium_margin"
58+ android : background =" ?attr/selectableItemBackground"
59+ android : padding =" @dimen/activity_margin" >
60+
61+ <com .simplemobiletools.commons.views.MySwitchCompat
62+ android : id =" @+id/settings_turn_flashlight_on"
63+ android : layout_width =" match_parent"
64+ android : layout_height =" wrap_content"
65+ android : background =" @null"
66+ android : clickable =" false"
67+ android : paddingLeft =" @dimen/medium_margin"
68+ android : paddingStart =" @dimen/medium_margin"
69+ android : text =" @string/turn_flashlight_on" />
70+
71+ </RelativeLayout >
72+
5373 <RelativeLayout
5474 android : id =" @+id/settings_bright_display_holder"
5575 android : layout_width =" match_parent"
You can’t perform that action at this time.
0 commit comments