jenkins-bot has submitted this change and it was merged. Change subject: Add Talk link at bottom of page ......................................................................
Add Talk link at bottom of page Opens the talk page from the link in external browser. Change-Id: I39e5b18d5c96def6b9ac41a0fead92eeddf22712 (cherry picked from commit 89069e7df9d31dacf32c7d5b967a526121fa4a43) --- M app/src/main/java/org/wikipedia/page/Namespace.java M app/src/main/java/org/wikipedia/page/PageFragment.java M app/src/main/java/org/wikipedia/page/PageTitle.java M app/src/main/java/org/wikipedia/page/bottomcontent/BottomContentHandler.java M app/src/main/res/values-qq/strings.xml M app/src/main/res/values/strings.xml 6 files changed, 30 insertions(+), 4 deletions(-) Approvals: Dbrant: Looks good to me, approved jenkins-bot: Verified diff --git a/app/src/main/java/org/wikipedia/page/Namespace.java b/app/src/main/java/org/wikipedia/page/Namespace.java index d17e9cf..abd21a7 100644 --- a/app/src/main/java/org/wikipedia/page/Namespace.java +++ b/app/src/main/java/org/wikipedia/page/Namespace.java @@ -95,6 +95,14 @@ return Namespace.SPECIAL; } + // This works for the links provided by the app itself since they always have the English + // version of the namespace. + // TODO: It would be nice to add a mapping table, as is done for File and Special, + // so we can also handle links passed to the app. + if (name != null && name.contains("Talk")) { + return Namespace.TALK; + } + return Namespace.MAIN; } diff --git a/app/src/main/java/org/wikipedia/page/PageFragment.java b/app/src/main/java/org/wikipedia/page/PageFragment.java index 046567b..a58905c 100755 --- a/app/src/main/java/org/wikipedia/page/PageFragment.java +++ b/app/src/main/java/org/wikipedia/page/PageFragment.java @@ -376,10 +376,12 @@ if (!isResumed()) { return; } - // if it's a Special page, launch it in an external browser, since mobileview + // If it's a Special page, launch it in an external browser, since mobileview // doesn't support the Special namespace. // TODO: remove when Special pages are properly returned by the server - if (title.isSpecial()) { + // If this is a Talk page also show in external browser since we don't handle those pages + // in the app very well at this time. + if (title.isSpecial() || title.isTalkPage()) { visitInExternalBrowser(getActivity(), Uri.parse(title.getMobileUri())); return; } diff --git a/app/src/main/java/org/wikipedia/page/PageTitle.java b/app/src/main/java/org/wikipedia/page/PageTitle.java index 7242c4e..0fe4eef 100644 --- a/app/src/main/java/org/wikipedia/page/PageTitle.java +++ b/app/src/main/java/org/wikipedia/page/PageTitle.java @@ -286,6 +286,15 @@ return namespace().special(); } + /** + * Check if the Title represents a talk page + * + * @return true if it is a talk page, false if not + */ + public boolean isTalkPage() { + return namespace().talk(); + } + @Override public int describeContents() { return 0; diff --git a/app/src/main/java/org/wikipedia/page/bottomcontent/BottomContentHandler.java b/app/src/main/java/org/wikipedia/page/bottomcontent/BottomContentHandler.java index 92f4ee6..42d1a8d 100644 --- a/app/src/main/java/org/wikipedia/page/bottomcontent/BottomContentHandler.java +++ b/app/src/main/java/org/wikipedia/page/bottomcontent/BottomContentHandler.java @@ -272,11 +272,16 @@ if (page.isMainPage() || page.isFilePage()) { pageLastUpdatedText.setVisibility(View.GONE); } else { - String lastUpdatedHtml = "<a href=\"" + page.getTitle().getUriForAction("history") + PageTitle title = page.getTitle(); + String lastUpdatedHtml = "<a href=\"" + title.getUriForAction("history") + "\">" + activity.getString(R.string.last_updated_text, formatDateRelative(page.getPageProperties().getLastModified()) + "</a>"); - pageLastUpdatedText.setText(Html.fromHtml(lastUpdatedHtml)); + // TODO: Hide the Talk link if already on a talk page + PageTitle talkPageTitle = new PageTitle("Talk", title.getPrefixedText(), title.getSite()); + String discussionHtml = "<a href=\"" + talkPageTitle.getCanonicalUri() + "\">" + + activity.getString(R.string.talk_page_link_text) + "</a>"; + pageLastUpdatedText.setText(Html.fromHtml(lastUpdatedHtml + " — " + discussionHtml)); pageLastUpdatedText.setMovementMethod(new LinkMovementMethodExt(linkHandler)); pageLastUpdatedText.setVisibility(View.VISIBLE); } diff --git a/app/src/main/res/values-qq/strings.xml b/app/src/main/res/values-qq/strings.xml index de28215..7d1e4ad 100644 --- a/app/src/main/res/values-qq/strings.xml +++ b/app/src/main/res/values-qq/strings.xml @@ -61,6 +61,7 @@ <string name="nearby_distance_in_kilometers">Distance to the place mentioned in the nearby page in kilometers. Please leave the %.2f as is. It represents a floating point number with 2 digits after the decimal point.</string> <string name="nearby_zoom_to_location">Small toast (popup) message on Nearby screen saying that the current location of the device was not available.</string> <string name="last_updated_text">Message in footer of article indicating when the article was last updated. \'%s\' is substituted with the appropriately formatted human-readable timestamp, such as \"seven days ago\".</string> + <string name="talk_page_link_text">Link text for accessing Talk pages. Use the same word in your language as is done on the web site. Some use the term discussions.</string> <string name="content_license_html">HTML specifying license of the Wiki and link to appropriate CC page</string> <string name="edit_save_action_license_logged_in">HTML specifying Terms of Use and CC license before saving edits</string> <string name="edit_save_action_license_anon">HTML specifying Terms of Use and CC license and a log link before saving edits, only when the user has not logged in. Please do not change the href=\'https://#login\' part of the message.</string> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 06dd0e6..77a4534 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -53,6 +53,7 @@ <string name="nearby_zoom_to_location">Zoom to a location on the map</string> <string name="last_updated_text">Last updated %s</string> + <string name="talk_page_link_text">Talk</string> <string name="content_license_html"><![CDATA[Content is available under <a href=\"//creativecommons.org/licenses/by-sa/3.0/\">CC BY-SA 3.0</a> unless otherwise noted]]></string> <string name="edit_save_action_license_logged_in"><![CDATA[By saving, you agree to the <a href="https://wikimediafoundation.org/wiki/Terms_of_Use">Terms of Use</a>, and to irrevocably release your contributions under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a> license.]]></string> <string name="edit_save_action_license_anon"><![CDATA[By saving, you agree to the <a href="https://wikimediafoundation.org/wiki/Terms_of_Use">Terms of Use</a>, and to irrevocably release your contributions under the <a href="https://creativecommons.org/licenses/by-sa/3.0/">CC BY-SA 3.0</a> license. Edits will be attributed to the IP address of your device. If you <a href="https://#login">log in</a>, you will have more privacy.]]></string> -- To view, visit https://gerrit.wikimedia.org/r/197851 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: merged Gerrit-Change-Id: I39e5b18d5c96def6b9ac41a0fead92eeddf22712 Gerrit-PatchSet: 13 Gerrit-Project: apps/android/wikipedia Gerrit-Branch: master Gerrit-Owner: BearND <bsitzm...@wikimedia.org> Gerrit-Reviewer: BearND <bsitzm...@wikimedia.org> Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org> Gerrit-Reviewer: Dbrant <dbr...@wikimedia.org> Gerrit-Reviewer: Mholloway <mhollo...@wikimedia.org> Gerrit-Reviewer: Niedzielski <sniedziel...@wikimedia.org> Gerrit-Reviewer: jenkins-bot <> _______________________________________________ MediaWiki-commits mailing list MediaWiki-commits@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits