Search in sources :

Example 6 with ListBuilder

use of androidx.slice.builders.ListBuilder 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();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 7 with ListBuilder

use of androidx.slice.builders.ListBuilder 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();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

Example 8 with ListBuilder

use of androidx.slice.builders.ListBuilder in project Resurrection_packages_apps_Settings by ResurrectionRemix.

the class MediaOutputSlice method getSlice.

@Override
public Slice getSlice() {
    // Reload theme for switching dark mode on/off
    mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true);
    final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED);
    if (!isVisible()) {
        Log.d(TAG, "getSlice() is not visible");
        return listBuilder.build();
    }
    final List<MediaDevice> devices = getMediaDevices();
    final MediaDevice connectedDevice = getWorker().getCurrentConnectedMediaDevice();
    if (connectedDevice != null) {
        listBuilder.addRow(getActiveDeviceHeaderRow(connectedDevice));
    }
    for (MediaDevice device : devices) {
        if (connectedDevice == null || !TextUtils.equals(connectedDevice.getId(), device.getId())) {
            listBuilder.addRow(getMediaDeviceRow(device));
        }
    }
    return listBuilder.build();
}
Also used : ListBuilder(androidx.slice.builders.ListBuilder) MediaDevice(com.android.settingslib.media.MediaDevice)

Example 9 with ListBuilder

use of androidx.slice.builders.ListBuilder 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();
}
Also used : SliceBackgroundWorker(com.android.settings.slices.SliceBackgroundWorker) IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder) BatteryTip(com.android.settings.fuelgauge.batterytip.tips.BatteryTip)

Example 10 with ListBuilder

use of androidx.slice.builders.ListBuilder 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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) Drawable(android.graphics.drawable.Drawable) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Aggregations

ListBuilder (androidx.slice.builders.ListBuilder)58 IconCompat (androidx.core.graphics.drawable.IconCompat)47 SliceAction (androidx.slice.builders.SliceAction)34 PendingIntent (android.app.PendingIntent)31 ColorInt (android.annotation.ColorInt)25 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)20 Intent (android.content.Intent)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 Drawable (android.graphics.drawable.Drawable)3 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)3 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)3 Resources (android.content.res.Resources)2 SpannableString (android.text.SpannableString)2 SliderPreferenceController (com.android.settings.core.SliderPreferenceController)2 TogglePreferenceController (com.android.settings.core.TogglePreferenceController)2 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)2 SliceBackgroundWorker (com.android.settings.slices.SliceBackgroundWorker)2 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)2 AlertDialog (android.app.AlertDialog)1 BluetoothAdapter (android.bluetooth.BluetoothAdapter)1