diff options
-rw-r--r-- | res/values-de/strings.xml | 5 | ||||
-rw-r--r-- | res/values-es/strings.xml | 5 | ||||
-rw-r--r-- | res/values-hu/strings.xml | 5 | ||||
-rw-r--r-- | res/values-ru/strings.xml | 5 | ||||
-rw-r--r-- | res/values/strings.xml | 5 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/fragments/MainFragment.java | 45 | ||||
-rw-r--r-- | src/github/daneren2005/dsub/util/FileUtil.java | 15 |
7 files changed, 55 insertions, 30 deletions
diff --git a/res/values-de/strings.xml b/res/values-de/strings.xml index 23ad19de..73a520bc 100644 --- a/res/values-de/strings.xml +++ b/res/values-de/strings.xml @@ -44,8 +44,9 @@ <string name="main.about_text">Autor: Scott Jackson
\nEmail: dsub.android@gmail.com
\nVersion: %1$s
- \nGenutzter Speicher: %2$s von %3$s
- \nVerfügbarer Speicher: %4$s von %5$s</string>
+ \nFiles Cached: %2$s
+ \nGenutzter Speicher: %3$s von %4$s
+ \nVerfügbarer Speicher: %5$s von %6$s</string>
<string name="main.select_server">Wähle Server</string>
<string name="main.shuffle">Zufallswiedergabe</string>
<string name="main.offline">Gehe Offline</string>
diff --git a/res/values-es/strings.xml b/res/values-es/strings.xml index e18e4b08..84b7c35c 100644 --- a/res/values-es/strings.xml +++ b/res/values-es/strings.xml @@ -43,8 +43,9 @@ <string name="main.about_text">Autor: Scott Jackson \nEmail: dsub.android@gmail.com \nVersión: %1$s - \nEspacio usado: %2$s of %3$s - \nEspacio disponible: %4$s of %5$s</string> + \nFiles Cached: %2$s + \nEspacio usado: %3$s of %4$s + \nEspacio disponible: %5$s of %6$s</string> <string name="main.select_server">Seleccionar servidor</string> <string name="main.shuffle">Reproducción aleatoria</string> <string name="main.offline">Modo Offline</string> diff --git a/res/values-hu/strings.xml b/res/values-hu/strings.xml index af44ef94..f18d5342 100644 --- a/res/values-hu/strings.xml +++ b/res/values-hu/strings.xml @@ -44,8 +44,9 @@ <string name="main.about_text">Fejlesztő: Scott Jackson
\nEmail: dsub.android@gmail.com
\nVerzió: %1$s
- \nFelhasznált tároló: %2$s/%3$s
- \nFelhasználható tároló: %4$s/%5$s</string>
+ \nFiles Cached: %2$s
+ \nFelhasznált tároló: %3$s/%4$s
+ \nFelhasználható tároló: %5$s/%6$s</string>
<string name="main.select_server">Kiszolgáló kiválasztása</string>
<string name="main.shuffle">Lejátszás kevert sorrendben</string>
<string name="main.offline">Offline mód</string>
diff --git a/res/values-ru/strings.xml b/res/values-ru/strings.xml index 7094fe7d..0f6cce5d 100644 --- a/res/values-ru/strings.xml +++ b/res/values-ru/strings.xml @@ -35,8 +35,9 @@ <string name="main.about_text">Автор: Scott Jackson
\nEmail: dsub.android@gmail.com
\nВерсия: %1$s
- \nИспользовано места: %2$s из %3$s
- \nДоступно места: %4$s из %5$s</string>
+ \nFiles Cached: %2$s
+ \nИспользовано места: %3$s из %4$s
+ \nДоступно места: %5$s из %6$s</string>
<string name="main.select_server">Выбрать сервер</string>
<string name="main.shuffle">Случайное воспроизведение</string>
<string name="main.offline">Отключиться</string>
diff --git a/res/values/strings.xml b/res/values/strings.xml index 8824085c..499fc174 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -44,8 +44,9 @@ <string name="main.about_text">Author: Scott Jackson
\nEmail: dsub.android@gmail.com
\nVersion: %1$s
- \nUsed Space: %2$s of %3$s
- \nAvailable Space: %4$s of %5$s</string>
+ \nFiles Cached: %2$s
+ \nUsed Space: %3$s of %4$s
+ \nAvailable Space: %5$s of %6$s</string>
<string name="main.select_server">Select server</string>
<string name="main.shuffle">Shuffle play</string>
<string name="main.offline">Go Offline</string>
diff --git a/src/github/daneren2005/dsub/fragments/MainFragment.java b/src/github/daneren2005/dsub/fragments/MainFragment.java index 3a9370a3..c9bbf850 100644 --- a/src/github/daneren2005/dsub/fragments/MainFragment.java +++ b/src/github/daneren2005/dsub/fragments/MainFragment.java @@ -24,6 +24,7 @@ import github.daneren2005.dsub.service.DownloadService; import github.daneren2005.dsub.util.Constants;
import github.daneren2005.dsub.util.FileUtil;
import github.daneren2005.dsub.util.LoadingTask;
+import github.daneren2005.dsub.util.Pair;
import github.daneren2005.dsub.view.MergeAdapter;
import github.daneren2005.dsub.util.Util;
import github.daneren2005.dsub.service.MusicService;
@@ -319,22 +320,34 @@ public class MainFragment extends SubsonicFragment { }
private void showAboutDialog() {
- try {
- File rootFolder = FileUtil.getMusicDirectory(context);
- StatFs stat = new StatFs(rootFolder.getPath());
- long bytesTotalFs = (long) stat.getBlockCount() * (long) stat.getBlockSize();
- long bytesAvailableFs = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
-
- String msg = getResources().getString(R.string.main_about_text,
- context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName,
- Util.formatBytes(FileUtil.getUsedSize(context, rootFolder)),
- Util.formatBytes(Util.getCacheSizeMB(context) * 1024L * 1024L),
- Util.formatBytes(bytesAvailableFs),
- Util.formatBytes(bytesTotalFs));
- Util.info(context, R.string.main_about_title, msg);
- } catch(Exception e) {
- Util.toast(context, "Failed to open dialog");
- }
+ new LoadingTask<String>(context) {
+ @Override
+ protected String doInBackground() throws Throwable {
+ File rootFolder = FileUtil.getMusicDirectory(context);
+ StatFs stat = new StatFs(rootFolder.getPath());
+ long bytesTotalFs = (long) stat.getBlockCount() * (long) stat.getBlockSize();
+ long bytesAvailableFs = (long) stat.getAvailableBlocks() * (long) stat.getBlockSize();
+
+ Pair<Long, Long> used = FileUtil.getUsedSize(context, rootFolder);
+
+ return getResources().getString(R.string.main_about_text,
+ context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionName,
+ used.getFirst(),
+ Util.formatBytes(used.getSecond()),
+ Util.formatBytes(Util.getCacheSizeMB(context) * 1024L * 1024L),
+ Util.formatBytes(bytesAvailableFs),
+ Util.formatBytes(bytesTotalFs));
+ }
+
+ @Override
+ protected void done(String msg) {
+ try {
+ Util.info(context, R.string.main_about_title, msg);
+ } catch(Exception e) {
+ Util.toast(context, "Failed to open dialog");
+ }
+ }
+ }.execute();
}
private void getLogs() {
diff --git a/src/github/daneren2005/dsub/util/FileUtil.java b/src/github/daneren2005/dsub/util/FileUtil.java index 657ca50c..a68ded45 100644 --- a/src/github/daneren2005/dsub/util/FileUtil.java +++ b/src/github/daneren2005/dsub/util/FileUtil.java @@ -510,16 +510,23 @@ public class FileUtil { return index == -1 ? name : name.substring(0, index); } - public static long getUsedSize(Context context, File file) { + public static Pair<Long, Long> getUsedSize(Context context, File file) { + long number = 0L; long size = 0L; if(file.isFile()) { - return file.length(); + if(isMediaFile(file)) { + return new Pair<Long, Long>(1L, file.length()); + } else { + return new Pair<Long, Long>(0L, 0L); + } } else { for (File child : FileUtil.listFiles(file)) { - size += getUsedSize(context, child); + Pair<Long, Long> pair = getUsedSize(context, child); + number += pair.getFirst(); + size += pair.getSecond(); } - return size; + return new Pair<Long, Long>(number, size); } } |