<attr name="controller" format="string" />
<!-- {@code true} when the controller declared represents a slice from {@link android.app.SettingsSliceContract} -->
<attr name="platform_slice" format="boolean" />
- <!-- Whether or not dynamic summary text from PreferenceController is allowed when creating slice object, by default it's false. -->
- <attr name="allowDynamicSummaryInSlice" format="boolean" />
<!-- customized subtitle if it's an unavailable slice -->
<attr name="unavailableSliceSubtitle" format="string" />
</declare-styleable>
android:title="@string/firmware_version"
android:summary="@string/summary_placeholder"
settings:enableCopying="true"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.firmwareversion.FirmwareVersionDetailPreferenceController"/>
<!-- Security patch -->
android:title="@string/build_number"
android:summary="@string/summary_placeholder"
settings:enableCopying="true"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.firmwareversion.SimpleBuildNumberPreferenceController"/>
</PreferenceScreen>
\ No newline at end of file
android:key="hardware_info_device_model"
android:title="@string/model_info"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.hardwareinfo.DeviceModelPreferenceController"
settings:enableCopying="true"/>
android:key="hardware_info_device_serial"
android:title="@string/status_serial_number"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.hardwareinfo.SerialNumberPreferenceController"
settings:enableCopying="true"/>
android:key="hardware_info_device_revision"
android:title="@string/hardware_revision"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.hardwareinfo.HardwareRevisionPreferenceController"
settings:enableCopying="true"/>
android:title="@string/status_number"
android:summary="@string/summary_placeholder"
android:selectable="false"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.PhoneNumberPreferenceController"
settings:enableCopying="true"/>
android:title="@string/hardware_info"
settings:keywords="@string/keywords_model_and_hardware"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
android:fragment="com.android.settings.deviceinfo.hardwareinfo.HardwareInfoFragment"
settings:controller="com.android.settings.deviceinfo.HardwareInfoPreferenceController"/>
android:title="@string/status_imei"
settings:keywords="@string/keywords_imei_info"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.deviceinfo.imei.ImeiInfoPreferenceController"/>
<!-- Android version -->
android:order="32"
android:title="@string/firmware_version"
android:summary="@string/summary_placeholder"
- settings:allowDynamicSummaryInSlice="true"
android:fragment="com.android.settings.deviceinfo.firmwareversion.FirmwareVersionSettings"
settings:controller="com.android.settings.deviceinfo.firmwareversion.FirmwareVersionPreferenceController"/>
android:icon="@drawable/ic_volume_remote"
android:title="@string/remote_media_volume_option_title"
android:order="-185"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.notification.RemoteVolumePreferenceController"/>
<!-- Media volume -->
android:icon="@drawable/ic_media_stream"
android:title="@string/media_volume_option_title"
android:order="-180"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.notification.MediaVolumePreferenceController"/>
<!-- Media output switcher -->
android:icon="@drawable/ic_local_phone_24_lib"
android:title="@string/call_volume_option_title"
android:order="-170"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.notification.CallVolumePreferenceController"/>
<!-- Hands free profile output switcher -->
android:icon="@drawable/ic_notifications"
android:title="@string/ring_volume_option_title"
android:order="-160"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.notification.RingVolumePreferenceController"/>
android:icon="@*android:drawable/ic_audio_alarm"
android:title="@string/alarm_volume_option_title"
android:order="-150"
- settings:allowDynamicSummaryInSlice="true"
settings:controller="com.android.settings.notification.AlarmVolumePreferenceController"/>
<!-- Notification volume -->
MetadataFlag.FLAG_NEED_PREF_SUMMARY,
MetadataFlag.FLAG_NEED_PREF_ICON,
MetadataFlag.FLAG_NEED_SEARCHABLE,
- MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE})
@Retention(RetentionPolicy.SOURCE)
public @interface MetadataFlag {
int FLAG_NEED_PLATFORM_SLICE_FLAG = 1 << 7;
int FLAG_NEED_KEYWORDS = 1 << 8;
int FLAG_NEED_SEARCHABLE = 1 << 9;
- int FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE = 1 << 10;
- int FLAG_NEED_PREF_APPEND = 1 << 11;
- int FLAG_UNAVAILABLE_SLICE_SUBTITLE = 1 << 12;
+ int FLAG_NEED_PREF_APPEND = 1 << 10;
+ int FLAG_UNAVAILABLE_SLICE_SUBTITLE = 1 << 11;
}
public static final String METADATA_PREF_TYPE = "type";
public static final String METADATA_PLATFORM_SLICE_FLAG = "platform_slice";
public static final String METADATA_KEYWORDS = "keywords";
public static final String METADATA_SEARCHABLE = "searchable";
- public static final String METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE =
- "allow_dynamic_summary_in_slice";
public static final String METADATA_APPEND = "staticPreferenceLocation";
public static final String METADATA_UNAVAILABLE_SLICE_SUBTITLE =
"unavailable_slice_subtitle";
preferenceMetadata.putBoolean(METADATA_SEARCHABLE,
isSearchable(preferenceAttributes));
}
- if (hasFlag(flags, MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE)) {
- preferenceMetadata.putBoolean(METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
- isDynamicSummaryAllowed(preferenceAttributes));
- }
if (hasFlag(flags, MetadataFlag.FLAG_NEED_PREF_APPEND) && hasPrefScreenFlag) {
preferenceMetadata.putBoolean(METADATA_APPEND,
isAppended(preferenceScreenAttributes));
}
/**
- * Returns the fragment name if this preference launches a child fragment.
- */
- public static String getDataChildFragment(Context context, AttributeSet attrs) {
- return getStringData(context, attrs, R.styleable.Preference,
- R.styleable.Preference_android_fragment);
- }
-
- /**
* Call {@link #extractMetadata(Context, int, int)} with a {@link MetadataFlag} instead.
*/
@Deprecated
return styledAttributes.getBoolean(R.styleable.Preference_searchable, true /* default */);
}
- private static boolean isDynamicSummaryAllowed(TypedArray styledAttributes) {
- return styledAttributes.getBoolean(R.styleable.Preference_allowDynamicSummaryInSlice,
- false /* default */);
- }
-
private static String getKeywords(TypedArray styledAttributes) {
return styledAttributes.getString(R.styleable.Preference_keywords);
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public void copy() {
final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
CLIPBOARD_SERVICE);
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public boolean isSliceable() {
return true;
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public void copy() {
final ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(
CLIPBOARD_SERVICE);
public CharSequence getSummary() {
return HardwareInfoPreferenceController.getDeviceModel();
}
+
+ @Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public boolean isSliceable() {
return true;
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public void copy() {
Sliceable.setCopyContent(mContext, getSummary(),
mContext.getText(R.string.status_serial_number));
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public void copy() {
Sliceable.setCopyContent(mContext, getSummary(), mContext.getText(R.string.status_imei));
}
import androidx.preference.Preference;
import com.android.settings.accounts.AccountRestrictionHelper;
-import com.android.settings.core.PreferenceControllerMixin;
import com.android.settings.core.SliderPreferenceController;
import com.android.settingslib.RestrictedPreference;
* restriction
*/
public abstract class AdjustVolumeRestrictedPreferenceController extends
- SliderPreferenceController implements PreferenceControllerMixin {
+ SliderPreferenceController {
private AccountRestrictionHelper mHelper;
import com.android.settings.R;
-public class AlarmVolumePreferenceController extends
- VolumeSeekBarPreferenceController {
+public class AlarmVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String KEY_ALARM_VOLUME = "alarm_volume";
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_ALARM_VOLUME;
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public int getAudioStream() {
if (mAudioManager.isBluetoothScoOn()) {
return AudioManager.STREAM_BLUETOOTH_SCO;
import com.android.settings.R;
-public class MediaVolumePreferenceController extends
- VolumeSeekBarPreferenceController {
+public class MediaVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String KEY_MEDIA_VOLUME = "media_volume";
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_MEDIA_VOLUME;
}
import java.util.List;
import java.util.Objects;
-public class RemoteVolumePreferenceController extends
- VolumeSeekBarPreferenceController {
+public class RemoteVolumePreferenceController extends VolumeSeekBarPreferenceController {
private static final String KEY_REMOTE_VOLUME = "remote_volume";
@VisibleForTesting
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public String getPreferenceKey() {
return KEY_REMOTE_VOLUME;
}
}
@Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
+
+ @Override
public int getAudioStream() {
return AudioManager.STREAM_RING;
}
if (System.getProperty(SYSPROP_CRASH_ON_ERROR) != null) {
throw new RuntimeException(e);
}
- Log.e(TAG, "Error trying to get non-indexable keys from: " + clazz.getName() , e);
+ Log.e(TAG, "Error trying to get non-indexable keys from: " + clazz.getName(), e);
continue;
}
* @return the summary text for a {@link Slice} built for {@param sliceData}.
*/
public static CharSequence getSubtitleText(Context context,
- AbstractPreferenceController controller, SliceData sliceData) {
- final boolean isDynamicSummaryAllowed = sliceData.isDynamicSummaryAllowed();
+ BasePreferenceController controller, SliceData sliceData) {
+ final boolean isDynamicSummaryAllowed = controller.useDynamicSliceSummary();
CharSequence summaryText = controller.getSummary();
// Priority 1 : User prefers showing the dynamic summary in slice view rather than static
private final boolean mIsPlatformDefined;
- private final boolean mIsDynamicSummaryAllowed;
-
private final String mUnavailableSliceSubtitle;
public String getKey() {
return mIsPlatformDefined;
}
- public boolean isDynamicSummaryAllowed() {
- return mIsDynamicSummaryAllowed;
- }
-
public String getUnavailableSliceSubtitle() {
return mUnavailableSliceSubtitle;
}
mPreferenceController = builder.mPrefControllerClassName;
mSliceType = builder.mSliceType;
mIsPlatformDefined = builder.mIsPlatformDefined;
- mIsDynamicSummaryAllowed = builder.mIsDynamicSummaryAllowed;
mUnavailableSliceSubtitle = builder.mUnavailableSliceSubtitle;
}
private boolean mIsPlatformDefined;
- private boolean mIsDynamicSummaryAllowed;
-
private String mUnavailableSliceSubtitle;
public Builder setKey(String key) {
return this;
}
- public Builder setDynamicSummaryAllowed(boolean isDynamicSummaryAllowed) {
- mIsDynamicSummaryAllowed = isDynamicSummaryAllowed;
- return this;
- }
-
public Builder setUnavailableSliceSubtitle(
String unavailableSliceSubtitle) {
mUnavailableSliceSubtitle = unavailableSliceSubtitle;
package com.android.settings.slices;
-import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_CONTROLLER;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ICON;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
| MetadataFlag.FLAG_NEED_PREF_ICON
| MetadataFlag.FLAG_NEED_PREF_SUMMARY
| MetadataFlag.FLAG_NEED_PLATFORM_SLICE_FLAG
- | MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE
| MetadataFlag.FLAG_UNAVAILABLE_SLICE_SUBTITLE);
for (Bundle bundle : metadata) {
final int sliceType = SliceBuilderUtils.getSliceType(mContext, controllerClassName,
key);
final boolean isPlatformSlice = bundle.getBoolean(METADATA_PLATFORM_SLICE_FLAG);
- final boolean isDynamicSummaryAllowed = bundle.getBoolean(
- METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE);
final String unavailableSliceSubtitle = bundle.getString(
METADATA_UNAVAILABLE_SLICE_SUBTITLE);
.setFragmentName(fragmentName)
.setSliceType(sliceType)
.setPlatformDefined(isPlatformSlice)
- .setDynamicSummaryAllowed(isDynamicSummaryAllowed)
.setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
}
/**
+ * Whether or not summary comes from something dynamic (ie, not hardcoded in xml)
+ */
+ default boolean useDynamicSliceSummary() {
+ return false;
+ }
+
+ /**
* Set the copy content to the clipboard and show the toast.
*/
static void setCopyContent(Context context, CharSequence copyContent,
IndexColumns.CONTROLLER,
IndexColumns.PLATFORM_SLICE,
IndexColumns.SLICE_TYPE,
- IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
};
cursor.getColumnIndex(IndexColumns.CONTROLLER));
final boolean isPlatformDefined = cursor.getInt(
cursor.getColumnIndex(IndexColumns.PLATFORM_SLICE)) == TRUE;
- final boolean isDynamicSummaryAllowed = cursor.getInt(
- cursor.getColumnIndex(IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE)) == TRUE;
int sliceType = cursor.getInt(
cursor.getColumnIndex(IndexColumns.SLICE_TYPE));
final String unavailableSliceSubtitle = cursor.getString(
.setUri(uri)
.setPlatformDefined(isPlatformDefined)
.setSliceType(sliceType)
- .setDynamicSummaryAllowed(isDynamicSummaryAllowed)
.setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
}
private static final String DATABASE_NAME = "slices_index.db";
private static final String SHARED_PREFS_TAG = "slices_shared_prefs";
- private static final int DATABASE_VERSION = 4;
+ private static final int DATABASE_VERSION = 5;
public interface Tables {
String TABLE_SLICES_INDEX = "slices_index";
String SLICE_TYPE = "slice_type";
/**
- * Boolean flag, {@code true} when the slice object prefers using the dynamic summary from
- * preference controller.
- */
- String ALLOW_DYNAMIC_SUMMARY_IN_SLICE = "allow_dynamic_summary_in_slice";
-
- /**
* Customized subtitle if it's a unavailable slice
*/
String UNAVAILABLE_SLICE_SUBTITLE = "unavailable_slice_subtitle";
", " +
IndexColumns.SLICE_TYPE +
", " +
- IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE +
- ", " +
IndexColumns.UNAVAILABLE_SLICE_SUBTITLE +
");";
values.put(IndexColumns.CONTROLLER, dataRow.getPreferenceController());
values.put(IndexColumns.PLATFORM_SLICE, dataRow.isPlatformDefined());
values.put(IndexColumns.SLICE_TYPE, dataRow.getSliceType());
- values.put(IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
- dataRow.isDynamicSummaryAllowed());
values.put(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
dataRow.getUnavailableSliceSubtitle());
android:title="title"
android:icon="@drawable/ic_android"
android:summary="summary1"
- settings:controller="com.android.settings.core.BadPreferenceController"
- settings:allowDynamicSummaryInSlice="true"/>
+ settings:controller="com.android.settings.core.BadPreferenceController"/>
<Preference
android:key="key2"
android:title="title"
android:icon="@drawable/ic_android"
android:summary="summary2"
- settings:controller="com.android.settings.slices.FakePreferenceController"
- settings:allowDynamicSummaryInSlice="true"/>
+ settings:controller="com.android.settings.slices.FakePreferenceController"/>
</PreferenceScreen>
\ No newline at end of file
settings:controller="com.android.settings.slices.FakePreferenceController"
settings:keywords="a, b, c"
settings:platform_slice="true"
- settings:allowDynamicSummaryInSlice="true"
settings:unavailableSliceSubtitle="subtitleOfUnavailableSlice"/>
</PreferenceScreen>
\ No newline at end of file
public int getAvailabilityStatus() {
return AVAILABLE;
}
+
+ @Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
}
package com.android.settings.core;
-import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_APPEND;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEY;
import static com.android.settings.core.PreferenceXmlParserUtils.METADATA_KEYWORDS;
@Test
@Config(qualifiers = "mcc999")
- public void extractMetadata_requestIsDynamicSummaryAllowed_shouldDefaultToFalse()
- throws Exception {
- final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
- R.xml.display_settings, MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE);
-
- for (Bundle bundle : metadata) {
- assertThat(bundle.getBoolean(METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE)).isFalse();
- }
- }
-
- @Test
- @Config(qualifiers = "mcc998")
- public void extractMetadata_requestIsDynamicSummaryAllowed_shouldReturnAttributeValue()
- throws Exception {
- final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
- R.xml.location_settings, MetadataFlag.FLAG_ALLOW_DYNAMIC_SUMMARY_IN_SLICE);
-
- for (Bundle bundle : metadata) {
- assertThat(bundle.getBoolean(METADATA_ALLOW_DYNAMIC_SUMMARY_IN_SLICE)).isTrue();
- }
- }
-
- @Test
- @Config(qualifiers = "mcc999")
public void extractMetadata_requestAppendProperty_shouldDefaultToFalse()
throws Exception {
final List<Bundle> metadata = PreferenceXmlParserUtils.extractMetadata(mContext,
public boolean isSliceable() {
return true;
}
+
+ @Override
+ public boolean useDynamicSliceSummary() {
+ return true;
+ }
}
private final Class SLIDER_CONTROLLER = FakeSliderController.class;
private final Class COPYABLE_CONTROLLER = FakeCopyableController.class;
private final Class CONTEXT_CONTROLLER = FakeContextOnlyPreferenceController.class;
- private final boolean IS_DYNAMIC_SUMMARY_ALLOWED = false;
private final String INTENT_PATH = SettingsSlicesContract.PATH_SETTING_INTENT + "/" + KEY;
private final String ACTION_PATH = SettingsSlicesContract.PATH_SETTING_ACTION + "/" + KEY;
@Test
public void getDynamicSummary_allowDynamicSummary_returnsControllerSummary() {
- final SliceData data = getDummyData(true /*isDynamicSummaryAllowed*/);
+ final SliceData data = getDummyData();
final FakePreferenceController controller = spy(
new FakePreferenceController(mContext, KEY));
final String controllerSummary = "new_Summary";
@Test
public void getDynamicSummary_allowDynamicSummary_nullSummary_returnsNull() {
- final SliceData data = getDummyData(true /*isDynamicSummaryAllowed*/);
+ final SliceData data = getDummyData();
final FakePreferenceController controller = spy(
new FakePreferenceController(mContext, KEY));
- final String controllerSummary = null;
- doReturn(controllerSummary).when(controller).getSummary();
- final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
-
- assertThat(summary).isNull();
- }
-
- @Test
- public void getDynamicSummary_returnsScreenTitle() {
- final SliceData data = getDummyData();
- final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
+ doReturn(null).when(controller).getSummary();
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
- assertThat(summary).isEqualTo(data.getScreenTitle());
+ assertThat(summary).isNull();
}
@Test
final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
- assertThat(summary).isEqualTo("");
- }
-
- @Test
- public void
- getDynamicSummary_emptyScreenTitle_placeHolderControllerSummary_returnsEmptyString() {
- final SliceData data = getDummyData(mContext.getString(R.string.summary_placeholder), null);
- final FakePreferenceController controller = new FakePreferenceController(mContext, KEY);
- final CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
-
- assertThat(summary).isEqualTo("");
+ assertThat(summary).isNull();
}
@Test
CharSequence summary = SliceBuilderUtils.getSubtitleText(mContext, controller, data);
- assertThat(summary).isEqualTo("");
+ assertThat(summary).isEqualTo(summaryPlaceholder);
}
@Test
R.drawable.ic_settings_accent).toIcon().getResId();
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
- IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
+ null /* unavailableSliceSubtitle */);
Settings.Global.putInt(mContext.getContentResolver(),
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
final String subtitleOfUnavailableSlice = "subtitleOfUnavailableSlice";
final SliceData data = getDummyData(FakeUnavailablePreferenceController.class,
SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE, 0 /* icon */,
- IS_DYNAMIC_SUMMARY_ALLOWED, subtitleOfUnavailableSlice);
+ subtitleOfUnavailableSlice);
Settings.Global.putInt(mContext.getContentResolver(),
FakeUnavailablePreferenceController.AVAILABILITY_KEY,
BasePreferenceController.DISABLED_DEPENDENT_SETTING);
private SliceData getDummyData() {
return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
- ICON, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
- }
-
- private SliceData getDummyData(boolean isDynamicSummaryAllowed) {
- return getDummyData(TOGGLE_CONTROLLER, SUMMARY, SliceData.SliceType.SWITCH, SCREEN_TITLE,
- ICON, isDynamicSummaryAllowed, null /* unavailableSliceSubtitle */);
+ ICON, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, int sliceType, int icon) {
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE,
- icon, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
+ icon, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(String summary, String screenTitle) {
return getDummyData(TOGGLE_CONTROLLER, summary, SliceData.SliceType.SWITCH, screenTitle,
- ICON, IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
+ ICON, null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, int sliceType) {
return getDummyData(prefController, SUMMARY, sliceType, SCREEN_TITLE, ICON,
- IS_DYNAMIC_SUMMARY_ALLOWED, null /* unavailableSliceSubtitle */);
+ null /* unavailableSliceSubtitle */);
}
private SliceData getDummyData(Class prefController, String summary, int sliceType,
- String screenTitle, int icon, boolean isDynamicSummaryAllowed,
- String unavailableSliceSubtitle) {
+ String screenTitle, int icon, String unavailableSliceSubtitle) {
return new SliceData.Builder()
.setKey(KEY)
.setTitle(TITLE)
.setUri(URI)
.setPreferenceControllerClassName(prefController.getName())
.setSliceType(sliceType)
- .setDynamicSummaryAllowed(isDynamicSummaryAllowed)
.setUnavailableSliceSubtitle(unavailableSliceSubtitle)
.build();
}
assertThat(fakeSlice.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
assertThat(fakeSlice.getSliceType()).isEqualTo(SliceData.SliceType.SLIDER);
assertThat(fakeSlice.isPlatformDefined()).isTrue(); // from XML
- assertThat(fakeSlice.isDynamicSummaryAllowed()).isTrue(); // from XML
assertThat(fakeSlice.getUnavailableSliceSubtitle()).isEqualTo(
"subtitleOfUnavailableSlice"); // from XML
}
private final String PREF_CONTROLLER = "com.android.settings.slices.tester";
private final int SLICE_TYPE = SliceData.SliceType.SWITCH;
private final boolean IS_PLATFORM_DEFINED = true;
- private final boolean IS_DYNAMIC_SUMMARY_ALLOWED = true;
private final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
@Test
.setPreferenceControllerClassName(PREF_CONTROLLER)
.setSliceType(SLICE_TYPE)
.setPlatformDefined(IS_PLATFORM_DEFINED)
- .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED)
.setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE);
SliceData data = builder.build();
assertThat(data.getPreferenceController()).isEqualTo(PREF_CONTROLLER);
assertThat(data.getSliceType()).isEqualTo(SLICE_TYPE);
assertThat(data.isPlatformDefined()).isEqualTo(IS_PLATFORM_DEFINED);
- assertThat(data.isDynamicSummaryAllowed()).isEqualTo(IS_DYNAMIC_SUMMARY_ALLOWED);
assertThat(data.getUnavailableSliceSubtitle()).isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
}
}
@Test
- public void testBuilder_noDynamicSummaryAllowed_buildsMatchingObject() {
- SliceData.Builder builder = new SliceData.Builder()
- .setKey(KEY)
- .setTitle(TITLE)
- .setSummary(SUMMARY)
- .setScreenTitle(SCREEN_TITLE)
- .setIcon(ICON)
- .setFragmentName(FRAGMENT_NAME)
- .setUri(URI)
- .setPreferenceControllerClassName(PREF_CONTROLLER);
-
- SliceData data = builder.build();
-
- assertThat(data.getKey()).isEqualTo(KEY);
- assertThat(data.getTitle()).isEqualTo(TITLE);
- assertThat(data.getSummary()).isEqualTo(SUMMARY);
- assertThat(data.getScreenTitle()).isEqualTo(SCREEN_TITLE);
- assertThat(data.getIconResource()).isEqualTo(ICON);
- assertThat(data.getFragmentClassName()).isEqualTo(FRAGMENT_NAME);
- assertThat(data.getUri()).isEqualTo(URI);
- assertThat(data.getPreferenceController()).isEqualTo(PREF_CONTROLLER);
- assertThat(data.isDynamicSummaryAllowed()).isFalse();
- }
-
- @Test
public void testEquality_identicalObjects() {
SliceData.Builder builder = new SliceData.Builder()
.setKey(KEY)
.setIcon(ICON)
.setFragmentName(FRAGMENT_NAME)
.setUri(URI)
- .setPreferenceControllerClassName(PREF_CONTROLLER)
- .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED);
+ .setPreferenceControllerClassName(PREF_CONTROLLER);
SliceData dataOne = builder.build();
SliceData dataTwo = builder.build();
assertThat(data.getFragmentClassName()).isEqualTo(FAKE_FRAGMENT_NAME);
assertThat(data.getUri()).isNull();
assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
- assertThat(data.isDynamicSummaryAllowed()).isFalse(); /* default value */
assertThat(data.getUnavailableSliceSubtitle()).isNull();
}
@Test
public void testGetSliceDataFromKey_allowDynamicSummary_validSliceReturned() {
String key = "key";
- insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
+ insertSpecialCase(key, true /* isPlatformSlice */,
null /* customizedUnavailableSliceSubtitle */);
SliceData data = mAccessor.getSliceDataFromKey(key);
assertThat(data.getFragmentClassName()).isEqualTo(FAKE_FRAGMENT_NAME);
assertThat(data.getUri()).isNull();
assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
- assertThat(data.isDynamicSummaryAllowed()).isTrue();
- }
-
- @Test
- public void testGetSliceDataFromKey_doNotAllowDynamicSummary_validSliceReturned() {
- String key = "key";
- insertSpecialCase(key, true /* isPlatformSlice */, false /* isDynamicSummaryAllowed */,
- null /* customizedUnavailableSliceSubtitle */);
-
- SliceData data = mAccessor.getSliceDataFromKey(key);
-
- assertThat(data.getKey()).isEqualTo(key);
- assertThat(data.getTitle()).isEqualTo(FAKE_TITLE);
- assertThat(data.getSummary()).isEqualTo(FAKE_SUMMARY);
- assertThat(data.getScreenTitle()).isEqualTo(FAKE_SCREEN_TITLE);
- assertThat(data.getKeywords()).isEqualTo(FAKE_KEYWORDS);
- assertThat(data.getIconResource()).isEqualTo(FAKE_ICON);
- assertThat(data.getFragmentClassName()).isEqualTo(FAKE_FRAGMENT_NAME);
- assertThat(data.getUri()).isNull();
- assertThat(data.getPreferenceController()).isEqualTo(FAKE_CONTROLLER_NAME);
- assertThat(data.isDynamicSummaryAllowed()).isFalse();
}
@Test(expected = IllegalStateException.class)
@Test
public void testGetSliceDataFromKey_defaultUnavailableSlice_validSliceReturned() {
String key = "key";
- insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
+ insertSpecialCase(key, true /* isPlatformSlice */,
null /* customizedUnavailableSliceSubtitle */);
SliceData data = mAccessor.getSliceDataFromKey(key);
public void testGetSliceDataFromKey_customizeSubtitleOfUnavailableSlice_validSliceReturned() {
String key = "key";
String subtitle = "subtitle";
- insertSpecialCase(key, true /* isPlatformSlice */, true /* isDynamicSummaryAllowed */,
- subtitle);
+ insertSpecialCase(key, true /* isPlatformSlice */, subtitle);
SliceData data = mAccessor.getSliceDataFromKey(key);
}
private void insertSpecialCase(String key, boolean isPlatformSlice) {
- insertSpecialCase(key, isPlatformSlice, false /* isDynamicSummaryAllowed */,
- null /*customizedUnavailableSliceSubtitle*/);
+ insertSpecialCase(key, isPlatformSlice, null /*customizedUnavailableSliceSubtitle*/);
}
private void insertSpecialCase(String key, boolean isPlatformSlice,
- boolean isDynamicSummaryAllowed, String customizedUnavailableSliceSubtitle) {
+ String customizedUnavailableSliceSubtitle) {
ContentValues values = new ContentValues();
values.put(SlicesDatabaseHelper.IndexColumns.KEY, key);
values.put(SlicesDatabaseHelper.IndexColumns.TITLE, FAKE_TITLE);
values.put(SlicesDatabaseHelper.IndexColumns.FRAGMENT, FAKE_FRAGMENT_NAME);
values.put(SlicesDatabaseHelper.IndexColumns.CONTROLLER, FAKE_CONTROLLER_NAME);
values.put(SlicesDatabaseHelper.IndexColumns.PLATFORM_SLICE, isPlatformSlice);
- values.put(SlicesDatabaseHelper.IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
- isDynamicSummaryAllowed);
values.put(SlicesDatabaseHelper.IndexColumns.SLICE_TYPE, SliceData.SliceType.INTENT);
values.put(SlicesDatabaseHelper.IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
customizedUnavailableSliceSubtitle);
IndexColumns.CONTROLLER,
IndexColumns.PLATFORM_SLICE,
IndexColumns.SLICE_TYPE,
- IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE,
IndexColumns.UNAVAILABLE_SLICE_SUBTITLE,
};
private final Uri URI = Uri.parse("content://com.android.settings.slices/test");
private final String PREF_CONTROLLER = "com.android.settings.slices.tester";
private final boolean PLATFORM_DEFINED = true;
- private final boolean IS_DYNAMIC_SUMMARY_ALLOWED = true;
private final int SLICE_TYPE = SliceData.SliceType.SLIDER;
private final String UNAVAILABLE_SLICE_SUBTITLE = "subtitleOfUnavailableSlice";
.isEqualTo(1 /* true */);
assertThat(cursor.getInt(cursor.getColumnIndex(IndexColumns.SLICE_TYPE)))
.isEqualTo(SLICE_TYPE);
- assertThat(cursor.getInt(
- cursor.getColumnIndex(
- IndexColumns.ALLOW_DYNAMIC_SUMMARY_IN_SLICE)))
- .isEqualTo(1 /* true */);
assertThat(cursor.getString(
cursor.getColumnIndex(IndexColumns.UNAVAILABLE_SLICE_SUBTITLE)))
.isEqualTo(UNAVAILABLE_SLICE_SUBTITLE);
.setPreferenceControllerClassName(PREF_CONTROLLER)
.setPlatformDefined(PLATFORM_DEFINED)
.setSliceType(SLICE_TYPE)
- .setDynamicSummaryAllowed(IS_DYNAMIC_SUMMARY_ALLOWED)
.setUnavailableSliceSubtitle(UNAVAILABLE_SLICE_SUBTITLE);
for (int i = 0; i < KEYS.length; i++) {