summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohn Reck <jreck@google.com>2011-05-24 15:53:07 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-05-24 15:53:07 -0700
commit45377778b556064718b61c9495ae5bdc900fd996 (patch)
tree4743c5e054de7c2a1a3d0e60cfbe876fa8ad0865
parentb0a86db3bfa39863977efd3bac5c9bf527d224aa (diff)
parent92935a725584211fcd14a99ee4b64b1da25ea61b (diff)
downloadpackages_apps_Browser-45377778b556064718b61c9495ae5bdc900fd996.tar.gz
packages_apps_Browser-45377778b556064718b61c9495ae5bdc900fd996.tar.bz2
packages_apps_Browser-45377778b556064718b61c9495ae5bdc900fd996.zip
Merge "Help dialog for useragent switcher lab"
-rw-r--r--res/drawable-mdpi/help_useragent_laptop.pngbin0 -> 3964 bytes
-rw-r--r--res/drawable-mdpi/help_useragent_tablet.pngbin0 -> 4171 bytes
-rw-r--r--res/layout/help_dialog_useragent_switcher.xml37
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/com/android/browser/preferences/LabPreferencesFragment.java31
5 files changed, 66 insertions, 6 deletions
diff --git a/res/drawable-mdpi/help_useragent_laptop.png b/res/drawable-mdpi/help_useragent_laptop.png
new file mode 100644
index 000000000..59aa7211d
--- /dev/null
+++ b/res/drawable-mdpi/help_useragent_laptop.png
Binary files differ
diff --git a/res/drawable-mdpi/help_useragent_tablet.png b/res/drawable-mdpi/help_useragent_tablet.png
new file mode 100644
index 000000000..7b579cdf2
--- /dev/null
+++ b/res/drawable-mdpi/help_useragent_tablet.png
Binary files differ
diff --git a/res/layout/help_dialog_useragent_switcher.xml b/res/layout/help_dialog_useragent_switcher.xml
new file mode 100644
index 000000000..cc29a2da2
--- /dev/null
+++ b/res/layout/help_dialog_useragent_switcher.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2011 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:orientation="vertical">
+
+ <TextView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/help_useragent_switcher" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/help_useragent_tablet" />
+
+ <ImageView
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:src="@drawable/help_useragent_laptop" />
+
+</LinearLayout>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index ad8f64d98..ae28023d7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -665,7 +665,9 @@
<!-- Title for the useragent switcher lab feature [CHAR LIMIT=40] -->
<string name="pref_enable_useragent_switcher">Useragent Switcher</string>
<!-- Summary for the useragent switcher lab feature [CHAR LIMIT=120] -->
- <string name="pref_enable_useragent_switcher_summary">Toggle between tablet and desktop versions of a site (per tab)</string>
+ <string name="pref_enable_useragent_switcher_summary">Toggle between the tablet and desktop versions of a site</string>
+ <!-- Text explaining how to use the useragent switcher lab feature [CHAR LIMIT=none] -->
+ <string name="help_useragent_switcher">Tap on the Android or laptop icon to toggle between the tablet and desktop versions of a site.</string>
<!-- Title for a dialog displayed when the browser has a data connectivity
problem -->
diff --git a/src/com/android/browser/preferences/LabPreferencesFragment.java b/src/com/android/browser/preferences/LabPreferencesFragment.java
index f99b96dc7..d9ef3dfa8 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;
}
}