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

Commit b094ed8e authored by Pfohl's avatar Pfohl Committed by Randy Pfohl
Browse files

adding new animation to be used when gesture tutorial package is available

test: built and verified animation shows up and is clickable to gesture tutorial menu on handheld devices

bug:248342586
Change-Id: I29a68accf67c4efc6b94058c2702f106edfec0a8
parent 8cd0c581
Loading
Loading
Loading
Loading
+1 −0

File added.

Preview size limit exceeded, changes collapsed.

+45 −2
Original line number Diff line number Diff line
@@ -75,6 +75,13 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i

    private static final String KEY_SHOW_A11Y_TUTORIAL_DIALOG = "show_a11y_tutorial_dialog_bool";

    static final String LAUNCHER_PACKAGE_NAME = "com.google.android.apps.nexuslauncher";

    static final String ACTION_GESTURE_SANDBOX = "com.android.quickstep.action.GESTURE_SANDBOX";

    final Intent mLaunchSandboxIntent = new Intent(ACTION_GESTURE_SANDBOX)
            .setPackage(LAUNCHER_PACKAGE_NAME);

    private static final int MIN_LARGESCREEN_WIDTH_DP = 600;

    private boolean mA11yTutorialDialogShown = false;
@@ -121,6 +128,7 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
            mVideoPreference.applyDynamicColor();
        }
        setIllustrationVideo(mVideoPreference, getDefaultKey());
        setIllustrationClickListener(mVideoPreference, getDefaultKey());

        migrateOverlaySensitivityToSettings(context, mOverlayManager);
    }
@@ -221,7 +229,37 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
        setCurrentSystemNavigationMode(mOverlayManager, key);
        setIllustrationVideo(mVideoPreference, key);
        setGestureNavigationTutorialDialog(key);
        setIllustrationClickListener(mVideoPreference, key);
        return true;
    }

    private boolean isGestureTutorialAvailable() {
        Context context = getContext();
        return context != null
                && mLaunchSandboxIntent.resolveActivity(context.getPackageManager()) != null;
    }

    private void setIllustrationClickListener(IllustrationPreference videoPref,
            String systemNavKey) {

        switch (systemNavKey) {
            case KEY_SYSTEM_NAV_GESTURAL:
                if (isGestureTutorialAvailable()){
                    videoPref.setOnPreferenceClickListener(preference -> {
                        startActivity(mLaunchSandboxIntent.putExtra("use_tutorial_menu", true));
                        return true;
                    });
                } else {
                    videoPref.setOnPreferenceClickListener(null);
                }

                break;
            case KEY_SYSTEM_NAV_2BUTTONS:
            case KEY_SYSTEM_NAV_3BUTTONS:
            default:
                videoPref.setOnPreferenceClickListener(null);
                break;
        }
    }

    static void migrateOverlaySensitivityToSettings(Context context,
@@ -278,11 +316,16 @@ public class SystemNavigationGestureSettings extends RadioButtonPickerFragment i
        }
    }

    private static void setIllustrationVideo(IllustrationPreference videoPref,
    private void setIllustrationVideo(IllustrationPreference videoPref,
            String systemNavKey) {
        switch (systemNavKey) {
            case KEY_SYSTEM_NAV_GESTURAL:
                if (isGestureTutorialAvailable()) {
                    videoPref.setLottieAnimationResId(
                            R.raw.lottie_system_nav_fully_gestural_with_nav);
                } else {
                    videoPref.setLottieAnimationResId(R.raw.lottie_system_nav_fully_gestural);
                }
                break;
            case KEY_SYSTEM_NAV_2BUTTONS:
                videoPref.setLottieAnimationResId(R.raw.lottie_system_nav_2_button);