diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
index 23d68c9ed9..827ed41c81 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java
@@ -180,6 +180,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvMemoryClass;
private TextView tvMemoryUsage;
private TextView tvStorageUsage;
+ private TextView tvCacheUsage;
private TextView tvContactInfo;
private TextView tvSuffixes;
private TextView tvAndroidId;
@@ -350,6 +351,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvMemoryClass = view.findViewById(R.id.tvMemoryClass);
tvMemoryUsage = view.findViewById(R.id.tvMemoryUsage);
tvStorageUsage = view.findViewById(R.id.tvStorageUsage);
+ tvCacheUsage = view.findViewById(R.id.tvCacheUsage);
tvContactInfo = view.findViewById(R.id.tvContactInfo);
tvSuffixes = view.findViewById(R.id.tvSuffixes);
tvAndroidId = view.findViewById(R.id.tvAndroidId);
@@ -1819,8 +1821,9 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
data.nheap = Debug.getNativeHeapAllocatedSize();
data.available = Helper.getAvailableStorageSpace();
data.total = Helper.getTotalStorageSpace();
- data.used = Helper.getSize(context.getFilesDir());
- data.cache = Helper.getCacheQuota(context);
+ data.used = Helper.getSizeUsed(context.getFilesDir());
+ data.cache_used = Helper.getSizeUsed(context.getCacheDir());
+ data.cache_quota = Helper.getCacheQuota(context);
return data;
}
@@ -1834,8 +1837,10 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvStorageUsage.setText(getString(R.string.title_advanced_storage_usage,
Helper.humanReadableByteCount(data.total - data.available),
Helper.humanReadableByteCount(data.total),
- Helper.humanReadableByteCount(data.used),
- data.cache > 0 ? Helper.humanReadableByteCount(data.cache) : "-"));
+ Helper.humanReadableByteCount(data.used)));
+ tvCacheUsage.setText(getString(R.string.title_advanced_cache_usage,
+ Helper.humanReadableByteCount(data.cache_used),
+ Helper.humanReadableByteCount(data.cache_quota)));
getView().postDelayed(new Runnable() {
@Override
@@ -1991,6 +1996,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private long available;
private long total;
private long used;
- private long cache;
+ private long cache_used;
+ private long cache_quota;
}
}
diff --git a/app/src/main/java/eu/faircode/email/Helper.java b/app/src/main/java/eu/faircode/email/Helper.java
index d276699a45..ea7a68c1a0 100644
--- a/app/src/main/java/eu/faircode/email/Helper.java
+++ b/app/src/main/java/eu/faircode/email/Helper.java
@@ -2029,16 +2029,16 @@ public class Helper {
} catch (IOException ex) {
Log.w(ex);
}
- return -1;
+ return 0;
}
- static long getSize(File dir) {
+ static long getSizeUsed(File dir) {
long size = 0;
File[] listed = dir.listFiles();
if (listed != null)
for (File file : listed)
if (file.isDirectory())
- size += getSize(file);
+ size += getSizeUsed(file);
else
size += file.length();
return size;
diff --git a/app/src/main/java/eu/faircode/email/Log.java b/app/src/main/java/eu/faircode/email/Log.java
index 5d5741d79b..899ccf566e 100644
--- a/app/src/main/java/eu/faircode/email/Log.java
+++ b/app/src/main/java/eu/faircode/email/Log.java
@@ -1885,13 +1885,17 @@ public class Log {
long storage_available = Helper.getAvailableStorageSpace();
long storage_total = Helper.getTotalStorageSpace();
- long storage_used = Helper.getSize(context.getFilesDir());
- long cache = Helper.getCacheQuota(context);
- sb.append(String.format("Storage space: %s/%s App: %s cache: %s\r\n",
+ long storage_used = Helper.getSizeUsed(context.getFilesDir());
+ sb.append(String.format("Storage space: %s/%s App: %s\r\n",
Helper.humanReadableByteCount(storage_total - storage_available),
Helper.humanReadableByteCount(storage_total),
- Helper.humanReadableByteCount(storage_used),
- cache > 0 ? Helper.humanReadableByteCount(cache) : "-"));
+ Helper.humanReadableByteCount(storage_used)));
+
+ long cache_used = Helper.getSizeUsed(context.getCacheDir());
+ long cache_quota = Helper.getCacheQuota(context);
+ sb.append(String.format("Cache space: %s/%s\r\n",
+ Helper.humanReadableByteCount(cache_used),
+ Helper.humanReadableByteCount(cache_quota)));
Runtime rt = Runtime.getRuntime();
long hused = (rt.totalMemory() - rt.freeMemory()) / 1024L / 1024L;
diff --git a/app/src/main/res/layout/fragment_options_misc.xml b/app/src/main/res/layout/fragment_options_misc.xml
index b312b672ed..3ae83eb6f3 100644
--- a/app/src/main/res/layout/fragment_options_misc.xml
+++ b/app/src/main/res/layout/fragment_options_misc.xml
@@ -1497,6 +1497,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvMemoryUsage" />
+
+
+
+ app:layout_constraintTop_toBottomOf="@id/tvCacheUsage" />
Processors: %1$d
Memory class: %1$s/%2$s Total: %3$s
Memory usage: %1$s/%2$s Native: %3$s
- Storage space: %1$s/%2$s App: %3$s Cache: %4$s
- Cache size: %1$s
+ Storage space: %1$s/%2$s App: %3$s
+ Cache space: %1$s/%2$s
Cursor window size: %1$s
Contact lookup: %1$d cached: %2$d
Public suffix list: %1$d