Fix notifications in double and messages not removed from cache

This commit is contained in:
Thomas 2022-10-08 11:59:17 +02:00
parent 6b2d3670d3
commit eea7e83f85
4 changed files with 7 additions and 10 deletions

View file

@ -1482,7 +1482,7 @@ public class Helper {
message = message.substring(0, 499) + ""; 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) .setContentIntent(pIntent)
.setContentText(message); .setContentText(message);
int ledColour = Color.BLUE; 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))); prefColor = Integer.parseInt(sharedpreferences.getString(context.getString(R.string.SET_LED_COLOUR_VAL), String.valueOf(LED_COLOUR)));
} }
switch (prefColor) { switch (prefColor) {
case 0: // BLUE
ledColour = Color.BLUE;
break;
case 1: // CYAN case 1: // CYAN
ledColour = Color.CYAN; ledColour = Color.CYAN;
break; break;

View file

@ -65,8 +65,8 @@ public class NotificationsWorker extends Worker {
NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID);
notificationBuilder.setSmallIcon(R.drawable.ic_notification) notificationBuilder.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground)) .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getApplicationContext().getString(R.string.scheduled_toots)) .setContentTitle(getApplicationContext().getString(R.string.notifications))
.setContentText(getApplicationContext().getString(R.string.scheduled_toots)) .setContentText(getApplicationContext().getString(R.string.fetch_notifications))
.setDefaults(NotificationCompat.DEFAULT_ALL) .setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_DEFAULT); .setPriority(Notification.PRIORITY_DEFAULT);
return Futures.immediateFuture(new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build())); 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); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(getApplicationContext(), CHANNEL_ID);
notificationBuilder.setSmallIcon(R.drawable.ic_notification) notificationBuilder.setSmallIcon(R.drawable.ic_notification)
.setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground)) .setLargeIcon(BitmapFactory.decodeResource(getApplicationContext().getResources(), R.drawable.ic_launcher_foreground))
.setContentTitle(getApplicationContext().getString(R.string.scheduled_toots)) .setContentTitle(getApplicationContext().getString(R.string.notifications))
.setContentText(getApplicationContext().getString(R.string.scheduled_toots)) .setContentText(getApplicationContext().getString(R.string.fetch_notifications))
.setDefaults(NotificationCompat.DEFAULT_ALL) .setDefaults(NotificationCompat.DEFAULT_ALL)
.setPriority(Notification.PRIORITY_DEFAULT); .setPriority(Notification.PRIORITY_DEFAULT);
return new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build()); return new ForegroundInfo(FETCH_NOTIFICATION_CHANNEL_ID, notificationBuilder.build());

View file

@ -325,12 +325,11 @@ public class StatusesVM extends AndroidViewModel {
//The status must also be deleted in cache //The status must also be deleted in cache
try { try {
BaseAccount account = new app.fedilab.android.client.entities.app.Account(getApplication().getApplicationContext()).getAccountByToken(token); 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) { } catch (DBException e) {
e.printStackTrace(); e.printStackTrace();
} }
Handler mainHandler = new Handler(Looper.getMainLooper()); Handler mainHandler = new Handler(Looper.getMainLooper());
Status finalStatus = status; Status finalStatus = status;
Runnable myRunnable = () -> statusMutableLiveData.setValue(finalStatus); Runnable myRunnable = () -> statusMutableLiveData.setValue(finalStatus);

View file

@ -1474,4 +1474,5 @@
<string name="cached_messages">Cached message</string> <string name="cached_messages">Cached message</string>
<string name="reply">Reply</string> <string name="reply">Reply</string>
<string name="display_options">Display options</string> <string name="display_options">Display options</string>
<string name="fetch_notifications">Fetch notifications</string>
</resources> </resources>