From 42c6e857fb994d12afb8c78431b49f917cf37589 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Wed, 9 Aug 2023 12:57:19 +0200 Subject: [PATCH] Handle new permission in imgly SDK activities --- .../pro/activities/ViewPagerActivity.kt | 2 +- .../gallery/pro/helpers/Constants.kt | 2 + .../pro/activities/NewPhotoEditActivity.kt | 7 +-- .../pro/activities/NewVideoEditActivity.kt | 7 +-- build.gradle | 49 ------------------- settings.gradle | 3 -- 6 files changed, 11 insertions(+), 59 deletions(-) delete mode 100644 build.gradle delete mode 100644 settings.gradle diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt index 9e75c7fbb..1027578f6 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/ViewPagerActivity.kt @@ -111,7 +111,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View override fun onResume() { super.onResume() - if (!hasPermission(getPermissionToRequest())) { + if (!hasPermission(getRequiredPermission())) { finish() return } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt index 4546d6039..c5a68d828 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/helpers/Constants.kt @@ -244,6 +244,8 @@ const val FOLDER_STYLE_ROUNDED_CORNERS = 2 fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE +fun getRequiredPermission() = if (isUpsideDownCakePlus()) PERMISSION_READ_MEDIA_VISUAL_USER_SELECTED else getPermissionToRequest() + fun getPermissionsToRequest(): Collection { val permissions = mutableListOf(getPermissionToRequest()) if (isRPlus()) { diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt index 793f0386f..9a0ba34e7 100644 --- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt +++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewPhotoEditActivity.kt @@ -20,6 +20,7 @@ import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.fixDateTaken import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem import com.simplemobiletools.gallery.pro.helpers.getPermissionToRequest +import com.simplemobiletools.gallery.pro.helpers.getPermissionsToRequest import ly.img.android.pesdk.PhotoEditorSettingsList import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic import ly.img.android.pesdk.assets.font.basic.FontPackBasic @@ -62,7 +63,7 @@ class NewPhotoEditActivity : SimpleActivity() { return } - handlePermission(getPermissionToRequest()) { + handlePartialMediaPermissions(getPermissionsToRequest()) { if (it) { initEditActivity() } else { @@ -296,9 +297,9 @@ class NewPhotoEditActivity : SimpleActivity() { } val theme = if (isUsingSystemDarkTheme()) { - R.style.Theme_Imgly_NoFullscreen + ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen } else { - R.style.Theme_Imgly_Light_NoFullscreen + ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen } getSettingsModel(UiConfigTheme::class.java).theme = theme diff --git a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt index e17f22a22..66be52e82 100644 --- a/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt +++ b/app/src/proprietary/kotlin/com/simplemobiletools/gallery/pro/activities/NewVideoEditActivity.kt @@ -17,6 +17,7 @@ import com.simplemobiletools.gallery.pro.extensions.config import com.simplemobiletools.gallery.pro.extensions.fixDateTaken import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem import com.simplemobiletools.gallery.pro.helpers.getPermissionToRequest +import com.simplemobiletools.gallery.pro.helpers.getPermissionsToRequest import ly.img.android.pesdk.VideoEditorSettingsList import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic import ly.img.android.pesdk.assets.font.basic.FontPackBasic @@ -57,7 +58,7 @@ class NewVideoEditActivity : SimpleActivity() { return } - handlePermission(getPermissionToRequest()) { + handlePartialMediaPermissions(getPermissionsToRequest()) { if (it) { initEditActivity() } else { @@ -274,9 +275,9 @@ class NewVideoEditActivity : SimpleActivity() { } val theme = if (isUsingSystemDarkTheme()) { - R.style.Theme_Imgly_NoFullscreen + ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen } else { - R.style.Theme_Imgly_Light_NoFullscreen + ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen } getSettingsModel(UiConfigTheme::class.java).theme = theme diff --git a/build.gradle b/build.gradle deleted file mode 100644 index 8e8e41680..000000000 --- a/build.gradle +++ /dev/null @@ -1,49 +0,0 @@ -// Top-level build file where you can add configuration options common to all sub-projects/modules. - -buildscript { - // needed only if we are including commons locally from our pc, not via Jitpack - /*ext { - propCompileSdkVersion = 33 - propMinSdkVersion = 23 - propTargetSdkVersion = propCompileSdkVersion - propVersionCode = 1 - propVersionName = '5.34.26' - }*/ - - ext.kotlin_version = '1.9.0' - ext.is_proprietary = gradle.startParameter.taskNames.any { task -> task.contains("Proprietary") } - - repositories { - google() - jcenter() - if (is_proprietary) { - maven { url 'https://artifactory.img.ly/artifactory/imgly' } - } - } - - dependencies { - classpath 'com.android.tools.build:gradle:8.1.0' - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" - if (is_proprietary) { - classpath 'ly.img.android.pesdk:plugin:10.7.3' - } - - // NOTE: Do not place your application dependencies here; they belong - // in the individual module build.gradle files - } -} - -allprojects { - repositories { - google() - jcenter() - maven { url "https://jitpack.io" } - if (is_proprietary) { - maven { url 'https://artifactory.img.ly/artifactory/imgly' } - } - } -} - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/settings.gradle b/settings.gradle deleted file mode 100644 index d100c1c8e..000000000 --- a/settings.gradle +++ /dev/null @@ -1,3 +0,0 @@ -include ':app' -//include ':commons' -//project(':commons').projectDir = new File('../Simple-Commons/commons')