]>
Commit | Line | Data |
---|---|---|
42aa846a | 1 | package de.cwde.shisensho; |
2 | ||
3 | import android.content.SharedPreferences; | |
4 | import android.content.SharedPreferences.OnSharedPreferenceChangeListener; | |
5 | import android.os.Bundle; | |
6 | import android.preference.*; | |
7 | ||
8 | public 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 | } |