add a prompt for making the app the default media management app

This commit is contained in:
tibbi 2022-04-24 16:11:51 +02:00
parent dc2605e723
commit 6428836c73
3 changed files with 25 additions and 3 deletions

View file

@ -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'

View file

@ -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
}
}
}

View file

@ -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()