Dynamic Select-To-Speak and Talkback setFragment style on SUW Welcome Screen.
Check the APK target SDK to use corresponding fragment to avoid wrong status before these app release to R. Bug: 147997595 Bug: 148394224 Bug: 148438898 Test: Manual test Change-Id: I3a4ca6b8566f3f731b651e1f785f4fc18319ca89
This commit is contained in:
@@ -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();
|
||||
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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();
|
||||
}
|
||||
}
|
@@ -46,4 +46,3 @@ public class ToggleScreenReaderPreferenceFragmentForSetupWizard
|
||||
super.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -47,4 +47,3 @@ public class ToggleSelectToSpeakPreferenceFragmentForSetupWizard
|
||||
super.onStop();
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user