Show Last Known Location in LocationPickerActivity (#4816)

* Show Last Known Location in LocationPickerActivity

* Removed extra empty line

* Added tests

* Added tests

* Added tests

* Added tests

* Added tests

* Added tests

* Added tests
This commit is contained in:
Devarsh Mavani 2022-02-16 00:44:46 +05:30 committed by GitHub
parent 458024bdee
commit c2bc5b4f23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 41 additions and 2 deletions

View file

@ -9,6 +9,7 @@ import static fr.free.nrw.commons.category.CategoryClientKt.CATEGORY_UNCATEGORIS
import static fr.free.nrw.commons.description.EditDescriptionConstants.LIST_OF_DESCRIPTION_AND_CAPTION;
import static fr.free.nrw.commons.description.EditDescriptionConstants.UPDATED_WIKITEXT;
import static fr.free.nrw.commons.description.EditDescriptionConstants.WIKITEXT;
import static fr.free.nrw.commons.upload.mediaDetails.UploadMediaDetailFragment.LAST_LOCATION;
import android.annotation.SuppressLint;
import android.app.AlertDialog;
@ -821,11 +822,15 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
*/
double defaultLatitude = 37.773972;
double defaultLongitude = -122.431297;
if (media.getCoordinates() != null) {
defaultLatitude = media.getCoordinates().getLatitude();
defaultLongitude = media.getCoordinates().getLongitude();
} else {
String[] lastLocation = applicationKvStore.getString(LAST_LOCATION,(defaultLatitude + "," + defaultLongitude)).split(",");
defaultLatitude = Double.parseDouble(lastLocation[0]);
defaultLongitude = Double.parseDouble(lastLocation[1]);
}
startActivityForResult(new LocationPicker.IntentBuilder()
.defaultLocation(new CameraPosition.Builder()
.target(new LatLng(defaultLatitude, defaultLongitude))