From 599240c79f97c899a884db33fd3a26da62bc7455 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Wed, 17 Jan 2024 13:37:58 -0300 Subject: [PATCH] Show size of app backups in Backup Status screen --- .../stevesoltys/seedvault/settings/AppListRetriever.kt | 4 ++++ .../stevesoltys/seedvault/settings/AppStatusAdapter.kt | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt index e185b79b..3bf94458 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppListRetriever.kt @@ -38,6 +38,7 @@ data class AppStatus( val icon: Drawable, val name: String, val time: Long, + val size: Long?, val status: AppBackupState, val isSpecial: Boolean = false, ) : AppListItem() @@ -87,6 +88,7 @@ internal class AppListRetriever( icon = getIcon(packageName), name = context.getString(stringId), time = metadata?.time ?: 0, + size = metadata?.size, status = status, isSpecial = true ) @@ -111,6 +113,7 @@ internal class AppListRetriever( icon = getIcon(it.packageName), name = getAppName(context, it.packageName).toString(), time = time, + size = metadata?.size, status = status ) }.sortedBy { it.name.lowercase(locale) } @@ -125,6 +128,7 @@ internal class AppListRetriever( icon = getIcon(it.packageName), name = getAppName(context, it.packageName).toString(), time = 0, + size = null, status = FAILED_NOT_ALLOWED ) }.sortedBy { it.name.lowercase(locale) } diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt index 5536f6b5..b4db433d 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/AppStatusAdapter.kt @@ -3,6 +3,7 @@ package com.stevesoltys.seedvault.settings import android.content.Intent import android.net.Uri import android.provider.Settings.ACTION_APPLICATION_DETAILS_SETTINGS +import android.text.format.Formatter.formatShortFileSize import android.view.LayoutInflater import android.view.View import android.view.View.GONE @@ -116,7 +117,12 @@ internal class AppStatusAdapter(private val toggleListener: AppStatusToggleListe setState(item.status, false) } if (item.status == SUCCEEDED) { - appInfo.text = item.time.toRelativeTime(context) + appInfo.text = if (item.size == null) { + item.time.toRelativeTime(context) + } else { + item.time.toRelativeTime(context).toString() + + " (${formatShortFileSize(v.context, item.size)})" + } appInfo.visibility = VISIBLE } switchView.visibility = INVISIBLE