use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class LowStorageSlice method getSlice.
@Override
public Slice getSlice() {
// Get used storage percentage from StorageManager.
final PrivateStorageInfo info = PrivateStorageInfo.getPrivateStorageInfo(new StorageManagerVolumeProvider(mContext.getSystemService(StorageManager.class)));
final double usedPercentage = (double) (info.totalBytes - info.freeBytes) / info.totalBytes;
// Generate Low storage Slice.
final String percentageString = NumberFormat.getPercentInstance().format(usedPercentage);
final String freeSizeString = Formatter.formatFileSize(mContext, info.freeBytes);
final ListBuilder listBuilder = new ListBuilder(mContext, CustomSliceRegistry.LOW_STORAGE_SLICE_URI, ListBuilder.INFINITY).setAccentColor(Utils.getColorAccentDefaultColor(mContext));
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.ic_storage);
if (usedPercentage < LOW_STORAGE_THRESHOLD) {
// For clients that ignore error checking, a generic storage slice will be given.
final CharSequence titleStorage = mContext.getText(R.string.storage_settings);
final String summaryStorage = mContext.getString(R.string.storage_summary, percentageString, freeSizeString);
return listBuilder.addRow(buildRowBuilder(titleStorage, summaryStorage, icon)).setIsError(true).build();
}
final CharSequence titleLowStorage = mContext.getText(R.string.storage_menu_free);
final String summaryLowStorage = mContext.getString(R.string.low_storage_summary, percentageString, freeSizeString);
return listBuilder.addRow(buildRowBuilder(titleLowStorage, summaryLowStorage, icon)).build();
}
use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class WifiCallingSliceHelper method wifiPreferenceRowBuilder.
/**
* Returns RowBuilder for a new row containing specific wifi calling preference.
*
* @param listBuilder ListBuilder that will be the parent for this RowBuilder
* @param preferenceTitleResId resource Id for the preference row title
* @param action action to be added for the row
* @param subId subscription id
* @return RowBuilder for the row
*/
private RowBuilder wifiPreferenceRowBuilder(ListBuilder listBuilder, int preferenceTitleResId, String action, boolean checked, int subId) {
final IconCompat icon = IconCompat.createWithResource(mContext, R.drawable.radio_button_check);
final Resources res = getResourcesForSubId(subId);
return new RowBuilder().setTitle(res.getText(preferenceTitleResId)).setTitleItem(SliceAction.createToggle(getBroadcastIntent(action), icon, res.getText(preferenceTitleResId), checked));
}
use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class BluetoothSliceBuilderTest method getBluetoothSlice_correctSliceContent.
@Test
public void getBluetoothSlice_correctSliceContent() {
final Slice BluetoothSlice = BluetoothSliceBuilder.getSlice(mContext);
final SliceMetadata metadata = SliceMetadata.from(mContext, BluetoothSlice);
assertThat(metadata.getTitle()).isEqualTo(mContext.getString(R.string.bluetooth_settings_title));
final List<SliceAction> toggles = metadata.getToggles();
assertThat(toggles).hasSize(1);
final SliceAction primaryAction = metadata.getPrimaryAction();
final IconCompat expectedToggleIcon = IconCompat.createWithResource(mContext, com.android.internal.R.drawable.ic_settings_bluetooth);
assertThat(primaryAction.getIcon().toString()).isEqualTo(expectedToggleIcon.toString());
}
use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class ProviderModelSlice method getSeeAllRow.
protected ListBuilder.RowBuilder getSeeAllRow() {
final CharSequence title = mContext.getText(R.string.previous_connected_see_all);
final IconCompat icon = getSeeAllIcon();
return new ListBuilder.RowBuilder().setTitleItem(icon, ListBuilder.ICON_IMAGE).setTitle(title).setPrimaryAction(getPrimaryAction(icon, title));
}
use of androidx.core.graphics.drawable.IconCompat in project android_packages_apps_Settings by omnirom.
the class UtilsTest method createIconWithDrawable_BitmapDrawable.
@Test
public void createIconWithDrawable_BitmapDrawable() {
final Bitmap bitmap = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888);
final BitmapDrawable drawable = new BitmapDrawable(mContext.getResources(), bitmap);
final IconCompat icon = Utils.createIconWithDrawable(drawable);
assertThat(icon.getBitmap()).isNotNull();
}
Aggregations