Dbrant has submitted this change and it was merged.
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, 67 insertions(+), 6 deletions(-)
Approvals:
Dbrant: Looks good to me, approved
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..c14912a 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">"Your changes have not been
saved yet. 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..abf1768 100644
--- a/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
+++ b/wikipedia/src/main/java/org/wikipedia/editing/EditPreviewFragment.java
@@ -186,12 +186,67 @@
}
@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 onUrlClick(final String href) {
+ // Check if this is an internal link, and if it is then
open it internally
+ if (href.startsWith("/wiki/")) {
+ PageTitle title = getSite().titleForInternalLink(href);
+ onInternalLinkClicked(title);
+ } else {
+ //Show dialogue asking user to confirm they want to
leave
+ showLeavingEditDialogue(new Runnable() {
+ @Override
+ public void run() {
+ openExternalLink(href);
+ }
+ });
+ }
+ }
+
+ @Override
+ public void onInternalLinkClicked(final PageTitle title) {
+ //Show dialogue asking user to confirm they want to leave
+ showLeavingEditDialogue(new Runnable() {
+ @Override
+ public void run() {
+ 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);
+ }
+ });
+ }
+
+ /**
+ * Shows the user a dialogue asking them if they really meant
to leave the edit
+ * workflow, and warning them that their changes have not yet
been saved.
+ * @param runnable The runnable that is run if the user
chooses to leave.
+ */
+ private void showLeavingEditDialogue(final Runnable runnable) {
+ //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) {
+ //They meant to leave; close dialogue and
run specified action
+ dialog.dismiss();
+ runnable.run();
+ }
+ })
+
.setNegativeButton(R.string.dialog_message_leaving_edit_stay, null)
+ .create();
+ leavingEditDialog.show();
+ }
+
+ /**
+ * Open an external link. The method uses the onUrlClick
method in the superclass of
+ * of LinkHandler to do the heavy lifting. You can't call this
method from inside a
+ * Runnable or an AlertDialog, so we put it in here instead.
+ * @param href The href of the external link to be opened.
+ */
+ private void openExternalLink(String href) {
+ super.onUrlClick(href);
}
@Override
--
To view, visit https://gerrit.wikimedia.org/r/172454
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4e651ad7a548db17702a6165b44b6caf56c93d4e
Gerrit-PatchSet: 4
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Deskana <[email protected]>
Gerrit-Reviewer: BearND <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Deskana <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits