mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-06-27 09:02:59 +02:00
remove the previous weird way of setting photo/video resolution
This commit is contained in:
@ -26,18 +26,6 @@ class Config(context: Context) : BaseConfig(context) {
|
||||
get() = prefs.getBoolean(SHOW_PREVIEW, false)
|
||||
set(enabled) = prefs.edit().putBoolean(SHOW_PREVIEW, enabled).apply()
|
||||
|
||||
var forceRatioEnabled: Boolean
|
||||
get() = prefs.getBoolean(FORCE_RATIO, true)
|
||||
set(enabled) = prefs.edit().putBoolean(FORCE_RATIO, enabled).apply()
|
||||
|
||||
var maxPhotoResolution: Int
|
||||
get() = prefs.getInt(MAX_PHOTO_RESOLUTION, FIVE_MPX)
|
||||
set(maxRes) = prefs.edit().putInt(MAX_PHOTO_RESOLUTION, maxRes).apply()
|
||||
|
||||
var maxVideoResolution: Int
|
||||
get() = prefs.getInt(MAX_VIDEO_RESOLUTION, P720)
|
||||
set(maxRes) = prefs.edit().putInt(MAX_VIDEO_RESOLUTION, maxRes).apply()
|
||||
|
||||
var isSoundEnabled: Boolean
|
||||
get() = prefs.getBoolean(SOUND, true)
|
||||
set(enabled) = prefs.edit().putBoolean(SOUND, enabled).apply()
|
||||
|
@ -6,20 +6,9 @@ object Constants {
|
||||
val ORIENT_LANDSCAPE_RIGHT = 2
|
||||
}
|
||||
|
||||
val TWO_MPX = 3000000
|
||||
val FIVE_MPX = 6000000
|
||||
val EIGHT_MPX = 9000000
|
||||
|
||||
val P480 = 400000
|
||||
val P720 = 1000000
|
||||
val P1080 = 2100000
|
||||
|
||||
// shared preferences
|
||||
val SAVE_PHOTOS = "save_photos"
|
||||
val SHOW_PREVIEW = "show_preview"
|
||||
val SOUND = "sound"
|
||||
val FORCE_RATIO = "force_ratio"
|
||||
val MAX_PHOTO_RESOLUTION = "max_photo_resolution"
|
||||
val MAX_VIDEO_RESOLUTION = "max_video_resolution"
|
||||
val LAST_USED_CAMERA = "last_used_camera"
|
||||
val LAST_FLASHLIGHT_STATE = "last_flashlight_state"
|
||||
|
@ -156,15 +156,5 @@ class Utils {
|
||||
rotation += Utils.compensateDeviceRotation(currCameraId, deviceOrientation)
|
||||
return rotation % 360
|
||||
}
|
||||
|
||||
|
||||
fun getMaxVideoResolution(config: Config): Int {
|
||||
return when (config.maxVideoResolution) {
|
||||
0 -> 400000
|
||||
1 -> 1000000
|
||||
2 -> 2100000
|
||||
else -> 0
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,8 @@ package com.simplemobiletools.camera.activities
|
||||
import android.os.Bundle
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import com.simplemobiletools.camera.*
|
||||
import com.simplemobiletools.camera.BuildConfig
|
||||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||
import com.simplemobiletools.commons.extensions.humanizePath
|
||||
@ -25,7 +26,6 @@ class SettingsActivity : SimpleActivity() {
|
||||
setupSavePhotosFolder()
|
||||
setupShowPreview()
|
||||
setupSound()
|
||||
setupForceRatio()
|
||||
setupMaxPhotoResolution()
|
||||
setupMaxVideoResolution()
|
||||
updateTextColors(settings_holder)
|
||||
@ -77,72 +77,17 @@ class SettingsActivity : SimpleActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupForceRatio() {
|
||||
settings_force_ratio.isChecked = config.forceRatioEnabled
|
||||
settings_force_ratio_holder.setOnClickListener {
|
||||
settings_force_ratio.toggle()
|
||||
config.forceRatioEnabled = settings_force_ratio.isChecked
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupMaxPhotoResolution() {
|
||||
/*settings_max_photo_resolution.setSelection(getMaxPhotoSelection())
|
||||
settings_max_photo_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
config.maxPhotoResolution = getMaxPhotoPx(settings_max_photo_resolution.selectedItemPosition)
|
||||
}
|
||||
settings_max_photo_resolution.text = ""
|
||||
settings_max_photo_resolution_holder.setOnClickListener {
|
||||
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun getMaxPhotoSelection(): Int {
|
||||
val maxRes = config.maxPhotoResolution
|
||||
return when (maxRes) {
|
||||
TWO_MPX -> 0
|
||||
FIVE_MPX -> 1
|
||||
EIGHT_MPX -> 2
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMaxPhotoPx(index: Int): Int {
|
||||
return when (index) {
|
||||
0 -> TWO_MPX
|
||||
1 -> FIVE_MPX
|
||||
2 -> EIGHT_MPX
|
||||
else -> -1
|
||||
}
|
||||
}
|
||||
|
||||
private fun setupMaxVideoResolution() {
|
||||
/*settings_max_video_resolution.setSelection(getMaxVideoSelection())
|
||||
settings_max_video_resolution.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
|
||||
override fun onNothingSelected(parent: AdapterView<*>?) {
|
||||
}
|
||||
settings_max_photo_resolution.text = ""
|
||||
settings_max_photo_resolution_holder.setOnClickListener {
|
||||
|
||||
override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
|
||||
config.maxVideoResolution = getMaxVideoPx(settings_max_video_resolution.selectedItemPosition)
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
private fun getMaxVideoSelection(): Int {
|
||||
return when (config.maxVideoResolution) {
|
||||
P480 -> 0
|
||||
P720 -> 1
|
||||
P1080 -> 2
|
||||
else -> 3
|
||||
}
|
||||
}
|
||||
|
||||
private fun getMaxVideoPx(index: Int): Int {
|
||||
return when (index) {
|
||||
0 -> P480
|
||||
1 -> P720
|
||||
2 -> P1080
|
||||
else -> -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user