]> average.org Git - WhereAmI.git/commitdiff
introduce preferences
authorEugene Crosser <Eugene.Crosser@ru.ibm.com>
Mon, 30 Jan 2012 15:30:36 +0000 (19:30 +0400)
committerEugene Crosser <Eugene.Crosser@ru.ibm.com>
Mon, 30 Jan 2012 15:30:36 +0000 (19:30 +0400)
AndroidManifest.xml
res/xml/preferences.xml [new file with mode: 0644]
src/org/average/whereami/WhereAmI.java
src/org/average/whereami/WhereAmIprefs.java [new file with mode: 0644]

index b262867a3b0dec824aad4c799fdc033fa100aea3..ebf93832f07d5bcbfaaa921bdbc298d287d74400 100644 (file)
@@ -17,5 +17,8 @@
                 <category android:name="android.intent.category.LAUNCHER" />
             </intent-filter>
         </activity>
+        <activity android:name="WhereAmIprefs"
+                  android:label="@string/app_name">
+        </activity>
     </application>
 </manifest> 
diff --git a/res/xml/preferences.xml b/res/xml/preferences.xml
new file mode 100644 (file)
index 0000000..8ebb456
--- /dev/null
@@ -0,0 +1,8 @@
+<PreferenceScreen
+  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"
+    />
+</PreferenceScreen>
index f3de41799e734b28e410bb6fa99bf8f39b91cd8b..1d3c2686e26da6b773d8da8b0042efab0bbc6bd8 100644 (file)
@@ -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 (file)
index 0000000..f191734
--- /dev/null
@@ -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);
+    }
+}