Skip to content

Commit ebd53d9

Browse files
committed
Fix #57
1 parent da8c3c5 commit ebd53d9

17 files changed

Lines changed: 47 additions & 1 deletion

File tree

app/src/main/kotlin/com/simplemobiletools/camera/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,10 @@ class Config(context: Context) : BaseConfig(context) {
3838
get() = prefs.getBoolean(VOLUME_BUTTONS_AS_SHUTTER, false)
3939
set(volumeButtonsAsShutter) = prefs.edit().putBoolean(VOLUME_BUTTONS_AS_SHUTTER, volumeButtonsAsShutter).apply()
4040

41+
var turnFlashOffAtStartup: Boolean
42+
get() = prefs.getBoolean(TURN_FLASH_OFF_AT_STARTUP, false)
43+
set(turnFlashOffAtStartup) = prefs.edit().putBoolean(TURN_FLASH_OFF_AT_STARTUP, turnFlashOffAtStartup).apply()
44+
4145
var lastUsedCamera: Int
4246
get() = prefs.getInt(LAST_USED_CAMERA, Camera.CameraInfo.CAMERA_FACING_BACK)
4347
set(cameraId) = prefs.edit().putInt(LAST_USED_CAMERA, cameraId).apply()

app/src/main/kotlin/com/simplemobiletools/camera/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ val SHOW_PREVIEW = "show_preview"
1010
val SOUND = "sound"
1111
val FOCUS_BEFORE_CAPTURE = "focus_before_capture"
1212
val VOLUME_BUTTONS_AS_SHUTTER = "volume_buttons_as_shutter"
13+
val TURN_FLASH_OFF_AT_STARTUP = "turn_flash_off_at_startup"
1314
val LAST_USED_CAMERA = "last_used_camera"
1415
val FLASHLIGHT_STATE = "flashlight_state"
1516
val BACK_PHOTO_RESOLUTION_INDEX = "back_photo_resolution_index"

app/src/main/kotlin/com/simplemobiletools/camera/activities/MainActivity.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
155155
mIsInPhotoMode = true
156156
mTimerHandler = Handler()
157157
mFadeHandler = Handler()
158-
mFlashlightState = config.flashlightState
158+
mFlashlightState = if (config.turnFlashOffAtStartup) FLASH_OFF else config.flashlightState
159159
setupPreviewImage(true)
160160
}
161161

app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class SettingsActivity : SimpleActivity() {
2929
setupSound()
3030
setupFocusBeforeCapture()
3131
setupVolumeButtonsAsShutter()
32+
setupTurnFlashOffAtStartup()
3233
updateTextColors(settings_holder)
3334
}
3435

@@ -99,4 +100,12 @@ class SettingsActivity : SimpleActivity() {
99100
config.volumeButtonsAsShutter = settings_volume_buttons_as_shutter.isChecked
100101
}
101102
}
103+
104+
private fun setupTurnFlashOffAtStartup() {
105+
settings_turn_flash_off_at_startup.isChecked = config.turnFlashOffAtStartup
106+
settings_turn_flash_off_at_startup_holder.setOnClickListener {
107+
settings_turn_flash_off_at_startup.toggle()
108+
config.turnFlashOffAtStartup = settings_turn_flash_off_at_startup.isChecked
109+
}
110+
}
102111
}

app/src/main/res/layout/activity_settings.xml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,5 +144,25 @@
144144
android:text="@string/volume_buttons_as_shutter"/>
145145

146146
</RelativeLayout>
147+
148+
<RelativeLayout
149+
android:id="@+id/settings_turn_flash_off_at_startup_holder"
150+
android:layout_width="match_parent"
151+
android:layout_height="wrap_content"
152+
android:layout_marginTop="@dimen/medium_margin"
153+
android:background="?attr/selectableItemBackground"
154+
android:padding="@dimen/activity_margin">
155+
156+
<com.simplemobiletools.commons.views.MySwitchCompat
157+
android:id="@+id/settings_turn_flash_off_at_startup"
158+
android:layout_width="match_parent"
159+
android:layout_height="wrap_content"
160+
android:background="@null"
161+
android:clickable="false"
162+
android:paddingLeft="@dimen/medium_margin"
163+
android:paddingStart="@dimen/medium_margin"
164+
android:text="@string/turn_flash_off_at_startup"/>
165+
166+
</RelativeLayout>
147167
</LinearLayout>
148168
</ScrollView>

app/src/main/res/values-de/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<string name="video">Video</string>
2828
<string name="focus_before_capture">Vor der Aufnahme fokussieren</string>
2929
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
30+
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
3031

3132
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
3233
<!-- Short description has to have less than 80 chars -->

app/src/main/res/values-es/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<string name="video">Vídeo</string>
2828
<string name="focus_before_capture">Enfocar antes de la captura</string>
2929
<string name="volume_buttons_as_shutter">Utilizar los botones de volumen como obturador</string>
30+
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
3031

3132
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
3233
<!-- Short description has to have less than 80 chars -->

app/src/main/res/values-fr/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<string name="video">Video</string>
2828
<string name="focus_before_capture">Focus before capture</string>
2929
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
30+
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
3031

3132
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
3233
<!-- Short description has to have less than 80 chars -->

app/src/main/res/values-it/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<string name="video">Video</string>
2828
<string name="focus_before_capture">Messa a fuoco prima della cattura</string>
2929
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
30+
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
3031

3132
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
3233
<!-- Short description has to have less than 80 chars -->

app/src/main/res/values-ja/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
<string name="video">Video</string>
2828
<string name="focus_before_capture">キャプチャ前に再度焦点を合わせる</string>
2929
<string name="volume_buttons_as_shutter">Use volume buttons as shutter</string>
30+
<string name="turn_flash_off_at_startup">Turn flash off at startup</string>
3031

3132
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
3233
<!-- Short description has to have less than 80 chars -->

0 commit comments

Comments
 (0)