From 62ab418c8662e1e338872843c150bf4cd336b295 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sun, 7 May 2017 12:22:27 +0200 Subject: [PATCH] add an option to use volume buttons as shutter --- .../com/simplemobiletools/camera/Config.kt | 4 ++++ .../com/simplemobiletools/camera/Constants.kt | 1 + .../camera/activities/SettingsActivity.kt | 9 +++++++++ app/src/main/res/layout/activity_settings.xml | 20 +++++++++++++++++++ app/src/main/res/values-de/strings.xml | 1 + app/src/main/res/values-es/strings.xml | 1 + app/src/main/res/values-fr/strings.xml | 1 + app/src/main/res/values-it/strings.xml | 1 + app/src/main/res/values-ja/strings.xml | 1 + app/src/main/res/values-lt/strings.xml | 1 + app/src/main/res/values-nl/strings.xml | 1 + app/src/main/res/values-pt-rBR/strings.xml | 1 + app/src/main/res/values-pt/strings.xml | 1 + app/src/main/res/values-ru/strings.xml | 1 + app/src/main/res/values-sv/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 16 files changed, 46 insertions(+) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/Config.kt b/app/src/main/kotlin/com/simplemobiletools/camera/Config.kt index 57840634..eefc2e9c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/Config.kt @@ -34,6 +34,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(FOCUS_BEFORE_CAPTURE, true) set(focus) = prefs.edit().putBoolean(FOCUS_BEFORE_CAPTURE, focus).apply() + var volumeButtonsAsShutter: Boolean + get() = prefs.getBoolean(VOLUME_BUTTONS_AS_SHUTTER, false) + set(volumeButtonsAsShutter) = prefs.edit().putBoolean(VOLUME_BUTTONS_AS_SHUTTER, volumeButtonsAsShutter).apply() + var lastUsedCamera: Int get() = prefs.getInt(LAST_USED_CAMERA, Camera.CameraInfo.CAMERA_FACING_BACK) set(cameraId) = prefs.edit().putInt(LAST_USED_CAMERA, cameraId).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/camera/Constants.kt index 1997451b..c0828279 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/Constants.kt @@ -9,6 +9,7 @@ val SAVE_PHOTOS = "save_photos" val SHOW_PREVIEW = "show_preview" val SOUND = "sound" val FOCUS_BEFORE_CAPTURE = "focus_before_capture" +val VOLUME_BUTTONS_AS_SHUTTER = "volume_buttons_as_shutter" val LAST_USED_CAMERA = "last_used_camera" val FLASHLIGHT_STATE = "flashlight_state" val BACK_PHOTO_RESOLUTION_INDEX = "back_photo_resolution_index" diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt index f1023a03..807c6745 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -28,6 +28,7 @@ class SettingsActivity : SimpleActivity() { setupShowPreview() setupSound() setupFocusBeforeCapture() + setupVolumeButtonsAsShutter() updateTextColors(settings_holder) } @@ -90,4 +91,12 @@ class SettingsActivity : SimpleActivity() { config.focusBeforeCapture = settings_focus_before_capture.isChecked } } + + private fun setupVolumeButtonsAsShutter() { + settings_volume_buttons_as_shutter.isChecked = config.volumeButtonsAsShutter + settings_volume_buttons_as_shutter_holder.setOnClickListener { + settings_volume_buttons_as_shutter.toggle() + config.volumeButtonsAsShutter = settings_volume_buttons_as_shutter.isChecked + } + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 1e8b107c..0cf34557 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -124,5 +124,25 @@ android:text="@string/focus_before_capture"/> + + + + + + diff --git a/app/src/main/res/values-de/strings.xml b/app/src/main/res/values-de/strings.xml index 1c9c52c4..1d2a1ac1 100644 --- a/app/src/main/res/values-de/strings.xml +++ b/app/src/main/res/values-de/strings.xml @@ -25,6 +25,7 @@ Photo Video Vor der Aufnahme fokussieren + Use volume buttons as shutter diff --git a/app/src/main/res/values-es/strings.xml b/app/src/main/res/values-es/strings.xml index 59cfa273..11ef6f72 100644 --- a/app/src/main/res/values-es/strings.xml +++ b/app/src/main/res/values-es/strings.xml @@ -25,6 +25,7 @@ Photo Video Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 144cd570..a349ae2a 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -25,6 +25,7 @@ Photo Video Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 81220d6e..a2559a62 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -25,6 +25,7 @@ Photo Video Messa a fuoco prima della cattura + Use volume buttons as shutter diff --git a/app/src/main/res/values-ja/strings.xml b/app/src/main/res/values-ja/strings.xml index f04853fd..c7185d93 100644 --- a/app/src/main/res/values-ja/strings.xml +++ b/app/src/main/res/values-ja/strings.xml @@ -25,6 +25,7 @@ Photo Video キャプチャ前に再度焦点を合わせる + Use volume buttons as shutter diff --git a/app/src/main/res/values-lt/strings.xml b/app/src/main/res/values-lt/strings.xml index e3bda64b..2a547780 100644 --- a/app/src/main/res/values-lt/strings.xml +++ b/app/src/main/res/values-lt/strings.xml @@ -25,6 +25,7 @@ Photo Video Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-nl/strings.xml b/app/src/main/res/values-nl/strings.xml index 7af48dce..8cae611b 100644 --- a/app/src/main/res/values-nl/strings.xml +++ b/app/src/main/res/values-nl/strings.xml @@ -26,6 +26,7 @@ Foto Video Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 9f27a0de..012f728b 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -25,6 +25,7 @@ Foto Vídeo Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index 403eda18..dceabea5 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -25,6 +25,7 @@ Foto Vídeo Focus before capture + Use volume buttons as shutter diff --git a/app/src/main/res/values-ru/strings.xml b/app/src/main/res/values-ru/strings.xml index 1f26ac31..389f7c38 100644 --- a/app/src/main/res/values-ru/strings.xml +++ b/app/src/main/res/values-ru/strings.xml @@ -25,6 +25,7 @@ Фото Видео Перефокусировка перед захватом + Use volume buttons as shutter diff --git a/app/src/main/res/values-sv/strings.xml b/app/src/main/res/values-sv/strings.xml index 2f11500b..10fcc515 100644 --- a/app/src/main/res/values-sv/strings.xml +++ b/app/src/main/res/values-sv/strings.xml @@ -25,6 +25,7 @@ Photo Video Fokusera om innan bildtagning + Use volume buttons as shutter diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 99e4541b..d235b9a1 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -25,6 +25,7 @@ Photo Video Focus before capture + Use volume buttons as shutter