Add keywords for AOD setting.

Used the WiFi slice for inspiration: ag/6793584

Also added "ambient" to the keywords, since "ambient display" is another
phrase used for AOD.

Bug: 279029717
Test: manually checked that the setting shows up when searching for
"aod"
Change-Id: I8a3a4a6635c9724565426b859722242d2bae9e49
This commit is contained in:
Ioana Alexandru
2023-04-20 16:05:50 +00:00
parent e1ae1c6516
commit e18a7140f3
3 changed files with 16 additions and 4 deletions

View File

@@ -7097,8 +7097,8 @@
<!-- List of synonyms for the font size, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_font_size">text size, large print, large font, large text, low vision, make text bigger, font enlarger, font enlargement</string>
<!-- List of synonyms for the always show time and info [CHAR LIMIT=NONE] -->
<string name="keywords_always_show_time_info">always on display, AOD</string>
<!-- List of synonyms for the always show time and info, used to match in settings search [CHAR LIMIT=NONE] -->
<string name="keywords_always_show_time_info">always on ambient display, AOD</string>
<!-- List of synonyms for the nfc tag apps control [CHAR LIMIT=NONE] -->
<string name="keywords_change_nfc_tag_apps_state">nfc, tag, reader</string>

View File

@@ -28,6 +28,7 @@ import android.hardware.display.AmbientDisplayConfiguration;
import android.net.Uri;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.slice.Slice;
import androidx.slice.builders.ListBuilder;
@@ -40,6 +41,10 @@ import com.android.settings.overlay.FeatureFactory;
import com.android.settings.slices.CustomSliceRegistry;
import com.android.settings.slices.CustomSliceable;
import java.util.Arrays;
import java.util.Set;
import java.util.stream.Collectors;
/**
* Custom {@link Slice} for Always on Display.
* <p>
@@ -75,6 +80,7 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
return new ListBuilder(mContext, CustomSliceRegistry.ALWAYS_ON_SLICE_URI,
ListBuilder.INFINITY)
.setAccentColor(color)
.setKeywords(getKeywords())
.addRow(new ListBuilder.RowBuilder()
.setTitle(mContext.getText(R.string.doze_always_on_title))
.setSubtitle(mContext.getText(R.string.doze_always_on_summary))
@@ -84,6 +90,13 @@ public class AlwaysOnDisplaySlice implements CustomSliceable {
.build();
}
private Set<String> getKeywords() {
final String keywords = mContext.getString(R.string.keywords_always_show_time_info);
return Arrays.stream(TextUtils.split(keywords, ","))
.map(String::trim)
.collect(Collectors.toSet());
}
@Override
public Uri getUri() {
return CustomSliceRegistry.ALWAYS_ON_SLICE_URI;

View File

@@ -22,7 +22,6 @@ import android.os.PowerManager;
import android.os.SystemProperties;
import android.os.UserHandle;
import android.provider.Settings;
import android.text.TextUtils;
import androidx.preference.Preference;
@@ -59,7 +58,7 @@ public class AmbientDisplayAlwaysOnPreferenceController extends TogglePreference
@Override
public boolean isSliceable() {
return TextUtils.equals(getPreferenceKey(), "ambient_display_always_on");
return true;
}
@Override