From 92935a725584211fcd14a99ee4b64b1da25ea61b Mon Sep 17 00:00:00 2001 From: John Reck Date: Tue, 24 May 2011 15:32:59 -0700 Subject: Help dialog for useragent switcher lab Change-Id: I1126f2dae652a36a133aa85a3a8aa823ab875b7b --- .../preferences/LabPreferencesFragment.java | 31 ++++++++++++++++++---- 1 file changed, 26 insertions(+), 5 deletions(-) (limited to 'src/com/android/browser/preferences') diff --git a/src/com/android/browser/preferences/LabPreferencesFragment.java b/src/com/android/browser/preferences/LabPreferencesFragment.java index f99b96d..d9ef3df 100644 --- a/src/com/android/browser/preferences/LabPreferencesFragment.java +++ b/src/com/android/browser/preferences/LabPreferencesFragment.java @@ -22,11 +22,14 @@ import com.android.browser.PreferenceKeys; import com.android.browser.R; import com.android.browser.search.SearchEngine; +import android.app.AlertDialog; import android.content.Intent; import android.os.Bundle; import android.preference.Preference; import android.preference.Preference.OnPreferenceChangeListener; import android.preference.PreferenceFragment; +import android.view.LayoutInflater; +import android.view.View; public class LabPreferencesFragment extends PreferenceFragment implements OnPreferenceChangeListener { @@ -41,12 +44,16 @@ public class LabPreferencesFragment extends PreferenceFragment // Load the XML preferences file addPreferencesFromResource(R.xml.lab_preferences); + registerChangeListener(PreferenceKeys.PREF_ENABLE_QUICK_CONTROLS); + registerChangeListener(PreferenceKeys.PREF_ENABLE_USERAGENT_SWITCHER); + useInstantPref = findPreference(PreferenceKeys.PREF_USE_INSTANT_SEARCH); + } - Preference e = findPreference(PreferenceKeys.PREF_ENABLE_QUICK_CONTROLS); + private void registerChangeListener(String key) { + Preference e = findPreference(key); if (e != null) { e.setOnPreferenceChangeListener(this); } - useInstantPref = findPreference(PreferenceKeys.PREF_USE_INSTANT_SEARCH); } @Override @@ -68,9 +75,23 @@ public class LabPreferencesFragment extends PreferenceFragment @Override public boolean onPreferenceChange(Preference preference, Object newValue) { - // Attempt to restart - startActivity(new Intent(BrowserActivity.ACTION_RESTART, null, - getActivity(), BrowserActivity.class)); + String key = preference.getKey(); + if (PreferenceKeys.PREF_ENABLE_QUICK_CONTROLS.equals(key)) { + // Attempt to restart + startActivity(new Intent(BrowserActivity.ACTION_RESTART, null, + getActivity(), BrowserActivity.class)); + } + if (PreferenceKeys.PREF_ENABLE_USERAGENT_SWITCHER.equals(key)) { + if ((Boolean)newValue) { + // Show the help + LayoutInflater inflater = LayoutInflater.from(getActivity()); + View content = inflater.inflate(R.layout.help_dialog_useragent_switcher, null); + new AlertDialog.Builder(getActivity()) + .setView(content) + .setNeutralButton(android.R.string.ok, null) + .show(); + } + } return true; } } -- cgit v1.1