From: Eugene Crosser Date: Tue, 7 Feb 2012 21:45:32 +0000 (+0400) Subject: handle preferences more precisely X-Git-Url: http://average.org/gitweb/?a=commitdiff_plain;h=e2ede72d7b3921a61f213115d5f6a046c4d2157a;p=WhereAmI.git handle preferences more precisely --- diff --git a/src/org/average/whereami/WhereAmI.java b/src/org/average/whereami/WhereAmI.java index 5fdbbed..94c0139 100644 --- a/src/org/average/whereami/WhereAmI.java +++ b/src/org/average/whereami/WhereAmI.java @@ -168,7 +168,7 @@ public class WhereAmI extends Activity Time tm = new Time(); tm.setToNow(); tvs.setText(R.string.failtry); - tvs.append(tm.format(" %d/%m/%Y %H:%M:%S")); + tvs.append(tm.format(" %d/%m/%Y %H:%M")); } if (managewifi) { boolean wifion = wifiman.setWifiEnabled(false); @@ -220,17 +220,6 @@ public class WhereAmI extends Activity tvt = (TextView)findViewById(R.id.time); tvd = (TextView)findViewById(R.id.date); tvs = (TextView)findViewById(R.id.timestamp); - ut = new UpdateTarget[] { - new UpdateTarget((TextView)findViewById(R.id.phonecall), - new PhoneLog(res, store)), - new UpdateTarget((TextView)findViewById(R.id.location), - new LastLocation(res, store)) - }; - Log.v(TAG, "created UI, about to start update task"); - mHandler.post(updateClock); - mHandler.post(updateCal); - mHandler.post(updateInfo); - Log.v(TAG, "created UI, update task created"); } /** Called when reactivated */ @@ -250,6 +239,17 @@ public class WhereAmI extends Activity } else { getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); } + ut = new UpdateTarget[] { + new UpdateTarget((TextView)findViewById(R.id.phonecall), + new PhoneLog(res, store)), + new UpdateTarget((TextView)findViewById(R.id.location), + new LastLocation(res, store)) + }; + Log.v(TAG, "created UI, about to start update tasks"); + mHandler.post(updateClock); + mHandler.post(updateCal); + mHandler.post(updateInfo); + Log.v(TAG, "created UI, update tasks created"); } /** Called when put to background */ @@ -257,6 +257,7 @@ public class WhereAmI extends Activity public void onPause() { super.onPause(); Log.v(TAG, "going background"); + resetInfo.run(); } /** Called when the activity is destroyed. */ diff --git a/src/org/average/whereami/WhereAmIprefs.java b/src/org/average/whereami/WhereAmIprefs.java index f191734..49a93dd 100644 --- a/src/org/average/whereami/WhereAmIprefs.java +++ b/src/org/average/whereami/WhereAmIprefs.java @@ -2,11 +2,39 @@ package org.average.whereami; import android.os.Bundle; import android.preference.PreferenceActivity; +import android.preference.Preference; +import android.preference.PreferenceManager; +import android.preference.Preference.OnPreferenceChangeListener; +import android.content.SharedPreferences; +import android.content.SharedPreferences.Editor; +import android.util.Log; public class WhereAmIprefs extends PreferenceActivity { + + final String TAG = getClass().getName(); + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); + Preference calendar_name = findPreference("calendar_name"); + calendar_name.setOnPreferenceChangeListener( + new OnPreferenceChangeListener() { + public boolean onPreferenceChange(Preference preference, + Object newValue) { + resetID(); + return true; + } + } + ); + } + + private void resetID() { + SharedPreferences prefs = + PreferenceManager.getDefaultSharedPreferences(this); + Editor editor = prefs.edit(); + editor.remove("calendar_id"); + editor.commit(); + Log.v(TAG, "Removed calendar_id from preferences"); } }