Skip to content

Fix #5182 Switch From Mapbox to MapLibre #5184

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ dependencies {
implementation 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.github.pedrovgs:renderers:3.3.3'
implementation 'com.mapbox.mapboxsdk:mapbox-android-sdk:9.2.1'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-localization-v9:0.12.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-plugin-scalebar-v9:0.5.0'
implementation 'com.mapbox.mapboxsdk:mapbox-android-telemetry:7.0.0'
implementation "org.maplibre.gl:android-sdk:$MAPLIBRE_VERSION"
implementation 'org.maplibre.gl:android-plugin-scalebar-v9:1.0.0'

implementation 'com.jakewharton.timber:timber:4.7.1'
implementation 'com.github.deano2390:MaterialShowcaseView:1.2.0'
implementation 'com.dinuscxj:circleprogressbar:1.1.1'
implementation 'com.karumi:dexter:5.0.0'
Expand Down Expand Up @@ -246,6 +246,8 @@ android {

configurations.all {
resolutionStrategy.force 'androidx.annotation:annotation:1.1.0'
resolutionStrategy.force 'com.jakewharton.timber:timber:4.7.1'
resolutionStrategy.force 'androidx.fragment:fragment:1.3.6'
exclude module: 'okhttp-ws'
}
flavorDimensions 'tier'
Expand Down
17 changes: 2 additions & 15 deletions app/src/main/java/fr/free/nrw/commons/CommonsApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.facebook.imagepipeline.core.ImagePipeline;
import com.facebook.imagepipeline.core.ImagePipelineConfig;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.WellKnownTileServer;
import fr.free.nrw.commons.auth.SessionManager;
import fr.free.nrw.commons.bookmarks.items.BookmarkItemsDao.Table;
import fr.free.nrw.commons.bookmarks.locations.BookmarkLocationsDao;
Expand Down Expand Up @@ -53,7 +54,6 @@
import java.util.Set;
import javax.inject.Inject;
import javax.inject.Named;
import leakcanary.ObjectWatcher;
import org.acra.ACRA;
import org.acra.annotation.AcraCore;
import org.acra.annotation.AcraDialog;
Expand Down Expand Up @@ -121,8 +121,6 @@ public class CommonsApplication extends MultiDexApplication {
* Constants End
*/

private ObjectWatcher objectWatcher;

private static CommonsApplication INSTANCE;

public static CommonsApplication getInstance() {
Expand Down Expand Up @@ -152,7 +150,7 @@ public void onCreate() {

INSTANCE = this;
ACRA.init(this);
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token));
Mapbox.getInstance(this, getString(R.string.mapbox_commons_app_token), WellKnownTileServer.Mapbox);

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

/**
* Provides a way to get member objectWatcher
*
* @param context Application context
* @return application member objectWatcher
*/
public static ObjectWatcher getObjectWatcher(Context context) {
CommonsApplication application = (CommonsApplication) context.getApplicationContext();
return application.objectWatcher;
}

/**
* clears data of current application
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,18 @@
import androidx.lifecycle.Observer;
import androidx.lifecycle.ViewModelProvider;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.mapbox.android.core.location.LocationEngineCallback;
import com.mapbox.android.core.location.LocationEngineResult;
import com.mapbox.android.core.permissions.PermissionsManager;
import com.mapbox.geojson.Point;
import com.mapbox.mapboxsdk.camera.CameraPosition;
import com.mapbox.mapboxsdk.camera.CameraPosition.Builder;
import com.mapbox.mapboxsdk.camera.CameraUpdateFactory;
import com.mapbox.mapboxsdk.geometry.LatLng;
import com.mapbox.mapboxsdk.location.LocationComponent;
import com.mapbox.mapboxsdk.location.LocationComponentActivationOptions;
import com.mapbox.mapboxsdk.location.engine.LocationEngineCallback;
import com.mapbox.mapboxsdk.location.engine.LocationEngineResult;
import com.mapbox.mapboxsdk.location.modes.CameraMode;
import com.mapbox.mapboxsdk.location.modes.RenderMode;
import com.mapbox.mapboxsdk.location.permissions.PermissionsManager;
import com.mapbox.mapboxsdk.maps.MapView;
import com.mapbox.mapboxsdk.maps.MapboxMap;
import com.mapbox.mapboxsdk.maps.MapboxMap.OnCameraIdleListener;
Expand Down Expand Up @@ -142,9 +142,9 @@ public class LocationPickerActivity extends BaseActivity implements OnMapReadyCa

@Override
protected void onCreate(@Nullable final Bundle savedInstanceState) {
getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
super.onCreate(savedInstanceState);

getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.hide();
Expand Down Expand Up @@ -194,7 +194,7 @@ private void addCredits() {
* Clicking back button destroy locationPickerActivity
*/
private void addBackButtonListener() {
final ImageView backButton = findViewById(R.id.mapbox_place_picker_toolbar_back_button);
final ImageView backButton = findViewById(R.id.maplibre_place_picker_toolbar_back_button);
backButton.setOnClickListener(view -> finish());
}

Expand Down Expand Up @@ -238,7 +238,7 @@ private void getToolbarUI() {
@Override
public void onMapReady(final MapboxMap mapboxMap) {
this.mapboxMap = mapboxMap;
mapboxMap.setStyle(Style.MAPBOX_STREETS, this::onStyleLoaded);
mapboxMap.setStyle(Style.getPredefinedStyle("Streets"), this::onStyleLoaded);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.inject.Inject
*/
class CustomSelectorViewModelFactory @Inject constructor(val context: Context,val imageFileLoader: ImageFileLoader) : ViewModelProvider.Factory {

override fun<CustomSelectorViewModel: ViewModel?> create(modelClass: Class<CustomSelectorViewModel>) : CustomSelectorViewModel {
override fun<CustomSelectorViewModel: ViewModel> create(modelClass: Class<CustomSelectorViewModel>) : CustomSelectorViewModel {
return CustomSelectorViewModel(context,imageFileLoader) as CustomSelectorViewModel
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@
import io.reactivex.Observable;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import java.util.Arrays;
import java.util.List;
import javax.inject.Inject;
import javax.inject.Named;
Expand Down Expand Up @@ -189,7 +190,8 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
mapBox = mapBoxMap;
initViews();
presenter.setActionListeners(applicationKvStore);
mapBoxMap.setStyle(isDarkTheme? Style.DARK:Style.OUTDOORS, style -> {
mapBoxMap.setStyle(isDarkTheme? Style.getPredefinedStyle("Dark"):
Style.getPredefinedStyle("Outdoors"), style -> {
final UiSettings uiSettings = mapBoxMap.getUiSettings();
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
uiSettings.setCompassMargins(12, 0, 0, 24);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ public void onViewCreated(@NonNull final View view, @Nullable final Bundle saved
initViews();
presenter.setActionListeners(applicationKvStore);
initNearbyFilter();
mapBoxMap.setStyle(isDarkTheme?Style.DARK:Style.OUTDOORS, style -> {
mapBoxMap.setStyle(isDarkTheme?Style.getPredefinedStyle("Dark"):Style.getPredefinedStyle("Outdoors"), style -> {
final UiSettings uiSettings = mapBoxMap.getUiSettings();
uiSettings.setCompassGravity(Gravity.BOTTOM | Gravity.LEFT);
uiSettings.setCompassMargins(12, 0, 0, 24);
Expand Down
1 change: 0 additions & 1 deletion app/src/main/java/fr/free/nrw/commons/settings/Prefs.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ public class Prefs {
public static final String DESCRIPTION_LANGUAGE = "languageDescription";
public static final String APP_UI_LANGUAGE = "appUiLanguage";
public static final String KEY_THEME_VALUE = "appThemePref";
public static final String TELEMETRY_PREFERENCE = "telemetryPref";

public static class Licenses {
public static final String CC_BY_SA_3 = "CC BY-SA 3.0";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import com.karumi.dexter.listener.PermissionGrantedResponse;
import com.karumi.dexter.listener.single.BasePermissionListener;
import com.mapbox.mapboxsdk.Mapbox;
import com.mapbox.mapboxsdk.maps.TelemetryDefinition;
import fr.free.nrw.commons.R;
import fr.free.nrw.commons.Utils;
import fr.free.nrw.commons.campaigns.CampaignView;
Expand Down Expand Up @@ -161,21 +160,6 @@ public boolean onPreferenceClick(Preference preference) {
findPreference(CampaignView.CAMPAIGNS_DEFAULT_PREFERENCE).setEnabled(false);
findPreference("managed_exif_tags").setEnabled(false);
}

// Opting out of telemetry due to app's privacy policy
telemetryOptInOut(false);
defaultKvStore.putBoolean(Prefs.TELEMETRY_PREFERENCE,false);
}

/**
* Opt in or out of MapBox telemetry
* @param shouldOptIn
*/
private void telemetryOptInOut(boolean shouldOptIn){
TelemetryDefinition telemetry = Mapbox.getTelemetry();
if (telemetry != null) {
telemetry.setUserTelemetryRequestState(shouldOptIn);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ public void bind(int position) {
if (position == 0) {
removeButton.setVisibility(View.GONE);
captionInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
captionInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
captionInputLayout.setEndIconDrawable(R.drawable.maplibre_info_icon_default);
captionInputLayout.setEndIconOnClickListener(v ->
callback.showAlert(R.string.media_detail_caption, R.string.caption_info));
Objects.requireNonNull(captionInputLayout.getEditText()).setFilters(new InputFilter[] {
new UploadMediaDetailInputFilter()
});

descInputLayout.setEndIconMode(TextInputLayout.END_ICON_CUSTOM);
descInputLayout.setEndIconDrawable(R.drawable.mapbox_info_icon_default);
descInputLayout.setEndIconDrawable(R.drawable.maplibre_info_icon_default);
descInputLayout.setEndIconOnClickListener(v ->
callback.showAlert(R.string.media_detail_description, R.string.description_info));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import androidx.core.app.NotificationManagerCompat
import androidx.work.CoroutineWorker
import androidx.work.Data
import androidx.work.WorkerParameters
import com.mapbox.mapboxsdk.plugins.localization.BuildConfig
import androidx.multidex.BuildConfig
import dagger.android.ContributesAndroidInjector
import fr.free.nrw.commons.CommonsApplication
import fr.free.nrw.commons.Media
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/mainBackground"
android:orientation="vertical">
<LinearLayout
android:id="@+id/toolbarLayout"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_notification.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/mainBackground">

<RelativeLayout
android:layout_width="match_parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_review.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/mainBackground">

<FrameLayout
android:id="@+id/mediaDetailContainer"
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="?attr/mainBackground"
android:orientation="vertical">
<LinearLayout
android:id="@+id/toolbarLayout"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/content_location_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
android:id="@+id/map_view"
android:layout_width="0dp"
android:layout_height="0dp"
app:mapbox_uiLogo="false"
app:maplibre_uiLogo="false"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/custom_selector_toolbar.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
android:id="@+id/toolbar_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
app:layout_constraintTop_toTopOf="parent">
app:layout_constraintTop_toTopOf="parent"
android:background="?attr/mainBackground">

<ImageButton
android:id="@+id/back"
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_achievements.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/drawer_layout"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/achievementBackground">

<ScrollView
android:layout_width="wrap_content"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/fragment_advance_query.xml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/reset"
android:textColor="@color/mapbox_blue"
android:textColor="@color/maplibre_blue"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toLeftOf="@id/btn_apply" />

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/fragment_leaderboard.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/achievementBackground">

<LinearLayout
android:id="@+id/filters"
Expand Down
5 changes: 3 additions & 2 deletions app/src/main/res/layout/fragment_media_license.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_marginBottom="@dimen/activity_margin_horizontal"
android:padding="@dimen/standard_gap">
android:padding="@dimen/standard_gap"
android:background="?attr/achievementBackground">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand All @@ -32,7 +33,7 @@
android:id="@+id/tooltip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/mapbox_info_icon_default"/>
android:src="@drawable/maplibre_info_icon_default"/>
</LinearLayout>

<TextView
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="?attr/achievementBackground">

<com.github.chrisbanes.photoview.PhotoView
android:id="@+id/backgroundImage"
Expand Down Expand Up @@ -50,7 +51,7 @@
android:id="@+id/tooltip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/mapbox_info_icon_default"/>
android:src="@drawable/maplibre_info_icon_default"/>
</LinearLayout>

<androidx.appcompat.widget.AppCompatImageButton
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/toolbar_location_picker.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
app:layout_constraintTop_toBottomOf="@+id/location_picker_toolbar_primary_text_view" />

<ImageView
android:id="@+id/mapbox_place_picker_toolbar_back_button"
android:id="@+id/maplibre_place_picker_toolbar_back_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/upload_categories_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
android:id="@+id/tooltip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/mapbox_info_icon_default" />
android:src="@drawable/maplibre_info_icon_default" />
</LinearLayout>

<TextView
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/upload_depicts_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
android:id="@+id/tooltip"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@drawable/mapbox_info_icon_default" />
android:src="@drawable/maplibre_info_icon_default" />
</LinearLayout>

<TextView
Expand Down
Loading