From 0a33abd501a43fd0f69ae74caa992e834e67c3bb Mon Sep 17 00:00:00 2001 From: Benjamin Meier Date: Tue, 10 Oct 2023 21:53:08 +0200 Subject: [PATCH] android 13 permission issue backport for 1.5.2 --- app/build.gradle | 6 +++--- app/src/main/AndroidManifest.xml | 5 +++++ .../com/gowtham/videotrimmer/MainActivity.java | 15 +++++++++++++-- library/build.gradle | 6 +++--- .../com/gowtham/library/ui/ActVideoTrimmer.java | 8 +++++++- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index 1593b86..e468044 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,13 +1,13 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 29 + compileSdkVersion 33 buildToolsVersion "30.0.0" defaultConfig { applicationId "com.gowtham.videotrimmer" - minSdkVersion 19 - targetSdkVersion 29 + minSdkVersion 21 + targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 31d6f12..20b9a98 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -3,6 +3,11 @@ xmlns:tools="http://schemas.android.com/tools" package="com.gowtham.videotrimmer"> + + + diff --git a/app/src/main/java/com/gowtham/videotrimmer/MainActivity.java b/app/src/main/java/com/gowtham/videotrimmer/MainActivity.java index 2f3a0e0..4954ee8 100644 --- a/app/src/main/java/com/gowtham/videotrimmer/MainActivity.java +++ b/app/src/main/java/com/gowtham/videotrimmer/MainActivity.java @@ -4,6 +4,7 @@ import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.util.Log; import android.view.View; @@ -224,8 +225,18 @@ private long getEdtValueLong(EditText editText) { } private boolean checkCamStoragePer() { - return checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, - Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA); + // return checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, + // Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA); + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) + { + return checkPermission( + Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.CAMERA); + } + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + return checkPermission( + Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.CAMERA); + } else + return checkPermission(Manifest.permission.READ_EXTERNAL_STORAGE,Manifest.permission.CAMERA); } private boolean checkPermission(String... permissions) { diff --git a/library/build.gradle b/library/build.gradle index 8131074..c0d5916 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -1,11 +1,11 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 30 + compileSdkVersion 33 buildToolsVersion "30.0.0" defaultConfig { - minSdkVersion 19 - targetSdkVersion 30 + minSdkVersion 21 + targetSdkVersion 33 versionCode 1 versionName "1.0" diff --git a/library/src/main/java/com/gowtham/library/ui/ActVideoTrimmer.java b/library/src/main/java/com/gowtham/library/ui/ActVideoTrimmer.java index d952082..048aaf9 100644 --- a/library/src/main/java/com/gowtham/library/ui/ActVideoTrimmer.java +++ b/library/src/main/java/com/gowtham/library/ui/ActVideoTrimmer.java @@ -595,7 +595,13 @@ private void showProcessingDialog() { } private boolean checkStoragePermission() { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + // if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) + { + return checkPermission( + Manifest.permission.READ_MEDIA_VIDEO, Manifest.permission.ACCESS_MEDIA_LOCATION); + } + else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { return checkPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE, Manifest.permission.READ_EXTERNAL_STORAGE, Manifest.permission.ACCESS_MEDIA_LOCATION); } else