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,7 +5,16 @@
android:id="@+id/storage_fragment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="@dimen/activity_margin">
tools:ignore="RelativeOverlap">
<RelativeLayout
android:id="@+id/free_space_holder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
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_value"
@ -46,13 +55,23 @@
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_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.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_margin"
android:text="@string/images"
android:textSize="@dimen/bigger_text_size" />
@ -60,9 +79,7 @@
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_margin"
android:alpha="0.7"
android:textSize="@dimen/normal_text_size"
tools:text="20 GB" />
@ -76,13 +93,23 @@
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/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/videos_label"
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" />
@ -90,9 +117,7 @@
android:id="@+id/videos_size"
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" />
@ -106,13 +131,23 @@
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/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/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" />
@ -120,9 +155,7 @@
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" />
@ -136,13 +169,23 @@
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/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.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" />
@ -150,9 +193,7 @@
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" />
@ -166,13 +207,23 @@
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/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/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" />
@ -180,9 +231,7 @@
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" />
@ -196,13 +245,23 @@
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/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.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" />
@ -210,9 +269,7 @@
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" />
@ -226,5 +283,5 @@
android:layout_marginBottom="@dimen/medium_margin"
android:max="100"
app:trackThickness="2dp" />
</RelativeLayout>
</com.simplemobiletools.filemanager.pro.fragments.StorageFragment>