add an Images progressbar at the storage analyzer
This commit is contained in:
parent
ff4ccbf439
commit
bf25cdfb2b
|
@ -18,14 +18,19 @@ import kotlinx.android.synthetic.main.storage_fragment.view.*
|
|||
|
||||
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
|
||||
override fun setupFragment(activity: SimpleActivity) {
|
||||
val imagesSize = getMediaTypeSize(MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
|
||||
val videosSize = getMediaTypeSize(MediaStore.Video.Media.EXTERNAL_CONTENT_URI)
|
||||
val audioSize = getMediaTypeSize(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI)
|
||||
val documents = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getProperSize(true)
|
||||
val downloads = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getProperSize(true)
|
||||
|
||||
ensureBackgroundThread {
|
||||
getStorageStats(activity)
|
||||
|
||||
val imagesSize = getMediaTypeSize(MediaStore.Images.Media.EXTERNAL_CONTENT_URI)
|
||||
val videosSize = getMediaTypeSize(MediaStore.Video.Media.EXTERNAL_CONTENT_URI)
|
||||
val audioSize = getMediaTypeSize(MediaStore.Audio.Media.EXTERNAL_CONTENT_URI)
|
||||
val documents = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOCUMENTS).getProperSize(true)
|
||||
val downloads = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getProperSize(true)
|
||||
|
||||
activity.runOnUiThread {
|
||||
images_size.text = imagesSize.formatSize()
|
||||
images_progressbar.progress = (imagesSize / 1000000).toInt()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,6 +41,10 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
|
||||
main_storage_usage_progressbar.setIndicatorColor(primaryColor)
|
||||
main_storage_usage_progressbar.trackColor = primaryColor.adjustAlpha(0.3f)
|
||||
|
||||
val redColor = context.resources.getColor(R.color.md_red_700)
|
||||
images_progressbar.setIndicatorColor(redColor)
|
||||
images_progressbar.trackColor = redColor.adjustAlpha(0.3f)
|
||||
}
|
||||
|
||||
private fun getMediaTypeSize(uri: Uri): Long {
|
||||
|
@ -73,10 +82,13 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
|
|||
val freeSpace = storageStatsManager.getFreeBytes(uuid)
|
||||
|
||||
activity.runOnUiThread {
|
||||
main_storage_usage_progressbar.max = (totalSpace / 1000000).toInt()
|
||||
main_storage_usage_progressbar.progress = ((totalSpace - freeSpace) / 1000000).toInt()
|
||||
main_storage_usage_progressbar.beVisible()
|
||||
arrayOf(main_storage_usage_progressbar, images_progressbar).forEach {
|
||||
it.max = (totalSpace / 1000000).toInt()
|
||||
}
|
||||
|
||||
main_storage_usage_progressbar.progress = ((totalSpace - freeSpace) / 1000000).toInt()
|
||||
|
||||
main_storage_usage_progressbar.beVisible()
|
||||
free_space_value.text = freeSpace.formatSizeThousand()
|
||||
total_space.text = String.format(context.getString(R.string.total_storage), totalSpace.formatSizeThousand())
|
||||
free_space_label.beVisible()
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<com.simplemobiletools.filemanager.pro.fragments.StorageFragment xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:id="@+id/storage_fragment"
|
||||
android:layout_width="match_parent"
|
||||
|
@ -24,7 +25,7 @@
|
|||
android:layout_toEndOf="@+id/free_space_value"
|
||||
android:text="@string/storage_free"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
android:visibility="gone" />
|
||||
android:visibility="invisible" />
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/main_storage_usage_progressbar"
|
||||
|
@ -34,14 +35,46 @@
|
|||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:max="100"
|
||||
android:visibility="gone" />
|
||||
android:visibility="invisible"
|
||||
app:trackThickness="4dp" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/total_space"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/main_storage_usage_progressbar"
|
||||
android:layout_marginBottom="@dimen/big_margin"
|
||||
android:textSize="@dimen/big_text_size"
|
||||
tools:text="Total storage: 64 GB" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/images_label"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/total_space"
|
||||
android:layout_marginTop="@dimen/big_text_size"
|
||||
android:text="@string/images"
|
||||
android:textSize="@dimen/bigger_text_size" />
|
||||
|
||||
<com.simplemobiletools.commons.views.MyTextView
|
||||
android:id="@+id/images_size"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/total_space"
|
||||
android:layout_alignParentEnd="true"
|
||||
android:layout_marginTop="@dimen/big_text_size"
|
||||
android:alpha="0.7"
|
||||
android:textSize="@dimen/normal_text_size"
|
||||
tools:text="20 GB" />
|
||||
|
||||
<com.google.android.material.progressindicator.LinearProgressIndicator
|
||||
android:id="@+id/images_progressbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_below="@+id/images_label"
|
||||
android:layout_marginTop="@dimen/medium_margin"
|
||||
android:layout_marginBottom="@dimen/medium_margin"
|
||||
android:max="100"
|
||||
app:trackThickness="2dp" />
|
||||
|
||||
</com.simplemobiletools.filemanager.pro.fragments.StorageFragment>
|
||||
|
|
Loading…
Reference in New Issue