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();
}
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);
}
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;
}
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);
}
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);
}
Aggregations