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

Commit d783d262 authored by Daniel Norman's avatar Daniel Norman
Browse files

cleanup: automatically expand the Triple Tap shortcut if enabled

This shortcut affects touch responsiveness so lets make sure that anyone
with it already enabled can see that it is enabled with no effort.

Fix: 328506957
Flag: EXEMPT low risk bugfix
Test: atest EditShortcutsPreferenceFragmentTest
Test: manually enable the shortcut, observe that the preference is
      expanded by default
Change-Id: I49529e42af2b15266c795cba0b1d5129895d7e87
parent 88f2973b
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();