From 4b0d1092c150b50affd3c67a43687985cbf99454 Mon Sep 17 00:00:00 2001 From: Ender's Games Date: Wed, 26 Sep 2018 00:11:46 -0400 Subject: [PATCH] Android: Adjust theme prefs for future selections --- .../com/reicast/emulator/AboutFragment.java | 5 +++-- .../java/com/reicast/emulator/FileBrowser.java | 12 ++++-------- .../com/reicast/emulator/MainActivity.java | 15 ++++++++++----- .../com/reicast/emulator/config/Config.java | 4 +++- .../emulator/config/InputModFragment.java | 2 +- .../emulator/config/OptionsFragment.java | 7 +++---- .../com/reicast/emulator/debug/GitAdapter.java | 8 +++++--- ...ckground_light.xml => background_dream.xml} | 0 .../src/main/res/drawable/game_selector.xml | 10 ---------- .../main/res/drawable/game_selector_dream.xml | 10 ++++++++++ .../{gradient_bg.xml => gradient_bg_dream.xml} | 0 ...g_hover.xml => gradient_bg_hover_dream.xml} | 6 +++--- .../src/main/res/drawable/list_selector.xml | 9 --------- .../main/res/drawable/list_selector_dream.xml | 9 +++++++++ .../src/main/res/layout/bios_list_item.xml | 2 +- .../res/layout/browser_fragment_header.xml | 2 +- .../main/res/layout/browser_fragment_item.xml | 2 +- .../src/main/res/layout/change_item.xml | 2 +- .../src/main/res/layout/dialog_item.xml | 2 +- .../reicast/src/main/res/values/colors.xml | 11 ++++++----- .../reicast/src/main/res/values/styles.xml | 18 +++++++----------- 21 files changed, 69 insertions(+), 67 deletions(-) rename shell/android-studio/reicast/src/main/res/drawable/{background_light.xml => background_dream.xml} (100%) delete mode 100644 shell/android-studio/reicast/src/main/res/drawable/game_selector.xml create mode 100644 shell/android-studio/reicast/src/main/res/drawable/game_selector_dream.xml rename shell/android-studio/reicast/src/main/res/drawable/{gradient_bg.xml => gradient_bg_dream.xml} (100%) rename shell/android-studio/reicast/src/main/res/drawable/{gradient_bg_hover.xml => gradient_bg_hover_dream.xml} (57%) delete mode 100644 shell/android-studio/reicast/src/main/res/drawable/list_selector.xml create mode 100644 shell/android-studio/reicast/src/main/res/drawable/list_selector_dream.xml diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java index bd2e6fa6a..71a9c1574 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/AboutFragment.java @@ -153,8 +153,9 @@ public class AboutFragment extends Fragment { ListView list = (ListView) ref.get().getView().findViewById(R.id.list); SharedPreferences mPrefs = PreferenceManager .getDefaultSharedPreferences(ref.get().getActivity()); - if (mPrefs.getBoolean("lightTheme", false)) { - list.setSelector(R.drawable.list_selector); + int app_theme = mPrefs.getInt(Config.pref_app_theme, 0); + if (app_theme == 7) { + list.setSelector(R.drawable.list_selector_dream); } else { list.setSelector(R.drawable.list_selector_dark); } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/FileBrowser.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/FileBrowser.java index 117b2fd5a..f030bdc12 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/FileBrowser.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/FileBrowser.java @@ -5,7 +5,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.graphics.Typeface; import android.graphics.drawable.Drawable; -import android.graphics.drawable.StateListDrawable; import android.net.Uri; import android.os.AsyncTask; import android.os.Build; @@ -17,14 +16,11 @@ import android.support.constraint.ConstraintLayout; import android.support.design.widget.Snackbar; import android.support.graphics.drawable.VectorDrawableCompat; import android.support.v4.app.Fragment; -import android.support.v4.content.ContextCompat; import android.support.v4.content.FileProvider; import android.view.Gravity; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.view.View.OnClickListener; -import android.view.View.OnTouchListener; import android.view.ViewGroup; import android.widget.ImageView; import android.widget.LinearLayout; @@ -52,7 +48,6 @@ import java.util.Collection; import java.util.Collections; import java.util.Comparator; import java.util.HashSet; -import java.util.Iterator; import java.util.List; import java.util.Locale; @@ -188,7 +183,7 @@ public class FileBrowser extends Fragment { private void installButtons() { try { File buttons = null; - String theme = mPrefs.getString(Config.pref_theme, null); + String theme = mPrefs.getString(Config.pref_button_theme, null); if (theme != null) { buttons = new File(theme); } @@ -452,9 +447,10 @@ public class FileBrowser extends Fragment { final View childview = browser.get().getActivity().getLayoutInflater().inflate( R.layout.browser_fragment_item, null, false); - if (browser.get().mPrefs.getBoolean("lightTheme", false)) { + int app_theme = browser.get().mPrefs.getInt(Config.pref_app_theme, 0); + if (app_theme == 7) { childview.findViewById(R.id.childview) - .setBackgroundResource(R.drawable.game_selector); + .setBackgroundResource(R.drawable.game_selector_dream); } else { childview.findViewById(R.id.childview) .setBackgroundResource(R.drawable.game_selector_dark); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java index 802b062c5..0c3352c69 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/MainActivity.java @@ -57,8 +57,12 @@ public class MainActivity extends AppCompatActivity implements @Override public void onCreate(Bundle savedInstanceState) { mPrefs = PreferenceManager.getDefaultSharedPreferences(this); - setTheme(mPrefs.getBoolean("lightTheme", false) - ? R.style.AppTheme_Light : R.style.AppTheme); + int app_theme = mPrefs.getInt(Config.pref_app_theme, 0); + if (app_theme == 7) { + setTheme(R.style.AppTheme_Dream); + } else { + setTheme(R.style.AppTheme); + } super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); @@ -536,11 +540,12 @@ public class MainActivity extends AppCompatActivity implements drawer.closeDrawer(GravityCompat.START); return true; case R.id.theme_menu: - if (mPrefs.getBoolean("lightTheme", false)) { - mPrefs.edit().putBoolean("lightTheme", false).apply(); + int app_theme = mPrefs.getInt(Config.pref_app_theme, 0); + if (app_theme == 7) { + mPrefs.edit().putInt(Config.pref_app_theme, 0).apply(); restartActivity(); } else { - mPrefs.edit().putBoolean("lightTheme", true).apply(); + mPrefs.edit().putInt(Config.pref_app_theme, 7).apply(); restartActivity(); } drawer.closeDrawer(GravityCompat.START); diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java index 65ed2ed76..eeb241c23 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/Config.java @@ -8,7 +8,9 @@ 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_button_theme = "button_theme"; + + public static final String pref_app_theme = "app_theme"; public static final String pref_gamedetails = "game_details"; diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java index 7ae8ebb2f..84e26cf0d 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/InputModFragment.java @@ -427,7 +427,7 @@ public class InputModFragment extends Fragment { try { File buttons = null; InputStream bitmap; - String theme = mPrefs.getString(Config.pref_theme, null); + String theme = mPrefs.getString(Config.pref_button_theme, null); if (theme != null) { buttons = new File(theme); } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java index 55f209dd6..62ff5fe22 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/config/OptionsFragment.java @@ -53,7 +53,6 @@ import java.io.OutputStream; import java.lang.ref.WeakReference; import java.util.Collection; import java.util.HashSet; -import java.util.Iterator; import java.util.List; public class OptionsFragment extends Fragment { @@ -608,10 +607,10 @@ public class OptionsFragment extends Fragment { public void onItemSelected(AdapterView parentView, View selectedItemView, int position, long id) { String theme = String.valueOf(parentView.getItemAtPosition(position)); if (theme.equals("None")) { - options.get().mPrefs.edit().remove(Config.pref_theme).apply(); + options.get().mPrefs.edit().remove(Config.pref_button_theme).apply(); } else { String theme_path = options.get().home_directory + "/themes/" + theme; - options.get().mPrefs.edit().putString(Config.pref_theme, theme_path).apply(); + options.get().mPrefs.edit().putString(Config.pref_button_theme, theme_path).apply(); } } @Override @@ -705,7 +704,7 @@ public class OptionsFragment extends Fragment { mPrefs.edit().remove(Config.pref_rendertype).apply(); mPrefs.edit().remove(Emulator.pref_nosound).apply(); mPrefs.edit().remove(Config.pref_renderdepth).apply(); - mPrefs.edit().remove(Config.pref_theme).apply(); + mPrefs.edit().remove(Config.pref_button_theme).apply(); getActivity().finish(); } diff --git a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java index 28d23ba7f..7b4f0d4f3 100644 --- a/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java +++ b/shell/android-studio/reicast/src/main/java/com/reicast/emulator/debug/GitAdapter.java @@ -30,6 +30,7 @@ import com.nostra13.universalimageloader.core.ImageLoader; import com.nostra13.universalimageloader.core.ImageLoaderConfiguration; import com.nostra13.universalimageloader.core.assist.ImageScaleType; import com.reicast.emulator.R; +import com.reicast.emulator.config.Config; import java.util.ArrayList; import java.util.HashMap; @@ -74,8 +75,9 @@ public class GitAdapter extends BaseAdapter { if (convertView == null) vi = this.inflater.inflate(R.layout.change_item, null); - if (mPrefs.getBoolean("lightTheme", false)) { - vi.setBackgroundResource(R.drawable.list_selector); + int app_theme = mPrefs.getInt(Config.pref_app_theme, 0); + if (app_theme == 7) { + vi.setBackgroundResource(R.drawable.list_selector_dream); } else { vi.setBackgroundResource(R.drawable.list_selector_dark); } @@ -99,7 +101,7 @@ public class GitAdapter extends BaseAdapter { RelativeLayout item = (RelativeLayout) vi.findViewById(R.id.change); if (current != null && current.equals(sha.substring(0, 7))) { item.getBackground().setColorFilter(0xFF00FF00, - PorterDuff.Mode.MULTIPLY); + PorterDuff.Mode.OVERLAY); } else { item.getBackground().setColorFilter(null); } diff --git a/shell/android-studio/reicast/src/main/res/drawable/background_light.xml b/shell/android-studio/reicast/src/main/res/drawable/background_dream.xml similarity index 100% rename from shell/android-studio/reicast/src/main/res/drawable/background_light.xml rename to shell/android-studio/reicast/src/main/res/drawable/background_dream.xml diff --git a/shell/android-studio/reicast/src/main/res/drawable/game_selector.xml b/shell/android-studio/reicast/src/main/res/drawable/game_selector.xml deleted file mode 100644 index 87c9c9bc8..000000000 --- a/shell/android-studio/reicast/src/main/res/drawable/game_selector.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/res/drawable/game_selector_dream.xml b/shell/android-studio/reicast/src/main/res/drawable/game_selector_dream.xml new file mode 100644 index 000000000..0ed29fe78 --- /dev/null +++ b/shell/android-studio/reicast/src/main/res/drawable/game_selector_dream.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/res/drawable/gradient_bg.xml b/shell/android-studio/reicast/src/main/res/drawable/gradient_bg_dream.xml similarity index 100% rename from shell/android-studio/reicast/src/main/res/drawable/gradient_bg.xml rename to shell/android-studio/reicast/src/main/res/drawable/gradient_bg_dream.xml diff --git a/shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover.xml b/shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover_dream.xml similarity index 57% rename from shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover.xml rename to shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover_dream.xml index 9365597a6..084f8f6df 100644 --- a/shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover.xml +++ b/shell/android-studio/reicast/src/main/res/drawable/gradient_bg_hover_dream.xml @@ -5,8 +5,8 @@ + android:centerColor="@color/colorDreamAccentDark" + android:endColor="@color/colorDreamAccent" + android:startColor="@color/colorDreamAccent" /> \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/res/drawable/list_selector.xml b/shell/android-studio/reicast/src/main/res/drawable/list_selector.xml deleted file mode 100644 index fb1560c2e..000000000 --- a/shell/android-studio/reicast/src/main/res/drawable/list_selector.xml +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/res/drawable/list_selector_dream.xml b/shell/android-studio/reicast/src/main/res/drawable/list_selector_dream.xml new file mode 100644 index 000000000..2648c6895 --- /dev/null +++ b/shell/android-studio/reicast/src/main/res/drawable/list_selector_dream.xml @@ -0,0 +1,9 @@ + + + + + + + + + \ No newline at end of file diff --git a/shell/android-studio/reicast/src/main/res/layout/bios_list_item.xml b/shell/android-studio/reicast/src/main/res/layout/bios_list_item.xml index 2b587ffc7..820a9ea25 100644 --- a/shell/android-studio/reicast/src/main/res/layout/bios_list_item.xml +++ b/shell/android-studio/reicast/src/main/res/layout/bios_list_item.xml @@ -13,7 +13,7 @@ android:orientation="horizontal" android:clickable="true" android:focusable="true" - android:background="@drawable/game_selector" > + android:background="@drawable/game_selector_dream" > + android:background="@drawable/game_selector_dream" > + android:background="@drawable/game_selector_dream" > diff --git a/shell/android-studio/reicast/src/main/res/layout/dialog_item.xml b/shell/android-studio/reicast/src/main/res/layout/dialog_item.xml index cffbd9b34..8df45a14e 100644 --- a/shell/android-studio/reicast/src/main/res/layout/dialog_item.xml +++ b/shell/android-studio/reicast/src/main/res/layout/dialog_item.xml @@ -3,7 +3,7 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="fill_parent" android:layout_height="wrap_content" - android:background="@drawable/list_selector" + android:background="@drawable/list_selector_dream" android:orientation="horizontal" android:padding="5dip" > diff --git a/shell/android-studio/reicast/src/main/res/values/colors.xml b/shell/android-studio/reicast/src/main/res/values/colors.xml index f18d85ced..73bf3c8ad 100644 --- a/shell/android-studio/reicast/src/main/res/values/colors.xml +++ b/shell/android-studio/reicast/src/main/res/values/colors.xml @@ -7,11 +7,12 @@ #e0e0e0 #e0e0e0 - #6e6b66 - #534e4b - #5787c7 - #42a5f5 - #3d3533 + #6e6b66 + #534e4b + #5787c7 + #42a5f5 + #3d3533 + #534e4b #42a5f5 diff --git a/shell/android-studio/reicast/src/main/res/values/styles.xml b/shell/android-studio/reicast/src/main/res/values/styles.xml index d619cdbaa..78ad67f27 100644 --- a/shell/android-studio/reicast/src/main/res/values/styles.xml +++ b/shell/android-studio/reicast/src/main/res/values/styles.xml @@ -8,25 +8,21 @@ @color/colorDarkPrimaryDark @color/colorDarkAccent @drawable/background_dark - @android:color/white @color/colorDarkText @android:color/white - @color/colorDarkTint -