use of androidx.core.app.NotificationManagerCompat in project react-native-push-notification by zo0r.
the class RNPushNotification method checkPermissions.
@ReactMethod
public void checkPermissions(Promise promise) {
ReactContext reactContext = getReactApplicationContext();
NotificationManagerCompat managerCompat = NotificationManagerCompat.from(reactContext);
promise.resolve(managerCompat.areNotificationsEnabled());
}
use of androidx.core.app.NotificationManagerCompat in project Slide by ccrama.
the class Reddit method setupNotificationChannels.
public void setupNotificationChannels() {
// Each triple contains the channel ID, name, and importance level
List<Triple<String, String, Integer>> notificationTripleList = new ArrayList<Triple<String, String, Integer>>() {
{
add(Triple.of(CHANNEL_IMG, "Image downloads", NotificationManagerCompat.IMPORTANCE_LOW));
add(Triple.of(CHANNEL_COMMENT_CACHE, "Comment caching", NotificationManagerCompat.IMPORTANCE_LOW));
add(Triple.of(CHANNEL_MAIL, "Reddit mail", NotificationManagerCompat.IMPORTANCE_HIGH));
add(Triple.of(CHANNEL_MODMAIL, "Reddit modmail", NotificationManagerCompat.IMPORTANCE_HIGH));
add(Triple.of(CHANNEL_SUBCHECKING, "Submission post checking", NotificationManagerCompat.IMPORTANCE_LOW));
}
};
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
for (Triple<String, String, Integer> notificationTriple : notificationTripleList) {
final NotificationChannelCompat notificationChannel = new NotificationChannelCompat.Builder(notificationTriple.getLeft(), notificationTriple.getRight()).setName(notificationTriple.getMiddle()).setLightsEnabled(true).setShowBadge(notificationTriple.getRight() == NotificationManagerCompat.IMPORTANCE_HIGH).setLightColor(notificationTriple.getLeft().contains("MODMAIL") ? ResourcesCompat.getColor(this.getResources(), R.color.md_red_500, null) : Palette.getColor("")).build();
notificationManager.createNotificationChannel(notificationChannel);
}
}
use of androidx.core.app.NotificationManagerCompat in project Applozic-Android-SDK by AppLozic.
the class NotificationService method startCallNotification.
// Cleanup: rename to a public api name eg: createApplozicCallNotification()
public void startCallNotification(Contact contact, Message message, String isAudioCallOnly, String callId) {
NotificationInfo notificationInfo = getNotificationInfo(contact, null, message);
if (notificationInfo == null) {
return;
}
Intent fullScreenIntent = null;
try {
fullScreenIntent = new Intent(context, Class.forName(VideoCallNotificationHelper.NOTIFICATION_ACTIVITY_NAME));
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
fullScreenIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
fullScreenIntent.putExtra("CONTACT_ID", message.getTo());
fullScreenIntent.putExtra(CALL_ID, callId);
if (!TextUtils.isEmpty(isAudioCallOnly) && "true".equals(isAudioCallOnly)) {
fullScreenIntent.putExtra(CALL_AUDIO_ONLY, true);
}
PendingIntent fullScreenPendingIntent = PendingIntent.getActivity(context, 0, fullScreenIntent, PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context, notificationChannels.getCallChannelId()).setSmallIcon(notificationInfo.smallIconResourceId).setContentTitle("Incoming call from " + notificationInfo.title + ".").setContentText("Tap to open call screen.").setVibrate(new long[] { 2000L, 1000L, 2000L, 1000L }).setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE)).setPriority(NotificationCompat.PRIORITY_HIGH).setCategory(NotificationCompat.CATEGORY_CALL).setFullScreenIntent(fullScreenPendingIntent, true);
if (notificationInfo.colorResourceId != null && notificationInfo.colorResourceId > 0) {
notificationBuilder.setColor(context.getResources().getColor(notificationInfo.colorResourceId));
}
Notification incomingCallNotification = notificationBuilder.build();
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(context);
notificationManager.notify(message.getGroupId() != null ? String.valueOf(message.getGroupId()).hashCode() : message.getContactIds().hashCode(), incomingCallNotification);
}
use of androidx.core.app.NotificationManagerCompat in project Applozic-Android-SDK by AppLozic.
the class WearableNotificationWithVoice method sendNotification.
/**
* This method is just like a wrapper class method for usual notification class which add voice actions
* for wearable devices
*
* @throws RuntimeException
*/
// Cleanup: defalut
public void sendNotification() throws Exception {
if (pendingIntent == null && notificationHandler == null) {
throw new RuntimeException("Either pendingIntent or handler class requires.");
}
// Action action = buildWearableAction(); removed remote input action for now
Notification notification = notificationBuilder.extend(new WearableExtender()).build();
if (ApplozicClient.getInstance(mContext).isNotificationSmallIconHidden() && Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
int smallIconViewId = mContext.getResources().getIdentifier("right_icon", "id", android.R.class.getPackage().getName());
if (smallIconViewId != 0) {
if (notification.contentIntent != null && notification.contentView != null) {
notification.contentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
if (notification.headsUpContentView != null) {
notification.headsUpContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
}
if (notification.bigContentView != null) {
notification.bigContentView.setViewVisibility(smallIconViewId, View.INVISIBLE);
}
}
}
}
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mContext);
notificationManager.notify(notificationId, notification);
}
use of androidx.core.app.NotificationManagerCompat in project Conversations by siacs.
the class ImportBackupService method updateImportBackupNotification.
private void updateImportBackupNotification(final long total, final long current) {
final int max;
final int progress;
if (total == 0) {
max = 1;
progress = 0;
} else {
max = 100;
progress = (int) (current * 100 / total);
}
final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(this);
try {
notificationManager.notify(NOTIFICATION_ID, createImportBackupNotification(max, progress));
} catch (final RuntimeException e) {
Log.d(Config.LOGTAG, "unable to make notification", e);
}
}
Aggregations