Merge "Make Color inversion shortcut searchable" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
47a9ea6d33
@@ -25,6 +25,7 @@ import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
|
||||
import android.app.settings.SettingsEnums;
|
||||
import android.content.ComponentName;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
@@ -37,17 +38,22 @@ import com.android.settings.accessibility.AccessibilityUtil.QuickSettingsTooltip
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settings.widget.SettingsMainSwitchPreference;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
import com.android.settingslib.search.SearchIndexableRaw;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/** Settings page for color inversion. */
|
||||
/**
|
||||
* Settings page for color inversion.
|
||||
*/
|
||||
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
|
||||
public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePreferenceFragment {
|
||||
|
||||
private static final String TAG = "ToggleColorInversionPreferenceFragment";
|
||||
private static final String ENABLED = Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED;
|
||||
|
||||
private static final String KEY_SHORTCUT_PREFERENCE = "color_inversion_shortcut_key";
|
||||
|
||||
@Override
|
||||
protected void registerKeysToObserverCallback(
|
||||
AccessibilitySettingsContentObserver contentObserver) {
|
||||
@@ -67,9 +73,9 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
mHtmlDescription = getText(R.string.accessibility_display_inversion_preference_subtitle);
|
||||
mTopIntroTitle = getText(R.string.accessibility_display_inversion_preference_intro_text);
|
||||
mImageUri = new Uri.Builder().scheme(ContentResolver.SCHEME_ANDROID_RESOURCE)
|
||||
.authority(getPrefContext().getPackageName())
|
||||
.appendPath(String.valueOf(R.raw.a11y_color_inversion_banner))
|
||||
.build();
|
||||
.authority(getPrefContext().getPackageName())
|
||||
.appendPath(String.valueOf(R.raw.a11y_color_inversion_banner))
|
||||
.build();
|
||||
final View view = super.onCreateView(inflater, container, savedInstanceState);
|
||||
updateFooterPreference();
|
||||
return view;
|
||||
@@ -159,7 +165,7 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
@Override
|
||||
int getUserShortcutTypes() {
|
||||
return AccessibilityUtil.getUserShortcutTypesFromSettings(getPrefContext(),
|
||||
mComponentName);
|
||||
mComponentName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -170,8 +176,8 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
@Override
|
||||
CharSequence getTileTooltipContent(@QuickSettingsTooltipType int type) {
|
||||
return getText(type == QuickSettingsTooltipType.GUIDE_TO_EDIT
|
||||
? R.string.accessibility_color_inversion_qs_tooltip_content
|
||||
: R.string.accessibility_color_inversion_auto_added_qs_tooltip_content);
|
||||
? R.string.accessibility_color_inversion_qs_tooltip_content
|
||||
: R.string.accessibility_color_inversion_auto_added_qs_tooltip_content);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -184,5 +190,17 @@ public class ToggleColorInversionPreferenceFragment extends ToggleFeaturePrefere
|
||||
}
|
||||
|
||||
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings);
|
||||
new BaseSearchIndexProvider(R.xml.accessibility_color_inversion_settings) {
|
||||
@Override
|
||||
public List<SearchIndexableRaw> getRawDataToIndex(Context context,
|
||||
boolean enabled) {
|
||||
final List<SearchIndexableRaw> rawData = new ArrayList<>();
|
||||
SearchIndexableRaw raw = new SearchIndexableRaw(context);
|
||||
raw.key = KEY_SHORTCUT_PREFERENCE;
|
||||
raw.title = context.getString(
|
||||
R.string.accessibility_display_inversion_shortcut_title);
|
||||
rawData.add(raw);
|
||||
return rawData;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
Reference in New Issue
Block a user