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

Commit f11cc713 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Move ShortcutsTutorial as a standalone DialogFragment" into main

parents 53a90b89 cac4bfaa
Loading
Loading
Loading
Loading
+0 −30
Original line number Diff line number Diff line
<!--
  Copyright (C) 2019 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License
  -->

<vector android:height="260dp" android:viewportHeight="260"
    android:viewportWidth="260" android:width="260dp" xmlns:android="http://schemas.android.com/apk/res/android">
    <path android:fillColor="#FFFFFF" android:pathData="M55,23.81V197c0,3.31 2.69,6 6,6h138c3.31,0 6,-2.69 6,-6V23.81C183.81,8.81 157.93,0 130,0S76.19,8.81 55,23.81z"/>
    <path android:fillColor="#F1F3F4" android:pathData="M61,209h138c6.62,0 12,-5.38 12,-12V28.32c-1.96,-1.56 -3.95,-3.07 -6,-4.52V197c0,3.31 -2.69,6 -6,6H61c-3.31,0 -6,-2.69 -6,-6V23.81c-2.05,1.45 -4.04,2.96 -6,4.52V197C49,203.62 54.38,209 61,209z"/>
    <path android:fillColor="#DADCE0" android:pathData="M61,212h138c8.27,0 15,-6.73 15,-15V30.79c-0.5,-0.42 -1,-0.85 -1.5,-1.26V197c0,7.44 -6.06,13.5 -13.5,13.5H61c-7.44,0 -13.5,-6.06 -13.5,-13.5V29.53c-0.5,0.41 -1,0.84 -1.5,1.26V197C46,205.27 52.73,212 61,212z"/>
    <path android:fillColor="#DADCE0" android:pathData="M211,197c0,6.62 -5.38,12 -12,12H61c-6.62,0 -12,-5.38 -12,-12V28.32c-0.5,0.4 -1,0.8 -1.5,1.21V197c0,7.44 6.06,13.5 13.5,13.5h138c7.44,0 13.5,-6.06 13.5,-13.5V29.53c-0.5,-0.41 -1,-0.81 -1.5,-1.21V197z"/>
    <path android:fillColor="#202124" android:pathData="M199,203H61c-3.31,0 -6,-2.69 -6,-6v-21.24h150V197C205,200.31 202.31,203 199,203z"/>
    <path android:fillAlpha="0.8" android:fillColor="#FFFFFF"
        android:pathData="M81.89,190.03l6.5,3.75c0.5,0.29 1.12,-0.07 1.12,-0.64v-7.51c0,-0.57 -0.62,-0.93 -1.12,-0.64l-6.5,3.75C81.4,189.02 81.4,189.74 81.89,190.03z" android:strokeAlpha="0.8"/>
    <path android:fillAlpha="0.8" android:fillColor="#FFFFFF"
        android:pathData="M130,189.38m-4.2,0a4.2,4.2 0,1 1,8.4 0a4.2,4.2 0,1 1,-8.4 0" android:strokeAlpha="0.8"/>
    <path android:fillColor="#FFFFFF" android:pathData="M179.78,184.38c-2.18,0.58 -4.73,0.83 -7.08,0.83c-2.36,0 -4.91,-0.25 -7.08,-0.83l-0.42,1.67c1.55,0.42 3.33,0.69 5,0.83v10.83h1.67v-5h1.67v5h1.67v-10.83c1.67,-0.14 3.45,-0.42 5,-0.83L179.78,184.38zM172.69,184.38c0.92,0 1.67,-0.75 1.67,-1.67c0,-0.92 -0.75,-1.67 -1.67,-1.67c-0.92,0 -1.67,0.75 -1.67,1.67C171.03,183.63 171.78,184.38 172.69,184.38z"/>
    <path android:fillColor="#E8EAED" android:pathData="M130,2c34.19,0 66.33,13.31 90.51,37.49S258,95.81 258,130s-13.31,66.33 -37.49,90.51S164.19,258 130,258s-66.33,-13.31 -90.51,-37.49S2,164.19 2,130s13.31,-66.33 37.49,-90.51S95.81,2 130,2M130,0C58.2,0 0,58.2 0,130s58.2,130 130,130s130,-58.2 130,-130S201.8,0 130,0L130,0z"/>
</vector>
+0 −60
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2019 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License
  -->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textDirection="locale"
    android:scrollbarStyle="outsideOverlay">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="24dp">

        <ImageView
            android:id="@+id/button_tutorial_image"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:src="@drawable/illustration_accessibility_button"
            android:scaleType="fitCenter"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:paddingTop="32dp"
            android:paddingLeft="24dp"
            android:paddingRight="24dp">

            <TextView
                android:id="@+id/button_tutorial_title"
                android:text="@string/accessibility_tutorial_dialog_title_button"
                style="@style/AccessibilityDialogTitle" />

            <TextView
                android:id="@+id/button_tutorial_message"
                style="@style/AccessibilityDialogDescription" />

        </LinearLayout>

    </LinearLayout>

</ScrollView>
+0 −63
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
  Copyright (C) 2019 The Android Open Source Project

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

       http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License
  -->

<ScrollView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:textDirection="locale"
    android:scrollbarStyle="outsideOverlay">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:paddingTop="24dp">

        <ImageView
            android:id="@+id/image"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:maxHeight="@dimen/accessibility_imageview_size"
            android:layout_gravity="center_horizontal"
            android:adjustViewBounds="true"
            android:paddingLeft="24dp"
            android:paddingRight="24dp" />

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical"
            android:gravity="center_horizontal"
            android:paddingTop="32dp"
            android:paddingLeft="24dp"
            android:paddingRight="24dp">

            <TextView
                android:id="@+id/gesture_tutorial_title"
                android:text="@string/accessibility_tutorial_dialog_title_gesture"
                style="@style/AccessibilityDialogTitle" />

            <TextView
                android:id="@+id/gesture_tutorial_message"
                style="@style/AccessibilityDialogDescription" />

        </LinearLayout>

    </LinearLayout>

</ScrollView>
+0 −18
Original line number Diff line number Diff line
@@ -69,24 +69,6 @@ public class AccessibilityDialogUtils {
         */
        int DISABLE_WARNING_FROM_TOGGLE = 1005;

        /**
         * OPEN: Settings > Accessibility > Magnification > Toggle user service in button
         * navigation.
         */
        int ACCESSIBILITY_BUTTON_TUTORIAL = 1006;

        /**
         * OPEN: Settings > Accessibility > Magnification > Toggle user service in gesture
         * navigation.
         */
        int GESTURE_NAVIGATION_TUTORIAL = 1007;

        /**
         * OPEN: Settings > Accessibility > Downloaded toggle service > Toggle user service > Show
         * launch tutorial.
         */
        int LAUNCH_ACCESSIBILITY_TUTORIAL = 1008;

        /**
         * OPEN: Settings > Accessibility > Display size and text > Click 'Reset settings' button.
         */
+5 −48
Original line number Diff line number Diff line
@@ -17,16 +17,12 @@
package com.android.settings.accessibility;

import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.DEFAULT;
import static com.android.settings.accessibility.AccessibilityDialogUtils.DialogEnums;
import static com.android.settings.accessibility.AccessibilityUtil.getShortcutSummaryList;
import static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_GENERAL_CATEGORY;

import android.annotation.SuppressLint;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.os.Handler;
import android.provider.Settings;
@@ -59,7 +55,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends BaseRestri
    private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";

    protected ShortcutPreference mShortcutPreference;
    protected Dialog mDialog;
    private AccessibilityManager.TouchExplorationStateChangeListener
            mTouchExplorationStateChangeListener;
    private AccessibilitySettingsContentObserver mSettingsContentObserver;
@@ -142,42 +137,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends BaseRestri
        super.onPause();
    }

    @Override
    public Dialog onCreateDialog(int dialogId) {
        switch (dialogId) {
            case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
                if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
                    mDialog = AccessibilityShortcutsTutorial
                            .createAccessibilityTutorialDialogForSetupWizard(
                                    getPrefContext(), getUserPreferredShortcutTypes(),
                                    this::callOnTutorialDialogButtonClicked, getLabelName());
                } else {
                    mDialog = AccessibilityShortcutsTutorial
                            .createAccessibilityTutorialDialog(
                                    getPrefContext(), getUserPreferredShortcutTypes(),
                                    this::callOnTutorialDialogButtonClicked, getLabelName());
                }
                mDialog.setCanceledOnTouchOutside(false);
                return mDialog;
            default:
                throw new IllegalArgumentException("Unsupported dialogId " + dialogId);
        }
    }

    protected CharSequence getShortcutTitle() {
        return getString(R.string.accessibility_shortcut_title, getLabelName());
    }

    @Override
    public int getDialogMetricsCategory(int dialogId) {
        switch (dialogId) {
            case DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL:
                return SettingsEnums.DIALOG_ACCESSIBILITY_TUTORIAL;
            default:
                return SettingsEnums.ACTION_UNKNOWN;
        }
    }

    @Override
    public void onSettingsClicked(ShortcutPreference preference) {
        EditShortcutsPreferenceFragment.showEditShortcutScreen(
@@ -202,7 +165,11 @@ public abstract class AccessibilityShortcutPreferenceFragment extends BaseRestri
                isChecked, shortcutTypes,
                Set.of(getComponentName().flattenToString()), getPrefContext().getUserId());
        if (isChecked) {
            showDialog(DialogEnums.LAUNCH_ACCESSIBILITY_TUTORIAL);
            AccessibilityShortcutsTutorial.DialogFragment.showDialog(
                    getChildFragmentManager(),
                    getUserPreferredShortcutTypes(),
                    getLabelName(),
                    WizardManagerHelper.isAnySetupWizard(getIntent()));
        }
        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
    }
@@ -236,16 +203,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends BaseRestri
        return context.getText(resId);
    }

    /**
     * This method will be invoked when a button in the tutorial dialog is clicked.
     *
     * @param dialog The dialog that received the click
     * @param which  The button that was clicked
     */
    private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
        dialog.dismiss();
    }

    @VisibleForTesting
    void initGeneralCategory() {
        final PreferenceCategory generalCategory = new PreferenceCategory(getPrefContext());
Loading