Fix #2156: Add plural support for share_license_summary string (#2161)

This commit is contained in:
Zhao Gang 2018-12-19 01:29:11 +08:00 committed by Adam Jones
parent 1d80cbaac9
commit db38174eb4
6 changed files with 12 additions and 8 deletions

View file

@ -252,13 +252,14 @@ public class UploadActivity extends AuthenticatedActivity implements UploadView,
@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

View file

@ -112,7 +112,7 @@ public class UploadPresenter {
*/
void selectLicense(String licenseName) {
uploadModel.setSelectedLicense(licenseName);
view.updateLicenseSummary(uploadModel.getSelectedLicense());
view.updateLicenseSummary(uploadModel.getSelectedLicense(), uploadModel.getCount());
}
//region Wizard step management
@ -357,7 +357,7 @@ public class UploadPresenter {
private void updateLicenses() {
String selectedLicense = uploadModel.getSelectedLicense();
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
view.updateLicenseSummary(selectedLicense);
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
}
/**

View file

@ -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();

View file

@ -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"

View file

@ -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

View file

@ -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>