diff --git a/app/build.gradle b/app/build.gradle index fc791ef83..b158eb122 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -77,7 +77,7 @@ android { } dependencies { - implementation 'com.github.SimpleMobileTools:Simple-Commons:9d9b24290c' + implementation 'com.github.SimpleMobileTools:Simple-Commons:cab93be34d' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24' diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt index 7bc411fc9..33a312862 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/activities/SettingsActivity.kt @@ -455,8 +455,10 @@ class SettingsActivity : SimpleActivity() { private fun setupKeepLastModified() { settings_keep_last_modified.isChecked = config.keepLastModified settings_keep_last_modified_holder.setOnClickListener { - settings_keep_last_modified.toggle() - config.keepLastModified = settings_keep_last_modified.isChecked + handleMediaManagementPrompt { + settings_keep_last_modified.toggle() + config.keepLastModified = settings_keep_last_modified.isChecked + } } } diff --git a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt index 767dd376e..f662f4212 100644 --- a/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/gallery/pro/extensions/Activity.kt @@ -15,8 +15,10 @@ import android.os.Build import android.provider.MediaStore import android.provider.MediaStore.Files import android.provider.MediaStore.Images +import android.provider.Settings import android.util.DisplayMetrics import android.view.View +import androidx.annotation.RequiresApi import androidx.appcompat.app.AppCompatActivity import androidx.exifinterface.media.ExifInterface import com.bumptech.glide.Glide @@ -123,6 +125,24 @@ fun SimpleActivity.launchAbout() { startAboutActivity(R.string.app_name, licenses, BuildConfig.VERSION_NAME, faqItems, true) } +@RequiresApi(Build.VERSION_CODES.S) +fun SimpleActivity.launchMediaManagementIntent() { + Intent(Settings.ACTION_REQUEST_MANAGE_MEDIA).apply { + data = Uri.parse("package:$packageName") + startActivity(this) + } +} + +fun SimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { + if (isSPlus() && !MediaStore.canManageMedia(this)) { + ConfirmationDialog(this, "", R.string.media_management_prompt, R.string.ok, 0) { + launchMediaManagementIntent() + } + } else { + callback() + } +} + fun AppCompatActivity.showSystemUI(toggleActionBarVisibility: Boolean) { if (toggleActionBarVisibility) { supportActionBar?.show()