use of android.app.NotificationChannelGroup in project xDrip by NightscoutFoundation.
the class NotificationChannels method cleanAllNotificationChannels.
@TargetApi(26)
public static void cleanAllNotificationChannels() {
// TODO this isn't right yet
List<NotificationChannel> channels = getNotifManager().getNotificationChannels();
for (NotificationChannel channel : channels) {
getNotifManager().deleteNotificationChannel(channel.getId());
}
List<NotificationChannelGroup> groups = getNotifManager().getNotificationChannelGroups();
for (NotificationChannelGroup group : groups) {
getNotifManager().deleteNotificationChannel(group.getId());
}
}
use of android.app.NotificationChannelGroup in project xDrip-plus by jamorham.
the class NotificationChannels method getChan.
@TargetApi(26)
public static NotificationChannel getChan(NotificationCompat.Builder wip) {
final Notification temp = wip.build();
if (temp.getChannelId() == null)
return null;
// create generic audio attributes
final AudioAttributes generic_audio = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN).build();
// create notification channel for hashing purposes from the existing notification builder
NotificationChannel template = new NotificationChannel(temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT);
// mirror the notification parameters in the channel
template.setGroup(temp.getChannelId());
template.setVibrationPattern(wip.mNotification.vibrate);
template.setSound(wip.mNotification.sound, generic_audio);
template.setLightColor(wip.mNotification.ledARGB);
if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// get a nice string to identify the hash
final String mhash = my_text_hash(template);
// create another notification channel using the hash because id is immutable
final NotificationChannel channel = new NotificationChannel(template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT);
// mirror the settings from the previous channel
channel.setSound(template.getSound(), generic_audio);
if (addChannelGroup()) {
channel.setGroup(template.getGroup());
} else {
channel.setGroup(channel.getId());
}
channel.setDescription(template.getDescription());
channel.setVibrationPattern(template.getVibrationPattern());
template.setLightColor(wip.mNotification.ledARGB);
if ((wip.mNotification.ledOnMS != 0) && (wip.mNotification.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// create a group to hold this channel if one doesn't exist or update text
getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup())));
// create this channel if it doesn't exist or update text
getNotifManager().createNotificationChannel(channel);
return channel;
}
use of android.app.NotificationChannelGroup in project xDrip-plus by jamorham.
the class NotificationChannels method cleanAllNotificationChannels.
@TargetApi(26)
public static void cleanAllNotificationChannels() {
// TODO this isn't right yet
List<NotificationChannel> channels = getNotifManager().getNotificationChannels();
for (NotificationChannel channel : channels) {
getNotifManager().deleteNotificationChannel(channel.getId());
}
List<NotificationChannelGroup> groups = getNotifManager().getNotificationChannelGroups();
for (NotificationChannelGroup group : groups) {
getNotifManager().deleteNotificationChannel(group.getId());
}
}
use of android.app.NotificationChannelGroup in project xDrip-plus by jamorham.
the class NotificationChannels method getChan.
@TargetApi(26)
public static NotificationChannel getChan(Notification.Builder wip) {
final Notification temp = wip.build();
if (temp.getChannelId() == null)
return null;
// create generic audio attributes
final AudioAttributes generic_audio = new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).setContentType(AudioAttributes.CONTENT_TYPE_UNKNOWN).build();
// create notification channel for hashing purposes from the existing notification builder
NotificationChannel template = new NotificationChannel(temp.getChannelId(), getString(temp.getChannelId()), NotificationManager.IMPORTANCE_DEFAULT);
// mirror the notification parameters in the channel
template.setGroup(temp.getChannelId());
template.setVibrationPattern(temp.vibrate);
template.setSound(temp.sound, generic_audio);
template.setLightColor(temp.ledARGB);
if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// get a nice string to identify the hash
final String mhash = my_text_hash(template);
// create another notification channel using the hash because id is immutable
final NotificationChannel channel = new NotificationChannel(template.getId() + mhash, getString(temp.getChannelId()) + mhash, NotificationManager.IMPORTANCE_DEFAULT);
// mirror the settings from the previous channel
channel.setSound(template.getSound(), generic_audio);
if (addChannelGroup()) {
channel.setGroup(template.getGroup());
} else {
channel.setGroup(channel.getId());
}
channel.setDescription(template.getDescription());
channel.setVibrationPattern(template.getVibrationPattern());
template.setLightColor(temp.ledARGB);
if ((temp.ledOnMS != 0) && (temp.ledOffMS != 0))
// weird how this doesn't work like vibration pattern
template.enableLights(true);
template.setDescription(temp.getChannelId() + " " + wip.hashCode());
// create a group to hold this channel if one doesn't exist or update text
getNotifManager().createNotificationChannelGroup(new NotificationChannelGroup(channel.getGroup(), getString(channel.getGroup())));
// create this channel if it doesn't exist or update text
getNotifManager().createNotificationChannel(channel);
return channel;
}
use of android.app.NotificationChannelGroup in project android_packages_apps_Settings by omnirom.
the class AppNotificationSettings method populateChannelList.
private void populateChannelList() {
if (!mChannelGroups.isEmpty()) {
// If there's anything in mChannelGroups, we've called populateChannelList twice.
// Clear out existing channels and log.
Log.w(TAG, "Notification channel group posted twice to settings - old size " + mChannelGroups.size() + ", new size " + mChannelGroupList.size());
for (Preference p : mChannelGroups) {
getPreferenceScreen().removePreference(p);
}
}
if (mChannelGroupList.isEmpty()) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
groupCategory.setTitle(R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
Preference empty = new Preference(getPrefContext());
empty.setTitle(R.string.no_channels);
empty.setEnabled(false);
groupCategory.addPreference(empty);
} else {
for (NotificationChannelGroup group : mChannelGroupList) {
PreferenceCategory groupCategory = new PreferenceCategory(getPrefContext());
if (group.getId() == null) {
groupCategory.setTitle(mChannelGroupList.size() > 1 ? R.string.notification_channels_other : R.string.notification_channels);
groupCategory.setKey(KEY_GENERAL_CATEGORY);
} else {
groupCategory.setTitle(group.getName());
groupCategory.setKey(group.getId());
}
groupCategory.setOrderingAsAdded(true);
getPreferenceScreen().addPreference(groupCategory);
mChannelGroups.add(groupCategory);
final List<NotificationChannel> channels = group.getChannels();
Collections.sort(channels, mChannelComparator);
int N = channels.size();
for (int i = 0; i < N; i++) {
final NotificationChannel channel = channels.get(i);
populateSingleChannelPrefs(groupCategory, channel);
}
}
int deletedChannelCount = mBackend.getDeletedChannelCount(mAppRow.pkg, mAppRow.uid);
if (deletedChannelCount > 0 && getPreferenceScreen().findPreference(KEY_DELETED) == null) {
mDeletedChannels = new FooterPreference(getPrefContext());
mDeletedChannels.setSelectable(false);
mDeletedChannels.setTitle(getResources().getQuantityString(R.plurals.deleted_channels, deletedChannelCount, deletedChannelCount));
mDeletedChannels.setEnabled(false);
mDeletedChannels.setKey(KEY_DELETED);
mDeletedChannels.setOrder(ORDER_LAST);
getPreferenceScreen().addPreference(mDeletedChannels);
}
}
updateDependents(mAppRow.banned);
}
Aggregations