Search in sources :

Example 11 with NotificationManagerCompat

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());
}
Also used : ReactContext(com.facebook.react.bridge.ReactContext) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) ReactMethod(com.facebook.react.bridge.ReactMethod)

Example 12 with NotificationManagerCompat

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);
    }
}
Also used : Triple(org.apache.commons.lang3.tuple.Triple) ArrayList(java.util.ArrayList) NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) NotificationChannelCompat(androidx.core.app.NotificationChannelCompat)

Example 13 with NotificationManagerCompat

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);
}
Also used : NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) NotificationCompat(androidx.core.app.NotificationCompat) Intent(android.content.Intent) PendingIntent(android.app.PendingIntent) PendingIntent(android.app.PendingIntent) Notification(android.app.Notification)

Example 14 with NotificationManagerCompat

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);
}
Also used : NotificationManagerCompat(androidx.core.app.NotificationManagerCompat) Notification(android.app.Notification) WearableExtender(androidx.core.app.NotificationCompat.WearableExtender)

Example 15 with NotificationManagerCompat

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);
    }
}
Also used : NotificationManagerCompat(androidx.core.app.NotificationManagerCompat)

Aggregations

NotificationManagerCompat (androidx.core.app.NotificationManagerCompat)26 PendingIntent (android.app.PendingIntent)6 Notification (android.app.Notification)5 Intent (android.content.Intent)5 NotificationCompat (androidx.core.app.NotificationCompat)5 NotificationChannel (android.app.NotificationChannel)2 NotificationManager (android.app.NotificationManager)2 Bundle (android.os.Bundle)2 NotificationChannelCompat (androidx.core.app.NotificationChannelCompat)2 TaskStackBuilder (android.app.TaskStackBuilder)1 Bitmap (android.graphics.Bitmap)1 RequiresApi (androidx.annotation.RequiresApi)1 NotificationChannelGroupCompat (androidx.core.app.NotificationChannelGroupCompat)1 WearableExtender (androidx.core.app.NotificationCompat.WearableExtender)1 RemoteInput (androidx.core.app.RemoteInput)1 TaskStackBuilder (androidx.core.app.TaskStackBuilder)1 MediaStyle (androidx.media.app.NotificationCompat.MediaStyle)1 SwipeRefreshLayout (androidx.swiperefreshlayout.widget.SwipeRefreshLayout)1 MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)1 ApplozicException (com.applozic.mobicomkit.exception.ApplozicException)1