Skip to content

Commit

Permalink
Private message replies are now part of the original conversion, rath…
Browse files Browse the repository at this point in the history
…er than starting a new one (fixes #442)
  • Loading branch information
QuantumBadger committed Feb 12, 2017
1 parent 764da6d commit 5be31d6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 7 deletions.
1 change: 1 addition & 0 deletions assets/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
78/1.9.8
Private message replies are now part of the original conversion, rather than starting a new one
Support keyboard Go-action in custom location dialog (thanks to gaudecker)

77/1.9.7
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,22 @@

public class CommentReplyActivity extends BaseActivity {

private enum ParentType {
MESSAGE, COMMENT_OR_POST
}

private Spinner usernameSpinner;
private EditText textEdit;

private String parentIdAndType = null;

private ParentType mParentType;

private static String lastText, lastParentIdAndType;

public static final String PARENT_TYPE = "parentType";
public static final String PARENT_TYPE_MESSAGE = "parentTypeMessage";

public static final String PARENT_ID_AND_TYPE_KEY = "parentIdAndType";
public static final String PARENT_MARKDOWN_KEY = "parent_markdown";
private static final String COMMENT_TEXT_KEY = "comment_text";
Expand All @@ -67,7 +76,17 @@ protected void onCreate(Bundle savedInstanceState) {

final Intent intent = getIntent();

setTitle(R.string.submit_comment_actionbar);
if(intent != null
&& intent.hasExtra(PARENT_TYPE)
&& intent.getStringExtra(PARENT_TYPE).equals(PARENT_TYPE_MESSAGE)) {

mParentType = ParentType.MESSAGE;
setTitle(R.string.submit_pmreply_actionbar);

} else {
mParentType = ParentType.COMMENT_OR_POST;
setTitle(R.string.submit_comment_actionbar);
}

final LinearLayout layout = (LinearLayout) getLayoutInflater().inflate(R.layout.comment_reply, null);

Expand Down Expand Up @@ -183,7 +202,13 @@ protected void onSuccess() {
@Override
public void run() {
if(progressDialog.isShowing()) progressDialog.dismiss();
General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_done));

if(mParentType == ParentType.MESSAGE) {
General.quickToast(CommentReplyActivity.this, getString(R.string.pm_reply_done));
} else {
General.quickToast(CommentReplyActivity.this, getString(R.string.comment_reply_done));
}

lastText = null;
lastParentIdAndType = null;
finish();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
import android.view.View;
import org.apache.commons.lang3.StringEscapeUtils;
import org.quantumbadger.redreader.R;
import org.quantumbadger.redreader.activities.PMSendActivity;
import org.quantumbadger.redreader.activities.CommentReplyActivity;
import org.quantumbadger.redreader.common.BetterSSB;
import org.quantumbadger.redreader.common.LinkHandler;
import org.quantumbadger.redreader.common.RRThemeAttributes;
Expand Down Expand Up @@ -65,7 +65,7 @@ public RedditPreparedMessage(final Context context, final RedditMessage message,
appearance.recycle();
}

body = MarkdownParser.parse(StringEscapeUtils.unescapeHtml4(message.body).toCharArray());
body = MarkdownParser.parse(message.getUnescapedBodyMarkdown().toCharArray());

idAndType = message.name;

Expand All @@ -92,9 +92,11 @@ public SpannableStringBuilder getHeader() {
}

private void openReplyActivity(final AppCompatActivity activity) {
final Intent intent = new Intent(activity, PMSendActivity.class);
intent.putExtra(PMSendActivity.EXTRA_RECIPIENT, src.author);
intent.putExtra(PMSendActivity.EXTRA_SUBJECT, src.subject);

final Intent intent = new Intent(activity, CommentReplyActivity.class);
intent.putExtra(CommentReplyActivity.PARENT_ID_AND_TYPE_KEY, idAndType);
intent.putExtra(CommentReplyActivity.PARENT_MARKDOWN_KEY, src.getUnescapedBodyMarkdown());
intent.putExtra(CommentReplyActivity.PARENT_TYPE, CommentReplyActivity.PARENT_TYPE_MESSAGE);
activity.startActivity(intent);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package org.quantumbadger.redreader.reddit.things;

import org.apache.commons.lang3.StringEscapeUtils;
import org.quantumbadger.redreader.jsonwrap.JsonValue;

public class RedditMessage {
Expand All @@ -25,4 +26,8 @@ public class RedditMessage {
public boolean _json_new, was_comment;
public JsonValue first_message, replies;
public long created, created_utc;

public String getUnescapedBodyMarkdown() {
return StringEscapeUtils.unescapeHtml4(body);
}
}
4 changes: 4 additions & 0 deletions src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -952,4 +952,8 @@
<string name="error_403_title_nonreddit">Permission Denied</string>
<string name="error_403_message_nonreddit">The server responded with a permission denied error.</string>

<!-- 2017-02-12 -->
<string name="submit_pmreply_actionbar">Reply</string>
<string name="pm_reply_done">Reply sent.</string>

</resources>

0 comments on commit 5be31d6

Please sign in to comment.