Merge "Add dismiss option for hotseat items" into ub-launcher3-master
diff --git a/res/values/strings.xml b/res/values/strings.xml
index dec8939..218f6db 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -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>
diff --git a/src/com/android/launcher3/notification/NotificationFooterLayout.java b/src/com/android/launcher3/notification/NotificationFooterLayout.java
index c7de5b0..fd3d41a 100644
--- a/src/com/android/launcher3/notification/NotificationFooterLayout.java
+++ b/src/com/android/launcher3/notification/NotificationFooterLayout.java
@@ -80,17 +80,28 @@
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
diff --git a/src/com/android/launcher3/notification/NotificationItemView.java b/src/com/android/launcher3/notification/NotificationItemView.java
index 021fb30..0320aa3 100644
--- a/src/com/android/launcher3/notification/NotificationItemView.java
+++ b/src/com/android/launcher3/notification/NotificationItemView.java
@@ -86,6 +86,13 @@
}
}
+ /**
+ * 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);
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index e70673a..72c95c4 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -37,7 +37,6 @@
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.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 @@
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 @@
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();
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index b580bd6..48f1c49 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -178,7 +178,10 @@
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);
};