Bug 1285926 - Add preference for enabling/disabling custom tabs support. r?snorp
MozReview-Commit-ID: 8KmJo5IM7JS
--- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
+++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java
@@ -7,30 +7,31 @@ package org.mozilla.gecko;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.support.customtabs.CustomTabsIntent;
import org.mozilla.gecko.customtabs.CustomTabsActivity;
import org.mozilla.gecko.db.BrowserContract;
+import org.mozilla.gecko.preferences.GeckoPreferences;
import org.mozilla.gecko.tabqueue.TabQueueHelper;
import org.mozilla.gecko.tabqueue.TabQueueService;
/**
* Activity that receives incoming Intents and dispatches them to the appropriate activities (e.g. browser, custom tabs, web app).
*/
public class LauncherActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
GeckoAppShell.ensureCrashHandling();
- if (AppConstants.MOZ_ANDROID_CUSTOM_TABS && isCustomTabsIntent()) {
+ if (AppConstants.MOZ_ANDROID_CUSTOM_TABS && isCustomTabsIntent() && isCustomTabsEnabled()) {
dispatchCustomTabsIntent();
} else if (isViewIntentWithURL()) {
dispatchViewIntent();
} else {
dispatchNormalIntent();
}
finish();
@@ -79,9 +80,13 @@ public class LauncherActivity extends Ac
return Intent.ACTION_VIEW.equals(intent.getAction())
&& intent.getDataString() != null;
}
private boolean isCustomTabsIntent() {
return isViewIntentWithURL()
&& getIntent().hasExtra(CustomTabsIntent.EXTRA_SESSION);
}
+
+ private boolean isCustomTabsEnabled() {
+ return GeckoSharedPrefs.forApp(this).getBoolean(GeckoPreferences.PREFS_CUSTOM_TABS, false);
+ }
}
--- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
+++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java
@@ -157,16 +157,17 @@ OnSharedPreferenceChangeListener
public static final String PREFS_HISTORY_SAVED_SEARCH = NON_PREF_PREFIX + "search.search_history.enabled";
private static final String PREFS_FAQ_LINK = NON_PREF_PREFIX + "faq.link";
private static final String PREFS_FEEDBACK_LINK = NON_PREF_PREFIX + "feedback.link";
public static final String PREFS_NOTIFICATIONS_CONTENT = NON_PREF_PREFIX + "notifications.content";
public static final String PREFS_NOTIFICATIONS_CONTENT_LEARN_MORE = NON_PREF_PREFIX + "notifications.content.learn_more";
public static final String PREFS_NOTIFICATIONS_WHATS_NEW = NON_PREF_PREFIX + "notifications.whats_new";
public static final String PREFS_APP_UPDATE_LAST_BUILD_ID = "app.update.last_build_id";
public static final String PREFS_READ_PARTNER_CUSTOMIZATIONS_PROVIDER = NON_PREF_PREFIX + "distribution.read_partner_customizations_provider";
+ public static final String PREFS_CUSTOM_TABS = NON_PREF_PREFIX + "customtabs";
private static final String ACTION_STUMBLER_UPLOAD_PREF = AppConstants.ANDROID_PACKAGE_NAME + ".STUMBLER_PREF";
// This isn't a Gecko pref, even if it looks like one.
private static final String PREFS_BROWSER_LOCALE = "locale";
public static final String PREFS_RESTORE_SESSION = NON_PREF_PREFIX + "restoreSession3";
@@ -874,16 +875,20 @@ OnSharedPreferenceChangeListener
}
} else if (PREFS_NOTIFICATIONS_CONTENT.equals(key) ||
PREFS_NOTIFICATIONS_CONTENT_LEARN_MORE.equals(key)) {
if (!FeedService.isInExperiment(this)) {
preferences.removePreference(pref);
i--;
continue;
}
+ } else if (PREFS_CUSTOM_TABS.equals(key) && !AppConstants.MOZ_ANDROID_CUSTOM_TABS) {
+ preferences.removePreference(pref);
+ i--;
+ continue;
}
// Some Preference UI elements are not actually preferences,
// but they require a key to work correctly. For example,
// "Clear private data" requires a key for its state to be
// saved when the orientation changes. It uses the
// "android.not_a_preference.privacy.clear" key - which doesn't
// exist in Gecko - to satisfy this requirement.
--- a/mobile/android/base/locales/en-US/android_strings.dtd
+++ b/mobile/android/base/locales/en-US/android_strings.dtd
@@ -267,16 +267,22 @@
<!ENTITY pref_tracking_protection_enabled "Enabled">
<!ENTITY pref_tracking_protection_enabled_pb "Enabled in Private Browsing">
<!ENTITY pref_tracking_protection_disabled "Disabled">
<!ENTITY pref_whats_new_notification "What\'s new in &brandShortName;">
<!ENTITY pref_whats_new_notification_summary "Learn about new features after an update">
+<!-- Custom Tabs is an Android API for allowing third-party apps to open URLs in a customized UI.
+ Instead of switching to the browser it appears as if the user stays in the third-party app.
+ For more see: https://developer.chrome.com/multidevice/android/customtabs -->
+<!ENTITY pref_custom_tabs "Custom Tabs">
+<!ENTITY pref_custom_tabs_summary "Allow third-party apps to open URLs with a customized look and feel. ">
+
<!ENTITY tracking_protection_prompt_title "Now with Tracking Protection">
<!ENTITY tracking_protection_prompt_text "Actively block tracking elements so you don\'t have to worry.">
<!ENTITY tracking_protection_prompt_tip_text "Visit Privacy settings to learn more">
<!ENTITY tracking_protection_prompt_action_button "Got it!">
<!ENTITY tab_queue_toast_message3 "Tab saved in &brandShortName;">
<!ENTITY tab_queue_toast_action "Open now">
<!ENTITY tab_queue_prompt_title "Opening multiple links?">
--- a/mobile/android/base/resources/xml/preferences_advanced.xml
+++ b/mobile/android/base/resources/xml/preferences_advanced.xml
@@ -33,16 +33,21 @@
android:persistent="true" />
<ListPreference android:key="browser.menu.showCharacterEncoding"
android:title="@string/pref_char_encoding"
android:entries="@array/pref_char_encoding_entries"
android:entryValues="@array/pref_char_encoding_values"
android:persistent="false" />
+ <SwitchPreference android:key="android.not_a_preference.customtabs"
+ android:title="@string/pref_custom_tabs"
+ android:summary="@string/pref_custom_tabs_summary"
+ android:defaultValue="false" />
+
<PreferenceCategory android:title="@string/pref_category_data_saver">
<ListPreference android:key="browser.image_blocking"
android:title="@string/pref_tap_to_load_images_title2"
android:entries="@array/pref_browser_image_blocking_entries"
android:entryValues="@array/pref_browser_image_blocking_values"
android:persistent="false" />
--- a/mobile/android/base/strings.xml.in
+++ b/mobile/android/base/strings.xml.in
@@ -229,16 +229,19 @@
<string name="pref_tracking_protection_enabled">&pref_tracking_protection_enabled;</string>
<string name="pref_tracking_protection_enabled_pb">&pref_tracking_protection_enabled_pb;</string>
<string name="pref_tracking_protection_disabled">&pref_tracking_protection_disabled;</string>
<string name="pref_whats_new_notification">&pref_whats_new_notification;</string>
<string name="pref_whats_new_notification_summary">&pref_whats_new_notification_summary;</string>
+ <string name="pref_custom_tabs">&pref_custom_tabs;</string>
+ <string name="pref_custom_tabs_summary">&pref_custom_tabs_summary;</string>
+
<string name="pref_char_encoding">&pref_char_encoding;</string>
<string name="pref_char_encoding_on">&pref_char_encoding_on;</string>
<string name="pref_char_encoding_off">&pref_char_encoding_off;</string>
<string name="pref_clear_private_data_now">&pref_clear_private_data2;</string>
<string name="pref_clear_private_data_now_tablet">&pref_clear_private_data_now_tablet;</string>
<string name="pref_clear_on_exit_title">&pref_clear_on_exit_title3;</string>
<string name="pref_clear_on_exit_summary2">&pref_clear_on_exit_summary2;</string>
<string name="pref_clear_on_exit_dialog_title">&pref_clear_on_exit_dialog_title;</string>