mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43: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;
|
||||
|
||||
/**
|
||||
* represents Licence object
|
||||
*/
|
||||
public class License {
|
||||
private String key;
|
||||
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) {
|
||||
if (url == null) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -13,10 +13,18 @@ import java.util.HashMap;
|
|||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Represents LicenseList
|
||||
*/
|
||||
public class LicenseList {
|
||||
private Map<String, License> licenses = new HashMap<>();
|
||||
private Resources res;
|
||||
|
||||
/**
|
||||
* Constructs new instance of LicenceList
|
||||
*
|
||||
* @param activity License activity
|
||||
*/
|
||||
public LicenseList(Activity activity) {
|
||||
res = activity.getResources();
|
||||
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() {
|
||||
return licenses.values();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets license
|
||||
* @param key License key
|
||||
* @return License that matches key
|
||||
*/
|
||||
public License get(String key) {
|
||||
return licenses.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a license from template
|
||||
* @param template License template
|
||||
* @return null
|
||||
*/
|
||||
@Nullable
|
||||
License licenseForTemplate(String template) {
|
||||
String ucTemplate = new PageTitle(template).getDisplayText();
|
||||
|
|
@ -50,6 +72,11 @@ public class LicenseList {
|
|||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets template name id
|
||||
* @param template License template
|
||||
* @return name id of template
|
||||
*/
|
||||
private String nameIdForTemplate(String template) {
|
||||
// hack :D (converts dashes and periods to underscores)
|
||||
// cc-by-sa-3.0 -> cc_by_sa_3_0
|
||||
|
|
@ -57,6 +84,11 @@ public class LicenseList {
|
|||
"_").replace(".", "_");
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets name of given template
|
||||
* @param template License template
|
||||
* @return name of template
|
||||
*/
|
||||
private String nameForTemplate(String template) {
|
||||
int nameId = res.getIdentifier("fr.free.nrw.commons:string/"
|
||||
+ nameIdForTemplate(template), null, null);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue