use of android.app.Notification.Action in project android_frameworks_base by AOSPA.
the class BugreportProgressService method updateProgress.
/**
* Updates the system notification for a given bugreport.
*/
private void updateProgress(BugreportInfo info) {
if (info.max <= 0 || info.progress < 0) {
Log.e(TAG, "Invalid progress values for " + info);
return;
}
if (info.finished) {
Log.w(TAG, "Not sending progress notification because bugreport has finished already (" + info + ")");
return;
}
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
final String percentageText = nf.format((double) info.progress / info.max);
String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
// TODO: Remove this workaround when notification progress is implemented on Wear.
if (mIsWatch) {
nf.setMinimumFractionDigits(0);
nf.setMaximumFractionDigits(0);
final String watchPercentageText = nf.format((double) info.progress / info.max);
title = title + "\n" + watchPercentageText;
}
final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed);
final Notification.Builder builder = newBaseNotification(mContext).setContentTitle(title).setTicker(title).setContentText(name).setProgress(info.max, info.progress, false).setOngoing(true);
// Wear bugreport doesn't need the bug info dialog, screenshot and cancel action.
if (!mIsWatch) {
final Action cancelAction = new Action.Builder(null, mContext.getString(com.android.internal.R.string.cancel), newCancelIntent(mContext, info)).build();
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
infoIntent.putExtra(EXTRA_ID, info.id);
final PendingIntent infoPendingIntent = PendingIntent.getService(mContext, info.id, infoIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action infoAction = new Action.Builder(null, mContext.getString(R.string.bugreport_info_action), infoPendingIntent).build();
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
screenshotIntent.putExtra(EXTRA_ID, info.id);
PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent.getService(mContext, info.id, screenshotIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action screenshotAction = new Action.Builder(null, mContext.getString(R.string.bugreport_screenshot_action), screenshotPendingIntent).build();
builder.setContentIntent(infoPendingIntent).setActions(infoAction, screenshotAction, cancelAction);
}
if (DEBUG) {
Log.d(TAG, "Sending 'Progress' notification for id " + info.id + " (pid " + info.pid + "): " + percentageText);
}
sendForegroundabledNotification(info.id, builder.build());
}
use of android.app.Notification.Action in project android_frameworks_base by ResurrectionRemix.
the class StorageNotification method onVolumeMounted.
private Notification onVolumeMounted(VolumeInfo vol) {
final VolumeRecord rec = mStorageManager.findRecordByUuid(vol.getFsUuid());
final DiskInfo disk = vol.getDisk();
// used to allow snoozing non-adoptable disks too.)
if (rec.isSnoozed() && disk.isAdoptable()) {
return null;
}
if (disk.isAdoptable() && !rec.isInited()) {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_new_notification_message, disk.getDescription());
final PendingIntent initIntent = buildInitPendingIntent(vol);
return buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_settings_24dp, mContext.getString(R.string.ext_media_init_action), initIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(initIntent).setDeleteIntent(buildSnoozeIntent(vol.getFsUuid())).setCategory(Notification.CATEGORY_SYSTEM).build();
} else {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_ready_notification_message, disk.getDescription());
final PendingIntent browseIntent = buildBrowsePendingIntent(vol);
final Notification.Builder builder = buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_folder_24dp, mContext.getString(R.string.ext_media_browse_action), browseIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(browseIntent).setCategory(Notification.CATEGORY_SYSTEM).setPriority(Notification.PRIORITY_LOW);
// USB disks notification can be persistent
if (disk.isUsb()) {
builder.setOngoing(mContext.getResources().getBoolean(R.bool.config_persistUsbDriveNotification));
}
// Non-adoptable disks can't be snoozed.
if (disk.isAdoptable()) {
builder.setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()));
}
return builder.build();
}
}
use of android.app.Notification.Action in project android_frameworks_base by ResurrectionRemix.
the class BugreportProgressService method updateProgress.
/**
* Updates the system notification for a given bugreport.
*/
private void updateProgress(BugreportInfo info) {
if (info.max <= 0 || info.progress < 0) {
Log.e(TAG, "Invalid progress values for " + info);
return;
}
if (info.finished) {
Log.w(TAG, "Not sending progress notification because bugreport has finished already (" + info + ")");
return;
}
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
final String percentageText = nf.format((double) info.progress / info.max);
String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
// TODO: Remove this workaround when notification progress is implemented on Wear.
if (mIsWatch) {
nf.setMinimumFractionDigits(0);
nf.setMaximumFractionDigits(0);
final String watchPercentageText = nf.format((double) info.progress / info.max);
title = title + "\n" + watchPercentageText;
}
final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed);
final Notification.Builder builder = newBaseNotification(mContext).setContentTitle(title).setTicker(title).setContentText(name).setProgress(info.max, info.progress, false).setOngoing(true);
// Wear bugreport doesn't need the bug info dialog, screenshot and cancel action.
if (!mIsWatch) {
final Action cancelAction = new Action.Builder(null, mContext.getString(com.android.internal.R.string.cancel), newCancelIntent(mContext, info)).build();
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
infoIntent.putExtra(EXTRA_ID, info.id);
final PendingIntent infoPendingIntent = PendingIntent.getService(mContext, info.id, infoIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action infoAction = new Action.Builder(null, mContext.getString(R.string.bugreport_info_action), infoPendingIntent).build();
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
screenshotIntent.putExtra(EXTRA_ID, info.id);
PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent.getService(mContext, info.id, screenshotIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action screenshotAction = new Action.Builder(null, mContext.getString(R.string.bugreport_screenshot_action), screenshotPendingIntent).build();
builder.setContentIntent(infoPendingIntent).setActions(infoAction, screenshotAction, cancelAction);
}
if (DEBUG) {
Log.d(TAG, "Sending 'Progress' notification for id " + info.id + " (pid " + info.pid + "): " + percentageText);
}
sendForegroundabledNotification(info.id, builder.build());
}
use of android.app.Notification.Action in project android_frameworks_base by DirtyUnicorns.
the class BugreportProgressService method updateProgress.
/**
* Updates the system notification for a given bugreport.
*/
private void updateProgress(BugreportInfo info) {
if (info.max <= 0 || info.progress < 0) {
Log.e(TAG, "Invalid progress values for " + info);
return;
}
if (info.finished) {
Log.w(TAG, "Not sending progress notification because bugreport has finished already (" + info + ")");
return;
}
final NumberFormat nf = NumberFormat.getPercentInstance();
nf.setMinimumFractionDigits(2);
nf.setMaximumFractionDigits(2);
final String percentageText = nf.format((double) info.progress / info.max);
String title = mContext.getString(R.string.bugreport_in_progress_title, info.id);
// TODO: Remove this workaround when notification progress is implemented on Wear.
if (mIsWatch) {
nf.setMinimumFractionDigits(0);
nf.setMaximumFractionDigits(0);
final String watchPercentageText = nf.format((double) info.progress / info.max);
title = title + "\n" + watchPercentageText;
}
final String name = info.name != null ? info.name : mContext.getString(R.string.bugreport_unnamed);
final Notification.Builder builder = newBaseNotification(mContext).setContentTitle(title).setTicker(title).setContentText(name).setProgress(info.max, info.progress, false).setOngoing(true);
// Wear bugreport doesn't need the bug info dialog, screenshot and cancel action.
if (!mIsWatch) {
final Action cancelAction = new Action.Builder(null, mContext.getString(com.android.internal.R.string.cancel), newCancelIntent(mContext, info)).build();
final Intent infoIntent = new Intent(mContext, BugreportProgressService.class);
infoIntent.setAction(INTENT_BUGREPORT_INFO_LAUNCH);
infoIntent.putExtra(EXTRA_ID, info.id);
final PendingIntent infoPendingIntent = PendingIntent.getService(mContext, info.id, infoIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action infoAction = new Action.Builder(null, mContext.getString(R.string.bugreport_info_action), infoPendingIntent).build();
final Intent screenshotIntent = new Intent(mContext, BugreportProgressService.class);
screenshotIntent.setAction(INTENT_BUGREPORT_SCREENSHOT);
screenshotIntent.putExtra(EXTRA_ID, info.id);
PendingIntent screenshotPendingIntent = mTakingScreenshot ? null : PendingIntent.getService(mContext, info.id, screenshotIntent, PendingIntent.FLAG_UPDATE_CURRENT);
final Action screenshotAction = new Action.Builder(null, mContext.getString(R.string.bugreport_screenshot_action), screenshotPendingIntent).build();
builder.setContentIntent(infoPendingIntent).setActions(infoAction, screenshotAction, cancelAction);
}
if (DEBUG) {
Log.d(TAG, "Sending 'Progress' notification for id " + info.id + " (pid " + info.pid + "): " + percentageText);
}
sendForegroundabledNotification(info.id, builder.build());
}
use of android.app.Notification.Action in project android_frameworks_base by crdroidandroid.
the class StorageNotification method onVolumeMounted.
private Notification onVolumeMounted(VolumeInfo vol) {
final VolumeRecord rec = mStorageManager.findRecordByUuid(vol.getFsUuid());
final DiskInfo disk = vol.getDisk();
// used to allow snoozing non-adoptable disks too.)
if (rec.isSnoozed() && disk.isAdoptable()) {
return null;
}
if (disk.isAdoptable() && !rec.isInited()) {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_new_notification_message, disk.getDescription());
final PendingIntent initIntent = buildInitPendingIntent(vol);
return buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_settings_24dp, mContext.getString(R.string.ext_media_init_action), initIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(initIntent).setDeleteIntent(buildSnoozeIntent(vol.getFsUuid())).setCategory(Notification.CATEGORY_SYSTEM).build();
} else {
final CharSequence title = disk.getDescription();
final CharSequence text = mContext.getString(R.string.ext_media_ready_notification_message, disk.getDescription());
final PendingIntent browseIntent = buildBrowsePendingIntent(vol);
final Notification.Builder builder = buildNotificationBuilder(vol, title, text).addAction(new Action(R.drawable.ic_folder_24dp, mContext.getString(R.string.ext_media_browse_action), browseIntent)).addAction(new Action(R.drawable.ic_eject_24dp, mContext.getString(R.string.ext_media_unmount_action), buildUnmountPendingIntent(vol))).setContentIntent(browseIntent).setCategory(Notification.CATEGORY_SYSTEM).setPriority(Notification.PRIORITY_LOW);
// USB disks notification can be persistent
if (disk.isUsb()) {
builder.setOngoing(mContext.getResources().getBoolean(R.bool.config_persistUsbDriveNotification));
}
// Non-adoptable disks can't be snoozed.
if (disk.isAdoptable()) {
builder.setDeleteIntent(buildSnoozeIntent(vol.getFsUuid()));
}
return builder.build();
}
}
Aggregations