Search in sources :

Example 1 with ListBuilder

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

the class WifiSlice method getHeaderRow.

private ListBuilder getHeaderRow(boolean isWifiEnabled) {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_settings_wireless);
    final String title = mContext.getString(R.string.wifi_settings);
    final PendingIntent toggleAction = getBroadcastIntent(mContext);
    final PendingIntent primaryAction = getPrimaryAction();
    final SliceAction primarySliceAction = SliceAction.createDeeplink(primaryAction, icon, ListBuilder.ICON_IMAGE, title);
    final SliceAction toggleSliceAction = SliceAction.createToggle(toggleAction, null, /* actionTitle */
    isWifiEnabled);
    return new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(COLOR_NOT_TINTED).setKeywords(getKeywords()).addRow(new ListBuilder.RowBuilder().setTitle(title).addEndItem(toggleSliceAction).setPrimaryAction(primarySliceAction));
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) PendingIntent(android.app.PendingIntent)

Example 2 with ListBuilder

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

the class SliceDeferredSetupCardRendererHelperTest method buildSlice.

private Slice buildSlice() {
    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).setSubtitle(SUMMARY).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 3 with ListBuilder

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

the class SliceFullCardRendererHelperTest 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 4 with ListBuilder

use of androidx.slice.builders.ListBuilder 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();
}
Also used : IconCompat(androidx.core.graphics.drawable.IconCompat) DataUsageController(com.android.settingslib.net.DataUsageController) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) SpannableString(android.text.SpannableString) SubscriptionManager(android.telephony.SubscriptionManager)

Example 5 with ListBuilder

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

the class EmergencyInfoSlice method getSlice.

@Override
public Slice getSlice() {
    final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.EMERGENCY_INFO_SLICE_URI, ListBuilder.INFINITY);
    listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(mContext.getText(R.string.emergency_info_title)).setSubtitle(mContext.getText(R.string.emergency_info_contextual_card_summary)).setPrimaryAction(createPrimaryAction()));
    return listBuilder.build();
}
Also used : ListBuilder(androidx.slice.builders.ListBuilder)

Aggregations

ListBuilder (androidx.slice.builders.ListBuilder)30 IconCompat (androidx.core.graphics.drawable.IconCompat)26 SliceAction (androidx.slice.builders.SliceAction)20 PendingIntent (android.app.PendingIntent)17 ColorInt (android.annotation.ColorInt)12 RowBuilder (androidx.slice.builders.ListBuilder.RowBuilder)9 Intent (android.content.Intent)4 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)2 Drawable (android.graphics.drawable.Drawable)2 PrivateStorageInfo (com.android.settingslib.deviceinfo.PrivateStorageInfo)2 Bundle (android.os.Bundle)1 SubscriptionManager (android.telephony.SubscriptionManager)1 SpannableString (android.text.SpannableString)1 InputRangeBuilder (androidx.slice.builders.ListBuilder.InputRangeBuilder)1 SliderPreferenceController (com.android.settings.core.SliderPreferenceController)1 TogglePreferenceController (com.android.settings.core.TogglePreferenceController)1 BatteryTip (com.android.settings.fuelgauge.batterytip.tips.BatteryTip)1 SliceBackgroundWorker (com.android.settings.slices.SliceBackgroundWorker)1 StorageManagerVolumeProvider (com.android.settingslib.deviceinfo.StorageManagerVolumeProvider)1 MediaDevice (com.android.settingslib.media.MediaDevice)1