From 0170050cad3a28ca4fdf0f34ff2f4414dd6b013a Mon Sep 17 00:00:00 2001 From: Eder Bastos <bastos.eder@gmail.com> Date: Fri, 4 Jul 2014 15:48:12 -0400 Subject: [PATCH 1/2] Use the "No Banner" graphic as a Drawable resource, instead of as an asset. --- .../drawable/no_banner.png} | Bin .../dolphinemu/gamelist/GameListAdapter.java | 17 ++++++++++++++- .../dolphinemu/gamelist/GameListItem.java | 20 +----------------- 3 files changed, 17 insertions(+), 20 deletions(-) rename Source/Android/{assets/NoBanner.png => res/drawable/no_banner.png} (100%) diff --git a/Source/Android/assets/NoBanner.png b/Source/Android/res/drawable/no_banner.png similarity index 100% rename from Source/Android/assets/NoBanner.png rename to Source/Android/res/drawable/no_banner.png diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java index 30796593ca..aabd4f2bc3 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java @@ -7,6 +7,7 @@ package org.dolphinemu.dolphinemu.gamelist; import android.content.Context; +import android.graphics.Bitmap; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -75,7 +76,21 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem> { holder.title.setText(item.getName()); holder.subtitle.setText(item.getData()); - holder.icon.setImageBitmap(item.getImage()); + + Bitmap icon = item.getImage(); + + if (icon != null) + { + holder.icon.setImageBitmap(item.getImage()); + } + else + { + holder.icon.setImageResource(R.drawable.no_banner); + } + + String subtitle = String.format(context.getString(R.string.file_size_gib), item.getFilesize()); + + holder.subtitle.setText(subtitle); } // Make every other game in the list grey diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java index 1b72da7b9b..b804337781 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java @@ -45,25 +45,7 @@ public final class GameListItem implements Comparable<GameListItem> if (!file.isDirectory() && !path.isEmpty()) { int[] Banner = NativeLibrary.GetBanner(path); - if (Banner[0] == 0) - { - try - { - // Open the no banner icon. - InputStream noBannerPath = ctx.getAssets().open("NoBanner.png"); - - // Decode the bitmap. - image = BitmapFactory.decodeStream(noBannerPath); - - // Scale the bitmap to match other banners. - image = Bitmap.createScaledBitmap(image, 96, 32, false); - } - catch (IOException e) - { - Log.e("GameListItem", e.toString()); - } - } - else + if (Banner[0] != 0) { image = Bitmap.createBitmap(Banner, 96, 32, Bitmap.Config.ARGB_8888); } From 36821cb1171e02aa914fed1f8968d69162d2a353 Mon Sep 17 00:00:00 2001 From: Eder Bastos <bastos.eder@gmail.com> Date: Fri, 4 Jul 2014 15:35:51 -0400 Subject: [PATCH 2/2] Display file size in GiB instead of bytes. --- Source/Android/res/values-ja/strings.xml | 2 ++ Source/Android/res/values/strings.xml | 3 +++ .../dolphinemu/gamelist/GameListAdapter.java | 20 ++++++++++++++++--- .../dolphinemu/gamelist/GameListFragment.java | 7 ++++--- .../dolphinemu/gamelist/GameListItem.java | 16 +++++++-------- 5 files changed, 34 insertions(+), 14 deletions(-) diff --git a/Source/Android/res/values-ja/strings.xml b/Source/Android/res/values-ja/strings.xml index d798a35652..97537a38e7 100644 --- a/Source/Android/res/values-ja/strings.xml +++ b/Source/Android/res/values-ja/strings.xml @@ -41,6 +41,8 @@ <string name="browse_folder">フォルダの参照</string> <string name="settings">設定</string> <string name="about">について</string> + <string name="file_size_gib">ファイルサイズ: %.2f GiB</string> + <string name="file_size_mib">ファイルサイズ: %.2f MiB</string> <!-- Game List Activity - Device Compatibility AlertDialog --> <string name="device_compat_warning">デバイスの互換性の警告</string> diff --git a/Source/Android/res/values/strings.xml b/Source/Android/res/values/strings.xml index 06de05ae27..913d124f02 100644 --- a/Source/Android/res/values/strings.xml +++ b/Source/Android/res/values/strings.xml @@ -34,6 +34,7 @@ <string name="parent_directory">Parent Directory</string> <string name="file_size">File Size: %1$s</string> + <!-- Game List Activity --> <string name="clear_game_list">Clear game list</string> <string name="clear_game_list_confirm">Do you want to clear the game list?</string> @@ -41,6 +42,8 @@ <string name="browse_folder">Browse Folder</string> <string name="settings">Settings</string> <string name="about">About</string> + <string name="file_size_gib">File Size: %.2f GiB</string> + <string name="file_size_mib">File Size: %.2f MiB</string> <!-- Game List Activity - Device Compatibility AlertDialog --> <string name="device_compat_warning">Device Compatibility Warning</string> diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java index aabd4f2bc3..4ca43f6250 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListAdapter.java @@ -24,6 +24,9 @@ import org.dolphinemu.dolphinemu.R; */ public final class GameListAdapter extends ArrayAdapter<GameListItem> { + private static final float BYTES_PER_GIB = 1024 * 1024 * 1024; + private static final float BYTES_PER_MIB = 1024 * 1024; + private final Context context; private final int id; @@ -75,20 +78,31 @@ public final class GameListAdapter extends ArrayAdapter<GameListItem> if (item != null) { holder.title.setText(item.getName()); - holder.subtitle.setText(item.getData()); Bitmap icon = item.getImage(); if (icon != null) { - holder.icon.setImageBitmap(item.getImage()); + holder.icon.setImageBitmap(icon); } else { holder.icon.setImageResource(R.drawable.no_banner); } - String subtitle = String.format(context.getString(R.string.file_size_gib), item.getFilesize()); + float fileSize = item.getFilesize() / BYTES_PER_GIB; + + String subtitle; + + if (fileSize >= 1.0f) + { + subtitle = String.format(context.getString(R.string.file_size_gib), fileSize); + } + else + { + fileSize = item.getFilesize() / BYTES_PER_MIB; + subtitle = String.format(context.getString(R.string.file_size_mib), fileSize); + } holder.subtitle.setText(subtitle); } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java index 244902af67..60e10a3561 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListFragment.java @@ -60,7 +60,7 @@ public final class GameListFragment extends ListFragment mGameAdapter.notifyDataSetChanged(); } - private void Fill() + private void fill() { List<GameListItem> fls = new ArrayList<GameListItem>(); String Directories = NativeLibrary.GetConfig("Dolphin.ini", "General", "GCMPathes", "0"); @@ -83,8 +83,9 @@ public final class GameListFragment extends ListFragment if (!entry.isHidden() && !entry.isDirectory()) { if (exts.contains(entryName.toLowerCase().substring(entryName.lastIndexOf('.')))) - fls.add(new GameListItem(getActivity(), entryName, String.format(getString(R.string.file_size), entry.length()), entry.getAbsolutePath())); + fls.add(new GameListItem(getActivity(), entryName, entry.length(), entry.getAbsolutePath())); } + } } catch (Exception ignored) @@ -110,7 +111,7 @@ public final class GameListFragment extends ListFragment mGameAdapter = new GameListAdapter(getActivity(), R.layout.gamelist_list_item); rootView.setAdapter(mGameAdapter); - Fill(); + fill(); return rootView; } diff --git a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java index b804337781..6459eda8d8 100644 --- a/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java +++ b/Source/Android/src/org/dolphinemu/dolphinemu/gamelist/GameListItem.java @@ -23,7 +23,7 @@ import org.dolphinemu.dolphinemu.NativeLibrary; public final class GameListItem implements Comparable<GameListItem> { private String name; - private final String data; + private long filesize; private final String path; private Bitmap image; @@ -32,13 +32,13 @@ public final class GameListItem implements Comparable<GameListItem> * * @param ctx The current {@link Context} * @param name The name of this GameListItem. - * @param data The subtitle for this GameListItem + * @param filesize The filesize for this GameListItem, in GiB * @param path The file path for the game represented by this GameListItem. */ - public GameListItem(Context ctx, String name, String data, String path) + public GameListItem(Context ctx, String name, long filesize, String path) { this.name = name; - this.data = data; + this.filesize = filesize; this.path = path; File file = new File(path); @@ -65,13 +65,13 @@ public final class GameListItem implements Comparable<GameListItem> } /** - * Gets the subtitle of this GameListItem. + * Gets the filesize of this GameListItem, in GiB. * - * @return the subtitle of this GameListItem. + * @return the filesize of this GameListItem. */ - public String getData() + public long getFilesize() { - return data; + return filesize; } /**