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

Commit f37f0103 authored by Menghan Li's avatar Menghan Li Committed by Android (Google) Code Review
Browse files

Merge "Dynamic Select-To-Speak and Talkback setFragment style on SUW Welcome Screen."

parents 8821654a 6287ee02
Loading
Loading
Loading
Loading
+11 −3
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settings.accessibility;

import static com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType.LEGACY;

import android.accessibilityservice.AccessibilityServiceInfo;
import android.app.settings.SettingsEnums;
import android.content.ComponentName;
@@ -99,9 +101,11 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
    public void onResume() {
        super.onResume();
        updateAccessibilityServicePreference(mScreenReaderPreference,
                findService(SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME));
                SCREEN_READER_PACKAGE_NAME, SCREEN_READER_SERVICE_NAME,
                LegacyToggleScreenReaderPreferenceFragmentForSetupWizard.class.getName());
        updateAccessibilityServicePreference(mSelectToSpeakPreference,
                findService(SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME));
                SELECT_TO_SPEAK_PACKAGE_NAME, SELECT_TO_SPEAK_SERVICE_NAME,
                LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard.class.getName());
        configureMagnificationPreferenceIfNeeded(mDisplayMagnificationPreference);
    }

@@ -143,7 +147,8 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
    }

    private void updateAccessibilityServicePreference(Preference preference,
            AccessibilityServiceInfo info) {
            String packageName, String serviceName, String targetLegacyFragment) {
        final AccessibilityServiceInfo info = findService(packageName, serviceName);
        if (info == null) {
            getPreferenceScreen().removePreference(preference);
            return;
@@ -154,6 +159,9 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
        preference.setTitle(title);
        ComponentName componentName = new ComponentName(serviceInfo.packageName, serviceInfo.name);
        preference.setKey(componentName.flattenToString());
        if (AccessibilityUtil.getAccessibilityServiceFragmentType(info) == LEGACY) {
            preference.setFragment(targetLegacyFragment);
        }

        // Update the extras.
        Bundle extras = preference.getExtras();
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

package com.android.settings.accessibility;

import android.app.settings.SettingsEnums;
import android.os.Bundle;

/** For accessibility services that target SDK <= Q in setup wizard. */
public class LegacyToggleScreenReaderPreferenceFragmentForSetupWizard
        extends LegacyAccessibilityServicePreferenceFragment {

    private boolean mToggleSwitchWasInitiallyChecked;

    @Override
    protected void onProcessArguments(Bundle arguments) {
        super.onProcessArguments(arguments);
        mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
    }

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
    }

    @Override
    public void onStop() {
        // Log the final choice in value if it's different from the previous value.
        if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
            mMetricsFeatureProvider.action(getContext(),
                    SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER,
                    mToggleSwitch.isChecked());
        }

        super.onStop();
    }
}
+50 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2020 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.
 */

package com.android.settings.accessibility;

import android.app.settings.SettingsEnums;
import android.os.Bundle;

/** For accessibility services that target SDK <= Q in setup wizard. */
public class LegacyToggleSelectToSpeakPreferenceFragmentForSetupWizard
        extends LegacyAccessibilityServicePreferenceFragment {

    private boolean mToggleSwitchWasInitiallyChecked;

    @Override
    protected void onProcessArguments(Bundle arguments) {
        super.onProcessArguments(arguments);
        mToggleSwitchWasInitiallyChecked = mToggleSwitch.isChecked();
    }

    @Override
    public int getMetricsCategory() {
        return SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SCREEN_READER;
    }

    @Override
    public void onStop() {
        // Log the final choice in value if it's different from the previous value.
        if (mToggleSwitch.isChecked() != mToggleSwitchWasInitiallyChecked) {
            mMetricsFeatureProvider.action(getContext(),
                    SettingsEnums.SUW_ACCESSIBILITY_TOGGLE_SELECT_TO_SPEAK,
                    mToggleSwitch.isChecked());
        }

        super.onStop();
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -46,4 +46,3 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard
        super.onStop();
    }
}
+0 −1
Original line number Diff line number Diff line
@@ -47,4 +47,3 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard
        super.onStop();
    }
}