mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 21:03:54 +01:00
Fixed 4794 : Added a functionality of remembering zoom level on map (#4817)
* Fixed 4794 : Added a functionality of remembering zoom level on map * Added Required Changes * Added Required Changes * Added Required Changes * Added Required Changes * Added Required Tests for the RememberZoomLevel
This commit is contained in:
parent
755b216507
commit
863477aa02
5 changed files with 129 additions and 7 deletions
|
|
@ -7,6 +7,7 @@ import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconIgnorePlacem
|
|||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.iconImage;
|
||||
import static com.mapbox.mapboxsdk.style.layers.PropertyFactory.visibility;
|
||||
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION;
|
||||
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_ZOOM;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
|
@ -382,6 +383,7 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
|
|||
mapboxMap.getCameraPosition().target.getLatitude()
|
||||
+ ","
|
||||
+ mapboxMap.getCameraPosition().target.getLongitude());
|
||||
applicationKvStore.putString(LAST_ZOOM, mapboxMap.getCameraPosition().zoom + "");
|
||||
}
|
||||
final Intent returningIntent = new Intent();
|
||||
returningIntent.putExtra(LocationPickerConstants.MAP_CAMERA_POSITION,
|
||||
|
|
|
|||
|
|
@ -18,6 +18,10 @@ class ImageCoordinates internal constructor(exif: ExifInterface?) {
|
|||
* @return string of `"[decLatitude]|[decLongitude]"` or null if coordinates do not exist
|
||||
*/
|
||||
var decimalCoords: String? = null
|
||||
var zoomLevel : Double = 16.0
|
||||
/**
|
||||
* @return double value of zoom or 16.0 by default
|
||||
*/
|
||||
|
||||
/**
|
||||
* Construct from a stream.
|
||||
|
|
|
|||
|
|
@ -60,6 +60,7 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
* from applicationKvStore.
|
||||
*/
|
||||
public static final String LAST_LOCATION = "last_location_while_uploading";
|
||||
public static final String LAST_ZOOM = "last_zoom_level_while_uploading";
|
||||
@BindView(R.id.tv_title)
|
||||
TextView tvTitle;
|
||||
@BindView(R.id.ib_map)
|
||||
|
|
@ -424,17 +425,19 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
editableUploadItem = uploadItem;
|
||||
double defaultLatitude = 37.773972;
|
||||
double defaultLongitude = -122.431297;
|
||||
double defaultZoom = 16.0;
|
||||
|
||||
if (uploadItem.getGpsCoords()
|
||||
if (uploadItem.getGpsCoords() != null && uploadItem.getGpsCoords()
|
||||
.getDecLatitude() != 0.0 && uploadItem.getGpsCoords().getDecLongitude() != 0.0) {
|
||||
defaultLatitude = uploadItem.getGpsCoords()
|
||||
.getDecLatitude();
|
||||
defaultLongitude = uploadItem.getGpsCoords().getDecLongitude();
|
||||
defaultZoom = uploadItem.getGpsCoords().getZoomLevel();
|
||||
startActivityForResult(new LocationPicker.IntentBuilder()
|
||||
.defaultLocation(new CameraPosition.Builder()
|
||||
.target(
|
||||
new com.mapbox.mapboxsdk.geometry.LatLng(defaultLatitude, defaultLongitude))
|
||||
.zoom(16).build())
|
||||
.zoom(defaultZoom).build())
|
||||
.activityKey("UploadActivity")
|
||||
.build(getActivity()), REQUEST_CODE);
|
||||
} else {
|
||||
|
|
@ -444,11 +447,14 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
defaultLatitude = Double.parseDouble(locationLatLng[0]);
|
||||
defaultLongitude = Double.parseDouble(locationLatLng[1]);
|
||||
}
|
||||
if(defaultKvStore.getString(LAST_ZOOM) != null){
|
||||
defaultZoom = Double.parseDouble(defaultKvStore.getString(LAST_ZOOM));
|
||||
}
|
||||
startActivityForResult(new LocationPicker.IntentBuilder()
|
||||
.defaultLocation(new CameraPosition.Builder()
|
||||
.target(
|
||||
new com.mapbox.mapboxsdk.geometry.LatLng(defaultLatitude, defaultLongitude))
|
||||
.zoom(16).build())
|
||||
.zoom(defaultZoom).build())
|
||||
.activityKey("NoLocationUploadActivity")
|
||||
.build(getActivity()), REQUEST_CODE);
|
||||
}
|
||||
|
|
@ -474,8 +480,9 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
|
||||
final String latitude = String.valueOf(cameraPosition.target.getLatitude());
|
||||
final String longitude = String.valueOf(cameraPosition.target.getLongitude());
|
||||
final double zoom = cameraPosition.zoom;
|
||||
|
||||
editLocation(latitude, longitude);
|
||||
editLocation(latitude, longitude,zoom);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -485,12 +492,13 @@ public class UploadMediaDetailFragment extends UploadBaseFragment implements
|
|||
* @param latitude new latitude
|
||||
* @param longitude new longitude
|
||||
*/
|
||||
public void editLocation(final String latitude, final String longitude){
|
||||
public void editLocation(final String latitude, final String longitude, final double zoom){
|
||||
|
||||
editableUploadItem.getGpsCoords().setDecLatitude(Double.parseDouble(latitude));
|
||||
editableUploadItem.getGpsCoords().setDecLongitude(Double.parseDouble(longitude));
|
||||
editableUploadItem.getGpsCoords().setDecimalCoords(latitude+"|"+longitude);
|
||||
editableUploadItem.getGpsCoords().setImageCoordsExists(true);
|
||||
editableUploadItem.getGpsCoords().setZoomLevel(zoom);
|
||||
Toast.makeText(getContext(), "Location Updated", Toast.LENGTH_LONG).show();
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue