Skip to content

Commit 03e3d05

Browse files
ashishkumar468neslihanturan
authored andcommitted
BugFix #2720 (#2831)
BugFix deprecated licenes #2720
1 parent 314ebd8 commit 03e3d05

File tree

4 files changed

+18
-24
lines changed

4 files changed

+18
-24
lines changed

app/src/main/java/fr/free/nrw/commons/Utils.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,8 @@ public static int licenseNameFor(String license) {
103103
return R.string.license_name_cc_by_sa_four;
104104
case Prefs.Licenses.CC0:
105105
return R.string.license_name_cc0;
106-
case Prefs.Licenses.CC_BY: // for backward compatibility to v2.1
107-
return R.string.license_name_cc_by_3_0;
108-
case Prefs.Licenses.CC_BY_SA: // for backward compatibility to v2.1
109-
return R.string.license_name_cc_by_sa_3_0;
110106
}
111-
throw new RuntimeException("Unrecognized license value: " + license);
107+
throw new IllegalStateException("Unrecognized license value: " + license);
112108
}
113109

114110
/**
@@ -132,7 +128,7 @@ public static String licenseUrlFor(String license) {
132128
case Prefs.Licenses.CC0:
133129
return "https://creativecommons.org/publicdomain/zero/1.0/";
134130
default:
135-
throw new RuntimeException("Unrecognized license value: " + license);
131+
throw new IllegalStateException("Unrecognized license value: " + license);
136132
}
137133
}
138134

app/src/main/java/fr/free/nrw/commons/contributions/Contribution.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -258,10 +258,6 @@ private String licenseTemplateFor(String license) {
258258
return "{{self|cc-by-sa-4.0}}";
259259
case Prefs.Licenses.CC0:
260260
return "{{self|cc-zero}}";
261-
case Prefs.Licenses.CC_BY:
262-
return "{{self|cc-by-3.0}}";
263-
case Prefs.Licenses.CC_BY_SA:
264-
return "{{self|cc-by-sa-3.0}}";
265261
}
266262

267263
throw new RuntimeException("Unrecognized license value: " + license);

app/src/main/java/fr/free/nrw/commons/settings/Prefs.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,5 @@ public static class Licenses {
1414
public static final String CC_BY_SA_4 = "CC BY-SA 4.0";
1515
public static final String CC_BY_4 = "CC BY 4.0";
1616
public static final String CC0 = "CC0";
17-
18-
// kept for backward compatibility to v2.1
19-
@Deprecated public static final String CC_BY = "CC BY";
20-
@Deprecated public static final String CC_BY_SA = "CC BY-SA";
2117
}
2218
}

app/src/main/java/fr/free/nrw/commons/upload/UploadPresenter.java

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,8 @@
22

33
import android.annotation.SuppressLint;
44
import android.content.Context;
5-
6-
import java.lang.reflect.Proxy;
7-
import java.util.ArrayList;
8-
import java.util.List;
9-
10-
import javax.inject.Inject;
11-
import javax.inject.Named;
12-
import javax.inject.Singleton;
13-
145
import fr.free.nrw.commons.R;
6+
import fr.free.nrw.commons.Utils;
157
import fr.free.nrw.commons.category.CategoriesModel;
168
import fr.free.nrw.commons.contributions.Contribution;
179
import fr.free.nrw.commons.filepicker.UploadableFile;
@@ -23,6 +15,12 @@
2315
import io.reactivex.Observable;
2416
import io.reactivex.android.schedulers.AndroidSchedulers;
2517
import io.reactivex.schedulers.Schedulers;
18+
import java.lang.reflect.Proxy;
19+
import java.util.ArrayList;
20+
import java.util.List;
21+
import javax.inject.Inject;
22+
import javax.inject.Named;
23+
import javax.inject.Singleton;
2624
import timber.log.Timber;
2725

2826
import static fr.free.nrw.commons.upload.UploadModel.UploadItem;
@@ -330,7 +328,15 @@ private void updateCards() {
330328
* Sets the list of licences and the default license.
331329
*/
332330
private void updateLicenses() {
333-
String selectedLicense = defaultKvStore.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
331+
String selectedLicense = defaultKvStore.getString(Prefs.DEFAULT_LICENSE,
332+
Prefs.Licenses.CC_BY_SA_4);//CC_BY_SA_4 is the default one used by the commons web app
333+
try {//I have to make sure that the stored default license was not one of the deprecated one's
334+
Utils.licenseNameFor(selectedLicense);
335+
} catch (IllegalStateException exception) {
336+
Timber.e(exception.getMessage());
337+
selectedLicense = Prefs.Licenses.CC_BY_SA_4;
338+
defaultKvStore.putString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_4);
339+
}
334340
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
335341
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
336342
}

0 commit comments

Comments
 (0)