mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
added JavaDoc comments
This commit is contained in:
parent
3d6c6e0301
commit
19ef7b126c
2 changed files with 41 additions and 0 deletions
|
|
@ -2,6 +2,9 @@ package fr.free.nrw.commons;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
import android.support.annotation.Nullable;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* represents Licence object
|
||||||
|
*/
|
||||||
public class License {
|
public class License {
|
||||||
private String key;
|
private String key;
|
||||||
private String template;
|
private String template;
|
||||||
|
|
@ -56,6 +59,12 @@ public class License {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the license URL
|
||||||
|
*
|
||||||
|
* @param language license language
|
||||||
|
* @return URL
|
||||||
|
*/
|
||||||
public @Nullable String getUrl(String language) {
|
public @Nullable String getUrl(String language) {
|
||||||
if (url == null) {
|
if (url == null) {
|
||||||
return null;
|
return null;
|
||||||
|
|
|
||||||
|
|
@ -13,10 +13,18 @@ import java.util.HashMap;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents LicenseList
|
||||||
|
*/
|
||||||
public class LicenseList {
|
public class LicenseList {
|
||||||
private Map<String, License> licenses = new HashMap<>();
|
private Map<String, License> licenses = new HashMap<>();
|
||||||
private Resources res;
|
private Resources res;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs new instance of LicenceList
|
||||||
|
*
|
||||||
|
* @param activity License activity
|
||||||
|
*/
|
||||||
public LicenseList(Activity activity) {
|
public LicenseList(Activity activity) {
|
||||||
res = activity.getResources();
|
res = activity.getResources();
|
||||||
XmlPullParser parser = res.getXml(R.xml.wikimedia_licenses);
|
XmlPullParser parser = res.getXml(R.xml.wikimedia_licenses);
|
||||||
|
|
@ -31,14 +39,28 @@ public class LicenseList {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets a collection of licenses
|
||||||
|
* @return License values
|
||||||
|
*/
|
||||||
public Collection<License> values() {
|
public Collection<License> values() {
|
||||||
return licenses.values();
|
return licenses.values();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets license
|
||||||
|
* @param key License key
|
||||||
|
* @return License that matches key
|
||||||
|
*/
|
||||||
public License get(String key) {
|
public License get(String key) {
|
||||||
return licenses.get(key);
|
return licenses.get(key);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a license from template
|
||||||
|
* @param template License template
|
||||||
|
* @return null
|
||||||
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
License licenseForTemplate(String template) {
|
License licenseForTemplate(String template) {
|
||||||
String ucTemplate = new PageTitle(template).getDisplayText();
|
String ucTemplate = new PageTitle(template).getDisplayText();
|
||||||
|
|
@ -50,6 +72,11 @@ public class LicenseList {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets template name id
|
||||||
|
* @param template License template
|
||||||
|
* @return name id of template
|
||||||
|
*/
|
||||||
private String nameIdForTemplate(String template) {
|
private String nameIdForTemplate(String template) {
|
||||||
// hack :D (converts dashes and periods to underscores)
|
// hack :D (converts dashes and periods to underscores)
|
||||||
// cc-by-sa-3.0 -> cc_by_sa_3_0
|
// cc-by-sa-3.0 -> cc_by_sa_3_0
|
||||||
|
|
@ -57,6 +84,11 @@ public class LicenseList {
|
||||||
"_").replace(".", "_");
|
"_").replace(".", "_");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets name of given template
|
||||||
|
* @param template License template
|
||||||
|
* @return name of template
|
||||||
|
*/
|
||||||
private String nameForTemplate(String template) {
|
private String nameForTemplate(String template) {
|
||||||
int nameId = res.getIdentifier("fr.free.nrw.commons:string/"
|
int nameId = res.getIdentifier("fr.free.nrw.commons:string/"
|
||||||
+ nameIdForTemplate(template), null, null);
|
+ nameIdForTemplate(template), null, null);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue