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,14 @@
|
||||
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.os.Bundle;
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
|
||||
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
|
||||
import com.android.internal.accessibility.util.ShortcutUtils;
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.dashboard.DashboardFragment;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
@@ -61,5 +66,13 @@ public class AccessibilityButtonFragment extends DashboardFragment {
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_button_settings);
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_button_settings) {
|
||||
@Override
|
||||
protected boolean isPageSearchEnabled(Context context) {
|
||||
// Page should be unsearchable if there are no active button targets
|
||||
String targets = Settings.Secure.getStringForUser(context.getContentResolver(),
|
||||
ShortcutUtils.convertToKey(SOFTWARE), context.getUserId());
|
||||
return targets != null && !targets.isEmpty();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.accessibility;
|
||||
|
||||
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
|
||||
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
|
||||
@@ -22,16 +23,21 @@ import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.os.UserHandle;
|
||||
import android.provider.Settings;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.preference.Preference;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.core.TogglePreferenceController;
|
||||
|
||||
/**
|
||||
* Settings page for accessibility shortcut
|
||||
* Setting to allow the hardware shortcut to turn on from the lock screen
|
||||
*/
|
||||
public class AccessibilityShortcutPreferenceController extends TogglePreferenceController {
|
||||
|
||||
public AccessibilityShortcutPreferenceController(Context context, String preferenceKey) {
|
||||
public class HardwareShortcutFromLockscreenPreferenceController
|
||||
extends TogglePreferenceController {
|
||||
public HardwareShortcutFromLockscreenPreferenceController(
|
||||
Context context, String preferenceKey) {
|
||||
super(context, preferenceKey);
|
||||
}
|
||||
|
||||
@@ -56,7 +62,33 @@ public class AccessibilityShortcutPreferenceController extends TogglePreferenceC
|
||||
|
||||
@Override
|
||||
public int getAvailabilityStatus() {
|
||||
return AVAILABLE;
|
||||
if (!com.android.settings.accessibility.Flags.fixA11ySettingsSearch()) {
|
||||
return AVAILABLE;
|
||||
} else {
|
||||
if (mContext.getSystemService(AccessibilityManager.class)
|
||||
.getAccessibilityShortcutTargets(HARDWARE).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 mContext.getString(R.string.accessibility_shortcut_description);
|
||||
} else {
|
||||
return mContext.getString(
|
||||
R.string.accessibility_shortcut_unassigned_setting_unavailable_summary,
|
||||
AccessibilityUtil.getShortcutSummaryList(mContext, HARDWARE));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
Reference in New Issue
Block a user