summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/popup/PopupContainerWithArrow.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2017-03-20 17:12:24 -0700
committerTony <twickham@google.com>2017-03-30 16:35:56 -0700
commit26b1746593851e239bfff65ae7a69b809ad87b99 (patch)
tree4f5a73f3253d52304a0f105aa03c2a882038b14a /src/com/android/launcher3/popup/PopupContainerWithArrow.java
parent4a907d0f9d1c80661c086aa95a8509698f38b324 (diff)
downloadandroid_packages_apps_Trebuchet-26b1746593851e239bfff65ae7a69b809ad87b99.tar.gz
android_packages_apps_Trebuchet-26b1746593851e239bfff65ae7a69b809ad87b99.tar.bz2
android_packages_apps_Trebuchet-26b1746593851e239bfff65ae7a69b809ad87b99.zip
Add support for system shortcuts in popup container
- Currently the system shortcuts are just widgets and app info - As shortcuts, they live in ShortcutsItemView - They are populated either as icons only (if there are deep shortcuts) or as icons + text - Widgets are disabled until binding them is complete (we request for them to be bound on long-press now). We should revisit this. Bug: 34940468 Change-Id: Ia51d002c3b3ede87658bdab57abfc3eeca1ed242
Diffstat (limited to 'src/com/android/launcher3/popup/PopupContainerWithArrow.java')
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java55
1 files changed, 37 insertions, 18 deletions
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index fffcb7107..b92814fab 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -22,7 +22,6 @@ import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
-import android.annotation.SuppressLint;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.Resources;
@@ -66,6 +65,7 @@ import com.android.launcher3.dragndrop.DragOptions;
import com.android.launcher3.graphics.TriangleShape;
import com.android.launcher3.notification.NotificationItemView;
import com.android.launcher3.notification.NotificationKeyData;
+import com.android.launcher3.shortcuts.DeepShortcutManager;
import com.android.launcher3.shortcuts.DeepShortcutView;
import com.android.launcher3.shortcuts.ShortcutsItemView;
import com.android.launcher3.util.PackageUserKey;
@@ -138,19 +138,21 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
return null;
}
ItemInfo itemInfo = (ItemInfo) icon.getTag();
+ if (!DeepShortcutManager.supportsShortcuts(itemInfo)) {
+ return null;
+ }
+
List<String> shortcutIds = launcher.getPopupDataProvider().getShortcutIdsForItem(itemInfo);
List<NotificationKeyData> notificationKeys = launcher.getPopupDataProvider()
.getNotificationKeysForItem(itemInfo);
- if (shortcutIds.size() > 0 || notificationKeys.size() > 0) {
- final PopupContainerWithArrow container =
- (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(
- R.layout.popup_container, launcher.getDragLayer(), false);
- container.setVisibility(View.INVISIBLE);
- launcher.getDragLayer().addView(container);
- container.populateAndShow(icon, shortcutIds, notificationKeys);
- return container;
- }
- return null;
+
+ final PopupContainerWithArrow container =
+ (PopupContainerWithArrow) launcher.getLayoutInflater().inflate(
+ R.layout.popup_container, launcher.getDragLayer(), false);
+ container.setVisibility(View.INVISIBLE);
+ launcher.getDragLayer().addView(container);
+ container.populateAndShow(icon, shortcutIds, notificationKeys);
+ return container;
}
public void populateAndShow(final BubbleTextView originalIcon, final List<String> shortcutIds,
@@ -187,6 +189,9 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
List<DeepShortcutView> shortcutViews = mShortcutsItemView == null
? Collections.EMPTY_LIST
: mShortcutsItemView.getDeepShortcutViews(reverseOrder);
+ List<View> systemShortcutViews = mShortcutsItemView == null
+ ? Collections.EMPTY_LIST
+ : mShortcutsItemView.getSystemShortcutViews(reverseOrder);
if (mNotificationItemView != null) {
BadgeInfo badgeInfo = mLauncher.getPopupDataProvider()
.getBadgeInfoForItem(originalItemInfo);
@@ -208,7 +213,8 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
final Looper workerLooper = LauncherModel.getWorkerLooper();
new Handler(workerLooper).postAtFrontOfQueue(PopupPopulator.createUpdateRunnable(
mLauncher, originalItemInfo, new Handler(Looper.getMainLooper()),
- this, shortcutIds, shortcutViews, notificationKeys, mNotificationItemView));
+ this, shortcutIds, shortcutViews, notificationKeys, mNotificationItemView,
+ systemShortcutViews));
}
private void addDummyViews(BubbleTextView originalIcon,
@@ -216,9 +222,12 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
final Resources res = getResources();
final int spacing = res.getDimensionPixelSize(R.dimen.popup_items_spacing);
final LayoutInflater inflater = mLauncher.getLayoutInflater();
+
int numItems = itemTypesToPopulate.length;
for (int i = 0; i < numItems; i++) {
PopupPopulator.Item itemTypeToPopulate = itemTypesToPopulate[i];
+ PopupPopulator.Item nextItemTypeToPopulate =
+ i < numItems - 1 ? itemTypesToPopulate[i + 1] : null;
final View item = inflater.inflate(itemTypeToPopulate.layoutId, this, false);
if (itemTypeToPopulate == PopupPopulator.Item.NOTIFICATION) {
@@ -228,23 +237,23 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
item.findViewById(R.id.footer).getLayoutParams().height = footerHeight;
}
- boolean itemIsFollowedByDifferentType = i < numItems - 1
- && itemTypesToPopulate[i + 1] != itemTypeToPopulate;
+ boolean shouldAddBottomMargin = nextItemTypeToPopulate != null
+ && itemTypeToPopulate.isShortcut ^ nextItemTypeToPopulate.isShortcut;
item.setAccessibilityDelegate(mAccessibilityDelegate);
- if (itemTypeToPopulate == PopupPopulator.Item.SHORTCUT) {
+ if (itemTypeToPopulate.isShortcut) {
if (mShortcutsItemView == null) {
mShortcutsItemView = (ShortcutsItemView) inflater.inflate(
R.layout.shortcuts_item, this, false);
addView(mShortcutsItemView);
}
- mShortcutsItemView.addDeepShortcutView((DeepShortcutView) item);
- if (itemIsFollowedByDifferentType) {
+ mShortcutsItemView.addShortcutView(item, itemTypeToPopulate, mIsAboveIcon);
+ if (shouldAddBottomMargin) {
((LayoutParams) mShortcutsItemView.getLayoutParams()).bottomMargin = spacing;
}
} else {
addView(item);
- if (itemIsFollowedByDifferentType) {
+ if (shouldAddBottomMargin) {
((LayoutParams) item.getLayoutParams()).bottomMargin = spacing;
}
}
@@ -602,6 +611,16 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra
badgeInfo.getNotificationKeys()));
}
+ @Override
+ protected void onWidgetsBound() {
+ enableWidgets();
+ }
+
+ public boolean enableWidgets() {
+ return mShortcutsItemView != null && mShortcutsItemView.enableWidgets(
+ (ItemInfo) mOriginalIcon.getTag());
+ }
+
private ObjectAnimator createArrowScaleAnim(float scale) {
return LauncherAnimUtils.ofPropertyValuesHolder(
mArrow, new PropertyListBuilder().scale(scale).build());