Skip to content

Commit

Permalink
Improve CorpseFinder details screen
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
d4rken committed Jan 19, 2025
1 parent 1f2ab1d commit 94577d9
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.text.format.Formatter
import android.view.ViewGroup
import androidx.core.view.isGone
import eu.darken.sdmse.R
import eu.darken.sdmse.common.files.FileType
import eu.darken.sdmse.common.lists.binding
import eu.darken.sdmse.common.lists.selection.SelectableItem
import eu.darken.sdmse.corpsefinder.core.Corpse
Expand All @@ -30,7 +31,16 @@ class CorpseElementHeaderVH(parent: ViewGroup) :
pathValue.text = corpse.lookup.userReadablePath.get(context)
typeIcon.setImageResource(corpse.filterType.iconRes)
typeValue.text = getString(corpse.filterType.labelRes)

sizeIcon.setImageResource(
when {
corpse.lookup.fileType == FileType.DIRECTORY -> R.drawable.ic_folder
corpse.lookup.fileType == FileType.FILE -> R.drawable.ic_file
else -> R.drawable.file_question
}
)
sizeVaule.text = Formatter.formatFileSize(context, corpse.size)

ownersValue.text = if (corpse.ownerInfo.owners.isNotEmpty()) {
corpse.ownerInfo.owners.joinToString("\n") { it.pkgId.name }
} else {
Expand All @@ -39,10 +49,22 @@ class CorpseElementHeaderVH(parent: ViewGroup) :

hintsLabel.isGone = corpse.riskLevel == RiskLevel.NORMAL
hintsValue.isGone = corpse.riskLevel == RiskLevel.NORMAL
hintsValue.text = when (corpse.riskLevel) {
RiskLevel.NORMAL -> ""
RiskLevel.KEEPER -> getString(R.string.corpsefinder_corpse_hint_keeper)
RiskLevel.COMMON -> getString(R.string.corpsefinder_corpse_hint_common)

when (corpse.riskLevel) {
RiskLevel.NORMAL -> hintsValue.apply {
text = ""
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorPrimary))
}

RiskLevel.KEEPER -> hintsValue.apply {
text = getString(R.string.corpsefinder_corpse_hint_keeper)
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorSecondary))
}

RiskLevel.COMMON -> hintsValue.apply {
text = getString(R.string.corpsefinder_corpse_hint_common)
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorTertiary))
}
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import android.text.format.Formatter
import android.view.ViewGroup
import androidx.core.view.isVisible
import eu.darken.sdmse.R
import eu.darken.sdmse.common.files.FileType
import eu.darken.sdmse.common.lists.binding
import eu.darken.sdmse.common.lists.selection.SelectableVH
import eu.darken.sdmse.corpsefinder.core.Corpse
Expand Down Expand Up @@ -41,22 +42,32 @@ class CorpseFinderListRowVH(parent: ViewGroup) :
secondary.text = corpse.lookup.userReadablePath.get(context).removeSuffix(primary.text)

when (corpse.riskLevel) {
RiskLevel.NORMAL -> {
tertiary.isVisible = false
RiskLevel.NORMAL -> tertiary.apply {
isVisible = false
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorPrimary))
}

RiskLevel.KEEPER -> {
tertiary.text = getString(R.string.corpsefinder_corpse_hint_keeper)
tertiary.isVisible = true
RiskLevel.KEEPER -> tertiary.apply {
text = getString(R.string.corpsefinder_corpse_hint_keeper)
isVisible = true
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorSecondary))
}

RiskLevel.COMMON -> {
tertiary.text = getString(R.string.corpsefinder_corpse_hint_common)
tertiary.isVisible = true
RiskLevel.COMMON -> tertiary.apply {
text = getString(R.string.corpsefinder_corpse_hint_common)
isVisible = true
setTextColor(getColorForAttr(com.google.android.material.R.attr.colorTertiary))
}
}

areaInfo.text = getString(corpse.filterType.labelRes)
sizeIcon.setImageResource(
when {
corpse.lookup.fileType == FileType.DIRECTORY -> R.drawable.ic_folder
corpse.lookup.fileType == FileType.FILE -> R.drawable.ic_file
else -> R.drawable.file_question
}
)
size.text = StringBuilder().apply {
if (corpse.content.isNotEmpty()) {
append(getQuantityString(eu.darken.sdmse.common.R.plurals.result_x_items, corpse.content.size))
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/layout/corpsefinder_corpse_element_header.xml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,16 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@id/path_value" />

<ImageView
android:id="@+id/size_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginEnd="4dp"
android:src="@drawable/ic_folder"
app:layout_constraintBottom_toBottomOf="@id/size_vaule"
app:layout_constraintEnd_toStartOf="@id/size_vaule"
app:layout_constraintTop_toTopOf="@id/size_vaule" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/size_vaule"
style="@style/TextAppearance.Material3.BodyMedium"
Expand Down
54 changes: 33 additions & 21 deletions app/src/main/res/layout/corpsefinder_list_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginStart="16dp"
android:src="@drawable/ghost"
android:src="@drawable/ic_file"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down Expand Up @@ -43,36 +43,31 @@
app:layout_constraintTop_toBottomOf="@id/primary"
tools:text="/storage/emulated/0/Android/data/eu.darken.sdmse" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/tertiary"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:layout_marginBottom="4dp"
android:textSize="10sp"
android:visibility="gone"
app:layout_constraintBottom_toTopOf="@id/area_info"
app:layout_constraintEnd_toEndOf="@id/secondary"
app:layout_constraintStart_toStartOf="@id/primary"
app:layout_constraintTop_toBottomOf="@id/secondary"
tools:text="@string/corpsefinder_corpse_hint_keeper"
tools:visibility="visible" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/area_info"
style="@style/TextAppearance.Material3.LabelSmall"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="2dp"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/size"
android:layout_marginEnd="8dp"
app:layout_constraintBottom_toTopOf="@id/tertiary"
app:layout_constraintEnd_toStartOf="@id/size_icon"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="@id/primary"
app:layout_constraintTop_toBottomOf="@id/tertiary"
app:layout_constraintTop_toBottomOf="@id/secondary"
app:layout_goneMarginBottom="8dp"
tools:text="Public storage" />

<ImageView
android:id="@+id/size_icon"
android:layout_width="16dp"
android:layout_height="16dp"
android:layout_marginEnd="4dp"
android:src="@drawable/ic_folder"
app:layout_constraintBottom_toBottomOf="@id/size"
app:layout_constraintEnd_toStartOf="@id/size"
app:layout_constraintTop_toTopOf="@id/size" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/size"
style="@style/TextAppearance.Material3.LabelSmall"
Expand All @@ -84,6 +79,23 @@
app:layout_constraintTop_toTopOf="@id/area_info"
tools:text="999 items, 999 KB" />

<com.google.android.material.textview.MaterialTextView
android:id="@+id/tertiary"
style="@style/TextAppearance.Material3.BodySmall"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:textColor="?colorTertiary"
android:textSize="10sp"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/secondary"
app:layout_constraintStart_toStartOf="@id/primary"
app:layout_constraintTop_toBottomOf="@id/area_info"
tools:text="@string/corpsefinder_corpse_hint_keeper"
tools:visibility="visible" />

<com.google.android.material.button.MaterialButton
android:id="@+id/details_action"
style="@style/SDMButton.Icon"
Expand Down

0 comments on commit 94577d9

Please sign in to comment.