use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BatteryFixSlice method getSlice.
@Override
public Slice getSlice() {
final ListBuilder sliceBuilder = new ListBuilder(mContext, BATTERY_FIX_SLICE_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
if (!isBatteryTipAvailableFromCache(mContext)) {
return buildBatteryGoodSlice(sliceBuilder, true);
}
final SliceBackgroundWorker worker = SliceBackgroundWorker.getInstance(getUri());
final List<BatteryTip> batteryTips = worker != null ? worker.getResults() : null;
if (batteryTips == null) {
// Because we need wait slice background worker return data
return buildBatteryGoodSlice(sliceBuilder, false);
}
for (BatteryTip batteryTip : batteryTips) {
if (batteryTip.getState() == BatteryTip.StateType.INVISIBLE) {
continue;
}
final Drawable drawable = mContext.getDrawable(batteryTip.getIconId());
final int iconTintColorId = batteryTip.getIconTintColorId();
if (iconTintColorId != View.NO_ID) {
drawable.setColorFilter(new PorterDuffColorFilter(mContext.getResources().getColor(iconTintColorId), PorterDuff.Mode.SRC_IN));
}
final IconCompat icon = Utils.createIconWithDrawable(drawable);
final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, batteryTip.getTitle(mContext));
sliceBuilder.addRow(new RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(batteryTip.getTitle(mContext)).setSubtitle(batteryTip.getSummary(mContext)).setPrimaryAction(primaryAction));
break;
}
return sliceBuilder.build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class BluetoothDevicesSlice method getSlice.
@Override
public Slice getSlice() {
// Reload theme for switching dark mode on/off
mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true);
final IconCompat icon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
final Drawable d = mContext.getDrawable(R.drawable.ic_add_24dp);
int color = Utils.getColorAttrDefaultColor(mContext, android.R.attr.colorControlNormal);
d.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.SRC_IN));
final IconCompat pairNewIcon = Utils.createIconWithDrawable(d);
final CharSequence title = mContext.getText(R.string.bluetooth_devices);
final CharSequence titleNoBluetoothDevices = mContext.getText(R.string.no_bluetooth_devices);
final CharSequence titlePairNew = mContext.getText(R.string.bluetooth_pairing_pref_title);
final PendingIntent primaryActionIntent = PendingIntent.getActivity(mContext, 0, getIntent(), 0);
final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryActionIntent, icon, ListBuilder.ICON_IMAGE, title);
final PendingIntent pairNewActionIntent = PendingIntent.getActivity(mContext, 0, getPairNewIntent(), 0);
final SliceAction pairNewAction = SliceAction.createDeeplink(pairNewActionIntent, pairNewIcon, ListBuilder.ICON_IMAGE, titlePairNew);
final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
// Get row builders by Bluetooth devices.
final List<ListBuilder.RowBuilder> rows = getBluetoothRowBuilder();
// Return a header with IsError flag, if no Bluetooth devices.
if (rows.isEmpty()) {
listBuilder.setHeader(new ListBuilder.HeaderBuilder().setTitle(titleNoBluetoothDevices).setPrimaryAction(primarySliceAction));
if (!BluetoothAdapter.getDefaultAdapter().isEnabled()) {
// this will hide the slice!
listBuilder.setIsError(true);
}
// add pair new row
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(pairNewIcon, ListBuilder.ICON_IMAGE).setTitle(titlePairNew).setPrimaryAction(pairNewAction);
listBuilder.addRow(rowBuilder);
return listBuilder.build();
}
// Get displayable device count.
final int deviceCount = Math.min(rows.size(), DEFAULT_EXPANDED_ROW_COUNT);
// According to the displayable device count to set sub title of header.
listBuilder.setHeader(new ListBuilder.HeaderBuilder().setTitle(title).setSubtitle(getSubTitle(deviceCount)).setPrimaryAction(primarySliceAction));
// According to the displayable device count to add bluetooth device rows.
for (int i = 0; i < deviceCount; i++) {
listBuilder.addRow(rows.get(i));
}
// add pair new row
final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(pairNewIcon, ListBuilder.ICON_IMAGE).setTitle(titlePairNew).setPrimaryAction(pairNewAction);
listBuilder.addRow(rowBuilder);
return listBuilder.build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class ContextualAdaptiveSleepSlice method getSlice.
@Override
public Slice getSlice() {
final long setupTime = mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE).getLong(PREF_KEY_SETUP_TIME, DEFAULT_SETUP_TIME);
if (setupTime == DEFAULT_SETUP_TIME) {
// Set the first setup time.
mContext.getSharedPreferences(PREF, Context.MODE_PRIVATE).edit().putLong(PREF_KEY_SETUP_TIME, System.currentTimeMillis()).apply();
return null;
}
// 4. Screen Attention is off.
if (isSettingsAvailable() && !isUserInteracted() && !isRecentlySetup() && !isTurnedOn()) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_adaptive_sleep);
final CharSequence title = mContext.getText(R.string.adaptive_sleep_title);
final CharSequence subtitle = mContext.getText(R.string.adaptive_sleep_contextual_slice_summary);
final SliceAction pAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
final ListBuilder listBuilder = new ListBuilder(mContext, CONTEXTUAL_ADAPTIVE_SLEEP_URI, ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).addRow(new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(subtitle).setPrimaryAction(pAction));
return listBuilder.build();
} else {
return null;
}
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class DarkThemeSlice method getSlice.
@Override
public Slice getSlice() {
final long currentUiSession = FeatureFactory.getFactory(mContext).getSlicesFeatureProvider().getUiSessionToken();
if (currentUiSession != sActiveUiSession) {
sActiveUiSession = currentUiSession;
sKeepSliceShow = false;
}
// Dark theme slice will disappear when battery saver is ON.
if (mPowerManager.isPowerSaveMode() || (!sKeepSliceShow && !isAvailable(mContext))) {
return new ListBuilder(mContext, CustomSliceRegistry.DARK_THEME_SLICE_URI, ListBuilder.INFINITY).setIsError(true).build();
}
sKeepSliceShow = true;
final PendingIntent toggleAction = getBroadcastIntent(mContext);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.dark_theme);
return new ListBuilder(mContext, CustomSliceRegistry.DARK_THEME_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.dark_theme_slice_title)).setTitleItem(icon, ICON_IMAGE).setSubtitle(mContext.getText(R.string.dark_theme_slice_subtitle)).setPrimaryAction(SliceAction.createToggle(toggleAction, null, /* actionTitle */
isDarkThemeMode(mContext)))).build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class NotificationChannelSlice method getNoSuggestedAppHeader.
private ListBuilder.HeaderBuilder getNoSuggestedAppHeader() {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_homepage_apps);
final CharSequence titleNoSuggestedApp = mContext.getString(R.string.no_suggested_app);
final SliceAction primarySliceActionForNoSuggestedApp = getPrimarySliceAction(icon, titleNoSuggestedApp, getAppAndNotificationPageIntent());
return new ListBuilder.HeaderBuilder().setTitle(titleNoSuggestedApp).setPrimaryAction(primarySliceActionForNoSuggestedApp);
}
Aggregations