lets set the minimal required OS version to Android 10

This commit is contained in:
tibbi 2022-04-20 21:20:40 +02:00
parent 77458cc759
commit 196f477d3e
3 changed files with 20 additions and 16 deletions

View File

@ -13,7 +13,7 @@ android {
defaultConfig { defaultConfig {
applicationId "com.simplemobiletools.camera" applicationId "com.simplemobiletools.camera"
minSdkVersion 21 minSdkVersion 29
targetSdkVersion 31 targetSdkVersion 31
versionCode 77 versionCode 77
versionName "5.3.1" versionName "5.3.1"

View File

@ -46,10 +46,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
var mLastHandledOrientation = 0 var mLastHandledOrientation = 0
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
window.addFlags(WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or window.addFlags(
WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD or
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED or
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON or
WindowManager.LayoutParams.FLAG_FULLSCREEN) WindowManager.LayoutParams.FLAG_FULLSCREEN
)
useDynamicTheme = false useDynamicTheme = false
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
@ -194,7 +196,12 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
setContentView(R.layout.activity_main) setContentView(R.layout.activity_main)
initButtons() initButtons()
(btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(0, 0, 0, (navigationBarHeight + resources.getDimension(R.dimen.activity_margin)).toInt()) (btn_holder.layoutParams as RelativeLayout.LayoutParams).setMargins(
0,
0,
0,
(navigationBarHeight + resources.getDimension(R.dimen.activity_margin)).toInt()
)
checkVideoCaptureIntent() checkVideoCaptureIntent()
mPreview = CameraPreview(this, camera_texture_view, mIsInPhotoMode) mPreview = CameraPreview(this, camera_texture_view, mIsInPhotoMode)
@ -202,7 +209,8 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener {
checkImageCaptureIntent() checkImageCaptureIntent()
mPreview?.setIsImageCaptureIntent(isImageCaptureIntent()) mPreview?.setIsImageCaptureIntent(isImageCaptureIntent())
val imageDrawable = if (config.lastUsedCamera == mCameraImpl.getBackCameraId().toString()) R.drawable.ic_camera_front_vector else R.drawable.ic_camera_rear_vector val imageDrawable =
if (config.lastUsedCamera == mCameraImpl.getBackCameraId().toString()) R.drawable.ic_camera_front_vector else R.drawable.ic_camera_rear_vector
toggle_camera.setImageResource(imageDrawable) toggle_camera.setImageResource(imageDrawable)
mFocusCircleView = FocusCircleView(applicationContext) mFocusCircleView = FocusCircleView(applicationContext)

View File

@ -1,12 +1,10 @@
package com.simplemobiletools.camera.helpers package com.simplemobiletools.camera.helpers
import android.annotation.TargetApi
import android.graphics.Bitmap import android.graphics.Bitmap
import android.graphics.BitmapFactory import android.graphics.BitmapFactory
import android.graphics.Matrix import android.graphics.Matrix
import android.net.Uri import android.net.Uri
import android.os.AsyncTask import android.os.AsyncTask
import android.os.Build
import android.os.Environment import android.os.Environment
import androidx.exifinterface.media.ExifInterface import androidx.exifinterface.media.ExifInterface
import com.simplemobiletools.camera.R import com.simplemobiletools.camera.R
@ -14,17 +12,17 @@ import com.simplemobiletools.camera.activities.MainActivity
import com.simplemobiletools.camera.extensions.config import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.extensions.getOutputMediaFile import com.simplemobiletools.camera.extensions.getOutputMediaFile
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.isNougatPlus
import java.io.File import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
import java.io.FileOutputStream import java.io.FileOutputStream
import java.io.OutputStream import java.io.OutputStream
class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOrientation: Int, val previewRotation: Int, val isUsingFrontCamera: Boolean, class PhotoProcessor(
val isThirdPartyIntent: Boolean) : val activity: MainActivity, val saveUri: Uri?, val deviceOrientation: Int, val previewRotation: Int, val isUsingFrontCamera: Boolean,
val isThirdPartyIntent: Boolean
) :
AsyncTask<ByteArray, Void, String>() { AsyncTask<ByteArray, Void, String>() {
@TargetApi(Build.VERSION_CODES.N)
override fun doInBackground(vararg params: ByteArray): String { override fun doInBackground(vararg params: ByteArray): String {
var fos: OutputStream? = null var fos: OutputStream? = null
val path: String val path: String
@ -86,9 +84,7 @@ class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOr
var image = BitmapFactory.decodeByteArray(data, 0, data.size) var image = BitmapFactory.decodeByteArray(data, 0, data.size)
val totalRotation = (imageRot + deviceRot + previewRotation) % 360 val totalRotation = (imageRot + deviceRot + previewRotation) % 360
if (path.startsWith(activity.internalStoragePath) || isNougatPlus() && !isThirdPartyIntent) { if (isThirdPartyIntent) {
// do not rotate the image itself in these cases, rotate it by exif only
} else {
// make sure the image itself is rotated at third party intents // make sure the image itself is rotated at third party intents
image = rotate(image, totalRotation) image = rotate(image, totalRotation)
} }
@ -109,7 +105,7 @@ class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOr
try { try {
image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos) image.compress(Bitmap.CompressFormat.JPEG, activity.config.photoQuality, fos)
if (!isThirdPartyIntent && isNougatPlus()) { if (!isThirdPartyIntent) {
activity.saveImageRotation(path, totalRotation) activity.saveImageRotation(path, totalRotation)
} }
} catch (e: Exception) { } catch (e: Exception) {
@ -118,7 +114,7 @@ class PhotoProcessor(val activity: MainActivity, val saveUri: Uri?, val deviceOr
} }
if (activity.config.savePhotoMetadata && !isThirdPartyIntent) { if (activity.config.savePhotoMetadata && !isThirdPartyIntent) {
val exifInterface = if (path.startsWith(activity.internalStoragePath) || !isNougatPlus()) { val exifInterface = if (path.startsWith(activity.internalStoragePath)) {
ExifInterface(path) ExifInterface(path)
} else { } else {
val documentFile = activity.getSomeDocumentFile(path) val documentFile = activity.getSomeDocumentFile(path)