From cf553a0aed8f494c715ae8b1a9c8f2d6c810fbd2 Mon Sep 17 00:00:00 2001 From: Eric House Date: Mon, 9 Aug 2021 21:21:10 -0700 Subject: [PATCH] set first theme choice as default workaround for not knowing how to set default based on os version: don't set default, and when there's none set use the first in the list. --- .../java/org/eehouse/android/xw4/PrefsDelegate.java | 10 +++++++++- xwords4/android/app/src/main/res/.gitignore | 2 +- .../app/src/main/res/values-v29/common_rsrc.xml | 11 +++++++++++ .../android/app/src/main/res/values-v29/strings.xml | 6 ++++++ .../android/app/src/main/res/values/common_rsrc.xml | 1 - xwords4/android/app/src/main/res/values/strings.xml | 1 - .../app/src/main/res/xml/prefs_appear_themes.xml | 2 +- 7 files changed, 28 insertions(+), 5 deletions(-) create mode 100644 xwords4/android/app/src/main/res/values-v29/common_rsrc.xml create mode 100644 xwords4/android/app/src/main/res/values-v29/strings.xml diff --git a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java index 8a1856e94..00daa9257 100644 --- a/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java +++ b/xwords4/android/app/src/main/java/org/eehouse/android/xw4/PrefsDelegate.java @@ -159,10 +159,18 @@ public class PrefsDelegate extends DelegateBase protected void onResume() { super.onResume(); - getSharedPreferences().registerOnSharedPreferenceChangeListener(this); + SharedPreferences sp = getSharedPreferences(); + sp.registerOnSharedPreferenceChangeListener( this ); // It's too early somehow to do this in init() above findViewById( R.id.prefs_menu ).setOnClickListener(this); + + String key = LocUtils.getString( mActivity, R.string.key_theme_which ); + if ( null == sp.getString( key, null ) ) { + Resources res = mActivity.getResources(); + String[] vals = res.getStringArray( R.array.color_themes ); + sp.edit().putString( key, vals[0] ).commit(); + } } @Override diff --git a/xwords4/android/app/src/main/res/.gitignore b/xwords4/android/app/src/main/res/.gitignore index 185a83c74..eb188953f 100644 --- a/xwords4/android/app/src/main/res/.gitignore +++ b/xwords4/android/app/src/main/res/.gitignore @@ -1,2 +1,2 @@ -values-*/strings.xml +values-*/ **/*__gen.png diff --git a/xwords4/android/app/src/main/res/values-v29/common_rsrc.xml b/xwords4/android/app/src/main/res/values-v29/common_rsrc.xml new file mode 100644 index 000000000..6c29f78b4 --- /dev/null +++ b/xwords4/android/app/src/main/res/values-v29/common_rsrc.xml @@ -0,0 +1,11 @@ + + + + @string/color_use_theme_os + @string/color_use_theme_light + @string/color_use_theme_dark + + + diff --git a/xwords4/android/app/src/main/res/values-v29/strings.xml b/xwords4/android/app/src/main/res/values-v29/strings.xml new file mode 100644 index 000000000..bc77b6529 --- /dev/null +++ b/xwords4/android/app/src/main/res/values-v29/strings.xml @@ -0,0 +1,6 @@ + + + Use Theme from Android Settings + diff --git a/xwords4/android/app/src/main/res/values/common_rsrc.xml b/xwords4/android/app/src/main/res/values/common_rsrc.xml index f89d84261..b705c7e80 100644 --- a/xwords4/android/app/src/main/res/values/common_rsrc.xml +++ b/xwords4/android/app/src/main/res/values/common_rsrc.xml @@ -386,7 +386,6 @@ @string/color_use_theme_light @string/color_use_theme_dark - @string/color_use_theme_os diff --git a/xwords4/android/app/src/main/res/values/strings.xml b/xwords4/android/app/src/main/res/values/strings.xml index b0a5469d0..274216c40 100644 --- a/xwords4/android/app/src/main/res/values/strings.xml +++ b/xwords4/android/app/src/main/res/values/strings.xml @@ -2746,7 +2746,6 @@ Board color theme Use Light theme Use Dark theme - Use Theme from Android Settings Edit Light theme Edit Dark theme diff --git a/xwords4/android/app/src/main/res/xml/prefs_appear_themes.xml b/xwords4/android/app/src/main/res/xml/prefs_appear_themes.xml index 5382f1d78..43aec48bc 100644 --- a/xwords4/android/app/src/main/res/xml/prefs_appear_themes.xml +++ b/xwords4/android/app/src/main/res/xml/prefs_appear_themes.xml @@ -6,12 +6,12 @@ +