Disabling elements on the A11y Shortcut setting subpage
Elements on the subpage get disabled if there are no enabled shortcut targets for the relevant type. In the case of A11y button, the items on its fragment become unsearchable when the setting is disabled. Test: Manually verify conditions described above & in bug Bug: 349180207 Flag: com.android.settings.accessibility.fix_a11y_settings_search Change-Id: Id39e2eda6c9d1de4cdbfcbc22b8a1f443e2822d9
This commit is contained in:
@@ -16,9 +16,13 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
@@ -32,14 +36,39 @@ import java.util.List;
|
||||
* Preference controller for accessibility button preference.
|
||||
*/
|
||||
public class AccessibilityButtonPreferenceController extends BasePreferenceController {
|
||||
|
||||
public AccessibilityButtonPreferenceController(Context context, String key) {
|
||||
super(context, key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
if (!com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||
return AVAILABLE;
|
||||
} else {
|
||||
if (mContext.getSystemService(AccessibilityManager.class)
|
||||
.getAccessibilityShortcutTargets(SOFTWARE).isEmpty()) {
|
||||
return DISABLED_DEPENDENT_SETTING;
|
||||
} else {
|
||||
return AVAILABLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(@NonNull Preference preference) {
|
||||
super.updateState(preference);
|
||||
refreshSummary(preference);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull CharSequence getSummary() {
|
||||
if (getAvailabilityStatus() == AVAILABLE) {
|
||||
return "";
|
||||
} else {
|
||||
return mContext.getString(
|
||||
R.string.accessibility_shortcut_unassigned_setting_unavailable_summary,
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, SOFTWARE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -47,7 +76,6 @@ public class AccessibilityButtonPreferenceController extends BasePreferenceContr
|
||||
super.displayPreference(screen);
|
||||
final Preference preference = screen.findPreference(getPreferenceKey());
|
||||
preference.setTitle(getPreferenceTitleResource());
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user