use of androidx.annotation.RequiresApi in project Conversations by siacs.
the class NotificationService method initializeChannels.
@RequiresApi(api = Build.VERSION_CODES.O)
void initializeChannels() {
final Context c = mXmppConnectionService;
final NotificationManager notificationManager = c.getSystemService(NotificationManager.class);
if (notificationManager == null) {
return;
}
notificationManager.deleteNotificationChannel("export");
notificationManager.deleteNotificationChannel("incoming_calls");
notificationManager.createNotificationChannelGroup(new NotificationChannelGroup("status", c.getString(R.string.notification_group_status_information)));
notificationManager.createNotificationChannelGroup(new NotificationChannelGroup("chats", c.getString(R.string.notification_group_messages)));
notificationManager.createNotificationChannelGroup(new NotificationChannelGroup("calls", c.getString(R.string.notification_group_calls)));
final NotificationChannel foregroundServiceChannel = new NotificationChannel("foreground", c.getString(R.string.foreground_service_channel_name), NotificationManager.IMPORTANCE_MIN);
foregroundServiceChannel.setDescription(c.getString(R.string.foreground_service_channel_description, c.getString(R.string.app_name)));
foregroundServiceChannel.setShowBadge(false);
foregroundServiceChannel.setGroup("status");
notificationManager.createNotificationChannel(foregroundServiceChannel);
final NotificationChannel errorChannel = new NotificationChannel("error", c.getString(R.string.error_channel_name), NotificationManager.IMPORTANCE_LOW);
errorChannel.setDescription(c.getString(R.string.error_channel_description));
errorChannel.setShowBadge(false);
errorChannel.setGroup("status");
notificationManager.createNotificationChannel(errorChannel);
final NotificationChannel videoCompressionChannel = new NotificationChannel("compression", c.getString(R.string.video_compression_channel_name), NotificationManager.IMPORTANCE_LOW);
videoCompressionChannel.setShowBadge(false);
videoCompressionChannel.setGroup("status");
notificationManager.createNotificationChannel(videoCompressionChannel);
final NotificationChannel exportChannel = new NotificationChannel("backup", c.getString(R.string.backup_channel_name), NotificationManager.IMPORTANCE_LOW);
exportChannel.setShowBadge(false);
exportChannel.setGroup("status");
notificationManager.createNotificationChannel(exportChannel);
final NotificationChannel incomingCallsChannel = new NotificationChannel(INCOMING_CALLS_NOTIFICATION_CHANNEL, c.getString(R.string.incoming_calls_channel_name), NotificationManager.IMPORTANCE_HIGH);
incomingCallsChannel.setSound(null, null);
incomingCallsChannel.setShowBadge(false);
incomingCallsChannel.setLightColor(LED_COLOR);
incomingCallsChannel.enableLights(true);
incomingCallsChannel.setGroup("calls");
incomingCallsChannel.setBypassDnd(true);
incomingCallsChannel.enableVibration(false);
notificationManager.createNotificationChannel(incomingCallsChannel);
final NotificationChannel ongoingCallsChannel = new NotificationChannel("ongoing_calls", c.getString(R.string.ongoing_calls_channel_name), NotificationManager.IMPORTANCE_LOW);
ongoingCallsChannel.setShowBadge(false);
ongoingCallsChannel.setGroup("calls");
notificationManager.createNotificationChannel(ongoingCallsChannel);
final NotificationChannel messagesChannel = new NotificationChannel("messages", c.getString(R.string.messages_channel_name), NotificationManager.IMPORTANCE_HIGH);
messagesChannel.setShowBadge(true);
messagesChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build());
messagesChannel.setLightColor(LED_COLOR);
final int dat = 70;
final long[] pattern = { 0, 3 * dat, dat, dat };
messagesChannel.setVibrationPattern(pattern);
messagesChannel.enableVibration(true);
messagesChannel.enableLights(true);
messagesChannel.setGroup("chats");
notificationManager.createNotificationChannel(messagesChannel);
final NotificationChannel silentMessagesChannel = new NotificationChannel("silent_messages", c.getString(R.string.silent_messages_channel_name), NotificationManager.IMPORTANCE_LOW);
silentMessagesChannel.setDescription(c.getString(R.string.silent_messages_channel_description));
silentMessagesChannel.setShowBadge(true);
silentMessagesChannel.setLightColor(LED_COLOR);
silentMessagesChannel.enableLights(true);
silentMessagesChannel.setGroup("chats");
notificationManager.createNotificationChannel(silentMessagesChannel);
final NotificationChannel quietHoursChannel = new NotificationChannel("quiet_hours", c.getString(R.string.title_pref_quiet_hours), NotificationManager.IMPORTANCE_LOW);
quietHoursChannel.setShowBadge(true);
quietHoursChannel.setLightColor(LED_COLOR);
quietHoursChannel.enableLights(true);
quietHoursChannel.setGroup("chats");
quietHoursChannel.enableVibration(false);
quietHoursChannel.setSound(null, null);
notificationManager.createNotificationChannel(quietHoursChannel);
final NotificationChannel deliveryFailedChannel = new NotificationChannel("delivery_failed", c.getString(R.string.delivery_failed_channel_name), NotificationManager.IMPORTANCE_DEFAULT);
deliveryFailedChannel.setShowBadge(false);
deliveryFailedChannel.setSound(RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION), new AudioAttributes.Builder().setContentType(AudioAttributes.CONTENT_TYPE_SONIFICATION).setUsage(AudioAttributes.USAGE_NOTIFICATION_COMMUNICATION_INSTANT).build());
deliveryFailedChannel.setGroup("chats");
notificationManager.createNotificationChannel(deliveryFailedChannel);
}
use of androidx.annotation.RequiresApi in project Douya by DreaminginCodeZH.
the class ResourcesFlusher method flushThemedResourceCache.
@MainThread
@RequiresApi(Build.VERSION_CODES.M)
@SuppressLint("PrivateApi")
private static void flushThemedResourceCache(@NonNull Object themedResourceCache) {
if (!sThemedResourceCacheClassInitialized) {
try {
sThemedResourceCacheClass = Class.forName("android.content.res.ThemedResourceCache");
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
sThemedResourceCacheClassInitialized = true;
}
if (sThemedResourceCacheClass == null) {
return;
}
if (!sThemedResourceCacheMThemedEntriesFieldInitialized) {
try {
sThemedResourceCacheMThemedEntriesField = sThemedResourceCacheClass.getDeclaredField("mThemedEntries");
sThemedResourceCacheMThemedEntriesField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
sThemedResourceCacheMThemedEntriesFieldInitialized = true;
}
if (sThemedResourceCacheMThemedEntriesField != null) {
ArrayMap themedEntries = null;
try {
themedEntries = (ArrayMap) sThemedResourceCacheMThemedEntriesField.get(themedResourceCache);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (themedEntries != null) {
themedEntries.clear();
}
}
if (!sThemedResourceCacheMUnthemedEntriesFieldInitialized) {
try {
sThemedResourceCacheMUnthemedEntriesField = sThemedResourceCacheClass.getDeclaredField("mUnthemedEntries");
sThemedResourceCacheMUnthemedEntriesField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
sThemedResourceCacheMUnthemedEntriesFieldInitialized = true;
}
if (sThemedResourceCacheMUnthemedEntriesField != null) {
LongSparseArray unthemedEntries = null;
try {
unthemedEntries = (LongSparseArray) sThemedResourceCacheMUnthemedEntriesField.get(themedResourceCache);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (unthemedEntries != null) {
unthemedEntries.clear();
}
}
if (!sThemedResourceCacheMNullThemedEntriesFieldInitialized) {
try {
sThemedResourceCacheMNullThemedEntriesField = sThemedResourceCacheClass.getDeclaredField("mNullThemedEntries");
sThemedResourceCacheMNullThemedEntriesField.setAccessible(true);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
sThemedResourceCacheMNullThemedEntriesFieldInitialized = true;
}
if (sThemedResourceCacheMNullThemedEntriesField != null) {
LongSparseArray nullThemedEntries = null;
try {
nullThemedEntries = (LongSparseArray) sThemedResourceCacheMNullThemedEntriesField.get(themedResourceCache);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
if (nullThemedEntries != null) {
nullThemedEntries.clear();
}
}
}
use of androidx.annotation.RequiresApi in project streaming-android by red5pro.
the class PublishService method createNotificationChannel.
@RequiresApi(Build.VERSION_CODES.O)
private String createNotificationChannel(String channelId, String channelName) {
NotificationChannel chan = new NotificationChannel(channelId, channelName, NotificationManager.IMPORTANCE_NONE);
chan.setLightColor(Color.BLUE);
chan.setLockscreenVisibility(Notification.VISIBILITY_PRIVATE);
NotificationManager service = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
service.createNotificationChannel(chan);
return channelId;
}
use of androidx.annotation.RequiresApi in project robolectric by robolectric.
the class ShadowAppOpsManager method noteProxyOpNoThrow.
@RequiresApi(api = Build.VERSION_CODES.S)
@Implementation(minSdk = Build.VERSION_CODES.S)
protected int noteProxyOpNoThrow(Object op, Object attributionSource, Object message, Object ignoredSkipProxyOperation) {
Preconditions.checkArgument(op instanceof Integer);
Preconditions.checkArgument(attributionSource instanceof AttributionSource);
Preconditions.checkArgument(message == null || message instanceof String);
Preconditions.checkArgument(ignoredSkipProxyOperation instanceof Boolean);
AttributionSource castedAttributionSource = (AttributionSource) attributionSource;
return noteProxyOpNoThrow((int) op, castedAttributionSource.getNextPackageName(), castedAttributionSource.getNextUid(), castedAttributionSource.getNextAttributionTag(), (String) message);
}
use of androidx.annotation.RequiresApi in project robolectric by robolectric.
the class ShadowImsMmTelManager method createForSubscriptionId.
/**
* Returns only one instance per subscription id.
*/
@RequiresApi(api = VERSION_CODES.Q)
@Implementation
protected static ImsMmTelManager createForSubscriptionId(int subId) {
if (!SubscriptionManager.isValidSubscriptionId(subId)) {
throw new IllegalArgumentException("Invalid subscription ID");
}
if (existingInstances.containsKey(subId)) {
return existingInstances.get(subId);
}
ImsMmTelManager imsMmTelManager = reflector(ImsMmTelManagerReflector.class).createForSubscriptionId(subId);
existingInstances.put(subId, imsMmTelManager);
return imsMmTelManager;
}
Aggregations