Fix issue #496 - wrong label for new reports and user sign-up

This commit is contained in:
Thomas 2022-11-20 15:37:09 +01:00
parent b334a5b655
commit 3f8f15256d
4 changed files with 33 additions and 7 deletions

View File

@ -67,6 +67,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
private final int TYPE_REACTION = 8;
private final int TYPE_UPDATE = 9;
private final int TYPE_FILERED = 10;
private final int TYPE_ADMIN_SIGNUP = 11;
private final int TYPE_ADMIN_REPORT = 12;
public FetchMoreCallBack fetchMoreCallBack;
private Context context;
@ -107,6 +109,10 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
return TYPE_POLL;
case "status":
return TYPE_STATUS;
case "admin.sign_up":
return TYPE_ADMIN_SIGNUP;
case "admin.report":
return TYPE_ADMIN_REPORT;
case "pleroma:emoji_reaction":
return TYPE_REACTION;
}
@ -118,7 +124,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override
public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
context = parent.getContext();
if (viewType == TYPE_FOLLOW || viewType == TYPE_FOLLOW_REQUEST) {
if (viewType == TYPE_FOLLOW || viewType == TYPE_FOLLOW_REQUEST || viewType == TYPE_ADMIN_REPORT || viewType == TYPE_ADMIN_SIGNUP) {
DrawerFollowBinding itemBinding = DrawerFollowBinding.inflate(LayoutInflater.from(parent.getContext()), parent, false);
return new ViewHolderFollow(itemBinding);
} else if (viewType == TYPE_FILERED) {
@ -133,7 +139,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
@Override
public void onBindViewHolder(@NonNull RecyclerView.ViewHolder viewHolder, int position) {
Notification notification = notificationList.get(position);
if (getItemViewType(position) == TYPE_FOLLOW || getItemViewType(position) == TYPE_FOLLOW_REQUEST) {
if (getItemViewType(position) == TYPE_FOLLOW || getItemViewType(position) == TYPE_FOLLOW_REQUEST || getItemViewType(position) == TYPE_ADMIN_REPORT || getItemViewType(position) == TYPE_ADMIN_SIGNUP) {
ViewHolderFollow holderFollow = (ViewHolderFollow) viewHolder;
MastodonHelper.loadPPMastodon(holderFollow.binding.avatar, notification.account);
holderFollow.binding.displayName.setText(
@ -157,13 +163,17 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
holderFollow.binding.username.setTextColor(theme_text_color);
holderFollow.binding.title.setTextColor(theme_text_color);
}
holderFollow.binding.rejectButton.setVisibility(View.GONE);
holderFollow.binding.acceptButton.setVisibility(View.GONE);
if (getItemViewType(position) == TYPE_FOLLOW_REQUEST) {
holderFollow.binding.rejectButton.setVisibility(View.VISIBLE);
holderFollow.binding.acceptButton.setVisibility(View.VISIBLE);
holderFollow.binding.title.setText(R.string.follow_request);
} else if (getItemViewType(position) == TYPE_ADMIN_REPORT) {
holderFollow.binding.title.setText(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_submitted_report)));
} else if (getItemViewType(position) == TYPE_ADMIN_SIGNUP) {
holderFollow.binding.title.setText(String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_signed_up)));
} else {
holderFollow.binding.rejectButton.setVisibility(View.GONE);
holderFollow.binding.acceptButton.setVisibility(View.GONE);
holderFollow.binding.title.setText(R.string.follow);
}
AccountsVM accountsVM = new ViewModelProvider((ViewModelStoreOwner) context).get(AccountsVM.class);
@ -317,6 +327,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_update));
} else if (getItemViewType(position) == TYPE_POLL) {
title = context.getString(R.string.notif_poll);
} else if (getItemViewType(position) == TYPE_POLL) {
title = context.getString(R.string.notif_poll);
}
if (notification.relatedNotifications != null && notification.relatedNotifications.size() > 0) {
if (notification.type.equals("favourite")) {

View File

@ -103,6 +103,8 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
isViewInitialized = true;
if (initialConversations != null) {
initializeConversationCommonView(initialConversations);
} else {
route(null, false);
}
}
}
@ -247,7 +249,7 @@ public class FragmentMastodonConversation extends Fragment implements Conversati
binding.recyclerView.setVisibility(View.GONE);
timelinesVM = new ViewModelProvider(FragmentMastodonConversation.this).get(TimelinesVM.class);
max_id = null;
route(null, false);
}
/**

View File

@ -176,7 +176,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
binding.recyclerView.setVisibility(View.GONE);
max_id = null;
initialNotifications = null;
route(null, false);
}
@ -213,6 +213,8 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
excludeType.add("mention");
excludeType.add("update");
excludeType.add("status");
excludeType.add("admin.sign_up");
excludeType.add("admin.report");
if (notificationType == NotificationTypeEnum.ALL) {
aggregateNotification = sharedpreferences.getBoolean(getString(R.string.SET_AGGREGATE_NOTIFICATION), true);
if (excludedCategories != null) {
@ -234,6 +236,10 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
excludeType.remove("update");
} else if (notificationType == NotificationTypeEnum.TOOTS) {
excludeType.remove("status");
} else if (notificationType == NotificationTypeEnum.ADMIN_SIGNUP) {
excludeType.remove("admin.sign_up");
} else if (notificationType == NotificationTypeEnum.ADMIN_REPORT) {
excludeType.remove("admin.report");
} else if (notificationType == NotificationTypeEnum.FOLLOWS) {
excludeType.remove("follow");
excludeType.remove("follow_request");
@ -343,7 +349,7 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
if (initialNotifications != null) {
initializeNotificationView(initialNotifications);
} else {
recreate();
route(null, false);
}
}
}
@ -684,6 +690,10 @@ public class FragmentMastodonNotification extends Fragment implements Notificati
REBLOGS("REBLOGS"),
@SerializedName("POLLS")
POLLS("POLLS"),
@SerializedName("ADMIN_SIGNUP")
ADMIN_SIGNUP("ADMIN_SIGNUP"),
@SerializedName("ADMIN_REPORT")
ADMIN_REPORT("ADMIN_REPORT"),
@SerializedName("TOOTS")
TOOTS("TOOTS"),
@SerializedName("FOLLOWS")

View File

@ -1902,4 +1902,6 @@
<string name="display_remote_profile">Display remote profile</string>
<string name="toast_fetch_error">The app cannot find remote data!</string>
<string name="delete_timeline">Delete timeline</string>
<string name="notif_submitted_report">Submitted a report</string>
<string name="notif_signed_up">Signed up</string>
</resources>