use the activity config at showing resolution picker

This commit is contained in:
tibbi 2017-05-05 11:15:34 +02:00
parent 9b27d22bf3
commit 4e3d8ae9ac
1 changed files with 7 additions and 7 deletions

View File

@ -4,9 +4,9 @@ import android.hardware.Camera
import android.support.v7.app.AlertDialog import android.support.v7.app.AlertDialog
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import com.simplemobiletools.camera.Preview.Companion.config
import com.simplemobiletools.camera.R import com.simplemobiletools.camera.R
import com.simplemobiletools.camera.activities.SimpleActivity import com.simplemobiletools.camera.activities.SimpleActivity
import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.extensions.getAspectRatio import com.simplemobiletools.camera.extensions.getAspectRatio
import com.simplemobiletools.commons.dialogs.RadioGroupDialog import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.setupDialogStuff import com.simplemobiletools.commons.extensions.setupDialogStuff
@ -32,7 +32,7 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isBackCamera: Boo
private fun setupPhotoResolutionPicker(view: View) { private fun setupPhotoResolutionPicker(view: View) {
val items = getFormattedResolutions(camera.parameters.supportedPictureSizes) val items = getFormattedResolutions(camera.parameters.supportedPictureSizes)
var selectionIndex = if (isBackCamera) config.backPhotoResIndex else config.frontPhotoResIndex var selectionIndex = if (isBackCamera) activity.config.backPhotoResIndex else activity.config.frontPhotoResIndex
selectionIndex = Math.max(selectionIndex, 0) selectionIndex = Math.max(selectionIndex, 0)
view.change_resolution_photo_holder.setOnClickListener { view.change_resolution_photo_holder.setOnClickListener {
@ -40,9 +40,9 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isBackCamera: Boo
selectionIndex = it as Int selectionIndex = it as Int
view.change_resolution_photo.text = items[selectionIndex].title view.change_resolution_photo.text = items[selectionIndex].title
if (isBackCamera) if (isBackCamera)
config.backPhotoResIndex = it activity.config.backPhotoResIndex = it
else else
config.frontPhotoResIndex = it activity.config.frontPhotoResIndex = it
dialog.dismiss() dialog.dismiss()
} }
} }
@ -51,16 +51,16 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isBackCamera: Boo
private fun setupVideoResolutionPicker(view: View) { private fun setupVideoResolutionPicker(view: View) {
val items = getFormattedResolutions(camera.parameters.supportedVideoSizes ?: camera.parameters.supportedPreviewSizes) val items = getFormattedResolutions(camera.parameters.supportedVideoSizes ?: camera.parameters.supportedPreviewSizes)
var selectionIndex = if (isBackCamera) config.backVideoResIndex else config.frontVideoResIndex var selectionIndex = if (isBackCamera) activity.config.backVideoResIndex else activity.config.frontVideoResIndex
view.change_resolution_video_holder.setOnClickListener { view.change_resolution_video_holder.setOnClickListener {
RadioGroupDialog(activity, items, selectionIndex) { RadioGroupDialog(activity, items, selectionIndex) {
selectionIndex = it as Int selectionIndex = it as Int
view.change_resolution_video.text = items[selectionIndex].title view.change_resolution_video.text = items[selectionIndex].title
if (isBackCamera) if (isBackCamera)
config.backVideoResIndex = it activity.config.backVideoResIndex = it
else else
config.frontVideoResIndex = it activity.config.frontVideoResIndex = it
dialog.dismiss() dialog.dismiss()
} }
} }