summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPankaj Garg <pgarg@codeaurora.org>2014-12-05 16:18:51 -0800
committerWebTech Code Review <code-review@localhost>2014-12-10 15:31:41 -0800
commit18902566fd9cf90e0f90c30cdd781813c792475c (patch)
tree24b49fdb68c1fa1175a310e783f95f7529b7f3cf
parentcdbedf12be2947e533a0e9a81f29fc407519e16d (diff)
downloadandroid_packages_apps_Gello-18902566fd9cf90e0f90c30cdd781813c792475c.tar.gz
android_packages_apps_Gello-18902566fd9cf90e0f90c30cdd781813c792475c.tar.bz2
android_packages_apps_Gello-18902566fd9cf90e0f90c30cdd781813c792475c.zip
Updated SWE Browser "About" menu item
- Changed "About" menu to preference screen layout, instead of popup - Added Version, Build date, Build Hash, User Agent, Help and Feedback Change-Id: I2c5b8f74f9ffc945adb305042c1ebcd61283e047
-rw-r--r--res/values-zh-rCN/strings.xml6
-rw-r--r--res/values-zh-rHK/strings.xml5
-rw-r--r--res/values-zh-rTW/strings.xml5
-rw-r--r--res/values/strings.xml5
-rw-r--r--res/xml/about_preferences.xml30
-rw-r--r--src/com/android/browser/BrowserPreferencesPage.java44
-rw-r--r--src/com/android/browser/Controller.java27
-rw-r--r--src/com/android/browser/PreferenceKeys.java11
-rw-r--r--src/com/android/browser/preferences/AboutPreferencesFragment.java148
9 files changed, 253 insertions, 28 deletions
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index a7779210..ef53343d 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -491,4 +491,10 @@
<string name="activity_not_found">没有找到处理 Intent <xliff:g id="NOACTIVITY">%s</xliff:g> 的Activity.</string>
<!-- Toast message displayed when the full screen received message -->
<string name="received_message_full_screen">收到来自: <xliff:g id="FROM">%s</xliff:g> 的一条消息.</string>
+
+ <string name="build_date">"版本日期"</string>
+ <string name="build_hash">"版本哈希值"</string>
+ <string name="user_agent">"浏览器UA标识"</string>
+ <string name="help">"帮助"</string>
+ <string name="feedback">"反馈"</string>
</resources>
diff --git a/res/values-zh-rHK/strings.xml b/res/values-zh-rHK/strings.xml
index 17d71cc3..224c9e70 100644
--- a/res/values-zh-rHK/strings.xml
+++ b/res/values-zh-rHK/strings.xml
@@ -410,4 +410,9 @@
<string name="accessibility_state_frozen" msgid="8041539250447035570">"儲存網頁"</string>
<string name="accessibility_transition_navscreen" msgid="2734915619351519547">"標籤管理"</string>
<string name="accessibility_button_bookmarks_folder_up" msgid="9179389954714270505">"上一個資料夾"</string>
+ <string name="build_date">"版本日期"</string>
+ <string name="build_hash">"版本哈希值"</string>
+ <string name="user_agent">"瀏覽器UA標識"</string>
+ <string name="help">"幫助"</string>
+ <string name="feedback">"反饋"</string>
</resources>
diff --git a/res/values-zh-rTW/strings.xml b/res/values-zh-rTW/strings.xml
index 5250ce3d..1762a96a 100644
--- a/res/values-zh-rTW/strings.xml
+++ b/res/values-zh-rTW/strings.xml
@@ -399,4 +399,9 @@
<string name="accessibility_state_frozen" msgid="8041539250447035570">"儲存的頁面"</string>
<string name="accessibility_transition_navscreen" msgid="2734915619351519547">"分頁管理"</string>
<string name="accessibility_button_bookmarks_folder_up" msgid="9179389954714270505">"上一個資料夾"</string>
+ <string name="build_date">"版本日期"</string>
+ <string name="build_hash">"版本哈希值"</string>
+ <string name="user_agent">"瀏覽器UA標識"</string>
+ <string name="help">"幫助"</string>
+ <string name="feedback">"反饋"</string>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9bd2aae0..0a4814e9 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1107,4 +1107,9 @@
<string name="ssl_certificate">Security certificate</string>
<string name="ssl_certificate_is_valid">This certificate is valid.</string>
<string name="version">Version</string>
+ <string name="build_date">Build Date</string>
+ <string name="build_hash">Build Hash</string>
+ <string name="user_agent">User Agent</string>
+ <string name="help">Help</string>
+ <string name="feedback">Feedback</string>
</resources>
diff --git a/res/xml/about_preferences.xml b/res/xml/about_preferences.xml
index 399d0c0f..14bab64a 100644
--- a/res/xml/about_preferences.xml
+++ b/res/xml/about_preferences.xml
@@ -30,8 +30,30 @@
*/
-->
-<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
- <PreferenceCategory>
- <Preference android:key="about_preference"/>
- </PreferenceCategory>
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ android:key="about"
+ android:title="@string/about" >
+ <Preference
+ android:key="version"
+ android:title="@string/version" />
+
+ <Preference
+ android:key="built"
+ android:title="@string/build_date" />
+
+ <Preference
+ android:key="hash"
+ android:title="@string/build_hash" />
+
+ <Preference
+ android:key="user_agent"
+ android:title="@string/user_agent" />
+
+ <Preference
+ android:key="help_about"
+ android:title="@string/help" />
+
+ <Preference
+ android:key="feedback"
+ android:title="@string/feedback" />
</PreferenceScreen>
diff --git a/src/com/android/browser/BrowserPreferencesPage.java b/src/com/android/browser/BrowserPreferencesPage.java
index 8f31ef97..a40c7c76 100644
--- a/src/com/android/browser/BrowserPreferencesPage.java
+++ b/src/com/android/browser/BrowserPreferencesPage.java
@@ -17,12 +17,17 @@
package com.android.browser;
import android.app.Activity;
+import android.app.Fragment;
import android.content.Intent;
import android.os.Bundle;
import android.preference.PreferenceActivity;
+import com.android.browser.preferences.AboutPreferencesFragment;
import com.android.browser.preferences.GeneralPreferencesFragment;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.InvocationTargetException;
+
public class BrowserPreferencesPage extends Activity {
public static void startPreferencesForResult(Activity callerActivity, String url, int requestCode) {
@@ -37,6 +42,16 @@ public class BrowserPreferencesPage extends Activity {
callerActivity.startActivityForResult(intent, requestCode);
}
+ public static void startPreferenceFragmentExtraForResult(Activity callerActivity,
+ String fragmentName,
+ Bundle bundle,
+ int requestCode) {
+ final Intent intent = new Intent(callerActivity, BrowserPreferencesPage.class);
+ intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT, fragmentName);
+ intent.putExtra(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, bundle);
+ callerActivity.startActivityForResult(intent, requestCode);
+ }
+
@Override
public void onCreate(Bundle icicle) {
@@ -49,6 +64,35 @@ public class BrowserPreferencesPage extends Activity {
if ("android.intent.action.MANAGE_NETWORK_USAGE".equals(action)) {
// TODO: switch to the Network fragment here?
}
+
+ Bundle extras = intent.getExtras();
+ String fragment = (String) extras.getCharSequence(PreferenceActivity.EXTRA_SHOW_FRAGMENT);
+ if (fragment != null) {
+ try {
+ Class<?> cls = Class.forName(fragment);
+ Constructor<?> ctor = cls.getConstructor();
+ Object obj = ctor.newInstance();
+
+ if (obj instanceof Fragment) {
+ Fragment frag = (Fragment) obj;
+
+ Bundle bundle = extras.getBundle(PreferenceActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS);
+ if (bundle != null) {
+ frag.setArguments(bundle);
+ }
+
+ getFragmentManager().beginTransaction().replace(
+ android.R.id.content,
+ (Fragment) obj).commit();
+ }
+ } catch (ClassNotFoundException e) {
+ } catch (NoSuchMethodException e) {
+ } catch (InvocationTargetException e) {
+ } catch (InstantiationException e) {
+ } catch (IllegalAccessException e) {
+ }
+ return;
+ }
}
getFragmentManager().beginTransaction().replace(android.R.id.content,
diff --git a/src/com/android/browser/Controller.java b/src/com/android/browser/Controller.java
index 181b1480..733e1221 100644
--- a/src/com/android/browser/Controller.java
+++ b/src/com/android/browser/Controller.java
@@ -40,8 +40,6 @@ import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteException;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
-import android.graphics.Canvas;
-import android.graphics.Paint;
import android.graphics.Rect;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
@@ -56,7 +54,6 @@ import android.os.Handler;
import android.os.Message;
import android.os.PowerManager;
import android.os.PowerManager.WakeLock;
-import android.preference.PreferenceActivity;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Intents.Insert;
import android.provider.Settings;
@@ -79,12 +76,12 @@ import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import android.webkit.ValueCallback;
import android.webkit.WebChromeClient.CustomViewCallback;
-import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import org.codeaurora.swe.CookieManager;
import org.codeaurora.swe.CookieSyncManager;
+import org.codeaurora.swe.Engine;
import org.codeaurora.swe.HttpAuthHandler;
import org.codeaurora.swe.SslErrorHandler;
import org.codeaurora.swe.WebSettings;
@@ -102,6 +99,7 @@ import com.android.browser.platformsupport.Browser;
import com.android.browser.platformsupport.BrowserContract;
import com.android.browser.platformsupport.WebAddress;
import com.android.browser.platformsupport.BrowserContract.Images;
+import com.android.browser.preferences.AboutPreferencesFragment;
import com.android.browser.provider.BrowserProvider2.Thumbnails;
import com.android.browser.provider.SnapshotProvider.Snapshots;
import com.android.browser.reflect.ReflectHelper;
@@ -116,7 +114,6 @@ import java.net.URLEncoder;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
@@ -2110,20 +2107,12 @@ public class Controller
break;
case R.id.about_menu_id:
- final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
- builder.setTitle(R.string.about);
- builder.setCancelable(true);
- String ua = "";
- final WebView currentWebView = getCurrentWebView();
- if (currentWebView != null) {
- final WebSettings s = currentWebView.getSettings();
- if (s != null) {
- ua = s.getUserAgentString();
- }
- }
- builder.setMessage("Agent:" + ua);
- builder.setPositiveButton(android.R.string.ok, null);
- builder.create().show();
+ Bundle bundle = new Bundle();
+ bundle.putCharSequence("UA", Engine.getDefaultUserAgent());
+ bundle.putCharSequence("TabTitle", mTabControl.getCurrentTab().getTitle());
+ bundle.putCharSequence("TabURL", mTabControl.getCurrentTab().getUrl());
+ BrowserPreferencesPage.startPreferenceFragmentExtraForResult(mActivity,
+ AboutPreferencesFragment.class.getName(), bundle, 0);
break;
case R.id.add_to_homescreen:
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index f3e752f4..ea6b1d63 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -121,4 +121,15 @@ public interface PreferenceKeys {
* Key for whether or not the last run was paused.
*/
static final String KEY_LAST_RUN_PAUSED = "last_paused";
+
+ // ----------------------
+ // Keys for about_preferences.xml
+ // ----------------------
+ static final String PREF_ABOUT = "about";
+ static final String PREF_VERSION = "version";
+ static final String PREF_BUILD_DATE = "built";
+ static final String PREF_BUILD_HASH = "hash";
+ static final String PREF_USER_AGENT = "user_agent";
+ static final String PREF_HELP = "help_about";
+ static final String PREF_FEEDBACK = "feedback";
}
diff --git a/src/com/android/browser/preferences/AboutPreferencesFragment.java b/src/com/android/browser/preferences/AboutPreferencesFragment.java
index d9793336..e3758b0c 100644
--- a/src/com/android/browser/preferences/AboutPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AboutPreferencesFragment.java
@@ -30,31 +30,169 @@
package com.android.browser.preferences;
+import android.app.ActionBar;
+import android.content.Intent;
+import android.net.Uri;
import android.os.Bundle;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceFragment;
+import android.preference.PreferenceScreen;
+import com.android.browser.BrowserActivity;
+import com.android.browser.PreferenceKeys;
import com.android.browser.R;
+import org.codeaurora.swe.BrowserCommandLine;
+
public class AboutPreferencesFragment extends PreferenceFragment
implements OnPreferenceClickListener {
- static final String PREF_ABOUT = "about_preference";
+ final String CMD_LINE_SWITCH_FEEDBACK = "mail-feedback-to";
+ final String CMD_LINE_SWITCH_HELPURL = "help-url";
+
+ final String ABOUT_TEXT_VERSION_KEY = "Version:";
+ final String ABOUT_TEXT_BUILT_KEY = "Built:";
+ final String ABOUT_TEXT_HASH_KEY = "Hash:";
+
+ String mFeedbackRecipient = "";
+ String mHelpURL = "";
+ String mVersion = "";
+ String mBuilt = "";
+ String mHash = "";
+ String mTabTitle = "";
+ String mTabURL = "";
+
+ String mAboutText = "";
+ PreferenceScreen mHeadPref = null;
+
+ private String findValueFromAboutText(String aboutKey) {
+ int start = mAboutText.indexOf(aboutKey);
+ int end = mAboutText.indexOf("\n", start);
+ String value = "";
+
+ if (start != -1 && end != -1) {
+ start += aboutKey.length();
+ value = mAboutText.substring(start, end);
+ }
+ return value;
+ }
+
+ private void setPreference(String prefKey, String value) {
+ Preference pref = findPreference(prefKey);
+ if (pref == null) {
+ return;
+ }
+
+ if (value.isEmpty()) {
+ if (mHeadPref != null)
+ mHeadPref.removePreference(pref);
+ } else {
+ pref.setSummary(value);
+ }
+ }
+
+ private void setOnClickListener(String prefKey, boolean set) {
+ Preference pref = findPreference(prefKey);
+ if (pref == null) {
+ return;
+ }
+
+ if (set) {
+ pref.setOnPreferenceClickListener(this);
+ } else {
+ if (mHeadPref != null)
+ mHeadPref.removePreference(pref);
+ }
+ }
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
+ ActionBar bar = getActivity().getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.about);
+ }
+
+ mAboutText = getString(R.string.about_text);
+
addPreferencesFromResource(R.xml.about_preferences);
- Preference aboutPreference = (Preference) findPreference(PREF_ABOUT);
- String about_text = getString(R.string.about_text);
- about_text = about_text.substring(about_text.indexOf("Hash"), about_text.length());
- aboutPreference.setSummary(about_text);
+ mHeadPref = (PreferenceScreen) findPreference(PreferenceKeys.PREF_ABOUT);
+
+ mVersion = findValueFromAboutText(ABOUT_TEXT_VERSION_KEY);
+ setPreference(PreferenceKeys.PREF_VERSION, mVersion);
+
+ mBuilt = findValueFromAboutText(ABOUT_TEXT_BUILT_KEY);
+ setPreference(PreferenceKeys.PREF_BUILD_DATE, mBuilt);
+
+ mHash = findValueFromAboutText(ABOUT_TEXT_HASH_KEY);
+ setPreference(PreferenceKeys.PREF_BUILD_HASH, mHash);
+
+ final Bundle arguments = getArguments();
+ String user_agent = "";
+ if (arguments != null) {
+ user_agent = (String) arguments.getCharSequence("UA");
+ mTabTitle = (String) arguments.getCharSequence("TabTitle");
+ mTabURL = (String) arguments.getCharSequence("TabURL");
+ }
+
+ setPreference(PreferenceKeys.PREF_USER_AGENT, user_agent);
+
+ if (BrowserCommandLine.hasSwitch(CMD_LINE_SWITCH_HELPURL)) {
+ mHelpURL = BrowserCommandLine.getSwitchValue(CMD_LINE_SWITCH_HELPURL);
+ }
+
+ setOnClickListener(PreferenceKeys.PREF_HELP, !mHelpURL.isEmpty());
+
+ if (BrowserCommandLine.hasSwitch(CMD_LINE_SWITCH_FEEDBACK)) {
+ mFeedbackRecipient = BrowserCommandLine.getSwitchValue(CMD_LINE_SWITCH_FEEDBACK);
+ }
+
+ setOnClickListener(PreferenceKeys.PREF_FEEDBACK, !mFeedbackRecipient.isEmpty());
}
@Override
public boolean onPreferenceClick(Preference preference) {
+ if (preference.getKey().equals(PreferenceKeys.PREF_HELP)) {
+ Intent intent = new Intent(getActivity(), BrowserActivity.class);
+ intent.setAction(Intent.ACTION_VIEW);
+ intent.setData(Uri.parse(mHelpURL));
+ getActivity().startActivity(intent);
+ return true;
+ } else if (preference.getKey().equals(PreferenceKeys.PREF_FEEDBACK)) {
+ Intent intent = new Intent(Intent.ACTION_SEND);
+ intent.setType("message/rfc822");
+ intent.putExtra(Intent.EXTRA_EMAIL, new String[]{mFeedbackRecipient});
+ intent.putExtra(Intent.EXTRA_SUBJECT,"Browser Feedback");
+
+ String message = "";
+ if (!mVersion.isEmpty()) {
+ message += "Version: " + mVersion + "\n";
+ }
+
+ if (!mBuilt.isEmpty()) {
+ message += "Build Date: " + mBuilt + "\n";
+ }
+
+ if (!mHash.isEmpty()) {
+ message += "Build Hash: " + mHash + "\n";
+ }
+
+ if (!mTabTitle.isEmpty()) {
+ message += "Tab Title: " + mTabTitle + "\n";
+ }
+
+ if (!mTabURL.isEmpty()) {
+ message += "Tab URL: " + mTabURL + "\n";
+ }
+
+ message += "\nEnter your feedback here...";
+
+ intent.putExtra(Intent.EXTRA_TEXT, message);
+ startActivity(Intent.createChooser(intent, "Select email application"));
+ return true;
+ }
return false;
}
}