Skip to content
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

Fix #5182 Switch From Mapbox to MapLibre #5184

Merged
merged 6 commits into from
Mar 31, 2023

Conversation

kartikaykaushik14
Copy link
Contributor

@kartikaykaushik14 kartikaykaushik14 commented Mar 21, 2023

Description (required)

Fixes #5182

What changes did you make and why?

Migrated from Mapbox to MapLibre

Tests performed (required)

Tested {build variant, e.g. ProdDebug} on {name of device or emulator} with API level {API level}.

Screenshots (for UI changes only)

Need help? See https://support.google.com/android/answer/9075928


Note: Please ensure that you have read CONTRIBUTING.md if this is your first pull request.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks great!
I will try to test tomorrow.

@nicolas-raoul
Copy link
Member

Meanwhile any idea why the unit tests testOnMapReady and testShowDetail fail?

@nicolas-raoul
Copy link
Member

I am getting this crash:

03-23 19:49:07.328 26593 26593 E AndroidRuntime: java.lang.IllegalArgumentException: Could not find layer Outdoor
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.Style.getPredefinedStyle(Style.java:1430)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at fr.free.nrw.commons.nearby.fragments.NearbyParentFragment.lambda$onViewCreated$2$NearbyParentFragment(NearbyParentFragment.java:319)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at fr.free.nrw.commons.nearby.fragments.-$$Lambda$NearbyParentFragment$LW_iO-h3e6OvgddLCQ2oE4vXWAc.onMapReady(Unknown Source:2)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.MapView$MapCallback.onMapReady(MapView.java:1322)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.MapView$MapCallback.initialised(MapView.java:1308)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.MapView.initialiseMap(MapView.java:203)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.MapView.access$800(MapView.java:65)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.mapbox.mapboxsdk.maps.MapView$6.run(MapView.java:355)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at android.os.Handler.handleCallback(Handler.java:942)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:99)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7884)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
03-23 19:49:07.328 26593 26593 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

@nicolas-raoul
Copy link
Member

Deleting the app's data solved the crash.
Maybe a kind of migraton is needed?

@nicolas-raoul
Copy link
Member

I can consistently crash by switching from dark mode to light mode in the app's settings menu and coming back to the map. Can you reproduce?

@kartikaykaushik14
Copy link
Contributor Author

kartikaykaushik14 commented Mar 23, 2023

@nicolas-raoul I have identified the root cause for issue "Could not find layer Outdoor". Pushing a new patch with these changes

Copy link
Contributor

@Ayan-10 Ayan-10 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's having some issues with the dark UI. Screenshots are attached below.

Screenshot_2023-03-24-01-17-26-54_d5db3f3edc380047609fe9c266f7c566
Screenshot_2023-03-24-01-17-08-67_d5db3f3edc380047609fe9c266f7c566
Screenshot_2023-03-24-01-17-17-84_d5db3f3edc380047609fe9c266f7c566

@kartikaykaushik14
Copy link
Contributor Author

@Ayan-10 I'm able to reproduce the issue. Still trying to figure out what could be the root cause since I'm using Mapbox's predefined style for "Dark" just like "Outdoors" and "Streets".

MapLibre offers us the option to use Mapbox Configuration so I continued with it to maintain consistency. I checked the URL being called for the Dark Style and it is "mapbox://styles/mapbox/light-v10" which is consistent with that being called in the case of mapbox-sdk.

@nicolas-raoul
Copy link
Member

Great, no more crash in Contributions now.

However, in addition to the visual issues reported by Ayan, I observe a crash in Explore: tap any picture, then tap the pen icon at the right of the latitude/longitude:

03-24 14:56:06.218 27280 27280 E AndroidRuntime: java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.free.nrw.commons/fr.free.nrw.commons.LocationPicker.LocationPickerActivity}: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3641)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3778)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:101)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:138)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:95)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2303)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.os.Handler.dispatchMessage(Handler.java:106)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.os.Looper.loopOnce(Looper.java:201)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.os.Looper.loop(Looper.java:288)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.ActivityThread.main(ActivityThread.java:7884)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at java.lang.reflect.Method.invoke(Native Method)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: Caused by: android.util.AndroidRuntimeException: requestFeature() must be called before adding content
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at com.android.internal.policy.PhoneWindow.requestFeature(PhoneWindow.java:402)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at fr.free.nrw.commons.LocationPicker.LocationPickerActivity.onCreate(LocationPickerActivity.java:147)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:8341)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.Activity.performCreate(Activity.java:8320)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1417)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3622)
03-24 14:56:06.218 27280 27280 E AndroidRuntime: 	... 12 more

If possible, would you mind using normal push instead of force-push, unless really necessary? Thanks! :-)

@kartikaykaushik14
Copy link
Contributor Author

@nicolas-raoul Could you please check if the issue still persists?

Meanwhile, I'm trying to fix the dark mode issue.

@Ayan-10
Copy link
Contributor

Ayan-10 commented Mar 24, 2023

The crash is not occurring for me anymore.

@nicolas-raoul
Copy link
Member

No crash anymore indeed, thanks!

@kartikaykaushik14
Copy link
Contributor Author

@Ayan-10 I Just pushed some changes for the "About" and "Settings" screens on dark mode. Please let me know how to get to the 3rd screen with achievements and leaderboard. I can apply a similar fix and test.

@nicolas-raoul
Copy link
Member

To see achievements, you must be logged-in, tap the app's hamburger menu, then tap the cup icon with your usename at the top of the menu.

I will test this branch from now, thanks!

@nicolas-raoul
Copy link
Member

UI that appears bright in dark mode:

  • Achievements
  • Leaderboard (right tab next to achievements)
  • Review, also known as Peer Review, accessible from the hamburger menu
  • Background of the upload wizard, when the picture does not take the full space (not sure whether this works in master, so no need to worry if not related to your PR)

@nicolas-raoul
Copy link
Member

I guess you have found out that the app has two flavors, beta and prod, matching https://commons.wikimedia.beta.wmflabs.org and https://commons.wikimedia.org.
We usually use prod even for development, unless we need to perform test uploads.

@nicolas-raoul
Copy link
Member

nicolas-raoul commented Mar 28, 2023

Sorry I noticed a few more places with bright elements in dark mode:

Upload wizard license selection step:
Screenshot_20230328-165650

Upload wizard location selection step:
Screenshot_20230328-165607

Upload wizard first step:
Screenshot_20230328-165550

Custom picker:
Screenshot_20230328-165435

Hamburger menu → Feedback:
Screenshot_20230328-165311

Nearby location alert, it seems to have a bright border, if it also happens in master then feel free to ignore:
Screenshot_20230328-165251~2

Some of these screens are difficult to find, please let me know which ones you can't locate.

@kartikaykaushik14
Copy link
Contributor Author

kartikaykaushik14 commented Mar 29, 2023

  1. Upload Wizard Media License - Working on it
  2. Upload Wizard Location Selection Step - Looks the same in master
  3. Upload Wizard First Step - Working on it
  4. Custom Picker - Working on it
  5. Feedback - Looks the same in master
  6. Nearby Location Alert - Unable to verify this.

@nicolas-raoul
Copy link
Member

nicolas-raoul commented Mar 29, 2023

Thanks! I created a different issue for (2) and (5).

For (6) you can use the "Fake GPS" app or similar to put yourself in a place that has many Wikidata items, for instance right on the Eiffel Tower. The banner should then appear within a minute.

@kartikaykaushik14
Copy link
Contributor Author

For 6) I observed the screen on Master as below -

Screenshot 2023-03-29 at 11 19 42 AM

Meanwhile, I observed the same bug on the Notifications screen and resolved it.

Copy link
Member

@nicolas-raoul nicolas-raoul left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works as intended, in both light and dark mode.
Code looks great, maybe some Strings could be made into constants, but no blocker.
Thanks a lot for implementing this very important change!

@nicolas-raoul nicolas-raoul merged commit 8f8dcc0 into commons-app:master Mar 31, 2023
@kartikaykaushik14 kartikaykaushik14 deleted the bug#4994 branch March 31, 2023 00:46
nicolas-raoul pushed a commit that referenced this pull request Apr 3, 2023
* feedback dialog: fix black font in dark mode

* LocationPickerActivity: fix light map in dark mode

* Fix #5182 Switch From Mapbox to MapLibre (#5184)

* Fix #5182 Switch From Mapbox to MapLibre

* Fix #5182 Switch From Mapbox to MapLibre - Resolved requestFeature() issue

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on two screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on additional screens

* Fix #5182 Switch From Mapbox to MapLibre - Resolved dark mode issue on notification screen

* Fix #5182 Switch From Mapbox to MapLibre - Test errors

* fix issue #5015 - custom image selector not identifying photo location (#5190)

Co-authored-by: Siva <doodsiva@gmail.com>

* feedback dialog: fix black font in dark mode

* LocationPickerActivity: fix light map in dark mode

* LocationPicker: use predefined style based on device theme

* LocationPickerActivityTest: add additional target exception in catch block

* LocationPickerConstants: remove extra newline introduced

---------

Co-authored-by: Kartikay Kaushik <93285364+kartikaykaushik14@users.noreply.github.com>
Co-authored-by: Siva Subramaniam <112970189+siva-subramaniam-v@users.noreply.github.com>
Co-authored-by: Siva <doodsiva@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch from Mapbox to MapLibre
3 participants