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

Commit

Permalink
add push post notifications
Browse files Browse the repository at this point in the history
closes #93
  • Loading branch information
sk22 committed Dec 7, 2022
1 parent 9a085be commit b190480
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ 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_at_symbol, pushSubscription.alerts.mention, i->onNotificationsChanged(PushNotification.Type.MENTION, 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 HeaderItem(R.string.settings_boring));
items.add(new TextItem(R.string.settings_account, ()->UiUtils.launchWebBrowser(getActivity(), "https://"+session.domain+"/auth/edit")));
Expand Down Expand Up @@ -293,6 +294,7 @@ private void onNotificationsChanged(PushNotification.Type type, boolean enabled)
case FOLLOW -> subscription.alerts.follow=enabled;
case REBLOG -> subscription.alerts.reblog=enabled;
case MENTION -> subscription.alerts.mention=subscription.alerts.poll=enabled;
case STATUS -> subscription.alerts.status=enabled;
}
needUpdateNotificationSettings=true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public enum Type{
@SerializedName("follow")
FOLLOW(R.string.notification_type_follow),
@SerializedName("poll")
POLL(R.string.notification_type_poll);
POLL(R.string.notification_type_poll),
@SerializedName("status")
STATUS(R.string.sk_notification_type_status);

@StringRes
public final int localizedName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ public static class Alerts implements Cloneable{
public boolean reblog;
public boolean mention;
public boolean poll;
public boolean status;

public static Alerts ofAll(){
Alerts alerts=new Alerts();
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=true;
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=true;
return alerts;
}

Expand All @@ -58,6 +59,7 @@ public String toString(){
", reblog="+reblog+
", mention="+mention+
", poll="+poll+
", status="+status+
'}';
}

Expand Down
2 changes: 2 additions & 0 deletions mastodon/src/main/res/values/strings_sk.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,6 @@
<string name="sk_disable_marquee">Disable scrolling text in title bars</string>
<string name="sk_settings_contribute">Contribute to Megalodon</string>
<string name="sk_settings_show_federated_timeline">Show federated timeline</string>
<string name="sk_notification_type_status">Posts</string>
<string name="sk_notify_posts">Post notifications</string>
</resources>

0 comments on commit b190480

Please sign in to comment.