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 6a196f89..4c2d6097 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/activities/SettingsActivity.kt @@ -5,6 +5,7 @@ import android.os.Bundle import com.simplemobiletools.camera.BuildConfig import com.simplemobiletools.camera.R import com.simplemobiletools.camera.extensions.config +import com.simplemobiletools.camera.models.CaptureMode import com.simplemobiletools.commons.dialogs.FilePickerDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.extensions.* @@ -13,9 +14,9 @@ import com.simplemobiletools.commons.helpers.NavigationIcon import com.simplemobiletools.commons.helpers.isTiramisuPlus import com.simplemobiletools.commons.models.FAQItem import com.simplemobiletools.commons.models.RadioItem -import kotlinx.android.synthetic.main.activity_settings.* -import java.util.* +import java.util.Locale import kotlin.system.exitProcess +import kotlinx.android.synthetic.main.activity_settings.* class SettingsActivity : SimpleActivity() { override fun onCreate(savedInstanceState: Bundle?) { @@ -38,6 +39,7 @@ class SettingsActivity : SimpleActivity() { setupSavePhotoMetadata() setupSavePhotosFolder() setupPhotoQuality() + setupCaptureMode() updateTextColors(settings_holder) val properPrimaryColor = getProperPrimaryColor() @@ -209,4 +211,23 @@ class SettingsActivity : SimpleActivity() { private fun updatePhotoQuality(quality: Int) { settings_photo_quality.text = "$quality%" } + + private fun setupCaptureMode() { + updateCaptureMode(config.captureMode) + settings_capture_mode_holder.setOnClickListener { + val items = CaptureMode.values().mapIndexed { index, captureMode -> + RadioItem(index, getString(captureMode.stringResId), captureMode) + } + + RadioGroupDialog(this@SettingsActivity, ArrayList(items), config.captureMode.ordinal) { + config.captureMode = it as CaptureMode + updateCaptureMode(it) + } + } + } + + private fun updateCaptureMode(captureMode: CaptureMode) { + settings_capture_mode.text = getString(captureMode.stringResId) + } + } 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 ec229691..f391b6ed 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Config.kt @@ -3,6 +3,7 @@ package com.simplemobiletools.camera.helpers import android.content.Context import android.os.Environment import androidx.camera.core.CameraSelector +import com.simplemobiletools.camera.models.CaptureMode import com.simplemobiletools.commons.helpers.BaseConfig import java.io.File @@ -73,4 +74,9 @@ class Config(context: Context) : BaseConfig(context) { var photoQuality: Int get() = prefs.getInt(PHOTO_QUALITY, 80) set(photoQuality) = prefs.edit().putInt(PHOTO_QUALITY, photoQuality).apply() + + var captureMode: CaptureMode + get() = CaptureMode.values()[prefs.getInt(CAPTURE_MODE, CaptureMode.MINIMISE_LATENCY.ordinal)] + set(captureMode) = prefs.edit().putInt(CAPTURE_MODE, captureMode.ordinal).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 012a8765..25de1cd6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/helpers/Constants.kt @@ -19,6 +19,7 @@ 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 PHOTO_QUALITY = "photo_quality" +const val CAPTURE_MODE = "capture_mode" const val FLASH_OFF = 0 const val FLASH_ON = 1 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 3f0ee04c..4079881c 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/implementations/CameraXPreview.kt @@ -26,6 +26,7 @@ import com.simplemobiletools.camera.R import com.simplemobiletools.camera.extensions.* import com.simplemobiletools.camera.helpers.* import com.simplemobiletools.camera.interfaces.MyPreview +import com.simplemobiletools.camera.models.CaptureMode import com.simplemobiletools.camera.models.MediaOutput import com.simplemobiletools.camera.models.MySize import com.simplemobiletools.camera.models.ResolutionOption @@ -209,7 +210,7 @@ class CameraXPreview( private fun buildImageCapture(resolution: Size, rotation: Int): ImageCapture { return Builder() - .setCaptureMode(CAPTURE_MODE_MINIMIZE_LATENCY) + .setCaptureMode(getCaptureMode()) .setFlashMode(flashMode) .setJpegQuality(config.photoQuality) .setTargetRotation(rotation) @@ -217,6 +218,13 @@ class CameraXPreview( .build() } + private fun getCaptureMode(): Int { + return when (config.captureMode) { + CaptureMode.MINIMISE_LATENCY -> CAPTURE_MODE_MINIMIZE_LATENCY + CaptureMode.MAXIMISE_QUALITY -> CAPTURE_MODE_MAXIMIZE_QUALITY + } + } + private fun buildVideoCapture(): VideoCapture { val qualitySelector = QualitySelector.from( videoQualityManager.getUserSelectedQuality(cameraSelector).toCameraXQuality(), diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/models/CaptureMode.kt b/app/src/main/kotlin/com/simplemobiletools/camera/models/CaptureMode.kt new file mode 100644 index 00000000..6eca0509 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/camera/models/CaptureMode.kt @@ -0,0 +1,9 @@ +package com.simplemobiletools.camera.models + +import androidx.annotation.StringRes +import com.simplemobiletools.camera.R + +enum class CaptureMode(@StringRes val stringResId: Int) { + MINIMISE_LATENCY(R.string.minimize_latency), + MAXIMISE_QUALITY(R.string.maximize_quality) +} diff --git a/app/src/main/kotlin/com/simplemobiletools/camera/views/ShadowDrawable.kt b/app/src/main/kotlin/com/simplemobiletools/camera/views/ShadowDrawable.kt index e10f93fa..99c5dfd6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/camera/views/ShadowDrawable.kt +++ b/app/src/main/kotlin/com/simplemobiletools/camera/views/ShadowDrawable.kt @@ -82,8 +82,6 @@ class ShadowDrawable(context: Context, private val drawable: Drawable, @StyleRes } shadowPaint.isAntiAlias = true shadowPaint.isFilterBitmap = true - shadowPaint.isAntiAlias = true - shadowPaint.isFilterBitmap = true } override fun draw(canvas: Canvas) { diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 0e0b34fe..a22fee4b 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -265,7 +265,7 @@ style="@style/SettingsHolderTextViewStyle" android:layout_width="match_parent" android:layout_height="wrap_content" - android:background="@drawable/ripple_bottom_corners"> + android:background="@drawable/ripple_background"> + + + + + + + +