Deskana has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/172454

Change subject: Show confirmation dialogue when users click on links in preview.
......................................................................

Show confirmation dialogue when users click on links in preview.

Currently, if you tap on a link during preview, you leave your edit and go to
the page you clicked on. The mental model here is actually a bit unclear. In
any case, leaving your edit when you tap on a link is quite jarring, and the
fact that there's no warning before leaving makes it worse.

In absence of more tightly refining the mental model, this patch simply throws
up a confirmation dialogue when a user taps on a wikilink during preview, and
asks them whether they really want to leave the edit workflow or not.

Change-Id: I4e651ad7a548db17702a6165b44b6caf56c93d4e
---
M wikipedia/res/values-qq/strings.xml
M wikipedia/res/values/strings.xml
M wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
3 files changed, 28 insertions(+), 6 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/apps/android/wikipedia 
refs/changes/54/172454/1

diff --git a/wikipedia/res/values-qq/strings.xml 
b/wikipedia/res/values-qq/strings.xml
index ce62738..1a5b56b 100644
--- a/wikipedia/res/values-qq/strings.xml
+++ b/wikipedia/res/values-qq/strings.xml
@@ -114,6 +114,9 @@
 {{Identical|Retry}}</string>
   <string name="dialog_message_edit_failed_cancel">Button text to cancel 
retrying a failed edit save.
 {{Identical|Cancel}}</string>
+  <string name="dialog_message_leaving_edit">Message for dialog box shown to 
users when they click on a link in an edit preview, informing them that if they 
leave the edit then they may lose their changes.</string>
+  <string name="dialog_message_leaving_edit_leave">Button text for choosing to 
leave the edit workflow when the user clicks on a link in preview.</string>
+  <string name="dialog_message_leaving_edit_stay">Button text for choosing to 
stay inside edit workflow when the user clicks on a link in preview.</string>
   <string name="menu_show_toc">Menu item text for showing the Table of 
Contents for the current article.
 {{Identical|Table of contents}}</string>
   <string name="search_no_results_found">Message shown to user when no search 
results are found for a string</string>
diff --git a/wikipedia/res/values/strings.xml b/wikipedia/res/values/strings.xml
index f5d84cf..4fb1e84 100644
--- a/wikipedia/res/values/strings.xml
+++ b/wikipedia/res/values/strings.xml
@@ -82,6 +82,9 @@
     <string name="dialog_message_edit_failed">Edit failed!</string>
     <string name="dialog_message_edit_failed_retry">Retry</string>
     <string name="dialog_message_edit_failed_cancel">Cancel</string>
+    <string name="dialog_message_leaving_edit">"Leaving this page may cause 
you to lose any changes you have made. Are you sure you want to leave this 
page?"</string>
+    <string name="dialog_message_leaving_edit_leave">Leave</string>
+    <string name="dialog_message_leaving_edit_stay">Stay</string>
     <string name="menu_show_toc">Table of Contents</string>
     <string name="search_no_results_found">No results found</string>
     <string name="edit_section_captcha_message">To help protect against 
automated spam, please enter the words that appear below</string>
diff --git 
a/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java 
b/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
index c7e74bd..38e42f9 100644
--- a/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
+++ b/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
@@ -186,12 +186,28 @@
                 }
 
                 @Override
-                public void onInternalLinkClicked(PageTitle title) {
-                    Intent intent = new Intent(getActivity(), 
PageActivity.class);
-                    intent.setAction(PageActivity.ACTION_PAGE_FOR_TITLE);
-                    intent.putExtra(PageActivity.EXTRA_PAGETITLE, title);
-                    intent.putExtra(PageActivity.EXTRA_HISTORYENTRY, new 
HistoryEntry(title, HistoryEntry.SOURCE_INTERNAL_LINK));
-                    startActivity(intent);
+                public void onInternalLinkClicked(final PageTitle title) {
+                    //Ask the user if they really meant to leave the edit 
workflow
+                    final AlertDialog leavingEditDialog = new 
AlertDialog.Builder(getActivity())
+                            .setMessage(R.string.dialog_message_leaving_edit)
+                            
.setPositiveButton(R.string.dialog_message_leaving_edit_leave, new 
DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, 
int which) {
+                                    dialog.dismiss();
+                                    Intent intent = new Intent(getActivity(), 
PageActivity.class);
+                                    
intent.setAction(PageActivity.ACTION_PAGE_FOR_TITLE);
+                                    
intent.putExtra(PageActivity.EXTRA_PAGETITLE, title);
+                                    
intent.putExtra(PageActivity.EXTRA_HISTORYENTRY, new HistoryEntry(title, 
HistoryEntry.SOURCE_INTERNAL_LINK));
+                                    startActivity(intent);
+                                }
+                            })
+                            
.setNegativeButton(R.string.dialog_message_leaving_edit_stay, new 
DialogInterface.OnClickListener() {
+                                @Override
+                                public void onClick(DialogInterface dialog, 
int which) {
+                                    dialog.dismiss();
+                                }
+                            }).create();
+                    leavingEditDialog.show();
                 }
 
                 @Override

-- 
To view, visit https://gerrit.wikimedia.org/r/172454
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4e651ad7a548db17702a6165b44b6caf56c93d4e
Gerrit-PatchSet: 1
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Deskana <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to