Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d33fc050 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias Committed by Android (Google) Code Review
Browse files

Merge "Fix broken gesture nav edu on tablets in portrait." into udc-qpr-dev

parents b095594a 41f7e169
Loading
Loading
Loading
Loading
+3 −75
Original line number Diff line number Diff line
@@ -13,80 +13,8 @@
    See the License for the specific language governing permissions and
    limitations under the License.
-->
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/gesture_tutorial_fragment_container"
    android:layout_width="match_parent"
        android:layout_height="match_parent"

        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent" />

    <RelativeLayout
        android:id="@+id/rotation_prompt"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:background="?attr/surfaceHome"
        android:visibility="gone"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/background"
            android:layout_width="300dp"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:background="@drawable/rotate_prompt_bg"
            android:padding="24dp">

            <ImageView
                android:id="@+id/icon"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:src="@drawable/rotate_tutorial_warning"

                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent"
                app:layout_constraintEnd_toEndOf="parent" />

            <TextView
                android:id="@+id/rotate_title"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="20dp"
                android:lineSpacingExtra="2sp"
                android:text="@string/gesture_tutorial_rotation_prompt_title"
                android:textAppearance="@style/rotate_prompt_title"

                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/icon"
                app:layout_constraintEnd_toEndOf="parent" />

            <TextView
                android:id="@+id/rotate_screen_subtitle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginTop="16dp"
                android:gravity="center"
                android:text="@string/gesture_tutorial_rotation_prompt"
                android:textAppearance="@style/rotate_prompt_subtitle"

                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toBottomOf="@id/rotate_title"
                app:layout_constraintEnd_toEndOf="parent" />

        </androidx.constraintlayout.widget.ConstraintLayout>
    </RelativeLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
    android:layout_height="match_parent"/>
 No newline at end of file
+60 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="?attr/surfaceHome">

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/background"
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:background="@drawable/rotate_prompt_bg"
        android:padding="24dp"

        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent">

        <ImageView
            android:id="@+id/icon"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/rotate_tutorial_warning"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintEnd_toEndOf="parent" />

        <TextView
            android:id="@+id/rotate_title"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="20dp"
            android:lineSpacingExtra="2sp"
            android:text="@string/gesture_tutorial_rotation_prompt_title"
            android:textAppearance="@style/rotate_prompt_title"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/icon"
            app:layout_constraintEnd_toEndOf="parent" />

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginTop="16dp"
            android:gravity="center"
            android:text="@string/gesture_tutorial_rotation_prompt"
            android:textAppearance="@style/rotate_prompt_subtitle"

            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@id/rotate_title"
            app:layout_constraintEnd_toEndOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

</androidx.constraintlayout.widget.ConstraintLayout>
 No newline at end of file
+3 −3
Original line number Diff line number Diff line
@@ -154,7 +154,7 @@ final class BackGestureTutorialController extends TutorialController {

    @Override
    public void onBackGestureAttempted(BackGestureResult result) {
        if (skipGestureAttempt()) {
        if (isGestureCompleted()) {
            return;
        }
        switch (mTutorialType) {
@@ -172,7 +172,7 @@ final class BackGestureTutorialController extends TutorialController {

    @Override
    public void onBackGestureProgress(float diffx, float diffy, boolean isLeftGesture) {
        if (skipGestureAttempt()) {
        if (isGestureCompleted()) {
            return;
        }

@@ -241,7 +241,7 @@ final class BackGestureTutorialController extends TutorialController {

    @Override
    public void onNavBarGestureAttempted(NavBarGestureResult result, PointF finalVelocity) {
        if (skipGestureAttempt()) {
        if (isGestureCompleted()) {
            return;
        }
        if (mTutorialType == BACK_NAVIGATION_COMPLETE) {
+6 −0
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ public class BackGestureTutorialFragment extends TutorialFragment {
        super(fromTutorialMenu);
    }

    @NonNull
    @Override
    TutorialType getDefaultTutorialType() {
        return TutorialType.BACK_NAVIGATION;
    }

    @Nullable
    @Override
    Integer getEdgeAnimationResId() {
+29 −33
Original line number Diff line number Diff line
@@ -53,16 +53,14 @@ public class GestureSandboxActivity extends FragmentActivity {
    static final String KEY_USE_TUTORIAL_MENU = "use_tutorial_menu";

    @Nullable private TutorialType[] mTutorialSteps;
    private GestureSandboxFragment mFragment;
    private GestureSandboxFragment mCurrentFragment;
    private GestureSandboxFragment mPendingFragment;

    private int mCurrentStep;
    private int mNumSteps;
    private boolean mShowRotationPrompt;

    private SharedPreferences mSharedPrefs;
    private StatsLogManager mStatsLogManager;

    private View mRotationPrompt;
    private TISBindHelper mTISBindHelper;

    @Override
@@ -82,7 +80,7 @@ public class GestureSandboxActivity extends FragmentActivity {
                && args.getBoolean(KEY_USE_TUTORIAL_MENU, false)) {
            mTutorialSteps = null;
            TutorialType tutorialTypeOverride = (TutorialType) args.get(KEY_TUTORIAL_TYPE);
            mFragment = tutorialTypeOverride == null
            mCurrentFragment = tutorialTypeOverride == null
                    ? new MenuFragment()
                    : makeTutorialFragment(
                            tutorialTypeOverride,
@@ -90,16 +88,15 @@ public class GestureSandboxActivity extends FragmentActivity {
                            /* fromMenu= */ true);
        } else {
            mTutorialSteps = getTutorialSteps(args);
            mFragment = makeTutorialFragment(
            mCurrentFragment = makeTutorialFragment(
                    mTutorialSteps[mCurrentStep - 1],
                    gestureComplete,
                    /* fromMenu= */ false);
        }
        getSupportFragmentManager().beginTransaction()
                .add(R.id.gesture_tutorial_fragment_container, mFragment)
                .add(R.id.gesture_tutorial_fragment_container, mCurrentFragment)
                .commit();

        mRotationPrompt = findViewById(R.id.rotation_prompt);
        if (FeatureFlags.ENABLE_NEW_GESTURE_NAV_TUTORIAL.get()) {
            correctUserOrientation();
        }
@@ -127,34 +124,45 @@ public class GestureSandboxActivity extends FragmentActivity {
        DeviceProfile deviceProfile = InvariantDeviceProfile.INSTANCE.get(
                getApplicationContext()).getDeviceProfile(this);
        if (deviceProfile.isTablet) {
            mShowRotationPrompt = getResources().getConfiguration().orientation
            boolean showRotationPrompt = getResources().getConfiguration().orientation
                    == ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
            updateVisibility(mRotationPrompt, mShowRotationPrompt ? View.VISIBLE : View.GONE);

            GestureSandboxFragment recreatedFragment =
                    showRotationPrompt || mPendingFragment == null
                            ? null : mPendingFragment.recreateFragment();
            showFragment(showRotationPrompt
                    ? new RotationPromptFragment()
                    : recreatedFragment == null
                            ? mCurrentFragment : recreatedFragment);
        } else {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        }
    }

    void updateVisibility(View view, int visibility) {
        if (view == null || view.getVisibility() == visibility) {
            return;
    private void showFragment(@NonNull GestureSandboxFragment fragment) {
        if (mCurrentFragment.recreateFragment() != null) {
            mPendingFragment = mCurrentFragment;
        }
        view.setVisibility(visibility);
        mCurrentFragment = fragment;
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.gesture_tutorial_fragment_container, mCurrentFragment)
                .runOnCommit(() -> mCurrentFragment.onAttachedToWindow())
                .commit();
    }

    @Override
    public void onAttachedToWindow() {
        super.onAttachedToWindow();
        if (mFragment.shouldDisableSystemGestures()) {
        if (mCurrentFragment.shouldDisableSystemGestures()) {
            disableSystemGestures();
        }
        mFragment.onAttachedToWindow();
        mCurrentFragment.onAttachedToWindow();
    }

    @Override
    public void onDetachedFromWindow() {
        super.onDetachedFromWindow();
        mFragment.onDetachedFromWindow();
        mCurrentFragment.onDetachedFromWindow();
    }

    @Override
@@ -169,14 +177,10 @@ public class GestureSandboxActivity extends FragmentActivity {
    protected void onSaveInstanceState(@NonNull Bundle savedInstanceState) {
        savedInstanceState.putStringArray(KEY_TUTORIAL_STEPS, getTutorialStepNames());
        savedInstanceState.putInt(KEY_CURRENT_STEP, mCurrentStep);
        mFragment.onSaveInstanceState(savedInstanceState);
        mCurrentFragment.onSaveInstanceState(savedInstanceState);
        super.onSaveInstanceState(savedInstanceState);
    }

    protected boolean isRotationPromptShowing() {
        return mShowRotationPrompt;
    }

    protected SharedPreferences getSharedPrefs() {
        return mSharedPrefs;
    }
@@ -205,7 +209,7 @@ public class GestureSandboxActivity extends FragmentActivity {
     */
    public void continueTutorial() {
        if (isTutorialComplete() || mTutorialSteps == null) {
            mFragment.close();
            mCurrentFragment.close();
            return;
        }
        launchTutorialStep(mTutorialSteps[mCurrentStep], false);
@@ -224,20 +228,12 @@ public class GestureSandboxActivity extends FragmentActivity {
     * the menu when complete.
     */
    public void launchTutorialStep(@NonNull TutorialType tutorialType, boolean fromMenu) {
        mFragment = makeTutorialFragment(tutorialType, false, fromMenu);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.gesture_tutorial_fragment_container, mFragment)
                .runOnCommit(() -> mFragment.onAttachedToWindow())
                .commit();
        showFragment(makeTutorialFragment(tutorialType, false, fromMenu));
    }

    /** Launches the gesture nav tutorial menu page */
    public void launchTutorialMenu() {
        mFragment = new MenuFragment();
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.gesture_tutorial_fragment_container, mFragment)
                .runOnCommit(() -> mFragment.onAttachedToWindow())
                .commit();
        showFragment(new MenuFragment());
    }

    private String[] getTutorialStepNames() {
Loading