Search in sources :

Example 66 with RequiresApi

use of androidx.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationChannelUtils method createSilentChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public static String createSilentChannel(NotificationManager notifManager) {
    @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(SILENT_CHANNEL_ID, getString(R.string.channel_silent_title), NotificationManager.IMPORTANCE_LOW);
    channel.setDescription(getString(R.string.channel_silent_description));
    channel.setShowBadge(true);
    notifManager.createNotificationChannel(channel);
    return channel.getId();
}
Also used : NotificationChannel(android.app.NotificationChannel) SuppressLint(android.annotation.SuppressLint) RequiresApi(androidx.annotation.RequiresApi)

Example 67 with RequiresApi

use of androidx.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationChannelUtils method updateMessageChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public static String updateMessageChannel(NotificationManager notifManager, ChannelType type, Uri newSound, long[] newVibro, AudioAttributes newAudioAttrs) {
    // settings
    NotificationChannel channel = getMessageChannel(notifManager, type);
    Uri sound = (newSound != null) ? newSound : channel.getSound();
    long[] vibro = (newVibro != null) ? newVibro : channel.getVibrationPattern();
    AudioAttributes audioAttrs = (newAudioAttrs != null) ? newAudioAttrs : channel.getAudioAttributes();
    // delete old channel
    notifManager.deleteNotificationChannel(getChannelID(type));
    // need to change channel settings
    updateChannelID(type);
    return createMessageChannel(notifManager, type, sound, vibro, audioAttrs);
}
Also used : NotificationChannel(android.app.NotificationChannel) AudioAttributes(android.media.AudioAttributes) Uri(android.net.Uri) RequiresApi(androidx.annotation.RequiresApi)

Example 68 with RequiresApi

use of androidx.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationChannelUtils method createCustomChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public static String createCustomChannel(NotificationManager notifManager, CharSequence name, String description, Uri sound, long[] vibro, AudioAttributes audioAttrs) {
    String id = UUID.randomUUID().toString();
    @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(id, name, android.app.NotificationManager.IMPORTANCE_HIGH);
    channel.setDescription(description);
    if (vibro != null)
        channel.setVibrationPattern(vibro);
    if (sound != null && audioAttrs != null)
        channel.setSound(sound, audioAttrs);
    notifManager.createNotificationChannel(channel);
    return id;
}
Also used : NotificationChannel(android.app.NotificationChannel) SuppressLint(android.annotation.SuppressLint) RequiresApi(androidx.annotation.RequiresApi)

Example 69 with RequiresApi

use of androidx.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationChannelUtils method createMessageChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public static String createMessageChannel(NotificationManager notifManager, ChannelType type, Uri sound, long[] vibro, AudioAttributes audioAttrs) {
    @SuppressLint("WrongConstant") NotificationChannel channel = new NotificationChannel(getChannelID(type), getNameByType(type), android.app.NotificationManager.IMPORTANCE_HIGH);
    channel.setDescription(getDescriptionByType(type));
    if (vibro != null)
        channel.setVibrationPattern(vibro);
    if (sound != null && audioAttrs != null)
        channel.setSound(sound, audioAttrs);
    notifManager.createNotificationChannel(channel);
    return getChannelID(type);
}
Also used : NotificationChannel(android.app.NotificationChannel) SuppressLint(android.annotation.SuppressLint) RequiresApi(androidx.annotation.RequiresApi)

Example 70 with RequiresApi

use of androidx.annotation.RequiresApi in project xabber-android by redsolution.

the class NotificationChannelUtils method updateCustomChannel.

@RequiresApi(api = Build.VERSION_CODES.O)
public static String updateCustomChannel(NotificationManager notifManager, String channelID, Uri newSound, long[] newVibro, AudioAttributes newAudioAttrs) {
    // settings
    NotificationChannel channel = notifManager.getNotificationChannel(channelID);
    Uri sound = (newSound != null) ? newSound : channel.getSound();
    long[] vibro = (newVibro != null) ? newVibro : channel.getVibrationPattern();
    AudioAttributes audioAttrs = (newAudioAttrs != null) ? newAudioAttrs : channel.getAudioAttributes();
    CharSequence name = channel.getName();
    String description = channel.getDescription();
    // delete old channel
    notifManager.deleteNotificationChannel(channelID);
    // need to change channel settings
    return createCustomChannel(notifManager, name, description, sound, vibro, audioAttrs);
}
Also used : NotificationChannel(android.app.NotificationChannel) AudioAttributes(android.media.AudioAttributes) Uri(android.net.Uri) RequiresApi(androidx.annotation.RequiresApi)

Aggregations

RequiresApi (androidx.annotation.RequiresApi)117 NotificationChannel (android.app.NotificationChannel)16 Intent (android.content.Intent)13 SuppressLint (android.annotation.SuppressLint)10 NotificationManager (android.app.NotificationManager)9 Uri (android.net.Uri)9 StatusBarNotification (android.service.notification.StatusBarNotification)9 NonNull (androidx.annotation.NonNull)9 IOException (java.io.IOException)8 Notification (android.app.Notification)6 PendingIntent (android.app.PendingIntent)6 Context (android.content.Context)6 ObjectAnimator (android.animation.ObjectAnimator)5 Bundle (android.os.Bundle)5 ByteBuffer (java.nio.ByteBuffer)5 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 SecretKey (javax.crypto.SecretKey)5 GestureDescription (android.accessibilityservice.GestureDescription)4 TaskStackBuilder (android.app.TaskStackBuilder)4 Bitmap (android.graphics.Bitmap)4