diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index ac42e944d90f00c4a785e052e7b300a75e101e9f..e2c9882cbb68ebe6bd5d95180bda3463fa1d0f81 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -4,6 +4,7 @@
package="foundation.e.drive">
+
diff --git a/app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java b/app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java
index 8d4d0aa68c5a126daab9cdfbc5769b9d0e46b1d4..ef376d0cde5dc847009ed4a9d1ef8108b21e0040 100644
--- a/app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java
+++ b/app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java
@@ -18,6 +18,7 @@ import static foundation.e.drive.utils.AppConstants.ACCOUNT_USER_ID_KEY;
import android.accounts.Account;
import android.accounts.AccountManager;
+import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.content.Context;
import android.content.SharedPreferences;
@@ -55,6 +56,8 @@ public class AccountUserInfoWorker extends Worker {
private final AccountManager accountManager;
private final GetUserInfoRemoteOperation GetUserInfoRemoteOperation = new GetUserInfoRemoteOperation();
+ private static final int QUOTA_NOTIFICATION_ID = 11;
+
private final Context mContext;
private Account account;
@@ -157,7 +160,11 @@ public class AccountUserInfoWorker extends Worker {
} else if (relativeQuota >= 80.0 && needToNotify) {
addNotification(manager, context.getString(R.string.notif_quota_80plus_title), context.getString(R.string.notif_quota_80Plus_text), false);
} else {
- manager.cancelAll();
+ try {
+ manager.cancel(QUOTA_NOTIFICATION_ID);
+ } catch (Exception e) {
+ Timber.e(e, "Failed to cancel quota notification");
+ }
}
}
@@ -192,6 +199,11 @@ public class AccountUserInfoWorker extends Worker {
* - else with different notification. File conflict for example.
**/
private void addNotification(NotificationManager manager, String title, String text, boolean isOnGoing) {
+ NotificationChannel channel = manager.getNotificationChannel(AppConstants.notificationChannelID);
+ if (channel == null) {
+ CommonUtils.createNotificationChannel(getApplicationContext());
+ }
+
final NotificationCompat.Builder builder =
new NotificationCompat.Builder(getApplicationContext(), AppConstants.notificationChannelID)
.setSmallIcon(android.R.drawable.stat_sys_warning)
@@ -200,7 +212,7 @@ public class AccountUserInfoWorker extends Worker {
.setOngoing(isOnGoing)
.setStyle(new NotificationCompat.BigTextStyle().bigText(text));
// Add as notification
- manager.notify(0, builder.build());
+ manager.notify(QUOTA_NOTIFICATION_ID, builder.build());
}
private boolean fetchAliases() {
diff --git a/app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java b/app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java
index 668fb93d9f05257c6d556e2a18d91038e868b64c..a04a6b185f3737e57f06a02393395af43c5c13b7 100644
--- a/app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java
+++ b/app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java
@@ -150,12 +150,10 @@ public class AccountRemoveCallbackReceiver extends BroadcastReceiver {
private void deleteNotificationChannels(Context context) {
NotificationManager notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
- notificationManager.cancelAll();
try {
- notificationManager.deleteNotificationChannel(AppConstants.notificationChannelID);
- notificationManager.deleteNotificationChannel(SyncWorker.NOTIF_CHANNEL_ID);
+ notificationManager.cancelAll();
} catch (Exception exception) {
- Timber.e(exception, "Cannot delete notification Channel");
+ Timber.e(exception, "Cannot cancel all notifications");
}
}
}