show the aspect ratio at the resolutions dialog too

This commit is contained in:
tibbi 2017-03-21 23:24:31 +01:00
parent af72725ad7
commit c013f85ce5
12 changed files with 71 additions and 2 deletions

View File

@ -7,6 +7,7 @@ import android.view.View
import com.simplemobiletools.camera.Preview.Companion.config
import com.simplemobiletools.camera.R
import com.simplemobiletools.camera.activities.SimpleActivity
import com.simplemobiletools.camera.extensions.getAspectRatio
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.setupDialogStuff
import com.simplemobiletools.commons.models.RadioItem
@ -70,7 +71,8 @@ class ChangeResolutionDialog(val activity: SimpleActivity, val isBackCamera: Boo
val sorted = resolutions.sortedByDescending { it.width * it.height }
sorted.forEachIndexed { index, size ->
val megapixels = String.format("%.1f", (size.width * size.height.toFloat()) / 1000000)
items.add(RadioItem(index, "${size.width} x ${size.height} ($megapixels MP)"))
val aspectRatio = size.getAspectRatio(activity)
items.add(RadioItem(index, "${size.width} x ${size.height} ($megapixels MP, $aspectRatio)"))
}
return items
}

View File

@ -1,8 +1,10 @@
package com.simplemobiletools.camera.extensions
import android.content.Context
import android.hardware.Camera
import com.simplemobiletools.camera.R
private val RATIO_TOLERANCE = 0.2f
private val RATIO_TOLERANCE = 0.1f
fun Camera.Size.isSixteenToNine(): Boolean {
val selectedRatio = Math.abs(width / height.toFloat())
@ -10,3 +12,38 @@ fun Camera.Size.isSixteenToNine(): Boolean {
val diff = Math.abs(selectedRatio - checkedRatio)
return diff < RATIO_TOLERANCE
}
fun Camera.Size.isFourToThree(): Boolean {
val selectedRatio = Math.abs(width / height.toFloat())
val checkedRatio = 4 / 3.toFloat()
val diff = Math.abs(selectedRatio - checkedRatio)
return diff < RATIO_TOLERANCE
}
fun Camera.Size.isThreeToTwo(): Boolean {
val selectedRatio = Math.abs(width / height.toFloat())
val checkedRatio = 3 / 2.toFloat()
val diff = Math.abs(selectedRatio - checkedRatio)
return diff < RATIO_TOLERANCE
}
fun Camera.Size.isSixToFive(): Boolean {
val selectedRatio = Math.abs(width / height.toFloat())
val checkedRatio = 6 / 5.toFloat()
val diff = Math.abs(selectedRatio - checkedRatio)
return diff < RATIO_TOLERANCE
}
fun Camera.Size.getAspectRatio(context: Context): String {
return if (isSixteenToNine()) {
"16:9"
} else if (isFourToThree()) {
"4:3"
} else if (isThreeToTwo()) {
"3:2"
} else if (isSixToFive()) {
"6:5"
} else {
context.resources.getString(R.string.other)
}
}

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Wir benötigen Zugriff auf das Mirkofon um Videos aufnehmen zu können</string>
<string name="no_gallery_app_available">Keine Galerie App verfügbar</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Save photos and videos to</string>
<string name="show_preview">Zeige eine Vorschau des Photos nach der Aufnahme</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Se necesita el permiso de micrófono para grabar vídeos</string>
<string name="no_gallery_app_available">No hay disponible una aplicación de galería</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Guardar fotografías y vídeos en</string>
<string name="show_preview">Show a photo preview after capturing</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Nous avons besoin de l\'autorisation sur l\'audio pour enregistrer des vidéos</string>
<string name="no_gallery_app_available">Pas d\'application album disponible</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Sauvegarder les photos et vidéos vers</string>
<string name="show_preview">Apercevoir la photo après la prise</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">È necessario l\'accesso al microfono per registrare i video</string>
<string name="no_gallery_app_available">Nessuna app galleria disponibile</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Save photos and videos to</string>
<string name="show_preview">Show a photo preview after capturing</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">ビデオを記録するためにオーディオのアクセス許可が必要です</string>
<string name="no_gallery_app_available">利用可能なギャラリーアプリがありません</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">写真とビデオの保存先</string>
<string name="show_preview">キャプチャ後に写真のプレビューを表示</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Mums reikia audio leidimo, kad įrašyti vaizdo bylas</string>
<string name="no_gallery_app_available">Nėra galerijos programėlės</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Išsaugoti nuotraukas ir vaizdo įrašus į</string>
<string name="show_preview">Show a photo preview after capturing</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Necessitamos da permissão de áudio para gravar os vídeos</string>
<string name="no_gallery_app_available">Nenhuma aplicação de galeria disponível</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Guardar fotos e vídeos em</string>
<string name="show_preview">Mostrar pré-visualização após a captura</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">Нам нужно аудио разрешение для записи видео</string>
<string name="no_gallery_app_available">Нет доступного приложения-галереи</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Сохранять фото и видео в</string>
<string name="show_preview">Показывать сделанное фото</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">För att spela in video krävs ljudrättigheter</string>
<string name="no_gallery_app_available">Ingen galleri-app finns tillgänglig</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Save photos and videos to</string>
<string name="show_preview">Show a photo preview after capturing</string>

View File

@ -13,6 +13,9 @@
<string name="no_audio_permissions">We need the audio permission for recording videos</string>
<string name="no_gallery_app_available">No gallery app available</string>
<!-- other aspect ratio -->
<string name="other">other</string>
<!-- Settings -->
<string name="save_photos">Save photos and videos to</string>
<string name="show_preview">Show a photo preview after capturing</string>