Bug 1217174 - Part 1: Always show 'Send to other devices' menu item. r?mcomella draft
authorAlex Johnson <me@alex-johnson.net>
Mon, 28 Dec 2015 01:00:54 -0500
changeset 320204 2814f8b155fbb4709e8ca94f310b5cee73b3a8e3
parent 320203 0f363ae95dc90d593394ef464aa500804c824962
child 320205 4fa98e528e165f422826b3af0b2b358267398e03
child 320213 5ddfc173b0ee18251367aa9376c6e0f7b4fe16db
push id9157
push userme@alex-johnson.net
push dateSat, 09 Jan 2016 07:45:41 +0000
reviewersmcomella
bugs1217174
milestone46.0a1
Bug 1217174 - Part 1: Always show 'Send to other devices' menu item. r?mcomella
mobile/android/base/java/org/mozilla/gecko/widget/ActivityChooserModel.java
--- a/mobile/android/base/java/org/mozilla/gecko/widget/ActivityChooserModel.java
+++ b/mobile/android/base/java/org/mozilla/gecko/widget/ActivityChooserModel.java
@@ -769,28 +769,21 @@ public class ActivityChooserModel extend
 
             for (int i = 0; i < resolveInfoCount; i++) {
                 ResolveInfo resolveInfo = resolveInfos.get(i);
 
                 /**
                  * Mozilla: We want "Add to Firefox" to appear differently inside of Firefox than
                  * from external applications - override the name and icon here.
                  *
-                 * Do not display the menu item if there are no devices to share to.
-                 *
                  * Note: we check both the class name and the label to ensure we only change the
                  * label of the current channel.
                  */
                 if (shareDialogClassName.equals(resolveInfo.activityInfo.name) &&
                         channelToRemoveLabel.equals(resolveInfo.loadLabel(packageManager))) {
-                    // Don't add the menu item if there are no devices to share to.
-                    if (!hasOtherSyncClients()) {
-                        continue;
-                    }
-
                     resolveInfo.labelRes = R.string.overlay_share_send_other;
                     resolveInfo.icon = R.drawable.icon_shareplane;
                 }
 
                 mActivities.add(new ActivityResolveInfo(resolveInfo));
             }
             return true;
         }
@@ -1300,42 +1293,16 @@ public class ActivityChooserModel extend
                 removeHistoricalRecordsForPackage(packageName);
             }
 
             mReloadActivities = true;
         }
     }
 
     /**
-     * Mozilla: Return whether or not there are other synced clients.
-     */
-    private boolean hasOtherSyncClients() {
-        // ClientsDatabaseAccessor returns stale data (bug 1145896) so we work around this by
-        // checking if we have accounts set up - if not, we can't have any clients.
-        if (!FirefoxAccounts.firefoxAccountsExist(mContext) &&
-                !SyncAccounts.syncAccountsExist(mContext))  {
-            return false;
-        }
-
-        final BrowserDB browserDB = GeckoProfile.get(mContext).getDB();
-        final TabsAccessor tabsAccessor = browserDB.getTabsAccessor();
-        final Cursor remoteClientsCursor = tabsAccessor
-                .getRemoteClientsByRecencyCursor(mContext);
-        if (remoteClientsCursor == null) {
-            return false;
-        }
-
-        try {
-            return remoteClientsCursor.getCount() > 0;
-        } finally {
-            remoteClientsCursor.close();
-        }
-    }
-
-    /**
      * Mozilla: Reload activities on sync.
      */
     private class SyncStatusDelegate implements SyncStatusListener {
         @Override
         public Context getContext() {
             return mContext;
         }