Skip to content

Commit

Permalink
Fix #2156: Add plural support for share_license_summary string (#2161)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhao-gang authored and domdomegg committed Dec 18, 2018
1 parent 1d80cba commit db38174
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,14 @@ public void updateLicenses(List<String> licenses, String selectedLicense) {

@SuppressLint("StringFormatInvalid")
@Override
public void updateLicenseSummary(String selectedLicense) {
public void updateLicenseSummary(String selectedLicense, int imageCount) {
String licenseHyperLink = "<a href='" + Utils.licenseUrlFor(selectedLicense)+"'>" +
getString(Utils.licenseNameFor(selectedLicense)) + "</a><br>";
licenseSummary.setMovementMethod(LinkMovementMethod.getInstance());
licenseSummary.setText(
Html.fromHtml(
getString(R.string.share_license_summary, licenseHyperLink)));
getResources().getQuantityString(R.plurals.share_license_summary,
imageCount, licenseHyperLink)));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void receiveDirect(Uri media, String mimeType, @Contribution.FileSource String s
*/
void selectLicense(String licenseName) {
uploadModel.setSelectedLicense(licenseName);
view.updateLicenseSummary(uploadModel.getSelectedLicense());
view.updateLicenseSummary(uploadModel.getSelectedLicense(), uploadModel.getCount());
}

//region Wizard step management
Expand Down Expand Up @@ -357,7 +357,7 @@ private void updateCards() {
private void updateLicenses() {
String selectedLicense = uploadModel.getSelectedLicense();
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
view.updateLicenseSummary(selectedLicense);
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public interface UploadView {

void updateLicenses(List<String> licenses, String selectedLicense);

void updateLicenseSummary(String selectedLicense);
void updateLicenseSummary(String selectedLicense, int imageCount);

void updateTopCardContent();

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_upload_license.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
android:layout_marginEnd="@dimen/standard_gap"
android:layout_marginRight="@dimen/standard_gap"
android:layout_below="@id/license_list"
android:text="@string/share_license_summary" />
android:text="@plurals/share_license_summary" />

<fr.free.nrw.commons.ui.widget.HtmlTextView
android:id="@+id/media_upload_policy"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_single_upload.xml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
android:layout_marginTop="@dimen/standard_gap"
android:clickable="true"
android:gravity="center"
android:text="@string/share_license_summary"
android:text="@plurals/share_license_summary"
android:textColorLink="@color/button_blue" />

<fr.free.nrw.commons.ui.widget.HtmlTextView
Expand Down
5 changes: 4 additions & 1 deletion app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,10 @@
<string name="no_uploads_yet">You have not yet uploaded any photos.</string>
<string name="menu_retry_upload">Retry</string>
<string name="menu_cancel_upload">Cancel</string>
<string name="share_license_summary">This image will be licensed under %1$s</string>
<plurals name="share_license_summary">
<item quantity="one">This image will be licensed under %1$s</item>
<item quantity="other">These images will be licensed under %1$s</item>
</plurals>
<string name="media_upload_policy">By submitting this picture, I declare that this is my own work, that it does not contain copyrighted material or selfies, and otherwise adheres to &lt;a href=\"https://commons.wikimedia.org/wiki/Commons:Policies_and_guidelines\"&gt;Wikimedia Commons policies&lt;/a&gt;.</string>
<string name="menu_download">Download</string>
<string name="preference_license">Default License</string>
Expand Down

0 comments on commit db38174

Please sign in to comment.