make sure Recents are loaded properly at first launch, after granting permission

This commit is contained in:
tibbi 2021-05-19 23:12:44 +02:00
parent e22322b2d5
commit d8fad97da2
1 changed files with 7 additions and 2 deletions

View File

@ -259,6 +259,7 @@ class MainActivity : SimpleActivity() {
} }
private fun tryInitFileManager() { private fun tryInitFileManager() {
val hadPermission = hasPermission(PERMISSION_WRITE_STORAGE)
handlePermission(PERMISSION_WRITE_STORAGE) { handlePermission(PERMISSION_WRITE_STORAGE) {
checkOTGPath() checkOTGPath()
if (it) { if (it) {
@ -267,7 +268,7 @@ class MainActivity : SimpleActivity() {
} }
main_view_pager.onGlobalLayout { main_view_pager.onGlobalLayout {
initFileManager() initFileManager(!hadPermission)
} }
} else { } else {
toast(R.string.no_storage_permissions) toast(R.string.no_storage_permissions)
@ -276,7 +277,7 @@ class MainActivity : SimpleActivity() {
} }
} }
private fun initFileManager() { private fun initFileManager(refreshRecents: Boolean) {
if (intent.action == Intent.ACTION_VIEW && intent.data != null) { if (intent.action == Intent.ACTION_VIEW && intent.data != null) {
val data = intent.data val data = intent.data
if (data?.scheme == "file") { if (data?.scheme == "file") {
@ -302,6 +303,10 @@ class MainActivity : SimpleActivity() {
it?.isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT it?.isGetContentIntent = intent.action == Intent.ACTION_GET_CONTENT
it?.isPickMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false) it?.isPickMultipleIntent = intent.getBooleanExtra(Intent.EXTRA_ALLOW_MULTIPLE, false)
} }
if (refreshRecents) {
recents_fragment?.refreshItems()
}
} }
private fun initFragments() { private fun initFragments() {