Merge "Moving the shortcut application logic to the DeepShortcutView. This makes the logic for accessing various properties consistant and and ties it to the UI of the DeepShortcutView." into ub-launcher3-calgary-polish
diff --git a/res/values-fr/strings.xml b/res/values-fr/strings.xml
index 9c52739..8154c66 100644
--- a/res/values-fr/strings.xml
+++ b/res/values-fr/strings.xml
@@ -68,7 +68,7 @@
     <string name="msg_disabled_by_admin" msgid="6898038085516271325">"Désactivé par votre administrateur"</string>
     <string name="accessibility_action_overview" msgid="6257665857640347026">"Vue d\'ensemble"</string>
     <string name="allow_rotation_title" msgid="7728578836261442095">"Autoriser la rotation de l\'écran d\'accueil"</string>
-    <string name="allow_rotation_desc" msgid="8662546029078692509">"Lorsque l\'utilisateur fait pivoter le téléphone"</string>
+    <string name="allow_rotation_desc" msgid="8662546029078692509">"Lorsque vous faites pivoter le téléphone"</string>
     <string name="allow_rotation_blocked_desc" msgid="3212602545192996253">"Le paramètre d\'affichage actuel n\'autorise pas la rotation."</string>
     <string name="package_state_unknown" msgid="7592128424511031410">"Inconnu"</string>
     <string name="abandoned_clean_this" msgid="7610119707847920412">"Supprimer"</string>
diff --git a/res/values-sv/strings.xml b/res/values-sv/strings.xml
index c3e60fc..1d405ba 100644
--- a/res/values-sv/strings.xml
+++ b/res/values-sv/strings.xml
@@ -68,7 +68,7 @@
     <string name="msg_disabled_by_admin" msgid="6898038085516271325">"Inaktiverat av administratören"</string>
     <string name="accessibility_action_overview" msgid="6257665857640347026">"Översikt"</string>
     <string name="allow_rotation_title" msgid="7728578836261442095">"Tillåt rotering av startskärmen"</string>
-    <string name="allow_rotation_desc" msgid="8662546029078692509">"När mobilen roterar"</string>
+    <string name="allow_rotation_desc" msgid="8662546029078692509">"När mobilen vrids"</string>
     <string name="allow_rotation_blocked_desc" msgid="3212602545192996253">"Rotering tillåts inte i de nuvarande skärminställningarna"</string>
     <string name="package_state_unknown" msgid="7592128424511031410">"Okänt"</string>
     <string name="abandoned_clean_this" msgid="7610119707847920412">"Ta bort"</string>
diff --git a/src/com/android/launcher3/PagedView.java b/src/com/android/launcher3/PagedView.java
index 2758a7c..bea55d2 100644
--- a/src/com/android/launcher3/PagedView.java
+++ b/src/com/android/launcher3/PagedView.java
@@ -1800,6 +1800,7 @@
         case MotionEvent.ACTION_CANCEL:
             if (mTouchState == TOUCH_STATE_SCROLLING) {
                 snapToDestination();
+                onScrollInteractionEnd();
             }
             resetTouchState();
             break;
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 09076b3..25ed3b8 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -209,12 +209,8 @@
 
     @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;
@@ -223,11 +219,12 @@
                     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;
         }
     }
 
diff --git a/src/com/android/launcher3/logging/UserEventDispatcher.java b/src/com/android/launcher3/logging/UserEventDispatcher.java
index e780cc9..64a5f57 100644
--- a/src/com/android/launcher3/logging/UserEventDispatcher.java
+++ b/src/com/android/launcher3/logging/UserEventDispatcher.java
@@ -147,12 +147,14 @@
         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/DeepShortcutsContainer.java b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
index 5d9025a..4d10506 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutsContainer.java
@@ -33,7 +33,6 @@
 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.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;
@@ -460,6 +456,7 @@
             }
         } 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);
@@ -723,33 +720,11 @@
             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.
      */