Skip to content

Commit 8f8dcc0

Browse files
Fix commons-app#5182 Switch From Mapbox to MapLibre (commons-app#5184)
* Fix commons-app#5182 Switch From Mapbox to MapLibre * Fix commons-app#5182 Switch From Mapbox to MapLibre - Resolved requestFeature() issue * Fix commons-app#5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on two screens * Fix commons-app#5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on additional screens * Fix commons-app#5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on notification screen * Fix commons-app#5182 Switch From Mapbox to MapLibre - Test errors
1 parent 2989b73 commit 8f8dcc0

27 files changed

+63
-77
lines changed

app/build.gradle

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ dependencies {
3838
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
3939
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
4040
implementation 'com.github.pedrovgs:renderers:3.3.3'
41-
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1'
42-
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0'
43-
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v9:0.5.0'
44-
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:7.0.0'
41+
implementation "org.maplibre.gl:android-sdk:$MAPLIBRE_VERSION"
42+
implementation 'org.maplibre.gl:android-plugin-scalebar-v9:1.0.0'
43+
44+
implementation 'com.jakewharton.timber:timber:4.7.1'
4545
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
4646
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
4747
implementation 'com.karumi:dexter:5.0.0'
@@ -246,6 +246,8 @@ android {
246246

247247
configurations.all {
248248
resolutionStrategy.force 'androidx.annotation:annotation:1.1.0'
249+
resolutionStrategy.force 'com.jakewharton.timber:timber:4.7.1'
250+
resolutionStrategy.force 'androidx.fragment:fragment:1.3.6'
249251
exclude module: 'okhttp-ws'
250252
}
251253
flavorDimensions 'tier'

app/src/main/java/fr/free/nrw/commons/CommonsApplication.java

+2-15
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import com.facebook.imagepipeline.core.ImagePipeline;
2525
import com.facebook.imagepipeline.core.ImagePipelineConfig;
2626
import com.mapbox.mapboxsdk.Mapbox;
27+
import com.mapbox.mapboxsdk.WellKnownTileServer;
2728
import fr.free.nrw.commons.auth.SessionManager;
2829
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao.Table;
2930
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
@@ -53,7 +54,6 @@
5354
import java.util.Set;
5455
import javax.inject.Inject;
5556
import javax.inject.Named;
56-
import leakcanary.ObjectWatcher;
5757
import org.acra.ACRA;
5858
import org.acra.annotation.AcraCore;
5959
import org.acra.annotation.AcraDialog;
@@ -121,8 +121,6 @@ public class CommonsApplication extends MultiDexApplication {
121121
* Constants End
122122
*/
123123

124-
private ObjectWatcher objectWatcher;
125-
126124
private static CommonsApplication INSTANCE;
127125

128126
public static CommonsApplication getInstance() {
@@ -152,7 +150,7 @@ public void onCreate() {
152150

153151
INSTANCE = this;
154152
ACRA.init(this);
155-
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token));
153+
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token), WellKnownTileServer.Mapbox);
156154

157155
ApplicationlessInjection
158156
.getInstance(this)
@@ -268,17 +266,6 @@ public String getUserAgent() {
268266
+ " (https://mediawiki.org/wiki/Apps/Commons) Android/" + Build.VERSION.RELEASE;
269267
}
270268

271-
/**
272-
* Provides a way to get member objectWatcher
273-
*
274-
* @param context Application context
275-
* @return application member objectWatcher
276-
*/
277-
public static ObjectWatcher getObjectWatcher(Context context) {
278-
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
279-
return application.objectWatcher;
280-
}
281-
282269
/**
283270
* clears data of current application
284271
*

app/src/main/java/fr/free/nrw/commons/LocationPicker/LocationPickerActivity.java

+6-6
Original file line numberDiff line numberDiff line change
@@ -31,18 +31,18 @@
3131
import androidx.lifecycle.Observer;
3232
import androidx.lifecycle.ViewModelProvider;
3333
import com.google.android.material.floatingactionbutton.FloatingActionButton;
34-
import com.mapbox.android.core.location.LocationEngineCallback;
35-
import com.mapbox.android.core.location.LocationEngineResult;
36-
import com.mapbox.android.core.permissions.PermissionsManager;
3734
import com.mapbox.geojson.Point;
3835
import com.mapbox.mapboxsdk.camera.CameraPosition;
3936
import com.mapbox.mapboxsdk.camera.CameraPosition.Builder;
4037
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
4138
import com.mapbox.mapboxsdk.geometry.LatLng;
4239
import com.mapbox.mapboxsdk.location.LocationComponent;
4340
import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions;
41+
import com.mapbox.mapboxsdk.location.engine.LocationEngineCallback;
42+
import com.mapbox.mapboxsdk.location.engine.LocationEngineResult;
4443
import com.mapbox.mapboxsdk.location.modes.CameraMode;
4544
import com.mapbox.mapboxsdk.location.modes.RenderMode;
45+
import com.mapbox.mapboxsdk.location.permissions.PermissionsManager;
4646
import com.mapbox.mapboxsdk.maps.MapView;
4747
import com.mapbox.mapboxsdk.maps.MapboxMap;
4848
import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
@@ -142,9 +142,9 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa
142142

143143
@Override
144144
protected void onCreate(@Nullable final Bundle savedInstanceState) {
145+
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
145146
super.onCreate(savedInstanceState);
146147

147-
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
148148
final ActionBar actionBar = getSupportActionBar();
149149
if (actionBar != null) {
150150
actionBar.hide();
@@ -194,7 +194,7 @@ private void addCredits() {
194194
* Clicking back button destroy locationPickerActivity
195195
*/
196196
private void addBackButtonListener() {
197-
final ImageView backButton = findViewById(R.id.mapbox_place_picker_toolbar_back_button);
197+
final ImageView backButton = findViewById(R.id.maplibre_place_picker_toolbar_back_button);
198198
backButton.setOnClickListener(view -> finish());
199199
}
200200

@@ -238,7 +238,7 @@ private void getToolbarUI() {
238238
@Override
239239
public void onMapReady(final MapboxMap mapboxMap) {
240240
this.mapboxMap = mapboxMap;
241-
mapboxMap.setStyle(Style.MAPBOX_STREETS, this::onStyleLoaded);
241+
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), this::onStyleLoaded);
242242
}
243243

244244
/**

app/src/main/java/fr/free/nrw/commons/customselector/ui/selector/CustomSelectorViewModelFactory.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import javax.inject.Inject
1010
*/
1111
class CustomSelectorViewModelFactory @Inject constructor(val context: Context,val imageFileLoader: ImageFileLoader) : ViewModelProvider.Factory {
1212

13-
override fun<CustomSelectorViewModel: ViewModel?> create(modelClass: Class<CustomSelectorViewModel>) : CustomSelectorViewModel {
13+
override fun<CustomSelectorViewModel: ViewModel> create(modelClass: Class<CustomSelectorViewModel>) : CustomSelectorViewModel {
1414
return CustomSelectorViewModel(context,imageFileLoader) as CustomSelectorViewModel
1515
}
1616

app/src/main/java/fr/free/nrw/commons/explore/map/ExploreMapFragment.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
import io.reactivex.Observable;
8282
import io.reactivex.android.schedulers.AndroidSchedulers;
8383
import io.reactivex.schedulers.Schedulers;
84+
import java.util.Arrays;
8485
import java.util.List;
8586
import javax.inject.Inject;
8687
import javax.inject.Named;
@@ -189,7 +190,8 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
189190
mapBox = mapBoxMap;
190191
initViews();
191192
presenter.setActionListeners(applicationKvStore);
192-
mapBoxMap.setStyle(isDarkTheme? Style.DARK:Style.OUTDOORS, style -> {
193+
mapBoxMap.setStyle(isDarkTheme? Style.getPredefinedStyle("Dark"):
194+
Style.getPredefinedStyle("Outdoors"), style -> {
193195
final UiSettings uiSettings = mapBoxMap.getUiSettings();
194196
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
195197
uiSettings.setCompassMargins(12, 0, 0, 24);

app/src/main/java/fr/free/nrw/commons/nearby/fragments/NearbyParentFragment.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
316316
initViews();
317317
presenter.setActionListeners(applicationKvStore);
318318
initNearbyFilter();
319-
mapBoxMap.setStyle(isDarkTheme?Style.DARK:Style.OUTDOORS, style -> {
319+
mapBoxMap.setStyle(isDarkTheme?Style.getPredefinedStyle("Dark"):Style.getPredefinedStyle("Outdoors"), style -> {
320320
final UiSettings uiSettings = mapBoxMap.getUiSettings();
321321
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
322322
uiSettings.setCompassMargins(12, 0, 0, 24);

app/src/main/java/fr/free/nrw/commons/settings/Prefs.java

-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ public class Prefs {
1010
public static final String DESCRIPTION_LANGUAGE = "languageDescription";
1111
public static final String APP_UI_LANGUAGE = "appUiLanguage";
1212
public static final String KEY_THEME_VALUE = "appThemePref";
13-
public static final String TELEMETRY_PREFERENCE = "telemetryPref";
1413

1514
public static class Licenses {
1615
public static final String CC_BY_SA_3 = "CC BY-SA 3.0";

app/src/main/java/fr/free/nrw/commons/settings/SettingsFragment.java

-16
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
import com.karumi.dexter.listener.PermissionGrantedResponse;
3232
import com.karumi.dexter.listener.single.BasePermissionListener;
3333
import com.mapbox.mapboxsdk.Mapbox;
34-
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
3534
import fr.free.nrw.commons.R;
3635
import fr.free.nrw.commons.Utils;
3736
import fr.free.nrw.commons.campaigns.CampaignView;
@@ -161,21 +160,6 @@ public boolean onPreferenceClick(Preference preference) {
161160
findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false);
162161
findPreference("managed_exif_tags").setEnabled(false);
163162
}
164-
165-
// Opting out of telemetry due to app's privacy policy
166-
telemetryOptInOut(false);
167-
defaultKvStore.putBoolean(Prefs.TELEMETRY_PREFERENCE,false);
168-
}
169-
170-
/**
171-
* Opt in or out of MapBox telemetry
172-
* @param shouldOptIn
173-
*/
174-
private void telemetryOptInOut(boolean shouldOptIn){
175-
TelemetryDefinition telemetry = Mapbox.getTelemetry();
176-
if (telemetry != null) {
177-
telemetry.setUserTelemetryRequestState(shouldOptIn);
178-
}
179163
}
180164

181165
@Override

app/src/main/java/fr/free/nrw/commons/upload/UploadMediaDetailAdapter.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,15 @@ public void bind(int position) {
174174
if (position == 0) {
175175
removeButton.setVisibility(View.GONE);
176176
captionInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
177-
captionInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
177+
captionInputLayout.setEndIconDrawable(R.drawable.maplibre_info_icon_default);
178178
captionInputLayout.setEndIconOnClickListener(v ->
179179
callback.showAlert(R.string.media_detail_caption, R.string.caption_info));
180180
Objects.requireNonNull(captionInputLayout.getEditText()).setFilters(new InputFilter[] {
181181
new UploadMediaDetailInputFilter()
182182
});
183183

184184
descInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
185-
descInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
185+
descInputLayout.setEndIconDrawable(R.drawable.maplibre_info_icon_default);
186186
descInputLayout.setEndIconOnClickListener(v ->
187187
callback.showAlert(R.string.media_detail_description, R.string.description_info));
188188

app/src/main/java/fr/free/nrw/commons/upload/worker/UploadWorker.kt

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import androidx.core.app.NotificationManagerCompat
1111
import androidx.work.CoroutineWorker
1212
import androidx.work.Data
1313
import androidx.work.WorkerParameters
14-
import com.mapbox.mapboxsdk.plugins.localization.BuildConfig
14+
import androidx.multidex.BuildConfig
1515
import dagger.android.ContributesAndroidInjector
1616
import fr.free.nrw.commons.CommonsApplication
1717
import fr.free.nrw.commons.Media

app/src/main/res/layout/activity_about.xml

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
android:id="@+id/drawer_layout"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:background="?attr/mainBackground"
78
android:orientation="vertical">
89
<LinearLayout
910
android:id="@+id/toolbarLayout"

app/src/main/res/layout/activity_notification.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/drawer_layout"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:background="?attr/mainBackground">
89

910
<RelativeLayout
1011
android:layout_width="match_parent"

app/src/main/res/layout/activity_review.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/drawer_layout"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:background="?attr/mainBackground">
89

910
<FrameLayout
1011
android:id="@+id/mediaDetailContainer"

app/src/main/res/layout/activity_settings.xml

+1
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
android:id="@+id/drawer_layout"
66
android:layout_width="match_parent"
77
android:layout_height="match_parent"
8+
android:background="?attr/mainBackground"
89
android:orientation="vertical">
910
<LinearLayout
1011
android:id="@+id/toolbarLayout"

app/src/main/res/layout/content_location_picker.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
android:id="@+id/map_view"
3737
android:layout_width="0dp"
3838
android:layout_height="0dp"
39-
app:mapbox_uiLogo="false"
39+
app:maplibre_uiLogo="false"
4040
app:layout_constraintBottom_toBottomOf="parent"
4141
app:layout_constraintEnd_toEndOf="parent"
4242
app:layout_constraintStart_toStartOf="parent"

app/src/main/res/layout/custom_selector_toolbar.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
android:id="@+id/toolbar_layout"
77
android:layout_width="match_parent"
88
android:layout_height="?attr/actionBarSize"
9-
app:layout_constraintTop_toTopOf="parent">
9+
app:layout_constraintTop_toTopOf="parent"
10+
android:background="?attr/mainBackground">
1011

1112
<ImageButton
1213
android:id="@+id/back"

app/src/main/res/layout/fragment_achievements.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:id="@+id/drawer_layout"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:background="?attr/achievementBackground">
89

910
<ScrollView
1011
android:layout_width="wrap_content"

app/src/main/res/layout/fragment_advance_query.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
android:layout_width="wrap_content"
4848
android:layout_height="wrap_content"
4949
android:text="@string/reset"
50-
android:textColor="@color/mapbox_blue"
50+
android:textColor="@color/maplibre_blue"
5151
app:layout_constraintBottom_toBottomOf="parent"
5252
app:layout_constraintRight_toLeftOf="@id/btn_apply" />
5353

app/src/main/res/layout/fragment_leaderboard.xml

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:android="http://schemas.android.com/apk/res/android"
55
xmlns:app="http://schemas.android.com/apk/res-auto"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:background="?attr/achievementBackground">
89

910
<LinearLayout
1011
android:id="@+id/filters"

app/src/main/res/layout/fragment_media_license.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
android:layout_height="match_parent"
66
xmlns:app="http://schemas.android.com/apk/res-auto"
77
android:layout_marginBottom="@dimen/activity_margin_horizontal"
8-
android:padding="@dimen/standard_gap">
8+
android:padding="@dimen/standard_gap"
9+
android:background="?attr/achievementBackground">
910
<LinearLayout
1011
android:layout_width="match_parent"
1112
android:layout_height="match_parent"
@@ -32,7 +33,7 @@
3233
android:id="@+id/tooltip"
3334
android:layout_width="wrap_content"
3435
android:layout_height="match_parent"
35-
android:src="@drawable/mapbox_info_icon_default"/>
36+
android:src="@drawable/maplibre_info_icon_default"/>
3637
</LinearLayout>
3738

3839
<TextView

app/src/main/res/layout/fragment_upload_media_detail_fragment.xml

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
xmlns:app="http://schemas.android.com/apk/res-auto"
55
xmlns:tools="http://schemas.android.com/tools"
66
android:layout_width="match_parent"
7-
android:layout_height="match_parent">
7+
android:layout_height="match_parent"
8+
android:background="?attr/achievementBackground">
89

910
<com.github.chrisbanes.photoview.PhotoView
1011
android:id="@+id/backgroundImage"
@@ -50,7 +51,7 @@
5051
android:id="@+id/tooltip"
5152
android:layout_width="wrap_content"
5253
android:layout_height="match_parent"
53-
android:src="@drawable/mapbox_info_icon_default"/>
54+
android:src="@drawable/maplibre_info_icon_default"/>
5455
</LinearLayout>
5556

5657
<androidx.appcompat.widget.AppCompatImageButton

app/src/main/res/layout/toolbar_location_picker.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
app:layout_constraintTop_toBottomOf="@+id/location_picker_toolbar_primary_text_view" />
3838

3939
<ImageView
40-
android:id="@+id/mapbox_place_picker_toolbar_back_button"
40+
android:id="@+id/maplibre_place_picker_toolbar_back_button"
4141
android:layout_width="wrap_content"
4242
android:layout_height="wrap_content"
4343
android:layout_marginStart="16dp"

app/src/main/res/layout/upload_categories_fragment.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
android:id="@+id/tooltip"
3636
android:layout_width="wrap_content"
3737
android:layout_height="match_parent"
38-
android:src="@drawable/mapbox_info_icon_default" />
38+
android:src="@drawable/maplibre_info_icon_default" />
3939
</LinearLayout>
4040

4141
<TextView

app/src/main/res/layout/upload_depicts_fragment.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
android:id="@+id/tooltip"
4141
android:layout_width="wrap_content"
4242
android:layout_height="match_parent"
43-
android:src="@drawable/mapbox_info_icon_default" />
43+
android:src="@drawable/maplibre_info_icon_default" />
4444
</LinearLayout>
4545

4646
<TextView

0 commit comments

Comments
 (0)