support admin notifications
This commit is contained in:
@@ -163,6 +163,8 @@ public class PushNotificationReceiver extends BroadcastReceiver{
|
|||||||
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;
|
case UPDATE -> R.drawable.ic_fluent_history_24_filled;
|
||||||
|
case REPORT -> R.drawable.ic_fluent_warning_24_filled;
|
||||||
|
case SIGN_UP -> R.drawable.ic_fluent_person_available_24_filled;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.joinmastodon.android.fragments;
|
|||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import com.squareup.otto.Subscribe;
|
import com.squareup.otto.Subscribe;
|
||||||
@@ -12,14 +13,19 @@ import org.joinmastodon.android.api.requests.markers.SaveMarkers;
|
|||||||
import org.joinmastodon.android.api.session.AccountSessionManager;
|
import org.joinmastodon.android.api.session.AccountSessionManager;
|
||||||
import org.joinmastodon.android.events.PollUpdatedEvent;
|
import org.joinmastodon.android.events.PollUpdatedEvent;
|
||||||
import org.joinmastodon.android.events.RemoveAccountPostsEvent;
|
import org.joinmastodon.android.events.RemoveAccountPostsEvent;
|
||||||
|
import org.joinmastodon.android.model.Account;
|
||||||
import org.joinmastodon.android.model.Notification;
|
import org.joinmastodon.android.model.Notification;
|
||||||
import org.joinmastodon.android.model.PaginatedResponse;
|
import org.joinmastodon.android.model.PaginatedResponse;
|
||||||
import org.joinmastodon.android.model.Status;
|
import org.joinmastodon.android.model.Status;
|
||||||
import org.joinmastodon.android.ui.displayitems.AccountCardStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.AccountCardStatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.displayitems.AccountStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.HeaderStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.ImageStatusDisplayItem;
|
||||||
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
import org.joinmastodon.android.ui.displayitems.StatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.displayitems.TextStatusDisplayItem;
|
||||||
|
import org.joinmastodon.android.ui.utils.DiscoverInfoBannerHelper;
|
||||||
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
import org.joinmastodon.android.ui.utils.InsetStatusItemDecoration;
|
||||||
|
import org.joinmastodon.android.ui.utils.UiUtils;
|
||||||
import org.parceler.Parcels;
|
import org.parceler.Parcels;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -39,6 +45,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
private boolean onlyMentions;
|
private boolean onlyMentions;
|
||||||
private boolean onlyPosts;
|
private boolean onlyPosts;
|
||||||
private String maxID;
|
private String maxID;
|
||||||
|
private final DiscoverInfoBannerHelper bannerHelper = new DiscoverInfoBannerHelper(DiscoverInfoBannerHelper.BannerType.POST_NOTIFICATIONS);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState){
|
public void onCreate(Bundle savedInstanceState){
|
||||||
@@ -69,6 +76,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected List<StatusDisplayItem> buildDisplayItems(Notification n){
|
protected List<StatusDisplayItem> buildDisplayItems(Notification n){
|
||||||
|
Account reportTarget = n.report == null ? null : n.report.targetAccount == null ? null :
|
||||||
|
n.report.targetAccount;
|
||||||
String extraText=switch(n.type){
|
String extraText=switch(n.type){
|
||||||
case FOLLOW -> getString(R.string.user_followed_you);
|
case FOLLOW -> getString(R.string.user_followed_you);
|
||||||
case FOLLOW_REQUEST -> getString(R.string.user_sent_follow_request);
|
case FOLLOW_REQUEST -> getString(R.string.user_sent_follow_request);
|
||||||
@@ -77,6 +86,8 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
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);
|
case UPDATE -> getString(R.string.sk_post_edited);
|
||||||
|
case SIGN_UP -> getString(R.string.sk_signed_up);
|
||||||
|
case REPORT -> getString(R.string.sk_reported);
|
||||||
};
|
};
|
||||||
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, n.status, extraText, n, null) : null;
|
HeaderStatusDisplayItem titleItem=extraText!=null ? new HeaderStatusDisplayItem(n.id, n.account, n.createdAt, this, accountID, n.status, extraText, n, null) : null;
|
||||||
if(n.status!=null){
|
if(n.status!=null){
|
||||||
@@ -92,8 +103,13 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
items.add(0, titleItem);
|
items.add(0, titleItem);
|
||||||
return items;
|
return items;
|
||||||
}else if(titleItem!=null){
|
}else if(titleItem!=null){
|
||||||
AccountCardStatusDisplayItem card=new AccountCardStatusDisplayItem(n.id, this, n.account, n);
|
AccountCardStatusDisplayItem card=new AccountCardStatusDisplayItem(n.id, this,
|
||||||
return Arrays.asList(titleItem, card);
|
reportTarget != null ? reportTarget : n.account, n);
|
||||||
|
TextStatusDisplayItem text = n.report != null && !TextUtils.isEmpty(n.report.comment) ?
|
||||||
|
new TextStatusDisplayItem(n.id, n.report.comment, this,
|
||||||
|
Status.ofFake(n.id, n.report.comment, n.createdAt), true) :
|
||||||
|
null;
|
||||||
|
return text == null ? Arrays.asList(titleItem, card) : Arrays.asList(titleItem, text, card);
|
||||||
}else{
|
}else{
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
@@ -162,6 +178,9 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
if(status.inReplyToAccountId!=null && knownAccounts.containsKey(status.inReplyToAccountId))
|
if(status.inReplyToAccountId!=null && knownAccounts.containsKey(status.inReplyToAccountId))
|
||||||
args.putParcelable("inReplyToAccount", Parcels.wrap(knownAccounts.get(status.inReplyToAccountId)));
|
args.putParcelable("inReplyToAccount", Parcels.wrap(knownAccounts.get(status.inReplyToAccountId)));
|
||||||
Nav.go(getActivity(), ThreadFragment.class, args);
|
Nav.go(getActivity(), ThreadFragment.class, args);
|
||||||
|
}else if(n.report != null){
|
||||||
|
String domain = AccountSessionManager.getInstance().getAccount(accountID).domain;
|
||||||
|
UiUtils.launchWebBrowser(getActivity(), "https://"+domain+"/admin/reports/"+n.report.id);
|
||||||
}else{
|
}else{
|
||||||
Bundle args=new Bundle();
|
Bundle args=new Bundle();
|
||||||
args.putString("account", accountID);
|
args.putString("account", accountID);
|
||||||
@@ -174,6 +193,7 @@ public class NotificationsListFragment extends BaseStatusListFragment<Notificati
|
|||||||
public void onViewCreated(View view, Bundle savedInstanceState){
|
public void onViewCreated(View view, Bundle savedInstanceState){
|
||||||
super.onViewCreated(view, savedInstanceState);
|
super.onViewCreated(view, savedInstanceState);
|
||||||
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
list.addItemDecoration(new InsetStatusItemDecoration(this));
|
||||||
|
if (onlyPosts) bannerHelper.maybeAddBanner(contentWrap);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Notification getNotificationByID(String id){
|
private Notification getNotificationByID(String id){
|
||||||
|
|||||||
@@ -42,17 +42,9 @@ public class Announcement extends BaseModel implements DisplayItemsParent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Status toStatus() {
|
public Status toStatus() {
|
||||||
Status s = new Status();
|
Status s = Status.ofFake(id, content, publishedAt);
|
||||||
s.id = id;
|
|
||||||
s.mediaAttachments = List.of();
|
|
||||||
s.createdAt = startsAt != null ? startsAt : publishedAt;
|
s.createdAt = startsAt != null ? startsAt : publishedAt;
|
||||||
if (updatedAt != null) s.editedAt = updatedAt;
|
if (updatedAt != null) s.editedAt = updatedAt;
|
||||||
s.content = s.text = content;
|
|
||||||
s.spoilerText = "";
|
|
||||||
s.visibility = StatusPrivacy.PUBLIC;
|
|
||||||
s.mentions = List.of();
|
|
||||||
s.tags = List.of();
|
|
||||||
s.emojis = List.of();
|
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ public class Notification extends BaseModel implements DisplayItemsParent{
|
|||||||
public Instant createdAt;
|
public Instant createdAt;
|
||||||
@RequiredField
|
@RequiredField
|
||||||
public Account account;
|
public Account account;
|
||||||
|
|
||||||
public Status status;
|
public Status status;
|
||||||
|
public Report report;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postprocess() throws ObjectValidationException{
|
public void postprocess() throws ObjectValidationException{
|
||||||
@@ -50,6 +50,17 @@ public class Notification extends BaseModel implements DisplayItemsParent{
|
|||||||
@SerializedName("status")
|
@SerializedName("status")
|
||||||
STATUS,
|
STATUS,
|
||||||
@SerializedName("update")
|
@SerializedName("update")
|
||||||
UPDATE
|
UPDATE,
|
||||||
|
@SerializedName("admin.sign_up")
|
||||||
|
SIGN_UP,
|
||||||
|
@SerializedName("admin.report")
|
||||||
|
REPORT
|
||||||
|
}
|
||||||
|
|
||||||
|
@Parcel
|
||||||
|
public static class Report {
|
||||||
|
public String id;
|
||||||
|
public String comment;
|
||||||
|
public Account targetAccount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,7 +47,11 @@ public class PushNotification extends BaseModel{
|
|||||||
@SerializedName("status")
|
@SerializedName("status")
|
||||||
STATUS(R.string.sk_notification_type_status),
|
STATUS(R.string.sk_notification_type_status),
|
||||||
@SerializedName("update")
|
@SerializedName("update")
|
||||||
UPDATE(R.string.sk_notification_type_update);
|
UPDATE(R.string.sk_notification_type_update),
|
||||||
|
@SerializedName("admin.sign_up")
|
||||||
|
SIGN_UP(R.string.sk_sign_ups),
|
||||||
|
@SerializedName("admin.report")
|
||||||
|
REPORT(R.string.sk_new_reports);
|
||||||
|
|
||||||
@StringRes
|
@StringRes
|
||||||
public final int localizedName;
|
public final int localizedName;
|
||||||
|
|||||||
@@ -47,6 +47,14 @@ public class PushSubscription extends BaseModel implements Cloneable{
|
|||||||
public boolean status;
|
public boolean status;
|
||||||
public boolean update;
|
public boolean update;
|
||||||
|
|
||||||
|
// set to true here because i didn't add any items for those to the settings
|
||||||
|
// (so i don't have to determine whether the user is an admin to show the items or not, and
|
||||||
|
// admins can still disable those through the android notifications settings)
|
||||||
|
@SerializedName("admin.sign_up")
|
||||||
|
public boolean adminSignUp = true;
|
||||||
|
@SerializedName("admin.report")
|
||||||
|
public boolean adminReport = true;
|
||||||
|
|
||||||
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=alerts.update=true;
|
alerts.follow=alerts.favourite=alerts.reblog=alerts.mention=alerts.poll=alerts.status=alerts.update=true;
|
||||||
@@ -63,6 +71,8 @@ public class PushSubscription extends BaseModel implements Cloneable{
|
|||||||
", poll="+poll+
|
", poll="+poll+
|
||||||
", status="+status+
|
", status="+status+
|
||||||
", update="+update+
|
", update="+update+
|
||||||
|
", adminSignUp="+adminSignUp+
|
||||||
|
", adminReport="+adminReport+
|
||||||
'}';
|
'}';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -146,4 +146,18 @@ public class Status extends BaseModel implements DisplayItemsParent{
|
|||||||
strippedText=HtmlParser.strip(content);
|
strippedText=HtmlParser.strip(content);
|
||||||
return strippedText;
|
return strippedText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static Status ofFake(String id, String text, Instant createdAt) {
|
||||||
|
Status s = new Status();
|
||||||
|
s.id = id;
|
||||||
|
s.mediaAttachments = List.of();
|
||||||
|
s.createdAt = createdAt;
|
||||||
|
s.content = s.text = text;
|
||||||
|
s.spoilerText = "";
|
||||||
|
s.visibility = StatusPrivacy.PUBLIC;
|
||||||
|
s.mentions = List.of();
|
||||||
|
s.tags = List.of();
|
||||||
|
s.emojis = List.of();
|
||||||
|
return s;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,7 +346,8 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
|
|||||||
extraText.setVisibility(View.VISIBLE);
|
extraText.setVisibility(View.VISIBLE);
|
||||||
extraText.setText(item.extraText);
|
extraText.setText(item.extraText);
|
||||||
}
|
}
|
||||||
more.setVisibility(item.inset ? View.GONE : View.VISIBLE);
|
more.setVisibility(item.inset || (item.notification != null && item.notification.report != null)
|
||||||
|
? View.GONE : View.VISIBLE);
|
||||||
avatar.setClickable(!item.inset);
|
avatar.setClickable(!item.inset);
|
||||||
avatar.setContentDescription(item.parentFragment.getString(R.string.avatar_description, item.user.acct));
|
avatar.setContentDescription(item.parentFragment.getString(R.string.avatar_description, item.user.acct));
|
||||||
if(currentRelationshipRequest!=null){
|
if(currentRelationshipRequest!=null){
|
||||||
|
|||||||
@@ -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="M17.5 12c3.038 0 5.5 2.463 5.5 5.5 0 3.038-2.462 5.5-5.5 5.5-3.037 0-5.5-2.462-5.5-5.5 0-3.037 2.463-5.5 5.5-5.5zm-5.477 2C11.376 15.01 11 16.21 11 17.5c0 1.63 0.6 3.12 1.592 4.262-0.795 0.16-1.66 0.24-2.592 0.24-3.42 0-5.944-1.073-7.486-3.237-0.332-0.466-0.51-1.024-0.51-1.596v-0.92C2.004 15.007 3.01 14 4.253 14h7.77zm2.83 3.147c-0.194-0.196-0.51-0.196-0.706 0-0.196 0.195-0.196 0.512 0 0.707l2 2c0.195 0.195 0.512 0.195 0.707 0l4-4c0.195-0.195 0.195-0.512 0-0.707-0.195-0.196-0.512-0.196-0.707 0L16.5 18.793l-1.646-1.646zM10 2.005c2.762 0 5 2.239 5 5s-2.238 5-5 5c-2.761 0-5-2.239-5-5s2.239-5 5-5z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||||
|
</vector>
|
||||||
@@ -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="M10.03 3.659c0.856-1.548 3.081-1.548 3.937 0l7.746 14.001c0.83 1.5-0.255 3.34-1.969 3.34H4.254c-1.715 0-2.8-1.84-1.97-3.34l7.746-14zM12.997 17c0-0.552-0.447-0.999-0.998-0.999C11.447 16.001 11 16.448 11 17s0.447 1 0.999 1c0.551 0 0.998-0.448 0.998-1zm-0.259-7.853C12.688 8.782 12.374 8.5 11.995 8.5c-0.415 0-0.75 0.336-0.75 0.75l0.004 4.502 0.007 0.102c0.05 0.366 0.364 0.648 0.743 0.648 0.415 0 0.75-0.337 0.75-0.751l-0.004-4.502-0.007-0.101z" android:fillColor="@color/fluent_default_icon_tint"/>
|
||||||
|
</vector>
|
||||||
@@ -26,6 +26,50 @@
|
|||||||
android:gravity="top|start"
|
android:gravity="top|start"
|
||||||
android:minHeight="212dp"/>
|
android:minHeight="212dp"/>
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:id="@+id/forward_report"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:paddingHorizontal="8dp"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:gravity="center_vertical"
|
||||||
|
android:layoutDirection="locale"
|
||||||
|
android:background="?android:selectableItemBackground">
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/icon"
|
||||||
|
android:layout_width="24dp"
|
||||||
|
android:layout_height="24dp"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="32dp"
|
||||||
|
android:importantForAccessibility="no"
|
||||||
|
android:tint="?android:textColorPrimary"
|
||||||
|
android:src="@drawable/ic_fluent_arrow_forward_24_regular"/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/forward_report_text"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_weight="1"
|
||||||
|
android:paddingVertical="8dp"
|
||||||
|
android:textSize="16sp"
|
||||||
|
android:text="@string/sk_forward_report_to"
|
||||||
|
android:textColor="?android:textColorPrimary" />
|
||||||
|
|
||||||
|
<Switch
|
||||||
|
android:id="@+id/forward_report_switch"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:duplicateParentState="true"
|
||||||
|
android:layout_marginStart="16dp"
|
||||||
|
android:layout_marginEnd="12dp"
|
||||||
|
android:focusable="false"
|
||||||
|
android:clickable="false"/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
</ScrollView>
|
</ScrollView>
|
||||||
|
|||||||
@@ -245,4 +245,8 @@
|
|||||||
<string name="sk_settings_local_only_explanation">Your home instance must support local-only posting for this to work. Most modified versions of Mastodon do, but Mastodon doesn’t.</string>
|
<string name="sk_settings_local_only_explanation">Your home instance must support local-only posting for this to work. Most modified versions of Mastodon do, but Mastodon doesn’t.</string>
|
||||||
<string name="sk_settings_glitch_instance">Glitch local-only mode</string>
|
<string name="sk_settings_glitch_instance">Glitch local-only mode</string>
|
||||||
<string name="sk_settings_glitch_mode_explanation">Enable this if your home instance runs on Glitch. Not needed for Hometown or Akkoma.</string>
|
<string name="sk_settings_glitch_mode_explanation">Enable this if your home instance runs on Glitch. Not needed for Hometown or Akkoma.</string>
|
||||||
|
<string name="sk_signed_up">signed up</string>
|
||||||
|
<string name="sk_reported">reported</string>
|
||||||
|
<string name="sk_sign_ups">Users signing up</string>
|
||||||
|
<string name="sk_new_reports">New reports</string>
|
||||||
</resources>
|
</resources>
|
||||||
Reference in New Issue
Block a user