Merge pull request #107 from domdomegg/patch-2

Fix crash on viewing unknown licenses + add viewing creative commons 4.0 licenses
This commit is contained in:
Nicolas Raoul 2016-06-01 11:44:57 +09:00
commit 6ae48c08c8
2 changed files with 9 additions and 4 deletions

View file

@ -114,6 +114,8 @@
<string name="license_name_cc_by_sa_3_0_pl">CC BY-SA 3.0 (Poland)</string>
<string name="license_name_cc_by_sa_3_0_ro">CC BY-SA 3.0 (Romania)</string>
<string name="license_name_cc_by_3_0">CC BY 3.0</string>
<string name="license_name_cc_by_sa_4_0">CC BY-SA 4.0</string>
<string name="license_name_cc_by_4_0">CC BY 4.0</string>
<string name="license_name_cc_zero">CC Zero</string>
<string name="license_name_own_pd">own-pd</string>
<string name="license_name_cc_by_sa_2_5">CC BY-SA 2.5</string>

View file

@ -53,7 +53,7 @@ public class LicenseList {
}
public String nameIdForTemplate(String template) {
// hack :D
// hack :D (converts dashes and periods to underscores)
// cc-by-sa-3.0 -> cc_by_sa_3_0
return "license_name_" + template.toLowerCase().replace("-", "_").replace(".", "_");
}
@ -68,8 +68,11 @@ public class LicenseList {
Log.d("Commons", "LicenseList.nameForTemplate: stringId: " + stringId);
int nameId = stringIdByName(stringId);
Log.d("Commons", "LicenseList.nameForTemplate: nameId: " + nameId);
String name = res.getString(nameId);
Log.d("Commons", "LicenseList.nameForTemplate: name: " + name);
return name;
if(nameId != 0) {
String name = res.getString(nameId);
Log.d("Commons", "LicenseList.nameForTemplate: name: " + name);
return name;
}
return template;
}
}