Merge "Enforce the correct orientation for the gesture navigation tutorial" into udc-dev am: 372de4f521 am: 4522e5d2ec am: 1d73aa9da2

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

Change-Id: I5e2f94c93b7204eb9fc3b50fa81c531bbfe9cdf6
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Saumya Prakash
2023-06-12 00:34:07 +00:00
committed by Automerger Merge Worker
13 changed files with 205 additions and 13 deletions
@@ -147,7 +147,7 @@ final class BackGestureTutorialController extends TutorialController {
@Override
public void onBackGestureAttempted(BackGestureResult result) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
switch (mTutorialType) {
@@ -165,7 +165,7 @@ final class BackGestureTutorialController extends TutorialController {
@Override
public void onBackGestureProgress(float diffx, float diffy, boolean isLeftGesture) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
@@ -234,7 +234,7 @@ final class BackGestureTutorialController extends TutorialController {
@Override
public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
if (mTutorialType == BACK_NAVIGATION_COMPLETE) {
@@ -16,6 +16,8 @@
package com.android.quickstep.interaction;
import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Bundle;
@@ -29,6 +31,8 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentActivity;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.R;
import com.android.launcher3.config.FeatureFlags;
@@ -53,10 +57,12 @@ public class GestureSandboxActivity extends FragmentActivity {
private int mCurrentStep;
private int mNumSteps;
private boolean mShowRotationPrompt;
private SharedPreferences mSharedPrefs;
private StatsLogManager mStatsLogManager;
private View mRotationPrompt;
private TISBindHelper mTISBindHelper;
@Override
@@ -93,9 +99,49 @@ public class GestureSandboxActivity extends FragmentActivity {
.add(R.id.gesture_tutorial_fragment_container, mFragment)
.commit();
mRotationPrompt = findViewById(R.id.rotation_prompt);
if (FeatureFlags.ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
correctUserOrientation();
}
mTISBindHelper = new TISBindHelper(this, this::onTISConnected);
}
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
// Ensure the prompt to rotate the screen is updated
if (FeatureFlags.ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
correctUserOrientation();
}
}
/**
* Gesture animations are only in landscape for large screens and portrait for mobile. This
* method enforces the following flows:
* 1) phone / two-panel closed -> lock to portrait
* 2) two-panel open / tablet + portrait -> prompt the user to rotate the screen
* 3) two-panel open / tablet + landscape -> hide potential rotating prompt
*/
private void correctUserOrientation() {
DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.get(
getApplicationContext()).getDeviceProfile(this);
if (deviceProfile.isTablet) {
mShowRotationPrompt = getResources().getConfiguration().orientation
== ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
updateVisibility(mRotationPrompt, mShowRotationPrompt ? View.VISIBLE : View.GONE);
} else {
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
}
}
void updateVisibility(View view, int visibility) {
if (view == null || view.getVisibility() == visibility) {
return;
}
view.setVisibility(visibility);
}
@Override
public void onAttachedToWindow() {
super.onAttachedToWindow();
@@ -127,6 +173,10 @@ public class GestureSandboxActivity extends FragmentActivity {
super.onSaveInstanceState(savedInstanceState);
}
protected boolean isRotationPromptShowing() {
return mShowRotationPrompt;
}
protected SharedPreferences getSharedPrefs() {
return mSharedPrefs;
}
@@ -140,7 +140,7 @@ final class HomeGestureTutorialController extends SwipeUpGestureTutorialControll
@Override
public void onBackGestureAttempted(BackGestureResult result) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
switch (mTutorialType) {
@@ -167,7 +167,7 @@ final class HomeGestureTutorialController extends SwipeUpGestureTutorialControll
@Override
public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
switch (mTutorialType) {
@@ -170,7 +170,7 @@ final class OverviewGestureTutorialController extends SwipeUpGestureTutorialCont
@Override
public void onBackGestureAttempted(BackGestureResult result) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
switch (mTutorialType) {
@@ -197,7 +197,7 @@ final class OverviewGestureTutorialController extends SwipeUpGestureTutorialCont
@Override
public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
switch (mTutorialType) {
@@ -260,7 +260,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
@Override
public void setNavBarGestureProgress(@Nullable Float displacement) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
if (mTutorialType == HOME_NAVIGATION_COMPLETE
@@ -281,7 +281,7 @@ abstract class SwipeUpGestureTutorialController extends TutorialController {
@Override
public void onMotionPaused(boolean unused) {
if (isGestureCompleted()) {
if (skipGestureAttempt()) {
return;
}
if (mShowTasks) {
@@ -462,6 +462,10 @@ abstract class TutorialController implements BackGestureAttemptCallback,
return mGestureCompleted;
}
public boolean skipGestureAttempt() {
return isGestureCompleted() || mTutorialFragment.isRotationPromptShowing();
}
void hideFeedback() {
if (mFeedbackView.getVisibility() != View.VISIBLE) {
return;
@@ -498,6 +498,11 @@ abstract class TutorialFragment extends GestureSandboxFragment implements OnTouc
return activity != null ? activity.getStatsLogManager() : null;
}
protected boolean isRotationPromptShowing() {
GestureSandboxActivity activity = getGestureSandboxActivity();
return activity != null && activity.isRotationPromptShowing();
}
@Nullable
private SharedPreferences getSharedPreferences() {
GestureSandboxActivity activity = getGestureSandboxActivity();