Skip to content
This repository was archived by the owner on Oct 28, 2024. It is now read-only.

Commit 900e8fb

Browse files
committed
notifications for edited posts
closes #331
1 parent be4b032 commit 900e8fb

9 files changed

+26
-9
lines changed

mastodon/src/main/java/org/joinmastodon/android/PushNotificationReceiver.java

+1
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ private void notify(Context context, PushNotification pn, String accountID, org.
152152
case MENTION -> R.drawable.ic_fluent_mention_24_filled;
153153
case POLL -> R.drawable.ic_fluent_poll_24_filled;
154154
case STATUS -> R.drawable.ic_fluent_chat_24_filled;
155+
case UPDATE -> R.drawable.ic_fluent_history_24_filled;
155156
});
156157
}
157158

mastodon/src/main/java/org/joinmastodon/android/fragments/NotificationsListFragment.java

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import android.app.Activity;
44
import android.os.Bundle;
5-
import android.view.Menu;
6-
import android.view.MenuInflater;
75
import android.view.View;
86

97
import com.squareup.otto.Subscribe;
@@ -80,6 +78,7 @@ protected List<StatusDisplayItem> buildDisplayItems(Notification n){
8078
case REBLOG -> getString(R.string.notification_boosted);
8179
case FAVORITE -> getString(R.string.user_favorited);
8280
case POLL -> getString(R.string.poll_ended);
81+
case UPDATE -> getString(R.string.sk_post_edited);
8382
};
8483
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText, n, null) : null;
8584
if(n.status!=null){

mastodon/src/main/java/org/joinmastodon/android/fragments/SettingsFragment.java

+6-4
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ public void onCreate(Bundle savedInstanceState){
195195
GlobalUserPreferences.disableAltTextReminder=i.checked;
196196
GlobalUserPreferences.save();
197197
}));
198+
items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{
199+
GlobalUserPreferences.keepOnlyLatestNotification=i.checked;
200+
GlobalUserPreferences.save();
201+
}));
198202
items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{
199203
GlobalUserPreferences.translateButtonOpenedOnly=i.checked;
200204
GlobalUserPreferences.save();
@@ -226,11 +230,8 @@ public void onCreate(Bundle savedInstanceState){
226230
items.add(new SwitchItem(R.string.notify_follow, R.drawable.ic_fluent_person_add_24_regular, pushSubscription.alerts.follow, i->onNotificationsChanged(PushNotification.Type.FOLLOW, i.checked)));
227231
items.add(new SwitchItem(R.string.notify_reblog, R.drawable.ic_fluent_arrow_repeat_all_24_regular, pushSubscription.alerts.reblog, i->onNotificationsChanged(PushNotification.Type.REBLOG, i.checked)));
228232
items.add(new SwitchItem(R.string.notify_mention, R.drawable.ic_fluent_mention_24_regular, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, i.checked)));
233+
items.add(new SwitchItem(R.string.sk_notify_update, R.drawable.ic_fluent_history_24_regular, pushSubscription.alerts.update, i->onNotificationsChanged(PushNotification.Type.UPDATE, i.checked)));
229234
items.add(new SwitchItem(R.string.sk_notify_posts, R.drawable.ic_fluent_alert_24_regular, pushSubscription.alerts.status, i->onNotificationsChanged(PushNotification.Type.STATUS, i.checked)));
230-
items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{
231-
GlobalUserPreferences.keepOnlyLatestNotification=i.checked;
232-
GlobalUserPreferences.save();
233-
}));
234235

235236
items.add(new HeaderItem(R.string.settings_account));
236237
items.add(new TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular));
@@ -420,6 +421,7 @@ private void onNotificationsChanged(PushNotification.Type type, boolean enabled)
420421
case REBLOG -> subscription.alerts.reblog=enabled;
421422
case MENTION -> subscription.alerts.mention=subscription.alerts.poll=enabled;
422423
case STATUS -> subscription.alerts.status=enabled;
424+
case UPDATE -> subscription.alerts.update=enabled;
423425
}
424426
needUpdateNotificationSettings=true;
425427
}

mastodon/src/main/java/org/joinmastodon/android/model/Notification.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ public enum Type{
4848
@SerializedName("poll")
4949
POLL,
5050
@SerializedName("status")
51-
STATUS
51+
STATUS,
52+
@SerializedName("update")
53+
UPDATE
5254
}
5355
}

mastodon/src/main/java/org/joinmastodon/android/model/PushNotification.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,9 @@ public enum Type{
4545
@SerializedName("poll")
4646
POLL(R.string.notification_type_poll),
4747
@SerializedName("status")
48-
STATUS(R.string.sk_notification_type_status);
48+
STATUS(R.string.sk_notification_type_status),
49+
@SerializedName("update")
50+
UPDATE(R.string.sk_notification_type_update);
4951

5052
@StringRes
5153
public final int localizedName;

mastodon/src/main/java/org/joinmastodon/android/model/PushSubscription.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ public static class Alerts implements Cloneable{
4545
public boolean mention;
4646
public boolean poll;
4747
public boolean status;
48+
public boolean update;
4849

4950
public static Alerts ofAll(){
5051
Alerts alerts=new Alerts();
51-
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=true;
52+
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=alerts.update=true;
5253
return alerts;
5354
}
5455

@@ -61,6 +62,7 @@ public String toString(){
6162
", mention="+mention+
6263
", poll="+poll+
6364
", status="+status+
65+
", update="+update+
6466
'}';
6567
}
6668

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
2+
<path android:pathData="M19.25 12c0-4.004-3.246-7.25-7.25-7.25-1.662 0-3.194 0.56-4.417 1.5H8.25c0.552 0 1 0.448 1 1s-0.448 1-1 1h-3c-0.552 0-1-0.448-1-1V7H4.216L4.25 6.948V4.25c0-0.552 0.448-1 1-1s1 0.448 1 1v0.504C7.829 3.499 9.827 2.75 12 2.75c5.109 0 9.25 4.141 9.25 9.25s-4.141 9.25-9.25 9.25S2.75 17.109 2.75 12c0-0.383 0.023-0.76 0.068-1.13C2.881 10.358 3.334 10 3.85 10c0.59 0 1.017 0.569 0.949 1.156C4.766 11.433 4.75 11.714 4.75 12c0 4.004 3.246 7.25 7.25 7.25s7.25-3.246 7.25-7.25zM13 8c0-0.552-0.448-1-1-1s-1 0.448-1 1v5c0 0.552 0.448 1 1 1h3c0.552 0 1-0.448 1-1s-0.448-1-1-1h-2V8z" android:fillColor="@color/fluent_default_icon_tint"/>
3+
</vector>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
2+
<path android:pathData="M19.5 12c0-4.142-3.358-7.5-7.5-7.5-1.97 0-3.76 0.759-5.1 2h1.35C8.664 6.5 9 6.836 9 7.25S8.664 8 8.25 8h-3C4.836 8 4.5 7.664 4.5 7.25v-3c0-0.414 0.336-0.75 0.75-0.75S6 3.836 6 4.25v1.042C7.592 3.867 9.695 3 12 3c4.97 0 9 4.03 9 9s-4.03 9-9 9-9-4.03-9-9c0-0.468 0.036-0.928 0.105-1.377C3.16 10.256 3.486 10 3.857 10c0.46 0 0.791 0.438 0.724 0.892C4.528 11.254 4.5 11.624 4.5 12c0 4.142 3.358 7.5 7.5 7.5 4.142 0 7.5-3.358 7.5-7.5zm-7-4.25C12.5 7.336 12.164 7 11.75 7S11 7.336 11 7.75v4.5c0 0.414 0.336 0.75 0.75 0.75h2.5c0.414 0 0.75-0.336 0.75-0.75s-0.336-0.75-0.75-0.75H12.5V7.75z" android:fillColor="@color/fluent_default_icon_tint"/>
3+
</vector>

mastodon/src/main/res/values/strings_sk.xml

+3
Original file line numberDiff line numberDiff line change
@@ -171,4 +171,7 @@
171171
<string name="sk_edit_timeline">Edit timeline</string>
172172
<string name="sk_edit_timelines">Edit timelines</string>
173173
<string name="sk_alt_button">ALT</string>
174+
<string name="sk_post_edited">edited</string>
175+
<string name="sk_notification_type_update">Edited posts</string>
176+
<string name="sk_notify_update">Edits a reblogged posts</string>
174177
</resources>

0 commit comments

Comments
 (0)