mirror of
https://gitee.com/zhangsken/AndroidIDE.git
synced 2026-10-16 07:49:44 +08:00
fix: catch exceptions while launching OPEN_DOCUMENT_TREE intent
This commit is contained in:
@@ -39,6 +39,7 @@ import androidx.core.provider.DocumentsContractCompat.buildDocumentUriUsingTree
|
||||
import androidx.core.provider.DocumentsContractCompat.getTreeDocumentId
|
||||
import androidx.documentfile.provider.DocumentFile
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.itsaky.androidide.common.R
|
||||
import com.itsaky.androidide.resources.R.string
|
||||
import com.itsaky.androidide.utils.flashError
|
||||
import java.io.File
|
||||
@@ -106,7 +107,11 @@ open class BaseFragment @JvmOverloads constructor(contentLayoutId: Int = 0) :
|
||||
|
||||
protected fun pickDirectory(dirCallback: OnDirectoryPickedCallback?) {
|
||||
this.callback = dirCallback
|
||||
this.startForResult.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE))
|
||||
try {
|
||||
this.startForResult.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE))
|
||||
} catch (e: Exception) {
|
||||
requireActivity().flashError(getString(R.string.msg_dir_picker_failed, e.message))
|
||||
}
|
||||
}
|
||||
|
||||
fun interface OnDirectoryPickedCallback {
|
||||
|
||||
@@ -541,4 +541,5 @@
|
||||
<string name="idepref_java_diagnosticEnabled_title">Diagnostics enabled</string>
|
||||
<string name="idepref_java_diagnosticsEnabled_summary">(EXPERIMENTAL) Whether the Java source files should be analyzed for errors or not.</string>
|
||||
<string name="title_reload_color_schemes">Reload color schemes</string>
|
||||
<string name="msg_dir_picker_failed">Failed to start directory picker : %1$s</string>
|
||||
</resources>
|
||||
|
||||
Reference in New Issue
Block a user