Skip to content

Commit d1e75ef

Browse files
authored
Merge pull request #745 from esensar/feature/678-sdcard-storage-analysis
Add SD card to storage analysis
2 parents 4a9d047 + 69bddaa commit d1e75ef

File tree

8 files changed

+523
-376
lines changed

8 files changed

+523
-376
lines changed

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/activities/MimeTypesActivity.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
4040
private var zoomListener: MyRecyclerView.MyZoomListener? = null
4141
private var storedItems = ArrayList<ListItem>()
4242
private var currentViewType = VIEW_TYPE_LIST
43+
private var currentVolume = PRIMARY_VOLUME_NAME
4344

4445
override fun onCreate(savedInstanceState: Bundle?) {
4546
isMaterialActivity = true
@@ -53,6 +54,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
5354
}
5455

5556
currentMimeType = intent.getStringExtra(SHOW_MIMETYPE) ?: return
57+
currentVolume = intent.getStringExtra(VOLUME_NAME) ?: currentVolume
5658
binding.mimetypesToolbar.title = getString(
5759
when (currentMimeType) {
5860
IMAGES -> R.string.images
@@ -267,7 +269,7 @@ class MimeTypesActivity : SimpleActivity(), ItemOperationsListener {
267269
private fun getProperFileDirItems(callback: (ArrayList<FileDirItem>) -> Unit) {
268270
val fileDirItems = ArrayList<FileDirItem>()
269271
val showHidden = config.shouldShowHidden()
270-
val uri = MediaStore.Files.getContentUri("external")
272+
val uri = MediaStore.Files.getContentUri(currentVolume)
271273
val projection = arrayOf(
272274
MediaStore.Files.FileColumns.MIME_TYPE,
273275
MediaStore.Files.FileColumns.DATA,
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,29 @@
11
package com.simplemobiletools.filemanager.pro.extensions
22

33
import android.content.Context
4+
import android.os.storage.StorageManager
45
import com.simplemobiletools.commons.extensions.isPathOnOTG
56
import com.simplemobiletools.commons.extensions.isPathOnSD
7+
import com.simplemobiletools.commons.helpers.isNougatPlus
68
import com.simplemobiletools.filemanager.pro.helpers.Config
9+
import com.simplemobiletools.filemanager.pro.helpers.PRIMARY_VOLUME_NAME
10+
import java.util.Locale
711

812
val Context.config: Config get() = Config.newInstance(applicationContext)
913

1014
fun Context.isPathOnRoot(path: String) = !(path.startsWith(config.internalStoragePath) || isPathOnOTG(path) || (isPathOnSD(path)))
15+
16+
fun Context.getAllVolumeNames(): List<String> {
17+
val volumeNames = mutableListOf(PRIMARY_VOLUME_NAME)
18+
if (isNougatPlus()) {
19+
val storageManager = getSystemService(Context.STORAGE_SERVICE) as StorageManager
20+
getExternalFilesDirs(null)
21+
.mapNotNull { storageManager.getStorageVolume(it) }
22+
.filterNot { it.isPrimary }
23+
.mapNotNull { it.uuid?.lowercase(Locale.US) }
24+
.forEach {
25+
volumeNames.add(it)
26+
}
27+
}
28+
return volumeNames
29+
}

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/fragments/StorageFragment.kt

Lines changed: 156 additions & 74 deletions
Large diffs are not rendered by default.

app/src/main/kotlin/com/simplemobiletools/filemanager/pro/helpers/Constants.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ const val ARCHIVES = "archives"
4141
const val OTHERS = "others"
4242
const val SHOW_MIMETYPE = "show_mimetype"
4343

44+
const val VOLUME_NAME = "volume_name"
45+
const val PRIMARY_VOLUME_NAME = "external_primary"
46+
4447
// what else should we count as an audio except "audio/*" mimetype
4548
val extraAudioMimeTypes = arrayListOf("application/ogg")
4649
val extraDocumentMimeTypes = arrayListOf(
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M7.41,8.59L12,13.17l4.59,-4.58L18,10l-6,6 -6,-6 1.41,-1.41z"/>
5+
</vector>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="24dp" android:tint="#FFFFFF"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M7.41,15.41L12,10.83l4.59,4.58L18,14l-6,-6 -6,6z"/>
5+
</vector>

0 commit comments

Comments
 (0)