add settings option for capture mode
This commit is contained in:
parent
122841b641
commit
e412cec759
|
@ -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)
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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()
|
||||
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
@ -210,8 +211,9 @@ class CameraXPreview(
|
|||
}
|
||||
|
||||
private fun buildImageCapture(resolution: Size, rotation: Int): ImageCapture {
|
||||
val captureMode = getCaptureMode()
|
||||
return Builder()
|
||||
.setCaptureMode(CAPTURE_MODE_MINIMIZE_LATENCY)
|
||||
.setCaptureMode(captureMode)
|
||||
.setFlashMode(flashMode)
|
||||
.setJpegQuality(config.photoQuality)
|
||||
.setTargetRotation(rotation)
|
||||
|
@ -219,6 +221,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<Recorder> {
|
||||
val qualitySelector = QualitySelector.from(
|
||||
videoQualityManager.getUserSelectedQuality(cameraSelector).toCameraXQuality(),
|
||||
|
|
|
@ -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),
|
||||
}
|
|
@ -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) {
|
||||
|
|
|
@ -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">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_photo_quality_label"
|
||||
|
@ -283,6 +283,30 @@
|
|||
tools:text="80%" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
<RelativeLayout
|
||||
android:id="@+id/settings_capture_mode_holder"
|
||||
style="@style/SettingsHolderTextViewStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@drawable/ripple_bottom_corners">
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_capture_mode_label"
|
||||
style="@style/SettingsTextLabelStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/capture_mode" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/settings_capture_mode"
|
||||
style="@style/SettingsTextValueStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/settings_capture_mode_label"
|
||||
tools:text="@string/minimize_latency" />
|
||||
|
||||
</RelativeLayout>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
</androidx.core.widget.NestedScrollView>
|
||||
|
|
Loading…
Reference in New Issue