use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class WifiCallingSliceHelper method getWifiCallingPreferenceSlice.
/**
* Returns actionable wifi calling preference slice.
*
* @param isWifiOnlySupported adds row for wifi only if this is true
* @param currentWfcPref current Preference {@link ImsConfig}
* @param sliceUri sliceUri
* @return Slice for actionable wifi calling preference settings
*/
private Slice getWifiCallingPreferenceSlice(boolean isWifiOnlySupported, int currentWfcPref, Uri sliceUri) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.wifi_signal);
// Top row shows information on current preference state
ListBuilder listBuilder = new ListBuilder(mContext, sliceUri, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
listBuilder.setHeader(new ListBuilder.HeaderBuilder().setTitle(mContext.getText(R.string.wifi_calling_mode_title)).setSubtitle(getWifiCallingPreferenceSummary(currentWfcPref)).setPrimaryAction(SliceAction.createDeeplink(getActivityIntent(ACTION_WIFI_CALLING_SETTINGS_ACTIVITY), icon, ListBuilder.ICON_IMAGE, mContext.getText(R.string.wifi_calling_mode_title))));
if (isWifiOnlySupported) {
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_only_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_ONLY, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_ONLY));
}
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_wifi_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_WIFI_PREFERRED, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.WIFI_PREFERRED));
listBuilder.addRow(wifiPreferenceRowBuilder(listBuilder, com.android.internal.R.string.wfc_mode_cellular_preferred_summary, ACTION_WIFI_CALLING_PREFERENCE_CELLULAR_PREFERRED, currentWfcPref == ImsConfig.WfcModeFeatureValueConstants.CELLULAR_PREFERRED));
return listBuilder.build();
}
use of androidx.core.graphics.drawable.IconCompat in project Resurrection_packages_apps_Settings by ResurrectionRemix.
the class SliceTester method testSettingsCopyableSlice.
/**
* Test the copyable slice, including:
* - No intent
* - Correct title
* - Correct intent
* - Correct keywords
* - TTL
* - Color
*/
public static void testSettingsCopyableSlice(Context context, Slice slice, SliceData sliceData) {
final SliceMetadata metadata = SliceMetadata.from(context, slice);
final SliceItem colorItem = SliceQuery.findSubtype(slice, FORMAT_INT, SUBTYPE_COLOR);
final int color = colorItem.getInt();
assertThat(color).isEqualTo(Utils.getColorAccentDefaultColor(context));
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedIcon = IconCompat.createWithResource(context, sliceData.getIconResource());
assertThat(expectedIcon.toString()).isEqualTo(primaryAction.getIcon().toString());
final long sliceTTL = metadata.getExpiry();
assertThat(sliceTTL).isEqualTo(ListBuilder.INFINITY);
// Check primary intent
final PendingIntent primaryPendingIntent = primaryAction.getAction();
assertThat(primaryPendingIntent).isEqualTo(SliceBuilderUtils.getContentPendingIntent(context, sliceData));
assertThat(metadata.getTitle()).isEqualTo(sliceData.getTitle());
assertKeywords(metadata, sliceData);
}
use of androidx.core.graphics.drawable.IconCompat 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();
}
use of androidx.core.graphics.drawable.IconCompat 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();
}
use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class FlashlightSlice method getSlice.
@Override
public Slice getSlice() {
if (!isFlashlightAvailable(mContext)) {
return null;
}
final PendingIntent toggleAction = getBroadcastIntent(mContext);
@ColorInt final int color = Utils.getColorAccentDefaultColor(mContext);
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_signal_flashlight);
return new ListBuilder(mContext, CustomSliceRegistry.FLASHLIGHT_SLICE_URI, ListBuilder.INFINITY).setAccentColor(color).addRow(new RowBuilder().setTitle(mContext.getText(R.string.power_flashlight)).setTitleItem(icon, ICON_IMAGE).setPrimaryAction(SliceAction.createToggle(toggleAction, null, isFlashlightEnabled(mContext)))).build();
}
Aggregations