require the All Files access in foss and prepaid app variants

This commit is contained in:
tibbi 2022-05-14 15:15:43 +02:00
parent ba6ed86828
commit 4936eecb17
5 changed files with 33 additions and 2 deletions

View file

@ -78,7 +78,7 @@ android {
} }
dependencies { dependencies {
implementation 'com.github.SimpleMobileTools:Simple-Commons:06110ebf15' implementation 'com.github.SimpleMobileTools:Simple-Commons:a2b7c9c278'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0' implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
implementation 'it.sephiroth.android.exif:library:1.0.1' implementation 'it.sephiroth.android.exif:library:1.0.1'
implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24' implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.24'

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<resources> <resources>
<bool name="show_donate_in_about">true</bool> <bool name="show_donate_in_about">true</bool>
<bool name="require_all_files_access">true</bool>
</resources> </resources>

View file

@ -12,9 +12,11 @@ import android.graphics.drawable.Drawable
import android.graphics.drawable.LayerDrawable import android.graphics.drawable.LayerDrawable
import android.net.Uri import android.net.Uri
import android.os.Build import android.os.Build
import android.os.Environment
import android.provider.MediaStore import android.provider.MediaStore
import android.provider.MediaStore.Files import android.provider.MediaStore.Files
import android.provider.MediaStore.Images import android.provider.MediaStore.Images
import android.provider.Settings
import android.util.DisplayMetrics import android.util.DisplayMetrics
import android.view.View import android.view.View
import androidx.appcompat.app.AppCompatActivity import androidx.appcompat.app.AppCompatActivity
@ -24,6 +26,7 @@ import com.bumptech.glide.load.DecodeFormat
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.request.RequestOptions import com.bumptech.glide.request.RequestOptions
import com.simplemobiletools.commons.activities.BaseSimpleActivity import com.simplemobiletools.commons.activities.BaseSimpleActivity
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
import com.simplemobiletools.commons.dialogs.ConfirmationDialog import com.simplemobiletools.commons.dialogs.ConfirmationDialog
import com.simplemobiletools.commons.extensions.* import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.* import com.simplemobiletools.commons.helpers.*
@ -127,7 +130,29 @@ fun SimpleActivity.launchAbout() {
} }
fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) { fun BaseSimpleActivity.handleMediaManagementPrompt(callback: () -> Unit) {
if (isSPlus() && !MediaStore.canManageMedia(this) && !isExternalStorageManager()) { if (isRPlus() && resources.getBoolean(R.bool.require_all_files_access)) {
if (Environment.isExternalStorageManager()) {
callback()
} else {
ConfirmationAdvancedDialog(this, "", R.string.access_storage_prompt, R.string.ok, 0) { success ->
if (success) {
try {
val intent = Intent(Settings.ACTION_MANAGE_APP_ALL_FILES_ACCESS_PERMISSION)
intent.addCategory("android.intent.category.DEFAULT")
intent.data = Uri.parse("package:$packageName")
startActivity(intent)
} catch (e: Exception) {
showErrorToast(e)
val intent = Intent()
intent.action = Settings.ACTION_MANAGE_ALL_FILES_ACCESS_PERMISSION
startActivity(intent)
}
} else {
finish()
}
}
}
} else if (isSPlus() && !MediaStore.canManageMedia(this) && !isExternalStorageManager()) {
ConfirmationDialog(this, "", R.string.media_management_prompt, R.string.ok, 0) { ConfirmationDialog(this, "", R.string.media_management_prompt, R.string.ok, 0) {
launchMediaManagementIntent(callback) launchMediaManagementIntent(callback)
} }

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="require_all_files_access">false</bool>
</resources>

View file

@ -3,4 +3,5 @@
<bool name="show_donate_in_about">false</bool> <bool name="show_donate_in_about">false</bool>
<bool name="hide_google_relations">true</bool> <bool name="hide_google_relations">true</bool>
<bool name="hide_all_external_links">true</bool> <bool name="hide_all_external_links">true</bool>
<bool name="require_all_files_access">true</bool>
</resources> </resources>