Show free space for current choice

This commit is contained in:
Martin Fietz 2015-12-31 14:17:12 +01:00
parent d18efcc3b1
commit b793866ed4
2 changed files with 14 additions and 3 deletions

View File

@ -711,7 +711,7 @@ public class PreferenceController implements SharedPreferences.OnSharedPreferenc
} else {
choices[i] = path;
}
long bytes = StorageUtils.getFreeSpaceAvailable();
long bytes = StorageUtils.getFreeSpaceAvailable(path);
String freeSpace = String.format(context.getString(R.string.free_space_label),
Converter.byteToString(bytes));
choices[i] = Html.fromHtml("<html><small>" + choices[i]

View File

@ -51,8 +51,19 @@ public class StorageUtils {
* Get the number of free bytes that are available on the external storage.
*/
public static long getFreeSpaceAvailable() {
StatFs stat = new StatFs(UserPreferences.getDataFolder(
null).getAbsolutePath());
File dataFolder = UserPreferences.getDataFolder(null);
if (dataFolder != null) {
return getFreeSpaceAvailable(dataFolder.getAbsolutePath());
} else {
return 0;
}
}
/**
* Get the number of free bytes that are available on the external storage.
*/
public static long getFreeSpaceAvailable(String path) {
StatFs stat = new StatFs(path);
long availableBlocks;
long blockSize;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {