Search in sources :

Example 31 with SliceAction

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

the class MediaOutputSlice method getActiveDeviceHeaderRow.

private ListBuilder.RowBuilder getActiveDeviceHeaderRow(MediaDevice device) {
    final String title = device.getName();
    final IconCompat icon = getDeviceIconCompat(device);
    final PendingIntent broadcastAction = getBroadcastIntent(mContext, device.getId(), device.hashCode());
    final SliceAction primarySliceAction = SliceAction.createDeeplink(broadcastAction, icon, ListBuilder.ICON_IMAGE, title);
    final ListBuilder.RowBuilder rowBuilder = new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setSubtitle(device.getSummary()).setPrimaryAction(primarySliceAction);
    return rowBuilder;
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 32 with SliceAction

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

the class DeviceInfoSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_info_outline_24dp);
    final String title = mContext.getString(R.string.device_info_label);
    final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder(mContext, CustomSliceRegistry.DEVICE_INFO_SLICE_URI, ListBuilder.INFINITY).setAccentColor((Utils.getColorAccentDefaultColor(mContext))).setHeader(new ListBuilder.HeaderBuilder().setTitle(title)).addRow(new ListBuilder.RowBuilder().setTitle(getPhoneNumber()).setSubtitle(getDeviceModel()).setPrimaryAction(primaryAction)).build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder)

Example 33 with SliceAction

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

the class StorageSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_homepage_storage);
    final String title = mContext.getString(R.string.storage_label);
    final SliceAction primaryAction = SliceAction.createDeeplink(getPrimaryAction(), icon, ListBuilder.ICON_IMAGE, title);
    final PrivateStorageInfo info = getPrivateStorageInfo();
    return new ListBuilder(mContext, CustomSliceRegistry.STORAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext)).setHeader(new ListBuilder.HeaderBuilder().setTitle(title)).addRow(new ListBuilder.RowBuilder().setTitle(getStorageUsedText(info)).setSubtitle(getStorageSummaryText(info)).setPrimaryAction(primaryAction)).build();
}
Also used : PrivateStorageInfo(com.android.settingslib.deviceinfo.PrivateStorageInfo) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder)

Example 34 with SliceAction

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

the class SliceHalfCardRendererHelperTest method buildSlice.

private Slice buildSlice() {
    final String title = "test_title";
    final IconCompat icon = IconCompat.createWithResource(mActivity, R.drawable.empty_icon);
    final PendingIntent pendingIntent = PendingIntent.getActivity(mActivity, title.hashCode(), /* requestCode */
    new Intent("test action"), 0);
    final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, title);
    return new ListBuilder(mActivity, TEST_SLICE_URI, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(action)).build();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 35 with SliceAction

use of androidx.slice.builders.SliceAction in project android_packages_apps_Settings by omnirom.

the class BluetoothSliceBuilder method getSlice.

/**
 * Return a Bluetooth Slice bound to {@link CustomSliceRegistry#BLUETOOTH_URI}.
 * <p>
 * Note that you should register a listener for {@link #INTENT_FILTER} to get changes for
 * Bluetooth.
 */
public static Slice getSlice(Context context) {
    final boolean isBluetoothEnabled = isBluetoothEnabled();
    final CharSequence title = context.getText(R.string.bluetooth_settings);
    final IconCompat icon = IconCompat.createWithResource(context, com.android.internal.R.drawable.ic_settings_bluetooth);
    @ColorInt final int color = com.android.settings.Utils.getColorAccent(context).getDefaultColor();
    final PendingIntent toggleAction = getBroadcastIntent(context);
    final PendingIntent primaryAction = getPrimaryAction(context);
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isBluetoothEnabled);
    return new ListBuilder(context, CustomSliceRegistry.BLUETOOTH_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).addEndItem(toggleSliceAction).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)

Aggregations

SliceAction (androidx.slice.builders.SliceAction)46 IconCompat (androidx.core.graphics.drawable.IconCompat)39 ListBuilder (androidx.slice.builders.ListBuilder)37 PendingIntent (android.app.PendingIntent)32 ColorInt (android.annotation.ColorInt)18 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)16 Intent (android.content.Intent)10 Drawable (android.graphics.drawable.Drawable)6 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)3 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)3 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 SliceBroadcastReceiver (com.android.settings.slices.SliceBroadcastReceiver)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Uri (android.net.Uri)1 Bundle (android.os.Bundle)1 SubscriptionManager (android.telephony.SubscriptionManager)1 SpannableString (android.text.SpannableString)1