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

Commit 054faba0 authored by Schneider Victor-tulias's avatar Schneider Victor-tulias
Browse files

Add public constructors to gesture tutorial fragments.

The lack of public, no-arg constructors was causing the tutorial to crash on re-creation (eg. rotating the screen.) Added public constructors and refactored event logging.

Also added an update to the All Set page to allow the subtitle to display in one line.

Fixes: 226321558
Fixes: 226550217
Test: manual
Change-Id: I00a6135e658a66313df5e07833e6c6a20a618672
parent fe43ca95
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -72,12 +72,11 @@
            <TextView
                android:id="@+id/subtitle"
                style="@style/TextAppearance.GestureTutorial.Feedback.Subtitle.AllSet"
                android:layout_width="0dp"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginTop="@dimen/allset_subtitle_margin_top"
                app:layout_constraintTop_toBottomOf="@id/title"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintWidth_max="@dimen/allset_subtitle_width_max"
                android:gravity="start"/>

            <androidx.constraintlayout.widget.Guideline
+5 −7
Original line number Diff line number Diff line
@@ -15,20 +15,18 @@
 */
package com.android.quickstep.interaction;

import android.content.SharedPreferences;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;

import com.android.launcher3.logging.StatsLogManager;
import com.android.quickstep.interaction.TutorialController.TutorialType;

/** Shows the Home gesture interactive tutorial. */
public class AssistantGestureTutorialFragment extends TutorialFragment {

    protected AssistantGestureTutorialFragment(
            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
        super(sharedPrefs, statsLogManager);
    }
    public AssistantGestureTutorialFragment() {}

    @Override
    TutorialController createController(TutorialType type) {
@@ -49,12 +47,12 @@ public class AssistantGestureTutorialFragment extends TutorialFragment {
    }

    @Override
    void logTutorialStepShown() {
    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
        // No-Op: tutorial step not currently shown to users
    }

    @Override
    void logTutorialStepCompleted() {
    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
        // No-Op: tutorial step not currently shown to users
    }
}
+6 −9
Original line number Diff line number Diff line
@@ -19,10 +19,10 @@ import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.content.SharedPreferences;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.R;
@@ -34,10 +34,7 @@ import java.util.ArrayList;
/** Shows the Back gesture interactive tutorial. */
public class BackGestureTutorialFragment extends TutorialFragment {

    protected BackGestureTutorialFragment(
            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
        super(sharedPrefs, statsLogManager);
    }
    public BackGestureTutorialFragment() {}

    @Nullable
    @Override
@@ -126,14 +123,14 @@ public class BackGestureTutorialFragment extends TutorialFragment {
    }

    @Override
    void logTutorialStepShown() {
        mStatsLogManager.logger().log(
    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
        statsLogManager.logger().log(
                StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_SHOWN);
    }

    @Override
    void logTutorialStepCompleted() {
        mStatsLogManager.logger().log(
    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
        statsLogManager.logger().log(
                StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_BACK_STEP_COMPLETED);
    }
}
+10 −5
Original line number Diff line number Diff line
@@ -65,10 +65,7 @@ public class GestureSandboxActivity extends FragmentActivity {
        mTutorialSteps = getTutorialSteps(args);
        mCurrentTutorialStep = mTutorialSteps[mCurrentStep - 1];
        mFragment = TutorialFragment.newInstance(
                mCurrentTutorialStep,
                args.getBoolean(KEY_GESTURE_COMPLETE, false),
                mSharedPrefs,
                mStatsLogManager);
                mCurrentTutorialStep, args.getBoolean(KEY_GESTURE_COMPLETE, false));
        getSupportFragmentManager().beginTransaction()
                .add(R.id.gesture_tutorial_fragment_container, mFragment)
                .commit();
@@ -103,6 +100,14 @@ public class GestureSandboxActivity extends FragmentActivity {
        super.onSaveInstanceState(savedInstanceState);
    }

    protected SharedPreferences getSharedPrefs() {
        return mSharedPrefs;
    }

    protected StatsLogManager getStatsLogManager() {
        return mStatsLogManager;
    }

    /** Returns true iff there aren't anymore tutorial types to display to the user. */
    public boolean isTutorialComplete() {
        return mCurrentStep >= mNumSteps;
@@ -128,7 +133,7 @@ public class GestureSandboxActivity extends FragmentActivity {
        }
        mCurrentTutorialStep = mTutorialSteps[mCurrentStep];
        mFragment = TutorialFragment.newInstance(
                mCurrentTutorialStep, /* gestureComplete= */ false, mSharedPrefs, mStatsLogManager);
                mCurrentTutorialStep, /* gestureComplete= */ false);
        getSupportFragmentManager().beginTransaction()
                .replace(R.id.gesture_tutorial_fragment_container, mFragment)
                .runOnCommit(() -> mFragment.onAttachedToWindow())
+6 −9
Original line number Diff line number Diff line
@@ -18,10 +18,10 @@ package com.android.quickstep.interaction;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.content.SharedPreferences;
import android.view.MotionEvent;
import android.view.View;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.android.launcher3.R;
@@ -33,10 +33,7 @@ import java.util.ArrayList;
/** Shows the Home gesture interactive tutorial. */
public class HomeGestureTutorialFragment extends TutorialFragment {

    protected HomeGestureTutorialFragment(
            SharedPreferences sharedPrefs, StatsLogManager statsLogManager) {
        super(sharedPrefs, statsLogManager);
    }
    public HomeGestureTutorialFragment() {}

    @Nullable
    @Override
@@ -108,14 +105,14 @@ public class HomeGestureTutorialFragment extends TutorialFragment {
    }

    @Override
    void logTutorialStepShown() {
        mStatsLogManager.logger().log(
    void logTutorialStepShown(@NonNull StatsLogManager statsLogManager) {
        statsLogManager.logger().log(
                StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_SHOWN);
    }

    @Override
    void logTutorialStepCompleted() {
        mStatsLogManager.logger().log(
    void logTutorialStepCompleted(@NonNull StatsLogManager statsLogManager) {
        statsLogManager.logger().log(
                StatsLogManager.LauncherEvent.LAUNCHER_GESTURE_TUTORIAL_HOME_STEP_COMPLETED);
    }
}
Loading