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

Commit f43a5d32 authored by Samuel Fufa's avatar Samuel Fufa Committed by Android (Google) Code Review
Browse files

Merge "Add dismiss option for hotseat items" into ub-launcher3-master

parents 1db3be37 a18eb686
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -103,7 +103,7 @@
    <!-- Label for install drop target. [CHAR_LIMIT=20] -->
    <string name="install_drop_target_label">Install</string>
    <!-- Label for install dismiss prediction. -->
    <string translatable="false" name="dismiss_prediction_label">Dismiss prediction</string>
    <string translatable="false" name="dismiss_prediction_label">Don\'t suggest app</string>
    <!-- Label for pinning predicted app. -->
    <string name="pin_prediction" translatable="false">Pin Prediction</string>

+17 −6
Original line number Diff line number Diff line
@@ -80,17 +80,28 @@ public class NotificationFooterLayout extends FrameLayout {
        int iconSize = res.getDimensionPixelSize(R.dimen.notification_footer_icon_size);
        mIconLayoutParams = new LayoutParams(iconSize, iconSize);
        mIconLayoutParams.gravity = Gravity.CENTER_VERTICAL;
        // Compute margin start for each icon such that the icons between the first one
        // and the ellipsis are evenly spaced out.
        setWidth((int) res.getDimension(R.dimen.bg_popup_item_width));
        mBackgroundColor = Themes.getAttrColor(context, R.attr.popupColorPrimary);
    }


    /**
     * Compute margin start for each icon such that the icons between the first one and the ellipsis
     * are evenly spaced out.
     */
    public void setWidth(int width) {
        if (getLayoutParams() != null) {
            getLayoutParams().width = width;
        }
        Resources res = getResources();
        int iconSize = res.getDimensionPixelSize(R.dimen.notification_footer_icon_size);

        int paddingEnd = res.getDimensionPixelSize(R.dimen.notification_footer_icon_row_padding);
        int ellipsisSpace = res.getDimensionPixelSize(R.dimen.horizontal_ellipsis_offset)
                + res.getDimensionPixelSize(R.dimen.horizontal_ellipsis_size);
        int footerWidth = res.getDimensionPixelSize(R.dimen.bg_popup_item_width);
        int availableIconRowSpace = footerWidth - paddingEnd - ellipsisSpace
        int availableIconRowSpace = width - paddingEnd - ellipsisSpace
                - iconSize * MAX_FOOTER_NOTIFICATIONS;
        mIconLayoutParams.setMarginStart(availableIconRowSpace / MAX_FOOTER_NOTIFICATIONS);

        mBackgroundColor = Themes.getAttrColor(context, R.attr.popupColorPrimary);
    }

    @Override
+7 −0
Original line number Diff line number Diff line
@@ -86,6 +86,13 @@ public class NotificationItemView {
        }
    }

    /**
     * Sets width for notification footer and spaces out items evenly
     */
    public void setFooterWidth(int footerWidth) {
        mFooter.setWidth(footerWidth);
    }

    public void removeFooter() {
        if (mContainer.indexOfChild(mFooter) >= 0) {
            mContainer.removeView(mFooter);
+17 −5
Original line number Diff line number Diff line
@@ -37,7 +37,6 @@ import android.os.Build;
import android.os.Handler;
import android.os.Looper;
import android.util.AttributeSet;
import android.util.Log;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
@@ -66,7 +65,6 @@ import com.android.launcher3.notification.NotificationKeyData;
import com.android.launcher3.popup.PopupDataProvider.PopupDataChangeListener;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
import com.android.launcher3.testing.TestProtocol;
import com.android.launcher3.touch.ItemClickHandler;
import com.android.launcher3.touch.ItemLongClickListener;
import com.android.launcher3.util.PackageUserKey;
@@ -257,6 +255,16 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
        mNumNotifications = notificationKeys.size();
        mOriginalIcon = originalIcon;

        boolean hasDeepShortcuts = shortcutCount > 0;
        int containerWidth = (int) getResources().getDimension(R.dimen.bg_popup_item_width);

        // if there are deep shortcuts, we might want to increase the width of shortcuts to fit
        // horizontally laid out system shortcuts.
        if (hasDeepShortcuts) {
            containerWidth = (int) Math.max(containerWidth,
                    systemShortcuts.size() * getResources().getDimension(
                            R.dimen.system_shortcut_header_icon_touch_size));
        }
        // Add views
        if (mNumNotifications > 0) {
            // Add notification entries
@@ -265,18 +273,22 @@ public class PopupContainerWithArrow extends ArrowPopup implements DragSource,
            if (mNumNotifications == 1) {
                mNotificationItemView.removeFooter();
            }
            else {
                mNotificationItemView.setFooterWidth(containerWidth);
            }
            updateNotificationHeader();
        }
        int viewsToFlip = getChildCount();
        mSystemShortcutContainer = this;

        if (shortcutCount > 0) {
        if (hasDeepShortcuts) {
            if (mNotificationItemView != null) {
                mNotificationItemView.addGutter();
            }

            for (int i = shortcutCount; i > 0; i--) {
                mShortcuts.add(inflateAndAdd(R.layout.deep_shortcut, this));
                DeepShortcutView v = inflateAndAdd(R.layout.deep_shortcut, this);
                v.getLayoutParams().width = containerWidth;
                mShortcuts.add(v);
            }
            updateHiddenShortcuts();

+4 −1
Original line number Diff line number Diff line
@@ -178,7 +178,10 @@ public abstract class SystemShortcut<T extends BaseDraggingActivity> extends Ite

    public static final Factory<Launcher> DISMISS_PREDICTION = (launcher, itemInfo) -> {
        if (!FeatureFlags.ENABLE_PREDICTION_DISMISS.get()) return null;
        if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION) return null;
        if (itemInfo.container != LauncherSettings.Favorites.CONTAINER_PREDICTION
                && itemInfo.container != LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION) {
            return null;
        }
        return new DismissPrediction(launcher, itemInfo);
    };