fix calculation of media size [Christian Schneppe]

This commit is contained in:
12aw 2022-03-19 16:26:29 +01:00
parent 418e3bfe5f
commit 743e55244c
3 changed files with 3 additions and 12 deletions

View file

@ -373,10 +373,7 @@ public class ConversationsActivity extends XmppActivity implements OnConversatio
protected Void doInBackground(Void... params) {
try {
totalMemory = FileBackend.getDiskSize();
mediaUsage = FileBackend.getDirectorySize(new File(getAppMediaDirectory(activity, FileBackend.AUDIOS)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(activity, FileBackend.FILES)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(activity, FileBackend.IMAGES)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(activity, FileBackend.VIDEOS)));
mediaUsage = FileBackend.getDirectorySize(new File(getAppMediaDirectory(activity, null)));
relativeUsage = ((double) mediaUsage / (double) totalMemory);
try {
percentUsage = String.format(Locale.getDefault(),"%.2f", relativeUsage * 100) + " %";

View file

@ -141,10 +141,7 @@ public class MemoryManagementActivity extends XmppActivity {
@Override
protected Void doInBackground(Void... params) {
totalMemory = UIHelper.filesizeToString(FileBackend.getDiskSize());
mediaUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, IMAGES)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, AUDIOS)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, VIDEOS)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, FILES))));
mediaUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, null))));
picturesUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getConversationsDirectory(mContext, IMAGES).getAbsolutePath())));
videosUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getConversationsDirectory(mContext, VIDEOS).getAbsolutePath())));
filesUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getConversationsDirectory(mContext, FILES).getAbsolutePath())));

View file

@ -57,10 +57,7 @@ public class MemoryManagementPref extends Preference {
@Override
protected Void doInBackground(Void... params) {
totalMemory = UIHelper.filesizeToString(FileBackend.getDiskSize());
mediaUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, FileBackend.AUDIOS)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, FileBackend.FILES)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, FileBackend.IMAGES)))
+ FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, FileBackend.VIDEOS))));
mediaUsage = UIHelper.filesizeToString(FileBackend.getDirectorySize(new File(getAppMediaDirectory(mContext, null))));
return null;
}