mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
Cleanup paths.
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -1228,6 +1228,10 @@ public class ImageLoader {
|
||||
filter.addDataScheme("file");
|
||||
ApplicationLoader.applicationContext.registerReceiver(receiver, filter);
|
||||
|
||||
checkMediaPaths();
|
||||
}
|
||||
|
||||
public void checkMediaPaths() {
|
||||
HashMap<Integer, File> 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<Integer, File> createMediaPaths() { // not sure, but it seems as if these paths are not needed
|
||||
HashMap<Integer, File> 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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user