diff --git a/shell/android/src/com/reicast/emulator/FileBrowser.java b/shell/android/src/com/reicast/emulator/FileBrowser.java index ffd7363b1..7a56b15c5 100644 --- a/shell/android/src/com/reicast/emulator/FileBrowser.java +++ b/shell/android/src/com/reicast/emulator/FileBrowser.java @@ -1,6 +1,7 @@ package com.reicast.emulator; import java.io.File; +import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.FilenameFilter; import java.io.IOException; @@ -154,8 +155,25 @@ public class FileBrowser extends Fragment { // setContentView(R.layout.activity_main); parentActivity = getActivity(); try { + File buttons = null; + String theme = mPrefs.getString(Config.pref_theme, null); + if (theme != null) { + buttons = new File(theme); + } File file = new File(home_directory, "data/buttons.png"); - if (!file.exists()) { + if (buttons != null && buttons.exists()) { + InputStream in = new FileInputStream(buttons); + OutputStream out = new FileOutputStream(file); + + // Transfer bytes from in to out + byte[] buf = new byte[1024]; + int len; + while ((len = in.read(buf)) > 0) { + out.write(buf, 0, len); + } + in.close(); + out.close(); + } else if (!file.exists()) { file.createNewFile(); OutputStream fo = new FileOutputStream(file); InputStream png = parentActivity.getAssets() diff --git a/shell/android/src/com/reicast/emulator/config/Config.java b/shell/android/src/com/reicast/emulator/config/Config.java index c6e670fad..fe77dcca8 100644 --- a/shell/android/src/com/reicast/emulator/config/Config.java +++ b/shell/android/src/com/reicast/emulator/config/Config.java @@ -15,6 +15,7 @@ public class Config { public static final String pref_home = "home_directory"; public static final String pref_games = "game_directory"; + public static final String pref_theme = "button_theme"; public static final String pref_gamedetails = "game_details"; public static final String pref_nativeact = "enable_native"; diff --git a/shell/android/src/com/reicast/emulator/config/InputModFragment.java b/shell/android/src/com/reicast/emulator/config/InputModFragment.java index 2f4a25f19..76cdff3bc 100644 --- a/shell/android/src/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android/src/com/reicast/emulator/config/InputModFragment.java @@ -1,5 +1,7 @@ package com.reicast.emulator.config; +import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.io.InputStream; @@ -403,7 +405,17 @@ public class InputModFragment extends Fragment { System.gc(); } try { - InputStream bitmap = getResources().getAssets().open("buttons.png"); + File buttons = null; + InputStream bitmap = null; + String theme = mPrefs.getString(Config.pref_theme, null); + if (theme != null) { + buttons = new File(theme); + } + if (buttons != null && buttons.exists()) { + bitmap = new FileInputStream(buttons); + } else { + bitmap = getResources().getAssets().open("buttons.png"); + } BitmapFactory.Options options = new BitmapFactory.Options(); options.inSampleSize = sS; image = BitmapFactory.decodeStream(bitmap, null, options);