diff --git a/android/app/src/main/java/github/tornaco/android/thanos/dashboard/HeaderContent.kt b/android/app/src/main/java/github/tornaco/android/thanos/dashboard/HeaderContent.kt index 1840c74cc..c9b56b724 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/dashboard/HeaderContent.kt +++ b/android/app/src/main/java/github/tornaco/android/thanos/dashboard/HeaderContent.kt @@ -142,9 +142,18 @@ private fun MemStats( color = Color(onSurfaceColor) ) SmallSpacer() + + val extraDesc = if (memUsage.isEnabled) { + stringResource( + id = R.string.boost_status_available, + memUsage.memAvailableSizeString + ) + } else { + stringResource(id = R.string.boost_status_not_enabled) + } Text( modifier = Modifier.alignByBaseline(), - text = " (${memUsage.memUsageSizeString}/${memUsage.memTotalSizeString})", + text = " ($extraDesc)", style = MaterialTheme.typography.labelSmall.copy(fontSize = 10.sp), color = Color(onSurfaceColor) ) diff --git a/android/app/src/main/java/github/tornaco/android/thanos/dashboard/StatusHeaderInfo.kt b/android/app/src/main/java/github/tornaco/android/thanos/dashboard/StatusHeaderInfo.kt index d5152b48d..8913ad085 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/dashboard/StatusHeaderInfo.kt +++ b/android/app/src/main/java/github/tornaco/android/thanos/dashboard/StatusHeaderInfo.kt @@ -28,7 +28,9 @@ data class MemUsage( val memTotalSizeString: String = "", // 0-100 val memUsagePercent: Int = 1, - val memUsageSizeString: String = "" + val memUsageSizeString: String = "", + val memAvailableSizeString: String = "", + val isEnabled: Boolean = true ) enum class MemType { diff --git a/android/app/src/main/java/github/tornaco/android/thanos/main/NavViewModel.java b/android/app/src/main/java/github/tornaco/android/thanos/main/NavViewModel.java index 254d98bb1..42ffff6c4 100644 --- a/android/app/src/main/java/github/tornaco/android/thanos/main/NavViewModel.java +++ b/android/app/src/main/java/github/tornaco/android/thanos/main/NavViewModel.java @@ -159,13 +159,17 @@ private void loadState() { } private StatusHeaderInfo loadStatusHeaderInfo() { - final String[] memTotalSizeString = {"N/A"}; - final String[] memUsageSizeString = {"N/A"}; + final String[] memTotalSizeString = {""}; + final String[] memUsageSizeString = {""}; + final String[] memAvailableSizeString = {""}; final int[] memUsedPercent = {0}; - final String[] swapTotalSizeString = {"N/A"}; - final String[] swapUsageSizeString = {"N/A"}; + final String[] swapTotalSizeString = {""}; + final String[] swapUsageSizeString = {""}; + final String[] swapAvailableSizeString = {""}; final int[] swapUsedPercent = {0}; + final boolean[] swapEnabled = {false}; + final int[] runningAppsCount = {0}; @@ -179,14 +183,19 @@ private StatusHeaderInfo loadStatusHeaderInfo() { if (memoryInfo != null) { memTotalSizeString[0] = Formatter.formatFileSize(getApplication(), memoryInfo.totalMem); memUsageSizeString[0] = Formatter.formatFileSize(getApplication(), memoryInfo.totalMem - memoryInfo.availMem); + memAvailableSizeString[0] = Formatter.formatFileSize(getApplication(), memoryInfo.availMem); memUsedPercent[0] = (int) (100 * (((float) (memoryInfo.totalMem - memoryInfo.availMem) / Math.max((float) memoryInfo.totalMem, 1f)))); } SwapInfo swapInfo = thanosManager.getActivityManager().getSwapInfo(); if (swapInfo != null) { - swapTotalSizeString[0] = Formatter.formatFileSize(getApplication(), swapInfo.totalSwap); - swapUsageSizeString[0] = Formatter.formatFileSize(getApplication(), swapInfo.totalSwap - swapInfo.freeSwap); - swapUsedPercent[0] = (int) (100 * (((float) (swapInfo.totalSwap - swapInfo.freeSwap) / Math.max((float) swapInfo.totalSwap, 1f)))); + swapEnabled[0] = swapInfo.totalSwap > 0; + if (swapEnabled[0]) { + swapTotalSizeString[0] = Formatter.formatFileSize(getApplication(), swapInfo.totalSwap); + swapUsageSizeString[0] = Formatter.formatFileSize(getApplication(), swapInfo.totalSwap - swapInfo.freeSwap); + swapAvailableSizeString[0] = Formatter.formatFileSize(getApplication(), swapInfo.freeSwap); + swapUsedPercent[0] = (int) (100 * (((float) (swapInfo.totalSwap - swapInfo.freeSwap) / Math.max((float) swapInfo.totalSwap, 1f)))); + } } }); } @@ -197,13 +206,17 @@ private StatusHeaderInfo loadStatusHeaderInfo() { MemType.MEMORY, memTotalSizeString[0], memUsedPercent[0], - memUsageSizeString[0] + memUsageSizeString[0], + memAvailableSizeString[0], + true ), new MemUsage( MemType.SWAP, swapTotalSizeString[0], swapUsedPercent[0], - swapUsageSizeString[0] + swapUsageSizeString[0], + swapAvailableSizeString[0], + swapEnabled[0] ) ); } diff --git a/android/app/src/main/res/values-zh-rCN/strings.xml b/android/app/src/main/res/values-zh-rCN/strings.xml index d86ef42c6..ca5ddc2ca 100644 --- a/android/app/src/main/res/values-zh-rCN/strings.xml +++ b/android/app/src/main/res/values-zh-rCN/strings.xml @@ -69,6 +69,8 @@ 已阻止%s次应用启动请求 物理内存 %s 虚拟内存 %s + 可用 %s + 未开启 个应用受限 已处理%s次身份信息请求 diff --git a/android/app/src/main/res/values-zh-rTW/strings.xml b/android/app/src/main/res/values-zh-rTW/strings.xml index dec876bef..0c8d86b07 100644 --- a/android/app/src/main/res/values-zh-rTW/strings.xml +++ b/android/app/src/main/res/values-zh-rTW/strings.xml @@ -69,6 +69,8 @@ 已阻止%s次應用啟動請求 物理內存 %s 虛擬內存 %s + 可用 %s + 未開啟 個應用受限 已處理%s次身份信息請求 diff --git a/android/app/src/main/res/values/strings.xml b/android/app/src/main/res/values/strings.xml index 2bd7c2303..4d28d36c9 100644 --- a/android/app/src/main/res/values/strings.xml +++ b/android/app/src/main/res/values/strings.xml @@ -69,6 +69,8 @@ Blocked %s app startup requests Memory %s Swap %s + Available %s + Not enabled apps has been restricted Handled %s app privacy data requests