diff options
author | Andrew Dolgov <[email protected]> | 2013-04-29 21:30:57 +0400 |
---|---|---|
committer | Andrew Dolgov <[email protected]> | 2013-04-29 21:30:57 +0400 |
commit | d9ef4625b86a7ee556df668145c7750919cb7468 (patch) | |
tree | 2e5e53c5bfcabe1c119029e14a344034d1301de7 /src | |
parent | afdc28c04119864b395abcf6069e4cc54d347b4d (diff) |
restart if theme changed
Diffstat (limited to 'src')
-rw-r--r-- | src/org/fox/ttrss/CommonActivity.java | 28 |
1 files changed, 27 insertions, 1 deletions
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; @@ -85,6 +86,18 @@ public class CommonActivity extends SherlockFragmentActivity { } @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; } |