diff options
author | Jon Miranda <jonmiranda@google.com> | 2016-10-27 17:15:27 -0700 |
---|---|---|
committer | Jon Miranda <jonmiranda@google.com> | 2016-11-01 09:00:20 -0700 |
commit | cc42c5bd1073f4b4f45ea29a1b01563601729022 (patch) | |
tree | 200d3a2c012bba0732c93a968f35b1b5b212ea33 /src/com/android/launcher3 | |
parent | 2962d52deee3a6001d08f67dfd28f99b6cd98ce3 (diff) | |
download | android_packages_apps_Trebuchet-cc42c5bd1073f4b4f45ea29a1b01563601729022.tar.gz android_packages_apps_Trebuchet-cc42c5bd1073f4b4f45ea29a1b01563601729022.tar.bz2 android_packages_apps_Trebuchet-cc42c5bd1073f4b4f45ea29a1b01563601729022.zip |
Create new DeviceProfile when in multi window mode.
This is just a first pass to help make the codebase ready for MW mode.
ie. won't see the effects of this unless resizeableActivity is set to true
in the Android Manifest.
Also allows long clicks from edge when in MW mode.
Bug: 32176631
Change-Id: I48e5cb3bd15e70627d9bf007d93bc731612fba2e
Diffstat (limited to 'src/com/android/launcher3')
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 25 |
2 files changed, 31 insertions, 8 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 655c21868..b25c0a18f 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -205,6 +205,13 @@ public class DeviceProfile { computeAllAppsButtonSize(context); } + DeviceProfile getMultiWindowProfile(Context context, Point mwSize) { + // In multi-window mode, we can have widthPx = availableWidthPx + // and heightPx = availableHeightPx because Launcher uses the InvariantDeviceProfiles' + // widthPx and heightPx values where it's needed. + return new DeviceProfile(context, inv, mwSize, mwSize, mwSize.x, mwSize.y, isLandscape); + } + public void addLauncherLayoutChangedListener(LauncherLayoutChangeListener listener) { if (!mListeners.contains(listener)) { mListeners.add(listener); @@ -599,4 +606,11 @@ public class DeviceProfile { hotseatBarHeightPx + hotseatLandGutterPx + mInsets.left) / 2; return new int[]{ padding, padding }; } + + public boolean shouldIgnoreLongPressToOverview(float touchX, float edgeThreshold) { + boolean inMultiWindowMode = this != inv.landscapeProfile && this != inv.portraitProfile; + boolean touchedLhsEdge = mInsets.left == 0 && touchX < edgeThreshold; + boolean touchedRhsEdge = mInsets.right == 0 && touchX > (widthPx - edgeThreshold); + return !inMultiWindowMode && (touchedLhsEdge || touchedRhsEdge); + } } diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index 09b5ad504..c7fac87e3 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -45,6 +45,7 @@ import android.content.pm.PackageManager; import android.content.res.Configuration; import android.database.sqlite.SQLiteDatabase; import android.graphics.Bitmap; +import android.graphics.Point; import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.os.AsyncTask; @@ -359,10 +360,17 @@ public class Launcher extends Activity LauncherAppState app = LauncherAppState.getInstance(); // Load configuration-specific DeviceProfile - mDeviceProfile = getResources().getConfiguration().orientation - == Configuration.ORIENTATION_LANDSCAPE ? - app.getInvariantDeviceProfile().landscapeProfile - : app.getInvariantDeviceProfile().portraitProfile; + mDeviceProfile = + getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE + ? app.getInvariantDeviceProfile().landscapeProfile + : app.getInvariantDeviceProfile().portraitProfile; + + if (Utilities.isNycOrAbove() && isInMultiWindowMode()) { + Display display = getWindowManager().getDefaultDisplay(); + Point mwSize = new Point(); + display.getSize(mwSize); + mDeviceProfile = mDeviceProfile.getMultiWindowProfile(this, mwSize); + } mSharedPrefs = Utilities.getPrefs(this); mIsSafeModeEnabled = getPackageManager().isSafeMode(); @@ -2708,12 +2716,13 @@ public class Launcher extends Activity return true; } - boolean fromEdgeOfScreen = mLastDispatchTouchEventX < mEdgeOfScreenThresholdPx - || mLastDispatchTouchEventX > (mDeviceProfile.widthPx - mEdgeOfScreenThresholdPx); + + boolean ignoreLongPressToOverview = mDeviceProfile.shouldIgnoreLongPressToOverview( + mLastDispatchTouchEventX, mEdgeOfScreenThresholdPx); if (v instanceof Workspace) { if (!mWorkspace.isInOverviewMode()) { - if (!mWorkspace.isTouchActive() && !fromEdgeOfScreen) { + if (!mWorkspace.isTouchActive() && !ignoreLongPressToOverview) { getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS, LauncherLogProto.Action.NONE, LauncherLogProto.WORKSPACE, mWorkspace.getCurrentPage()); @@ -2748,7 +2757,7 @@ public class Launcher extends Activity getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS, LauncherLogProto.Action.NONE, LauncherLogProto.OVERVIEW); } else { - if (fromEdgeOfScreen) { + if (ignoreLongPressToOverview) { return false; } getUserEventDispatcher().logActionOnContainer(LauncherLogProto.Action.LONGPRESS, |