aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarry Youd <harry@harryyoud.co.uk>2017-09-27 22:33:00 +0100
committerLuK1337 <priv.luk@gmail.com>2018-01-23 23:47:18 +0100
commitff53035537214d8931c810d9634d69c76c7bd63d (patch)
treeb226aec65efe8b4f56aeb6ae63802be3eafb9626
parent0e79b791f0f19734c9b5caed3fed700801e62a27 (diff)
downloadandroid_packages_apps_Updater-staging/lineage-15.1.tar.gz
android_packages_apps_Updater-staging/lineage-15.1.tar.bz2
android_packages_apps_Updater-staging/lineage-15.1.zip
Updater: Add notification channelsstaging/lineage-15.1
Change-Id: I2f538fb47fe90e1008bf286739d33c829123353a
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/org/lineageos/updater/ExportUpdateService.java14
-rw-r--r--src/org/lineageos/updater/UpdatesCheckReceiver.java14
-rw-r--r--src/org/lineageos/updater/controller/UpdaterService.java14
4 files changed, 40 insertions, 6 deletions
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 2205c68..6716ea4 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -127,4 +127,8 @@
<string name="blocked_update_dialog_title">Update blocked</string>
<string name="blocked_update_dialog_message">This update cannot be installed using the updater app. Please read <xliff:g id="info_url">%1$s</xliff:g> for more information.</string>
<string name="blocked_update_info_url" translatable="false">http://wiki.lineageos.org/upgrading.html</string>
+
+ <string name="export_channel_title">Export completion</string>
+ <string name="new_updates_channel_title">New updates</string>
+ <string name="ongoing_channel_title">Ongoing downloads</string>
</resources>
diff --git a/src/org/lineageos/updater/ExportUpdateService.java b/src/org/lineageos/updater/ExportUpdateService.java
index 6705de6..f05a7d1 100644
--- a/src/org/lineageos/updater/ExportUpdateService.java
+++ b/src/org/lineageos/updater/ExportUpdateService.java
@@ -15,6 +15,7 @@
*/
package org.lineageos.updater;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -43,6 +44,9 @@ public class ExportUpdateService extends Service {
public static final String EXTRA_SOURCE_FILE = "source_file";
public static final String EXTRA_DEST_FILE = "dest_file";
+ private static final String EXPORT_NOTIFICATION_CHANNEL =
+ "export_notification_channel";
+
private volatile boolean mIsExporting = false;
private Thread mExportThread;
@@ -133,8 +137,14 @@ public class ExportUpdateService extends Service {
private void startExporting(File source, File destination) {
NotificationManager notificationManager =
(NotificationManager) getSystemService(NOTIFICATION_SERVICE);
-
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this);
+ NotificationChannel notificationChannel = new NotificationChannel(
+ EXPORT_NOTIFICATION_CHANNEL,
+ getString(R.string.export_channel_title),
+ NotificationManager.IMPORTANCE_LOW);
+ notificationManager.createNotificationChannel(notificationChannel);
+
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(this,
+ EXPORT_NOTIFICATION_CHANNEL);
NotificationCompat.BigTextStyle notificationStyle = new NotificationCompat.BigTextStyle();
notificationBuilder.setContentTitle(getString(R.string.dialog_export_title));
notificationStyle.setBigContentTitle(getString(R.string.dialog_export_title));
diff --git a/src/org/lineageos/updater/UpdatesCheckReceiver.java b/src/org/lineageos/updater/UpdatesCheckReceiver.java
index b70d388..9332bd9 100644
--- a/src/org/lineageos/updater/UpdatesCheckReceiver.java
+++ b/src/org/lineageos/updater/UpdatesCheckReceiver.java
@@ -16,6 +16,7 @@
package org.lineageos.updater;
import android.app.AlarmManager;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
@@ -24,7 +25,7 @@ import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.preference.PreferenceManager;
-import android.support.v7.app.NotificationCompat;
+import android.support.v4.app.NotificationCompat;
import android.util.Log;
import org.json.JSONException;
@@ -46,6 +47,9 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
private static final String DAILY_CHECK_ACTION = "daily_check_action";
private static final String ONESHOT_CHECK_ACTION = "oneshot_check_action";
+ private static final String NEW_UPDATES_NOTIFICATION_CHANNEL =
+ "new_updates_notification_channel";
+
@Override
public void onReceive(final Context context, Intent intent) {
if (Intent.ACTION_BOOT_COMPLETED.equals(intent.getAction())) {
@@ -121,7 +125,12 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
private static void showNotification(Context context) {
NotificationManager notificationManager =
(NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context);
+ NotificationChannel notificationChannel = new NotificationChannel(
+ NEW_UPDATES_NOTIFICATION_CHANNEL,
+ context.getString(R.string.new_updates_channel_title),
+ NotificationManager.IMPORTANCE_LOW);
+ NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context,
+ NEW_UPDATES_NOTIFICATION_CHANNEL);
notificationBuilder.setSmallIcon(R.drawable.ic_system_update);
Intent notificationIntent = new Intent(context, UpdatesActivity.class);
PendingIntent intent = PendingIntent.getActivity(context, 0, notificationIntent,
@@ -129,6 +138,7 @@ public class UpdatesCheckReceiver extends BroadcastReceiver {
notificationBuilder.setContentIntent(intent);
notificationBuilder.setContentTitle(context.getString(R.string.new_updates_found_title));
notificationBuilder.setAutoCancel(true);
+ notificationManager.createNotificationChannel(notificationChannel);
notificationManager.notify(0, notificationBuilder.build());
}
diff --git a/src/org/lineageos/updater/controller/UpdaterService.java b/src/org/lineageos/updater/controller/UpdaterService.java
index bfbb5d0..2c39502 100644
--- a/src/org/lineageos/updater/controller/UpdaterService.java
+++ b/src/org/lineageos/updater/controller/UpdaterService.java
@@ -15,6 +15,7 @@
*/
package org.lineageos.updater.controller;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.Service;
@@ -25,8 +26,8 @@ import android.content.IntentFilter;
import android.os.Binder;
import android.os.Bundle;
import android.os.IBinder;
+import android.support.v4.app.NotificationCompat;
import android.support.v4.content.LocalBroadcastManager;
-import android.support.v7.app.NotificationCompat;
import android.text.format.Formatter;
import android.util.Log;
@@ -53,6 +54,9 @@ public class UpdaterService extends Service {
public static final String ACTION_INSTALL_UPDATE = "action_install_update";
public static final String ACTION_INSTALL_STOP = "action_install_stop";
+ private static final String ONGOING_NOTIFICATION_CHANNEL =
+ "ongoing_notification_channel";
+
public static final int DOWNLOAD_RESUME = 0;
public static final int DOWNLOAD_PAUSE = 1;
@@ -75,7 +79,13 @@ public class UpdaterService extends Service {
mUpdaterController = UpdaterController.getInstance(this);
mNotificationManager = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
- mNotificationBuilder = new NotificationCompat.Builder(this);
+ NotificationChannel notificationChannel = new NotificationChannel(
+ ONGOING_NOTIFICATION_CHANNEL,
+ getString(R.string.ongoing_channel_title),
+ NotificationManager.IMPORTANCE_LOW);
+ mNotificationManager.createNotificationChannel(notificationChannel);
+ mNotificationBuilder = new NotificationCompat.Builder(this,
+ ONGOING_NOTIFICATION_CHANNEL);
mNotificationBuilder.setSmallIcon(R.drawable.ic_system_update);
mNotificationBuilder.setShowWhen(false);
mNotificationStyle = new NotificationCompat.BigTextStyle();