make the storage analyzer items clickable

This commit is contained in:
tibbi 2021-10-13 11:09:45 +02:00
parent 0961ceb096
commit cc58ea1b87
2 changed files with 272 additions and 196 deletions

View File

@ -3,8 +3,10 @@ package com.simplemobiletools.filemanager.pro.fragments
import android.annotation.SuppressLint
import android.app.usage.StorageStatsManager
import android.content.Context
import android.content.Intent
import android.os.storage.StorageManager
import android.provider.MediaStore
import android.provider.Settings
import android.util.AttributeSet
import androidx.appcompat.app.AppCompatActivity
import com.simplemobiletools.commons.extensions.*
@ -16,6 +18,7 @@ import kotlinx.android.synthetic.main.storage_fragment.view.*
import java.util.*
import kotlin.collections.HashMap
class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPagerFragment(context, attributeSet) {
private val IMAGES = "images"
private val VIDEOS = "videos"
@ -82,6 +85,22 @@ class StorageFragment(context: Context, attributeSet: AttributeSet) : MyViewPage
others_progressbar.progress = (othersSize / SIZE_DIVIDER).toInt()
}
}
free_space_holder.setOnClickListener {
try {
val storageSettingsIntent = Intent(Settings.ACTION_INTERNAL_STORAGE_SETTINGS)
activity.startActivity(storageSettingsIntent)
} catch (e: Exception) {
activity.showErrorToast(e)
}
}
images_holder.setOnClickListener { }
videos_holder.setOnClickListener { }
audio_holder.setOnClickListener { }
documents_holder.setOnClickListener { }
archives_holder.setOnClickListener { }
others_holder.setOnClickListener { }
}
override fun refreshFragment() {}

View File

@ -5,226 +5,283 @@
android:id="@+id/storage_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
tools:ignore="RelativeOverlap">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/free_space_value"
<RelativeLayout
android:id="@+id/free_space_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/storage_free_space_text_size"
tools:text="23 GB" />
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/activity_margin"
android:paddingEnd="@dimen/activity_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/free_space_label"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/free_space_value"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="@dimen/storage_free_space_text_size"
tools:text="23 GB" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/free_space_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/total_space"
android:layout_alignBaseline="@+id/free_space_value"
android:layout_alignBottom="@+id/free_space_value"
android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/free_space_value"
android:text="@string/storage_free"
android:textSize="@dimen/big_text_size"
android:visibility="invisible" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/main_storage_usage_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/free_space_value"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
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" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/images_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/total_space"
android:layout_alignBaseline="@+id/free_space_value"
android:layout_alignBottom="@+id/free_space_value"
android:layout_marginStart="@dimen/medium_margin"
android:layout_toEndOf="@+id/free_space_value"
android:text="@string/storage_free"
android:textSize="@dimen/big_text_size"
android:visibility="invisible" />
android:layout_below="@+id/free_space_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/main_storage_usage_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/free_space_value"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
android:visibility="invisible"
app:trackThickness="4dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/images_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/images"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/total_space"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/images_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
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" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/videos_holder"
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" />
android:layout_below="@+id/images_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/images_label"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/videos_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/videos"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/videos_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/videos_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/videos_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/audio_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/total_space"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/images"
android:textSize="@dimen/bigger_text_size" />
android:layout_below="@+id/videos_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/images_size"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/audio_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/audio"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/audio_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/audio_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/documents_holder"
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_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
android:layout_below="@+id/audio_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<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.commons.views.MyTextView
android:id="@+id/documents_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/documents"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/videos_label"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/documents_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/documents_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/documents_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/archives_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/images_progressbar"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/videos"
android:textSize="@dimen/bigger_text_size" />
android:layout_below="@+id/documents_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/videos_size"
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/archives_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/archives"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/archives_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/archives_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/archives_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
<RelativeLayout
android:id="@+id/others_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/images_progressbar"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/big_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
android:layout_below="@+id/archives_holder"
android:background="?attr/selectableItemBackground"
android:paddingStart="@dimen/activity_margin"
android:paddingTop="@dimen/normal_margin"
android:paddingEnd="@dimen/activity_margin"
android:paddingBottom="@dimen/normal_margin">
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/videos_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/videos_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/others_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/others"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/audio_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/videos_progressbar"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/audio"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/audio_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/videos_progressbar"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/big_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/audio_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/documents_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_progressbar"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/documents"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/documents_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/audio_progressbar"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/big_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/documents_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/documents_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/archives_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/documents_progressbar"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/archives"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/archives_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/documents_progressbar"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/big_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/archives_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/archives_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/others_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/archives_progressbar"
android:layout_marginTop="@dimen/big_margin"
android:text="@string/others"
android:textSize="@dimen/bigger_text_size" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/others_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/archives_progressbar"
android:layout_alignParentEnd="true"
android:layout_marginTop="@dimen/big_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/others_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/others_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
<com.simplemobiletools.commons.views.MyTextView
android:id="@+id/others_size"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
<com.google.android.material.progressindicator.LinearProgressIndicator
android:id="@+id/others_progressbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/others_label"
android:layout_marginTop="@dimen/medium_margin"
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
</com.simplemobiletools.filemanager.pro.fragments.StorageFragment>