jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/333685 )
Change subject: Make revert notification lead to the original page, with help
dialog.
......................................................................
Make revert notification lead to the original page, with help dialog.
When the user receives a revert notification, they'll now be able to click
the notification to go back to that page in the app, and see a brief
explanation dialog with a few reasons why the edit might be reverted.
Bug: T154787
Change-Id: I4c6a78f27f0a6ef5e7bfebc991958f3425cfc792
---
M app/src/main/java/org/wikipedia/Constants.java
A
app/src/main/java/org/wikipedia/descriptions/DescriptionEditRevertHelpView.java
M app/src/main/java/org/wikipedia/notifications/NotificationPresenter.java
M app/src/main/java/org/wikipedia/page/PageActivity.java
A app/src/main/res/layout/view_description_edit_revert_help.xml
M app/src/main/res/values/strings_no_translate.xml
6 files changed, 101 insertions(+), 7 deletions(-)
Approvals:
Niedzielski: Looks good to me, approved
jenkins-bot: Verified
diff --git a/app/src/main/java/org/wikipedia/Constants.java
b/app/src/main/java/org/wikipedia/Constants.java
index 48ed05a..ed43907 100644
--- a/app/src/main/java/org/wikipedia/Constants.java
+++ b/app/src/main/java/org/wikipedia/Constants.java
@@ -24,6 +24,8 @@
public static final String INTENT_SEARCH_FROM_WIDGET = "searchFromWidget";
public static final String INTENT_FEATURED_ARTICLE_FROM_WIDGET =
"featuredArticleFromWidget";
+ public static final String INTENT_EXTRA_REVERT_QNUMBER = "revertQNumber";
+
public static final int PROGRESS_BAR_MAX_VALUE = 10_000;
public static final int MAX_SUGGESTION_RESULTS = 3;
diff --git
a/app/src/main/java/org/wikipedia/descriptions/DescriptionEditRevertHelpView.java
b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditRevertHelpView.java
new file mode 100644
index 0000000..f8ab5a2
--- /dev/null
+++
b/app/src/main/java/org/wikipedia/descriptions/DescriptionEditRevertHelpView.java
@@ -0,0 +1,44 @@
+package org.wikipedia.descriptions;
+
+import android.content.Context;
+import android.net.Uri;
+import android.support.annotation.NonNull;
+import android.text.method.LinkMovementMethod;
+import android.widget.ScrollView;
+import android.widget.TextView;
+
+import org.wikipedia.R;
+import org.wikipedia.WikipediaApp;
+import org.wikipedia.util.StringUtil;
+
+import butterknife.BindView;
+import butterknife.ButterKnife;
+
+public class DescriptionEditRevertHelpView extends ScrollView {
+ @BindView(R.id.view_description_edit_revert_help_contents) TextView
helpText;
+
+ public DescriptionEditRevertHelpView(@NonNull Context context, @NonNull
String qNumber) {
+ super(context);
+ init(qNumber);
+ }
+
+ private void init(@NonNull String qNumber) {
+ inflate(getContext(), R.layout.view_description_edit_revert_help,
this);
+ ButterKnife.bind(this);
+ helpText.setMovementMethod(new LinkMovementMethod());
+
+
helpText.setText(StringUtil.fromHtml(String.format(getContext().getString(R.string.description_edit_revert_help_body),
+
getContext().getString(R.string.wikidata_description_guide_url),
+ getHistoryUri(qNumber))));
+ }
+
+ private Uri getHistoryUri(@NonNull String qNumber) {
+ return new Uri.Builder()
+ .scheme(WikipediaApp.getInstance().getWikiSite().scheme())
+ .authority("m.wikidata.org")
+ .appendPath("wiki")
+ .appendPath("Special:History")
+ .appendPath(qNumber)
+ .build();
+ }
+}
\ No newline at end of file
diff --git
a/app/src/main/java/org/wikipedia/notifications/NotificationPresenter.java
b/app/src/main/java/org/wikipedia/notifications/NotificationPresenter.java
index d55f481..e621079 100644
--- a/app/src/main/java/org/wikipedia/notifications/NotificationPresenter.java
+++ b/app/src/main/java/org/wikipedia/notifications/NotificationPresenter.java
@@ -13,8 +13,10 @@
import android.support.v4.app.NotificationCompat;
import android.support.v4.content.ContextCompat;
+import org.wikipedia.Constants;
import org.wikipedia.R;
import org.wikipedia.WikipediaApp;
+import org.wikipedia.page.PageActivity;
import org.wikipedia.util.ShareUtil;
public final class NotificationPresenter {
@@ -28,14 +30,10 @@
@DrawableRes int icon = R.mipmap.launcher;
@ColorInt int color = ContextCompat.getColor(context,
R.color.foundation_gray);
- Uri pageUri = uriForPath(n, n.isFromWikidata() &&
n.title().isMainNamespace()
- ? n.title().text() : n.title().full());
Uri historyUri = uriForPath(n, "Special:History/" + n.title().full());
Uri agentUri = uriForPath(n, "User:" + n.agent().name());
- PendingIntent pageIntent = PendingIntent.getActivity(context,
REQUEST_CODE_PAGE,
- ShareUtil.createChooserIntent(new Intent(Intent.ACTION_VIEW,
pageUri), null,
- context), PendingIntent.FLAG_UPDATE_CURRENT);
+ Intent pageIntent = PageActivity.newIntent(context, n.title().full());
PendingIntent historyIntent = PendingIntent.getActivity(context,
REQUEST_CODE_HISTORY,
ShareUtil.createChooserIntent(new Intent(Intent.ACTION_VIEW,
historyUri), null,
@@ -46,7 +44,6 @@
context), PendingIntent.FLAG_UPDATE_CURRENT);
NotificationCompat.Builder builder = new
NotificationCompat.Builder(context)
- .setContentIntent(pageIntent)
.setAutoCancel(true);
switch (n.type()) {
@@ -58,6 +55,7 @@
builder.addAction(0,
context.getString(R.string.notification_button_view_user), agentIntent);
break;
case Notification.TYPE_REVERTED:
+ pageIntent.putExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER,
n.title().text());
description =
context.getString(R.string.notification_reverted, n.agent().name(),
n.title().full());
icon = R.drawable.ic_rotate_left_white_24dp;
title = R.string.notification_reverted_title;
@@ -75,7 +73,8 @@
break;
}
- builder.setStyle(new
NotificationCompat.BigTextStyle().bigText(description))
+ builder.setContentIntent(PendingIntent.getActivity(context,
REQUEST_CODE_PAGE, pageIntent, PendingIntent.FLAG_UPDATE_CURRENT))
+ .setStyle(new
NotificationCompat.BigTextStyle().bigText(description))
.setContentText(description)
.setSmallIcon(Build.VERSION.SDK_INT >=
Build.VERSION_CODES.LOLLIPOP
? icon : R.mipmap.launcher)
diff --git a/app/src/main/java/org/wikipedia/page/PageActivity.java
b/app/src/main/java/org/wikipedia/page/PageActivity.java
index 992e4dc..37b7574 100644
--- a/app/src/main/java/org/wikipedia/page/PageActivity.java
+++ b/app/src/main/java/org/wikipedia/page/PageActivity.java
@@ -20,6 +20,7 @@
import android.support.design.widget.BottomSheetDialog;
import android.support.design.widget.BottomSheetDialogFragment;
import android.support.v4.app.Fragment;
+import android.support.v7.app.AlertDialog;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.preference.PreferenceManager;
import android.support.v7.view.ActionMode;
@@ -45,6 +46,7 @@
import org.wikipedia.analytics.IntentFunnel;
import org.wikipedia.analytics.LinkPreviewFunnel;
import org.wikipedia.dataclient.WikiSite;
+import org.wikipedia.descriptions.DescriptionEditRevertHelpView;
import org.wikipedia.events.ChangeTextSizeEvent;
import org.wikipedia.events.ThemeChangeEvent;
import org.wikipedia.history.HistoryEntry;
@@ -227,6 +229,12 @@
}
@NonNull
+ public static Intent newIntent(@NonNull Context context, @NonNull String
title) {
+ PageTitle pageTitle = new PageTitle(title,
WikipediaApp.getInstance().getWikiSite());
+ return newIntent(context, new HistoryEntry(pageTitle,
HistoryEntry.SOURCE_INTERNAL_LINK), pageTitle);
+ }
+
+ @NonNull
public static Intent newIntent(@NonNull Context context,
@NonNull HistoryEntry entry,
@NonNull PageTitle title) {
@@ -258,6 +266,9 @@
PageTitle title = intent.getParcelableExtra(EXTRA_PAGETITLE);
HistoryEntry historyEntry =
intent.getParcelableExtra(EXTRA_HISTORYENTRY);
loadPageInForegroundTab(title, historyEntry);
+ if (intent.hasExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER)) {
+
showDescriptionEditRevertDialog(intent.getStringExtra(Constants.INTENT_EXTRA_REVERT_QNUMBER));
+ }
} else if (ACTION_SHOW_TAB_LIST.equals(intent.getAction())) {
showTabList();
} else if (ACTION_RESUME_READING.equals(intent.getAction())) {
@@ -843,6 +854,15 @@
sendBroadcast(widgetIntent);
}
+ private void showDescriptionEditRevertDialog(@NonNull String qNumber) {
+ new AlertDialog.Builder(this)
+ .setTitle(R.string.notification_reverted_title)
+ .setView(new DescriptionEditRevertHelpView(this, qNumber))
+ .setPositiveButton(android.R.string.ok, null)
+ .create()
+ .show();
+ }
+
@VisibleForTesting
public void setPageLoadCallbacks(@Nullable PageLoadCallbacks
pageLoadCallbacks) {
this.pageLoadCallbacks = pageLoadCallbacks;
diff --git a/app/src/main/res/layout/view_description_edit_revert_help.xml
b/app/src/main/res/layout/view_description_edit_revert_help.xml
new file mode 100644
index 0000000..2a5eb4d
--- /dev/null
+++ b/app/src/main/res/layout/view_description_edit_revert_help.xml
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8"?>
+<merge
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:tools="http://schemas.android.com/tools"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content">
+
+ <TextView
+ android:id="@+id/view_description_edit_revert_help_contents"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ style="@style/RtlAwareTextView"
+ android:layout_margin="20dp"
+ android:lineSpacingMultiplier="1.2"
+ tools:text="Lorem ipsum"/>
+
+</merge>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings_no_translate.xml
b/app/src/main/res/values/strings_no_translate.xml
index c50678f..0653288 100644
--- a/app/src/main/res/values/strings_no_translate.xml
+++ b/app/src/main/res/values/strings_no_translate.xml
@@ -89,6 +89,18 @@
Descriptions are stored and maintained on Wikidata, a project of
the Wikimedia Foundation which provides a free, collaborative, multilingual,
secondary database supporting Wikipedia and other projects.
</p>
]]></string>
+
+ <string name="description_edit_revert_help_body"><![CDATA[
+ Thanks for editing Wikipedia!<br />
+ We know you tried your best, but one of the reviewers had a concern.
Possible reasons your edit was reverted include:
+ <p>
+ • your contribution didn\'t follow one of the <a
href="%1$s">guidelines</a>.
+ </p>
+ <p>
+ • your contribution looked like an experiment or vandalism.
+ </p>
+ If you are interested, see the <a href="%2$s">history of edits</a>.
+ ]]></string>
<!-- /Description editing -->
</resources>
--
To view, visit https://gerrit.wikimedia.org/r/333685
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I4c6a78f27f0a6ef5e7bfebc991958f3425cfc792
Gerrit-PatchSet: 2
Gerrit-Project: apps/android/wikipedia
Gerrit-Branch: master
Gerrit-Owner: Dbrant <[email protected]>
Gerrit-Reviewer: Brion VIBBER <[email protected]>
Gerrit-Reviewer: Dbrant <[email protected]>
Gerrit-Reviewer: Mholloway <[email protected]>
Gerrit-Reviewer: Niedzielski <[email protected]>
Gerrit-Reviewer: jenkins-bot <>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits