Merge "Removing some unused code path" into ub-launcher3-master
diff --git a/src/com/android/launcher3/badge/BadgeInfo.java b/src/com/android/launcher3/badge/BadgeInfo.java
index 170f231..f03544f 100644
--- a/src/com/android/launcher3/badge/BadgeInfo.java
+++ b/src/com/android/launcher3/badge/BadgeInfo.java
@@ -16,8 +16,6 @@
 
 package com.android.launcher3.badge;
 
-import android.support.annotation.Nullable;
-
 import com.android.launcher3.notification.NotificationInfo;
 import com.android.launcher3.notification.NotificationKeyData;
 import com.android.launcher3.util.PackageUserKey;
@@ -47,9 +45,6 @@
      */
     private int mTotalCount;
 
-    /** This will only be initialized if the badge should display the notification icon. */
-    private NotificationInfo mNotificationInfo;
-
     public BadgeInfo(PackageUserKey packageUserKey) {
         mPackageUserKey = packageUserKey;
         mNotificationKeys = new ArrayList<>();
@@ -98,14 +93,6 @@
         return Math.min(mTotalCount, MAX_COUNT);
     }
 
-    public void setNotificationToShow(@Nullable NotificationInfo notificationInfo) {
-        mNotificationInfo = notificationInfo;
-    }
-
-    public boolean hasNotificationToShow() {
-        return mNotificationInfo != null;
-    }
-
     /**
      * Whether newBadge represents the same PackageUserKey as this badge, and icons with
      * this badge should be invalidated. So, for instance, if a badge has 3 notifications
@@ -116,7 +103,6 @@
      */
     public boolean shouldBeInvalidated(BadgeInfo newBadge) {
         return mPackageUserKey.equals(newBadge.mPackageUserKey)
-                && (getNotificationCount() != newBadge.getNotificationCount()
-                    || hasNotificationToShow());
+                && (getNotificationCount() != newBadge.getNotificationCount());
     }
 }
diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java
index b78e470..d4c396a 100644
--- a/src/com/android/launcher3/folder/Folder.java
+++ b/src/com/android/launcher3/folder/Folder.java
@@ -412,17 +412,7 @@
         mInfo = info;
         ArrayList<ShortcutInfo> children = info.contents;
         Collections.sort(children, ITEM_POS_COMPARATOR);
-
-        ArrayList<ShortcutInfo> overflow = mContent.bindItems(children);
-
-        // If our folder has too many items we prune them from the list. This is an issue
-        // when upgrading from the old Folders implementation which could contain an unlimited
-        // number of items.
-        // TODO: Remove this, as with multi-page folders, there will never be any overflow
-        for (ShortcutInfo item: overflow) {
-            mInfo.remove(item, false);
-            mLauncher.getModelWriter().deleteItemFromDatabase(item);
-        }
+        mContent.bindItems(children);
 
         DragLayer.LayoutParams lp = (DragLayer.LayoutParams) getLayoutParams();
         if (lp == null) {
@@ -710,8 +700,7 @@
         final int itemType = item.itemType;
         return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
                 itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
-                itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) &&
-                    !isFull());
+                itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT));
     }
 
     public void onDragEnter(DragObject d) {
@@ -926,10 +915,6 @@
         return mState != STATE_ANIMATING;
     }
 
-    public boolean isFull() {
-        return mContent.isFull();
-    }
-
     private void centerAboutIcon() {
         DeviceProfile grid = mLauncher.getDeviceProfile();
 
diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java
index 4d8d171..2de09b8 100644
--- a/src/com/android/launcher3/folder/FolderIcon.java
+++ b/src/com/android/launcher3/folder/FolderIcon.java
@@ -205,7 +205,7 @@
         return ((itemType == LauncherSettings.Favorites.ITEM_TYPE_APPLICATION ||
                 itemType == LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT ||
                 itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) &&
-                !mFolder.isFull() && item != mInfo && !mFolder.isOpen());
+                item != mInfo && !mFolder.isOpen());
     }
 
     public boolean acceptDrop(ItemInfo dragInfo) {
diff --git a/src/com/android/launcher3/folder/FolderPagedView.java b/src/com/android/launcher3/folder/FolderPagedView.java
index 9e5bc4f..f4462aa 100644
--- a/src/com/android/launcher3/folder/FolderPagedView.java
+++ b/src/com/android/launcher3/folder/FolderPagedView.java
@@ -55,8 +55,6 @@
 
     private static final String TAG = "FolderPagedView";
 
-    private static final boolean ALLOW_FOLDER_SCROLL = true;
-
     private static final int REORDER_ANIMATION_DURATION = 230;
     private static final int START_VIEW_REORDER_DELAY = 30;
     private static final float VIEW_REORDER_DELAY_FACTOR = 0.9f;
@@ -183,21 +181,13 @@
 
     /**
      * Binds items to the layout.
-     * @return list of items that could not be bound, probably because we hit the max size limit.
      */
-    public ArrayList<ShortcutInfo> bindItems(ArrayList<ShortcutInfo> items) {
+    public void bindItems(ArrayList<ShortcutInfo> items) {
         ArrayList<View> icons = new ArrayList<>();
-        ArrayList<ShortcutInfo> extra = new ArrayList<>();
-
         for (ShortcutInfo item : items) {
-            if (!ALLOW_FOLDER_SCROLL && icons.size() >= mMaxItemsPerPage) {
-                extra.add(item);
-            } else {
-                icons.add(createNewView(item));
-            }
+            icons.add(createNewView(item));
         }
         arrangeChildren(icons, icons.size(), false);
-        return extra;
     }
 
     public void allocateSpaceForRank(int rank) {
@@ -431,10 +421,6 @@
                 pageIndex * mMaxItemsPerPage + sTmpArray[1] * mGridCountX + sTmpArray[0]);
     }
 
-    public boolean isFull() {
-        return !ALLOW_FOLDER_SCROLL && getItemCount() >= mMaxItemsPerPage;
-    }
-
     public View getFirstItem() {
         if (getChildCount() < 1) {
             return null;
diff --git a/src/com/android/launcher3/popup/PopupDataProvider.java b/src/com/android/launcher3/popup/PopupDataProvider.java
index abc186b..335426c 100644
--- a/src/com/android/launcher3/popup/PopupDataProvider.java
+++ b/src/com/android/launcher3/popup/PopupDataProvider.java
@@ -25,9 +25,7 @@
 import com.android.launcher3.Launcher;
 import com.android.launcher3.Utilities;
 import com.android.launcher3.badge.BadgeInfo;
-import com.android.launcher3.model.PackageItemInfo;
 import com.android.launcher3.model.WidgetItem;
-import com.android.launcher3.notification.NotificationInfo;
 import com.android.launcher3.notification.NotificationKeyData;
 import com.android.launcher3.notification.NotificationListener;
 import com.android.launcher3.shortcuts.DeepShortcutManager;
@@ -42,7 +40,6 @@
 import java.util.Iterator;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /**
  * Provides data for the popup menu that appears after long-clicking on apps.
@@ -94,8 +91,9 @@
                 mPackageUserToBadgeInfos.remove(postedPackageUserKey);
             }
         }
-        updateLauncherIconBadges(Utilities.singletonHashSet(postedPackageUserKey),
-                badgeShouldBeRefreshed);
+        if (badgeShouldBeRefreshed) {
+            mLauncher.updateIconBadges(Utilities.singletonHashSet(postedPackageUserKey));
+        }
     }
 
     @Override
@@ -106,7 +104,7 @@
             if (oldBadgeInfo.getNotificationKeys().size() == 0) {
                 mPackageUserToBadgeInfos.remove(removedPackageUserKey);
             }
-            updateLauncherIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
+            mLauncher.updateIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
             trimNotifications(mPackageUserToBadgeInfos);
         }
     }
@@ -142,7 +140,7 @@
         }
 
         if (!updatedBadges.isEmpty()) {
-            updateLauncherIconBadges(updatedBadges.keySet());
+            mLauncher.updateIconBadges(updatedBadges.keySet());
         }
         trimNotifications(updatedBadges);
     }
@@ -154,66 +152,6 @@
         }
     }
 
-    private void updateLauncherIconBadges(Set<PackageUserKey> updatedBadges) {
-        updateLauncherIconBadges(updatedBadges, true);
-    }
-
-    /**
-     * Updates the icons on launcher (workspace, folders, all apps) to refresh their badges.
-     * @param updatedBadges The packages whose badges should be refreshed (either a notification was
-     *                      added or removed, or the badge should show the notification icon).
-     * @param shouldRefresh An optional parameter that will allow us to only refresh badges that
-     *                      have actually changed. If a notification updated its content but not
-     *                      its count or icon, then the badge doesn't change.
-     */
-    private void updateLauncherIconBadges(Set<PackageUserKey> updatedBadges,
-            boolean shouldRefresh) {
-        Iterator<PackageUserKey> iterator = updatedBadges.iterator();
-        while (iterator.hasNext()) {
-            BadgeInfo badgeInfo = mPackageUserToBadgeInfos.get(iterator.next());
-            if (badgeInfo != null && !updateBadgeIcon(badgeInfo) && !shouldRefresh) {
-                // The notification icon isn't used, and the badge hasn't changed
-                // so there is no update to be made.
-                iterator.remove();
-            }
-        }
-        if (!updatedBadges.isEmpty()) {
-            mLauncher.updateIconBadges(updatedBadges);
-        }
-    }
-
-    /**
-     * Determines whether the badge should show a notification icon rather than a number,
-     * and sets that icon on the BadgeInfo if so.
-     * @param badgeInfo The badge to update with an icon (null if it shouldn't show one).
-     * @return Whether the badge icon potentially changed (true unless it stayed null).
-     */
-    private boolean updateBadgeIcon(BadgeInfo badgeInfo) {
-        boolean hadNotificationToShow = badgeInfo.hasNotificationToShow();
-        NotificationInfo notificationInfo = null;
-        NotificationListener notificationListener = NotificationListener.getInstanceIfConnected();
-        if (notificationListener != null && badgeInfo.getNotificationKeys().size() >= 1) {
-            // Look for the most recent notification that has an icon that should be shown in badge.
-            for (NotificationKeyData notificationKeyData : badgeInfo.getNotificationKeys()) {
-                String notificationKey = notificationKeyData.notificationKey;
-                StatusBarNotification[] activeNotifications = notificationListener
-                        .getActiveNotifications(new String[]{notificationKey});
-                if (activeNotifications.length == 1) {
-                    notificationInfo = new NotificationInfo(mLauncher, activeNotifications[0]);
-                    if (notificationInfo.shouldShowIconInBadge()) {
-                        // Found an appropriate icon.
-                        break;
-                    } else {
-                        // Keep looking.
-                        notificationInfo = null;
-                    }
-                }
-            }
-        }
-        badgeInfo.setNotificationToShow(notificationInfo);
-        return hadNotificationToShow || badgeInfo.hasNotificationToShow();
-    }
-
     public void setDeepShortcutMap(MultiHashMap<ComponentKey, String> deepShortcutMapCopy) {
         mDeepShortcutMap = deepShortcutMapCopy;
         if (LOGD) Log.d(TAG, "bindDeepShortcutMap: " + mDeepShortcutMap);