From 67cd50f1c190e510e102fd26fc143881a8c72463 Mon Sep 17 00:00:00 2001 From: Equip de Desenvolupadors de PBE Date: Wed, 21 Nov 2012 19:54:22 +0000 Subject: [PATCH] --- res/layout/help.xml | 24 ++++++++++++++++++++++++ res/menu/menu.xml | 7 +++++++ res/xml/prefs.xml | 6 ++++++ src/com/upc/pbe/upcnews/Prefs.java | 14 ++++++++++++++ src/com/upc/pbe/upcnews/UpcApp.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 97 insertions(+), 0 deletions(-) create mode 100644 res/layout/help.xml create mode 100644 res/menu/menu.xml create mode 100644 res/xml/prefs.xml create mode 100644 src/com/upc/pbe/upcnews/Prefs.java create mode 100644 src/com/upc/pbe/upcnews/UpcApp.java diff --git a/res/layout/help.xml b/res/layout/help.xml new file mode 100644 index 0000000..d3b3d8f --- /dev/null +++ b/res/layout/help.xml @@ -0,0 +1,24 @@ + + + + + + + + \ No newline at end of file diff --git a/res/menu/menu.xml b/res/menu/menu.xml new file mode 100644 index 0000000..7b42946 --- /dev/null +++ b/res/menu/menu.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/res/xml/prefs.xml b/res/xml/prefs.xml new file mode 100644 index 0000000..29c1127 --- /dev/null +++ b/res/xml/prefs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/src/com/upc/pbe/upcnews/Prefs.java b/src/com/upc/pbe/upcnews/Prefs.java new file mode 100644 index 0000000..264d0ed --- /dev/null +++ b/src/com/upc/pbe/upcnews/Prefs.java @@ -0,0 +1,14 @@ +package com.upc.pbe.upcnews; + +import android.os.Bundle; +import android.preference.PreferenceActivity; + +public class Prefs extends PreferenceActivity { + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + addPreferencesFromResource(R.xml.prefs); + } + +} \ No newline at end of file diff --git a/src/com/upc/pbe/upcnews/UpcApp.java b/src/com/upc/pbe/upcnews/UpcApp.java new file mode 100644 index 0000000..3569fb9 --- /dev/null +++ b/src/com/upc/pbe/upcnews/UpcApp.java @@ -0,0 +1,46 @@ +package com.upc.pbe.upcnews; + +import android.app.Application; +import android.content.SharedPreferences; +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; +import android.preference.PreferenceManager; +import android.util.Log; + + +public class UpcApp extends Application implements OnSharedPreferenceChangeListener { + + final static String TAG = "Application"; + SharedPreferences prefs; + String defaultUrl = "10.0.2.100"; + String url = null; + + public String getUrl() { + url = "http://" + prefs.getString("s", defaultUrl); + return url; + } + + + public void onCreate() { + super.onCreate(); + + //Prefs + prefs = PreferenceManager.getDefaultSharedPreferences(this); + prefs.registerOnSharedPreferenceChangeListener(this); + this.getUrl(); + Log.d(TAG, "onCreated"); + } + + + + public SharedPreferences getPrefs() { + return prefs; + } + + + public void onSharedPreferenceChanged(SharedPreferences arg0, String key) { + + Log.d(TAG, "onSharedPreferenceChanged for key: " + key); + + } + +} -- libgit2 0.22.2