Skip to content

Commit b425ab9

Browse files
committed
allow changing the storage in the main activity
1 parent b1c9822 commit b425ab9

File tree

1 file changed

+15
-5
lines changed
  • app/src/main/kotlin/com/simplemobiletools/filemanager/activities

1 file changed

+15
-5
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/activities/MainActivity.kt

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ import com.simplemobiletools.filemanager.Constants
1212
import com.simplemobiletools.filemanager.R
1313
import com.simplemobiletools.filemanager.Utils
1414
import com.simplemobiletools.filemanager.fragments.ItemsFragment
15+
import com.simplemobiletools.filepicker.dialogs.StoragePickerDialog
1516
import com.simplemobiletools.filepicker.extensions.getInternalPath
1617
import com.simplemobiletools.filepicker.models.FileDirItem
1718
import com.simplemobiletools.filepicker.views.Breadcrumbs
1819
import kotlinx.android.synthetic.main.activity_main.*
1920

2021
class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Breadcrumbs.BreadcrumbsListener {
22+
var mBasePath = getInternalPath()
2123

2224
override fun onCreate(savedInstanceState: Bundle?) {
2325
super.onCreate(savedInstanceState)
@@ -56,11 +58,11 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
5658
}
5759

5860
private fun initRootFileManager() {
59-
openPath(getInternalPath())
61+
openPath(mBasePath)
6062
}
6163

6264
private fun openPath(path: String) {
63-
breadcrumbs.setBreadcrumb(path, getInternalPath())
65+
breadcrumbs.setBreadcrumb(path, mBasePath)
6466
val bundle = Bundle()
6567
bundle.putString(Constants.PATH, path)
6668

@@ -123,12 +125,20 @@ class MainActivity : SimpleActivity(), ItemsFragment.ItemInteractionListener, Br
123125
}
124126

125127
override fun breadcrumbClicked(id: Int) {
126-
val item = breadcrumbs.getChildAt(id).tag as FileDirItem
127-
openPath(item.path)
128+
if (id == 0) {
129+
StoragePickerDialog(this@MainActivity, mBasePath, object : StoragePickerDialog.OnStoragePickerListener {
130+
override fun onPick(pickedPath: String) {
131+
mBasePath = pickedPath
132+
openPath(pickedPath)
133+
}
134+
})
135+
} else {
136+
val item = breadcrumbs.getChildAt(id).tag as FileDirItem
137+
openPath(item.path)
138+
}
128139
}
129140

130141
companion object {
131-
132142
private val STORAGE_PERMISSION = 1
133143
private val BACK_PRESS_TIMEOUT = 5000
134144

0 commit comments

Comments
 (0)