summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDemon000 <demonsingur@gmail.com>2017-09-15 23:24:32 +0300
committerRashed Abdel-Tawab <rashed@linux.com>2017-12-05 17:00:05 -0800
commitdcb41bc4f6bc13a876800842b3685e0d5b09c1e7 (patch)
treed05a39c3dd3974fce9c45fa8f390f98ea9f8d39c
parentc86ad54e022536c474cf0529eae53163ec1be83a (diff)
downloadandroid_packages_apps_DeskClock-dcb41bc4f6bc13a876800842b3685e0d5b09c1e7.tar.gz
android_packages_apps_DeskClock-dcb41bc4f6bc13a876800842b3685e0d5b09c1e7.tar.bz2
android_packages_apps_DeskClock-dcb41bc4f6bc13a876800842b3685e0d5b09c1e7.zip
DeskClock: use non-Compat Notification classes
Change-Id: Ide9326d028ec692ed58f95dea33ffa884f83e582
-rw-r--r--src/com/android/deskclock/alarms/AlarmNotifications.java70
-rw-r--r--src/com/android/deskclock/data/StopwatchNotificationBuilder.java10
-rw-r--r--src/com/android/deskclock/data/TimerNotificationBuilder.java25
3 files changed, 53 insertions, 52 deletions
diff --git a/src/com/android/deskclock/alarms/AlarmNotifications.java b/src/com/android/deskclock/alarms/AlarmNotifications.java
index 74ad7e6bf..b867717b8 100644
--- a/src/com/android/deskclock/alarms/AlarmNotifications.java
+++ b/src/com/android/deskclock/alarms/AlarmNotifications.java
@@ -25,8 +25,6 @@ import android.content.Intent;
import android.content.res.Resources;
import android.os.Build;
import android.service.notification.StatusBarNotification;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.content.ContextCompat;
import com.android.deskclock.AlarmClockFragment;
@@ -88,7 +86,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(context);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
+ Notification.Builder builder = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentTitle(context.getString(
@@ -98,8 +96,8 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setAutoCancel(false)
.setSortKey(createSortKey(instance))
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
if (Utils.isNOrLater()) {
@@ -127,7 +125,8 @@ final class AlarmNotifications {
builder.setContentIntent(PendingIntent.getActivity(context, id,
viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));
- NotificationManagerCompat nm = NotificationManagerCompat.from(context);
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification notification = builder.build();
nm.notify(id, notification);
updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -139,7 +138,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(context);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
+ Notification.Builder builder = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentTitle(context.getString(R.string.alarm_alert_predismiss_title))
@@ -148,8 +147,8 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setAutoCancel(false)
.setSortKey(createSortKey(instance))
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
if (Utils.isNOrLater()) {
@@ -170,7 +169,8 @@ final class AlarmNotifications {
builder.setContentIntent(PendingIntent.getActivity(context, id,
viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));
- NotificationManagerCompat nm = NotificationManagerCompat.from(context);
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification notification = builder.build();
nm.notify(id, notification);
updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -235,8 +235,8 @@ final class AlarmNotifications {
return;
}
- final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
-
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification firstUpcoming = getFirstActiveNotification(context, UPCOMING_GROUP_KEY,
canceledNotificationId, postedNotification);
if (firstUpcoming == null) {
@@ -249,7 +249,7 @@ final class AlarmNotifications {
|| !Objects.equals(summary.contentIntent, firstUpcoming.contentIntent)) {
Utils.createNotificationChannelsIfNeeded(context);
- summary = new NotificationCompat.Builder(context,
+ summary = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentIntent(firstUpcoming.contentIntent)
@@ -257,8 +257,8 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setGroup(UPCOMING_GROUP_KEY)
.setGroupSummary(true)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.build();
nm.notify(ALARM_GROUP_NOTIFICATION_ID, summary);
@@ -271,8 +271,8 @@ final class AlarmNotifications {
return;
}
- final NotificationManagerCompat nm = NotificationManagerCompat.from(context);
-
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification firstMissed = getFirstActiveNotification(context, MISSED_GROUP_KEY,
canceledNotificationId, postedNotification);
if (firstMissed == null) {
@@ -285,7 +285,7 @@ final class AlarmNotifications {
|| !Objects.equals(summary.contentIntent, firstMissed.contentIntent)) {
Utils.createNotificationChannelsIfNeeded(context);
- summary = new NotificationCompat.Builder(context,
+ summary = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentIntent(firstMissed.contentIntent)
@@ -293,8 +293,8 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setGroup(MISSED_GROUP_KEY)
.setGroupSummary(true)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true)
.build();
nm.notify(ALARM_GROUP_MISSED_NOTIFICATION_ID, summary);
@@ -307,7 +307,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(context);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
+ Notification.Builder builder = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentTitle(instance.getLabelOrDefault(context))
@@ -317,8 +317,8 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setAutoCancel(false)
.setSortKey(createSortKey(instance))
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
if (Utils.isNOrLater()) {
@@ -339,7 +339,8 @@ final class AlarmNotifications {
builder.setContentIntent(PendingIntent.getActivity(context, id,
viewAlarmIntent, PendingIntent.FLAG_UPDATE_CURRENT));
- NotificationManagerCompat nm = NotificationManagerCompat.from(context);
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification notification = builder.build();
nm.notify(id, notification);
updateUpcomingAlarmGroupNotification(context, -1, notification);
@@ -354,7 +355,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(context);
- NotificationCompat.Builder builder = new NotificationCompat.Builder(context,
+ Notification.Builder builder = new Notification.Builder(context,
Utils.ALARM_CHANNEL)
.setShowWhen(false)
.setContentTitle(context.getString(R.string.alarm_missed_title))
@@ -363,8 +364,8 @@ final class AlarmNotifications {
.setColor(ContextCompat.getColor(context, R.color.default_background))
.setSortKey(createSortKey(instance))
.setSmallIcon(R.drawable.stat_notify_alarm)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
if (Utils.isNOrLater()) {
@@ -387,7 +388,8 @@ final class AlarmNotifications {
builder.setContentIntent(PendingIntent.getBroadcast(context, id,
showAndDismiss, PendingIntent.FLAG_UPDATE_CURRENT));
- NotificationManagerCompat nm = NotificationManagerCompat.from(context);
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final Notification notification = builder.build();
nm.notify(id, notification);
updateMissedAlarmGroupNotification(context, -1, notification);
@@ -400,7 +402,7 @@ final class AlarmNotifications {
Utils.createNotificationChannelsIfNeeded(service);
- NotificationCompat.Builder notification = new NotificationCompat.Builder(service,
+ Notification.Builder notification = new Notification.Builder(service,
Utils.ALARM_CHANNEL)
.setContentTitle(instance.getLabelOrDefault(service))
.setContentText(AlarmUtils.getFormattedTime(service, instance.getAlarmTime()))
@@ -408,10 +410,10 @@ final class AlarmNotifications {
.setSmallIcon(R.drawable.stat_notify_alarm)
.setOngoing(true)
.setAutoCancel(false)
- .setDefaults(NotificationCompat.DEFAULT_LIGHTS)
+ .setDefaults(Notification.DEFAULT_LIGHTS)
.setWhen(0)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setCategory(Notification.CATEGORY_ALARM)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setLocalOnly(true);
// Setup Snooze Action
@@ -456,7 +458,9 @@ final class AlarmNotifications {
static synchronized void clearNotification(Context context, AlarmInstance instance) {
LogUtils.v("Clearing notifications for alarm instance: " + instance.mId);
- NotificationManagerCompat nm = NotificationManagerCompat.from(context);
+
+ final NotificationManager nm =
+ (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
final int id = instance.hashCode();
nm.cancel(id);
updateUpcomingAlarmGroupNotification(context, id, null);
diff --git a/src/com/android/deskclock/data/StopwatchNotificationBuilder.java b/src/com/android/deskclock/data/StopwatchNotificationBuilder.java
index 7fce9fcef..6070b1f23 100644
--- a/src/com/android/deskclock/data/StopwatchNotificationBuilder.java
+++ b/src/com/android/deskclock/data/StopwatchNotificationBuilder.java
@@ -17,6 +17,8 @@
package com.android.deskclock.data;
import android.app.Notification;
+import android.app.Notification.Action;
+import android.app.Notification.Builder;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
@@ -24,10 +26,6 @@ import android.content.res.Resources;
import android.os.SystemClock;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
-import android.support.v4.app.NotificationCompat;
-import android.support.v4.app.NotificationCompat.Action;
-import android.support.v4.app.NotificationCompat.Builder;
-import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.widget.RemoteViews;
@@ -130,7 +128,7 @@ class StopwatchNotificationBuilder {
Utils.createNotificationChannelsIfNeeded(context);
- final Builder notification = new NotificationCompat.Builder(context,
+ final Builder notification = new Notification.Builder(context,
Utils.STOPWATCH_CHANNEL)
.setLocalOnly(true)
.setOngoing(running)
@@ -138,7 +136,7 @@ class StopwatchNotificationBuilder {
.setContentIntent(pendingShowApp)
.setAutoCancel(stopwatch.isPaused())
.setSmallIcon(R.drawable.stat_notify_stopwatch)
- .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
+ .setStyle(new Notification.DecoratedCustomViewStyle())
.setColor(ContextCompat.getColor(context, R.color.default_background));
if (Utils.isNOrLater()) {
diff --git a/src/com/android/deskclock/data/TimerNotificationBuilder.java b/src/com/android/deskclock/data/TimerNotificationBuilder.java
index c98fcdec1..f15dc391d 100644
--- a/src/com/android/deskclock/data/TimerNotificationBuilder.java
+++ b/src/com/android/deskclock/data/TimerNotificationBuilder.java
@@ -19,6 +19,8 @@ package com.android.deskclock.data;
import android.annotation.TargetApi;
import android.app.AlarmManager;
import android.app.Notification;
+import android.app.Notification.Action;
+import android.app.Notification.Builder;
import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
@@ -26,7 +28,6 @@ import android.content.res.Resources;
import android.os.Build;
import android.os.SystemClock;
import android.support.annotation.DrawableRes;
-import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.widget.RemoteViews;
@@ -41,8 +42,6 @@ import com.android.deskclock.timer.TimerService;
import java.util.ArrayList;
import java.util.List;
-import static android.support.v4.app.NotificationCompat.Action;
-import static android.support.v4.app.NotificationCompat.Builder;
import static android.text.format.DateUtils.MINUTE_IN_MILLIS;
import static android.text.format.DateUtils.SECOND_IN_MILLIS;
@@ -150,18 +149,18 @@ class TimerNotificationBuilder {
Utils.createNotificationChannelsIfNeeded(context);
- final Builder notification = new NotificationCompat.Builder(context,
+ final Builder notification = new Notification.Builder(context,
Utils.TIMER_CHANNEL)
.setOngoing(true)
.setLocalOnly(true)
.setShowWhen(false)
.setAutoCancel(false)
.setContentIntent(pendingShowApp)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
+ .setCategory(Notification.CATEGORY_ALARM)
.setSmallIcon(R.drawable.stat_notify_timer)
.setSortKey(nm.getTimerNotificationSortKey())
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
- .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
+ .setStyle(new Notification.DecoratedCustomViewStyle())
.setColor(ContextCompat.getColor(context, R.color.default_background));
for (Action action : actions) {
@@ -265,7 +264,7 @@ class TimerNotificationBuilder {
Utils.createNotificationChannelsIfNeeded(context);
- final Builder notification = new NotificationCompat.Builder(context,
+ final Builder notification = new Notification.Builder(context,
Utils.TIMER_CHANNEL)
.setOngoing(true)
.setLocalOnly(true)
@@ -275,7 +274,7 @@ class TimerNotificationBuilder {
.setDefaults(Notification.DEFAULT_LIGHTS)
.setSmallIcon(R.drawable.stat_notify_timer)
.setFullScreenIntent(pendingFullScreen, true)
- .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
+ .setStyle(new Notification.DecoratedCustomViewStyle())
.setColor(ContextCompat.getColor(context, R.color.default_background));
for (Action action : actions) {
@@ -350,17 +349,17 @@ class TimerNotificationBuilder {
Utils.createNotificationChannelsIfNeeded(context);
- final Builder notification = new NotificationCompat.Builder(context,
+ final Builder notification = new Notification.Builder(context,
Utils.TIMER_CHANNEL)
.setLocalOnly(true)
.setShowWhen(false)
.setAutoCancel(false)
.setContentIntent(pendingShowApp)
- .setCategory(NotificationCompat.CATEGORY_ALARM)
+ .setCategory(Notification.CATEGORY_ALARM)
.setSmallIcon(R.drawable.stat_notify_timer)
- .setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
+ .setVisibility(Notification.VISIBILITY_PUBLIC)
.setSortKey(nm.getTimerNotificationMissedSortKey())
- .setStyle(new NotificationCompat.DecoratedCustomViewStyle())
+ .setStyle(new Notification.DecoratedCustomViewStyle())
.addAction(action)
.setColor(ContextCompat.getColor(context, R.color.default_background));