Search in sources :

Example 1 with SliceAction

use of androidx.slice.builders.SliceAction 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 SliceAction

use of androidx.slice.builders.SliceAction 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 SliceAction

use of androidx.slice.builders.SliceAction 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 SliceAction

use of androidx.slice.builders.SliceAction 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 SliceAction

use of androidx.slice.builders.SliceAction 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)

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