diff options
Diffstat (limited to 'src')
14 files changed, 145 insertions, 74 deletions
diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java index 89f7286d1..3d71632ce 100644 --- a/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java +++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollBar.java @@ -136,11 +136,11 @@ public class BaseRecyclerViewFastScrollBar { // Setter/getter for the track bar width for animations public void setTrackWidth(int width) { mInvalidateRect.set(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth, - mRv.getHeight()); + mRv.getVisibleHeight()); mTrackWidth = width; updateThumbPath(); mInvalidateRect.union(mThumbOffset.x - mThumbCurvature, 0, mThumbOffset.x + mThumbWidth, - mRv.getHeight()); + mRv.getVisibleHeight()); mRv.invalidate(mInvalidateRect); } @@ -198,7 +198,7 @@ public class BaseRecyclerViewFastScrollBar { if (mIsDragging) { // Update the fastscroller section name at this touch position int top = mRv.getBackgroundPadding().top; - int bottom = mRv.getHeight() - mRv.getBackgroundPadding().bottom - mThumbHeight; + int bottom = top + mRv.getVisibleHeight() - mThumbHeight; float boundedY = (float) Math.max(top, Math.min(bottom, y - mTouchOffset)); String sectionName = mRv.scrollToPositionAtProgress((boundedY - top) / (bottom - top)); @@ -230,7 +230,8 @@ public class BaseRecyclerViewFastScrollBar { // Draw the scroll bar track and thumb if (mTrackPaint.getAlpha() > 0) { - canvas.drawRect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, mRv.getHeight(), mTrackPaint); + canvas.drawRect(mThumbOffset.x, 0, mThumbOffset.x + mThumbWidth, + mRv.getVisibleHeight(), mTrackPaint); } canvas.drawPath(mThumbPath, mThumbPaint); diff --git a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java index b4567c53c..b9e627775 100644 --- a/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java +++ b/src/com/android/launcher3/BaseRecyclerViewFastScrollPopup.java @@ -112,7 +112,7 @@ public class BaseRecyclerViewFastScrollPopup { } mBgBounds.top = lastTouchY - (int) (FAST_SCROLL_OVERLAY_Y_OFFSET_FACTOR * bgHeight); mBgBounds.top = Math.max(edgePadding, - Math.min(mBgBounds.top, mRv.getHeight() - edgePadding - bgHeight)); + Math.min(mBgBounds.top, mRv.getVisibleHeight() - edgePadding - bgHeight)); mBgBounds.bottom = mBgBounds.top + bgHeight; // Generate a bitmap for a shadow matching these bounds diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index adf07a1ca..886c5f0a2 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1090,6 +1090,9 @@ public class Launcher extends Activity if (!isWorkspaceLoading()) { // Process any items that were added while Launcher was away. InstallShortcutReceiver.disableAndFlushInstallQueue(this); + + // Refresh shortcuts if the permission changed. + mModel.refreshShortcutsIfRequired(); } if (shouldShowDiscoveryBounce()) { diff --git a/src/com/android/launcher3/LauncherModel.java b/src/com/android/launcher3/LauncherModel.java index a51fd07e4..6a63110b1 100644 --- a/src/com/android/launcher3/LauncherModel.java +++ b/src/com/android/launcher3/LauncherModel.java @@ -146,6 +146,20 @@ public class LauncherModel extends BroadcastReceiver // Maps all launcher activities to the id's of their shortcuts (if they have any). private final MultiHashMap<ComponentKey, String> mBgDeepShortcutMap = new MultiHashMap<>(); + private boolean mHasShortcutHostPermission; + // Runnable to check if the shortcuts permission has changed. + private final Runnable mShortcutPermissionCheckRunnable = new Runnable() { + @Override + public void run() { + if (mDeepShortcutsLoaded) { + boolean hasShortcutHostPermission = mDeepShortcutManager.hasHostPermission(); + if (hasShortcutHostPermission != mHasShortcutHostPermission) { + mApp.reloadWorkspace(); + } + } + } + }; + // The lock that must be acquired before referencing any static bg data structures. Unlike // other locks, this one can generally be held long-term because we never expect any of these // static data structures to be referenced outside of the worker thread except on the first @@ -1244,6 +1258,7 @@ public class LauncherModel extends BroadcastReceiver if (resetAllAppsLoaded) mAllAppsLoaded = false; if (resetWorkspaceLoaded) mWorkspaceLoaded = false; // Always reset deep shortcuts loaded. + // TODO: why? mDeepShortcutsLoaded = false; } } @@ -1299,6 +1314,7 @@ public class LauncherModel extends BroadcastReceiver // If there is already one running, tell it to stop. stopLoaderLocked(); mLoaderTask = new LoaderTask(mApp.getContext(), synchronousBindPage); + // TODO: mDeepShortcutsLoaded does not need to be true for synchronous bind. if (synchronousBindPage != PagedView.INVALID_RESTORE_PAGE && mAllAppsLoaded && mWorkspaceLoaded && mDeepShortcutsLoaded && !mIsLoaderTaskRunning) { mLoaderTask.runBindSynchronousPage(synchronousBindPage); @@ -2793,11 +2809,14 @@ public class LauncherModel extends BroadcastReceiver } if (!mDeepShortcutsLoaded) { mBgDeepShortcutMap.clear(); - for (UserHandleCompat user : mUserManager.getUserProfiles()) { - if (mUserManager.isUserUnlocked(user)) { - List<ShortcutInfoCompat> shortcuts = mDeepShortcutManager - .queryForAllShortcuts(user); - updateDeepShortcutMap(null, user, shortcuts); + mHasShortcutHostPermission = mDeepShortcutManager.hasHostPermission(); + if (mHasShortcutHostPermission) { + for (UserHandleCompat user : mUserManager.getUserProfiles()) { + if (mUserManager.isUserUnlocked(user)) { + List<ShortcutInfoCompat> shortcuts = mDeepShortcutManager + .queryForAllShortcuts(user); + updateDeepShortcutMap(null, user, shortcuts); + } } } synchronized (LoaderTask.this) { @@ -2849,8 +2868,7 @@ public class LauncherModel extends BroadcastReceiver } public void bindDeepShortcuts() { - final MultiHashMap<ComponentKey, String> shortcutMapCopy = new MultiHashMap<>(); - shortcutMapCopy.putAll(mBgDeepShortcutMap); + final MultiHashMap<ComponentKey, String> shortcutMapCopy = mBgDeepShortcutMap.clone(); Runnable r = new Runnable() { @Override public void run() { @@ -2864,6 +2882,18 @@ public class LauncherModel extends BroadcastReceiver } /** + * Refreshes the cached shortcuts if the shortcut permission has changed. + * Current implementation simply reloads the workspace, but it can be optimized to + * use partial updates similar to {@link UserManagerCompat} + */ + public void refreshShortcutsIfRequired() { + if (Utilities.isNycMR1OrAbove()) { + sWorker.removeCallbacks(mShortcutPermissionCheckRunnable); + sWorker.post(mShortcutPermissionCheckRunnable); + } + } + + /** * Called when the icons for packages have been updated in the icon cache. */ public void onPackageIconsUpdated(HashSet<String> updatedPackages, UserHandleCompat user) { diff --git a/src/com/android/launcher3/LauncherStateTransitionAnimation.java b/src/com/android/launcher3/LauncherStateTransitionAnimation.java index 2b1ebdebe..eb70650b2 100644 --- a/src/com/android/launcher3/LauncherStateTransitionAnimation.java +++ b/src/com/android/launcher3/LauncherStateTransitionAnimation.java @@ -265,7 +265,6 @@ public class LauncherStateTransitionAnimation { toView.setScaleY(1.0f); toView.setAlpha(1.0f); toView.setVisibility(View.VISIBLE); - toView.bringToFront(); // Show the content view contentView.setVisibility(View.VISIBLE); diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java index d8601893e..c7bc23bd4 100644 --- a/src/com/android/launcher3/allapps/AllAppsContainerView.java +++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java @@ -259,13 +259,19 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc /** * Returns whether the view itself will handle the touch event or not. */ - public boolean shouldContainerScroll(float x, float y) { + public boolean shouldContainerScroll(MotionEvent ev) { int[] point = new int[2]; - point[0] = (int) x; - point[1] = (int) y; + point[0] = (int) ev.getX(); + point[1] = (int) ev.getY(); Utilities.mapCoordInSelfToDescendent(mAppsRecyclerView, this, point); - // if the MotionEvent is inside the thumb, container should not be pulled down. + // IF the MotionEvent is inside the search box, and the container keeps on receiving + // touch input, container should move down. + if (mLauncher.getDragLayer().isEventOverView(mSearchContainer, ev)) { + return true; + } + + // IF the MotionEvent is inside the thumb, container should not be pulled down. if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])) { return false; } @@ -464,7 +470,7 @@ public class AllAppsContainerView extends BaseContainerView implements DragSourc MarginLayoutParams mlp = (MarginLayoutParams) mAppsRecyclerView.getLayoutParams(); Rect insets = mLauncher.getDragLayer().getInsets(); - getContentView().setPadding(0, 0, 0, insets.bottom); + getContentView().setPadding(0, 0, 0, 0); int height = insets.top + grid.hotseatCellHeightPx; mlp.topMargin = height; diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java index d8f9fb189..39ab58b8f 100644 --- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java +++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java @@ -38,7 +38,6 @@ import android.widget.TextView; import com.android.launcher3.AppInfo; import com.android.launcher3.BubbleTextView; -import com.android.launcher3.CellLayout; import com.android.launcher3.DeviceProfile; import com.android.launcher3.Launcher; import com.android.launcher3.R; @@ -49,7 +48,6 @@ import com.android.launcher3.shortcuts.ShortcutsContainerListener; import java.util.HashMap; import java.util.List; - /** * The grid view adapter of all the apps. */ @@ -134,6 +132,11 @@ public class AllAppsGridAdapter extends RecyclerView.Adapter<AllAppsGridAdapter. return super.getRowCountForAccessibility(recycler, state); } } + + @Override + public int getPaddingBottom() { + return mLauncher.getDragLayer().getInsets().bottom; + } } /** diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java index 55f544caa..25ed3b8ec 100644 --- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java +++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java @@ -28,6 +28,7 @@ import com.android.launcher3.BaseRecyclerView; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DeviceProfile; import com.android.launcher3.ItemInfo; +import com.android.launcher3.Launcher; import com.android.launcher3.R; import com.android.launcher3.logging.UserEventDispatcher.LaunchSourceProvider; import com.android.launcher3.userevent.nano.LauncherLogProto; @@ -208,12 +209,8 @@ public class AllAppsRecyclerView extends BaseRecyclerView @Override public void fillInLaunchSourceData(View v, ItemInfo info, Target target, Target targetParent) { - targetParent.containerType = getContainerType(v); - } - - public int getContainerType(View v) { if (mApps.hasFilter()) { - return LauncherLogProto.SEARCHRESULT; + targetParent.containerType = LauncherLogProto.SEARCHRESULT; } else { if (v instanceof BubbleTextView) { BubbleTextView icon = (BubbleTextView) v; @@ -222,11 +219,12 @@ public class AllAppsRecyclerView extends BaseRecyclerView List<AlphabeticalAppsList.AdapterItem> items = mApps.getAdapterItems(); AlphabeticalAppsList.AdapterItem item = items.get(position); if (item.viewType == AllAppsGridAdapter.VIEW_TYPE_PREDICTION_ICON) { - return LauncherLogProto.PREDICTION; + targetParent.containerType = LauncherLogProto.PREDICTION; + return; } } } - return LauncherLogProto.ALLAPPS; + targetParent.containerType = LauncherLogProto.ALLAPPS; } } @@ -423,6 +421,12 @@ public class AllAppsRecyclerView extends BaseRecyclerView return getPaddingTop() + y - offset; } + @Override + protected int getVisibleHeight() { + return super.getVisibleHeight() + - Launcher.getLauncher(getContext()).getDragLayer().getInsets().bottom; + } + /** * Returns the available scroll height: * AvailableScrollHeight = Total height of the all items - last page height diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index b0a62e1de..588823051 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -111,7 +111,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul if (mLauncher.getWorkspace().isInOverviewMode() || mLauncher.isWidgetsViewVisible()) { mNoIntercept = true; } else if (mLauncher.isAllAppsVisible() && - !mAppsView.shouldContainerScroll(ev.getX(), ev.getY())) { + !mAppsView.shouldContainerScroll(ev)) { mNoIntercept = true; } else if (!mLauncher.isAllAppsVisible() && !shouldPossiblyIntercept(ev)) { mNoIntercept = true; @@ -262,10 +262,10 @@ public class AllAppsTransitionController implements TouchController, VerticalPul // Initialize values that should not change until #onDragEnd mStatusBarHeight = mLauncher.getDragLayer().getInsets().top; mHotseat.setVisibility(View.VISIBLE); + mHotseatBackgroundColor = mHotseat.getBackgroundDrawableColor(); + mHotseat.setBackgroundTransparent(true /* transparent */); if (!mLauncher.isAllAppsVisible()) { mLauncher.tryAndUpdatePredictedApps(); - mHotseatBackgroundColor = mHotseat.getBackgroundDrawableColor(); - mHotseat.setBackgroundTransparent(true /* transparent */); mAppsView.setVisibility(View.VISIBLE); mAppsView.setRevealDrawableColor(mHotseatBackgroundColor); } diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 448f70943..e88e77e20 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -207,7 +207,7 @@ public class DragLayer extends InsettableFrameLayout { return isEventOverView(mLauncher.getDropTargetBar(), ev); } - private boolean isEventOverView(View view, MotionEvent ev) { + public boolean isEventOverView(View view, MotionEvent ev) { getDescendantRectRelativeToSelf(view, mHitRect); return mHitRect.contains((int) ev.getX(), (int) ev.getY()); } diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java index e780cc91b..64a5f573d 100644 --- a/src/com/android/launcher3/logging/UserEventDispatcher.java +++ b/src/com/android/launcher3/logging/UserEventDispatcher.java @@ -147,12 +147,14 @@ public class UserEventDispatcher { dispatchUserEvent(event, null); } - public void logDeepShortcutsOpen(int containerType) { + public void logDeepShortcutsOpen(View icon) { LauncherEvent event = LoggerUtils.initLauncherEvent( Action.TOUCH, Target.ITEM, Target.CONTAINER); - event.action.touch = Action.LONGPRESS; + LaunchSourceProvider provider = getLaunchProviderRecursive(icon); + ItemInfo info = (ItemInfo) icon.getTag(); + provider.fillInLaunchSourceData(icon, info, event.srcTarget[0], event.srcTarget[1]); event.srcTarget[0].itemType = LauncherLogProto.DEEPSHORTCUT; - event.srcTarget[1].containerType = containerType; + event.action.touch = Action.LONGPRESS; event.elapsedContainerMillis = System.currentTimeMillis() - mElapsedContainerMillis; event.elapsedSessionMillis = System.currentTimeMillis() - mElapsedSessionMillis; dispatchUserEvent(event, null); diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java index 05ab84361..49d6fa932 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutManager.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutManager.java @@ -224,4 +224,16 @@ public class DeepShortcutManager { return Collections.EMPTY_LIST; } } + + @TargetApi(25) + public boolean hasHostPermission() { + if (Utilities.isNycMR1OrAbove()) { + try { + return mLauncherApps.hasShortcutHostPermission(); + } catch (SecurityException|IllegalStateException e) { + Log.e(TAG, "Failed to make shortcut manager call", e); + } + } + return false; + } } diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java index a341b973c..cfeccfc1a 100644 --- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java +++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java @@ -33,7 +33,6 @@ import android.os.Handler; import android.os.Looper; import android.text.TextUtils; import android.util.AttributeSet; -import android.util.Log; import android.view.Gravity; import android.view.HapticFeedbackConstants; import android.view.LayoutInflater; @@ -54,19 +53,16 @@ import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherModel; -import com.android.launcher3.LauncherSettings; import com.android.launcher3.LauncherViewPropertyAnimator; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; import com.android.launcher3.Utilities; import com.android.launcher3.Workspace; import com.android.launcher3.accessibility.ShortcutMenuAccessibilityDelegate; -import com.android.launcher3.allapps.AllAppsRecyclerView; import com.android.launcher3.compat.UserHandleCompat; import com.android.launcher3.dragndrop.DragController; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragView; -import com.android.launcher3.folder.Folder; import com.android.launcher3.graphics.TriangleShape; import com.android.launcher3.logging.UserEventDispatcher; import com.android.launcher3.userevent.nano.LauncherLogProto; @@ -134,6 +130,14 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC } public void populateAndShow(final BubbleTextView originalIcon, final List<String> ids) { + final Resources resources = getResources(); + final int arrowWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_width); + final int arrowHeight = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_height); + mArrowHorizontalOffset = resources.getDimensionPixelSize( + R.dimen.deep_shortcuts_arrow_horizontal_offset); + final int arrowVerticalOffset = resources.getDimensionPixelSize( + R.dimen.deep_shortcuts_arrow_vertical_offset); + // Add dummy views first, and populate with real shortcut info when ready. final int spacing = getResources().getDimensionPixelSize(R.dimen.deep_shortcuts_spacing); final LayoutInflater inflater = mLauncher.getLayoutInflater(); @@ -151,16 +155,9 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC numShortcuts, originalIcon.getContentDescription().toString())); measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); - orientAboutIcon(originalIcon); + orientAboutIcon(originalIcon, arrowHeight + arrowVerticalOffset); // Add the arrow. - final Resources resources = getResources(); - final int arrowWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_width); - final int arrowHeight = resources.getDimensionPixelSize(R.dimen.deep_shortcuts_arrow_height); - mArrowHorizontalOffset = resources.getDimensionPixelSize( - R.dimen.deep_shortcuts_arrow_horizontal_offset); - final int arrowVerticalOffset = resources.getDimensionPixelSize( - R.dimen.deep_shortcuts_arrow_vertical_offset); mArrow = addArrowView(mArrowHorizontalOffset, arrowVerticalOffset, arrowWidth, arrowHeight); mArrow.setPivotX(arrowWidth / 2); mArrow.setPivotY(mIsAboveIcon ? 0 : arrowHeight); @@ -308,9 +305,9 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC * So we always align left if there is enough horizontal space * and align above if there is enough vertical space. */ - private void orientAboutIcon(BubbleTextView icon) { + private void orientAboutIcon(BubbleTextView icon, int arrowHeight) { int width = getMeasuredWidth(); - int height = getMeasuredHeight(); + int height = getMeasuredHeight() + arrowHeight; DragLayer dragLayer = mLauncher.getDragLayer(); dragLayer.getDescendantRectRelativeToSelf(icon, mTempRect); @@ -352,10 +349,12 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC x += mIsLeftAligned ? xOffset : -xOffset; // Open above icon if there is room. - int y = mTempRect.top - height; - mIsAboveIcon = mTempRect.top - height > dragLayer.getTop() + insets.top; + int iconHeight = icon.getIcon().getBounds().height(); + int y = mTempRect.top + icon.getPaddingTop() - height; + mIsAboveIcon = y > dragLayer.getTop() + insets.top; if (!mIsAboveIcon) { - y = mTempRect.bottom; + y = mTempRect.top + icon.getPaddingTop() + iconHeight; + icon.setTextVisibility(false); } // Insets are added later, so subtract them now. @@ -476,6 +475,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC } } else if (action == MotionEvent.ACTION_UP) { cleanupDeferredDrag(true); + mLauncher.getUserEventDispatcher().logDeepShortcutsOpen(mDeferredDragIcon); } else if (action == MotionEvent.ACTION_CANCEL) { // Do not change the source icon visibility if we are already dragging the source icon. cleanupDeferredDrag(!mSrcIconDragStarted); @@ -563,7 +563,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC @Override public boolean supportsDeleteDropTarget() { - return true; + return false; } @Override @@ -715,6 +715,7 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC mDeferContainerRemoval = false; // Make the original icon visible in All Apps, but not in Workspace or Folders. cleanupDeferredDrag(mDeferredDragIcon.getTag() instanceof AppInfo); + mDeferredDragIcon.setTextVisibility(true); mLauncher.getDragController().removeDragListener(this); mLauncher.getDragLayer().removeView(this); } @@ -745,33 +746,11 @@ public class DeepShortcutsContainer extends LinearLayout implements View.OnLongC container.populateAndShow(icon, ids); icon.performHapticFeedback(HapticFeedbackConstants.LONG_PRESS, HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); - logOpen(launcher, icon); return container; } return null; } - private static void logOpen(Launcher launcher, View icon) { - ItemInfo info = (ItemInfo) icon.getTag(); - long iconContainer = info.container; - Folder openFolder = launcher.getWorkspace().getOpenFolder(); - int containerType; - if (iconContainer == LauncherSettings.Favorites.CONTAINER_DESKTOP) { - containerType = LauncherLogProto.WORKSPACE; - } else if (iconContainer == LauncherSettings.Favorites.CONTAINER_HOTSEAT) { - containerType = LauncherLogProto.HOTSEAT; - } else if (openFolder != null && iconContainer == openFolder.getInfo().id) { - containerType = LauncherLogProto.FOLDER; - } else if (icon.getParent() instanceof AllAppsRecyclerView) { - containerType = ((AllAppsRecyclerView) icon.getParent()).getContainerType(icon); - } else { - // This should not happen. - Log.w(TAG, "Couldn't determine parent of shortcut container"); - containerType = LauncherLogProto.DEFAULT_CONTAINERTYPE; - } - launcher.getUserEventDispatcher().logDeepShortcutsOpen(containerType); - } - /** * Extension of {@link ShortcutInfo} which does not badge the icons. */ diff --git a/src/com/android/launcher3/util/MultiHashMap.java b/src/com/android/launcher3/util/MultiHashMap.java index f54ab8840..b7275c1f7 100644 --- a/src/com/android/launcher3/util/MultiHashMap.java +++ b/src/com/android/launcher3/util/MultiHashMap.java @@ -1,3 +1,19 @@ +/* + * Copyright (C) 2016 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package com.android.launcher3.util; import java.util.ArrayList; @@ -7,6 +23,13 @@ import java.util.HashMap; * A utility map from keys to an ArrayList of values. */ public class MultiHashMap<K, V> extends HashMap<K, ArrayList<V>> { + + public MultiHashMap() { } + + public MultiHashMap(int size) { + super(size); + } + public void addToList(K key, V value) { ArrayList<V> list = get(key); if (list == null) { @@ -17,4 +40,13 @@ public class MultiHashMap<K, V> extends HashMap<K, ArrayList<V>> { list.add(value); } } + + @Override + public MultiHashMap<K, V> clone() { + MultiHashMap<K, V> map = new MultiHashMap<>(size()); + for (Entry<K, ArrayList<V>> entry : entrySet()) { + map.put(entry.getKey(), new ArrayList<V>(entry.getValue())); + } + return map; + } } |