Bug 1394356 - Temporary remove add to home screen for Android O. r=jwu
authorNevin Chen <cnevinchen@gmail.com>
Tue, 29 Aug 2017 17:53:56 +0800
changeset 377776 086838a1d7b215ea6f8df6871e14870c1b168ec4
parent 377775 6fc3ff8c6424400022df5b78f62108a4c1c0d057
child 377777 7cc985da769f2ba0588ff2af695e073e9c407e86
push id94338
push userkwierso@gmail.com
push dateThu, 31 Aug 2017 02:58:58 +0000
treeherdermozilla-inbound@9ca18987dabb [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjwu
bugs1394356
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1394356 - Temporary remove add to home screen for Android O. r=jwu MozReview-Commit-ID: 8Uz9QM7i4SD
mobile/android/app/src/main/res/menu-large-v26/browser_app_menu.xml
mobile/android/app/src/main/res/menu-v26/activitystream_contextmenu.xml
mobile/android/app/src/main/res/menu-v26/browser_app_menu.xml
mobile/android/app/src/main/res/menu-v26/home_contextmenu.xml
mobile/android/app/src/main/res/menu-v26/titlebar_contextmenu.xml
mobile/android/app/src/main/res/menu-xlarge-v26/browser_app_menu.xml
mobile/android/base/java/org/mozilla/gecko/delegates/BookmarkStateChangeDelegate.java
mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-large-v26/browser_app_menu.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!-- We disable AlwaysShowAction because we interpret the menu
+     attributes ourselves and thus the warning isn't relevant to us. -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      tools:ignore="AlwaysShowAction">
+
+    <item android:id="@+id/reload"
+          android:icon="@drawable/ic_menu_reload"
+          android:title="@string/reload"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/back"
+          android:icon="@drawable/ic_menu_back"
+          android:title="@string/back"
+          android:visible="false"/>
+
+    <item android:id="@+id/forward"
+          android:icon="@drawable/ic_menu_forward"
+          android:title="@string/forward"
+          android:visible="false"/>
+
+    <item android:id="@+id/bookmark"
+          android:icon="@drawable/ic_menu_bookmark_add"
+          android:title="@string/bookmark"
+          android:showAsAction="ifRoom"/>
+
+    <item android:id="@+id/share"
+          android:icon="@drawable/ic_menu_share"
+          android:title="@string/share"
+          android:showAsAction="ifRoom"/>
+
+    <item android:id="@+id/new_tab"
+          android:title="@string/new_tab"/>
+
+    <item android:id="@+id/new_private_tab"
+          android:title="@string/new_private_tab"/>
+
+    <item android:id="@+id/bookmarks_list"
+          android:title="@string/bookmarks_title"/>
+
+    <item android:id="@+id/history_list"
+          android:title="@string/history_title"/>
+
+    <item android:id="@+id/find_in_page"
+          android:title="@string/find_in_page" />
+
+    <item android:id="@+id/desktop_mode"
+          android:title="@string/desktop_mode"
+          android:checkable="true" />
+
+    <item android:id="@+id/addons_top_level"
+          android:title="@string/addons"
+          android:visible="false" />
+
+    <item android:id="@+id/page"
+          android:title="@string/page">
+
+        <menu>
+
+            <item android:id="@+id/subscribe"
+                  android:title="@string/contextmenu_subscribe"/>
+
+            <item android:id="@+id/save_as_pdf"
+                  android:title="@string/save_as_pdf"/>
+
+            <item android:id="@+id/print"
+                  android:title="@string/print"/>
+
+            <item android:id="@+id/add_search_engine"
+                  android:title="@string/contextmenu_add_search_engine"/>
+
+            <item android:id="@+id/set_as_homepage"
+                  android:title="@string/contextmenu_set_as_homepage"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/tools"
+          android:title="@string/tools">
+
+        <menu>
+
+            <item android:id="@+id/downloads"
+                  android:title="@string/downloads"/>
+
+            <item android:id="@+id/addons"
+                  android:title="@string/addons"/>
+
+            <item android:id="@+id/logins"
+                  android:title="@string/logins"/>
+
+            <item android:id="@+id/new_guest_session"
+                  android:visible="false"
+                  android:title="@string/new_guest_session"/>
+
+            <item android:id="@+id/exit_guest_session"
+                  android:visible="false"
+                  android:title="@string/exit_guest_session"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/char_encoding"
+          android:visible="false"
+          android:title="@string/char_encoding"/>
+
+    <item android:id="@+id/settings"
+          android:title="@string/settings" />
+
+    <item android:id="@+id/help"
+          android:title="@string/help_menu" />
+
+</menu>
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-v26/activitystream_contextmenu.xml
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="utf-8"?>
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+    <!-- Group ID's are required, otherwise NavigationView won't show any dividers. The ID's are unused, but still required. -->
+    <group android:id="@+id/group0">
+        <item
+            android:id="@+id/open_new_tab"
+            android:icon="@drawable/as_tab"
+            android:title="@string/contextmenu_open_new_tab"/>
+        <item
+            android:id="@+id/open_new_private_tab"
+            android:icon="@drawable/as_private"
+            android:title="@string/contextmenu_open_private_tab"/>
+    </group>
+
+    <group android:id="@+id/group1">
+        <item
+            android:id="@+id/dismiss"
+            android:icon="@drawable/as_dismiss"
+            android:title="@string/activity_stream_remove"/>
+
+        <item
+            android:id="@+id/delete"
+            android:icon="@drawable/as_bin"
+            android:visible="false"
+            android:title="@string/activity_stream_delete_history"/>
+    </group>
+
+    <group android:id="@+id/group2">
+        <item
+            android:id="@+id/bookmark"
+            android:icon="@drawable/as_bookmark"
+            android:title="@string/bookmark"/>
+        <item
+            android:id="@+id/share"
+            android:icon="@drawable/as_share"
+            android:title="@string/share"/>
+        <item
+            android:id="@+id/copy_url"
+            android:icon="@drawable/as_copy"
+            android:title="@string/contextmenu_copyurl"/>
+        <item
+            android:id="@+id/pin"
+            android:icon="@drawable/as_pin"
+            android:title="@string/contextmenu_top_sites_pin"/>
+    </group>
+</menu>
\ No newline at end of file
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-v26/browser_app_menu.xml
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!-- We disable AlwaysShowAction because we interpret the menu
+     attributes ourselves and thus the warning isn't relevant to us. -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      tools:ignore="AlwaysShowAction">
+
+    <item android:id="@+id/back"
+          android:icon="@drawable/ic_menu_back"
+          android:title="@string/back"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/forward"
+          android:icon="@drawable/ic_menu_forward"
+          android:title="@string/forward"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/bookmark"
+          android:icon="@drawable/ic_menu_bookmark_add"
+          android:title="@string/bookmark"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/reload"
+          android:icon="@drawable/ic_menu_reload"
+          android:title="@string/reload"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/share"
+          android:icon="@drawable/ic_menu_share"
+          android:title="@string/share"
+          android:showAsAction="ifRoom"/>
+
+    <item android:id="@+id/new_tab"
+          android:title="@string/new_tab"/>
+
+    <item android:id="@+id/new_private_tab"
+          android:title="@string/new_private_tab"/>
+
+    <item android:id="@+id/bookmarks_list"
+          android:title="@string/bookmarks_title"/>
+
+    <item android:id="@+id/history_list"
+          android:title="@string/history_title"/>
+
+    <item android:id="@+id/find_in_page"
+          android:title="@string/find_in_page" />
+
+    <item android:id="@+id/desktop_mode"
+          android:title="@string/desktop_mode"
+          android:checkable="true" />
+
+    <item android:id="@+id/addons_top_level"
+          android:title="@string/addons"
+          android:visible="false" />
+
+    <item android:id="@+id/page"
+          android:title="@string/page">
+
+        <menu>
+
+            <item android:id="@+id/subscribe"
+                  android:title="@string/contextmenu_subscribe"/>
+
+            <item android:id="@+id/save_as_pdf"
+                  android:title="@string/save_as_pdf"/>
+
+            <item android:id="@+id/print"
+                  android:title="@string/print"/>
+
+            <item android:id="@+id/add_search_engine"
+                  android:title="@string/contextmenu_add_search_engine"/>
+
+            <item android:id="@+id/set_as_homepage"
+                  android:title="@string/contextmenu_set_as_homepage"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/tools"
+          android:title="@string/tools">
+
+        <menu>
+
+            <item android:id="@+id/downloads"
+                  android:title="@string/downloads"/>
+
+            <item android:id="@+id/addons"
+                  android:title="@string/addons"/>
+
+            <item android:id="@+id/logins"
+                  android:title="@string/logins"/>
+
+            <item android:id="@+id/new_guest_session"
+                  android:visible="false"
+                  android:title="@string/new_guest_session"/>
+
+            <item android:id="@+id/exit_guest_session"
+                  android:visible="false"
+                  android:title="@string/exit_guest_session"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/char_encoding"
+          android:visible="false"
+          android:title="@string/char_encoding"/>
+
+    <item android:id="@+id/settings"
+          android:title="@string/settings" />
+
+    <item android:id="@+id/help"
+          android:title="@string/help_menu" />
+
+</menu>
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-v26/home_contextmenu.xml
@@ -0,0 +1,41 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@+id/home_open_new_tab"
+          android:title="@string/contextmenu_open_new_tab"/>
+
+    <item android:id="@+id/home_open_private_tab"
+          android:title="@string/contextmenu_open_private_tab"/>
+
+    <item android:id="@+id/home_copyurl"
+          android:title="@string/contextmenu_copyurl"/>
+
+    <item android:id="@+id/home_share"
+          android:title="@string/contextmenu_share"/>
+
+    <item android:id="@+id/top_sites_edit"
+          android:title="@string/contextmenu_top_sites_edit"/>
+
+    <item android:id="@+id/top_sites_pin"
+          android:title="@string/contextmenu_top_sites_pin"/>
+
+    <item android:id="@+id/top_sites_unpin"
+          android:title="@string/contextmenu_top_sites_unpin"/>
+
+    <item android:id="@+id/home_edit_bookmark"
+          android:title="@string/contextmenu_edit_bookmark"/>
+
+    <item android:id="@+id/home_remove"
+          android:title="@string/contextmenu_remove"/>
+
+    <item android:id="@+id/home_as_pin"
+        android:title="@string/contextmenu_top_sites_pin"/>
+
+    <item android:id="@+id/home_set_as_homepage"
+          android:title="@string/contextmenu_set_as_homepage"/>
+
+</menu>
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-v26/titlebar_contextmenu.xml
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<menu xmlns:android="http://schemas.android.com/apk/res/android">
+
+    <item android:id="@+id/pasteandgo"
+          android:title="@string/contextmenu_pasteandgo"/>
+
+    <item android:id="@+id/paste"
+          android:title="@string/contextmenu_paste"/>
+
+    <item android:id="@+id/subscribe"
+          android:title="@string/contextmenu_subscribe"/>
+
+    <item android:id="@+id/add_search_engine"
+          android:title="@string/contextmenu_add_search_engine"/>
+
+    <item android:id="@+id/copyurl"
+          android:title="@string/contextmenu_copyurl"/>
+
+    <item android:id="@+id/set_as_homepage"
+          android:title="@string/contextmenu_set_as_homepage"/>
+
+</menu>
new file mode 100644
--- /dev/null
+++ b/mobile/android/app/src/main/res/menu-xlarge-v26/browser_app_menu.xml
@@ -0,0 +1,121 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- This Source Code Form is subject to the terms of the Mozilla Public
+   - License, v. 2.0. If a copy of the MPL was not distributed with this
+   - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
+
+<!-- We disable AlwaysShowAction because we interpret the menu
+     attributes ourselves and thus the warning isn't relevant to us. -->
+<menu xmlns:android="http://schemas.android.com/apk/res/android"
+      xmlns:tools="http://schemas.android.com/tools"
+      tools:ignore="AlwaysShowAction">
+
+    <item android:id="@+id/reload"
+          android:icon="@drawable/ic_menu_reload"
+          android:title="@string/reload"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/back"
+          android:icon="@drawable/ic_menu_back"
+          android:title="@string/back"
+          android:visible="false"/>
+
+    <item android:id="@+id/forward"
+          android:icon="@drawable/ic_menu_forward"
+          android:title="@string/forward"
+          android:visible="false"/>
+
+    <item android:id="@+id/bookmark"
+          android:icon="@drawable/ic_menu_bookmark_add"
+          android:title="@string/bookmark"
+          android:showAsAction="always"/>
+
+    <item android:id="@+id/share"
+          android:icon="@drawable/ic_menu_share"
+          android:title="@string/share"
+          android:showAsAction="ifRoom"/>
+
+    <item android:id="@+id/new_tab"
+          android:title="@string/new_tab"/>
+
+    <item android:id="@+id/new_private_tab"
+          android:title="@string/new_private_tab"/>
+
+    <item android:id="@+id/bookmarks_list"
+          android:title="@string/bookmarks_title"/>
+
+    <item android:id="@+id/history_list"
+          android:title="@string/history_title"/>
+
+    <item android:id="@+id/find_in_page"
+          android:title="@string/find_in_page" />
+
+    <item android:id="@+id/addons_top_level"
+          android:title="@string/addons"
+          android:visible="false" />
+
+    <item android:id="@+id/desktop_mode"
+          android:title="@string/desktop_mode"
+          android:checkable="true" />
+
+
+    <item android:id="@+id/page"
+          android:title="@string/page">
+
+        <menu>
+
+            <item android:id="@+id/subscribe"
+                  android:title="@string/contextmenu_subscribe"/>
+
+            <item android:id="@+id/save_as_pdf"
+                  android:title="@string/save_as_pdf"/>
+
+            <item android:id="@+id/print"
+                  android:title="@string/print"/>
+
+            <item android:id="@+id/add_search_engine"
+                  android:title="@string/contextmenu_add_search_engine"/>
+
+            <item android:id="@+id/set_as_homepage"
+                  android:title="@string/contextmenu_set_as_homepage"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/tools"
+          android:title="@string/tools">
+
+        <menu>
+
+            <item android:id="@+id/downloads"
+                  android:title="@string/downloads"/>
+
+            <item android:id="@+id/addons"
+                  android:title="@string/addons"/>
+
+            <item android:id="@+id/logins"
+                  android:title="@string/logins"/>
+
+            <item android:id="@+id/new_guest_session"
+                  android:visible="false"
+                  android:title="@string/new_guest_session"/>
+
+            <item android:id="@+id/exit_guest_session"
+                  android:visible="false"
+                  android:title="@string/exit_guest_session"/>
+
+        </menu>
+
+    </item>
+
+    <item android:id="@+id/char_encoding"
+          android:visible="false"
+          android:title="@string/char_encoding"/>
+
+    <item android:id="@+id/settings"
+          android:title="@string/settings" />
+
+    <item android:id="@+id/help"
+          android:title="@string/help_menu" />
+
+</menu>
--- a/mobile/android/base/java/org/mozilla/gecko/delegates/BookmarkStateChangeDelegate.java
+++ b/mobile/android/base/java/org/mozilla/gecko/delegates/BookmarkStateChangeDelegate.java
@@ -11,16 +11,17 @@ import android.content.res.Resources;
 import android.graphics.Color;
 import android.graphics.drawable.Drawable;
 import android.support.design.widget.Snackbar;
 import android.support.v4.content.ContextCompat;
 import android.view.View;
 import android.widget.ListView;
 
 import org.mozilla.gecko.AboutPages;
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.GeckoApplication;
 import org.mozilla.gecko.GeckoSharedPrefs;
 import org.mozilla.gecko.R;
 import org.mozilla.gecko.SnackbarBuilder;
 import org.mozilla.gecko.Tab;
 import org.mozilla.gecko.Tabs;
 import org.mozilla.gecko.Telemetry;
@@ -187,21 +188,28 @@ public class BookmarkStateChangeDelegate
                                 GeckoApplication.createShortcut(title, url);
                             }
                         });
                     }
                 }
             }
         });
 
-        final PromptListItem[] items = new PromptListItem[2];
-        items[0] = new PromptListItem(res.getString(R.string.contextmenu_edit_bookmark));
-        items[1] = new PromptListItem(res.getString(R.string.contextmenu_add_to_launcher));
+        if (AppConstants.Versions.feature26Plus) {
+            final PromptListItem[] items = new PromptListItem[1];
+            items[0] = new PromptListItem(res.getString(R.string.contextmenu_edit_bookmark));
+            ps.show("", "", items, ListView.CHOICE_MODE_NONE);
+        } else {
+            final PromptListItem[] items = new PromptListItem[2];
+            items[0] = new PromptListItem(res.getString(R.string.contextmenu_edit_bookmark));
+            items[1] = new PromptListItem(res.getString(R.string.contextmenu_add_to_launcher));
+            ps.show("", "", items, ListView.CHOICE_MODE_NONE);
+        }
 
-        ps.show("", "", items, ListView.CHOICE_MODE_NONE);
+
     }
 
     private void showReaderModeBookmarkAddedSnackbar() {
         final BrowserApp browserApp = getBrowserApp();
         if (browserApp == null) {
             return;
         }
 
--- a/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
+++ b/mobile/android/base/java/org/mozilla/gecko/promotion/AddToHomeScreenPromotion.java
@@ -8,16 +8,17 @@ package org.mozilla.gecko.promotion;
 import android.app.Activity;
 import android.content.Context;
 import android.database.Cursor;
 import android.os.Bundle;
 import android.support.annotation.CallSuper;
 import android.support.annotation.Nullable;
 import android.util.Log;
 
+import org.mozilla.gecko.AppConstants;
 import org.mozilla.gecko.switchboard.SwitchBoard;
 
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.mozilla.gecko.AboutPages;
 import org.mozilla.gecko.BrowserApp;
 import org.mozilla.gecko.GeckoProfile;
 import org.mozilla.gecko.Tab;
@@ -131,16 +132,21 @@ public class AddToHomeScreenPromotion ex
         }
 
         if (isTabsTrayVisible()) {
             // We only want to show this prompt if this tab is in the foreground and not on top
             // of the tabs tray.
             return;
         }
 
+        // Temporary remove add to home screen
+        if (AppConstants.Versions.feature26Plus) {
+            return;
+        }
+
         ThreadUtils.postToBackgroundThread(new Runnable() {
             @Override
             public void run() {
                 maybeShowPromotionForUrl(tab.getURL(), tab.getTitle());
             }
         });
     }