mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 04:43:54 +01:00
Merge remote-tracking branch 'refs/remotes/origin/2.7.x-release'
This commit is contained in:
commit
ba9287fa8b
7 changed files with 137 additions and 58 deletions
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -1,5 +1,15 @@
|
|||
# Wikimedia Commons for Android
|
||||
|
||||
## v2.7.0
|
||||
- New Nearby Places UI with direct uploads (and associated category suggestions)
|
||||
- Added two-factor authentication login
|
||||
- Added Notifications activity to display user talk messages
|
||||
- Added real-time location tracking in Nearby
|
||||
- Added "rate us", "translate", and FB link in About
|
||||
- Improvements to UI of navigation drawer, tutorial, media details view, login activity and Settings
|
||||
- Added option to nominate picture for deletion in media details view
|
||||
- Too many bug and crash fixes to mention!
|
||||
|
||||
## v2.6.7
|
||||
- Added null checks to prevent frequent crashes in ModificationsSyncAdapter
|
||||
|
||||
|
|
|
|||
|
|
@ -91,8 +91,8 @@ android {
|
|||
|
||||
defaultConfig {
|
||||
applicationId 'fr.free.nrw.commons'
|
||||
versionCode 82
|
||||
versionName '2.6.7'
|
||||
versionCode 83
|
||||
versionName '2.7.0'
|
||||
setProperty("archivesBaseName", "app-commons-v$versionName-" + getBranchName())
|
||||
|
||||
minSdkVersion project.minSdkVersion
|
||||
|
|
|
|||
|
|
@ -262,8 +262,6 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
locationManager.removeLocationListener(this);
|
||||
locationManager.unregisterLocationManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -292,8 +290,13 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
// to the retained fragment object to perform its own cleanup.
|
||||
removeMapFragment();
|
||||
removeListFragment();
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
|
||||
}
|
||||
unregisterReceiver(broadcastReceiver);
|
||||
broadcastReceiver = null;
|
||||
locationManager.removeLocationListener(this);
|
||||
locationManager.unregisterLocationManager();
|
||||
|
||||
}
|
||||
|
||||
private void addNetworkBroadcastReceiver() {
|
||||
|
|
@ -422,6 +425,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
if (nearbyMapFragment != null) {
|
||||
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
|
||||
fm.beginTransaction().remove(nearbyMapFragment).commit();
|
||||
nearbyMapFragment = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -433,6 +437,7 @@ public class NearbyActivity extends NavigationBaseActivity implements LocationUp
|
|||
if (nearbyListFragment != null) {
|
||||
android.support.v4.app.FragmentManager fm = getSupportFragmentManager();
|
||||
fm.beginTransaction().remove(nearbyListFragment).commit();
|
||||
nearbyListFragment = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import fr.free.nrw.commons.R;
|
|||
import fr.free.nrw.commons.Utils;
|
||||
import fr.free.nrw.commons.contributions.ContributionController;
|
||||
import fr.free.nrw.commons.utils.UriDeserializer;
|
||||
import fr.free.nrw.commons.utils.ViewUtil;
|
||||
import timber.log.Timber;
|
||||
|
||||
import static android.app.Activity.RESULT_OK;
|
||||
|
|
@ -106,7 +107,8 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
private PolygonOptions currentLocationPolygonOptions;
|
||||
|
||||
private boolean isBottomListSheetExpanded;
|
||||
private final double CAMERA_TARGET_SHIFT_FACTOR = 0.06;
|
||||
private final double CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT = 0.06;
|
||||
private final double CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE = 0.04;
|
||||
|
||||
@Inject
|
||||
@Named("prefs")
|
||||
|
|
@ -254,13 +256,28 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
}
|
||||
|
||||
// Make camera to follow user on location change
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(isBottomListSheetExpanded ?
|
||||
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR,
|
||||
curMapBoxLatLng.getLongitude())
|
||||
: curMapBoxLatLng ) // Sets the new camera position
|
||||
.zoom(mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||
.build();
|
||||
CameraPosition position ;
|
||||
if(ViewUtil.isPortrait(getActivity())){
|
||||
position = new CameraPosition.Builder()
|
||||
.target(isBottomListSheetExpanded ?
|
||||
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
|
||||
curMapBoxLatLng.getLongitude())
|
||||
: curMapBoxLatLng ) // Sets the new camera position
|
||||
.zoom(isBottomListSheetExpanded ?
|
||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||
.build();
|
||||
}else {
|
||||
position = new CameraPosition.Builder()
|
||||
.target(isBottomListSheetExpanded ?
|
||||
new LatLng(curMapBoxLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
|
||||
curMapBoxLatLng.getLongitude())
|
||||
: curMapBoxLatLng ) // Sets the new camera position
|
||||
.zoom(isBottomListSheetExpanded ?
|
||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||
.build();
|
||||
}
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory
|
||||
.newCameraPosition(position), 1000);
|
||||
|
|
@ -274,12 +291,21 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
if (mapboxMap != null && curLatLng != null) {
|
||||
if (isBottomListSheetExpanded) {
|
||||
// Make camera to follow user on location change
|
||||
position = new CameraPosition.Builder()
|
||||
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR,
|
||||
curLatLng.getLongitude())) // Sets the new camera target above
|
||||
// current to make it visible when sheet is expanded
|
||||
.zoom(11) // Same zoom level
|
||||
.build();
|
||||
if(ViewUtil.isPortrait(getActivity())) {
|
||||
position = new CameraPosition.Builder()
|
||||
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
|
||||
curLatLng.getLongitude())) // Sets the new camera target above
|
||||
// current to make it visible when sheet is expanded
|
||||
.zoom(11) // Fixed zoom level
|
||||
.build();
|
||||
} else {
|
||||
position = new CameraPosition.Builder()
|
||||
.target(new LatLng(curLatLng.getLatitude() - CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
|
||||
curLatLng.getLongitude())) // Sets the new camera target above
|
||||
// current to make it visible when sheet is expanded
|
||||
.zoom(11) // Fixed zoom level
|
||||
.build();
|
||||
}
|
||||
|
||||
} else {
|
||||
// Make camera to follow user on location change
|
||||
|
|
@ -345,10 +371,29 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
fabRecenter.setOnClickListener(view -> {
|
||||
if (curLatLng != null) {
|
||||
mapView.getMapAsync(mapboxMap -> {
|
||||
CameraPosition position = new CameraPosition.Builder()
|
||||
.target(new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude())) // Sets the new camera position
|
||||
.zoom(11) // Sets the zoom
|
||||
.build(); // Creates a CameraPosition from the builder
|
||||
CameraPosition position;
|
||||
|
||||
if(ViewUtil.isPortrait(getActivity())){
|
||||
position = new CameraPosition.Builder()
|
||||
.target(isBottomListSheetExpanded ?
|
||||
new LatLng(curLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_PORTRAIT,
|
||||
curLatLng.getLongitude())
|
||||
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
||||
.zoom(isBottomListSheetExpanded ?
|
||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||
.build();
|
||||
}else {
|
||||
position = new CameraPosition.Builder()
|
||||
.target(isBottomListSheetExpanded ?
|
||||
new LatLng(curLatLng.getLatitude()- CAMERA_TARGET_SHIFT_FACTOR_LANDSCAPE,
|
||||
curLatLng.getLongitude())
|
||||
: new LatLng(curLatLng.getLatitude(), curLatLng.getLongitude(), 0)) // Sets the new camera position
|
||||
.zoom(isBottomListSheetExpanded ?
|
||||
11 // zoom level is fixed to 11 when bottom sheet is expanded
|
||||
:mapboxMap.getCameraPosition().zoom) // Same zoom level
|
||||
.build();
|
||||
}
|
||||
|
||||
mapboxMap.animateCamera(CameraUpdateFactory
|
||||
.newCameraPosition(position), 1000);
|
||||
|
|
@ -535,7 +580,9 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
transparentView.setAlpha(0);
|
||||
closeFabs(isFabOpen);
|
||||
hideFAB();
|
||||
this.getView().requestFocus();
|
||||
if (this.getView() != null) {
|
||||
this.getView().requestFocus();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -776,6 +823,9 @@ public class NearbyMapFragment extends DaggerFragment {
|
|||
if (mapView != null) {
|
||||
mapView.onDestroy();
|
||||
}
|
||||
selected = null;
|
||||
currentLocationMarker = null;
|
||||
|
||||
super.onDestroyView();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,12 +1,18 @@
|
|||
package fr.free.nrw.commons.upload;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapRegionDecoder;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.ref.WeakReference;
|
||||
|
||||
import fr.free.nrw.commons.R;
|
||||
import fr.free.nrw.commons.contributions.ContributionsActivity;
|
||||
import fr.free.nrw.commons.utils.ImageUtils;
|
||||
import timber.log.Timber;
|
||||
|
||||
|
|
@ -21,16 +27,13 @@ import timber.log.Timber;
|
|||
|
||||
public class DetectUnwantedPicturesAsync extends AsyncTask<Void, Void, ImageUtils.Result> {
|
||||
|
||||
interface Callback {
|
||||
void onResult(ImageUtils.Result result);
|
||||
}
|
||||
|
||||
private final Callback callback;
|
||||
private final String imageMediaFilePath;
|
||||
public final WeakReference<Activity> activityWeakReference;
|
||||
|
||||
DetectUnwantedPicturesAsync(String imageMediaFilePath, Callback callback) {
|
||||
this.callback = callback;
|
||||
DetectUnwantedPicturesAsync(WeakReference<Activity> activityWeakReference, String imageMediaFilePath) {
|
||||
//this.callback = callback;
|
||||
this.imageMediaFilePath = imageMediaFilePath;
|
||||
this.activityWeakReference = activityWeakReference;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -53,7 +56,29 @@ public class DetectUnwantedPicturesAsync extends AsyncTask<Void, Void, ImageUtil
|
|||
@Override
|
||||
protected void onPostExecute(ImageUtils.Result result) {
|
||||
super.onPostExecute(result);
|
||||
//callback to UI so that it can take necessary decision based on the result obtained
|
||||
callback.onResult(result);
|
||||
Activity activity = activityWeakReference.get();
|
||||
|
||||
if (result != ImageUtils.Result.IMAGE_OK) {
|
||||
//show appropriate error message
|
||||
String errorMessage = result == ImageUtils.Result.IMAGE_DARK ? activity.getString(R.string.upload_image_too_dark) : activity.getString(R.string.upload_image_blurry);
|
||||
AlertDialog.Builder errorDialogBuilder = new AlertDialog.Builder(activity);
|
||||
errorDialogBuilder.setMessage(errorMessage);
|
||||
errorDialogBuilder.setTitle(activity.getString(R.string.warning));
|
||||
errorDialogBuilder.setPositiveButton(activity.getString(R.string.no), (dialogInterface, i) -> {
|
||||
//user does not wish to upload the picture, take them back to ContributionsActivity
|
||||
Intent intent = new Intent(activity, ContributionsActivity.class);
|
||||
dialogInterface.dismiss();
|
||||
activity.startActivity(intent);
|
||||
});
|
||||
errorDialogBuilder.setNegativeButton(activity.getString(R.string.yes), (dialogInterface, i) -> {
|
||||
//user wishes to go ahead with the upload of this picture, just dismiss this dialog
|
||||
dialogInterface.dismiss();
|
||||
});
|
||||
|
||||
AlertDialog errorDialog = errorDialogBuilder.create();
|
||||
if (!activity.isFinishing()) {
|
||||
errorDialog.show();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -415,31 +415,9 @@ public class ShareActivity
|
|||
|
||||
private void performUnwantedPictureDetectionProcess() {
|
||||
String imageMediaFilePath = FileUtils.getPath(this,mediaUri);
|
||||
DetectUnwantedPicturesAsync detectUnwantedPicturesAsync = new DetectUnwantedPicturesAsync(imageMediaFilePath, result -> {
|
||||
|
||||
if (result != ImageUtils.Result.IMAGE_OK) {
|
||||
//show appropriate error message
|
||||
String errorMessage = result == ImageUtils.Result.IMAGE_DARK ? getString(R.string.upload_image_too_dark) : getString(R.string.upload_image_blurry);
|
||||
AlertDialog.Builder errorDialogBuilder = new AlertDialog.Builder(this);
|
||||
errorDialogBuilder.setMessage(errorMessage);
|
||||
errorDialogBuilder.setTitle(getString(R.string.warning));
|
||||
errorDialogBuilder.setPositiveButton(getString(R.string.no), (dialogInterface, i) -> {
|
||||
//user does not wish to upload the picture, take them back to ContributionsActivity
|
||||
Intent intent = new Intent(ShareActivity.this, ContributionsActivity.class);
|
||||
dialogInterface.dismiss();
|
||||
startActivity(intent);
|
||||
});
|
||||
errorDialogBuilder.setNegativeButton(getString(R.string.yes), (dialogInterface, i) -> {
|
||||
//user wishes to go ahead with the upload of this picture, just dismiss this dialog
|
||||
dialogInterface.dismiss();
|
||||
});
|
||||
|
||||
AlertDialog errorDialog = errorDialogBuilder.create();
|
||||
if (!isFinishing()) {
|
||||
errorDialog.show();
|
||||
}
|
||||
}
|
||||
});
|
||||
DetectUnwantedPicturesAsync detectUnwantedPicturesAsync
|
||||
= new DetectUnwantedPicturesAsync(new WeakReference<Activity>(this)
|
||||
, imageMediaFilePath);
|
||||
|
||||
detectUnwantedPicturesAsync.execute();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
package fr.free.nrw.commons.utils;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.Display;
|
||||
import android.view.View;
|
||||
import android.widget.Toast;
|
||||
|
||||
|
|
@ -16,4 +18,13 @@ public class ViewUtil {
|
|||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
|
||||
public static boolean isPortrait(Context context) {
|
||||
Display orientation = ((Activity)context).getWindowManager().getDefaultDisplay();
|
||||
if(orientation.getWidth() < orientation.getHeight()){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue