@@ -135,15 +135,15 @@ private String getPostTitle(Context context, String postTitle) {
135135 private void buildSinglePendingDraftNotification (Context context , String postTitle , String formattedMessage ,
136136 int postId , boolean isPage ) {
137137 buildSinglePendingDraftNotification (context , getResultIntentForOnePost (context , postId , isPage ),
138- String .format (formattedMessage , getPostTitle (context , postTitle )), postId , isPage );
138+ String .format (formattedMessage , getPostTitle (context , postTitle )), postId , isPage );
139139 }
140140
141141 private void buildSinglePendingDraftNotificationGeneric (Context context , String postTitle , int postId ,
142142 boolean isPage ) {
143143 buildSinglePendingDraftNotification (context , getResultIntentForOnePost (context , postId , isPage ),
144- String .format (context .getString (R .string .pending_draft_one_generic ),
145- getPostTitle (context , postTitle )),
146- postId , isPage );
144+ String .format (context .getString (R .string .pending_draft_one_generic ),
145+ getPostTitle (context , postTitle )),
146+ postId , isPage );
147147 }
148148
149149 private PendingIntent getResultIntentForOnePost (Context context , int postId , boolean isPage ) {
@@ -156,10 +156,12 @@ private PendingIntent getResultIntentForOnePost(Context context, int postId, boo
156156 resultIntent .putExtra (POST_ID_EXTRA , postId );
157157 resultIntent .putExtra (IS_PAGE_EXTRA , isPage );
158158 resultIntent .putExtra (ARG_NOTIFICATION_TYPE , NotificationType .PENDING_DRAFTS );
159- PendingIntent pendingIntent = PendingIntent
160- .getActivity (context , BASE_REQUEST_CODE + PendingDraftsNotificationsUtils
161- .makePendingDraftNotificationId (postId ),
162- resultIntent , PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT );
159+ PendingIntent pendingIntent = PendingIntent .getActivity (
160+ context ,
161+ BASE_REQUEST_CODE + PendingDraftsNotificationsUtils .makePendingDraftNotificationId (postId ),
162+ resultIntent ,
163+ PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT | PendingIntent .FLAG_IMMUTABLE
164+ );
163165
164166 return pendingIntent ;
165167 }
@@ -180,8 +182,7 @@ private void buildSinglePendingDraftNotification(Context context, PendingIntent
180182 addDismissActionForNotification (context , builder , postId , isPage );
181183
182184 NativeNotificationsUtils .showMessageToUserWithBuilder (builder , message , false ,
183- PendingDraftsNotificationsUtils
184- .makePendingDraftNotificationId (postId ), context );
185+ PendingDraftsNotificationsUtils .makePendingDraftNotificationId (postId ), context );
185186 mSystemNotificationsTracker .trackShownNotification (NotificationType .PENDING_DRAFTS );
186187 }
187188
@@ -194,52 +195,52 @@ private void addOpenDraftActionForNotification(Context context, NotificationComp
194195 openDraftIntent .putExtra (IS_PAGE_EXTRA , isPage );
195196 openDraftIntent .putExtra (ARG_NOTIFICATION_TYPE , NotificationType .PENDING_DRAFTS );
196197
197- PendingIntent pendingIntent = PendingIntent
198- .getActivity (context ,
199- // need to add + 2 so the request code is different, otherwise they overlap
200- BASE_REQUEST_CODE + 1 + PendingDraftsNotificationsUtils
201- .makePendingDraftNotificationId (postId ),
202- openDraftIntent ,
203- PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT );
204- builder .addAction (R .drawable .ic_pencil_white_24dp , context .getText (R .string .edit ),
205- pendingIntent );
198+ PendingIntent pendingIntent = PendingIntent .getActivity (
199+ context ,
200+ // need to add + 1 so the request code is different, otherwise they overlap
201+ BASE_REQUEST_CODE + 1 + PendingDraftsNotificationsUtils .makePendingDraftNotificationId (postId ),
202+ openDraftIntent ,
203+ PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT | PendingIntent .FLAG_IMMUTABLE
204+ );
205+ builder .addAction (R .drawable .ic_pencil_white_24dp , context .getText (R .string .edit ), pendingIntent );
206206 }
207207
208208 private void addIgnoreActionForNotification (Context context , NotificationCompat .Builder builder , int postId ,
209209 boolean isPage ) {
210210 // Call processing service when user taps on IGNORE - we should remember this decision for this post
211211 Intent ignoreIntent = new Intent (context , NotificationsProcessingService .class );
212212 ignoreIntent .putExtra (NotificationsProcessingService .ARG_ACTION_TYPE ,
213- NotificationsProcessingService .ARG_ACTION_DRAFT_PENDING_IGNORE );
213+ NotificationsProcessingService .ARG_ACTION_DRAFT_PENDING_IGNORE );
214214 ignoreIntent .putExtra (POST_ID_EXTRA , postId );
215215 ignoreIntent .putExtra (IS_PAGE_EXTRA , isPage );
216216 ignoreIntent .putExtra (ARG_NOTIFICATION_TYPE , NotificationType .PENDING_DRAFTS );
217- PendingIntent ignorePendingIntent = PendingIntent
218- . getService ( context ,
219- // need to add + 2 so the request code is different, otherwise they overlap
220- BASE_REQUEST_CODE + 2
221- + PendingDraftsNotificationsUtils . makePendingDraftNotificationId ( postId ) ,
222- ignoreIntent , PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT );
223- builder . addAction ( R . drawable . ic_close_white_24dp , context . getText ( R . string . ignore ),
224- ignorePendingIntent );
217+ PendingIntent ignorePendingIntent = PendingIntent . getService (
218+ context ,
219+ // need to add + 2 so the request code is different, otherwise they overlap
220+ BASE_REQUEST_CODE + 2 + PendingDraftsNotificationsUtils . makePendingDraftNotificationId ( postId ),
221+ ignoreIntent ,
222+ PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_UPDATE_CURRENT | PendingIntent . FLAG_IMMUTABLE
223+ );
224+ builder . addAction ( R . drawable . ic_close_white_24dp , context . getText ( R . string . ignore ), ignorePendingIntent );
225225 }
226226
227227 private void addDismissActionForNotification (Context context , NotificationCompat .Builder builder , int postId ,
228228 boolean isPage ) {
229229 // Call processing service when notification is dismissed
230230 Intent notificationDeletedIntent = new Intent (context , NotificationsProcessingService .class );
231231 notificationDeletedIntent .putExtra (NotificationsProcessingService .ARG_ACTION_TYPE ,
232- NotificationsProcessingService .ARG_ACTION_DRAFT_PENDING_DISMISS );
232+ NotificationsProcessingService .ARG_ACTION_DRAFT_PENDING_DISMISS );
233233 notificationDeletedIntent .putExtra (POST_ID_EXTRA , postId );
234234 notificationDeletedIntent .putExtra (IS_PAGE_EXTRA , isPage );
235235 notificationDeletedIntent .putExtra (NotificationsProcessingService .ARG_NOTIFICATION_TYPE ,
236236 NotificationType .PENDING_DRAFTS );
237- PendingIntent dismissPendingIntent = PendingIntent
238- .getService (context ,
239- // need to add + 3 so the request code is different, otherwise they overlap
240- BASE_REQUEST_CODE + 3
241- + PendingDraftsNotificationsUtils .makePendingDraftNotificationId (postId ),
242- notificationDeletedIntent , PendingIntent .FLAG_CANCEL_CURRENT );
237+ PendingIntent dismissPendingIntent = PendingIntent .getService (
238+ context ,
239+ // need to add + 3 so the request code is different, otherwise they overlap
240+ BASE_REQUEST_CODE + 3 + PendingDraftsNotificationsUtils .makePendingDraftNotificationId (postId ),
241+ notificationDeletedIntent ,
242+ PendingIntent .FLAG_CANCEL_CURRENT | PendingIntent .FLAG_IMMUTABLE
243+ );
243244 builder .setDeleteIntent (dismissPendingIntent );
244245 }
245246}
0 commit comments