Handle config changes in Launcher

- This is practically a revert to http://ag/c/13687966/5 and refactored to use DisplayController.DisplayInfoChangeListener
- Make Launcher handle size and density change so transition is less janky when screen size changes
- Added fix in RecentsView to update state and TaskView when display profile changes
- Removed 720dp specific resoureces
- Removed unused widget_section_indent
- Removed unnecessary all_apps_background_canvas 600dp override that is not needed in AllApps+
- Moved remaining dp specific into DeviceProfile
- Simplified allowRotation logic to use single variable in DeviceProfile to determine if allow rotation is enabled by default

Fixes: 180803696
Test: manual
Change-Id: Iea0a7d1a0e14dc3613152dd3b3887450a2e1fc2f
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index d5860dc..e5ad243 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -16,10 +16,12 @@
 
 package com.android.launcher3;
 
+import static android.util.DisplayMetrics.DENSITY_DEVICE_STABLE;
 import static android.view.WindowManager.LayoutParams.TYPE_APPLICATION;
 
 import static com.android.launcher3.ResourceUtils.pxFromDp;
 import static com.android.launcher3.Utilities.dpiFromPx;
+import static com.android.launcher3.util.WindowManagerCompat.MIN_TABLET_WIDTH;
 
 import android.annotation.SuppressLint;
 import android.content.Context;
@@ -61,6 +63,7 @@
     public final boolean isPhone;
     public final boolean transposeLayoutWithOrientation;
     public final boolean isTwoPanels;
+    public final boolean allowRotation;
 
     // Device properties in current orientation
     public final boolean isLandscape;
@@ -172,6 +175,8 @@
 
     // Drop Target
     public int dropTargetBarSizePx;
+    public int dropTargetDragPaddingPx;
+    public int dropTargetTextSizePx;
 
     // Insets
     private final Rect mInsets = new Rect();
@@ -190,6 +195,9 @@
     // How much of the bottom inset is due to Taskbar rather than other system elements.
     public int nonOverlappingTaskbarInset;
 
+    // DragController
+    public int flingToDeleteThresholdVelocity;
+
     DeviceProfile(Context context, InvariantDeviceProfile inv, Info info, WindowBounds windowBounds,
             boolean isMultiWindowMode, boolean transposeLayoutWithOrientation,
             boolean useTwoPanels) {
@@ -210,7 +218,12 @@
         int nonFinalAvailableHeightPx = windowBounds.availableSize.y;
 
         mInfo = info;
-        isTablet = info.isTablet(windowBounds);
+        // If the device's pixel density was scaled (usually via settings for A11y), use the
+        // original dimensions to determine if rotation is allowed of not.
+        float originalSmallestWidth = dpiFromPx(Math.min(widthPx, heightPx), DENSITY_DEVICE_STABLE);
+        allowRotation = originalSmallestWidth >= MIN_TABLET_WIDTH;
+        // Tablet UI does not support emulated landscape.
+        isTablet = allowRotation && info.isTablet(windowBounds);
         isPhone = !isTablet;
         isTwoPanels = isTablet && useTwoPanels;
 
@@ -287,7 +300,11 @@
 
         iconDrawablePaddingOriginalPx =
                 res.getDimensionPixelSize(R.dimen.dynamic_grid_icon_drawable_padding);
+
         dropTargetBarSizePx = res.getDimensionPixelSize(R.dimen.dynamic_grid_drop_target_size);
+        dropTargetDragPaddingPx = res.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
+        dropTargetTextSizePx = res.getDimensionPixelSize(R.dimen.drop_target_text_size);
+
         workspaceSpringLoadedBottomSpace =
                 res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space);
 
@@ -354,6 +371,9 @@
         }
         updateWorkspacePadding();
 
+        flingToDeleteThresholdVelocity = res.getDimensionPixelSize(
+                R.dimen.drag_flingToDeleteMinVelocity);
+
         // This is done last, after iconSizePx is calculated above.
         Path dotPath = GraphicsUtils.getShapePath(DEFAULT_DOT_SIZE);
         mDotRendererWorkSpace = new DotRenderer(iconSizePx, dotPath, DEFAULT_DOT_SIZE);
@@ -821,6 +841,7 @@
         writer.println(prefix + "DeviceProfile:");
         writer.println(prefix + "\t1 dp = " + mMetrics.density + " px");
 
+        writer.println(prefix + "\tallowRotation:" + allowRotation);
         writer.println(prefix + "\tisTablet:" + isTablet);
         writer.println(prefix + "\tisPhone:" + isPhone);
         writer.println(prefix + "\ttransposeLayoutWithOrientation:"