Merge pull request #1 from SimpleMobileTools/master

traer as actualizacións ao repositorio
This commit is contained in:
Xose M 2018-01-16 07:03:45 +01:00 committed by GitHub
commit a3a6102c7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
27 changed files with 181 additions and 36 deletions

View File

@ -1,6 +1,17 @@
Changelog
==========
Version 3.1.1 *(2018-01-14)*
----------------------------
* Fixing a crash at saving photos
Version 3.1.0 *(2018-01-13)*
----------------------------
* Allow changing the photo compression quality
* Make dark theme the default
Version 3.0.1 *(2017-12-07)*
----------------------------

View File

@ -4,14 +4,13 @@ apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
buildToolsVersion "27.0.1"
defaultConfig {
applicationId "com.simplemobiletools.camera"
minSdkVersion 16
targetSdkVersion 27
versionCode 51
versionName "3.0.1"
versionCode 53
versionName "3.1.1"
setProperty("archivesBaseName", "camera")
}
@ -42,7 +41,7 @@ ext {
}
dependencies {
implementation 'com.simplemobiletools:commons:3.2.3'
implementation 'com.simplemobiletools:commons:3.6.19'
debugImplementation "com.squareup.leakcanary:leakcanary-android:$leakCanaryVersion"
releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:$leakCanaryVersion"

View File

@ -6,7 +6,6 @@ import android.content.res.Resources
import android.hardware.Camera
import android.hardware.SensorManager
import android.net.Uri
import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.provider.MediaStore
@ -579,6 +578,7 @@ class MainActivity : SimpleActivity(), PreviewListener, PhotoProcessor.MediaSave
add(Release(39, R.string.release_39))
add(Release(44, R.string.release_44))
add(Release(46, R.string.release_46))
add(Release(52, R.string.release_52))
checkWhatsNew(this, BuildConfig.VERSION_CODE)
}
}

View File

@ -7,6 +7,7 @@ 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.dialogs.RadioGroupDialog
import com.simplemobiletools.commons.extensions.beVisibleIf
import com.simplemobiletools.commons.extensions.humanizePath
import com.simplemobiletools.commons.extensions.updateTextColors
@ -14,6 +15,7 @@ import com.simplemobiletools.commons.extensions.useEnglishToggled
import com.simplemobiletools.commons.helpers.LICENSE_GLIDE
import com.simplemobiletools.commons.helpers.LICENSE_KOTLIN
import com.simplemobiletools.commons.helpers.LICENSE_LEAK_CANARY
import com.simplemobiletools.commons.models.RadioItem
import kotlinx.android.synthetic.main.activity_settings.*
import java.io.File
import java.util.*
@ -39,6 +41,7 @@ class SettingsActivity : SimpleActivity() {
setupAlwaysOpenBackCamera()
setupSavePhotoMetadata()
setupSavePhotosFolder()
setupPhotoQuality()
updateTextColors(settings_holder)
}
@ -159,4 +162,27 @@ class SettingsActivity : SimpleActivity() {
}
}
}
private fun setupPhotoQuality() {
settings_photo_quality.text = "${config.photoQuality}%"
settings_photo_quality_holder.setOnClickListener {
val items = arrayListOf(
RadioItem(50, "50%"),
RadioItem(55, "55%"),
RadioItem(60, "60%"),
RadioItem(65, "65%"),
RadioItem(70, "70%"),
RadioItem(75, "75%"),
RadioItem(80, "80%"),
RadioItem(85, "85%"),
RadioItem(90, "90%"),
RadioItem(95, "95%"),
RadioItem(100, "100%"))
RadioGroupDialog(this@SettingsActivity, items, config.photoQuality) {
config.photoQuality = it as Int
settings_photo_quality.text = "${config.photoQuality}%"
}
}
}
}

View File

@ -85,4 +85,8 @@ class Config(context: Context) : BaseConfig(context) {
var savePhotoMetadata: Boolean
get() = prefs.getBoolean(SAVE_PHOTO_METADATA, true)
set(savePhotoMetadata) = prefs.edit().putBoolean(SAVE_PHOTO_METADATA, savePhotoMetadata).apply()
var photoQuality: Int
get() = prefs.getInt(PHOTO_QUALITY, 80)
set(photoQuality) = prefs.edit().putInt(PHOTO_QUALITY, photoQuality).apply()
}

View File

@ -22,6 +22,7 @@ val PHOTO_PREVIEW_HINT_SHOWN = "photo_preview_hint_shown"
val KEEP_SETTINGS_VISIBLE = "keep_settings_visible"
val ALWAYS_OPEN_BACK_CAMERA = "always_open_back_camera"
val SAVE_PHOTO_METADATA = "save_photo_metadata"
val PHOTO_QUALITY = "photo_quality"
val FLASH_OFF = 0
val FLASH_ON = 1

View File

@ -15,10 +15,7 @@ import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.extensions.getOutputMediaFile
import com.simplemobiletools.camera.extensions.getPreviewRotation
import com.simplemobiletools.commons.extensions.*
import java.io.File
import java.io.FileNotFoundException
import java.io.FileOutputStream
import java.io.OutputStream
import java.io.*
class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId: Int, val deviceOrientation: Int) : AsyncTask<ByteArray, Void, String>() {
@ -46,7 +43,7 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
val photoFile = File(path)
if (activity.needsStupidWritePermissions(path)) {
if (activity.config.treeUri.isEmpty()) {
if (!activity.hasProperStoredTreeUri()) {
activity.toast(R.string.save_error_internal_storage)
activity.config.savePhotosFolder = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).toString()
return ""
@ -89,24 +86,24 @@ class PhotoProcessor(val activity: MainActivity, val uri: Uri?, val currCameraId
image = Bitmap.createBitmap(image, 0, 0, image.width, image.height, matrix, false)
}
image.compress(Bitmap.CompressFormat.JPEG, 80, fos)
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
val fileExif = ExifInterface(path)
var exifOrientation = ExifInterface.ORIENTATION_NORMAL.toString()
if (path.startsWith(activity.internalStoragePath)) {
exifOrientation = getExifOrientation(totalRotation)
}
if (activity.config.savePhotoMetadata)
tempExif.copyTo(fileExif)
fileExif.setAttribute(ExifInterface.TAG_ORIENTATION, exifOrientation)
try {
fileExif.saveAttributes()
} catch (e: IOException) {
}
return photoFile.absolutePath
} catch (e: FileNotFoundException) {
} catch (e: Exception) {
activity.showErrorToast(e)
} finally {
fos?.close()
}

View File

@ -296,6 +296,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
isWaitingForTakePictureCallback = true
mIsPreviewShown = true
try {
Thread {
mCamera!!.takePicture(null, null, takePictureCallback)
if (config.isSoundEnabled) {
@ -306,6 +307,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mp?.start()
}
}
}.start()
} catch (ignored: Exception) {
}
}
@ -396,8 +398,9 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
}
camera.cancelAutoFocus()
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE))
if (focusModes.contains(Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE)) {
mParameters!!.focusMode = Camera.Parameters.FOCUS_MODE_CONTINUOUS_PICTURE
}
camera.parameters = mParameters
@ -584,7 +587,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mCamera!!.parameters = mParameters
Handler().postDelayed({
mActivity!!.runOnUiThread {
mActivity?.runOnUiThread {
mParameters?.flashMode = Camera.Parameters.FLASH_MODE_AUTO
mCamera?.parameters = mParameters
}
@ -617,7 +620,12 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
mCurrVideoPath = mActivity!!.getOutputMediaFile(false)
if (mCurrVideoPath.isEmpty()) {
mActivity!!.toast(R.string.video_creating_error)
mActivity?.toast(R.string.video_creating_error)
return false
}
if (mRecorder == null) {
mActivity?.toast(R.string.unknown_error_occurred)
return false
}
@ -627,6 +635,7 @@ class Preview : ViewGroup, SurfaceHolder.Callback, MediaScannerConnection.OnScan
} else {
CamcorderProfile.get(CamcorderProfile.QUALITY_LOW)
}
profile.apply {
videoFrameWidth = resolution.width
videoFrameHeight = resolution.height

View File

@ -264,5 +264,40 @@
android:clickable="false"/>
</RelativeLayout>
<RelativeLayout
android:id="@+id/settings_photo_quality_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/medium_margin"
android:background="?attr/selectableItemBackground"
android:paddingBottom="@dimen/bigger_margin"
android:paddingLeft="@dimen/activity_margin"
android:paddingRight="@dimen/activity_margin"
android:paddingTop="@dimen/bigger_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_photo_quality_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/settings_photo_quality"
android:layout_toStartOf="@+id/settings_photo_quality"
android:paddingLeft="@dimen/medium_margin"
android:paddingRight="@dimen/medium_margin"
android:text="@string/photo_compression_quality"/>
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/settings_photo_quality"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginEnd="@dimen/small_margin"
android:layout_marginRight="@dimen/small_margin"
android:background="@null"
android:clickable="false"/>
</RelativeLayout>
</LinearLayout>
</ScrollView>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">الكاميرا البسيطة</string>
<string name="app_launcher_name">الكاميرا</string>
<string name="camera_unavailable">الكاميرا غير متاحة</string>
<string name="camera_open_error">حدث خطأ أثناء الدخول إلى الكاميرا</string>
<string name="video_creating_error">حدث خطأ أثناء إنشاء ملف الفيديو</string>
<string name="video_mode_error">أخفق التبديل إلى وضع الفيديو</string>
<string name="save_error_internal_storage">حدث خطأ، تم تغيير مجلد الحفظ إلى وحدة التخزين الداخلية</string>
<string name="camera_switch_error">أخفق تبديل الكاميرا</string>
<string name="click_to_resume_preview">انقر على الصورة لاستئناف المعاينة</string>
<string name="photo_not_saved">تعذر حفظ الصورة</string>
<!-- other aspect ratio -->
<string name="other">آخرى</string>
<!-- Settings -->
<string name="save_photos">حفظ الصور ومقاطع الفيديو إلى</string>
<string name="show_preview">عرض معاينة الصورة بعد التقاطها</string>
<string name="shutter_sound">صوت الغالق</string>
<string name="back_camera">دقة الكاميرا الخلفية</string>
<string name="front_camera">دقة الكاميرا الامامية</string>
<string name="photo">الصور</string>
<string name="video">الفديو</string>
<string name="focus_before_capture">تركيز قبل الإلتقاط</string>
<string name="volume_buttons_as_shutter">استخدام أزرار الصوت للإلتقاط</string>
<string name="turn_flash_off_at_startup">إيقاف تشغيل الفلاش عند بدء التشغيل</string>
<string name="flip_front_camera_photos_horizontally">قلب صور الكاميرا الأمامية أفقيا</string>
<string name="keep_settings_visible">إبقاء أزرار الإعداد مرئيا</string>
<string name="always_open_back_camera">دائما فتح التطبيق مع الكاميرا الخلفية</string>
<string name="save_photo_metadata">حفظ بيانات الصورة الوصفية</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
<string name="app_short_description">كاميرا مع فلاش، والتكبير وبدون أي إعلانات.</string>
<string name="app_long_description">الكاميرا يمكن استخدامها لكل من التقاط الصور وتسجيل الفيديو. يمكنك التبديل بين الكاميرا الأمامية والخلفية، تعديل مسار الحفظ وتحديد الدقة . يمكن تشغيل وإيقاف الوميض أو استخدامها كمصباح. يمكنك القرص للتكبير والتصغير. إذا كنت ترغب في تشغيل هذا التطبيق عبر الضغط على زر الكاميرا الأجهزة ، قد تضطر إلى تعطيل الخيار المدمج في التطبيق الكاميرا في إعدادات -> تطبيقات -> كاميرا -> تعطيل. \n
لا يحتوي على إعلانات أو أذونات لا حاجة لها. مفتوح المصدر بشكل كامل، ويوفر الألوان للتخصيص. هذا التطبيق هو مجرد قطعة واحدة من سلسلة أكبر من التطبيقات. يمكنك العثور على بقيتهم هنا\n
http://www.simplemobiletools.com</string>
<!--
Haven't found some strings? There's more at
https://github.com/SimpleMobileTools/Simple-Commons/tree/master/commons/src/main/res
-->
</resources>

View File

@ -29,18 +29,19 @@
<string name="keep_settings_visible">Button für Einstellungen immer sichtbar</string>
<string name="always_open_back_camera">Starte App immer mit der Rückkamera</string>
<string name="save_photo_metadata">Exif-Metadaten speichern</string>
<string name="photo_compression_quality">Foto-Komprimierungsqualität</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->
<string name="app_short_description">Eine schlichte Kamera mit Blitzlicht, Zoom und ohne Werbung.</string>
<string name="app_short_description">Eine schlichte Kamera mit Blitzlicht und Zoom, ganz ohne Werbung.</string>
<string name="app_long_description">
Die Kamera kann sowohl zum Schießen von Fotos, als auch zum Aufnehmen von Videos genutzt werden. Wechsle zwischen Front- und Rückkamera, verändere den Pfad, in dem die Bilder gespeichert werden oder verändere die Bild-Auflösung. Der Blitz kann an- und ausgeschaltet werden, und als Taschenlampe benutzt werden. Mit den Fingern kann gezoomt werden.
Die Kamera kann sowohl zum Schießen von Fotos, als auch zum Aufnehmen von Videos genutzt werden. Wechsle zwischen Front- und Rückkamera, verändere den Pfad, in dem Bilder gespeichert werden, oder ändere die Bildauflösung. Der Blitz kann ein- und ausgeschaltet werden oder als Taschenlampe benutzt werden. Mit den Fingern kann gezoomt werden.
Falls du diese App durch einen Hardware-Kameraknopf starten möchtest, kann es sein, dass du die vorinstallierte Kamera-App erst deaktivieren musst unter Einstellungen -> Apps -> Kamera -> deaktivieren.
Falls du diese App durch einen Hardware-Kameraknopf starten möchtest, musst du vielleicht die vorinstallierte Kamera-App erst deaktivieren, unter Einstellungen -> Apps -> Kamera -> deaktivieren.
Beinhaltet weder Werbung, noch unnötige Berechtigungen. Sie ist komplett Open Source und beinhaltet anpassbare Farben.
Beinhaltet keine Werbung oder unnötige Berechtigungen. Sie ist komplett Open Source, alle verwendeten Farben sind anpassbar.
Diese App ist Teil einer größeren Serie von Apps. Diese findet man unter http://www.simplemobiletools.com
Diese App ist nur eine aus einer größeren Serie von schlichten Apps. Der Rest davon findet sich auf http://www.simplemobiletools.com
</string>
<!--

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Garder visible les boutons de réglage</string>
<string name="always_open_back_camera">Toujours ouvrir l\'application avec la caméra arrière</string>
<string name="save_photo_metadata">Sauvegarder les méta-données exif de la photo</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Play Store. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Manter visibles os botóns de axustes</string>
<string name="always_open_back_camera">Abrir sempre o aplicativo coa cámara traseira</string>
<string name="save_photo_metadata">Gardar metadatos exif da foto</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Pozostawiaj widoczne przyciski ustawień</string>
<string name="always_open_back_camera">Zawsze otwieraj aplikację z włączoną tylnią kamerą</string>
<string name="save_photo_metadata">Zapisuj metadane exif zdjęcia</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Manter o botão de configurações visível</string>
<string name="always_open_back_camera">Sempre abrir o app com a câmera traseira</string>
<string name="save_photo_metadata">Salvar metadados exif com a foto</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Botão de definições sempre visível</string>
<string name="always_open_back_camera">Abrir a aplicação sempre com a câmara traseira</string>
<string name="save_photo_metadata">Guardar dados exif das fotos</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Всегда показывать панель настроек</string>
<string name="always_open_back_camera">Всегда включать заднюю камеру при запуске</string>
<string name="save_photo_metadata">Сохранять данные EXIF</string>
<string name="photo_compression_quality">Качество фото после сжатия</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Neskrývať tlačidlá nastavení</string>
<string name="always_open_back_camera">Stále otvárať aplikáciu s aktívnou zadnou kamerou</string>
<string name="save_photo_metadata">Ukladať exif metadáta fotografií</string>
<string name="photo_compression_quality">Kvalita kompresie fotiek</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->

View File

@ -1,4 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<!-- Default colors -->
<color name="default_text_color">@color/theme_dark_text_color</color>
<color name="default_background_color">@color/theme_dark_background_color</color>
</resources>

View File

@ -2,6 +2,7 @@
<resources>
<!-- Release notes -->
<string name="release_52">Allow changing the photo compression quality</string>
<string name="release_46">Added optional exif metadata saving, enabled by default</string>
<string name="release_44">Added a toggle for flipping front camera photos horizontally</string>
<string name="release_39">

View File

@ -29,6 +29,7 @@
<string name="keep_settings_visible">Keep setting buttons visible</string>
<string name="always_open_back_camera">Always open the app with the Back camera</string>
<string name="save_photo_metadata">Save photo exif metadata</string>
<string name="photo_compression_quality">Photo compression quality</string>
<!-- Strings displayed only on Google Playstore. Optional, but good to have -->
<!-- Short description has to have less than 80 chars -->