From ecc054fdc790ab6cd0ccf9693b192a7e1fd3252c Mon Sep 17 00:00:00 2001 From: Eugene Crosser Date: Mon, 30 Jan 2012 19:30:36 +0400 Subject: [PATCH] introduce preferences --- AndroidManifest.xml | 3 +++ res/xml/preferences.xml | 8 ++++++++ src/org/average/whereami/WhereAmI.java | 15 ++++++++++++--- src/org/average/whereami/WhereAmIprefs.java | 12 ++++++++++++ 4 files changed, 35 insertions(+), 3 deletions(-) create mode 100644 res/xml/preferences.xml create mode 100644 src/org/average/whereami/WhereAmIprefs.java diff --git a/AndroidManifest.xml b/AndroidManifest.xml index b262867..ebf9383 100644 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -17,5 +17,8 @@ + + diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml new file mode 100644 index 0000000..8ebb456 --- /dev/null +++ b/res/xml/preferences.xml @@ -0,0 +1,8 @@ + + + diff --git a/src/org/average/whereami/WhereAmI.java b/src/org/average/whereami/WhereAmI.java index f3de417..1d3c268 100644 --- a/src/org/average/whereami/WhereAmI.java +++ b/src/org/average/whereami/WhereAmI.java @@ -1,5 +1,7 @@ package org.average.whereami; +import org.average.whereami.WhereAmIprefs; + import android.app.Activity; import android.net.wifi.WifiManager; import android.os.Bundle; @@ -13,6 +15,7 @@ import android.content.Intent; import android.content.IntentFilter; import android.content.Context; import android.content.res.Resources; +import android.content.SharedPreferences; import android.text.format.Time; import android.util.Log; import android.view.View; @@ -27,6 +30,7 @@ public class WhereAmI extends Activity { private WifiManager wifiman; private Integer runningtasks = 0; + private SharedPreferences prefs; private class UpdateTarget { private TextView tv; @@ -179,12 +183,16 @@ public class WhereAmI extends Activity 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); - //getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN); - //getWindow().clearFlags(WindowManager.LayoutParams. - // FLAG_FORCE_NOT_FULLSCREEN); + 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); @@ -245,6 +253,7 @@ public class WhereAmI extends Activity return true; case R.id.settings: Log.w("WhereAmI", "settings requested"); + startActivity(new Intent(this, WhereAmIprefs.class)); return true; default: return super.onOptionsItemSelected(item); diff --git a/src/org/average/whereami/WhereAmIprefs.java b/src/org/average/whereami/WhereAmIprefs.java new file mode 100644 index 0000000..f191734 --- /dev/null +++ b/src/org/average/whereami/WhereAmIprefs.java @@ -0,0 +1,12 @@ +package org.average.whereami; + +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class WhereAmIprefs extends PreferenceActivity { + @Override + public void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.preferences); + } +} -- 2.43.0