mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Fix Wiki Love Monuments year (#5049)
* Remove year from messages containing "Wiki Loves Monuments 2021" * Retrieve Wiki Love Monuments year dynamically * Add test and doc
This commit is contained in:
parent
33679eb6b4
commit
789960a966
15 changed files with 60 additions and 16 deletions
|
|
@ -18,6 +18,7 @@ import androidx.browser.customtabs.CustomTabsIntent;
|
|||
import androidx.core.content.ContextCompat;
|
||||
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import org.wikipedia.dataclient.WikiSite;
|
||||
import org.wikipedia.page.PageTitle;
|
||||
|
|
@ -243,4 +244,18 @@ public class Utils {
|
|||
return "30 Sep";
|
||||
}
|
||||
|
||||
/***
|
||||
* Function to get the current WLM year
|
||||
* It increments at the start of September in line with the other WLM functions
|
||||
* (No consideration of locales for now)
|
||||
* @param calendar
|
||||
* @return
|
||||
*/
|
||||
public static int getWikiLovesMonumentsYear(Calendar calendar) {
|
||||
int year = calendar.get(Calendar.YEAR);
|
||||
if (calendar.get(Calendar.MONTH) < Calendar.SEPTEMBER) {
|
||||
year -= 1;
|
||||
}
|
||||
return year;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,11 +3,13 @@ package fr.free.nrw.commons.upload;
|
|||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import fr.free.nrw.commons.Media;
|
||||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.contributions.Contribution;
|
||||
import fr.free.nrw.commons.filepicker.UploadableFile.DateTimeWithSource;
|
||||
import fr.free.nrw.commons.settings.Prefs.Licenses;
|
||||
import fr.free.nrw.commons.utils.ConfigUtils;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
|
@ -61,10 +63,9 @@ class PageContentsCreator {
|
|||
buffer.append("{{Location|").append(decimalCoords).append("}}").append("\n");
|
||||
}
|
||||
|
||||
if (contribution.getWikidataPlace()!=null && contribution.getWikidataPlace().isMonumentUpload()) {
|
||||
buffer.append("{{Wiki Loves Monuments 2021|1= ")
|
||||
.append(contribution.getCountryCode())
|
||||
.append("}}").append("\n");
|
||||
if (contribution.getWikidataPlace() != null && contribution.getWikidataPlace().isMonumentUpload()) {
|
||||
buffer.append(String.format(Locale.ENGLISH, "{{Wiki Loves Monuments %d|1= %s}}\n",
|
||||
Utils.getWikiLovesMonumentsYear(Calendar.getInstance()), contribution.getCountryCode()));
|
||||
}
|
||||
|
||||
buffer.append("== {{int:license-header}} ==\n")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue