diff --git a/MessengerProj/src/main/java/com/b44t/messenger/FileLoader.java b/MessengerProj/src/main/java/com/b44t/messenger/FileLoader.java index b89239a30..17cb7b2c1 100644 --- a/MessengerProj/src/main/java/com/b44t/messenger/FileLoader.java +++ b/MessengerProj/src/main/java/com/b44t/messenger/FileLoader.java @@ -77,11 +77,13 @@ public class FileLoader { mediaDirs = dirs; } + /* public File checkDirectory(int type) { return mediaDirs.get(type); } + */ - public File getDirectory(int type) { + public File getDirectory(int type) { // always returns the cache directory as this is the only one set in mediaDirs[] - we do not use the other directories at the moment File dir = mediaDirs.get(type); if (dir == null && type != MEDIA_DIR_CACHE) { dir = mediaDirs.get(MEDIA_DIR_CACHE); diff --git a/MessengerProj/src/main/java/com/b44t/messenger/ImageLoader.java b/MessengerProj/src/main/java/com/b44t/messenger/ImageLoader.java index 1ab17a392..da368c6ab 100644 --- a/MessengerProj/src/main/java/com/b44t/messenger/ImageLoader.java +++ b/MessengerProj/src/main/java/com/b44t/messenger/ImageLoader.java @@ -1228,6 +1228,10 @@ public class ImageLoader { filter.addDataScheme("file"); ApplicationLoader.applicationContext.registerReceiver(receiver, filter); + checkMediaPaths(); + } + + public void checkMediaPaths() { HashMap mediaDirs = new HashMap<>(); File cachePath = AndroidUtilities.getCacheDir(); if (!cachePath.isDirectory()) { @@ -1242,13 +1246,11 @@ public class ImageLoader { } catch (Exception e) { FileLog.e("messenger", e); } + mediaDirs.put(FileLoader.MEDIA_DIR_CACHE, cachePath); FileLoader.getInstance().setMediaDirs(mediaDirs); - checkMediaPaths(); - } - - public void checkMediaPaths() { + /* cacheOutQueue.postRunnable(new Runnable() { @Override public void run() { @@ -1261,8 +1263,10 @@ public class ImageLoader { }); } }); + */ } + /* public HashMap createMediaPaths() { // not sure, but it seems as if these paths are not needed HashMap mediaDirs = new HashMap<>(); File cachePath = AndroidUtilities.getCacheDir(); @@ -1344,6 +1348,7 @@ public class ImageLoader { return mediaDirs; } + */ private boolean canMoveFiles(File from, File to, int type) { RandomAccessFile file = null; diff --git a/MessengerProj/src/main/java/com/b44t/ui/CacheControlActivity.java b/MessengerProj/src/main/java/com/b44t/ui/CacheControlActivity.java index 9d6f1149a..d499b5e42 100644 --- a/MessengerProj/src/main/java/com/b44t/ui/CacheControlActivity.java +++ b/MessengerProj/src/main/java/com/b44t/ui/CacheControlActivity.java @@ -63,16 +63,16 @@ public class CacheControlActivity extends BaseFragment { private int typeSectionTitle = 2; private int typeCount = 3; // /EDIT BY MR -- no gaps, please - private long databaseSize = -1; - private long cacheSize = -1; - private long documentsSize = -1; - private long audioSize = -1; - private long musicSize = -1; - private long photoSize = -1; - private long videoSize = -1; - private long totalSize = -1; - private boolean clear[] = new boolean[6]; - private boolean calculating = true; + //private long databaseSize = -1; + //private long cacheSize = -1; + //private long documentsSize = -1; + //private long audioSize = -1; + //private long musicSize = -1; + //private long photoSize = -1; + //private long videoSize = -1; + //private long totalSize = -1; + //private boolean clear[] = new boolean[6]; + //private boolean calculating = true; private volatile boolean canceled = false; @@ -91,8 +91,9 @@ public class CacheControlActivity extends BaseFragment { databaseInfoRow = -1; // EDIT BY MR -- was: rowCount++; File file = new File(ApplicationLoader.getFilesDirFixed(), "cache4.db"); - databaseSize = file.length(); + //databaseSize = file.length(); + /* Utilities.globalQueue.postRunnable(new Runnable() { @Override public void run() { @@ -129,6 +130,7 @@ public class CacheControlActivity extends BaseFragment { }); } }); + */ return true; } @@ -570,7 +572,7 @@ public class CacheControlActivity extends BaseFragment { @Override public boolean isEnabled(int i) { - return i == databaseRow || i == cacheRow && totalSize > 0 || i == keepMediaRow; + return i == databaseRow || /*i == cacheRow && totalSize > 0 ||*/ i == keepMediaRow; } @Override @@ -612,13 +614,14 @@ public class CacheControlActivity extends BaseFragment { } TextSettingsCell textCell = (TextSettingsCell) view; if (i == databaseRow) { - textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false); + //textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false); } else if (i == cacheRow) { /*if (calculating) { textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), LocaleController.getString("CalculatingSize", R.string.CalculatingSize), false); - } else */ { + } else { textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), totalSize == 0 ? LocaleController.getString("CacheEmpty", R.string.CacheEmpty) : AndroidUtilities.formatFileSize(totalSize), false); } + */ } else if (i == keepMediaRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("mainconfig", Activity.MODE_PRIVATE); int keepMedia = preferences.getInt("keep_media", 2);