commit 5477820adcf51875a413bf8fa01fbf1fc7c4f789
parent 9310a6214b85b1bd954ecd71443504982ae3af27
Author: Jan Dankert <devnull@localhost>
Date: Tue, 7 Feb 2012 00:17:09 +0100
Theme in Application speichern.
Diffstat:
4 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/res/values/strings.xml b/res/values/strings.xml
@@ -81,6 +81,7 @@
<string name="scroll_down_desc">Beim Laden von Themen automatisch zum letzten
Beitrag springen</string>
<string name="use_ibc_theme">IBC-Theme benutzen</string>
+ <string name="theme_changed">Theme wurde aktualisiert</string>
<string name="auto_login">Automatisch anmelden</string>
<string name="auto_login_desc">Beim Starten des Forums automatisch anmelden.
</string>
diff --git a/src/de/mtbnews/android/Configuration.java b/src/de/mtbnews/android/Configuration.java
@@ -1,13 +1,14 @@
package de.mtbnews.android;
-import de.mtbnews.android.service.SubscriptionService;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
+import android.text.AndroidCharacter;
import android.widget.Toast;
+import de.mtbnews.android.service.SubscriptionService;
public class Configuration extends PreferenceActivity
{
@@ -62,6 +63,19 @@ public class Configuration extends PreferenceActivity
Toast.LENGTH_SHORT).show();
}
}
+
+ // Theme geƤndert
+ if (key.equals("ibc_theme"))
+ {
+ final IBCApplication application = (IBCApplication) getApplication();
+ if (prefs.getBoolean("ibc_theme", false))
+ application.setTheme(R.style.IBC);
+ else
+ application.setTheme(android.R.style.Theme);
+
+ Toast.makeText(Configuration.this, R.string.theme_changed,
+ Toast.LENGTH_SHORT).show();
+ }
}
};
diff --git a/src/de/mtbnews/android/IBCActivity.java b/src/de/mtbnews/android/IBCActivity.java
@@ -52,6 +52,8 @@ public class IBCActivity extends ListActivity
@Override
public void onCreate(Bundle savedInstanceState)
{
+ setTheme(((IBCApplication) getApplication()).themeResId);
+
super.onCreate(savedInstanceState);
setContentView(R.layout.start);
@@ -171,7 +173,8 @@ public class IBCActivity extends ListActivity
startActivity(new Intent(IBCActivity.this, PhotoActivity.class));
return true;
case R.id.menu_mailbox:
- startActivity(new Intent(IBCActivity.this, MailboxActivity.class));
+ startActivity(new Intent(IBCActivity.this,
+ MailboxActivity.class));
return true;
case R.id.www_bikemarkt:
diff --git a/src/de/mtbnews/android/IBCApplication.java b/src/de/mtbnews/android/IBCApplication.java
@@ -31,6 +31,8 @@ public class IBCApplication extends Application
public SharedPreferences prefs;
+ public int themeResId;
+
public TapatalkClient getTapatalkClient()
{
return client;
@@ -44,11 +46,12 @@ public class IBCApplication extends Application
@Override
public void onCreate()
{
- client = new TapatalkClient(IBC.IBC_FORUM_CONNECTOR_URL);
prefs = PreferenceManager.getDefaultSharedPreferences(this);
- if (prefs.getBoolean("ibc_theme", true))
- setTheme(R.style.IBC);
+ themeResId = (prefs.getBoolean("ibc_theme", true)) ? R.style.IBC
+ : android.R.style.Theme;
+
+ client = new TapatalkClient(IBC.IBC_FORUM_CONNECTOR_URL);
if (prefs.getBoolean("autostart_subscription_service", false))
{