unify theme setting, disable light theme on HC

This commit is contained in:
Andrew Dolgov 2013-04-16 13:15:21 +04:00
parent 16aaf4547f
commit e9b049c540
8 changed files with 28 additions and 44 deletions

View File

@ -192,4 +192,5 @@
<string name="requires_api5">Requires version 1.7.6</string>
<string name="labels">Labels</string>
<string name="article_img_view_caption">View Caption</string>
<string name="light_theme_is_not_supported_on_honeycomb">Light theme is not supported on Honeycomb</string>
</resources>

View File

@ -30,11 +30,6 @@ public class CommonActivity extends FragmentActivity {
protected SharedPreferences m_prefs;
protected boolean isDarkTheme() {
return m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK") ||
m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK_GRAY");
}
protected void setSmallScreen(boolean smallScreen) {
Log.d(TAG, "m_smallScreenMode=" + smallScreen);
m_smallScreenMode = smallScreen;
@ -142,4 +137,24 @@ public class CommonActivity extends FragmentActivity {
toast.show();
}
protected void setAppTheme(SharedPreferences prefs) {
String defaultTheme = "THEME_DARK";
if (prefs.getString("theme", defaultTheme).equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else if (prefs.getString("theme", defaultTheme).equals("THEME_SEPIA")) {
setTheme(R.style.SepiaTheme);
} else if (prefs.getString("theme", defaultTheme).equals("THEME_DARK_GRAY")) {
setTheme(R.style.DarkGrayTheme);
} else {
// LightTheme is not supported on honeycomb
if (android.os.Build.VERSION.SDK_INT >= 11 && android.os.Build.VERSION.SDK_INT < 14) {
toast(R.string.light_theme_is_not_supported_on_honeycomb);
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
}
}
}

View File

@ -40,11 +40,7 @@ public class FeedsActivity extends OnlineActivity implements HeadlinesEventListe
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -26,11 +26,7 @@ public class HeadlinesActivity extends OnlineActivity implements HeadlinesEventL
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -145,16 +145,8 @@ public class OnlineActivity extends CommonActivity {
// we use that before parent onCreate so let's init locally
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_SEPIA")) {
setTheme(R.style.SepiaTheme);
} else if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK_GRAY")) {
setTheme(R.style.DarkGrayTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -74,15 +74,7 @@ public class OfflineActivity extends CommonActivity {
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_SEPIA")) {
setTheme(R.style.SepiaTheme);
} else if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK_GRAY")) {
setTheme(R.style.DarkGrayTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -30,11 +30,7 @@ public class OfflineFeedsActivity extends OfflineActivity implements OfflineHead
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);

View File

@ -27,11 +27,7 @@ public class OfflineHeadlinesActivity extends OfflineActivity implements Offline
m_prefs = PreferenceManager
.getDefaultSharedPreferences(getApplicationContext());
if (m_prefs.getString("theme", "THEME_DARK").equals("THEME_DARK")) {
setTheme(R.style.DarkTheme);
} else {
setTheme(R.style.LightTheme);
}
setAppTheme(m_prefs);
super.onCreate(savedInstanceState);