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

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

Merge "cleanup: automatically expand the Triple Tap shortcut if enabled" into main

parents c506fcf3 d783d262
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -206,6 +206,16 @@ public class EditShortcutsPreferenceFragment extends DashboardFragment {
    public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
        super.onCreatePreferences(savedInstanceState, rootKey);

        // Expand to show the Triple Tap shortcut if the user already has that shortcut enabled.
        // This shortcut affects touch responsiveness so we want to ensure that the user sees that
        // the shortcut is enabled without requiring them to manually expand it.
        TripleTapShortcutOptionController tripleTapShortcutOptionController =
                use(TripleTapShortcutOptionController.class);
        if (tripleTapShortcutOptionController.isShortcutAvailable()
                && tripleTapShortcutOptionController.isChecked()) {
            onExpanded();
        }

        Activity activity = getActivity();
        final Preference descriptionPref = findPreference(getString(
                R.string.accessibility_shortcut_description_pref));
+21 −0
Original line number Diff line number Diff line
@@ -435,6 +435,27 @@ public class EditShortcutsPreferenceFragmentTest {
        });
    }

    @Test
    public void fragmentCreated_tripleTapEnabled_automaticallyExpanded() {
        Settings.Secure.putInt(
                mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_DISPLAY_MAGNIFICATION_ENABLED,
                AccessibilityUtil.State.ON);
        ShadowLooper.runUiThreadTasksIncludingDelayedTasks();

        mFragmentScenario = createFragScenario(/* isInSuw= */ false, TARGET);
        mFragmentScenario.moveToState(Lifecycle.State.RESUMED);
        mFragmentScenario.onFragment(fragment -> {
            Preference advanced = fragment.findPreference(
                    mContext.getString(R.string.accessibility_shortcuts_advanced_collapsed));
            assertThat(advanced.isVisible()).isFalse();

            Preference tripleTap = fragment.findPreference(
                    mContext.getString(R.string.accessibility_shortcut_triple_tap_pref));
            assertThat(tripleTap.isVisible()).isTrue();
        });
    }

    @Test
    public void fragmentRecreated_expanded_advancedRemainInvisible() {
        onAdvancedPreferenceClicked_advancedShouldBecomeInvisible();