Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 03be2ec7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Removing some unused code path" into ub-launcher3-master

parents 01629fea 6bb51f42
Loading
Loading
Loading
Loading
+1 −15
Original line number Diff line number Diff line
@@ -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 @@ public class BadgeInfo {
     */
    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 @@ public class BadgeInfo {
        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 class BadgeInfo {
     */
    public boolean shouldBeInvalidated(BadgeInfo newBadge) {
        return mPackageUserKey.equals(newBadge.mPackageUserKey)
                && (getNotificationCount() != newBadge.getNotificationCount()
                    || hasNotificationToShow());
                && (getNotificationCount() != newBadge.getNotificationCount());
    }
}
+2 −17
Original line number Diff line number Diff line
@@ -412,17 +412,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
        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 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
        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 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC
        return mState != STATE_ANIMATING;
    }

    public boolean isFull() {
        return mContent.isFull();
    }

    private void centerAboutIcon() {
        DeviceProfile grid = mLauncher.getDeviceProfile();

+1 −1
Original line number Diff line number Diff line
@@ -205,7 +205,7 @@ public class FolderIcon extends FrameLayout implements FolderListener {
        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) {
+2 −16
Original line number Diff line number Diff line
@@ -55,8 +55,6 @@ public class FolderPagedView extends PagedView {

    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 @@ public class FolderPagedView extends PagedView {

    /**
     * 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));
        }
        }
        arrangeChildren(icons, icons.size(), false);
        return extra;
    }

    public void allocateSpaceForRank(int rank) {
@@ -431,10 +421,6 @@ public class FolderPagedView extends PagedView {
                pageIndex * mMaxItemsPerPage + sTmpArray[1] * mGridCountX + sTmpArray[0]);
    }

    public boolean isFull() {
        return !ALLOW_FOLDER_SCROLL && getItemCount() >= mMaxItemsPerPage;
    }

    public View getFirstItem() {
        if (getChildCount() < 1) {
            return null;
+5 −67
Original line number Diff line number Diff line
@@ -25,9 +25,7 @@ import com.android.launcher3.ItemInfo;
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.HashMap;
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 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
                mPackageUserToBadgeInfos.remove(postedPackageUserKey);
            }
        }
        updateLauncherIconBadges(Utilities.singletonHashSet(postedPackageUserKey),
                badgeShouldBeRefreshed);
        if (badgeShouldBeRefreshed) {
            mLauncher.updateIconBadges(Utilities.singletonHashSet(postedPackageUserKey));
        }
    }

    @Override
@@ -106,7 +104,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
            if (oldBadgeInfo.getNotificationKeys().size() == 0) {
                mPackageUserToBadgeInfos.remove(removedPackageUserKey);
            }
            updateLauncherIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
            mLauncher.updateIconBadges(Utilities.singletonHashSet(removedPackageUserKey));
            trimNotifications(mPackageUserToBadgeInfos);
        }
    }
@@ -142,7 +140,7 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
        }

        if (!updatedBadges.isEmpty()) {
            updateLauncherIconBadges(updatedBadges.keySet());
            mLauncher.updateIconBadges(updatedBadges.keySet());
        }
        trimNotifications(updatedBadges);
    }
@@ -154,66 +152,6 @@ public class PopupDataProvider implements NotificationListener.NotificationsChan
        }
    }

    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);