From cc418047454f17cd612a31cea412a8d2b95fca4c Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Mon, 24 Jul 2023 01:41:16 +0300 Subject: [PATCH 1/7] update settings for requesting location permission & saving user preference --- app/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 3 ++ .../camera/activities/SettingsActivity.kt | 35 +++++++++++++++++-- .../camera/extensions/Context.kt | 10 +++++- .../camera/helpers/Config.kt | 4 +++ .../camera/helpers/Constants.kt | 1 + app/src/main/res/layout/activity_settings.xml | 15 ++++++++ 7 files changed, 65 insertions(+), 5 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index fcd06a89..eec54d04 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:4c83ec8740' + implementation 'com.github.fatihergin:Simple-Commons:49f496ea16' implementation 'androidx.documentfile:documentfile:1.0.1' implementation "androidx.exifinterface:exifinterface:1.3.5" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 5037bff3..053bf145 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -23,6 +23,9 @@ + + + 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 cf77ea1b..b69afeb4 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -4,15 +4,15 @@ import android.annotation.SuppressLint import android.os.Bundle import com.simplemobiletools.camera.BuildConfig import com.simplemobiletools.camera.R +import com.simplemobiletools.camera.extensions.checkLocationPermission import com.simplemobiletools.camera.extensions.config import com.simplemobiletools.camera.models.CaptureMode import com.simplemobiletools.commons.dialogs.FeatureLockedDialog import com.simplemobiletools.commons.dialogs.FilePickerDialog +import com.simplemobiletools.commons.dialogs.OpenAppSettingsDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* -import com.simplemobiletools.commons.helpers.LICENSE_GLIDE -import com.simplemobiletools.commons.helpers.NavigationIcon -import com.simplemobiletools.commons.helpers.isTiramisuPlus +import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.RadioItem import kotlinx.android.synthetic.main.activity_settings.* @@ -43,6 +43,7 @@ class SettingsActivity : SimpleActivity() { setupVolumeButtonsAsShutter() setupFlipPhotos() setupSavePhotoMetadata() + setupSaveMediaLocation() setupSavePhotosFolder() setupPhotoQuality() setupCaptureMode() @@ -165,6 +166,34 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupSaveMediaLocation() { + settings_save_media_location.isChecked = config.saveMediaLocation + settings_save_media_location_holder.setOnClickListener { + val willEnableSaveMediaLocation = !config.saveMediaLocation + + if (willEnableSaveMediaLocation) { + if (checkLocationPermission()) { + updateSaveMediaLocationConfig(true) + } else { + handlePermission(PERMISSION_ACCESS_FINE_LOCATION) { _ -> + if (checkLocationPermission()) { + updateSaveMediaLocationConfig(true) + } else { + OpenAppSettingsDialog(activity = this@SettingsActivity, permissionId = R.string.permission_name_location) + } + } + } + } else { + updateSaveMediaLocationConfig(false) + } + } + } + + private fun updateSaveMediaLocationConfig(enabled: Boolean) { + settings_save_media_location.isChecked = enabled + config.saveMediaLocation = enabled + } + private fun setupSavePhotosFolder() { settings_save_photos_label.text = addLockedLabelIfNeeded(R.string.save_photos) settings_save_photos.text = getLastPart(config.savePhotosFolder) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/camera/extensions/Context.kt index 4587a5c0..90fa434f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/extensions/Context.kt @@ -2,9 +2,13 @@ package com.simplemobiletools.camera.extensions import android.content.Context import com.simplemobiletools.camera.helpers.Config +import com.simplemobiletools.commons.extensions.hasPermission +import com.simplemobiletools.commons.helpers.PERMISSION_ACCESS_COARSE_LOCATION +import com.simplemobiletools.commons.helpers.PERMISSION_ACCESS_FINE_LOCATION import java.io.File import java.text.SimpleDateFormat -import java.util.* +import java.util.Date +import java.util.Locale val Context.config: Config get() = Config.newInstance(applicationContext) @@ -41,3 +45,7 @@ fun getRandomMediaName(isPhoto: Boolean): String { "VID_$timestamp" } } + +fun Context.checkLocationPermission(): Boolean { + return hasPermission(PERMISSION_ACCESS_FINE_LOCATION) || hasPermission(PERMISSION_ACCESS_COARSE_LOCATION) +} diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt index 01b80789..c2fe1631 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt @@ -68,6 +68,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SAVE_PHOTO_METADATA, true) set(savePhotoMetadata) = prefs.edit().putBoolean(SAVE_PHOTO_METADATA, savePhotoMetadata).apply() + var saveMediaLocation: Boolean + get() = prefs.getBoolean(SAVE_MEDIA_LOCATION, false) + set(saveMediaLocation) = prefs.edit().putBoolean(SAVE_MEDIA_LOCATION, saveMediaLocation).apply() + var photoQuality: Int get() = prefs.getInt(PHOTO_QUALITY, 80) set(photoQuality) = prefs.edit().putInt(PHOTO_QUALITY, photoQuality).apply() diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt index 2850e250..194127be 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt @@ -18,6 +18,7 @@ const val BACK_VIDEO_RESOLUTION_INDEX = "back_video_resolution_index_3" const val FRONT_PHOTO_RESOLUTION_INDEX = "front_photo_resolution_index_3" const val FRONT_VIDEO_RESOLUTION_INDEX = "front_video_resolution_index_3" const val SAVE_PHOTO_METADATA = "save_photo_metadata" +const val SAVE_MEDIA_LOCATION = "save_media_location" const val PHOTO_QUALITY = "photo_quality" const val CAPTURE_MODE = "capture_mode" const val TIMER_MODE = "timer_mode" diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 60e0b3aa..e2930245 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -204,6 +204,21 @@ + + + + + + Date: Mon, 24 Jul 2023 01:54:34 +0300 Subject: [PATCH 2/7] save medias with location data if it's allowed --- app/build.gradle | 2 +- .../camera/helpers/SimpleLocationManager.kt | 81 +++++++++++++++++++ .../implementations/CameraXInitializer.kt | 4 +- .../camera/implementations/CameraXPreview.kt | 46 ++++++++--- 4 files changed, 121 insertions(+), 12 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/camera/helpers/SimpleLocationManager.kt diff --git a/app/build.gradle b/app/build.gradle index eec54d04..37248298 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ android { } dependencies { - implementation 'com.github.fatihergin:Simple-Commons:49f496ea16' + implementation 'com.github.fatihergin:Simple-Commons:23b8cf8be1' // TODO: replace it with SimpleMobileTools after merging the Commons PR implementation 'androidx.documentfile:documentfile:1.0.1' implementation "androidx.exifinterface:exifinterface:1.3.5" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/SimpleLocationManager.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/SimpleLocationManager.kt new file mode 100644 index 00000000..c3b3df03 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/SimpleLocationManager.kt @@ -0,0 +1,81 @@ +package com.simplemobiletools.camera.helpers + +import android.Manifest +import android.location.Location +import android.location.LocationListener +import android.location.LocationManager +import androidx.annotation.RequiresPermission +import com.simplemobiletools.camera.extensions.checkLocationPermission +import com.simplemobiletools.camera.extensions.config +import com.simplemobiletools.commons.activities.BaseSimpleActivity +import com.simplemobiletools.commons.helpers.PERMISSION_ACCESS_FINE_LOCATION + +class SimpleLocationManager(private val activity: BaseSimpleActivity) { + + companion object { + private const val LOCATION_UPDATE_MIN_TIME_INTERVAL_MS = 5_000L + private const val LOCATION_UPDATE_MIN_DISTANCE_M = 10F + } + + private val locationManager = activity.getSystemService(LocationManager::class.java)!! + private val locationListener = LocationListener { location -> + this@SimpleLocationManager.location = location + } + + private var location: Location? = null + + fun getLocation(): Location? { + if (location == null) { + location = getLastKnownLocation() + } + + return location + } + + private fun getLastKnownLocation(): Location? { + return if (activity.checkLocationPermission()) { + var accurateLocation: Location? = null + for (provider in locationManager.allProviders) { + val location = locationManager.getLastKnownLocation(provider) ?: continue + if (accurateLocation == null || location.accuracy < accurateLocation.accuracy) { + accurateLocation = location + } + } + accurateLocation + } else { + null + } + } + + fun requestLocationUpdates() { + activity.apply { + if (checkLocationPermission()) { + registerLocationUpdateListener() + } else { + handlePermission(PERMISSION_ACCESS_FINE_LOCATION) { _ -> + if (checkLocationPermission()) { + registerLocationUpdateListener() + } else { + config.saveMediaLocation = false + } + } + } + } + } + + @RequiresPermission(anyOf = [Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION]) + private fun registerLocationUpdateListener() { + locationManager.allProviders.forEach { provider -> + locationManager.requestLocationUpdates( + provider, + LOCATION_UPDATE_MIN_TIME_INTERVAL_MS, + LOCATION_UPDATE_MIN_DISTANCE_M, + locationListener + ) + } + } + + fun dropLocationUpdates() { + locationManager.removeUpdates(locationListener) + } +} diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXInitializer.kt b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXInitializer.kt index 88b01e69..4ce3c40f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXInitializer.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXInitializer.kt @@ -2,12 +2,12 @@ package com.simplemobiletools.camera.implementations import android.net.Uri import androidx.camera.view.PreviewView +import com.simplemobiletools.camera.activities.MainActivity import com.simplemobiletools.camera.helpers.CameraErrorHandler import com.simplemobiletools.camera.helpers.MediaOutputHelper import com.simplemobiletools.camera.helpers.MediaSoundHelper -import com.simplemobiletools.commons.activities.BaseSimpleActivity -class CameraXInitializer(private val activity: BaseSimpleActivity) { +class CameraXInitializer(private val activity: MainActivity) { fun createCameraXPreview( previewView: PreviewView, diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt index b4ad662a..a4baac68 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt @@ -10,8 +10,6 @@ import android.util.Rational import android.util.Size import android.view.* import android.view.GestureDetector.SimpleOnGestureListener -import android.widget.Toast -import androidx.appcompat.app.AppCompatActivity import androidx.camera.core.* import androidx.camera.core.ImageCapture.* import androidx.camera.lifecycle.ProcessCameraProvider @@ -34,11 +32,12 @@ import com.simplemobiletools.camera.models.CaptureMode import com.simplemobiletools.camera.models.MediaOutput import com.simplemobiletools.camera.models.MySize import com.simplemobiletools.camera.models.ResolutionOption +import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.toast import com.simplemobiletools.commons.helpers.ensureBackgroundThread class CameraXPreview( - private val activity: AppCompatActivity, + private val activity: BaseSimpleActivity, private val previewView: PreviewView, private val mediaSoundHelper: MediaSoundHelper, private val mediaOutputHelper: MediaOutputHelper, @@ -122,6 +121,7 @@ class CameraXPreview( private var isPhotoCapture = initInPhotoMode private var lastRotation = 0 private var lastCameraStartTime = 0L + private var simpleLocationManager: SimpleLocationManager? = null init { bindToLifeCycle() @@ -351,6 +351,21 @@ class CameraXPreview( } } + override fun onResume(owner: LifecycleOwner) { + super.onResume(owner) + if (config.saveMediaLocation) { + if (simpleLocationManager == null) { + simpleLocationManager = SimpleLocationManager(activity) + } + simpleLocationManager?.requestLocationUpdates() + } + } + + override fun onPause(owner: LifecycleOwner) { + super.onPause(owner) + simpleLocationManager?.dropLocationUpdates() + } + override fun onStop(owner: LifecycleOwner) { orientationEventListener.disable() } @@ -473,6 +488,9 @@ class CameraXPreview( val metadata = Metadata().apply { isReversedHorizontal = isFrontCameraInUse() && config.flipPhotos + if (config.saveMediaLocation) { + location = simpleLocationManager?.getLocation() + } } val mediaOutput = mediaOutputHelper.getImageMediaOutput() @@ -572,16 +590,26 @@ class CameraXPreview( val recording = when (val mediaOutput = mediaOutputHelper.getVideoMediaOutput()) { is MediaOutput.FileDescriptorMediaOutput -> { - FileDescriptorOutputOptions.Builder(mediaOutput.fileDescriptor).build() - .let { videoCapture!!.output.prepareRecording(activity, it) } + FileDescriptorOutputOptions.Builder(mediaOutput.fileDescriptor).apply { + if (config.saveMediaLocation) { + setLocation(simpleLocationManager?.getLocation()) + } + }.build().let { videoCapture!!.output.prepareRecording(activity, it) } } is MediaOutput.FileMediaOutput -> { - FileOutputOptions.Builder(mediaOutput.file).build() - .let { videoCapture!!.output.prepareRecording(activity, it) } + FileOutputOptions.Builder(mediaOutput.file).apply { + if (config.saveMediaLocation) { + setLocation(simpleLocationManager?.getLocation()) + } + }.build().let { videoCapture!!.output.prepareRecording(activity, it) } } is MediaOutput.MediaStoreOutput -> { - MediaStoreOutputOptions.Builder(contentResolver, mediaOutput.contentUri).setContentValues(mediaOutput.contentValues).build() - .let { videoCapture!!.output.prepareRecording(activity, it) } + MediaStoreOutputOptions.Builder(contentResolver, mediaOutput.contentUri).apply { + setContentValues(mediaOutput.contentValues) + if (config.saveMediaLocation) { + setLocation(simpleLocationManager?.getLocation()) + } + }.build().let { videoCapture!!.output.prepareRecording(activity, it) } } } From 90c6b3193b298e2a0fcc99763aee78928a2fac25 Mon Sep 17 00:00:00 2001 From: fatih ergin Date: Mon, 24 Jul 2023 22:43:14 +0300 Subject: [PATCH 3/7] update location permission strings --- app/build.gradle | 2 +- .../camera/activities/SettingsActivity.kt | 26 +++++++++---------- .../camera/helpers/Config.kt | 6 ++--- .../camera/helpers/Constants.kt | 2 +- .../camera/implementations/CameraXPreview.kt | 11 ++++---- app/src/main/res/layout/activity_settings.xml | 6 ++--- app/src/main/res/values-ar/strings.xml | 4 +-- app/src/main/res/values-az/strings.xml | 2 +- app/src/main/res/values-be/strings.xml | 2 +- app/src/main/res/values-bg/strings.xml | 2 +- app/src/main/res/values-ca/strings.xml | 4 +-- app/src/main/res/values-cs/strings.xml | 4 +-- app/src/main/res/values-cy/strings.xml | 4 +-- app/src/main/res/values-da/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 4 +-- app/src/main/res/values-el/strings.xml | 2 +- app/src/main/res/values-eo/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 4 +-- app/src/main/res/values-et/strings.xml | 4 +-- app/src/main/res/values-fi/strings.xml | 4 +-- app/src/main/res/values-fr/strings.xml | 4 +-- app/src/main/res/values-gl/strings.xml | 4 +-- app/src/main/res/values-hr/strings.xml | 4 +-- app/src/main/res/values-hu/strings.xml | 4 +-- app/src/main/res/values-in/strings.xml | 4 +-- app/src/main/res/values-it/strings.xml | 4 +-- app/src/main/res/values-iw/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 4 +-- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values-lt/strings.xml | 4 +-- app/src/main/res/values-ml/strings.xml | 2 +- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-ne/strings.xml | 2 +- app/src/main/res/values-nl/strings.xml | 4 +-- app/src/main/res/values-nn/strings.xml | 4 +-- app/src/main/res/values-pa-rPK/strings.xml | 2 +- app/src/main/res/values-pl/strings.xml | 4 +-- app/src/main/res/values-pt-rBR/strings.xml | 4 +-- app/src/main/res/values-pt-rPT/strings.xml | 4 +-- app/src/main/res/values-pt/strings.xml | 4 +-- app/src/main/res/values-ro/strings.xml | 2 +- app/src/main/res/values-ru/strings.xml | 4 +-- app/src/main/res/values-sk/strings.xml | 2 +- app/src/main/res/values-sl/strings.xml | 2 +- app/src/main/res/values-sr/strings.xml | 2 +- app/src/main/res/values-sv/strings.xml | 4 +-- app/src/main/res/values-th/strings.xml | 2 +- app/src/main/res/values-tr/strings.xml | 4 +-- app/src/main/res/values-uk/strings.xml | 4 +-- app/src/main/res/values-zh-rCN/strings.xml | 4 +-- app/src/main/res/values-zh-rTW/strings.xml | 2 +- app/src/main/res/values/strings.xml | 2 +- 52 files changed, 100 insertions(+), 99 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 37248298..e557467d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -63,7 +63,7 @@ android { } dependencies { - implementation 'com.github.fatihergin:Simple-Commons:23b8cf8be1' // TODO: replace it with SimpleMobileTools after merging the Commons PR + implementation 'com.github.fatihergin:Simple-Commons:4ef43732e6' // TODO: replace it with SimpleMobileTools after merging the Commons PR implementation 'androidx.documentfile:documentfile:1.0.1' implementation "androidx.exifinterface:exifinterface:1.3.5" implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.5.1" 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 b69afeb4..2ee9d8fc 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -43,7 +43,7 @@ class SettingsActivity : SimpleActivity() { setupVolumeButtonsAsShutter() setupFlipPhotos() setupSavePhotoMetadata() - setupSaveMediaLocation() + setupSavePhotoVideoLocation() setupSavePhotosFolder() setupPhotoQuality() setupCaptureMode() @@ -166,32 +166,32 @@ class SettingsActivity : SimpleActivity() { } } - private fun setupSaveMediaLocation() { - settings_save_media_location.isChecked = config.saveMediaLocation - settings_save_media_location_holder.setOnClickListener { - val willEnableSaveMediaLocation = !config.saveMediaLocation + private fun setupSavePhotoVideoLocation() { + settings_save_photo_video_location.isChecked = config.savePhotoVideoLocation + settings_save_photo_video_location_holder.setOnClickListener { + val willEnableSavePhotoVideoLocation = !config.savePhotoVideoLocation - if (willEnableSaveMediaLocation) { + if (willEnableSavePhotoVideoLocation) { if (checkLocationPermission()) { - updateSaveMediaLocationConfig(true) + updateSavePhotoVideoLocationConfig(true) } else { handlePermission(PERMISSION_ACCESS_FINE_LOCATION) { _ -> if (checkLocationPermission()) { - updateSaveMediaLocationConfig(true) + updateSavePhotoVideoLocationConfig(true) } else { - OpenAppSettingsDialog(activity = this@SettingsActivity, permissionId = R.string.permission_name_location) + OpenAppSettingsDialog(activity = this@SettingsActivity, message = getString(R.string.allow_location_permission)) } } } } else { - updateSaveMediaLocationConfig(false) + updateSavePhotoVideoLocationConfig(false) } } } - private fun updateSaveMediaLocationConfig(enabled: Boolean) { - settings_save_media_location.isChecked = enabled - config.saveMediaLocation = enabled + private fun updateSavePhotoVideoLocationConfig(enabled: Boolean) { + settings_save_photo_video_location.isChecked = enabled + config.savePhotoVideoLocation = enabled } private fun setupSavePhotosFolder() { diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt index c2fe1631..0f0bfd39 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt @@ -68,9 +68,9 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SAVE_PHOTO_METADATA, true) set(savePhotoMetadata) = prefs.edit().putBoolean(SAVE_PHOTO_METADATA, savePhotoMetadata).apply() - var saveMediaLocation: Boolean - get() = prefs.getBoolean(SAVE_MEDIA_LOCATION, false) - set(saveMediaLocation) = prefs.edit().putBoolean(SAVE_MEDIA_LOCATION, saveMediaLocation).apply() + var savePhotoVideoLocation: Boolean + get() = prefs.getBoolean(SAVE_PHOTO_VIDEO_LOCATION, false) + set(savePhotoVideoLocation) = prefs.edit().putBoolean(SAVE_PHOTO_VIDEO_LOCATION, savePhotoVideoLocation).apply() var photoQuality: Int get() = prefs.getInt(PHOTO_QUALITY, 80) diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt index 194127be..0a245e1a 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt @@ -18,7 +18,7 @@ const val BACK_VIDEO_RESOLUTION_INDEX = "back_video_resolution_index_3" const val FRONT_PHOTO_RESOLUTION_INDEX = "front_photo_resolution_index_3" const val FRONT_VIDEO_RESOLUTION_INDEX = "front_video_resolution_index_3" const val SAVE_PHOTO_METADATA = "save_photo_metadata" -const val SAVE_MEDIA_LOCATION = "save_media_location" +const val SAVE_PHOTO_VIDEO_LOCATION = "save_photo_video_location" const val PHOTO_QUALITY = "photo_quality" const val CAPTURE_MODE = "capture_mode" const val TIMER_MODE = "timer_mode" diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt index a4baac68..5221b2e8 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt @@ -34,6 +34,7 @@ import com.simplemobiletools.camera.models.MySize import com.simplemobiletools.camera.models.ResolutionOption import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.extensions.toast +import com.simplemobiletools.commons.helpers.PERMISSION_ACCESS_FINE_LOCATION import com.simplemobiletools.commons.helpers.ensureBackgroundThread class CameraXPreview( @@ -353,7 +354,7 @@ class CameraXPreview( override fun onResume(owner: LifecycleOwner) { super.onResume(owner) - if (config.saveMediaLocation) { + if (config.savePhotoVideoLocation) { if (simpleLocationManager == null) { simpleLocationManager = SimpleLocationManager(activity) } @@ -488,7 +489,7 @@ class CameraXPreview( val metadata = Metadata().apply { isReversedHorizontal = isFrontCameraInUse() && config.flipPhotos - if (config.saveMediaLocation) { + if (config.savePhotoVideoLocation) { location = simpleLocationManager?.getLocation() } } @@ -591,14 +592,14 @@ class CameraXPreview( val recording = when (val mediaOutput = mediaOutputHelper.getVideoMediaOutput()) { is MediaOutput.FileDescriptorMediaOutput -> { FileDescriptorOutputOptions.Builder(mediaOutput.fileDescriptor).apply { - if (config.saveMediaLocation) { + if (config.savePhotoVideoLocation) { setLocation(simpleLocationManager?.getLocation()) } }.build().let { videoCapture!!.output.prepareRecording(activity, it) } } is MediaOutput.FileMediaOutput -> { FileOutputOptions.Builder(mediaOutput.file).apply { - if (config.saveMediaLocation) { + if (config.savePhotoVideoLocation) { setLocation(simpleLocationManager?.getLocation()) } }.build().let { videoCapture!!.output.prepareRecording(activity, it) } @@ -606,7 +607,7 @@ class CameraXPreview( is MediaOutput.MediaStoreOutput -> { MediaStoreOutputOptions.Builder(contentResolver, mediaOutput.contentUri).apply { setContentValues(mediaOutput.contentValues) - if (config.saveMediaLocation) { + if (config.savePhotoVideoLocation) { setLocation(simpleLocationManager?.getLocation()) } }.build().let { videoCapture!!.output.prepareRecording(activity, it) } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index e2930245..25aa66bd 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -205,17 +205,17 @@ + android:text="@string/save_photo_video_location" /> diff --git a/app/src/main/res/values-ar/strings.xml b/app/src/main/res/values-ar/strings.xml index 81346ca5..7652292e 100644 --- a/app/src/main/res/values-ar/strings.xml +++ b/app/src/main/res/values-ar/strings.xml @@ -47,12 +47,12 @@ إبقاء أزرار الإعداد مرئيا افتح التطبيق دائمًا بالكاميرا الخلفية حفظ بيانات الصورة الوصفية - حفظ موقع الصورة Save photo and video location جودة ضغط الصور الغالق + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-az/strings.xml b/app/src/main/res/values-az/strings.xml index ec8aad37..0097b0a3 100644 --- a/app/src/main/res/values-az/strings.xml +++ b/app/src/main/res/values-az/strings.xml @@ -50,10 +50,10 @@ Parametrlər düyməsini göstər Tətbiqi həmişə Arxa kamerada başlat Şəklin haqqında əlavələri saxla - Save photo location Save photo and video location Şəkil sıxışdırma keyfiyyəti Çəkən + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-cs/strings.xml b/app/src/main/res/values-cs/strings.xml index 2f7ee359..3e790008 100644 --- a/app/src/main/res/values-cs/strings.xml +++ b/app/src/main/res/values-cs/strings.xml @@ -47,12 +47,12 @@ Neskrývat tlačítka nastavení Aplikaci vždy otevřít s aktivním zadním fotoaparátem Ukládat exif metadata fotografií - Save photo location Save photo and video location Úroveň komprese fotografií Spoušť + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-cy/strings.xml b/app/src/main/res/values-cy/strings.xml index 688cbe40..04667c0c 100644 --- a/app/src/main/res/values-cy/strings.xml +++ b/app/src/main/res/values-cy/strings.xml @@ -47,12 +47,12 @@ Cadw\'r botymau gosodiadau mewn golwg Agor yr ap gyda\'r camera cefn bob tro Cadw metaddata lluniau - Save photo location Save photo and video location Ansawdd cywasgiad lluniau Caead + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-da/strings.xml b/app/src/main/res/values-da/strings.xml index 4e18c0a1..12056550 100644 --- a/app/src/main/res/values-da/strings.xml +++ b/app/src/main/res/values-da/strings.xml @@ -47,10 +47,10 @@ Lad indstillingsknapperne være synlige Åbn altid appen med kameraet på bagsiden Gem Exif-metadata i fotos - Save photo location Save photo and video location Fotokomprimeringskvalitet Lukker + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-el/strings.xml b/app/src/main/res/values-el/strings.xml index fc77b08a..826ad44c 100644 --- a/app/src/main/res/values-el/strings.xml +++ b/app/src/main/res/values-el/strings.xml @@ -50,10 +50,10 @@ Διατήρηση εμφανών κουμπιών ρύθμισης Πάντα άνοιγμα της εφαρμογής με την πίσω κάμερα Αποθήκευση μεταδεδομένων exif φωτογραφίας - Αποθήκευση τοποθεσίας φωτογραφίας Save photo and video location Ποιότητα συμπίεσης φωτογραφιών Κλείστρο + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-et/strings.xml b/app/src/main/res/values-et/strings.xml index a778cf51..3cff72e5 100644 --- a/app/src/main/res/values-et/strings.xml +++ b/app/src/main/res/values-et/strings.xml @@ -47,12 +47,12 @@ Hoia seadistusnupud nähtaval Rakenduse käivitamisel kasuta esmalt tagakaamerat Salvesta fotofaili EXIF-metateave - Foto salvestamise asukoht Save photo and video location Fotode pakkimise tase Katik + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-fi/strings.xml b/app/src/main/res/values-fi/strings.xml index 8f02d2c4..cad7bd99 100644 --- a/app/src/main/res/values-fi/strings.xml +++ b/app/src/main/res/values-fi/strings.xml @@ -47,12 +47,12 @@ Pidä asetuspainikkeet näkyvissä Avaa sovellus aina takakamera aktiivisena Tallenna valokuvien Exif-metatiedot - Save photo location Save photo and video location Valokuvien pakkauslaatu Suljin + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml index 9cf63a4c..2ff821be 100644 --- a/app/src/main/res/values-fr/strings.xml +++ b/app/src/main/res/values-fr/strings.xml @@ -47,12 +47,12 @@ Garder visible les boutons de réglage Toujours ouvrir l\'application avec l\'appareil photo arrière Enregistrer les métadonnées Exif dans les photos - Enregistrer l’emplacement de la photo Save photo and video location Qualité des photos Obturateur + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-gl/strings.xml b/app/src/main/res/values-gl/strings.xml index ed42fdad..d969b876 100644 --- a/app/src/main/res/values-gl/strings.xml +++ b/app/src/main/res/values-gl/strings.xml @@ -47,12 +47,12 @@ Manter visibles os botóns dos axustes Abrir sempre o aplicativo coa cámara traseira Gardar metadatos EXIF da foto - Save photo location Save photo and video location Calidade da compresión da foto Obturador + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-hr/strings.xml b/app/src/main/res/values-hr/strings.xml index 7cb681e2..e8ad7f4c 100644 --- a/app/src/main/res/values-hr/strings.xml +++ b/app/src/main/res/values-hr/strings.xml @@ -47,12 +47,12 @@ Ostavi gumbe postavki vidljivima Otvori aplikaciju uvijek pomoću stražnje kamere Spremi exif metapodatke fotografije - Save photo location Save photo and video location Kvaliteta kompresije fotografije Otvor objektiva + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-hu/strings.xml b/app/src/main/res/values-hu/strings.xml index bdc16558..ca3687d9 100644 --- a/app/src/main/res/values-hu/strings.xml +++ b/app/src/main/res/values-hu/strings.xml @@ -47,12 +47,12 @@ Tartsa láthatóvá a beállítási gombokat Mindig a Hátsó kamerával nyissa meg az alkalmazást Fotó adatok mentése - Save photo location Save photo and video location Fotó tömörítés minősége Záró + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-in/strings.xml b/app/src/main/res/values-in/strings.xml index f2eff3c4..64d8877b 100644 --- a/app/src/main/res/values-in/strings.xml +++ b/app/src/main/res/values-in/strings.xml @@ -47,12 +47,12 @@ Selalu tampilkan tombol pengaturan Selalu buka aplikasi dengan kamera belakang Simpan metadata exif foto - Lokasi penyimpanan foto Save photo and video location Kualitas kompresi foto Rana + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-it/strings.xml b/app/src/main/res/values-it/strings.xml index 67aeec98..9bb6f0ba 100644 --- a/app/src/main/res/values-it/strings.xml +++ b/app/src/main/res/values-it/strings.xml @@ -47,12 +47,12 @@ Mantieni il pulsante delle impostazioni visibile Apri sempre l\'app con la fotocamera posteriore Salva i metadati Exif nelle foto - Salva la posizione della foto Save photo and video location Qualità della compressione delle foto Otturatore + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-iw/strings.xml b/app/src/main/res/values-iw/strings.xml index 91cdf81a..9c7ed152 100644 --- a/app/src/main/res/values-iw/strings.xml +++ b/app/src/main/res/values-iw/strings.xml @@ -49,10 +49,10 @@ השאר את לחצני ההגדרה גלויים פתח את האפליקציה תמיד עם המצלמה האחורית שמור מטא נתונים של Exif של תמונה - Save photo location Save photo and video location איכות דחיסת תמונה תריס + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-ko/strings.xml b/app/src/main/res/values-ko/strings.xml index 99d5a1f6..76f7ff26 100644 --- a/app/src/main/res/values-ko/strings.xml +++ b/app/src/main/res/values-ko/strings.xml @@ -47,10 +47,10 @@ 설정 버튼 표시 유지 항상 후면카메라로 실행 사진 exif 메타 데이터 저장 - Save photo location Save photo and video location 사진 압축 품질 Shutter + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-ml/strings.xml b/app/src/main/res/values-ml/strings.xml index cfd7e561..a042fbd7 100644 --- a/app/src/main/res/values-ml/strings.xml +++ b/app/src/main/res/values-ml/strings.xml @@ -47,10 +47,10 @@ ക്രമീകരണ ബട്ടൺ ദൃശ്യമാക്കുക എല്ലായ്പ്പോഴും പുറകിലെ ക്യാമറ ഉപയോഗിച്ച് അപ്ലിക്കേഷൻ തുറക്കുക ഫോട്ടോ exif മെറ്റാഡാറ്റ സംരക്ഷിക്കുക - Save photo location Save photo and video location ഫോട്ടോ കംപ്രഷൻ ക്വാളിറ്റി ഷട്ടർ + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-nn/strings.xml b/app/src/main/res/values-nn/strings.xml index d52dc362..216c3c82 100644 --- a/app/src/main/res/values-nn/strings.xml +++ b/app/src/main/res/values-nn/strings.xml @@ -47,12 +47,12 @@ Held innstillingknappen synleg Byt til kameraet bak når appen vert opna Gøym Exif-metadata i bilete - Save photo location Save photo and video location Biletekvalitet (Merk: høgre % tek au meir rom) Opptak + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-pa-rPK/strings.xml b/app/src/main/res/values-pa-rPK/strings.xml index 83455786..35467bec 100644 --- a/app/src/main/res/values-pa-rPK/strings.xml +++ b/app/src/main/res/values-pa-rPK/strings.xml @@ -47,8 +47,8 @@ Keep the setting buttons visible Always open the app with the Back camera ایکسیف میٹاڈیٹا سامبھو - Save photo location Save photo and video location Photo compression quality Shutter + You must allow Camera accessing location, else it cannot complete this action. diff --git a/app/src/main/res/values-pl/strings.xml b/app/src/main/res/values-pl/strings.xml index db4451b8..2c06ca0f 100644 --- a/app/src/main/res/values-pl/strings.xml +++ b/app/src/main/res/values-pl/strings.xml @@ -47,12 +47,12 @@ Pozostawiaj przyciski ustawień widoczne Zawsze otwieraj aplikację z włączonym tylnym aparatem Zapisuj metadane EXIF w zdjęciach - Zapisuj lokalizację zdjęcia Save photo and video location Jakość kompresji zdjęć Migawka + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-pt-rBR/strings.xml b/app/src/main/res/values-pt-rBR/strings.xml index 765da9d0..4b50666d 100644 --- a/app/src/main/res/values-pt-rBR/strings.xml +++ b/app/src/main/res/values-pt-rBR/strings.xml @@ -47,12 +47,12 @@ Mantenha os botões de configuração visíveis Sempre abra o aplicativo com a câmera traseira Salvar metadados exif da foto - Save photo location Save photo and video location Qualidade de compresão de imagem Obturador + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-pt-rPT/strings.xml b/app/src/main/res/values-pt-rPT/strings.xml index 61f563eb..f124bfbb 100644 --- a/app/src/main/res/values-pt-rPT/strings.xml +++ b/app/src/main/res/values-pt-rPT/strings.xml @@ -47,12 +47,12 @@ Botão de definições sempre visível Abrir a aplicação sempre com a câmara traseira Guardar dados exif das fotos - Save photo location Save photo and video location Qualidade da compressão Obturador + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-pt/strings.xml b/app/src/main/res/values-pt/strings.xml index ea2a0b42..5bf01c93 100644 --- a/app/src/main/res/values-pt/strings.xml +++ b/app/src/main/res/values-pt/strings.xml @@ -47,12 +47,12 @@ Manter botão de definições visível Abrir sempre a aplicação com a câmera traseira Guardar dados exif com a foto - Local para guardar as fotos Save photo and video location Qualidade de compressão da foto Obturador + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-ro/strings.xml b/app/src/main/res/values-ro/strings.xml index d1d6e14a..835142a0 100644 --- a/app/src/main/res/values-ro/strings.xml +++ b/app/src/main/res/values-ro/strings.xml @@ -47,10 +47,10 @@ Păstrați vizibile butoanele de setări Deschideți întotdeauna aplicația cu camera din spate Salvați metadatele exif ale fotografiilor - Save photo location Save photo and video location Calitatea comprimării fotografiilor Declanșator + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-sk/strings.xml b/app/src/main/res/values-sk/strings.xml index f1954a34..726597fc 100644 --- a/app/src/main/res/values-sk/strings.xml +++ b/app/src/main/res/values-sk/strings.xml @@ -50,10 +50,10 @@ Neskrývať tlačidlá nastavení Stále otvárať aplikáciu s aktívnou zadnou kamerou Ukladať exif metadáta fotografií - Ukladať údaje o polohe Ukladať údaje o polohe fotiek a videí Kvalita kompresie fotiek Spúšť + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-th/strings.xml b/app/src/main/res/values-th/strings.xml index b45ba441..e18ad110 100644 --- a/app/src/main/res/values-th/strings.xml +++ b/app/src/main/res/values-th/strings.xml @@ -51,10 +51,10 @@ Keep the setting buttons visible Always open the app with the Back camera Save photo exif metadata - Save photo location Save photo and video location Photo compression quality Shutter + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-uk/strings.xml b/app/src/main/res/values-uk/strings.xml index 690b0e22..3fa04e8a 100644 --- a/app/src/main/res/values-uk/strings.xml +++ b/app/src/main/res/values-uk/strings.xml @@ -47,12 +47,12 @@ Завжди показувати панель налаштувань Завжди активувати задню камеру під час запуску додатка Зберігати метадані EXIF - Зберігати розташування фото Save photo and video location Якість фото після стиснення Затвор + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 3d91c576..820f62d6 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -47,12 +47,12 @@ 设置按钮保持可见 打开应用时切换到后置相机 保存照片 EXIF 元数据 - 保存照片位置 Save photo and video location 照片压缩品质 快门 + You must allow Camera accessing location, else it cannot complete this action. - \ No newline at end of file + diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 4d2bcaa2..32cd305b 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -49,10 +49,10 @@ 設定按鈕不消失 開啟程式總是用後鏡頭 儲存相片EXIF資訊 - Save photo location Save photo and video location 相片壓縮品質 快門 + You must allow Camera accessing location, else it cannot complete this action.