Search in sources :

Example 31 with ListBuilder

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

the class ContextualCardFeatureProviderImplTest method buildSlice.

private Slice buildSlice(Uri sliceUri, String packageName) {
    final Bundle args = new Bundle();
    args.putString(AppInfoBase.ARG_PACKAGE_NAME, packageName);
    final Intent intent = new Intent("action");
    intent.putExtra(SettingsActivity.EXTRA_SHOW_FRAGMENT_ARGUMENTS, args);
    final PendingIntent pendingIntent = spy(PendingIntent.getActivity(mContext, 0, /* requestCode */
    intent, 0));
    doReturn(intent).when(pendingIntent).getIntent();
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.empty_icon);
    final SliceAction action = SliceAction.createDeeplink(pendingIntent, icon, ListBuilder.SMALL_IMAGE, "title");
    return new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).addRow(new ListBuilder.RowBuilder().addEndItem(icon, ListBuilder.ICON_IMAGE).setTitle("title").setPrimaryAction(action)).build();
}
Also used : Bundle(android.os.Bundle) 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 32 with ListBuilder

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

the class WifiSlice method getSlice.

@Override
public Slice getSlice() {
    // Reload theme for switching dark mode on/off
    mContext.getTheme().applyStyle(R.style.Theme_Settings_Home, true);
    final boolean isWifiEnabled = isWifiEnabled();
    ListBuilder listBuilder = getHeaderRow(isWifiEnabled);
    if (!isWifiEnabled) {
        WifiScanWorker.clearClickedWifi();
        return listBuilder.build();
    }
    final WifiScanWorker worker = SliceBackgroundWorker.getInstance(getUri());
    final List<AccessPoint> apList = worker != null ? worker.getResults() : null;
    final int apCount = apList == null ? 0 : apList.size();
    final boolean isFirstApActive = apCount > 0 && apList.get(0).isActive();
    handleNetworkCallback(worker, isFirstApActive);
    // Need a loading text when results are not ready or out of date.
    boolean needLoadingRow = true;
    // Skip checking the existence of the first access point if it's active
    int index = isFirstApActive ? 1 : 0;
    // AP list.
    for (; index < apCount; index++) {
        if (apList.get(index).isReachable()) {
            needLoadingRow = false;
            break;
        }
    }
    // Add AP rows
    final CharSequence placeholder = mContext.getText(R.string.summary_placeholder);
    for (int i = 0; i < DEFAULT_EXPANDED_ROW_COUNT; i++) {
        if (i < apCount) {
            listBuilder.addRow(getAccessPointRow(apList.get(i)));
        } else if (needLoadingRow) {
            listBuilder.addRow(getLoadingRow(placeholder));
            needLoadingRow = false;
        } else {
            listBuilder.addRow(new ListBuilder.RowBuilder().setTitle(placeholder).setSubtitle(placeholder));
        }
    }
    return listBuilder.build();
}
Also used : AccessPoint(com.android.settingslib.wifi.AccessPoint) ListBuilder(androidx.slice.builders.ListBuilder) AccessPoint(com.android.settingslib.wifi.AccessPoint)

Example 33 with ListBuilder

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

the class MobileDataSlice method getSlice.

@Override
public Slice getSlice() {
    final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_network_cell);
    final String title = mContext.getText(R.string.mobile_data_settings_title).toString();
    @ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
    // Return null until we can show a disabled-action Slice, blaming Airplane mode.
    if (isAirplaneModeEnabled()) {
        return null;
    }
    // Return null until we can show a disabled-action Slice.
    if (!isMobileDataAvailable()) {
        return null;
    }
    final CharSequence summary = getSummary();
    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 */
    isMobileDataEnabled());
    final ListBuilder listBuilder = new ListBuilder(mContext, getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new ListBuilder.RowBuilder().setTitle(title).setSubtitle(summary).addEndItem(toggleSliceAction).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 34 with ListBuilder

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

the class SliceBuilderUtils method buildToggleSlice.

private static Slice buildToggleSlice(Context context, SliceData sliceData, BasePreferenceController controller) {
    final PendingIntent contentIntent = getContentPendingIntent(context, sliceData);
    final IconCompat icon = getSafeIcon(context, sliceData);
    final CharSequence subtitleText = getSubtitleText(context, controller, sliceData);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
    final TogglePreferenceController toggleController = (TogglePreferenceController) controller;
    final SliceAction sliceAction = getToggleAction(context, sliceData, toggleController.isChecked());
    final Set<String> keywords = buildSliceKeywords(sliceData);
    return new ListBuilder(context, sliceData.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(sliceData.getTitle()).setSubtitle(subtitleText).setPrimaryAction(SliceAction.createDeeplink(contentIntent, icon, ListBuilder.ICON_IMAGE, sliceData.getTitle())).addEndItem(sliceAction)).setKeywords(keywords).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) TogglePreferenceController(com.android.settings.core.TogglePreferenceController)

Example 35 with ListBuilder

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

the class SliceBuilderUtils method buildUnavailableSlice.

private static Slice buildUnavailableSlice(Context context, SliceData data) {
    final String title = data.getTitle();
    final Set<String> keywords = buildSliceKeywords(data);
    @ColorInt final int color = Utils.getColorAccentDefaultColor(context);
    final String customSubtitle = data.getUnavailableSliceSubtitle();
    final CharSequence subtitle = !TextUtils.isEmpty(customSubtitle) ? customSubtitle : context.getText(R.string.disabled_dependent_setting_summary);
    final IconCompat icon = getSafeIcon(context, data);
    final SliceAction primaryAction = SliceAction.createDeeplink(getContentPendingIntent(context, data), icon, ListBuilder.ICON_IMAGE, title);
    return new ListBuilder(context, data.getUri(), ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(title).setTitleItem(icon, ListBuilder.ICON_IMAGE).setSubtitle(subtitle).setPrimaryAction(primaryAction)).setKeywords(keywords).build();
}
Also used : ColorInt(android.annotation.ColorInt) IconCompat(androidx.core.graphics.drawable.IconCompat) SliceAction(androidx.slice.builders.SliceAction) ListBuilder(androidx.slice.builders.ListBuilder) RowBuilder(androidx.slice.builders.ListBuilder.RowBuilder)

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