diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2018-03-02 12:24:41 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2018-03-03 00:41:09 -0800 |
commit | 623eddd7e80784e1d3dd758503fe014a15f6c1c8 (patch) | |
tree | b07ca08881131bfb21d6cd3203bee60ca81c7488 /src/com/android/launcher3/dragndrop | |
parent | 85f1eed52de4c983c1e279523a1c9b35d6ccb842 (diff) | |
download | android_packages_apps_Trebuchet-623eddd7e80784e1d3dd758503fe014a15f6c1c8.tar.gz android_packages_apps_Trebuchet-623eddd7e80784e1d3dd758503fe014a15f6c1c8.tar.bz2 android_packages_apps_Trebuchet-623eddd7e80784e1d3dd758503fe014a15f6c1c8.zip |
Updating Launcher rotation logic
When auto-rotate is on, launcher allways allows rotation. This allows uses to use
locked rotation feature is available on the device
When auto-rotate is off, workspace does not allow rotation, but overview in quickstep
will allow rotation
Bug: 73872056
Change-Id: Ie12365c268fd5e4958634ed97b5a33dcadc691e2
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r-- | src/com/android/launcher3/dragndrop/AddItemActivity.java | 22 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/BaseItemDragListener.java | 12 |
2 files changed, 12 insertions, 22 deletions
diff --git a/src/com/android/launcher3/dragndrop/AddItemActivity.java b/src/com/android/launcher3/dragndrop/AddItemActivity.java index db199c117..95e103436 100644 --- a/src/com/android/launcher3/dragndrop/AddItemActivity.java +++ b/src/com/android/launcher3/dragndrop/AddItemActivity.java @@ -16,6 +16,11 @@ package com.android.launcher3.dragndrop; +import static com.android.launcher3.logging.LoggerUtils.newCommandAction; +import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; +import static com.android.launcher3.logging.LoggerUtils.newItemTarget; +import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent; + import android.annotation.TargetApi; import android.app.ActivityOptions; import android.appwidget.AppWidgetManager; @@ -23,7 +28,6 @@ import android.content.ClipData; import android.content.ClipDescription; import android.content.Intent; import android.content.pm.LauncherApps.PinItemRequest; -import android.content.res.Configuration; import android.graphics.Canvas; import android.graphics.Point; import android.graphics.PointF; @@ -43,7 +47,6 @@ import com.android.launcher3.LauncherAppState; import com.android.launcher3.LauncherAppWidgetHost; import com.android.launcher3.LauncherAppWidgetProviderInfo; import com.android.launcher3.R; -import com.android.launcher3.Utilities; import com.android.launcher3.compat.AppWidgetManagerCompat; import com.android.launcher3.compat.LauncherAppsCompatVO; import com.android.launcher3.model.WidgetItem; @@ -55,11 +58,6 @@ import com.android.launcher3.widget.PendingAddWidgetInfo; import com.android.launcher3.widget.WidgetHostViewLoader; import com.android.launcher3.widget.WidgetImageView; -import static com.android.launcher3.logging.LoggerUtils.newCommandAction; -import static com.android.launcher3.logging.LoggerUtils.newContainerTarget; -import static com.android.launcher3.logging.LoggerUtils.newItemTarget; -import static com.android.launcher3.logging.LoggerUtils.newLauncherEvent; - @TargetApi(Build.VERSION_CODES.O) public class AddItemActivity extends BaseActivity implements OnLongClickListener, OnTouchListener { @@ -154,15 +152,7 @@ public class AddItemActivity extends BaseActivity implements OnLongClickListener .setPackage(getPackageName()) .setFlags(Intent.FLAG_ACTIVITY_NEW_TASK)); - if (!getResources().getBoolean(R.bool.allow_rotation) && - !Utilities.isAllowRotationPrefEnabled(this) && - (getResources().getConfiguration().orientation == - Configuration.ORIENTATION_LANDSCAPE && !isInMultiWindowMode())) { - // If we are starting the drag in landscape even though home is locked in portrait, - // restart the home activity to temporarily allow rotation. - homeIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK); - } - + listener.initWhenReady(); startActivity(homeIntent, ActivityOptions.makeCustomAnimation(this, 0, android.R.anim.fade_out).toBundle()); mFinishOnPause = true; diff --git a/src/com/android/launcher3/dragndrop/BaseItemDragListener.java b/src/com/android/launcher3/dragndrop/BaseItemDragListener.java index 9638a75d8..df4a7c1f5 100644 --- a/src/com/android/launcher3/dragndrop/BaseItemDragListener.java +++ b/src/com/android/launcher3/dragndrop/BaseItemDragListener.java @@ -17,6 +17,8 @@ package com.android.launcher3.dragndrop; import static com.android.launcher3.LauncherState.NORMAL; +import static com.android.launcher3.states.RotationHelper.REQUEST_LOCK; +import static com.android.launcher3.states.RotationHelper.REQUEST_NONE; import android.content.ClipDescription; import android.content.Intent; @@ -79,6 +81,7 @@ public abstract class BaseItemDragListener extends InternalStateHandler implemen AbstractFloatingView.closeAllOpenViews(launcher, alreadyOnHome); launcher.getStateManager().goToState(NORMAL, alreadyOnHome /* animated */); launcher.getDragLayer().setOnDragListener(this); + launcher.getRotationHelper().setStateHandlerRequest(REQUEST_LOCK); mLauncher = launcher; mDragController = launcher.getDragController(); @@ -157,6 +160,7 @@ public abstract class BaseItemDragListener extends InternalStateHandler implemen } private void postCleanup() { + clearReference(); if (mLauncher != null) { // Remove any drag params from the launcher intent since the drag operation is complete. Intent newIntent = new Intent(mLauncher.getIntent()); @@ -164,16 +168,12 @@ public abstract class BaseItemDragListener extends InternalStateHandler implemen mLauncher.setIntent(newIntent); } - new Handler(Looper.getMainLooper()).post(new Runnable() { - @Override - public void run() { - removeListener(); - } - }); + new Handler(Looper.getMainLooper()).post(this::removeListener); } public void removeListener() { if (mLauncher != null) { + mLauncher.getRotationHelper().setStateHandlerRequest(REQUEST_NONE); mLauncher.getDragLayer().setOnDragListener(null); } } |