Skip to content

Commit 94577d9

Browse files
committed
Improve CorpseFinder details screen
* Highlight hints with different colors to draw more attention * Rearrange layout * Add little icon that indicates if the corpse is a file or a folder
1 parent 1f2ab1d commit 94577d9

File tree

4 files changed

+88
-33
lines changed

4 files changed

+88
-33
lines changed

app/src/main/java/eu/darken/sdmse/corpsefinder/ui/details/corpse/elements/CorpseElementHeaderVH.kt

+26-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.text.format.Formatter
44
import android.view.ViewGroup
55
import androidx.core.view.isGone
66
import eu.darken.sdmse.R
7+
import eu.darken.sdmse.common.files.FileType
78
import eu.darken.sdmse.common.lists.binding
89
import eu.darken.sdmse.common.lists.selection.SelectableItem
910
import eu.darken.sdmse.corpsefinder.core.Corpse
@@ -30,7 +31,16 @@ class CorpseElementHeaderVH(parent: ViewGroup) :
3031
pathValue.text = corpse.lookup.userReadablePath.get(context)
3132
typeIcon.setImageResource(corpse.filterType.iconRes)
3233
typeValue.text = getString(corpse.filterType.labelRes)
34+
35+
sizeIcon.setImageResource(
36+
when {
37+
corpse.lookup.fileType == FileType.DIRECTORY -> R.drawable.ic_folder
38+
corpse.lookup.fileType == FileType.FILE -> R.drawable.ic_file
39+
else -> R.drawable.file_question
40+
}
41+
)
3342
sizeVaule.text = Formatter.formatFileSize(context, corpse.size)
43+
3444
ownersValue.text = if (corpse.ownerInfo.owners.isNotEmpty()) {
3545
corpse.ownerInfo.owners.joinToString("\n") { it.pkgId.name }
3646
} else {
@@ -39,10 +49,22 @@ class CorpseElementHeaderVH(parent: ViewGroup) :
3949

4050
hintsLabel.isGone = corpse.riskLevel == RiskLevel.NORMAL
4151
hintsValue.isGone = corpse.riskLevel == RiskLevel.NORMAL
42-
hintsValue.text = when (corpse.riskLevel) {
43-
RiskLevel.NORMAL -> ""
44-
RiskLevel.KEEPER -> getString(R.string.corpsefinder_corpse_hint_keeper)
45-
RiskLevel.COMMON -> getString(R.string.corpsefinder_corpse_hint_common)
52+
53+
when (corpse.riskLevel) {
54+
RiskLevel.NORMAL -> hintsValue.apply {
55+
text = ""
56+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorPrimary))
57+
}
58+
59+
RiskLevel.KEEPER -> hintsValue.apply {
60+
text = getString(R.string.corpsefinder_corpse_hint_keeper)
61+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorSecondary))
62+
}
63+
64+
RiskLevel.COMMON -> hintsValue.apply {
65+
text = getString(R.string.corpsefinder_corpse_hint_common)
66+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorTertiary))
67+
}
4668
}
4769

4870

app/src/main/java/eu/darken/sdmse/corpsefinder/ui/list/CorpseFinderListRowVH.kt

+19-8
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import android.text.format.Formatter
44
import android.view.ViewGroup
55
import androidx.core.view.isVisible
66
import eu.darken.sdmse.R
7+
import eu.darken.sdmse.common.files.FileType
78
import eu.darken.sdmse.common.lists.binding
89
import eu.darken.sdmse.common.lists.selection.SelectableVH
910
import eu.darken.sdmse.corpsefinder.core.Corpse
@@ -41,22 +42,32 @@ class CorpseFinderListRowVH(parent: ViewGroup) :
4142
secondary.text = corpse.lookup.userReadablePath.get(context).removeSuffix(primary.text)
4243

4344
when (corpse.riskLevel) {
44-
RiskLevel.NORMAL -> {
45-
tertiary.isVisible = false
45+
RiskLevel.NORMAL -> tertiary.apply {
46+
isVisible = false
47+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorPrimary))
4648
}
4749

48-
RiskLevel.KEEPER -> {
49-
tertiary.text = getString(R.string.corpsefinder_corpse_hint_keeper)
50-
tertiary.isVisible = true
50+
RiskLevel.KEEPER -> tertiary.apply {
51+
text = getString(R.string.corpsefinder_corpse_hint_keeper)
52+
isVisible = true
53+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorSecondary))
5154
}
5255

53-
RiskLevel.COMMON -> {
54-
tertiary.text = getString(R.string.corpsefinder_corpse_hint_common)
55-
tertiary.isVisible = true
56+
RiskLevel.COMMON -> tertiary.apply {
57+
text = getString(R.string.corpsefinder_corpse_hint_common)
58+
isVisible = true
59+
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorTertiary))
5660
}
5761
}
5862

5963
areaInfo.text = getString(corpse.filterType.labelRes)
64+
sizeIcon.setImageResource(
65+
when {
66+
corpse.lookup.fileType == FileType.DIRECTORY -> R.drawable.ic_folder
67+
corpse.lookup.fileType == FileType.FILE -> R.drawable.ic_file
68+
else -> R.drawable.file_question
69+
}
70+
)
6071
size.text = StringBuilder().apply {
6172
if (corpse.content.isNotEmpty()) {
6273
append(getQuantityString(eu.darken.sdmse.common.R.plurals.result_x_items, corpse.content.size))

app/src/main/res/layout/corpsefinder_corpse_element_header.xml

+10
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
app:layout_constraintEnd_toEndOf="parent"
6969
app:layout_constraintTop_toBottomOf="@id/path_value" />
7070

71+
<ImageView
72+
android:id="@+id/size_icon"
73+
android:layout_width="16dp"
74+
android:layout_height="16dp"
75+
android:layout_marginEnd="4dp"
76+
android:src="@drawable/ic_folder"
77+
app:layout_constraintBottom_toBottomOf="@id/size_vaule"
78+
app:layout_constraintEnd_toStartOf="@id/size_vaule"
79+
app:layout_constraintTop_toTopOf="@id/size_vaule" />
80+
7181
<com.google.android.material.textview.MaterialTextView
7282
android:id="@+id/size_vaule"
7383
style="@style/TextAppearance.Material3.BodyMedium"

app/src/main/res/layout/corpsefinder_list_item.xml

+33-21
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
android:layout_width="24dp"
1212
android:layout_height="24dp"
1313
android:layout_marginStart="16dp"
14-
android:src="@drawable/ghost"
14+
android:src="@drawable/ic_file"
1515
app:layout_constraintBottom_toBottomOf="parent"
1616
app:layout_constraintStart_toStartOf="parent"
1717
app:layout_constraintTop_toTopOf="parent" />
@@ -43,36 +43,31 @@
4343
app:layout_constraintTop_toBottomOf="@id/primary"
4444
tools:text="/storage/emulated/0/Android/data/eu.darken.sdmse" />
4545

46-
<com.google.android.material.textview.MaterialTextView
47-
android:id="@+id/tertiary"
48-
style="@style/TextAppearance.Material3.BodySmall"
49-
android:layout_width="0dp"
50-
android:layout_height="wrap_content"
51-
android:layout_marginTop="4dp"
52-
android:layout_marginBottom="4dp"
53-
android:textSize="10sp"
54-
android:visibility="gone"
55-
app:layout_constraintBottom_toTopOf="@id/area_info"
56-
app:layout_constraintEnd_toEndOf="@id/secondary"
57-
app:layout_constraintStart_toStartOf="@id/primary"
58-
app:layout_constraintTop_toBottomOf="@id/secondary"
59-
tools:text="@string/corpsefinder_corpse_hint_keeper"
60-
tools:visibility="visible" />
61-
6246
<com.google.android.material.textview.MaterialTextView
6347
android:id="@+id/area_info"
6448
style="@style/TextAppearance.Material3.LabelSmall"
6549
android:layout_width="wrap_content"
6650
android:layout_height="wrap_content"
6751
android:layout_marginTop="2dp"
68-
android:layout_marginBottom="8dp"
69-
app:layout_constraintBottom_toBottomOf="parent"
70-
app:layout_constraintEnd_toStartOf="@id/size"
52+
android:layout_marginEnd="8dp"
53+
app:layout_constraintBottom_toTopOf="@id/tertiary"
54+
app:layout_constraintEnd_toStartOf="@id/size_icon"
7155
app:layout_constraintHorizontal_bias="0.0"
7256
app:layout_constraintStart_toStartOf="@id/primary"
73-
app:layout_constraintTop_toBottomOf="@id/tertiary"
57+
app:layout_constraintTop_toBottomOf="@id/secondary"
58+
app:layout_goneMarginBottom="8dp"
7459
tools:text="Public storage" />
7560

61+
<ImageView
62+
android:id="@+id/size_icon"
63+
android:layout_width="16dp"
64+
android:layout_height="16dp"
65+
android:layout_marginEnd="4dp"
66+
android:src="@drawable/ic_folder"
67+
app:layout_constraintBottom_toBottomOf="@id/size"
68+
app:layout_constraintEnd_toStartOf="@id/size"
69+
app:layout_constraintTop_toTopOf="@id/size" />
70+
7671
<com.google.android.material.textview.MaterialTextView
7772
android:id="@+id/size"
7873
style="@style/TextAppearance.Material3.LabelSmall"
@@ -84,6 +79,23 @@
8479
app:layout_constraintTop_toTopOf="@id/area_info"
8580
tools:text="999 items, 999 KB" />
8681

82+
<com.google.android.material.textview.MaterialTextView
83+
android:id="@+id/tertiary"
84+
style="@style/TextAppearance.Material3.BodySmall"
85+
android:layout_width="0dp"
86+
android:layout_height="wrap_content"
87+
android:layout_marginTop="8dp"
88+
android:layout_marginBottom="8dp"
89+
android:textColor="?colorTertiary"
90+
android:textSize="10sp"
91+
android:visibility="gone"
92+
app:layout_constraintBottom_toBottomOf="parent"
93+
app:layout_constraintEnd_toEndOf="@id/secondary"
94+
app:layout_constraintStart_toStartOf="@id/primary"
95+
app:layout_constraintTop_toBottomOf="@id/area_info"
96+
tools:text="@string/corpsefinder_corpse_hint_keeper"
97+
tools:visibility="visible" />
98+
8799
<com.google.android.material.button.MaterialButton
88100
android:id="@+id/details_action"
89101
style="@style/SDMButton.Icon"

0 commit comments

Comments
 (0)