mirror of
https://codeberg.org/tom79/Fedilab.git
synced 2024-12-23 17:20:04 +02:00
Fix issue #234 - Reactions in notifications for Pleroma
This commit is contained in:
parent
f5bf2ad0b0
commit
cf1a1b3e53
3 changed files with 24 additions and 1 deletions
|
@ -29,6 +29,8 @@ public class Notification {
|
||||||
public String type;
|
public String type;
|
||||||
@SerializedName("created_at")
|
@SerializedName("created_at")
|
||||||
public Date created_at;
|
public Date created_at;
|
||||||
|
@SerializedName("emoji")
|
||||||
|
public String emoji;
|
||||||
@SerializedName("account")
|
@SerializedName("account")
|
||||||
public Account account;
|
public Account account;
|
||||||
@SerializedName("status")
|
@SerializedName("status")
|
||||||
|
|
|
@ -60,6 +60,7 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
private final int TYPE_POLL = 5;
|
private final int TYPE_POLL = 5;
|
||||||
private final int TYPE_STATUS = 6;
|
private final int TYPE_STATUS = 6;
|
||||||
private final int NOTIFICATION_FETCH_MORE = 7;
|
private final int NOTIFICATION_FETCH_MORE = 7;
|
||||||
|
private final int TYPE_REACTION = 8;
|
||||||
public FetchMoreCallBack fetchMoreCallBack;
|
public FetchMoreCallBack fetchMoreCallBack;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
|
@ -96,6 +97,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
return TYPE_POLL;
|
return TYPE_POLL;
|
||||||
case "status":
|
case "status":
|
||||||
return TYPE_STATUS;
|
return TYPE_STATUS;
|
||||||
|
case "pleroma:emoji_reaction":
|
||||||
|
return TYPE_REACTION;
|
||||||
}
|
}
|
||||||
return super.getItemViewType(position);
|
return super.getItemViewType(position);
|
||||||
}
|
}
|
||||||
|
@ -197,6 +200,8 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_star_24);
|
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_star_24);
|
||||||
} else if (getItemViewType(position) == TYPE_REBLOG) {
|
} else if (getItemViewType(position) == TYPE_REBLOG) {
|
||||||
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_repeat_24);
|
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_repeat_24);
|
||||||
|
} else if (getItemViewType(position) == TYPE_REACTION) {
|
||||||
|
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_insert_emoticon_24);
|
||||||
} else if (getItemViewType(position) == TYPE_POLL) {
|
} else if (getItemViewType(position) == TYPE_POLL) {
|
||||||
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_poll_24);
|
holderStatus.bindingNotification.status.typeOfNotification.setImageResource(R.drawable.ic_baseline_poll_24);
|
||||||
}
|
}
|
||||||
|
@ -205,13 +210,19 @@ public class NotificationAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
|
||||||
statusManagement(context, statusesVM, searchVM, holderStatus, this, null, notificationList, notification.status, Timeline.TimeLineEnum.NOTIFICATION, false, true);
|
statusManagement(context, statusesVM, searchVM, holderStatus, this, null, notificationList, notification.status, Timeline.TimeLineEnum.NOTIFICATION, false, true);
|
||||||
holderStatus.bindingNotification.status.dateShort.setText(Helper.dateDiff(context, notification.created_at));
|
holderStatus.bindingNotification.status.dateShort.setText(Helper.dateDiff(context, notification.created_at));
|
||||||
holderStatus.bindingNotification.containerTransparent.setAlpha(.3f);
|
holderStatus.bindingNotification.containerTransparent.setAlpha(.3f);
|
||||||
if (getItemViewType(position) == TYPE_MENTION || getItemViewType(position) == TYPE_STATUS) {
|
if (getItemViewType(position) == TYPE_MENTION || getItemViewType(position) == TYPE_STATUS || getItemViewType(position) == TYPE_REACTION) {
|
||||||
holderStatus.bindingNotification.status.actionButtons.setVisibility(View.VISIBLE);
|
holderStatus.bindingNotification.status.actionButtons.setVisibility(View.VISIBLE);
|
||||||
String title = "";
|
String title = "";
|
||||||
if (getItemViewType(position) == TYPE_MENTION) {
|
if (getItemViewType(position) == TYPE_MENTION) {
|
||||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_mention));
|
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_mention));
|
||||||
} else if (getItemViewType(position) == TYPE_STATUS) {
|
} else if (getItemViewType(position) == TYPE_STATUS) {
|
||||||
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_status));
|
title = String.format(Locale.getDefault(), "%s %s", notification.account.display_name, context.getString(R.string.notif_status));
|
||||||
|
} else if (getItemViewType(position) == TYPE_REACTION) {
|
||||||
|
if (notification.emoji == null) {
|
||||||
|
notification.emoji = "";
|
||||||
|
}
|
||||||
|
title = String.format(Locale.getDefault(), "%s reacted with %s", notification.account.username, notification.emoji);
|
||||||
|
MastodonHelper.loadPPMastodon(holderStatus.bindingNotification.status.avatar, notification.account);
|
||||||
}
|
}
|
||||||
notification.account.display_name = title;
|
notification.account.display_name = title;
|
||||||
holderStatus.bindingNotification.status.displayName.setText(
|
holderStatus.bindingNotification.status.displayName.setText(
|
||||||
|
|
10
app/src/main/res/drawable/ic_baseline_insert_emoticon_24.xml
Normal file
10
app/src/main/res/drawable/ic_baseline_insert_emoticon_24.xml
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
<vector xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:width="24dp"
|
||||||
|
android:height="24dp"
|
||||||
|
android:tint="#FFFFFF"
|
||||||
|
android:viewportWidth="24"
|
||||||
|
android:viewportHeight="24">
|
||||||
|
<path
|
||||||
|
android:fillColor="@android:color/white"
|
||||||
|
android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8zM15.5,11c0.83,0 1.5,-0.67 1.5,-1.5S16.33,8 15.5,8 14,8.67 14,9.5s0.67,1.5 1.5,1.5zM8.5,11c0.83,0 1.5,-0.67 1.5,-1.5S9.33,8 8.5,8 7,8.67 7,9.5 7.67,11 8.5,11zM12,17.5c2.33,0 4.31,-1.46 5.11,-3.5L6.89,14c0.8,2.04 2.78,3.5 5.11,3.5z" />
|
||||||
|
</vector>
|
Loading…
Reference in a new issue