1
0
mirror of https://github.com/KokaKiwi/BarInsta synced 2024-11-22 06:37:30 +00:00

show documentprovider error details

This commit is contained in:
Austin Huang 2021-06-26 13:56:47 -04:00
parent bdad254f5d
commit 9c811a6291
No known key found for this signature in database
GPG Key ID: 84C23AA04587A91F
4 changed files with 8 additions and 10 deletions

View File

@ -82,7 +82,7 @@ public class DirectorySelectActivity extends BaseLanguageActivity {
return;
}
if (!"com.android.externalstorage.documents".equals(data.getData().getAuthority())) {
showErrorDialog(getString(R.string.dir_select_no_download_folder));
showErrorDialog(getString(R.string.dir_select_no_download_folder, data.getData().getAuthority()));
return;
}
AppExecutors.INSTANCE.getMainThread().execute(() -> {

View File

@ -111,7 +111,7 @@ public class DownloadsPreferencesFragment extends BasePreferencesFragment {
R.string.error,
"com.android.externalstorage.documents".equals(data.getData().getAuthority())
? "Please report this error to the developers:\n\n" + sw.toString()
: getString(R.string.dir_select_no_download_folder),
: getString(R.string.dir_select_no_download_folder, data.getData().getAuthority()),
R.string.ok,
0,
0

View File

@ -38,8 +38,6 @@ object DownloadUtils {
private const val DIR_TEMP = "Temp"
private const val DIR_BACKUPS = "Backups"
private var root: DocumentFile? = null
const val WRITE_PERMISSION = Manifest.permission.WRITE_EXTERNAL_STORAGE
val PERMS = arrayOf(Manifest.permission.WRITE_EXTERNAL_STORAGE)
@JvmStatic
@Throws(ReselectDocumentTreeException::class)
fun init(
@ -49,11 +47,11 @@ object DownloadUtils {
if (isEmpty(barinstaDirUri)) {
throw ReselectDocumentTreeException("folder path is null or empty")
}
val uri = Uri.parse(barinstaDirUri)
if (!barinstaDirUri!!.startsWith("content://com.android.externalstorage.documents")) {
// reselect the folder in selector view
throw ReselectDocumentTreeException(Uri.parse(barinstaDirUri))
throw ReselectDocumentTreeException(uri)
}
val uri = Uri.parse(barinstaDirUri)
val existingPermissions = context.contentResolver.persistedUriPermissions
if (existingPermissions.isEmpty()) {
// reselect the folder in selector view
@ -150,7 +148,7 @@ object DownloadUtils {
list.add(DIR_DOWNLOADS)
return list
}
val finalUsername = if (username!!.startsWith("@")) username.substring(1) else username
val finalUsername = if (username.startsWith("@")) username.substring(1) else username
list.add(DIR_DOWNLOADS)
list.add(finalUsername)
return list
@ -337,7 +335,7 @@ object DownloadUtils {
private fun checkPathExists(paths: List<String>, context: Context): Boolean {
if (root == null) return false
val uri = root!!.getUri()
val uri = root!!.uri
var found = false
var docId = DocumentsContract.getTreeDocumentId(uri)
for (path in paths) {
@ -349,7 +347,7 @@ object DownloadUtils {
), null, null, null
)
if (docCursor == null) return false
while (docCursor!!.moveToNext() && !found) {
while (docCursor.moveToNext() && !found) {
if (path.equals(docCursor.getString(0))) {
docId = docCursor.getString(1)
found = true

View File

@ -512,7 +512,7 @@
<string name="dir_select_folder_not_exist">The previously selected folder does not exist now:</string>
<string name="dir_select_message2">Re-select the directory or select a new directory by clicking the button below.</string>
<string name="select_a_folder">No folder selected!</string>
<string name="dir_select_no_download_folder">Please choose a directory from your storage, not a category on the sidebar.</string>
<string name="dir_select_no_download_folder">Please choose a directory from your storage, not a category on the sidebar.\n(%s)</string>
<string name="dir_select_success_message">Success! Please wait. Starting app…</string>
<string name="barinsta_folder">Barinsta folder</string>
<string name="top">Top</string>