Loading app/src/main/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package="foundation.e.drive"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" tools:ignore="ProtectedPermissions" /> Loading app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java +14 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = 0; private final Context mContext; private Account account; Loading Loading @@ -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"); } } } Loading Loading @@ -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) Loading @@ -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() { Loading app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java +2 −4 Original line number Diff line number Diff line Loading @@ -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"); } } } Loading
app/src/main/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -4,6 +4,7 @@ package="foundation.e.drive"> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.POST_NOTIFICATIONS" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_PRIVILEGED_PHONE_STATE" tools:ignore="ProtectedPermissions" /> Loading
app/src/main/java/foundation/e/drive/account/AccountUserInfoWorker.java +14 −2 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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 = 0; private final Context mContext; private Account account; Loading Loading @@ -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"); } } } Loading Loading @@ -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) Loading @@ -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() { Loading
app/src/main/java/foundation/e/drive/account/receivers/AccountRemoveCallbackReceiver.java +2 −4 Original line number Diff line number Diff line Loading @@ -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"); } } }