mirror of
https://github.com/SimpleMobileTools/Simple-Camera.git
synced 2025-02-27 08:37:47 +01:00
show a video resolution picker if recording fails
This commit is contained in:
parent
63d228a50e
commit
7e709bebfb
@ -13,7 +13,7 @@ import com.simplemobiletools.commons.models.RadioItem
|
||||
import kotlinx.android.synthetic.main.dialog_change_resolution.view.*
|
||||
|
||||
class ChangeResolutionDialog(val activity: SimpleActivity, val isFrontCamera: Boolean, val photoResolutions: ArrayList<MySize>,
|
||||
val videoResolutions: ArrayList<MySize>, val callback: () -> Unit) {
|
||||
val videoResolutions: ArrayList<MySize>, val openVideoResolutions: Boolean, val callback: () -> Unit) {
|
||||
private var dialog: AlertDialog
|
||||
private val config = activity.config
|
||||
|
||||
@ -27,7 +27,11 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isFrontCamera: Bo
|
||||
.setPositiveButton(R.string.ok, null)
|
||||
.setOnDismissListener { callback() }
|
||||
.create().apply {
|
||||
activity.setupDialogStuff(view, this, if (isFrontCamera) R.string.front_camera else R.string.back_camera)
|
||||
activity.setupDialogStuff(view, this, if (isFrontCamera) R.string.front_camera else R.string.back_camera) {
|
||||
if (openVideoResolutions) {
|
||||
view.change_resolution_video_holder.performClick()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -500,7 +500,7 @@ class PreviewCameraOne : ViewGroup, SurfaceHolder.Callback, MyPreview {
|
||||
val photoResolutions = mCamera!!.parameters.supportedPictureSizes.map { MySize(it.width, it.height) } as ArrayList<MySize>
|
||||
val videoSizes = mCamera!!.parameters.supportedVideoSizes ?: mCamera!!.parameters.supportedPreviewSizes
|
||||
val videoResolutions = videoSizes.map { MySize(it.width, it.height) } as ArrayList<MySize>
|
||||
ChangeResolutionDialog(mActivity!!, getIsUsingFrontCamera(), photoResolutions, videoResolutions) {
|
||||
ChangeResolutionDialog(mActivity!!, getIsUsingFrontCamera(), photoResolutions, videoResolutions, false) {
|
||||
if (oldResolution != getSelectedResolution()) {
|
||||
refreshPreview()
|
||||
}
|
||||
|
@ -25,6 +25,8 @@ import android.view.MotionEvent
|
||||
import android.view.Surface
|
||||
import android.view.TextureView
|
||||
import android.view.ViewGroup
|
||||
import android.widget.Toast
|
||||
import com.simplemobiletools.camera.R
|
||||
import com.simplemobiletools.camera.activities.MainActivity
|
||||
import com.simplemobiletools.camera.dialogs.ChangeResolutionDialog
|
||||
import com.simplemobiletools.camera.extensions.config
|
||||
@ -36,6 +38,7 @@ import com.simplemobiletools.camera.models.FocusArea
|
||||
import com.simplemobiletools.camera.models.MySize
|
||||
import com.simplemobiletools.commons.extensions.rescanPaths
|
||||
import com.simplemobiletools.commons.extensions.showErrorToast
|
||||
import com.simplemobiletools.commons.extensions.toast
|
||||
import com.simplemobiletools.commons.helpers.isJellyBean1Plus
|
||||
import java.io.File
|
||||
import java.lang.IllegalArgumentException
|
||||
@ -899,18 +902,23 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
||||
}
|
||||
|
||||
mIsRecording = false
|
||||
try {
|
||||
mMediaRecorder!!.stop()
|
||||
mMediaRecorder!!.reset()
|
||||
mActivity.rescanPaths(arrayListOf(mLastVideoPath)) {
|
||||
mActivity.videoSaved(Uri.fromFile(File(mLastVideoPath)))
|
||||
}
|
||||
|
||||
} catch (e: Exception) {
|
||||
mActivity.toast(R.string.video_recording_failed, Toast.LENGTH_LONG)
|
||||
openResolutionsDialog(true)
|
||||
} finally {
|
||||
Thread {
|
||||
closeCamera()
|
||||
openCamera(mTextureView.width, mTextureView.height)
|
||||
}.start()
|
||||
mActivity.setRecordingState(false)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAvailableVideoSizes(configMap: StreamConfigurationMap) = configMap.getOutputSizes(MediaRecorder::class.java).filter {
|
||||
it.width <= MAX_VIDEO_WIDTH && it.height <= MAX_VIDEO_HEIGHT
|
||||
@ -934,11 +942,15 @@ class PreviewCameraTwo : ViewGroup, TextureView.SurfaceTextureListener, MyPrevie
|
||||
override fun getCameraState() = mCameraState
|
||||
|
||||
override fun showChangeResolutionDialog() {
|
||||
openResolutionsDialog(false)
|
||||
}
|
||||
|
||||
private fun openResolutionsDialog(openVideoResolutions: Boolean) {
|
||||
val oldResolution = getCurrentResolution()
|
||||
val configMap = getCameraCharacteristics().get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP)
|
||||
val photoResolutions = configMap.getOutputSizes(ImageFormat.JPEG).map { MySize(it.width, it.height) } as ArrayList
|
||||
val videoResolutions = getAvailableVideoSizes(configMap).map { MySize(it.width, it.height) } as ArrayList
|
||||
ChangeResolutionDialog(mActivity, mUseFrontCamera, photoResolutions, videoResolutions) {
|
||||
ChangeResolutionDialog(mActivity, mUseFrontCamera, photoResolutions, videoResolutions, openVideoResolutions) {
|
||||
if (oldResolution != getCurrentResolution()) {
|
||||
if (mIsRecording) {
|
||||
stopRecording()
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">انقر على الصورة لاستئناف المعاينة</string>
|
||||
<string name="photo_not_saved">تعذر حفظ الصورة</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">آخرى</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Önbaxışa davam etmək üçün şəkilə toxun</string>
|
||||
<string name="photo_not_saved">Şəkli yaddaşa salmaq olmur</string>
|
||||
<string name="setting_resolution_failed">Uyğun görüntü imkanını seçmək olmur</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">digər</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Klicke auf das Bild, um bei der Vorschau zu bleiben</string>
|
||||
<string name="photo_not_saved">Das Foto konnte nicht gespeichert werden</string>
|
||||
<string name="setting_resolution_failed">Korrekte Auflösung konnte nicht eingestellt werden</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">andere</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Haga clic en la imagen para reanudar la vista previa</string>
|
||||
<string name="photo_not_saved">The photo could not be saved</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">otro</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Cliquez sur l\'image pour reprendre l\'aperçu</string>
|
||||
<string name="photo_not_saved">La photo ne peut pas être sauvegardée</string>
|
||||
<string name="setting_resolution_failed">La définition de la résolution a échoué</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">autre</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Pulse na imaxe para voltar a vista previa</string>
|
||||
<string name="photo_not_saved">Non se puido gardar a fotografía</string>
|
||||
<string name="setting_resolution_failed">Fallou o establecemento da resolución</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">outro</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Kliknite sliku kako biste nastavili pregled</string>
|
||||
<string name="photo_not_saved">Fotografiju nije moguće spremiti</string>
|
||||
<string name="setting_resolution_failed">Postavljanje ispravne rezolucije nije uspjelo</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">ostalo</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Click on the image to resume preview</string>
|
||||
<string name="photo_not_saved">The photo could not be saved</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">other</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">プレビューを再開するには画像をタップ</string>
|
||||
<string name="photo_not_saved">この画像は保存されていません</string>
|
||||
<string name="setting_resolution_failed">適切な解像度の設定に失敗しました</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">その他</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">미리보기를 다시 시작하려면 이미지를 클릭하십시오.</string>
|
||||
<string name="photo_not_saved">사진을 저장할 수 없습니다.</string>
|
||||
<string name="setting_resolution_failed">해상도 설정에 실패했습니다.</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">other</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Paspausti ant paveikslėlio peržiūros pratęsimui</string>
|
||||
<string name="photo_not_saved">Nuotrauka negali būti išsaugota</string>
|
||||
<string name="setting_resolution_failed">Nustatant tinkamą raišką įvyko klaida</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">Kita</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Click on the image to resume preview</string>
|
||||
<string name="photo_not_saved">The photo could not be saved</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">Ander</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Kliknij obraz, aby wznowić podgląd</string>
|
||||
<string name="photo_not_saved">Nie mogłem zapisać zdjęcia</string>
|
||||
<string name="setting_resolution_failed">Nie mogłem ustawić poprawnej rozdzielczości</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">inne</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Clique na imagem para resumir a pré-visualização</string>
|
||||
<string name="photo_not_saved">A foto não pôde ser salva</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">outra</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Clique na imagem para continuar com a pré-visualização</string>
|
||||
<string name="photo_not_saved">Não foi possível guardar a foto</string>
|
||||
<string name="setting_resolution_failed">Falha ao definir a resolução ideal</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">outra</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Чтобы возобновить предпросмотр, нажмите на изображение</string>
|
||||
<string name="photo_not_saved">Не удалось сохранить фото</string>
|
||||
<string name="setting_resolution_failed">Не удалось установить правильное разрешение</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">другое</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Pre pokračovanie prehliadania kliknite na obrázok</string>
|
||||
<string name="photo_not_saved">Fotografiu sa nepodarilo uložiť</string>
|
||||
<string name="setting_resolution_failed">Nepodarilo sa nastaviť správne rozlíšenie</string>
|
||||
<string name="video_recording_failed">Nahrávanie videa zlyhalo, skúste použiť iné rozlíšenie</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">iný</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Tryck på bilden för att återuppta förhandsgranskningen</string>
|
||||
<string name="photo_not_saved">Fotot kunde inte sparas</string>
|
||||
<string name="setting_resolution_failed">Det gick inte att ställa in den valda upplösningen</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">annat</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Önizlemeye devam etmek için resmin üzerine tıklayın</string>
|
||||
<string name="photo_not_saved">Fotoğraf kaydedilemedi</string>
|
||||
<string name="setting_resolution_failed">Doğru çözünürlük ayarı başarısız oldu</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">diğer</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">點擊圖片回到拍攝預覽</string>
|
||||
<string name="photo_not_saved">相片無法儲存</string>
|
||||
<string name="setting_resolution_failed">設定合適解析度失敗</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">其它</string>
|
||||
|
@ -11,6 +11,7 @@
|
||||
<string name="click_to_resume_preview">Click on the image to resume preview</string>
|
||||
<string name="photo_not_saved">The photo could not be saved</string>
|
||||
<string name="setting_resolution_failed">Setting proper resolution failed</string>
|
||||
<string name="video_recording_failed">Video recording failed, try using a different resolution</string>
|
||||
|
||||
<!-- Other aspect ratio -->
|
||||
<string name="other">other</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user