Skip to content

Commit

Permalink
[app] update mem bar
Browse files Browse the repository at this point in the history
  • Loading branch information
Tornaco committed May 23, 2022
1 parent d8b7cf0 commit 72ee9bb
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand All @@ -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))));
}
}
});
}
Expand All @@ -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]
)
);
}
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<string name="boost_status_blocked_start_count">已阻止%s次应用启动请求</string>
<string name="boost_status_mem_usage_percent">物理内存 %s</string>
<string name="boost_status_swap_usage_percent">虚拟内存 %s</string>
<string name="boost_status_available">可用 %s</string>
<string name="boost_status_not_enabled">未开启</string>

<string name="secure_privacy_enabled_apps">个应用受限</string>
<string name="secure_privacy_request_count">已处理%s次身份信息请求</string>
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<string name="boost_status_blocked_start_count">已阻止%s次應用啟動請求</string>
<string name="boost_status_mem_usage_percent">物理內存 %s</string>
<string name="boost_status_swap_usage_percent">虛擬內存 %s</string>
<string name="boost_status_available">可用 %s</string>
<string name="boost_status_not_enabled">未開啟</string>

<string name="secure_privacy_enabled_apps">個應用受限</string>
<string name="secure_privacy_request_count">已處理%s次身份信息請求</string>
Expand Down
2 changes: 2 additions & 0 deletions android/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
<string name="boost_status_blocked_start_count">Blocked %s app startup requests</string>
<string name="boost_status_mem_usage_percent">Memory %s</string>
<string name="boost_status_swap_usage_percent">Swap %s</string>
<string name="boost_status_available">Available %s</string>
<string name="boost_status_not_enabled">Not enabled</string>

<string name="secure_privacy_enabled_apps">apps has been restricted</string>
<string name="secure_privacy_request_count">Handled %s app privacy data requests</string>
Expand Down

0 comments on commit 72ee9bb

Please sign in to comment.