mirror of
https://github.com/commons-app/apps-android-commons.git
synced 2025-10-27 12:53:55 +01:00
Show user current location (#4825)
This commit is contained in:
parent
27e3f20ba2
commit
755b216507
2 changed files with 35 additions and 4 deletions
|
|
@ -80,6 +80,7 @@ import fr.free.nrw.commons.description.DescriptionEditHelper;
|
|||
import fr.free.nrw.commons.di.CommonsDaggerSupportFragment;
|
||||
import fr.free.nrw.commons.explore.depictions.WikidataItemDetailsActivity;
|
||||
import fr.free.nrw.commons.kvstore.JsonKvStore;
|
||||
import fr.free.nrw.commons.location.LocationServiceManager;
|
||||
import fr.free.nrw.commons.nearby.Label;
|
||||
import fr.free.nrw.commons.profile.ProfileActivity;
|
||||
import fr.free.nrw.commons.ui.widget.HtmlTextView;
|
||||
|
|
@ -117,6 +118,9 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
private boolean isWikipediaButtonDisplayed;
|
||||
private Callback callback;
|
||||
|
||||
@Inject
|
||||
LocationServiceManager locationManager;
|
||||
|
||||
|
||||
public static MediaDetailFragment forMedia(int index, boolean editable, boolean isCategoryImage, boolean isWikipediaButtonDisplayed) {
|
||||
MediaDetailFragment mf = new MediaDetailFragment();
|
||||
|
|
@ -826,9 +830,14 @@ public class MediaDetailFragment extends CommonsDaggerSupportFragment implements
|
|||
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]);
|
||||
if(locationManager.getLastLocation()!=null) {
|
||||
defaultLatitude = locationManager.getLastLocation().getLatitude();
|
||||
defaultLongitude = locationManager.getLastLocation().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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue