Add Open Source licenses in about menu.
- Add command line switch for privacy policy url and eula url.
- Consolidate all browser switches inside BrowserSwitches class.
Change-Id: If0257c0e34e030a2619cb5957ad8c852c5a49633
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
index cc36a30..2a8175a 100644
--- a/AndroidManifest.xml
+++ b/AndroidManifest.xml
@@ -187,6 +187,11 @@
</intent-filter>
</activity>
+ <activity android:name=".preferences.LegalPreviewActivity"
+ android:parentActivityName=".BrowserActivity"
+ android:theme="@style/SettingsTheme">
+ </activity>
+
<activity android:name="BookmarkSearch"
android:label="@string/bookmarks_search"
android:stateNotNeeded="true"
diff --git a/res/layout/credits_tab.xml b/res/layout/credits_tab.xml
new file mode 100644
index 0000000..9570063
--- /dev/null
+++ b/res/layout/credits_tab.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/license_layout"
+ android:layout_width="fill_parent"
+ android:layout_height="fill_parent">
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/webview_wrapper.xml b/res/layout/webview_wrapper.xml
new file mode 100644
index 0000000..2f80936
--- /dev/null
+++ b/res/layout/webview_wrapper.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+-->
+
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:layout_weight="1" >
+</FrameLayout>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 54e5fe2..db717a7 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -1127,6 +1127,15 @@
<string name="user_agent">User Agent</string>
<string name="help">Help</string>
<string name="feedback">Feedback</string>
+ <string name="swe_legal">Legal information</string>
+ <string name="swe_open_source_licenses">Open source licenses</string>
+ <string name="swe_open_source_license_url">chrome://credits</string>
+ <string name="swe_pref_legal_info_summary">Copyright (c) 2015, The Linux Foundation. All rights reserved.</string>
+ <string name="swe_eula">End user licenses agreement</string>
+ <string name="swe_eula_url"></string>
+ <string name="swe_privacy_policy">Privacy policy</string>
+ <string name="swe_privacy_policy_url"></string>
+
<!-- Toast message displayed when user attempts to modify a setting disabled by the administrator -->
<string name="mdm_managed_alert">Managed by your administrator</string>
diff --git a/res/xml/about_preferences.xml b/res/xml/about_preferences.xml
index 14bab64..2b156fa 100644
--- a/res/xml/about_preferences.xml
+++ b/res/xml/about_preferences.xml
@@ -56,4 +56,10 @@
<Preference
android:key="feedback"
android:title="@string/feedback" />
+
+ <Preference
+ android:key="legal"
+ android:title="@string/swe_legal"
+ android:summary="@string/swe_pref_legal_info_summary"/>
+
</PreferenceScreen>
diff --git a/res/xml/legal_preferences.xml b/res/xml/legal_preferences.xml
new file mode 100644
index 0000000..8727e3a
--- /dev/null
+++ b/res/xml/legal_preferences.xml
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+-->
+<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
+ android:key="legal"
+ android:title="@string/swe_legal">
+ <Preference
+ android:key="legal_credits"
+ android:title="@string/swe_open_source_licenses"/>
+
+ <Preference
+ android:key="legal_eula"
+ android:title="@string/swe_eula" />
+
+ <Preference
+ android:key="legal_privacy_policy"
+ android:title="@string/swe_privacy_policy" />
+</PreferenceScreen>
\ No newline at end of file
diff --git a/src/com/android/browser/BrowserConfigBase.java b/src/com/android/browser/BrowserConfigBase.java
index 99b6456..495e735 100644
--- a/src/com/android/browser/BrowserConfigBase.java
+++ b/src/com/android/browser/BrowserConfigBase.java
@@ -42,13 +42,7 @@
abstract class BrowserConfigBase {
- private static final String OVERRIDE_USER_AGENT = "user-agent";
- private static final String OVERRIDE_MEDIA_DOWNLOAD = "media-download";
- private static final String HTTP_HEADERS = "http-headers";
- private static final String ENABLE_SWE = "enabled-swe";
- private static final String ENABLE_TOP_CONTROLS = "enable-top-controls-position-calculation";
- private static final String TOP_CONTROLS_HIDE_THRESHOLD = "top-controls-hide-threshold";
- private static final String TOP_CONTROLS_SHOW_THRESHOLD = "top-controls-show-threshold";
+
private Context mContext;
public BrowserConfigBase(Context context) {
@@ -57,7 +51,7 @@
public void overrideUserAgent() {
// Check if the UA is already present using command line file
- if (BrowserCommandLine.hasSwitch(OVERRIDE_USER_AGENT)) {
+ if (BrowserCommandLine.hasSwitch(BrowserSwitches.OVERRIDE_USER_AGENT)) {
return;
}
@@ -69,7 +63,7 @@
ua = constructUserAgent(ua);
if (!TextUtils.isEmpty(ua)){
- BrowserCommandLine.appendSwitchWithValue(OVERRIDE_USER_AGENT, ua);
+ BrowserCommandLine.appendSwitchWithValue(BrowserSwitches.OVERRIDE_USER_AGENT, ua);
}
}
@@ -77,22 +71,22 @@
boolean defaultAllowMediaDownloadsValue = mContext.getResources().getBoolean(
R.bool.def_allow_media_downloads);
if (defaultAllowMediaDownloadsValue)
- BrowserCommandLine.appendSwitchWithValue(OVERRIDE_MEDIA_DOWNLOAD, "1");
+ BrowserCommandLine.appendSwitchWithValue(BrowserSwitches.OVERRIDE_MEDIA_DOWNLOAD, "1");
}
public void setExtraHTTPRequestHeaders() {
String headers = mContext.getResources().getString(
R.string.def_extra_http_headers);
if (!TextUtils.isEmpty(headers))
- BrowserCommandLine.appendSwitchWithValue(HTTP_HEADERS, headers);
+ BrowserCommandLine.appendSwitchWithValue(BrowserSwitches.HTTP_HEADERS, headers);
}
public void initCommandLineSwitches() {
//SWE-hide-title-bar - enable following flags
- BrowserCommandLine.appendSwitch(ENABLE_TOP_CONTROLS);
- BrowserCommandLine.appendSwitchWithValue(TOP_CONTROLS_SHOW_THRESHOLD, "0.5");
- BrowserCommandLine.appendSwitchWithValue(TOP_CONTROLS_HIDE_THRESHOLD, "0.5");
- BrowserCommandLine.appendSwitch(ENABLE_SWE);
+ BrowserCommandLine.appendSwitch(BrowserSwitches.ENABLE_TOP_CONTROLS);
+ BrowserCommandLine.appendSwitchWithValue(BrowserSwitches.TOP_CONTROLS_SHOW_THRESHOLD, "0.5");
+ BrowserCommandLine.appendSwitchWithValue(BrowserSwitches.TOP_CONTROLS_HIDE_THRESHOLD, "0.5");
+ BrowserCommandLine.appendSwitch(BrowserSwitches.ENABLE_SWE);
// Allow to override UserAgent
overrideUserAgent();
diff --git a/src/com/android/browser/BrowserSwitches.java b/src/com/android/browser/BrowserSwitches.java
new file mode 100644
index 0000000..77b6f05
--- /dev/null
+++ b/src/com/android/browser/BrowserSwitches.java
@@ -0,0 +1,68 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser;
+
+// Contains all of the command line switches that are specific to the SWE Browser
+
+public class BrowserSwitches {
+ //Command line flag for strict mode
+ public final static String STRICT_MODE = "enable-strict-mode";
+
+ // Command line flag for single-process mode.
+ // Must match the value of kSingleProcess in content_switches.cc
+ public static final String SINGLE_PROCESS = "single-process";
+
+ //SWE TODO : Add description for each switch.
+
+ public static final String OVERRIDE_USER_AGENT = "user-agent";
+
+ public static final String OVERRIDE_MEDIA_DOWNLOAD = "media-download";
+
+ public static final String HTTP_HEADERS = "http-headers";
+
+ public static final String ENABLE_SWE = "enabled-swe";
+
+ public static final String ENABLE_TOP_CONTROLS = "enable-top-controls-position-calculation";
+
+ public static final String TOP_CONTROLS_HIDE_THRESHOLD = "top-controls-hide-threshold";
+
+ public static final String TOP_CONTROLS_SHOW_THRESHOLD = "top-controls-show-threshold";
+
+ public static final String CRASH_LOG_SERVER_CMD = "crash-log-server";
+
+ public static final String CMD_LINE_SWITCH_FEEDBACK = "mail-feedback-to";
+
+ public static final String CMD_LINE_SWITCH_HELPURL = "help-url";
+
+ public static final String CMD_LINE_SWITCH_EULA_URL = "legal-eula-url";
+
+ public static final String CMD_LINE_SWITCH_PRIVACY_POLICY_URL = "legal-privacy-policy-url";
+}
diff --git a/src/com/android/browser/CrashLogExceptionHandler.java b/src/com/android/browser/CrashLogExceptionHandler.java
index 09f64e8..367a409 100644
--- a/src/com/android/browser/CrashLogExceptionHandler.java
+++ b/src/com/android/browser/CrashLogExceptionHandler.java
@@ -71,7 +71,6 @@
public class CrashLogExceptionHandler implements Thread.UncaughtExceptionHandler {
private static final String CRASH_LOG_FILE = "crash.log";
- private static final String CRASH_LOG_SERVER_CMD = "crash-log-server";
private static final String CRASH_LOG_MAX_FILE_SIZE_CMD = "crash-log-max-file-size";
private static final String CRASH_REPORT_DIR = "Crash Reports";
@@ -95,9 +94,9 @@
public CrashLogExceptionHandler(Context ctx) {
mAppContext = ctx;
- if (BrowserCommandLine.hasSwitch(CRASH_LOG_SERVER_CMD)) {
+ if (BrowserCommandLine.hasSwitch(BrowserSwitches.CRASH_LOG_SERVER_CMD)) {
initNativeReporter(ctx);
- mLogServer = BrowserCommandLine.getSwitchValue(CRASH_LOG_SERVER_CMD);
+ mLogServer = BrowserCommandLine.getSwitchValue(BrowserSwitches.CRASH_LOG_SERVER_CMD);
if (mLogServer != null) {
uploadPastCrashLog();
mOverrideHandler = true;
@@ -338,7 +337,7 @@
private void uploadNativeCrashReport(final File report) {
Log.w(LOGTAG, "Preparing Crash Report for upload " + report.getName());
// get server url from commandline
- String server = BrowserCommandLine.getSwitchValue(CRASH_LOG_SERVER_CMD);
+ String server = BrowserCommandLine.getSwitchValue(BrowserSwitches.CRASH_LOG_SERVER_CMD);
try {
HttpClient httpClient = new DefaultHttpClient();
HttpPost httpPost = new HttpPost(server);
diff --git a/src/com/android/browser/EngineInitializer.java b/src/com/android/browser/EngineInitializer.java
index 27ffbe0..037e658 100644
--- a/src/com/android/browser/EngineInitializer.java
+++ b/src/com/android/browser/EngineInitializer.java
@@ -53,12 +53,6 @@
public class EngineInitializer {
private final static String LOGTAG = "EngineInitializer";
- //Command line flag for strict mode
- private final static String STRICT_MODE = "enable-strict-mode";
-
- // Command line flag for single-process mode.
- // Must match the value of kSingleProcess in content_switches.cc
- private static final String SINGLE_PROCESS = "single-process";
private static boolean mInitializationStarted = false;
private static boolean mSynchronousInitialization = false;
@@ -281,7 +275,7 @@
}
Engine.loadNativeLibraries(mApplicationContext);
- if (!BrowserCommandLine.hasSwitch(SINGLE_PROCESS)) {
+ if (!BrowserCommandLine.hasSwitch(BrowserSwitches.SINGLE_PROCESS)) {
Engine.warmUpChildProcess(mApplicationContext);
}
return true;
@@ -366,7 +360,7 @@
BrowserConfig.getInstance(ctx).initCommandLineSwitches();
//Note: Only enable this for debugging.
- if (BrowserCommandLine.hasSwitch(STRICT_MODE)) {
+ if (BrowserCommandLine.hasSwitch(BrowserSwitches.STRICT_MODE)) {
Log.v(LOGTAG, "StrictMode enabled");
StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder()
.detectDiskReads()
diff --git a/src/com/android/browser/PreferenceKeys.java b/src/com/android/browser/PreferenceKeys.java
index 99e5f1c..951a658 100644
--- a/src/com/android/browser/PreferenceKeys.java
+++ b/src/com/android/browser/PreferenceKeys.java
@@ -132,6 +132,13 @@
static final String PREF_USER_AGENT = "user_agent";
static final String PREF_HELP = "help_about";
static final String PREF_FEEDBACK = "feedback";
-
static final String PREF_EDGE_SWIPE = "edge_swiping_action";
+ static final String PREF_LEGAL = "legal";
+
+ // ----------------------
+ // Keys for legal_preferences.xml
+ // ----------------------
+ static final String PREF_LEGAL_CREDITS = "legal_credits";
+ static final String PREF_LEGAL_EULA = "legal_eula";
+ static final String PREF_LEGAL_PRIVACY_POLICY = "legal_privacy_policy";
}
diff --git a/src/com/android/browser/preferences/AboutPreferencesFragment.java b/src/com/android/browser/preferences/AboutPreferencesFragment.java
index 8f261e6..2a0edac 100644
--- a/src/com/android/browser/preferences/AboutPreferencesFragment.java
+++ b/src/com/android/browser/preferences/AboutPreferencesFragment.java
@@ -40,6 +40,8 @@
import android.preference.PreferenceScreen;
import com.android.browser.BrowserActivity;
+import com.android.browser.BrowserPreferencesPage;
+import com.android.browser.BrowserSwitches;
import com.android.browser.PreferenceKeys;
import com.android.browser.R;
@@ -48,9 +50,6 @@
public class AboutPreferencesFragment extends PreferenceFragment
implements OnPreferenceClickListener {
- 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:";
@@ -139,17 +138,21 @@
setPreference(PreferenceKeys.PREF_USER_AGENT, user_agent);
- if (BrowserCommandLine.hasSwitch(CMD_LINE_SWITCH_HELPURL)) {
- mHelpURL = BrowserCommandLine.getSwitchValue(CMD_LINE_SWITCH_HELPURL);
+ if (BrowserCommandLine.hasSwitch(BrowserSwitches.CMD_LINE_SWITCH_HELPURL)) {
+ mHelpURL = BrowserCommandLine.getSwitchValue(
+ BrowserSwitches.CMD_LINE_SWITCH_HELPURL);
}
setOnClickListener(PreferenceKeys.PREF_HELP, !mHelpURL.isEmpty());
- if (BrowserCommandLine.hasSwitch(CMD_LINE_SWITCH_FEEDBACK)) {
- mFeedbackRecipient = BrowserCommandLine.getSwitchValue(CMD_LINE_SWITCH_FEEDBACK);
+ if (BrowserCommandLine.hasSwitch(BrowserSwitches.CMD_LINE_SWITCH_FEEDBACK)) {
+ mFeedbackRecipient = BrowserCommandLine.getSwitchValue(
+ BrowserSwitches.CMD_LINE_SWITCH_FEEDBACK);
}
setOnClickListener(PreferenceKeys.PREF_FEEDBACK, !mFeedbackRecipient.isEmpty());
+
+ setOnClickListener(PreferenceKeys.PREF_LEGAL, true);
}
@Override
@@ -160,6 +163,11 @@
intent.setData(Uri.parse(mHelpURL));
getActivity().startActivity(intent);
return true;
+ } else if(preference.getKey().equals(PreferenceKeys.PREF_LEGAL)) {
+ Bundle bundle = new Bundle();
+ BrowserPreferencesPage.startPreferenceFragmentExtraForResult(getActivity(),
+ LegalPreferencesFragment.class.getName(), bundle, 0);
+ return true;
} else if (preference.getKey().equals(PreferenceKeys.PREF_FEEDBACK)) {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("message/rfc822");
diff --git a/src/com/android/browser/preferences/LegalPreferencesFragment.java b/src/com/android/browser/preferences/LegalPreferencesFragment.java
new file mode 100644
index 0000000..ce75630
--- /dev/null
+++ b/src/com/android/browser/preferences/LegalPreferencesFragment.java
@@ -0,0 +1,121 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser.preferences;
+
+import android.app.ActionBar;
+
+import android.content.Intent;
+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.BrowserSwitches;
+import com.android.browser.PreferenceKeys;
+import com.android.browser.R;
+
+import org.codeaurora.swe.BrowserCommandLine;
+
+public class LegalPreferencesFragment extends PreferenceFragment
+ implements OnPreferenceClickListener {
+
+ PreferenceScreen mHeadPref = null;
+ String mEulaUrl = "";
+ String mPrivacyPolicyUrl = "";
+
+ 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.swe_legal);
+ }
+ addPreferencesFromResource(R.xml.legal_preferences);
+ mHeadPref = (PreferenceScreen) findPreference(PreferenceKeys.PREF_LEGAL);
+
+
+ setOnClickListener(PreferenceKeys.PREF_LEGAL_CREDITS, true);
+
+ if(BrowserCommandLine.hasSwitch(BrowserSwitches.CMD_LINE_SWITCH_EULA_URL)) {
+ mEulaUrl = BrowserCommandLine.getSwitchValue(BrowserSwitches.CMD_LINE_SWITCH_EULA_URL);
+ } else {
+ mEulaUrl = getResources().getString(R.string.swe_eula_url);
+ }
+ setOnClickListener(PreferenceKeys.PREF_LEGAL_EULA, !mEulaUrl.isEmpty());
+
+
+ if(BrowserCommandLine.hasSwitch(BrowserSwitches.CMD_LINE_SWITCH_PRIVACY_POLICY_URL)) {
+ mPrivacyPolicyUrl = BrowserCommandLine.getSwitchValue(
+ BrowserSwitches.CMD_LINE_SWITCH_PRIVACY_POLICY_URL);
+ } else {
+ mPrivacyPolicyUrl = getResources().getString(R.string.swe_privacy_policy_url);
+ }
+ setOnClickListener(PreferenceKeys.PREF_LEGAL_PRIVACY_POLICY, !mPrivacyPolicyUrl.isEmpty());
+ }
+
+ @Override
+ public boolean onPreferenceClick(Preference preference) {
+ Bundle b = new Bundle();
+ if(preference.getKey().equals(PreferenceKeys.PREF_LEGAL_CREDITS)) {
+ Intent i = new Intent(getActivity(), LegalPreviewActivity.class);
+ i.putExtra(LegalPreviewActivity.URL_INTENT_EXTRA, getResources()
+ .getString(R.string.swe_open_source_license_url));
+ startActivity(i);
+ return true;
+ } else if(preference.getKey().equals(PreferenceKeys.PREF_LEGAL_EULA)) {
+ Intent i = new Intent(getActivity(), LegalPreviewActivity.class);
+ i.putExtra(LegalPreviewActivity.URL_INTENT_EXTRA, mEulaUrl);
+ startActivity(i);
+ return true;
+ } else if(preference.getKey().equals(PreferenceKeys.PREF_LEGAL_PRIVACY_POLICY)) {
+ Intent i = new Intent(getActivity(), LegalPreviewActivity.class);
+ i.putExtra(LegalPreviewActivity.URL_INTENT_EXTRA, mPrivacyPolicyUrl);
+ startActivity(i);
+ return true;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/browser/preferences/LegalPreviewActivity.java b/src/com/android/browser/preferences/LegalPreviewActivity.java
new file mode 100644
index 0000000..8987e98
--- /dev/null
+++ b/src/com/android/browser/preferences/LegalPreviewActivity.java
@@ -0,0 +1,79 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser.preferences;
+
+import android.app.ActionBar;
+import android.app.Fragment;
+import android.app.FragmentTransaction;
+import android.os.Bundle;
+import android.support.v4.app.FragmentActivity;
+import android.view.KeyEvent;
+
+import com.android.browser.R;
+
+public class LegalPreviewActivity extends FragmentActivity {
+ LegalPreviewFragment mLegalPreviewFragment;
+ protected static final String URL_INTENT_EXTRA = "url";
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.credits_tab);
+ ActionBar bar = getActionBar();
+ if (bar != null) {
+ bar.setTitle(R.string.swe_open_source_licenses);
+ }
+ FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
+ mLegalPreviewFragment = new LegalPreviewFragment();
+ Bundle args = new Bundle();
+ args.putString(URL_INTENT_EXTRA, getIntent().getExtras()
+ .getString(URL_INTENT_EXTRA));
+ mLegalPreviewFragment.setArguments(args);
+ fragmentTransaction.add(R.id.license_layout, mLegalPreviewFragment,
+ "LegalPreviewFragmentTag");
+ fragmentTransaction.addToBackStack(null);
+ fragmentTransaction.commit();
+ }
+
+ @Override
+ public boolean onKeyUp(int keyCode, KeyEvent event) {
+ switch(keyCode) {
+ case KeyEvent.KEYCODE_BACK:
+ if (event.isTracking() && !event.isCanceled()) {
+ if(!mLegalPreviewFragment.onBackPressed()) {
+ finish();
+ }
+ }
+ break;
+ }
+ return false;
+ }
+}
diff --git a/src/com/android/browser/preferences/LegalPreviewFragment.java b/src/com/android/browser/preferences/LegalPreviewFragment.java
new file mode 100644
index 0000000..ec60e10
--- /dev/null
+++ b/src/com/android/browser/preferences/LegalPreviewFragment.java
@@ -0,0 +1,83 @@
+/*
+ * Copyright (c) 2015 The Linux Foundation. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution.
+ * * Neither the name of The Linux Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+ * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+ * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+ * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+ * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+package com.android.browser.preferences;
+
+import android.app.Fragment;
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.FrameLayout;
+
+import com.android.browser.R;
+
+import org.codeaurora.swe.WebView;
+
+public class LegalPreviewFragment extends Fragment {
+
+ private WebView mWebView;
+ private String mUrl;
+
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ Bundle args = getArguments();
+ mUrl = args.getString(LegalPreviewActivity.URL_INTENT_EXTRA);
+ }
+
+ @Override
+ public View onCreateView(LayoutInflater inflater, ViewGroup container,
+ Bundle savedInstanceState) {
+ ViewGroup contentContainer = (ViewGroup) inflater.inflate(
+ R.layout.webview_wrapper, container, false);
+ FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
+ FrameLayout.LayoutParams.MATCH_PARENT,
+ FrameLayout.LayoutParams.MATCH_PARENT);
+ mWebView = new WebView(getActivity());
+ contentContainer.addView(mWebView.getView(), params);
+ return contentContainer;
+ }
+
+ @Override
+ public void onActivityCreated(Bundle b) {
+ super.onActivityCreated(b);
+ if (mWebView == null) return;
+ mWebView.loadUrl(mUrl);
+ }
+
+ public boolean onBackPressed() {
+ if(mWebView != null && mWebView.canGoBack()) {
+ mWebView.goBack();
+ return true;
+ }
+ return false;
+ }
+}