[automerger skipped] Import translations. DO NOT MERGE ANYWHERE am: 3c8c47778f -s ours

am skip reason: subject contains skip directive

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/Launcher3/+/18515845

Change-Id: I25108edb99bb4b01ead60019fc4680e090cee1cd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
diff --git a/go/quickstep/src/com/android/launcher3/AppSharing.java b/go/quickstep/src/com/android/launcher3/AppSharing.java
index e717937..cb1f1c7 100644
--- a/go/quickstep/src/com/android/launcher3/AppSharing.java
+++ b/go/quickstep/src/com/android/launcher3/AppSharing.java
@@ -16,6 +16,8 @@
 
 package com.android.launcher3;
 
+import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP;
+
 import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
@@ -123,6 +125,8 @@
 
         @Override
         public void onClick(View view) {
+            ActivityContext.lookupContext(view.getContext())
+                    .getStatsLogManager().logger().log(LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP);
             if (!isEnabled()) {
                 showCannotShareToast(view.getContext());
                 return;
diff --git a/res/layout/work_apps_edu.xml b/res/layout/work_apps_edu.xml
index f3b3053..aa7c998 100644
--- a/res/layout/work_apps_edu.xml
+++ b/res/layout/work_apps_edu.xml
@@ -56,6 +56,7 @@
                     android:layout_height="@dimen/x_icon_size"
                     android:layout_gravity="center"
                     android:padding="@dimen/x_icon_padding"
+                    android:contentDescription="@string/accessibility_close"
                     android:src="@drawable/ic_remove_no_shadow" />
             </FrameLayout>
         </RelativeLayout>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index 7b2ed8b..c16792a 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -31,7 +31,6 @@
     <dimen name="drop_target_button_drawable_horizontal_padding">24dp</dimen>
     <dimen name="drop_target_button_drawable_vertical_padding">20dp</dimen>
     <dimen name="drop_target_button_gap">32dp</dimen>
-    <dimen name="drop_target_button_workspace_edge_gap">32dp</dimen>
     <dimen name="drop_target_top_margin">110dp</dimen>
     <dimen name="drop_target_bottom_margin">48dp</dimen>
 
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2612a7d..766dca3 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -241,8 +241,6 @@
     <dimen name="drop_target_button_drawable_horizontal_padding">16dp</dimen>
     <dimen name="drop_target_button_drawable_vertical_padding">8dp</dimen>
     <dimen name="drop_target_button_gap">28dp</dimen>
-    <dimen name="drop_target_button_workspace_edge_gap">0dp</dimen>
-    <dimen name="drop_target_button_screen_edge_gap">28dp</dimen>
 
     <!-- the distance an icon must be dragged before button drop targets accept it -->
     <dimen name="drag_distanceThreshold">30dp</dimen>
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 5152217..3ddc90e 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -215,8 +215,6 @@
     public int dropTargetHorizontalPaddingPx;
     public int dropTargetVerticalPaddingPx;
     public int dropTargetGapPx;
-    public int dropTargetButtonWorkspaceEdgeGapPx;
-    public int dropTargetButtonScreenEdgeGapPx;
 
     // Insets
     private final Rect mInsets = new Rect();
@@ -344,10 +342,6 @@
         dropTargetVerticalPaddingPx = res.getDimensionPixelSize(
                 R.dimen.drop_target_button_drawable_vertical_padding);
         dropTargetGapPx = res.getDimensionPixelSize(R.dimen.drop_target_button_gap);
-        dropTargetButtonWorkspaceEdgeGapPx = res.getDimensionPixelSize(
-                R.dimen.drop_target_button_workspace_edge_gap);
-        dropTargetButtonScreenEdgeGapPx = res.getDimensionPixelSize(
-                R.dimen.drop_target_button_screen_edge_gap);
 
         workspaceSpringLoadedBottomSpace =
                 res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
@@ -1410,10 +1404,6 @@
         writer.println(prefix + pxToDpStr("dropTargetBarSizePx", dropTargetBarSizePx));
         writer.println(
                 prefix + pxToDpStr("dropTargetBarBottomMarginPx", dropTargetBarBottomMarginPx));
-        writer.println(prefix + pxToDpStr("dropTargetButtonWorkspaceEdgeGapPx",
-                dropTargetButtonWorkspaceEdgeGapPx));
-        writer.println(prefix + pxToDpStr("dropTargetButtonScreenEdgeGapPx",
-                dropTargetButtonScreenEdgeGapPx));
 
         writer.println(
                 prefix + pxToDpStr("workspaceSpringLoadShrunkTop", workspaceSpringLoadShrunkTop));
diff --git a/src/com/android/launcher3/DropTargetBar.java b/src/com/android/launcher3/DropTargetBar.java
index 6a8ba1b..dbddb26 100644
--- a/src/com/android/launcher3/DropTargetBar.java
+++ b/src/com/android/launcher3/DropTargetBar.java
@@ -162,6 +162,10 @@
             ButtonDropTarget firstButton = mTempTargets[0];
             firstButton.setTextVisible(true);
             firstButton.setIconVisible(true);
+            firstButton.setTextMultiLine(false);
+            // Reset second button padding in case it was previously changed to multi-line text.
+            firstButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
+                    verticalPadding);
 
             ButtonDropTarget secondButton = mTempTargets[1];
             secondButton.setTextVisible(true);
@@ -171,56 +175,38 @@
             secondButton.setPadding(horizontalPadding, verticalPadding, horizontalPadding,
                     verticalPadding);
 
+            float scale = dp.getWorkspaceSpringLoadScale();
+            int scaledPanelWidth = (int) (dp.getCellLayoutWidth() * scale);
+
+            int availableWidth;
             if (dp.isTwoPanels) {
                 // Both buttons for two panel fit to the width of one Cell Layout (less
                 // half of the center gap between the buttons).
-                float scale = dp.getWorkspaceSpringLoadScale();
-                int scaledPanelWidth = (int) (dp.getCellLayoutWidth() * scale);
                 int halfButtonGap = dp.dropTargetGapPx / 2;
-                scaledPanelWidth -= halfButtonGap / 2;
-
-                int widthSpec = MeasureSpec.makeMeasureSpec(scaledPanelWidth, MeasureSpec.AT_MOST);
-                firstButton.measure(widthSpec, heightSpec);
-                secondButton.measure(widthSpec, heightSpec);
+                availableWidth = scaledPanelWidth - halfButtonGap / 2;
             } else {
-                int availableWidth;
-                int buttonGap = dp.dropTargetGapPx;
-                if (mIsVertical) {
-                    // Both buttons plus the button gap do not display past the edge of the
-                    // scaled workspace, less a pre-defined gap from the edge of the workspace.
-                    float scale = dp.getWorkspaceSpringLoadScale();
-                    int panelWidth = (int) (dp.getCellLayoutWidth() * scale);
-                    availableWidth = Math.min(
-                            panelWidth - (2 * dp.dropTargetButtonWorkspaceEdgeGapPx), width);
-                } else {
-                    // Both buttons plus the button gap display up to a pre-defined margin of
-                    // the unscaled workspace edge.
-                    availableWidth = Math.min(
-                            dp.availableWidthPx - (2 * dp.dropTargetButtonScreenEdgeGapPx),
-                            width);
-                }
-                int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth - buttonGap,
-                        MeasureSpec.AT_MOST);
+                // Both buttons plus the button gap do not display past the edge of the scaled
+                // workspace.
+                availableWidth = (scaledPanelWidth - dp.dropTargetGapPx) / 2;
+            }
 
-                // First button's width is at most the drop target bar's total width less the button
-                // gap.
-                firstButton.measure(widthSpec, heightSpec);
+            int widthSpec = MeasureSpec.makeMeasureSpec(availableWidth, MeasureSpec.AT_MOST);
+            firstButton.measure(widthSpec, heightSpec);
+            secondButton.measure(widthSpec, heightSpec);
 
-                int usedWidth = firstButton.getMeasuredWidth() + buttonGap;
-                int remainingWidth = availableWidth - usedWidth;
-                widthSpec = MeasureSpec.makeMeasureSpec(remainingWidth, MeasureSpec.AT_MOST);
-                secondButton.measure(widthSpec, heightSpec);
-
-                // Remove both icons and put the second button's text on two lines if text is
-                // truncated on phones. We assume first button's text is never truncated, so it
-                // remains single-line.
-                if (secondButton.isTextTruncated(remainingWidth) && !mIsVertical) {
+            if (!mIsVertical) {
+                // Remove icons and put the button's text on two lines if text is truncated.
+                if (firstButton.isTextTruncated(availableWidth)) {
                     firstButton.setIconVisible(false);
+                    firstButton.setTextMultiLine(true);
+                    firstButton.setPadding(horizontalPadding, verticalPadding / 2,
+                            horizontalPadding, verticalPadding / 2);
+                }
+                if (secondButton.isTextTruncated(availableWidth)) {
                     secondButton.setIconVisible(false);
                     secondButton.setTextMultiLine(true);
-                    secondButton.setPadding(secondButton.getPaddingLeft(),
-                            secondButton.getPaddingTop() / 2, secondButton.getPaddingRight(),
-                            secondButton.getPaddingBottom() / 2);
+                    secondButton.setPadding(horizontalPadding, verticalPadding / 2,
+                            horizontalPadding, verticalPadding / 2);
                 }
             }
         }
@@ -235,16 +221,18 @@
         }
 
         DeviceProfile dp = mLauncher.getDeviceProfile();
-        int barCenter = (right - left) / 2;
-        if (mIsVertical) {
-            // Center vertical bar over scaled workspace, accounting for hotseat offset.
-            float scale = dp.getWorkspaceSpringLoadScale();
-            Workspace<?> ws = mLauncher.getWorkspace();
+        // Center vertical bar over scaled workspace, accounting for hotseat offset.
+        float scale = dp.getWorkspaceSpringLoadScale();
+        Workspace<?> ws = mLauncher.getWorkspace();
+        int barCenter;
+        if (dp.isTwoPanels) {
+            barCenter = (right - left) / 2;
+        } else {
             int workspaceCenter = (ws.getLeft() + ws.getRight()) / 2;
             int cellLayoutCenter = ((dp.getInsets().left + dp.workspacePadding.left) + (dp.widthPx
                     - dp.getInsets().right - dp.workspacePadding.right)) / 2;
             int cellLayoutCenterOffset = (int) ((cellLayoutCenter - workspaceCenter) * scale);
-            barCenter = workspaceCenter + cellLayoutCenterOffset;
+            barCenter = workspaceCenter + cellLayoutCenterOffset - left;
         }
 
         if (visibleCount == 1) {
@@ -254,46 +242,14 @@
         } else if (visibleCount == 2) {
             int buttonGap = dp.dropTargetGapPx;
 
-            if (dp.isTwoPanels) {
-                ButtonDropTarget leftButton = mTempTargets[0];
-                leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
-                        barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
+            ButtonDropTarget leftButton = mTempTargets[0];
+            leftButton.layout(barCenter - leftButton.getMeasuredWidth() - (buttonGap / 2), 0,
+                    barCenter - (buttonGap / 2), leftButton.getMeasuredHeight());
 
-                ButtonDropTarget rightButton = mTempTargets[1];
-                rightButton.layout(barCenter + (buttonGap / 2), 0,
-                        barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
-                        rightButton.getMeasuredHeight());
-            } else {
-                int start;
-                int end;
-                if (mIsVertical) {
-                    // Scaled CellLayout width is assumed to not exceed the bounds of left/right.
-                    float scale = dp.getWorkspaceSpringLoadScale();
-                    int panelWidth = (int) (dp.getCellLayoutWidth() * scale);
-                    start = barCenter - (panelWidth / 2) + dp.dropTargetButtonWorkspaceEdgeGapPx;
-                    end = barCenter + (panelWidth / 2) - dp.dropTargetButtonWorkspaceEdgeGapPx;
-                } else {
-                    start = Math.max(dp.dropTargetButtonScreenEdgeGapPx, left);
-                    end = Math.min(dp.availableWidthPx - dp.dropTargetButtonScreenEdgeGapPx, right);
-                }
-
-                ButtonDropTarget leftButton = mTempTargets[0];
-                ButtonDropTarget rightButton = mTempTargets[1];
-
-                int leftButtonWidth = leftButton.getMeasuredWidth();
-                int rightButtonWidth = rightButton.getMeasuredWidth();
-                int buttonPlusGapWidth = leftButtonWidth + buttonGap + rightButtonWidth;
-
-                int extraSpace = end - start - buttonPlusGapWidth;
-                start = (start - left) + (extraSpace / 2);
-
-                leftButton.layout(start, 0, start + leftButtonWidth,
-                        leftButton.getMeasuredHeight());
-
-                int rightButtonStart = start + leftButtonWidth + buttonGap;
-                rightButton.layout(rightButtonStart, 0, rightButtonStart + rightButtonWidth,
-                        rightButton.getMeasuredHeight());
-            }
+            ButtonDropTarget rightButton = mTempTargets[1];
+            rightButton.layout(barCenter + (buttonGap / 2), 0,
+                    barCenter + (buttonGap / 2) + rightButton.getMeasuredWidth(),
+                    rightButton.getMeasuredHeight());
         }
     }
 
diff --git a/src/com/android/launcher3/logging/StatsLogManager.java b/src/com/android/launcher3/logging/StatsLogManager.java
index f4f270c..5dcd48c 100644
--- a/src/com/android/launcher3/logging/StatsLogManager.java
+++ b/src/com/android/launcher3/logging/StatsLogManager.java
@@ -589,6 +589,9 @@
 
         @UiEvent(doc = "User tapped taskbar All Apps button.")
         LAUNCHER_TASKBAR_ALLAPPS_BUTTON_TAP(1057),
+
+        @UiEvent(doc = "User tapped on Share app system shortcut.")
+        LAUNCHER_SYSTEM_SHORTCUT_APP_SHARE_TAP(1075),
         ;
 
         // ADD MORE
diff --git a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
index 73aa296..a2ab7f9 100644
--- a/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
+++ b/src/com/android/launcher3/secondarydisplay/SecondaryDisplayLauncher.java
@@ -53,7 +53,6 @@
     private LauncherModel mModel;
 
     private BaseDragLayer mDragLayer;
-    // TODO(b/216191717): Verify all apps works on secondary display.
     private ActivityAllAppsContainerView<SecondaryDisplayLauncher> mAppsView;
     private View mAppsButton;
 
diff --git a/src/com/android/launcher3/util/OnboardingPrefs.java b/src/com/android/launcher3/util/OnboardingPrefs.java
index c1e4fa8..64aeceb 100644
--- a/src/com/android/launcher3/util/OnboardingPrefs.java
+++ b/src/com/android/launcher3/util/OnboardingPrefs.java
@@ -140,4 +140,19 @@
         mSharedPrefs.edit().putInt(eventKey, count).apply();
         return hasReachedMaxCount(count, eventKey);
     }
+
+    /**
+     * Add "incCountBy" to the given event count, if we haven't already reached the max count.
+     *
+     * @return Whether we have now reached the max count.
+     */
+    public boolean incrementEventCountBy(int incCountBy, @EventCountKey String eventKey) {
+        int count = getCount(eventKey);
+        if (hasReachedMaxCount(count, eventKey)) {
+            return true;
+        }
+        count += incCountBy;
+        mSharedPrefs.edit().putInt(eventKey, count).apply();
+        return hasReachedMaxCount(count, eventKey);
+    }
 }