xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference
android:key="fullscreen"
- android:title="Use full screen display"
- android:summary="Check it on, check it off"
+ android:title="@string/fullscreentitle"
+ android:summary="@string/fullscreensummary"
+ android:defaultValue="false"
+ />
+ <ListPreference
+ android:key="updateperiod"
+ android:title="@string/updatetitle"
+ android:summary="@string/updatesummary"
+ android:defaultValue="120000"
+ android:entries="@array/updatenames"
+ android:entryValues="@array/updatevals"
/>
</PreferenceScreen>
import android.content.Context;
import android.content.res.Resources;
import android.content.SharedPreferences;
+import android.preference.PreferenceManager;
import android.text.format.Time;
import android.util.Log;
import android.view.View;
public class WhereAmI extends Activity
{
private WifiManager wifiman;
+ private Long updatedelay = 60000L;
private Integer runningtasks = 0;
private SharedPreferences prefs;
connChangedRegistered = true;
boolean wifion = wifiman.setWifiEnabled(true);
Log.w("WhereAmI", "enabling wifi result " + wifion);
- mHandler.postDelayed(resetInfo, 30000);
+ mHandler.postDelayed(resetInfo, updatedelay);
mHandler.postDelayed(this, 60000);
}
};
/** Called when the activity is first created. */
@Override
- public void onCreate(Bundle savedInstanceState)
- {
+ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
- prefs = getSharedPreferences("WhereAmI", MODE_PRIVATE);
wifiman = (WifiManager)getSystemService(Context.WIFI_SERVICE);
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
- boolean fullscreen = prefs.getBoolean("fullscreen", false);
- if (fullscreen) {
- getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
- getWindow().clearFlags(WindowManager.LayoutParams.
- FLAG_FORCE_NOT_FULLSCREEN);
- }
setContentView(R.layout.main);
res = getResources();
month = res.getStringArray(R.array.month);
Log.w("WhereAmI", "created UI, update task created");
}
+ /** Called when reactivated */
+ @Override
+ public void onResume() {
+ super.onResume();
+ prefs = PreferenceManager.getDefaultSharedPreferences(this);
+ boolean fullscreen = prefs.getBoolean("fullscreen", false);
+ updatedelay = Long.parseLong(prefs.getString("updateperiod", "1200000"));
+ if (fullscreen) {
+ getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ getWindow().clearFlags(WindowManager.LayoutParams.
+ FLAG_FORCE_NOT_FULLSCREEN);
+ } else {
+ getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
+ }
+ }
+
/** Called when put to background */
@Override
- public void onPause()
- {
+ public void onPause() {
super.onPause();
Log.w("WhereAmI", "going background");
}
/** Called when the activity is destroyed. */
@Override
- public void onDestroy()
- {
+ public void onDestroy() {
super.onDestroy();
Log.w("WhereAmI", "going down");
mHandler.removeCallbacks(updateClock);