Commit 67cd50f1c190e510e102fd26fc143881a8c72463
1 parent
499ae9f8
--no commit message
Showing
5 changed files
with
97 additions
and
0 deletions
res/layout/help.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
3 | + android:id="@+id/LinearLayout1" | ||
4 | + android:layout_width="match_parent" | ||
5 | + android:layout_height="match_parent" | ||
6 | + android:orientation="vertical" > | ||
7 | + | ||
8 | + <TextView | ||
9 | + android:id="@+id/textView1" | ||
10 | + android:layout_width="wrap_content" | ||
11 | + android:layout_height="wrap_content" | ||
12 | + android:layout_gravity="center" | ||
13 | + android:text="@string/help" | ||
14 | + android:textAppearance="?android:attr/textAppearanceLarge" /> | ||
15 | + | ||
16 | + <TextView | ||
17 | + android:id="@+id/textView2" | ||
18 | + android:layout_width="wrap_content" | ||
19 | + android:layout_height="wrap_content" | ||
20 | + android:layout_gravity="center_horizontal" | ||
21 | + android:text="Help, I need somebody, Help!, not just anybody, Help!, you know I need someone... HEEEEELP!" | ||
22 | + android:textAppearance="?android:attr/textAppearanceMedium" /> | ||
23 | + | ||
24 | +</LinearLayout> | ||
0 | \ No newline at end of file | 25 | \ No newline at end of file |
res/menu/menu.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<menu xmlns:android="http://schemas.android.com/apk/res/android" > | ||
3 | + <item android:id="@+id/itemprefs" android:title="@string/prefs"></item> | ||
4 | + <item android:id="@+id/itemhelp" android:title="@string/help"></item> | ||
5 | + | ||
6 | + | ||
7 | +</menu> | ||
0 | \ No newline at end of file | 8 | \ No newline at end of file |
res/xml/prefs.xml
0 → 100644
1 | +<?xml version="1.0" encoding="utf-8"?> | ||
2 | +<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" > | ||
3 | + <EditTextPreference android:key="s" android:title="@string/url" android:summary="@string/urlhint"/> | ||
4 | + | ||
5 | + | ||
6 | +</PreferenceScreen> | ||
0 | \ No newline at end of file | 7 | \ No newline at end of file |
src/com/upc/pbe/upcnews/Prefs.java
0 → 100644
1 | +package com.upc.pbe.upcnews; | ||
2 | + | ||
3 | +import android.os.Bundle; | ||
4 | +import android.preference.PreferenceActivity; | ||
5 | + | ||
6 | +public class Prefs extends PreferenceActivity { | ||
7 | + | ||
8 | + @Override | ||
9 | + protected void onCreate(Bundle savedInstanceState) { | ||
10 | + super.onCreate(savedInstanceState); | ||
11 | + addPreferencesFromResource(R.xml.prefs); | ||
12 | + } | ||
13 | + | ||
14 | +} | ||
0 | \ No newline at end of file | 15 | \ No newline at end of file |
src/com/upc/pbe/upcnews/UpcApp.java
0 → 100644
1 | +package com.upc.pbe.upcnews; | ||
2 | + | ||
3 | +import android.app.Application; | ||
4 | +import android.content.SharedPreferences; | ||
5 | +import android.content.SharedPreferences.OnSharedPreferenceChangeListener; | ||
6 | +import android.preference.PreferenceManager; | ||
7 | +import android.util.Log; | ||
8 | + | ||
9 | + | ||
10 | +public class UpcApp extends Application implements OnSharedPreferenceChangeListener { | ||
11 | + | ||
12 | + final static String TAG = "Application"; | ||
13 | + SharedPreferences prefs; | ||
14 | + String defaultUrl = "10.0.2.100"; | ||
15 | + String url = null; | ||
16 | + | ||
17 | + public String getUrl() { | ||
18 | + url = "http://" + prefs.getString("s", defaultUrl); | ||
19 | + return url; | ||
20 | + } | ||
21 | + | ||
22 | + | ||
23 | + public void onCreate() { | ||
24 | + super.onCreate(); | ||
25 | + | ||
26 | + //Prefs | ||
27 | + prefs = PreferenceManager.getDefaultSharedPreferences(this); | ||
28 | + prefs.registerOnSharedPreferenceChangeListener(this); | ||
29 | + this.getUrl(); | ||
30 | + Log.d(TAG, "onCreated"); | ||
31 | + } | ||
32 | + | ||
33 | + | ||
34 | + | ||
35 | + public SharedPreferences getPrefs() { | ||
36 | + return prefs; | ||
37 | + } | ||
38 | + | ||
39 | + | ||
40 | + public void onSharedPreferenceChanged(SharedPreferences arg0, String key) { | ||
41 | + | ||
42 | + Log.d(TAG, "onSharedPreferenceChanged for key: " + key); | ||
43 | + | ||
44 | + } | ||
45 | + | ||
46 | +} |