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

Commit

Permalink
notifications for edited posts
Browse files Browse the repository at this point in the history
closes #331
  • Loading branch information
sk22 committed Jan 21, 2023
1 parent be4b032 commit 900e8fb
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ private void notify(Context context, PushNotification pn, String accountID, org.
case MENTION -> R.drawable.ic_fluent_mention_24_filled;
case POLL -> R.drawable.ic_fluent_poll_24_filled;
case STATUS -> R.drawable.ic_fluent_chat_24_filled;
case UPDATE -> R.drawable.ic_fluent_history_24_filled;
});
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@

import android.app.Activity;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;

import com.squareup.otto.Subscribe;
Expand Down Expand Up @@ -80,6 +78,7 @@ protected List<StatusDisplayItem> buildDisplayItems(Notification n){
case REBLOG -> getString(R.string.notification_boosted);
case FAVORITE -> getString(R.string.user_favorited);
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;
if(n.status!=null){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ public void onCreate(Bundle savedInstanceState){
GlobalUserPreferences.disableAltTextReminder=i.checked;
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->{
GlobalUserPreferences.translateButtonOpenedOnly=i.checked;
GlobalUserPreferences.save();
Expand Down Expand Up @@ -226,11 +230,8 @@ public void onCreate(Bundle savedInstanceState){
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_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_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 TextItem(R.string.sk_settings_profile, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/settings/profile"), R.drawable.ic_fluent_open_24_regular));
Expand Down Expand Up @@ -420,6 +421,7 @@ private void onNotificationsChanged(PushNotification.Type type, boolean enabled)
case REBLOG -> subscription.alerts.reblog=enabled;
case MENTION -> subscription.alerts.mention=subscription.alerts.poll=enabled;
case STATUS -> subscription.alerts.status=enabled;
case UPDATE -> subscription.alerts.update=enabled;
}
needUpdateNotificationSettings=true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ public enum Type{
@SerializedName("poll")
POLL,
@SerializedName("status")
STATUS
STATUS,
@SerializedName("update")
UPDATE
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@ public enum Type{
@SerializedName("poll")
POLL(R.string.notification_type_poll),
@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
public final int localizedName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,11 @@ public static class Alerts implements Cloneable{
public boolean mention;
public boolean poll;
public boolean status;
public boolean update;

public static Alerts ofAll(){
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;
}

Expand All @@ -61,6 +62,7 @@ public String toString(){
", mention="+mention+
", poll="+poll+
", status="+status+
", update="+update+
'}';
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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>
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 3 additions & 0 deletions mastodon/src/main/res/values/strings_sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,7 @@
<string name="sk_edit_timeline">Edit timeline</string>
<string name="sk_edit_timelines">Edit timelines</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>

0 comments on commit 900e8fb

Please sign in to comment.