Merge branch '2.13-release' of https://github.com/commons-app/apps-android-commons into 2.13-release-3

This commit is contained in:
Josephine Lim 2020-09-24 01:38:03 +10:00
commit a75ec1e89b
4 changed files with 42 additions and 14 deletions

View file

@ -20,6 +20,7 @@ import com.mapbox.mapboxsdk.Mapbox;
import com.squareup.leakcanary.LeakCanary;
import com.squareup.leakcanary.RefWatcher;
import io.reactivex.Completable;
import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
@ -267,17 +268,18 @@ public class CommonsApplication extends Application {
}
sessionManager.logout()
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(() -> {
Timber.d("All accounts have been removed");
clearImageCache();
//TODO: fix preference manager
defaultPrefs.clearAll();
defaultPrefs.putBoolean("firstrun", false);
updateAllDatabases();
logoutListener.onLogoutComplete();
});
.andThen(Completable.fromAction(() ->{
Timber.d("All accounts have been removed");
clearImageCache();
//TODO: fix preference manager
defaultPrefs.clearAll();
defaultPrefs.putBoolean("firstrun", false);
updateAllDatabases();
}
))
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(logoutListener::onLogoutComplete, Timber::e);
}
/**

View file

@ -5,6 +5,7 @@ import com.mapbox.mapboxsdk.annotations.Marker;
public class NearbyMarker extends Marker {
private final Place place;
private NearbyBaseMarker nearbyBaseMarker;
private boolean disabled;
/**
* Creates a instance of {@link Marker} using the builder of Marker.
@ -24,4 +25,12 @@ public class NearbyMarker extends Marker {
public Place getPlace() {
return place;
}
public void setDisabled(boolean disabled) {
this.disabled = disabled;
}
public boolean isDisabled() {
return disabled;
}
}

View file

@ -1208,6 +1208,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
nearbyBaseMarker.icon(IconFactory.getInstance(getContext())
.fromBitmap(icon));
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
if(marker instanceof NearbyMarker){
((NearbyMarker) marker).setDisabled(false);
}
}
}
}
@ -1226,6 +1230,9 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
for (Marker marker : mapBox.getMarkers()) {
if (!marker.equals(currentLocationMarker)) {
marker.setIcon(IconFactory.getInstance(getContext()).fromBitmap(icon));
if(marker instanceof NearbyMarker){
((NearbyMarker) marker).setDisabled(true);
}
}
}
addCurrentLocationMarker(NearbyController.currentLocation);
@ -1249,10 +1256,10 @@ public class NearbyParentFragment extends CommonsDaggerSupportFragment
});
mapBox.setOnMarkerClickListener(marker -> {
if (marker instanceof NearbyMarker) {
if (marker instanceof NearbyMarker && !((NearbyMarker) marker).isDisabled()) {
presenter.markerSelected(marker);
}
return false;
return true;
});
}
}

View file

@ -3,6 +3,8 @@ package fr.free.nrw.commons.upload;
import android.content.Context;
import android.net.Uri;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import org.wikipedia.csrf.CsrfTokenClient;
import java.io.File;
@ -41,7 +43,15 @@ public class UploadClient {
(bytesWritten, contentLength) -> notificationUpdater
.onProgress(bytesWritten, contentLength));
MultipartBody.Part filePart = MultipartBody.Part.createFormData("file", filename, countingRequestBody);
MultipartBody.Part filePart;
try {
filePart = MultipartBody.Part
.createFormData("file", URLEncoder.encode(filename, "utf-8"), countingRequestBody);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
filePart = MultipartBody.Part
.createFormData("file", filename, countingRequestBody);
}
RequestBody fileNameRequestBody = RequestBody.create(okhttp3.MultipartBody.FORM, filename);
RequestBody tokenRequestBody;
try {