/*
    QuasselDroid - Quassel client for Android
 	Copyright (C) 2011 Ken Børge Viktil
 	Copyright (C) 2011 Magnus Fjell
 	Copyright (C) 2011 Martin Sandsmark <martin.sandsmark@kde.org>

    This program is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by the Free
    Software Foundation, either version 3 of the License, or (at your option)
    any later version, or under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either version 2.1 of
    the License, or (at your option) any later version.

 	This program is distributed in the hope that it will be useful,
 	but WITHOUT ANY WARRANTY; without even the implied warranty of
 	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 	GNU General Public License for more details.

    You should have received a copy of the GNU General Public License and the
    GNU Lesser General Public License along with this program.  If not, see
    <http://www.gnu.org/licenses/>.
 */

package com.iskrembilen.quasseldroid.gui;

import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import com.iskrembilen.quasseldroid.R;
import com.iskrembilen.quasseldroid.util.ThemeUtil;

public class PreferenceView extends PreferenceActivity {
	
	Preference backlogLimit;
	Preference backlogAdditional;
	private OnSharedPreferenceChangeListener listener;
	
	/**	 Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
    	super.onCreate(savedInstanceState);
    	addPreferencesFromResource(R.layout.preferences);
    	
    	SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
		listener =new OnSharedPreferenceChangeListener() {

			@Override
			public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
				if(key.equals(getResources().getString(R.string.preference_theme))){
					ThemeUtil.setTheme(PreferenceView.this, sharedPreferences.getString(key, ""));
				}

			}
		};
		preferences.registerOnSharedPreferenceChangeListener(listener); //To avoid GC issues
    }
}

@@ -1760,16 +1760,48 @@
 tate) %7B%0A
+    %09setTheme(ThemeUtil.theme);%0A
     %09sup
@@ -1888,21 +1888,16 @@
 ences);%0A
-    %09
 %0A    %09Sh

Use the selected theme in preferences