Skip to content

Commit 51f58b7

Browse files
domdomeggmaskaravivek
authored andcommitted
Add MapBox localization (commons-app#2614)
1 parent 1d225c5 commit 51f58b7

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

app/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ dependencies {
3535
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
3636
implementation 'com.github.pedrovgs:renderers:3.3.3'
3737
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:6.8.0'
38+
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization:0.6.0'
3839
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
3940
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
4041
implementation 'com.karumi:dexter:5.0.0'

app/src/main/java/fr/free/nrw/commons/nearby/NearbyMapFragment.java

+9
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
import com.mapbox.mapboxsdk.maps.MapView;
4545
import com.mapbox.mapboxsdk.maps.MapboxMap;
4646
import com.mapbox.mapboxsdk.maps.MapboxMapOptions;
47+
import com.mapbox.mapboxsdk.plugins.localization.LocalizationPlugin;
4748

4849
import java.lang.reflect.Type;
4950
import java.util.ArrayList;
@@ -528,6 +529,14 @@ private void setupMapView(Bundle savedInstanceState) {
528529
// create map
529530
mapView.onCreate(savedInstanceState);
530531
mapView.getMapAsync(mapboxMap -> {
532+
LocalizationPlugin localizationPlugin = new LocalizationPlugin(mapView, mapboxMap);
533+
534+
try {
535+
localizationPlugin.matchMapLanguageWithDeviceDefault();
536+
} catch (RuntimeException exception) {
537+
Timber.d(exception.toString());
538+
}
539+
531540
NearbyMapFragment.this.mapboxMap = mapboxMap;
532541
addMapMovementListeners();
533542
updateMapSignificantlyForCurrentLocation();

0 commit comments

Comments
 (0)