diff options
author | Nawab <nawab.hussaen@gmail.com> | 2016-09-12 01:12:28 +0530 |
---|---|---|
committer | Nawab <nawab.hussaen@gmail.com> | 2016-09-12 01:12:28 +0530 |
commit | 81722ab8bbee9bcf6bce2a3ffaef489829864929 (patch) | |
tree | a9b15fb9fb6418c6d7cdc1bb999ac667b1a87021 /WordPress/src/main/java | |
parent | d915cc4164fa9bd2e10aa844b39d86d598fe900b (diff) | |
download | gradle-perf-android-medium-81722ab8bbee9bcf6bce2a3ffaef489829864929.tar.gz |
Fixed issue #4327 : Apostrophe displayed incorrectly when replying from a notification
Diffstat (limited to 'WordPress/src/main/java')
-rw-r--r-- | WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java | 84 |
1 files changed, 38 insertions, 46 deletions
diff --git a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java index 15ffa897d..86a70e37d 100644 --- a/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java +++ b/WordPress/src/main/java/org/wordpress/android/ui/comments/CommentDetailFragment.java @@ -28,6 +28,7 @@ import com.android.volley.VolleyError; import com.simperium.client.BucketObjectMissingException; import com.wordpress.rest.RestRequest; +import org.apache.commons.lang.StringEscapeUtils; import org.json.JSONObject; import org.wordpress.android.Constants; import org.wordpress.android.R; @@ -76,7 +77,6 @@ import org.wordpress.android.widgets.WPNetworkImageView; import java.util.EnumSet; import java.util.List; -import java.util.Locale; import de.greenrobot.event.EventBus; @@ -85,58 +85,44 @@ import de.greenrobot.event.EventBus; * prior to this there were separate comment detail screens for each list */ public class CommentDetailFragment extends Fragment implements NotificationFragment { + private static final String KEY_LOCAL_BLOG_ID = "local_blog_id"; + private static final String KEY_COMMENT_ID = "comment_id"; + private static final String KEY_NOTE_ID = "note_id"; private int mLocalBlogId; private int mRemoteBlogId; - private Comment mComment; private Note mNote; - private SuggestionAdapter mSuggestionAdapter; private SuggestionServiceConnectionManager mSuggestionServiceConnectionManager; - private TextView mTxtStatus; private TextView mTxtContent; private View mSubmitReplyBtn; private SuggestionAutoCompleteText mEditReply; private ViewGroup mLayoutReply; private ViewGroup mLayoutButtons; - private View mBtnLikeComment; private ImageView mBtnLikeIcon; private TextView mBtnLikeTextView; - private View mBtnModerateComment; private ImageView mBtnModerateIcon; private TextView mBtnModerateTextView; - private TextView mBtnSpamComment; private TextView mBtnTrashComment; - private String mRestoredReplyText; private String mRestoredNoteId; - private boolean mIsUsersBlog = false; private boolean mShouldFocusReplyField; - /* * Used to request a comment from a note using its site and comment ids, rather than build * the comment with the content in the note. See showComment() */ private boolean mShouldRequestCommentFromNote = false; - private boolean mIsSubmittingReply = false; - private NotificationsDetailListFragment mNotificationsDetailListFragment; - private OnCommentChangeListener mOnCommentChangeListener; private OnPostClickListener mOnPostClickListener; private OnCommentActionListener mOnCommentActionListener; private OnNoteCommentActionListener mOnNoteCommentActionListener; - - private static final String KEY_LOCAL_BLOG_ID = "local_blog_id"; - private static final String KEY_COMMENT_ID = "comment_id"; - private static final String KEY_NOTE_ID = "note_id"; - /* * these determine which actions (moderation, replying, marking as spam) to enable * for this comment - all actions are enabled when opened from the comment list, only @@ -219,11 +205,11 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm mLayoutButtons = (ViewGroup) inflater.inflate(R.layout.comment_action_footer, null, false); mBtnLikeComment = mLayoutButtons.findViewById(R.id.btn_like); - mBtnLikeIcon = (ImageView)mLayoutButtons.findViewById(R.id.btn_like_icon); - mBtnLikeTextView = (TextView)mLayoutButtons.findViewById(R.id.btn_like_text); + mBtnLikeIcon = (ImageView) mLayoutButtons.findViewById(R.id.btn_like_icon); + mBtnLikeTextView = (TextView) mLayoutButtons.findViewById(R.id.btn_like_text); mBtnModerateComment = mLayoutButtons.findViewById(R.id.btn_moderate); - mBtnModerateIcon = (ImageView)mLayoutButtons.findViewById(R.id.btn_moderate_icon); - mBtnModerateTextView = (TextView)mLayoutButtons.findViewById(R.id.btn_moderate_text); + mBtnModerateIcon = (ImageView) mLayoutButtons.findViewById(R.id.btn_moderate_icon); + mBtnModerateTextView = (TextView) mLayoutButtons.findViewById(R.id.btn_moderate_text); mBtnSpamComment = (TextView) mLayoutButtons.findViewById(R.id.text_btn_spam); mBtnTrashComment = (TextView) mLayoutButtons.findViewById(R.id.image_trash_comment); @@ -503,6 +489,10 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm return mRemoteBlogId; } + private void setRemoteBlogId(int remoteBlogId) { + mRemoteBlogId = remoteBlogId; + } + /* * reload the current comment from the local database */ @@ -702,25 +692,25 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm if (!postExists) { AppLog.d(T.COMMENTS, "comment detail > retrieving post"); ReaderPostActions.requestPost(blogId, postId, new ReaderActions.OnRequestListener() { - @Override - public void onSuccess() { - if (!isAdded()) return; - - // update title if it wasn't set above - if (!hasTitle) { - String postTitle = ReaderPostTable.getPostTitle(blogId, postId); - if (!TextUtils.isEmpty(postTitle)) { - setPostTitle(txtPostTitle, postTitle, true); - } else { - txtPostTitle.setText(R.string.untitled); - } - } - } + @Override + public void onSuccess() { + if (!isAdded()) return; - @Override - public void onFailure(int statusCode) { + // update title if it wasn't set above + if (!hasTitle) { + String postTitle = ReaderPostTable.getPostTitle(blogId, postId); + if (!TextUtils.isEmpty(postTitle)) { + setPostTitle(txtPostTitle, postTitle, true); + } else { + txtPostTitle.setText(R.string.untitled); } - }); + } + } + + @Override + public void onFailure(int statusCode) { + } + }); } txtPostTitle.setOnClickListener(new View.OnClickListener() { @@ -838,7 +828,8 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm } } else { String errorMessage = TextUtils.isEmpty(result.getMessage()) ? getString(R.string.reply_failed) : result.getMessage(); - ToastUtils.showToast(getActivity(), errorMessage, ToastUtils.Duration.LONG); + String strUnEscapeHTML = StringEscapeUtils.unescapeHtml(errorMessage); + ToastUtils.showToast(getActivity(), strUnEscapeHTML, ToastUtils.Duration.LONG); // refocus editor on failure and show soft keyboard EditTextUtils.showSoftInput(mEditReply); } @@ -991,18 +982,23 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm private boolean canModerate() { return mEnabledActions != null && (mEnabledActions.contains(EnabledActions.ACTION_APPROVE) || mEnabledActions.contains(EnabledActions.ACTION_UNAPPROVE)); } + private boolean canMarkAsSpam() { return (mEnabledActions != null && mEnabledActions.contains(EnabledActions.ACTION_SPAM)); } + private boolean canReply() { return (mEnabledActions != null && mEnabledActions.contains(EnabledActions.ACTION_REPLY)); } + private boolean canTrash() { return canModerate(); } + private boolean canEdit() { return (mLocalBlogId > 0 && canModerate()); } + private boolean canLike() { return (!mShouldRequestCommentFromNote && mEnabledActions != null && mEnabledActions.contains(EnabledActions.ACTION_LIKE)); } @@ -1071,7 +1067,7 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm ReaderAnim.animateLikeButton(mBtnLikeIcon, mBtnLikeComment.isActivated()); // Bump analytics - AnalyticsTracker.track(mBtnLikeComment.isActivated() ? Stat.NOTIFICATION_LIKED : Stat.NOTIFICATION_UNLIKED); + AnalyticsTracker.track(mBtnLikeComment.isActivated() ? Stat.NOTIFICATION_LIKED : Stat.NOTIFICATION_UNLIKED); boolean commentWasUnapproved = false; if (mNotificationsDetailListFragment != null && mComment != null) { @@ -1092,7 +1088,7 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm new RestRequest.Listener() { @Override public void onResponse(JSONObject response) { - if (response != null && !response.optBoolean("success")) { + if (response != null && !response.optBoolean("success")) { if (!isAdded()) return; // Failed, so switch the button state back @@ -1187,8 +1183,4 @@ public class CommentDetailFragment extends Fragment implements NotificationFragm final String path = String.format("/sites/%s/comments/%s", remoteBlogId, commentId); WordPress.getRestClientUtils().get(path, restListener, restErrListener); } - - private void setRemoteBlogId(int remoteBlogId) { - mRemoteBlogId = remoteBlogId; - } } |