Accessibility shortcut secondary action - divide different fragment for different fragment type
Different accessibility service fragment type have different UI. - AccessibilityServiceFragmentType.LEGACY will use LegacyAccessibilityServicePreferenceFragment - AccessibilityServiceFragmentType.INVISIBLE will use InvisibleToggleAccessibilityServicePreferenceFragment - AccessibilityServiceFragmentType.INTUITIVE will use ToggleAccessibilityServicePreferenceFragment Bug: 142530063 Test: Manual Change-Id: Ib32a4f97514450e5c0d29e99c22935efecf8b6df
This commit is contained in:
@@ -48,6 +48,7 @@ import com.android.internal.accessibility.AccessibilityShortcutController;
|
||||
import com.android.internal.content.PackageMonitor;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.Utils;
|
||||
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.display.DarkUIPreferenceController;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -402,7 +403,24 @@ public class AccessibilitySettings extends DashboardFragment {
|
||||
preference.setEnabled(true);
|
||||
}
|
||||
|
||||
preference.setFragment(ToggleAccessibilityServicePreferenceFragment.class.getName());
|
||||
switch (AccessibilityUtil.getAccessibilityServiceFragmentType(info)) {
|
||||
case AccessibilityServiceFragmentType.LEGACY:
|
||||
preference.setFragment(
|
||||
LegacyAccessibilityServicePreferenceFragment.class.getName());
|
||||
break;
|
||||
case AccessibilityServiceFragmentType.INVISIBLE:
|
||||
preference.setFragment(
|
||||
InvisibleToggleAccessibilityServicePreferenceFragment.class.getName());
|
||||
break;
|
||||
case AccessibilityServiceFragmentType.INTUITIVE:
|
||||
preference.setFragment(
|
||||
ToggleAccessibilityServicePreferenceFragment.class.getName());
|
||||
break;
|
||||
default:
|
||||
// impossible status
|
||||
throw new AssertionError();
|
||||
}
|
||||
|
||||
preference.setPersistent(true);
|
||||
|
||||
final Bundle extras = preference.getExtras();
|
||||
|
@@ -38,19 +38,19 @@ final class AccessibilityUtil {
|
||||
*
|
||||
* {@code LEGACY} for displaying appearance aligned with sdk version Q accessibility service
|
||||
* page, but only hardware shortcut allowed.
|
||||
* {@code HEADLESS} for displaying appearance without switch bar.
|
||||
* {@code INVISIBLE} for displaying appearance without switch bar.
|
||||
* {@code INTUITIVE} for displaying appearance with new design.
|
||||
*/
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@IntDef({
|
||||
AccessibilityServiceFragmentType.LEGACY,
|
||||
AccessibilityServiceFragmentType.HEADLESS,
|
||||
AccessibilityServiceFragmentType.INVISIBLE,
|
||||
AccessibilityServiceFragmentType.INTUITIVE,
|
||||
})
|
||||
|
||||
public @interface AccessibilityServiceFragmentType {
|
||||
int LEGACY = 0;
|
||||
int HEADLESS = 1;
|
||||
int INVISIBLE = 1;
|
||||
int INTUITIVE = 2;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ final class AccessibilityUtil {
|
||||
return AccessibilityServiceFragmentType.LEGACY;
|
||||
}
|
||||
return requestA11yButton
|
||||
? AccessibilityServiceFragmentType.HEADLESS
|
||||
? AccessibilityServiceFragmentType.INVISIBLE
|
||||
: AccessibilityServiceFragmentType.INTUITIVE;
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.accessibilityservice.AccessibilityServiceInfo;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.settings.SettingsActivity;
|
||||
import com.android.settings.widget.SwitchBar;
|
||||
|
||||
/**
|
||||
* For accessibility services that target SDK > Q, and
|
||||
* {@link AccessibilityServiceInfo#FLAG_REQUEST_ACCESSIBILITY_BUTTON}
|
||||
* is set.
|
||||
*/
|
||||
public class InvisibleToggleAccessibilityServicePreferenceFragment extends
|
||||
ToggleAccessibilityServicePreferenceFragment {
|
||||
|
||||
@Override
|
||||
public void onActivityCreated(Bundle savedInstanceState) {
|
||||
super.onActivityCreated(savedInstanceState);
|
||||
|
||||
final SettingsActivity activity = (SettingsActivity) getActivity();
|
||||
final SwitchBar mSwitchBar = activity.getSwitchBar();
|
||||
mSwitchBar.hide();
|
||||
}
|
||||
}
|
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2019 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.os.Bundle;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
/** For accessibility services that target SDK <= Q. */
|
||||
public class LegacyAccessibilityServicePreferenceFragment extends
|
||||
ToggleAccessibilityServicePreferenceFragment {
|
||||
@Override
|
||||
public void onViewCreated(View view, Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
final PreferenceScreen preferenceScreen = getPreferenceScreen();
|
||||
final ShortcutPreference preference = preferenceScreen.findPreference(
|
||||
getShortcutPreferenceKey());
|
||||
if (preference != null) {
|
||||
preference.setSettingsVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
@@ -101,7 +101,7 @@ public final class AccessibilityUtilTest {
|
||||
info.flags |= AccessibilityServiceInfo.FLAG_REQUEST_ACCESSIBILITY_BUTTON;
|
||||
|
||||
assertThat(AccessibilityUtil.getAccessibilityServiceFragmentType(info)).isEqualTo(
|
||||
AccessibilityUtil.AccessibilityServiceFragmentType.HEADLESS);
|
||||
AccessibilityUtil.AccessibilityServiceFragmentType.INVISIBLE);
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user