notifications for edited posts

closes sk22#331
This commit is contained in:
sk
2023-01-21 22:06:00 +01:00
parent be4b032527
commit 900e8fb2e9
9 changed files with 26 additions and 9 deletions

View File

@@ -152,6 +152,7 @@ public class PushNotificationReceiver extends BroadcastReceiver{
case MENTION -> R.drawable.ic_fluent_mention_24_filled; case MENTION -> R.drawable.ic_fluent_mention_24_filled;
case POLL -> R.drawable.ic_fluent_poll_24_filled; case POLL -> R.drawable.ic_fluent_poll_24_filled;
case STATUS -> R.drawable.ic_fluent_chat_24_filled; case STATUS -> R.drawable.ic_fluent_chat_24_filled;
case UPDATE -> R.drawable.ic_fluent_history_24_filled;
}); });
} }

View File

@@ -2,8 +2,6 @@ package org.joinmastodon.android.fragments;
import android.app.Activity; import android.app.Activity;
import android.os.Bundle; import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View; import android.view.View;
import com.squareup.otto.Subscribe; import com.squareup.otto.Subscribe;
@@ -80,6 +78,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
case REBLOG -> getString(R.string.notification_boosted); case REBLOG -> getString(R.string.notification_boosted);
case FAVORITE -> getString(R.string.user_favorited); case FAVORITE -> getString(R.string.user_favorited);
case POLL -> getString(R.string.poll_ended); case POLL -> getString(R.string.poll_ended);
case UPDATE -> getString(R.string.sk_post_edited);
}; };
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText, n, null) : null; HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, null, extraText, n, null) : null;
if(n.status!=null){ if(n.status!=null){

View File

@@ -195,6 +195,10 @@ public class SettingsFragment extends MastodonToolbarFragment{
GlobalUserPreferences.disableAltTextReminder=i.checked; GlobalUserPreferences.disableAltTextReminder=i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
})); }));
items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{
GlobalUserPreferences.keepOnlyLatestNotification=i.checked;
GlobalUserPreferences.save();
}));
items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{ items.add(new SwitchItem(R.string.sk_settings_translate_only_opened, R.drawable.ic_fluent_translate_24_regular, GlobalUserPreferences.translateButtonOpenedOnly, i->{
GlobalUserPreferences.translateButtonOpenedOnly=i.checked; GlobalUserPreferences.translateButtonOpenedOnly=i.checked;
GlobalUserPreferences.save(); GlobalUserPreferences.save();
@@ -226,11 +230,8 @@ public class SettingsFragment extends MastodonToolbarFragment{
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))); 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)));
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))); 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)));
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))); 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)));
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)));
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))); 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)));
items.add(new SwitchItem(R.string.sk_settings_single_notification, R.drawable.ic_fluent_convert_range_24_regular, GlobalUserPreferences.keepOnlyLatestNotification, i->{
GlobalUserPreferences.keepOnlyLatestNotification=i.checked;
GlobalUserPreferences.save();
}));
items.add(new HeaderItem(R.string.settings_account)); items.add(new HeaderItem(R.string.settings_account));
items.add(new TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular)); 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 @@ public class SettingsFragment extends MastodonToolbarFragment{
case REBLOG -> subscription.alerts.reblog=enabled; case REBLOG -> subscription.alerts.reblog=enabled;
case MENTION -> subscription.alerts.mention=subscription.alerts.poll=enabled; case MENTION -> subscription.alerts.mention=subscription.alerts.poll=enabled;
case STATUS -> subscription.alerts.status=enabled; case STATUS -> subscription.alerts.status=enabled;
case UPDATE -> subscription.alerts.update=enabled;
} }
needUpdateNotificationSettings=true; needUpdateNotificationSettings=true;
} }

View File

@@ -48,6 +48,8 @@ public class Notification extends BaseModel implements DisplayItemsParent{
@SerializedName("poll") @SerializedName("poll")
POLL, POLL,
@SerializedName("status") @SerializedName("status")
STATUS STATUS,
@SerializedName("update")
UPDATE
} }
} }

View File

@@ -45,7 +45,9 @@ public class PushNotification extends BaseModel{
@SerializedName("poll") @SerializedName("poll")
POLL(R.string.notification_type_poll), POLL(R.string.notification_type_poll),
@SerializedName("status") @SerializedName("status")
STATUS(R.string.sk_notification_type_status); STATUS(R.string.sk_notification_type_status),
@SerializedName("update")
UPDATE(R.string.sk_notification_type_update);
@StringRes @StringRes
public final int localizedName; public final int localizedName;

View File

@@ -45,10 +45,11 @@ public class PushSubscription extends BaseModel implements Cloneable{
public boolean mention; public boolean mention;
public boolean poll; public boolean poll;
public boolean status; public boolean status;
public boolean update;
public static Alerts ofAll(){ public static Alerts ofAll(){
Alerts alerts=new Alerts(); Alerts alerts=new Alerts();
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=true; alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=alerts.update=true;
return alerts; return alerts;
} }
@@ -61,6 +62,7 @@ public class PushSubscription extends BaseModel implements Cloneable{
", mention="+mention+ ", mention="+mention+
", poll="+poll+ ", poll="+poll+
", status="+status+ ", status="+status+
", update="+update+
'}'; '}';
} }

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<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"/>
</vector>

View File

@@ -0,0 +1,3 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android" android:width="24dp" android:height="24dp" android:viewportWidth="24" android:viewportHeight="24">
<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"/>
</vector>

View File

@@ -171,4 +171,7 @@
<string name="sk_edit_timeline">Edit timeline</string> <string name="sk_edit_timeline">Edit timeline</string>
<string name="sk_edit_timelines">Edit timelines</string> <string name="sk_edit_timelines">Edit timelines</string>
<string name="sk_alt_button">ALT</string> <string name="sk_alt_button">ALT</string>
<string name="sk_post_edited">edited</string>
<string name="sk_notification_type_update">Edited posts</string>
<string name="sk_notify_update">Edits a reblogged posts</string>
</resources> </resources>