From d9ef4625b86a7ee556df668145c7750919cb7468 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Mon, 29 Apr 2013 21:30:57 +0400 Subject: [PATCH] restart if theme changed --- src/org/fox/ttrss/CommonActivity.java | 28 ++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/org/fox/ttrss/CommonActivity.java b/src/org/fox/ttrss/CommonActivity.java index 58e1f882..6edba235 100644 --- a/src/org/fox/ttrss/CommonActivity.java +++ b/src/org/fox/ttrss/CommonActivity.java @@ -29,6 +29,7 @@ public class CommonActivity extends SherlockFragmentActivity { private boolean m_smallScreenMode = true; private boolean m_compatMode = false; + private String m_theme; protected SharedPreferences m_prefs; @@ -84,6 +85,18 @@ public class CommonActivity extends SherlockFragmentActivity { return m_writableDb; } + @Override + public void onResume() { + super.onResume(); + + if (!m_theme.equals(m_prefs.getString("theme", "THEME_DARK"))) { + Log.d(TAG, "theme changed, restarting"); + + finish(); + startActivity(getIntent()); + } + } + @Override public void onDestroy() { super.onDestroy(); @@ -96,7 +109,13 @@ public class CommonActivity extends SherlockFragmentActivity { public void onCreate(Bundle savedInstanceState) { m_prefs = PreferenceManager .getDefaultSharedPreferences(getApplicationContext()); - + + if (savedInstanceState != null) { + m_theme = savedInstanceState.getString("theme"); + } else { + m_theme = m_prefs.getString("theme", "THEME_DARK"); + } + initDatabase(); m_compatMode = android.os.Build.VERSION.SDK_INT <= 10; @@ -106,6 +125,13 @@ public class CommonActivity extends SherlockFragmentActivity { super.onCreate(savedInstanceState); } + @Override + public void onSaveInstanceState(Bundle out) { + super.onSaveInstanceState(out); + + out.putString("theme", m_theme); + } + public boolean isSmallScreen() { return m_smallScreenMode; }