]> cvs.zerfleddert.de Git - FreeShisen/blame - src/de/cwde/shisensho/SettingsActivity.java
try to use the andriod way of Preferences and ruin everything[tm]
[FreeShisen] / src / de / cwde / shisensho / SettingsActivity.java
CommitLineData
42aa846a 1package de.cwde.shisensho;
2
3import android.content.SharedPreferences;
4import android.content.SharedPreferences.OnSharedPreferenceChangeListener;
5import android.os.Bundle;
6import android.preference.*;
7
8public class SettingsActivity extends PreferenceActivity
9 implements OnSharedPreferenceChangeListener {
10
11 private ShisenSho app;
12
13 private static final String KEY_PREF_DIFF = "pref_diff";
14 private static final String KEY_PREF_SIZE = "pref_size";
15 //private static final String KEY_PREF_GRAV = "pref_grav";
16 //private static final String KEY_PREF_TIME = "pref_time";
17
18 @SuppressWarnings("deprecation")
19 @Override
20 public void onCreate(Bundle savedInstanceState) {
21 super.onCreate(savedInstanceState);
22 app = ShisenSho.app();
23 addPreferencesFromResource(R.xml.preferences);
24 }
25
26 @Override
27 public void onBackPressed() {
28 app.setOptions();
29 super.onBackPressed();
30 }
31
32 @SuppressWarnings("deprecation")
33 @Override
34 protected void onResume() {
35 super.onResume();
36 getPreferenceScreen().getSharedPreferences()
37 .registerOnSharedPreferenceChangeListener(this);
38 }
39
40 @SuppressWarnings("deprecation")
41 @Override
42 protected void onPause() {
43 super.onPause();
44 getPreferenceScreen().getSharedPreferences()
45 .unregisterOnSharedPreferenceChangeListener(this);
46 }
47
48
49 public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
50 if (key.equals(KEY_PREF_DIFF)) {
51 @SuppressWarnings("deprecation")
52 Preference myPref = findPreference(key);
53 // Set summary to be the user-description for the selected value
54 myPref.setSummary(sharedPreferences.getString(key, ""));
55 }
56 if (key.equals(KEY_PREF_SIZE)) {
57 @SuppressWarnings("deprecation")
58 Preference myPref = findPreference(key);
59 // Set summary to be the user-description for the selected value
60 myPref.setSummary(sharedPreferences.getString(key, ""));
61 }
62 }
63}
Impressum, Datenschutz