use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceTester method testSettingsSliderSlice.
/**
* Test the contents of an slider based slice, including:
* - No intent
* - Correct title
* - Correct keywords
* - TTL
* - Color
*/
public static void testSettingsSliderSlice(Context context, Slice slice, SliceData sliceData) {
final SliceMetadata metadata = SliceMetadata.from(context, slice);
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
final int color = colorItem.getInt();
assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(context, sliceData.getIconResource());
assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
final long sliceTTL = metadata.getExpiry();
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
final int headerType = metadata.getHeaderType();
assertThat(headerType).isEqualTo(EventInfo.ROW_TYPE_SLIDER);
// Check primary intent
final PendingIntent primaryPendingIntent = primaryAction.getAction();
assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(context, sliceData));
assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DataUsageSlice method getSlice.
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_data_usage);
final String title = mContext.getString(R.string.data_usage_summary_title);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
DataUsageController dataUsageController = new DataUsageController(mContext);
DataUsageController.DataUsageInfo info = null;
SubscriptionManager subscriptionManager = (SubscriptionManager) mContext.getSystemService(Context.TELEPHONY_SUBSCRIPTION_SERVICE);
int defaultSubId = subscriptionManager.getDefaultDataSubscriptionId();
boolean showDailyDataUsage = Settings.System.getInt(mContext.getContentResolver(), Settings.System.DATA_USAGE_PERIOD, 1) == 0;
if (defaultSubId == SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
info = dataUsageController.getDataUsageInfo();
} else {
info = showDailyDataUsage ? dataUsageController.getDailyDataUsageInfo(DataUsageUtils.getMobileTemplate(mContext, defaultSubId)) : dataUsageController.getDataUsageInfo(DataUsageUtils.getMobileTemplate(mContext, defaultSubId));
}
final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.DATA_USAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).setHeader(new ListBuilder.HeaderBuilder().setTitle(title));
if (DataUsageUtils.hasSim(mContext)) {
listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(getDataUsageText(info)).setSubtitle(getCycleTime(info)).setPrimaryAction(primaryAction));
} else {
listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.no_sim_card)).setPrimaryAction(primaryAction));
}
return listBuilder.build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MediaOutputIndicatorSlice method getSlice.
@Override
public Slice getSlice() {
if (!isVisible()) {
return null;
}
final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
final CharSequence title = mContext.getText(R.string.media_output_title);
final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext, 0, /* requestCode */
getMediaOutputSliceIntent(), 0);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final ListBuilder listBuilder = new ListBuilder(mContext, MEDIA_OUTPUT_INDICATOR_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setSubtitle(findActiveDeviceName()).setPrimaryAction(primarySliceAction));
return listBuilder.build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class LocationSlice method getSlice.
@Override
public Slice getSlice() {
final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_signal_location);
final CharSequence title = mContext.getText(R.string.location_settings_title);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final PendingIntent primaryAction = getPrimaryAction();
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
return new ListBuilder(mContext, CustomSliceRegistry.LOCATION_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ICON_IMAGE).setPrimaryAction(primarySliceAction)).build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class MediaOutputSlice method getMediaDeviceRow.
private ListBuilder.RowBuilder getMediaDeviceRow(MediaDevice device) {
final String title = device.getName();
final PendingIntent broadcastAction = getBroadcastIntent(mContext, device.getId(), device.hashCode());
final IconCompat deviceIcon = getDeviceIconCompat(device);
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(deviceIcon, ListBuilder.ICON_IMAGE).setPrimaryAction(SliceAction.create(broadcastAction, deviceIcon, ListBuilder.ICON_IMAGE, title)).setTitle(title).setSubtitle(device.getSummary());
return rowBuilder;
}
Aggregations