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

Commit b8293152 authored by menghanli's avatar menghanli
Browse files

Support accessibility shortcut secondary action (11/n)

Refactor current shortcut design to base fragment and provide
protected function to customize the legacy design,
magnification or no need shortcut app.

Bug: 142530063
Bug: 142531156
Test: make RunSettingsRoboTests2

Change-Id: I51c951ef8f819a1940ddfe33b009b40ed5ec0530
parent d737601a
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.UserHandle;
import android.provider.Settings;
import android.view.View;
import android.view.accessibility.AccessibilityManager;
import android.widget.Switch;

@@ -83,6 +84,12 @@ public class AccessibilityShortcutPreferenceFragment extends ToggleFeaturePrefer
        });
    }

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

    @Override
    public void onResume() {
        super.onResume();
+6 −12
Original line number Diff line number Diff line
@@ -21,8 +21,6 @@ import static com.android.settings.accessibility.AccessibilityUtil.UserShortcutT
import android.os.Bundle;
import android.view.View;

import androidx.preference.PreferenceScreen;

import com.android.settings.R;

import com.google.common.collect.ImmutableSet;
@@ -35,22 +33,18 @@ public class LegacyAccessibilityServicePreferenceFragment extends
    public void onViewCreated(View view, Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);

        final PreferenceScreen preferenceScreen = getPreferenceScreen();
        final ShortcutPreference shortcutPreference = preferenceScreen.findPreference(
                getShortcutPreferenceKey());
        if (shortcutPreference != null) {
        final CharSequence hardwareTitle = getPrefContext().getText(
                R.string.accessibility_shortcut_edit_dialog_title_hardware);
            shortcutPreference.setSummary(hardwareTitle);
            shortcutPreference.setSettingsVisibility(View.GONE);
        }
        mShortcutPreference.setSummary(hardwareTitle);
        mShortcutPreference.setSettingsVisibility(View.GONE);

        // Only allowed hardware PreferredShortcutType in this fragment.
        setAllowedPreferredShortcutType(UserShortcutType.HARDWARE);
    }

    private void setAllowedPreferredShortcutType(int type) {
        final AccessibilityUserShortcutType shortcut = new AccessibilityUserShortcutType(
                getComponentName().flattenToString(), type);
                mComponentName.flattenToString(), type);

        SharedPreferenceUtils.setUserShortcutType(getPrefContext(),
                ImmutableSet.of(shortcut.flattenToString()));
+20 −281

File changed.

Preview size limit exceeded, changes collapsed.

+4 −259

File changed.

Preview size limit exceeded, changes collapsed.

+5 −261

File changed.

Preview size limit exceeded, changes collapsed.

Loading