19
19
import android .widget .TextView ;
20
20
import android .widget .Toast ;
21
21
22
+ import androidx .recyclerview .widget .RecyclerView ;
23
+
22
24
import org .joinmastodon .android .GlobalUserPreferences ;
23
25
import org .joinmastodon .android .R ;
24
26
import org .joinmastodon .android .api .requests .accounts .GetAccountRelationships ;
25
27
import org .joinmastodon .android .api .requests .statuses .GetStatusSourceText ;
26
28
import org .joinmastodon .android .api .session .AccountSessionManager ;
27
29
import org .joinmastodon .android .fragments .BaseStatusListFragment ;
28
30
import org .joinmastodon .android .fragments .ComposeFragment ;
31
+ import org .joinmastodon .android .fragments .NotificationsListFragment ;
29
32
import org .joinmastodon .android .fragments .ProfileFragment ;
30
33
import org .joinmastodon .android .fragments .ThreadFragment ;
31
34
import org .joinmastodon .android .fragments .report .ReportReasonChoiceFragment ;
32
35
import org .joinmastodon .android .model .Account ;
33
36
import org .joinmastodon .android .model .Attachment ;
37
+ import org .joinmastodon .android .model .Notification ;
34
38
import org .joinmastodon .android .model .Relationship ;
35
39
import org .joinmastodon .android .model .Status ;
36
40
import org .joinmastodon .android .ui .text .HtmlParser ;
@@ -62,15 +66,17 @@ public class HeaderStatusDisplayItem extends StatusDisplayItem{
62
66
private boolean hasVisibilityToggle ;
63
67
boolean needBottomPadding ;
64
68
private String extraText ;
69
+ private Notification notification ;
65
70
66
- public HeaderStatusDisplayItem (String parentID , Account user , Instant createdAt , BaseStatusListFragment parentFragment , String accountID , Status status , String extraText ){
71
+ public HeaderStatusDisplayItem (String parentID , Account user , Instant createdAt , BaseStatusListFragment parentFragment , String accountID , Status status , String extraText , Notification notification ){
67
72
super (parentID , parentFragment );
68
73
this .user =user ;
69
74
this .createdAt =createdAt ;
70
75
avaRequest =new UrlImageLoaderRequest (GlobalUserPreferences .playGifs ? user .avatar : user .avatarStatic , V .dp (50 ), V .dp (50 ));
71
76
this .accountID =accountID ;
72
77
parsedName =new SpannableStringBuilder (user .displayName );
73
78
this .status =status ;
79
+ this .notification =notification ;
74
80
HtmlParser .parseCustomEmoji (parsedName , user .emojis );
75
81
emojiHelper .setText (parsedName );
76
82
if (status !=null ){
@@ -107,7 +113,7 @@ public ImageLoaderRequest getImageRequest(int index){
107
113
108
114
public static class Holder extends StatusDisplayItem .Holder <HeaderStatusDisplayItem > implements ImageLoaderViewHolder {
109
115
private final TextView name , username , timestamp , extraText ;
110
- private final ImageView avatar , more , visibility ;
116
+ private final ImageView avatar , more , visibility , deleteNotification ;
111
117
private final PopupMenu optionsMenu ;
112
118
private Relationship relationship ;
113
119
private APIRequest <?> currentRelationshipRequest ;
@@ -127,12 +133,18 @@ public Holder(Activity activity, ViewGroup parent){
127
133
avatar =findViewById (R .id .avatar );
128
134
more =findViewById (R .id .more );
129
135
visibility =findViewById (R .id .visibility );
136
+ deleteNotification =findViewById (R .id .delete_notification );
130
137
extraText =findViewById (R .id .extra_text );
131
138
avatar .setOnClickListener (this ::onAvaClick );
132
139
avatar .setOutlineProvider (roundCornersOutline );
133
140
avatar .setClipToOutline (true );
134
141
more .setOnClickListener (this ::onMoreClick );
135
142
visibility .setOnClickListener (v ->item .parentFragment .onVisibilityIconClick (this ));
143
+ deleteNotification .setOnClickListener (v ->UiUtils .confirmDeleteNotification (activity , item .parentFragment .getAccountID (), item .notification , ()->{
144
+ if (item .parentFragment instanceof NotificationsListFragment fragment ) {
145
+ fragment .removeNotification (item .notification );
146
+ }
147
+ }));
136
148
137
149
optionsMenu =new PopupMenu (activity , more );
138
150
optionsMenu .inflate (R .menu .post );
@@ -226,6 +238,7 @@ public void onBind(HeaderStatusDisplayItem item){
226
238
else
227
239
timestamp .setText (item .parentFragment .getString (R .string .edited_timestamp , UiUtils .formatRelativeTimestamp (itemView .getContext (), item .status .editedAt )));
228
240
visibility .setVisibility (item .hasVisibilityToggle && !item .inset ? View .VISIBLE : View .GONE );
241
+ deleteNotification .setVisibility (GlobalUserPreferences .enableDeleteNotifications && item .notification !=null ? View .VISIBLE : View .GONE );
229
242
if (item .hasVisibilityToggle ){
230
243
visibility .setImageResource (item .status .spoilerRevealed ? R .drawable .ic_visibility_off : R .drawable .ic_visibility );
231
244
visibility .setContentDescription (item .parentFragment .getString (item .status .spoilerRevealed ? R .string .hide_content : R .string .reveal_content ));
0 commit comments