summaryrefslogtreecommitdiff
path: root/ui/notifications/src
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-03-17 12:06:41 +0100
committerGitHub <noreply@github.com>2024-03-17 12:06:41 +0100
commit17f5a5d1b85f07bada36abe6541ed0fc1e1d83a2 (patch)
treee0813fb457b766f6edc532ad28a63f200f629763 /ui/notifications/src
parent8dc8cc64a8a6de3adfba1aaf0a0306f90727a2c4 (diff)
downloadAntennaPod-17f5a5d1b85f07bada36abe6541ed0fc1e1d83a2.zip
Move notification icons and widget icons to separate modules (#6995)
Diffstat (limited to 'ui/notifications/src')
-rw-r--r--ui/notifications/src/main/java/de/danoeh/antennapod/ui/notifications/NotificationUtils.java118
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_fast_forward.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_fast_rewind.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_next_chapter.xml7
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_pause.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_play.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_playback_speed.xml8
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_skip.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_sleep.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_sleep_off.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_stream.xml14
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_sync.xml5
-rw-r--r--ui/notifications/src/main/res/drawable/ic_notification_sync_error.xml5
13 files changed, 192 insertions, 0 deletions
diff --git a/ui/notifications/src/main/java/de/danoeh/antennapod/ui/notifications/NotificationUtils.java b/ui/notifications/src/main/java/de/danoeh/antennapod/ui/notifications/NotificationUtils.java
new file mode 100644
index 000000000..93cf6baf1
--- /dev/null
+++ b/ui/notifications/src/main/java/de/danoeh/antennapod/ui/notifications/NotificationUtils.java
@@ -0,0 +1,118 @@
+package de.danoeh.antennapod.ui.notifications;
+
+import android.content.Context;
+
+import androidx.core.app.NotificationChannelCompat;
+import androidx.core.app.NotificationChannelGroupCompat;
+import androidx.core.app.NotificationManagerCompat;
+
+import java.util.Arrays;
+import java.util.List;
+
+import de.danoeh.antennapod.storage.preferences.UserPreferences;
+
+public class NotificationUtils {
+ public static final String CHANNEL_ID_USER_ACTION = "user_action";
+ public static final String CHANNEL_ID_DOWNLOADING = "downloading";
+ public static final String CHANNEL_ID_PLAYING = "playing";
+ public static final String CHANNEL_ID_DOWNLOAD_ERROR = "error";
+ public static final String CHANNEL_ID_SYNC_ERROR = "sync_error";
+ public static final String CHANNEL_ID_EPISODE_NOTIFICATIONS = "episode_notifications";
+
+ public static final String GROUP_ID_ERRORS = "group_errors";
+ public static final String GROUP_ID_NEWS = "group_news";
+
+ public static void createChannels(final Context context) {
+ final NotificationManagerCompat mNotificationManager = NotificationManagerCompat.from(context);
+
+ final List<NotificationChannelGroupCompat> channelGroups = Arrays.asList(
+ createGroupErrors(context),
+ createGroupNews(context));
+ mNotificationManager.createNotificationChannelGroupsCompat(channelGroups);
+
+ final List<NotificationChannelCompat> channels = Arrays.asList(
+ createChannelUserAction(context),
+ createChannelDownloading(context),
+ createChannelPlaying(context),
+ createChannelError(context),
+ createChannelSyncError(context),
+ createChannelEpisodeNotification(context));
+ mNotificationManager.createNotificationChannelsCompat(channels);
+ }
+
+ private static NotificationChannelCompat createChannelUserAction(final Context c) {
+ return new NotificationChannelCompat.Builder(
+ CHANNEL_ID_USER_ACTION, NotificationManagerCompat.IMPORTANCE_HIGH)
+ .setName(c.getString(R.string.notification_channel_user_action))
+ .setDescription(c.getString(R.string.notification_channel_user_action_description))
+ .setGroup(GROUP_ID_ERRORS)
+ .build();
+ }
+
+ private static NotificationChannelCompat createChannelDownloading(final Context c) {
+ return new NotificationChannelCompat.Builder(
+ CHANNEL_ID_DOWNLOADING, NotificationManagerCompat.IMPORTANCE_LOW)
+ .setName(c.getString(R.string.notification_channel_downloading))
+ .setDescription(c.getString(R.string.notification_channel_downloading_description))
+ .setShowBadge(false)
+ .build();
+ }
+
+ private static NotificationChannelCompat createChannelPlaying(final Context c) {
+ return new NotificationChannelCompat.Builder(
+ CHANNEL_ID_PLAYING, NotificationManagerCompat.IMPORTANCE_LOW)
+ .setName(c.getString(R.string.notification_channel_playing))
+ .setDescription(c.getString(R.string.notification_channel_playing_description))
+ .setShowBadge(false)
+ .build();
+ }
+
+ private static NotificationChannelCompat createChannelError(final Context c) {
+ final NotificationChannelCompat.Builder notificationChannel = new NotificationChannelCompat.Builder(
+ CHANNEL_ID_DOWNLOAD_ERROR, NotificationManagerCompat.IMPORTANCE_HIGH)
+ .setName(c.getString(R.string.notification_channel_download_error))
+ .setDescription(c.getString(R.string.notification_channel_download_error_description))
+ .setGroup(GROUP_ID_ERRORS);
+
+ if (!UserPreferences.getShowDownloadReportRaw()) {
+ // Migration from app managed setting: disable notification
+ notificationChannel.setImportance(NotificationManagerCompat.IMPORTANCE_NONE);
+ }
+ return notificationChannel.build();
+ }
+
+ private static NotificationChannelCompat createChannelSyncError(final Context c) {
+ final NotificationChannelCompat.Builder notificationChannel = new NotificationChannelCompat.Builder(
+ CHANNEL_ID_SYNC_ERROR, NotificationManagerCompat.IMPORTANCE_HIGH)
+ .setName(c.getString(R.string.notification_channel_sync_error))
+ .setDescription(c.getString(R.string.notification_channel_sync_error_description))
+ .setGroup(GROUP_ID_ERRORS);
+
+ if (!UserPreferences.getGpodnetNotificationsEnabledRaw()) {
+ // Migration from app managed setting: disable notification
+ notificationChannel.setImportance(NotificationManagerCompat.IMPORTANCE_NONE);
+ }
+ return notificationChannel.build();
+ }
+
+ private static NotificationChannelCompat createChannelEpisodeNotification(final Context c) {
+ return new NotificationChannelCompat.Builder(
+ CHANNEL_ID_EPISODE_NOTIFICATIONS, NotificationManagerCompat.IMPORTANCE_DEFAULT)
+ .setName(c.getString(R.string.notification_channel_new_episode))
+ .setDescription(c.getString(R.string.notification_channel_new_episode_description))
+ .setGroup(GROUP_ID_NEWS)
+ .build();
+ }
+
+ private static NotificationChannelGroupCompat createGroupErrors(final Context c) {
+ return new NotificationChannelGroupCompat.Builder(GROUP_ID_ERRORS)
+ .setName(c.getString(R.string.notification_group_errors))
+ .build();
+ }
+
+ private static NotificationChannelGroupCompat createGroupNews(final Context c) {
+ return new NotificationChannelGroupCompat.Builder(GROUP_ID_NEWS)
+ .setName(c.getString(R.string.notification_group_news))
+ .build();
+ }
+}
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_fast_forward.xml b/ui/notifications/src/main/res/drawable/ic_notification_fast_forward.xml
new file mode 100644
index 000000000..8ee82f4ed
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_fast_forward.xml
@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp" android:viewportHeight="24.0"
+ android:viewportWidth="24.0" android:width="30dp">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M4,18l8.5,-6L4,6v12zM13,6v12l8.5,-6L13,6z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_fast_rewind.xml b/ui/notifications/src/main/res/drawable/ic_notification_fast_rewind.xml
new file mode 100644
index 000000000..261ed7e6f
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_fast_rewind.xml
@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp" android:viewportHeight="24.0"
+ android:viewportWidth="24.0" android:width="30dp">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M11,18L11,6l-8.5,6 8.5,6zM11.5,12l8.5,6L20,6l-8.5,6z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_next_chapter.xml b/ui/notifications/src/main/res/drawable/ic_notification_next_chapter.xml
new file mode 100644
index 000000000..cb55e93a9
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_next_chapter.xml
@@ -0,0 +1,7 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="24dp"
+ android:width="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path android:fillColor="#fff" android:pathData="M12,2A10,10 0 0,0 2,12A10,10 0 0,0 12,22A10,10 0 0,0 22,12A10,10 0 0,0 12,2M12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4M8,8V16L13,12M14,8V16H16V8" />
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_pause.xml b/ui/notifications/src/main/res/drawable/ic_notification_pause.xml
new file mode 100644
index 000000000..16ebd4eab
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_pause.xml
@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp" android:viewportHeight="24.0"
+ android:viewportWidth="24.0" android:width="30dp">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M6,19h4L10,5L6,5v14zM14,5v14h4L18,5h-4z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_play.xml b/ui/notifications/src/main/res/drawable/ic_notification_play.xml
new file mode 100644
index 000000000..eb4acd983
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_play.xml
@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp" android:viewportHeight="24.0"
+ android:viewportWidth="24.0" android:width="30dp">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M8,5v14l11,-7z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_playback_speed.xml b/ui/notifications/src/main/res/drawable/ic_notification_playback_speed.xml
new file mode 100644
index 000000000..5aad5031a
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_playback_speed.xml
@@ -0,0 +1,8 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp"
+ android:viewportHeight="24.0"
+ android:viewportWidth="24.0"
+ android:width="30dp">
+
+ <path android:fillColor="#ffffff" android:pathData="M 12 15.98 A 2.98 2.98 0 0 1 9.02 12.99 c 0 -1.11 0.61 -2.09 1.49 -2.6 L 20.17 4.81 L 14.67 14.34 C 14.17 15.31 13.16 15.98 12 15.98 M 12 3.05 c 1.8 0 3.48 0.5 4.94 1.31 l -2.09 1.2 C 13.99 5.22 12.99 5.04 12 5.04 a 7.96 7.96 0 0 0 -7.96 7.96 c 0 2.2 0.89 4.19 2.33 5.62 h 0.01 c 0.39 0.39 0.39 1.01 0 1.4 c -0.39 0.39 -1.02 0.39 -1.41 0.01 v 0 C 3.17 18.22 2.05 15.74 2.05 12.99 A 9.95 9.95 0 0 1 12 3.05 m 9.95 9.95 c 0 2.75 -1.11 5.23 -2.91 7.03 v 0 c -0.39 0.38 -1.01 0.38 -1.4 -0.01 c -0.39 -0.39 -0.39 -1.01 0 -1.4 v 0 c 1.44 -1.44 2.33 -3.42 2.33 -5.62 c 0 -0.99 -0.19 -1.99 -0.54 -2.88 L 20.62 8.02 c 0.83 1.49 1.32 3.16 1.32 4.97 z" />
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_skip.xml b/ui/notifications/src/main/res/drawable/ic_notification_skip.xml
new file mode 100644
index 000000000..6bf03002a
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_skip.xml
@@ -0,0 +1,5 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:height="30dp" android:viewportHeight="24.0"
+ android:viewportWidth="24.0" android:width="30dp">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M6,18l8.5,-6L6,6v12zM16,6v12h2V6h-2z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_sleep.xml b/ui/notifications/src/main/res/drawable/ic_notification_sleep.xml
new file mode 100644
index 000000000..60cfbb616
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_sleep.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#ffffff" android:pathData="M23,12H17V10L20.39,6H17V4H23V6L19.62,10H23V12M15,16H9V14L12.39,10H9V8H15V10L11.62,14H15V16M7,20H1V18L4.39,14H1V12H7V14L3.62,18H7V20Z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_sleep_off.xml b/ui/notifications/src/main/res/drawable/ic_notification_sleep_off.xml
new file mode 100644
index 000000000..8cb32124b
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_sleep_off.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#ffffff" android:pathData="M2,5.27L3.28,4L20,20.72L18.73,22L12.73,16H9V14L9.79,13.06L2,5.27M23,12H17V10L20.39,6H17V4H23V6L19.62,10H23V12M9.82,8H15V10L13.54,11.72L9.82,8M7,20H1V18L4.39,14H1V12H7V14L3.62,18H7V20Z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_stream.xml b/ui/notifications/src/main/res/drawable/ic_notification_stream.xml
new file mode 100644
index 000000000..aca761365
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_stream.xml
@@ -0,0 +1,14 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="24dp"
+ android:height="24dp"
+ android:viewportWidth="24"
+ android:viewportHeight="24">
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="m20.5099,12.0219c0,-1.41 -1.143,-2.553 -2.553,-2.553h-1.2765v-0.4255c0,-2.5849 -2.0955,-4.6804 -4.6804,-4.6804 -2.1275,0 -3.9401,1.4382 -4.5017,3.4039H6.8941c-1.8799,0 -3.4039,1.524 -3.4039,3.4039 0,1.8799 1.524,3.4039 3.4039,3.4039h2.553v1.702H6.8941c-2.8199,0 -5.1059,-2.286 -5.1059,-5.1059 0,-2.6381 1.9913,-4.7996 4.5528,-5.0719C7.4047,4.0566 9.5407,2.661 12,2.661c3.0976,0 5.6761,2.2041 6.2633,5.14 2.2041,0.1532 3.9486,1.9743 3.9486,4.2209 0,1.4041 -0.6445,2.3463 -1.5471,3.1885 -0.4185,-0.2876 -0.8313,-0.5368 -1.3724,-0.8908 1.092,-0.8808 1.2175,-1.8722 1.2175,-2.2977z"
+ android:strokeWidth="0.85098612"/>
+ <path
+ android:fillColor="#FFFFFFFF"
+ android:pathData="m12.2085,13.3476v9.4907l7.4569,-4.7453z"
+ android:strokeWidth="0.67790419"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_sync.xml b/ui/notifications/src/main/res/drawable/ic_notification_sync.xml
new file mode 100644
index 000000000..c42a78d7d
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_sync.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M12,4L12,1L8,5l4,4L12,6c3.31,0 6,2.69 6,6 0,1.01 -0.25,1.97 -0.7,2.8l1.46,1.46C19.54,15.03 20,13.57 20,12c0,-4.42 -3.58,-8 -8,-8zM12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.01 0.25,-1.97 0.7,-2.8L5.24,7.74C4.46,8.97 4,10.43 4,12c0,4.42 3.58,8 8,8v3l4,-4 -4,-4v3z"/>
+</vector>
diff --git a/ui/notifications/src/main/res/drawable/ic_notification_sync_error.xml b/ui/notifications/src/main/res/drawable/ic_notification_sync_error.xml
new file mode 100644
index 000000000..b5be1b747
--- /dev/null
+++ b/ui/notifications/src/main/res/drawable/ic_notification_sync_error.xml
@@ -0,0 +1,5 @@
+<vector android:height="24dp"
+ android:viewportHeight="24.0" android:viewportWidth="24.0"
+ android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
+ <path android:fillColor="#FFFFFFFF" android:pathData="M3,12c0,2.21 0.91,4.2 2.36,5.64L3,20h6v-6l-2.24,2.24C5.68,15.15 5,13.66 5,12c0,-2.61 1.67,-4.83 4,-5.65L9,4.26C5.55,5.15 3,8.27 3,12zM11,17h2v-2h-2v2zM21,4h-6v6l2.24,-2.24C18.32,8.85 19,10.34 19,12c0,2.61 -1.67,4.83 -4,5.65v2.09c3.45,-0.89 6,-4.01 6,-7.74 0,-2.21 -0.91,-4.2 -2.36,-5.64L21,4zM11,13h2L13,7h-2v6z"/>
+</vector>