From eea7e83f85232ba4aa7de58b0ff0f93a71675fbb Mon Sep 17 00:00:00 2001 From: Thomas Date: Sat, 8 Oct 2022 11:59:17 +0200 Subject: [PATCH] Fix notifications in double and messages not removed from cache --- app/src/main/java/app/fedilab/android/helper/Helper.java | 5 +---- .../app/fedilab/android/jobs/NotificationsWorker.java | 8 ++++---- .../fedilab/android/viewmodel/mastodon/StatusesVM.java | 3 +-- app/src/main/res/values/strings.xml | 1 + 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/app/fedilab/android/helper/Helper.java b/app/src/main/java/app/fedilab/android/helper/Helper.java index 60cf32da..20e2dd01 100644 --- a/app/src/main/java/app/fedilab/android/helper/Helper.java +++ b/app/src/main/java/app/fedilab/android/helper/Helper.java @@ -1482,7 +1482,7 @@ public class Helper { message = message.substring(0, 499) + "…"; } }*/ - notificationBuilder.setGroup(account.mastodon_account != null ? account.mastodon_account.acct : "" + "@" + account.instance) + notificationBuilder.setGroup(account.mastodon_account != null ? account.mastodon_account.username + "@" + account.instance : "" + "@" + account.instance) .setContentIntent(pIntent) .setContentText(message); int ledColour = Color.BLUE; @@ -1493,9 +1493,6 @@ public class Helper { prefColor = Integer.parseInt(sharedpreferences.getString(context.getString(R.string.SET_LED_COLOUR_VAL), String.valueOf(LED_COLOUR))); } switch (prefColor) { - case 0: // BLUE - ledColour = Color.BLUE; - break; case 1: // CYAN ledColour = Color.CYAN; break; diff --git a/app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java b/app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java index 7b773592..ad73c584 100644 --- a/app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java +++ b/app/src/main/java/app/fedilab/android/jobs/NotificationsWorker.java @@ -65,8 +65,8 @@ public class NotificationsWorker extends Worker { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID); notificationBuilder.setSmallIcon(R.drawable.ic_notification) .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground)) - .setContentTitle(getApplicationContext().getString(R.string.scheduled_toots)) - .setContentText(getApplicationContext().getString(R.string.scheduled_toots)) + .setContentTitle(getApplicationContext().getString(R.string.notifications)) + .setContentText(getApplicationContext().getString(R.string.fetch_notifications)) .setDefaults(NotificationCompat.DEFAULT_ALL) .setPriority(Notification.PRIORITY_DEFAULT); return Futures.immediateFuture(new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build())); @@ -85,8 +85,8 @@ public class NotificationsWorker extends Worker { NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID); notificationBuilder.setSmallIcon(R.drawable.ic_notification) .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground)) - .setContentTitle(getApplicationContext().getString(R.string.scheduled_toots)) - .setContentText(getApplicationContext().getString(R.string.scheduled_toots)) + .setContentTitle(getApplicationContext().getString(R.string.notifications)) + .setContentText(getApplicationContext().getString(R.string.fetch_notifications)) .setDefaults(NotificationCompat.DEFAULT_ALL) .setPriority(Notification.PRIORITY_DEFAULT); return new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build()); diff --git a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java index 50913b42..d0bd1838 100644 --- a/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java +++ b/app/src/main/java/app/fedilab/android/viewmodel/mastodon/StatusesVM.java @@ -325,12 +325,11 @@ public class StatusesVM extends AndroidViewModel { //The status must also be deleted in cache try { BaseAccount account = new app.fedilab.android.client.entities.app.Account(getApplication().getApplicationContext()).getAccountByToken(token); - new StatusCache(getApplication().getApplicationContext()).deleteStatus(id, account.instance); + new StatusCache(getApplication().getApplicationContext()).deleteStatus(account.instance, id); } catch (DBException e) { e.printStackTrace(); } - Handler mainHandler = new Handler(Looper.getMainLooper()); Status finalStatus = status; Runnable myRunnable = () -> statusMutableLiveData.setValue(finalStatus); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 2bd5d6d1..d2178f1e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -1474,4 +1474,5 @@ Cached message Reply Display options + Fetch notifications