package net.indivia.hacklabbo.statusreader;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceManager;
import android.util.Log;
import android.widget.Toast;

public class PrefScreen extends PreferenceActivity {
	private static final String LOG_TAG = "PreferenceScreenActivity";
	private static String 
		SPREF_KEY_SERV,
		SPREF_KEY_REFRESH,
		SPREF_KEY_UPDATE;
	private static Context ctx;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        extracted();
        ctx = getApplicationContext();
        
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getBaseContext());
        prefs.registerOnSharedPreferenceChangeListener(mListener);
        
		/*SPREF_KEY_SERV = getString(R.string.key_refresh_service);
		SPREF_KEY_REFRESH = getString(R.string.key_refresh_time);
		SPREF_KEY_UPDATE = getString(R.string.key_update_service);*/
    }

	private void extracted() {
		addPreferencesFromResource(R.xml.prefs);
	}
    
    public OnSharedPreferenceChangeListener mListener = new OnSharedPreferenceChangeListener() {        
        @Override
        public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
        	boolean preference;
        	Log.d(LOG_TAG, "onSharedPrefCh(): "+key);
        	/*if (key.equalsIgnoreCase(SPREF_KEY_SERV)){
        		preference = sharedPreferences.getBoolean(SPREF_KEY_SERV, false);
        		if(preference){
        			startService(ATab.feedBurnI);
        		} else {
        			stopService(ATab.feedBurnI);
        		}
        	} else if (key.equalsIgnoreCase(SPREF_KEY_REFRESH)) {
        		stopService(ATab.feedBurnI);
        		startService(ATab.feedBurnI);
        	}*/
        	
        	/*preference = sharedPreferences.getBoolean(SPREF_KEY_UPDATE, true);
        	if (preference){
                Intent iUpdate = new Intent(ctx,CheckUpdate.class);
        		startService(iUpdate);
        	}*/
        }
    };
}
