Skip to content

Commit 2db34f6

Browse files
committed
Return with no action if reply text is empty
Opening comments screen when there's an empty message looks like a fail-safe. We cannot reply with an empty message either from the app or from the website as send button is disabled till we enter a text. Even in the case of voice reply from a wearable, an empty voice reply doesn't make sense. User can tap the notification itself to go straight to the comments screen in case there's ever an empty reply and so this logic to open comments activity from service on empty reply is removed.
1 parent 579372b commit 2db34f6

File tree

2 files changed

+20
-46
lines changed

2 files changed

+20
-46
lines changed

WordPress/src/main/java/org/wordpress/android/push/NativeNotificationsUtils.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package org.wordpress.android.push;
22

33
import android.content.Context;
4-
import android.content.Intent;
54

65
import androidx.core.app.NotificationCompat;
76
import androidx.core.app.NotificationManagerCompat;
@@ -64,9 +63,4 @@ public static void dismissNotification(int pushId, Context context) {
6463
notificationManager.cancel(pushId);
6564
}
6665
}
67-
68-
public static void hideStatusBar(Context context) {
69-
Intent closeIntent = new Intent(Intent.ACTION_CLOSE_SYSTEM_DIALOGS);
70-
context.sendBroadcast(closeIntent);
71-
}
7266
}

WordPress/src/main/java/org/wordpress/android/push/NotificationsProcessingService.java

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
import org.wordpress.android.fluxc.store.SiteStore;
3737
import org.wordpress.android.models.Note;
3838
import org.wordpress.android.ui.comments.unified.CommentsStoreAdapter;
39-
import org.wordpress.android.ui.main.WPMainActivity;
40-
import org.wordpress.android.ui.notifications.NotificationsListFragment;
4139
import org.wordpress.android.ui.notifications.SystemNotificationsTracker;
4240
import org.wordpress.android.ui.notifications.receivers.NotificationsPendingDraftsReceiver;
4341
import org.wordpress.android.ui.notifications.utils.NotificationsActions;
@@ -612,49 +610,31 @@ private void replyToComment() {
612610
return;
613611
}
614612

615-
if (!TextUtils.isEmpty(mReplyText)) {
616-
SiteModel site = mSiteStore.getSiteBySiteId(mNote.getSiteId());
617-
if (site == null) {
618-
AppLog.e(T.NOTIFS, "Impossible to reply to a comment on a site that is not in the App."
619-
+ " SiteId: " + mNote.getSiteId());
620-
requestFailed(ARG_ACTION_APPROVE);
621-
return;
622-
}
613+
if (TextUtils.isEmpty(mReplyText)) return;
623614

624-
// Pseudo comment (built from the note)
625-
CommentModel comment = mNote.buildComment();
615+
SiteModel site = mSiteStore.getSiteBySiteId(mNote.getSiteId());
616+
if (site == null) {
617+
AppLog.e(T.NOTIFS, "Impossible to reply to a comment on a site that is not in the App."
618+
+ " SiteId: " + mNote.getSiteId());
619+
requestFailed(ARG_ACTION_APPROVE);
620+
return;
621+
}
626622

627-
// Pseudo comment reply
628-
CommentModel reply = new CommentModel();
629-
reply.setContent(mReplyText);
623+
// Pseudo comment (built from the note)
624+
CommentModel comment = mNote.buildComment();
630625

631-
// Push the reply
632-
RemoteCreateCommentPayload payload = new RemoteCreateCommentPayload(site, comment, reply);
633-
mCommentsStoreAdapter.dispatch(CommentActionBuilder.newCreateNewCommentAction(payload));
626+
// Pseudo comment reply
627+
CommentModel reply = new CommentModel();
628+
reply.setContent(mReplyText);
634629

635-
// Bump analytics
636-
AnalyticsUtils.trackCommentReplyWithDetails(true,
637-
site, comment, AnalyticsCommentActionSource.NOTIFICATIONS);
638-
AnalyticsUtils.trackQuickActionTouched(QuickActionTrackPropertyValue.REPLY_TO, site, comment);
639-
} else {
640-
// cancel the current notification
641-
NativeNotificationsUtils.dismissNotification(mPushId, mContext);
642-
NativeNotificationsUtils.hideStatusBar(mContext);
643-
// and just trigger the Activity to allow the user to write a reply
644-
startReplyToCommentActivity();
645-
}
646-
}
630+
// Push the reply
631+
RemoteCreateCommentPayload payload = new RemoteCreateCommentPayload(site, comment, reply);
632+
mCommentsStoreAdapter.dispatch(CommentActionBuilder.newCreateNewCommentAction(payload));
647633

648-
private void startReplyToCommentActivity() {
649-
Intent intent = new Intent(mContext, WPMainActivity.class);
650-
intent.putExtra(WPMainActivity.ARG_OPENED_FROM_PUSH, true);
651-
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK
652-
| Intent.FLAG_ACTIVITY_CLEAR_TASK);
653-
intent.setAction("android.intent.action.MAIN");
654-
intent.addCategory("android.intent.category.LAUNCHER");
655-
intent.putExtra(NotificationsListFragment.NOTE_ID_EXTRA, mNoteId);
656-
intent.putExtra(NotificationsListFragment.NOTE_INSTANT_REPLY_EXTRA, true);
657-
startActivity(intent);
634+
// Bump analytics
635+
AnalyticsUtils.trackCommentReplyWithDetails(true,
636+
site, comment, AnalyticsCommentActionSource.NOTIFICATIONS);
637+
AnalyticsUtils.trackQuickActionTouched(QuickActionTrackPropertyValue.REPLY_TO, site, comment);
658638
}
659639

660640
private void resetOriginalNotification() {

0 commit comments

Comments
 (0)