mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fix 2072: default license selector in Settings (#2084)
* SharedPreferences Dep Injection added, updateLicense() updated method updateLicense() was previously looking to the UploadModel for the current default license, this has now been changed so that it gets it from a SharedPreferences object * UploadModel.license aligned to SharedPreferences variable UploadModel.license within the constuctor is now assigned to the string of the "default_license" value within SharedPreferences Admittedly this may not be completly necissary as UploadModel.license is modified via UploadPresenter.updateLicense on creation.
This commit is contained in:
parent
aec377f547
commit
fcd5432f74
2 changed files with 6 additions and 2 deletions
|
|
@ -74,8 +74,8 @@ public class UploadModel {
|
||||||
FileProcessor fileProcessor) {
|
FileProcessor fileProcessor) {
|
||||||
this.licenses = licenses;
|
this.licenses = licenses;
|
||||||
this.prefs = prefs;
|
this.prefs = prefs;
|
||||||
|
this.license = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||||
this.bitmapRegionDecoderWrapper = bitmapRegionDecoderWrapper;
|
this.bitmapRegionDecoderWrapper = bitmapRegionDecoderWrapper;
|
||||||
this.license = Prefs.Licenses.CC_BY_SA_3;
|
|
||||||
this.licensesByName = licensesByName;
|
this.licensesByName = licensesByName;
|
||||||
this.context = context;
|
this.context = context;
|
||||||
this.mwApi = mwApi;
|
this.mwApi = mwApi;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package fr.free.nrw.commons.upload;
|
package fr.free.nrw.commons.upload;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
import android.content.SharedPreferences;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
|
@ -10,12 +11,14 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
import javax.inject.Named;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
|
|
||||||
import fr.free.nrw.commons.R;
|
import fr.free.nrw.commons.R;
|
||||||
import fr.free.nrw.commons.category.CategoriesModel;
|
import fr.free.nrw.commons.category.CategoriesModel;
|
||||||
import fr.free.nrw.commons.contributions.Contribution;
|
import fr.free.nrw.commons.contributions.Contribution;
|
||||||
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
import fr.free.nrw.commons.mwapi.MediaWikiApi;
|
||||||
|
import fr.free.nrw.commons.settings.Prefs;
|
||||||
import fr.free.nrw.commons.utils.ImageUtils;
|
import fr.free.nrw.commons.utils.ImageUtils;
|
||||||
import io.reactivex.Completable;
|
import io.reactivex.Completable;
|
||||||
import io.reactivex.Observable;
|
import io.reactivex.Observable;
|
||||||
|
|
@ -50,6 +53,7 @@ public class UploadPresenter {
|
||||||
@UploadView.UploadPage
|
@UploadView.UploadPage
|
||||||
private int currentPage = UploadView.PLEASE_WAIT;
|
private int currentPage = UploadView.PLEASE_WAIT;
|
||||||
|
|
||||||
|
@Inject @Named("default_preferences")SharedPreferences prefs;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
UploadPresenter(UploadModel uploadModel,
|
UploadPresenter(UploadModel uploadModel,
|
||||||
|
|
@ -355,7 +359,7 @@ public class UploadPresenter {
|
||||||
* Sets the list of licences and the default license.
|
* Sets the list of licences and the default license.
|
||||||
*/
|
*/
|
||||||
private void updateLicenses() {
|
private void updateLicenses() {
|
||||||
String selectedLicense = uploadModel.getSelectedLicense();
|
String selectedLicense = prefs.getString(Prefs.DEFAULT_LICENSE, Prefs.Licenses.CC_BY_SA_3);
|
||||||
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
|
view.updateLicenses(uploadModel.getLicenses(), selectedLicense);
|
||||||
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
|
view.updateLicenseSummary(selectedLicense, uploadModel.getCount());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue