Handle new permission in imgly SDK activities
This commit is contained in:
parent
46868cf262
commit
42c6e857fb
6 changed files with 11 additions and 59 deletions
|
@ -111,7 +111,7 @@ class ViewPagerActivity : SimpleActivity(), ViewPager.OnPageChangeListener, View
|
||||||
|
|
||||||
override fun onResume() {
|
override fun onResume() {
|
||||||
super.onResume()
|
super.onResume()
|
||||||
if (!hasPermission(getPermissionToRequest())) {
|
if (!hasPermission(getRequiredPermission())) {
|
||||||
finish()
|
finish()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -244,6 +244,8 @@ const val FOLDER_STYLE_ROUNDED_CORNERS = 2
|
||||||
|
|
||||||
fun getPermissionToRequest() = if (isTiramisuPlus()) PERMISSION_READ_MEDIA_IMAGES else PERMISSION_WRITE_STORAGE
|
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<Int> {
|
fun getPermissionsToRequest(): Collection<Int> {
|
||||||
val permissions = mutableListOf(getPermissionToRequest())
|
val permissions = mutableListOf(getPermissionToRequest())
|
||||||
if (isRPlus()) {
|
if (isRPlus()) {
|
||||||
|
|
|
@ -20,6 +20,7 @@ import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
|
import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
|
||||||
import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem
|
import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.helpers.getPermissionToRequest
|
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.PhotoEditorSettingsList
|
||||||
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
|
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
|
||||||
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
|
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
|
||||||
|
@ -62,7 +63,7 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePermission(getPermissionToRequest()) {
|
handlePartialMediaPermissions(getPermissionsToRequest()) {
|
||||||
if (it) {
|
if (it) {
|
||||||
initEditActivity()
|
initEditActivity()
|
||||||
} else {
|
} else {
|
||||||
|
@ -296,9 +297,9 @@ class NewPhotoEditActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val theme = if (isUsingSystemDarkTheme()) {
|
val theme = if (isUsingSystemDarkTheme()) {
|
||||||
R.style.Theme_Imgly_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
|
||||||
} else {
|
} else {
|
||||||
R.style.Theme_Imgly_Light_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
||||||
|
|
|
@ -17,6 +17,7 @@ import com.simplemobiletools.gallery.pro.extensions.config
|
||||||
import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
|
import com.simplemobiletools.gallery.pro.extensions.fixDateTaken
|
||||||
import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem
|
import com.simplemobiletools.gallery.pro.extensions.tryDeleteFileDirItem
|
||||||
import com.simplemobiletools.gallery.pro.helpers.getPermissionToRequest
|
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.VideoEditorSettingsList
|
||||||
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
|
import ly.img.android.pesdk.assets.filter.basic.FilterPackBasic
|
||||||
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
|
import ly.img.android.pesdk.assets.font.basic.FontPackBasic
|
||||||
|
@ -57,7 +58,7 @@ class NewVideoEditActivity : SimpleActivity() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
handlePermission(getPermissionToRequest()) {
|
handlePartialMediaPermissions(getPermissionsToRequest()) {
|
||||||
if (it) {
|
if (it) {
|
||||||
initEditActivity()
|
initEditActivity()
|
||||||
} else {
|
} else {
|
||||||
|
@ -274,9 +275,9 @@ class NewVideoEditActivity : SimpleActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
val theme = if (isUsingSystemDarkTheme()) {
|
val theme = if (isUsingSystemDarkTheme()) {
|
||||||
R.style.Theme_Imgly_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_NoFullscreen
|
||||||
} else {
|
} else {
|
||||||
R.style.Theme_Imgly_Light_NoFullscreen
|
ly.img.android.pesdk.ui.R.style.Theme_Imgly_Light_NoFullscreen
|
||||||
}
|
}
|
||||||
|
|
||||||
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
getSettingsModel(UiConfigTheme::class.java).theme = theme
|
||||||
|
|
49
build.gradle
49
build.gradle
|
@ -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
|
|
||||||
}
|
|
|
@ -1,3 +0,0 @@
|
||||||
include ':app'
|
|
||||||
//include ':commons'
|
|
||||||
//project(':commons').projectDir = new File('../Simple-Commons/commons')
|
|
Loading…
Reference in a new issue