Skip to content

Commit 229f5e4

Browse files
committed
Fixes #456. Props aagam94
1 parent a0bfab2 commit 229f5e4

File tree

2 files changed

+42
-11
lines changed

2 files changed

+42
-11
lines changed

res/values/strings.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,8 @@
220220
<string name="delete">Delete</string>
221221
<string name="approve">Approve</string>
222222
<string name="unapprove">Unapprove</string>
223+
<string name="confirm_delete">Confirm Deletion</string>
224+
<string name="confirm_delete_data">Are you sure you want to delete this comment?</string>
223225

224226
<!-- new account view -->
225227
<string name="account_setup">Account Setup</string>

src/org/wordpress/android/ui/comments/CommentsActivity.java

Lines changed: 40 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -213,19 +213,48 @@ public void run() {
213213
}
214214
}.start();
215215
} else if (status.equals("delete")) {
216-
showDialog(ID_DIALOG_DELETING);
217-
// pop out of the detail view if on a smaller screen
218-
FragmentManager fm = getSupportFragmentManager();
219-
CommentFragment f = (CommentFragment) fm
220-
.findFragmentById(R.id.commentDetail);
221-
if (f == null) {
222-
fm.popBackStack();
223-
}
224-
new Thread() {
216+
Thread action3 = new Thread() {
225217
public void run() {
226-
deleteComment(commentID);
218+
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(
219+
CommentsActivity.this);
220+
dialogBuilder.setTitle(getResources().getText(
221+
R.string.confirm_delete));
222+
dialogBuilder.setMessage(getResources().getText(R.string.confirm_delete_data));
223+
dialogBuilder.setPositiveButton("Yes",
224+
new DialogInterface.OnClickListener() {
225+
public void onClick(DialogInterface dialog,
226+
int whichButton) {
227+
showDialog(ID_DIALOG_DELETING);
228+
// pop out of the detail view if on a smaller screen
229+
FragmentManager fm = getSupportFragmentManager();
230+
CommentFragment f = (CommentFragment) fm
231+
.findFragmentById(R.id.commentDetail);
232+
if (f == null) {
233+
fm.popBackStack();
234+
}
235+
new Thread() {
236+
public void run() {
237+
deleteComment(commentID);
238+
}
239+
}.start();
240+
241+
242+
}
243+
});
244+
dialogBuilder.setNegativeButton("No",
245+
new DialogInterface.OnClickListener() {
246+
public void onClick(DialogInterface dialog,
247+
int whichButton) {
248+
//Don't delete Comment
249+
}
250+
});
251+
dialogBuilder.setCancelable(true);
252+
if (!isFinishing()) {
253+
dialogBuilder.create().show();
254+
}
227255
}
228-
}.start();
256+
};
257+
runOnUiThread(action3);
229258
} else if (status.equals("reply")) {
230259

231260
Intent i = new Intent(CommentsActivity.this, AddCommentActivity.class);

0 commit comments

Comments
 (0)