diff --git a/mobile/android/base/AndroidManifest.xml.in b/mobile/android/base/AndroidManifest.xml.in index dc460f2fd506..828343c7ac78 100644 --- a/mobile/android/base/AndroidManifest.xml.in +++ b/mobile/android/base/AndroidManifest.xml.in @@ -312,10 +312,12 @@ +#ifdef MOZ_ANDROID_CUSTOM_TABS +#endif @@ -419,6 +421,7 @@ android:name="org.mozilla.gecko.telemetry.TelemetryUploadService" android:exported="false"/> +#ifdef MOZ_ANDROID_CUSTOM_TABS @@ -426,6 +429,7 @@ +#endif #include ../services/manifests/FxAccountAndroidManifest_services.xml.in diff --git a/mobile/android/base/AppConstants.java.in b/mobile/android/base/AppConstants.java.in index 7041dc760afd..425d8f2ea4ea 100644 --- a/mobile/android/base/AppConstants.java.in +++ b/mobile/android/base/AppConstants.java.in @@ -309,6 +309,13 @@ public class AppConstants { false; //#endif + public static final boolean MOZ_ANDROID_CUSTOM_TABS = +//#ifdef MOZ_ANDROID_CUSTOM_TABS + true; +//#else + false; +//#endif + // (bug 1266820) Temporarily disabled since no one is working on it. public static final boolean SCREENSHOTS_IN_BOOKMARKS_ENABLED = false; diff --git a/mobile/android/base/generate_build_config.py b/mobile/android/base/generate_build_config.py index dc0998086378..e302335d9892 100644 --- a/mobile/android/base/generate_build_config.py +++ b/mobile/android/base/generate_build_config.py @@ -39,6 +39,7 @@ def _defines(): for var in ('MOZ_ANDROID_ACTIVITY_STREAM' 'MOZ_ANDROID_ANR_REPORTER', 'MOZ_ANDROID_BEAM', + 'MOZ_ANDROID_CUSTOM_TABS', 'MOZ_ANDROID_DOWNLOADS_INTEGRATION', 'MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE', 'MOZ_ANDROID_EXCLUDE_FONTS', diff --git a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java index 7c21f4aaea56..2ab716071350 100644 --- a/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java +++ b/mobile/android/base/java/org/mozilla/gecko/LauncherActivity.java @@ -65,7 +65,9 @@ public class LauncherActivity extends Activity { } else if (!isViewIntentWithURL(safeIntent)) { dispatchNormalIntent(); - } else if (isCustomTabsIntent(safeIntent)) { + // Is this a custom tabs intent, and are custom tabs enabled? + } else if (AppConstants.MOZ_ANDROID_CUSTOM_TABS && isCustomTabsIntent(safeIntent) + && isCustomTabsEnabled()) { dispatchCustomTabsIntent(); // Can we dispatch this VIEW action intent to the tab queue service? @@ -156,6 +158,10 @@ public class LauncherActivity extends Activity { return GeckoApp.ACTION_WEBAPP.equals(safeIntent.getAction()); } + private boolean isCustomTabsEnabled() { + return GeckoSharedPrefs.forApp(this).getBoolean(GeckoPreferences.PREFS_CUSTOM_TABS, false); + } + private boolean isDeepLink(SafeIntent intent) { if (intent == null || intent.getData() == null || intent.getData().getScheme() == null || intent.getAction() == null) { diff --git a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java index dd8ad119b58b..b28ab392a71c 100644 --- a/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java +++ b/mobile/android/base/java/org/mozilla/gecko/preferences/GeckoPreferences.java @@ -161,6 +161,7 @@ public class GeckoPreferences 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_READ_PARTNER_BOOKMARKS_PROVIDER = NON_PREF_PREFIX + "distribution.read_partner_bookmarks_provider"; + public static final String PREFS_CUSTOM_TABS = NON_PREF_PREFIX + "customtabs"; public static final String PREFS_ACTIVITY_STREAM = NON_PREF_PREFIX + "experiments.activitystream"; public static final String PREFS_CATEGORY_EXPERIMENTAL_FEATURES = NON_PREF_PREFIX + "category_experimental"; public static final String PREFS_COMPACT_TABS = NON_PREF_PREFIX + "compact_tabs"; @@ -695,6 +696,7 @@ public class GeckoPreferences i--; continue; } else if (PREFS_CATEGORY_EXPERIMENTAL_FEATURES.equals(key) + && !AppConstants.MOZ_ANDROID_CUSTOM_TABS && !ActivityStream.isUserSwitchable(this)) { preferences.removePreference(pref); i--; @@ -885,6 +887,10 @@ public class GeckoPreferences i--; continue; } + } else if (PREFS_CUSTOM_TABS.equals(key) && !AppConstants.MOZ_ANDROID_CUSTOM_TABS) { + preferences.removePreference(pref); + i--; + continue; } else if (PREFS_ACTIVITY_STREAM.equals(key) && !ActivityStream.isUserSwitchable(this)) { preferences.removePreference(pref); diff --git a/mobile/android/base/locales/en-US/android_strings.dtd b/mobile/android/base/locales/en-US/android_strings.dtd index 9100c399ea22..157c17ade588 100644 --- a/mobile/android/base/locales/en-US/android_strings.dtd +++ b/mobile/android/base/locales/en-US/android_strings.dtd @@ -283,6 +283,11 @@ for experimental features. --> + + + diff --git a/mobile/android/base/resources/xml/preferences_advanced.xml b/mobile/android/base/resources/xml/preferences_advanced.xml index a3e826e58457..cae2c8c91e58 100644 --- a/mobile/android/base/resources/xml/preferences_advanced.xml +++ b/mobile/android/base/resources/xml/preferences_advanced.xml @@ -89,6 +89,12 @@ android:title="@string/pref_activity_stream" android:summary="@string/pref_activity_stream_summary" /> + + + diff --git a/mobile/android/base/strings.xml.in b/mobile/android/base/strings.xml.in index 04eec1ab641c..4bfb0d79d43e 100644 --- a/mobile/android/base/strings.xml.in +++ b/mobile/android/base/strings.xml.in @@ -241,6 +241,8 @@ &pref_category_experimental; + &pref_custom_tabs; + &pref_custom_tabs_summary3; &custom_tabs_menu_item_open_in; &custom_tabs_menu_footer; &custom_tabs_hint_url_copy; diff --git a/mobile/android/moz.configure b/mobile/android/moz.configure index 412885d08900..fe24c981ca35 100644 --- a/mobile/android/moz.configure +++ b/mobile/android/moz.configure @@ -68,6 +68,10 @@ project_flag('MOZ_ANDROID_DOWNLOAD_CONTENT_SERVICE', help='Background service for downloading additional content at runtime', default=True) +project_flag('MOZ_ANDROID_CUSTOM_TABS', + help='Enable support for Android custom tabs', + default=milestone.is_nightly) + # Enable the Switchboard A/B framework code. # Note: The framework is always included in the app. This flag controls # usage of the framework.