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

Commit 66dde6fe authored by Riley Jones's avatar Riley Jones Committed by Android (Google) Code Review
Browse files

Merge "Cleaning up deprecated QS tooltip code" into main

parents 87ce9dbb f337bf1f
Loading
Loading
Loading
Loading
+0 −11
Original line number Diff line number Diff line
@@ -96,17 +96,6 @@ public class AccessibilityHearingAidsFragment extends AccessibilityShortcutPrefe
        return mFeatureName;
    }

    @Override
    protected ComponentName getTileComponentName() {
        return AccessibilityShortcutController.ACCESSIBILITY_HEARING_AIDS_TILE_COMPONENT_NAME;
    }

    @Override
    protected CharSequence getTileTooltipContent(int type) {
        // No tooltip to be shown
        return null;
    }

    @Override
    protected boolean showGeneralCategory() {
        // Have static preference under dynamically created PreferenceCategory KEY_GENERAL_CATEGORY.
+0 −69
Original line number Diff line number Diff line
@@ -20,10 +20,8 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh
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 static com.android.settings.accessibility.ToggleFeaturePreferenceFragment.KEY_SAVED_QS_TOOLTIP_TYPE;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.Dialog;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -44,7 +42,6 @@ import androidx.preference.PreferenceScreen;

import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.settings.R;
import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltipType;
import com.android.settings.accessibility.shortcuts.EditShortcutsPreferenceFragment;
import com.android.settings.dashboard.RestrictedDashboardFragment;

@@ -60,16 +57,12 @@ import java.util.Set;
public abstract class AccessibilityShortcutPreferenceFragment extends RestrictedDashboardFragment
        implements ShortcutPreference.OnClickCallback {
    private static final String KEY_SHORTCUT_PREFERENCE = "shortcut_preference";
    protected static final String KEY_SAVED_QS_TOOLTIP_RESHOW = "qs_tooltip_reshow";

    protected ShortcutPreference mShortcutPreference;
    protected Dialog mDialog;
    private AccessibilityManager.TouchExplorationStateChangeListener
            mTouchExplorationStateChangeListener;
    private AccessibilitySettingsContentObserver mSettingsContentObserver;
    private AccessibilityQuickSettingsTooltipWindow mTooltipWindow;
    private boolean mNeedsQSTooltipReshow = false;
    private int mNeedsQSTooltipType = QuickSettingsTooltipType.GUIDE_TO_EDIT;

    public AccessibilityShortcutPreferenceFragment(String restrictionKey) {
        super(restrictionKey);
@@ -81,26 +74,10 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
    /** Returns the accessibility feature name. */
    protected abstract CharSequence getLabelName();

    /** Returns the accessibility tile component name. */
    protected abstract ComponentName getTileComponentName();

    /** Returns the accessibility tile tooltip content. */
    protected abstract CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type);

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Restore the user shortcut type and tooltip.
        if (savedInstanceState != null) {
            if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_RESHOW)) {
                mNeedsQSTooltipReshow = savedInstanceState.getBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW);
            }
            if (savedInstanceState.containsKey(KEY_SAVED_QS_TOOLTIP_TYPE)) {
                mNeedsQSTooltipType = savedInstanceState.getInt(KEY_SAVED_QS_TOOLTIP_TYPE);
            }
        }

        final int resId = getPreferenceScreenResId();
        if (resId <= 0) {
            final PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(
@@ -141,21 +118,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
        return super.onCreateView(inflater, container, savedInstanceState);
    }

    @Override
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        // Reshow tooltip when activity recreate, such as rotate device.
        if (mNeedsQSTooltipReshow) {
            view.post(() -> {
                final Activity activity = getActivity();
                if (activity != null && !activity.isFinishing()) {
                    showQuickSettingsTooltipIfNeeded();
                }
            });
        }
    }

    @Override
    public void onResume() {
        super.onResume();
@@ -177,16 +139,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
        super.onPause();
    }

    @Override
    public void onSaveInstanceState(Bundle outState) {
        final boolean isTooltipWindowShowing = mTooltipWindow != null && mTooltipWindow.isShowing();
        if (mNeedsQSTooltipReshow || isTooltipWindowShowing) {
            outState.putBoolean(KEY_SAVED_QS_TOOLTIP_RESHOW, /* value= */ true);
            outState.putInt(KEY_SAVED_QS_TOOLTIP_TYPE, mNeedsQSTooltipType);
        }
        super.onSaveInstanceState(outState);
    }

    @Override
    public Dialog onCreateDialog(int dialogId) {
        switch (dialogId) {
@@ -289,7 +241,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
     */
    private void callOnTutorialDialogButtonClicked(DialogInterface dialog, int which) {
        dialog.dismiss();
        showQuickSettingsTooltipIfNeeded();
    }

    @VisibleForTesting
@@ -362,26 +313,6 @@ public abstract class AccessibilityShortcutPreferenceFragment extends Restricted
        mShortcutPreference.setSummary(getShortcutTypeSummary(getPrefContext()));
    }

    /**
     * Shows the quick settings tooltip if the quick settings feature is assigned. The tooltip only
     * shows once.
     *
     * @param type The quick settings tooltip type
     */
    protected void showQuickSettingsTooltipIfNeeded(@QuickSettingsTooltipType int type) {
        mNeedsQSTooltipType = type;
        showQuickSettingsTooltipIfNeeded();
    }

    /**
     * @deprecated made obsolete by quick settings rollout.
     *
     * (TODO 367414968: finish removal.)
     */
    @Deprecated
    private void showQuickSettingsTooltipIfNeeded() {
    }

    /**
     * Returns the user preferred shortcut types or the default shortcut types if not set
     */
+0 −5
Original line number Diff line number Diff line
@@ -71,11 +71,6 @@ public class LaunchAccessibilityActivityPreferenceFragment extends ToggleFeature
        return view;
    }

    @Override
    protected void onPreferenceToggled(String preferenceKey, boolean enabled) {
        // Do nothing.
    }

    @Override
    protected void onProcessArguments(Bundle arguments) {
        super.onProcessArguments(arguments);
+0 −4
Original line number Diff line number Diff line
@@ -107,10 +107,6 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
        if (enabled == isEnabled) {
            return;
        }

        if (enabled) {
            showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
        }
        logAccessibilityServiceEnabled(mComponentName, enabled);
        Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
    }
+0 −4
Original line number Diff line number Diff line
@@ -158,10 +158,6 @@ public class ToggleDaltonizerPreferenceFragment extends ToggleFeaturePreferenceF
        if (enabled == isEnabled) {
            return;
        }

        if (enabled) {
            showQuickSettingsTooltipIfNeeded(QuickSettingsTooltipType.GUIDE_TO_DIRECT_USE);
        }
        logAccessibilityServiceEnabled(mComponentName, enabled);
        Settings.Secure.putInt(getContentResolver(), ENABLED, enabled ? ON : OFF);
    }
Loading