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

Fixes #545 - Add support for campaigns #4423

Merged
merged 21 commits into from
Aug 18, 2021
Merged

Conversation

ashishkumar468
Copy link
Collaborator

@ashishkumar468 ashishkumar468 commented May 22, 2021

Description (required)
Query Wikidata to fetch monuments and show them in Nearby
Fixes #545

What changes did you make and why?

  • Add query for monuments
  • Make an API call to fetch monuments
  • Attach the list of monuments with nearby places response and render the monuments on the Map along with other nearby items

Tests performed (required)
Tested the build prodDebug on the local emulator.- Able to see monuments for location (50.9709677364145, 22.776031494140625)

Feature

  • Fetch/store and read from JSON for wiki data property of monuments based on the current location/country
  • Home Screen Banner to show WLM in on
  • Its Wiki Loves Monuments Month banner above NearbyMap
  • Nearby should show another filter option (WLM) to filter on/off monuments
  • Monuments should show up along with nearby pins on maps
  • If the monuments are not enabled: No API call should be made to fetch them. Currently, this is set to true by default, after testing it would be true for dates b/w 1st September to 31st October.
  • Tapping on the monument marker should show details similar to that of a nearby item and it should allow uploading pictures for that monument.
  • The caption and description should be pre-filled: Caption is the monument name and description is the monument-name + (address from P6375).
  • In the license selection screen, the user should be shown a message that is media is uploaded as a part of WLM.
  • Reverse Geo Code the coordinates to get the country code and use that in the media template
  • Append template for WLM along with the other templates.

Screenshots (for UI changes only)
image

@codecov-commenter
Copy link

Codecov Report

Merging #4423 (9a0b3bf) into master (b6ffe9f) will decrease coverage by 0.05%.
The diff coverage is 0.00%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4423      +/-   ##
============================================
- Coverage     10.34%   10.29%   -0.06%     
  Complexity      479      479              
============================================
  Files           342      342              
  Lines         13201    13269      +68     
  Branches       1083     1089       +6     
============================================
  Hits           1366     1366              
- Misses        11766    11834      +68     
  Partials         69       69              
Impacted Files Coverage Δ Complexity Δ
...fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...a/fr/free/nrw/commons/nearby/NearbyController.java 2.70% <0.00%> (-0.24%) 1.00 <0.00> (ø)
.../java/fr/free/nrw/commons/nearby/NearbyPlaces.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...rc/main/java/fr/free/nrw/commons/nearby/Place.java 15.85% <0.00%> (-0.61%) 4.00 <0.00> (ø)
...commons/nearby/fragments/NearbyParentFragment.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b6ffe9f...9a0b3bf. Read the comment docs.

@ashishkumar468 ashishkumar468 marked this pull request as ready for review July 8, 2021 18:02
- Show monuments in maps along with nearby
@ashishkumar468 ashishkumar468 self-assigned this Jul 10, 2021
@ashishkumar468 ashishkumar468 changed the title [WIP]Fixes #545 - Add support for campaigns Fixes #545 - Add support for campaigns Jul 10, 2021
@misaochan
Copy link
Member

misaochan commented Jul 12, 2021

Hi @ashishkumar468 ,

I have been trying to test this PR, but have encountered a few roadblocks. I am running a Samsung Galaxy S20 FE on Android 11.

  1. There is no WLM banner displayed - I know it's not September yet, but the campaign should be hardcoded to "active" during this testing period?
  2. So I access Nearby the usual way. As it is a fresh install, I am prompted for location permissions. I accept "While using the app". However the progress bar never stops loading - I attached a screenshot below. There is also an unmarshalling exception that may be related to this, attached logs below.
2021-07-12 18:50:45.491 15623-15623/fr.free.nrw.commons E/Parcel: Class not found when unmarshalling: com.google.android.gms.location.LocationResult
    java.lang.ClassNotFoundException: com.google.android.gms.location.LocationResult
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.os.Parcel.readParcelableCreator(Parcel.java:3350)
        at android.os.Parcel.readParcelable(Parcel.java:3284)
        at android.os.Parcel.readValue(Parcel.java:3186)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3579)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
        at android.os.BaseBundle.unparcel(BaseBundle.java:236)
        at android.os.BaseBundle.containsKey(BaseBundle.java:516)
        at android.content.Intent.hasExtra(Intent.java:8699)
        at com.mapbox.android.core.location.LocationEngineResult.hasResult(LocationEngineResult.java:107)
        at com.mapbox.android.core.location.LocationEngineResult.extractAndroidResult(LocationEngineResult.java:101)
        at com.mapbox.android.core.location.LocationEngineResult.extractResult(LocationEngineResult.java:92)
        at com.mapbox.android.telemetry.location.LocationUpdatesBroadcastReceiver.onReceive(LocationUpdatesBroadcastReceiver.java:35)
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666)
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8506)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.location.LocationResult" on path: DexPathList[[zip file "/data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/base.apk"],nativeLibraryDirectories=[/data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/lib/arm64, /data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:454) 
        at android.os.Parcel.readParcelableCreator(Parcel.java:3350) 
        at android.os.Parcel.readParcelable(Parcel.java:3284) 
        at android.os.Parcel.readValue(Parcel.java:3186) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3579) 
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:236) 
        at android.os.BaseBundle.containsKey(BaseBundle.java:516) 
        at android.content.Intent.hasExtra(Intent.java:8699) 
        at com.mapbox.android.core.location.LocationEngineResult.hasResult(LocationEngineResult.java:107) 
        at com.mapbox.android.core.location.LocationEngineResult.extractAndroidResult(LocationEngineResult.java:101) 
        at com.mapbox.android.core.location.LocationEngineResult.extractResult(LocationEngineResult.java:92) 
        at com.mapbox.android.telemetry.location.LocationUpdatesBroadcastReceiver.onReceive(LocationUpdatesBroadcastReceiver.java:35) 
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666) 
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:246) 
        at android.app.ActivityThread.main(ActivityThread.java:8506) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 
2021-07-12 18:50:45.491 15623-15623/fr.free.nrw.commons E/LocationUpdateReceiver: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.location.LocationResult
2021-07-12 18:50:50.713 15623-15623/fr.free.nrw.commons E/Parcel: Class not found when unmarshalling: com.google.android.gms.location.LocationResult
    java.lang.ClassNotFoundException: com.google.android.gms.location.LocationResult
        at java.lang.Class.classForName(Native Method)
        at java.lang.Class.forName(Class.java:454)
        at android.os.Parcel.readParcelableCreator(Parcel.java:3350)
        at android.os.Parcel.readParcelable(Parcel.java:3284)
        at android.os.Parcel.readValue(Parcel.java:3186)
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3579)
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292)
        at android.os.BaseBundle.unparcel(BaseBundle.java:236)
        at android.os.BaseBundle.containsKey(BaseBundle.java:516)
        at android.content.Intent.hasExtra(Intent.java:8699)
        at com.mapbox.android.core.location.LocationEngineResult.hasResult(LocationEngineResult.java:107)
        at com.mapbox.android.core.location.LocationEngineResult.extractAndroidResult(LocationEngineResult.java:101)
        at com.mapbox.android.core.location.LocationEngineResult.extractResult(LocationEngineResult.java:92)
        at com.mapbox.android.telemetry.location.LocationUpdatesBroadcastReceiver.onReceive(LocationUpdatesBroadcastReceiver.java:35)
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666)
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:246)
        at android.app.ActivityThread.main(ActivityThread.java:8506)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130)
     Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.gms.location.LocationResult" on path: DexPathList[[zip file "/data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/base.apk"],nativeLibraryDirectories=[/data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/lib/arm64, /data/app/~~RSmKKRT0IFSE8K51sZ8wag==/fr.free.nrw.commons-AneDxkbXOovvzM-4kZHYuw==/base.apk!/lib/arm64-v8a, /system/lib64, /system/system_ext/lib64]]
        at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
        at java.lang.Class.classForName(Native Method) 
        at java.lang.Class.forName(Class.java:454) 
        at android.os.Parcel.readParcelableCreator(Parcel.java:3350) 
        at android.os.Parcel.readParcelable(Parcel.java:3284) 
        at android.os.Parcel.readValue(Parcel.java:3186) 
        at android.os.Parcel.readArrayMapInternal(Parcel.java:3579) 
        at android.os.BaseBundle.initializeFromParcelLocked(BaseBundle.java:292) 
        at android.os.BaseBundle.unparcel(BaseBundle.java:236) 
        at android.os.BaseBundle.containsKey(BaseBundle.java:516) 
        at android.content.Intent.hasExtra(Intent.java:8699) 
        at com.mapbox.android.core.location.LocationEngineResult.hasResult(LocationEngineResult.java:107) 
        at com.mapbox.android.core.location.LocationEngineResult.extractAndroidResult(LocationEngineResult.java:101) 
        at com.mapbox.android.core.location.LocationEngineResult.extractResult(LocationEngineResult.java:92) 
        at com.mapbox.android.telemetry.location.LocationUpdatesBroadcastReceiver.onReceive(LocationUpdatesBroadcastReceiver.java:35) 
        at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0$LoadedApk$ReceiverDispatcher$Args(LoadedApk.java:1666) 
        at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2) 
        at android.os.Handler.handleCallback(Handler.java:938) 
        at android.os.Handler.dispatchMessage(Handler.java:99) 
        at android.os.Looper.loop(Looper.java:246) 
        at android.app.ActivityThread.main(ActivityThread.java:8506) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:602) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1130) 
2021-07-12 18:50:50.713 15623-15623/fr.free.nrw.commons E/LocationUpdateReceiver: android.os.BadParcelableException: ClassNotFoundException when unmarshalling: com.google.android.gms.location.LocationResult
  1. I cannot get any points to display at all, the progress bar just loads forever. I tried manually moving to my location on the map and tapping "search this area", but with the same result. Tried another area and same result. Tried switching between different activities, same result. Killing and restarting app, same result.

On the other hand, I just tried v3.0.2 Nearby and that works fine for me on the same device.

@ashishkumar468
Copy link
Collaborator Author

@misaochan I will look into it, for now can you try a different device. Also, you would need to enable the wlm from the settings.

@misaochan
Copy link
Member

Tried with emulator, Pixel 3a running Android 10, encountered the same issue. :/

@neslihanturan
Copy link
Collaborator

Thanks for the PR @ashishkumar468 :) I have tested it. At first the campaign setting was off but WLM setting was on. With these settings no campaign banner appeared and nearby loads forever (even pins didn't appear).
On my second attempt I made both campaign and WLM setting on. Then I was able to see the setting. Nearby pins loaded with no problem. However I don't see any pins with WLM logo even at the location that you shared. I didn't experience any crash. Also I recognized some UI issues that WLM logo on campaign doesn't fit, search this area button conflicts with it is WLM month notice.
image
image
image

@misaochan
Copy link
Member

misaochan commented Jul 14, 2021

Thanks for testing @neslihanturan !

@ashishkumar468 I was unaware that there were 2 separate settings. Aside from the issues Neslihan mentioned, I also think we should consolidate both into one setting - campaigns should automatically include WLM. If a separate flag is needed for testing WLM, I think we should just hardcode it to "on" for testing purposes for the time being.

Also, I think we all agreed that the WLM banner in Contributions should just utilize the existing design (for campaign cards), right? :) It is just the functionality that we are changing - if the user taps on the banner they should be brought to Nearby.

@misaochan
Copy link
Member

misaochan commented Jul 15, 2021

Tested again today with Neslihan's method (both campaign and WLM setting turned to on), it works for me! Will consolidate my feedback below with a checklist:

  • As mentioned by Neslihan, the UI of the Contributions card needs to change - use the old design and text, but send the user to Nearby when they tap on it. For reference, the design should be the same as the design implemented Show campaigns #2113 , and the text should be: "Wiki Loves Monuments 1 Sep - 31 Oct".

  • The banner in Nearby should say "It's Wiki Loves Monuments month!". There is a typo in the current banner. ;)

  • I am able to view monuments in my area! Great job @ashishkumar468 . :) However, if a monument overlaps with a "Needs Photos" pin, both pins are shown - in that case I think the Needs Photos pin should be hidden.

  • (Optional) Also, I understand that this is slightly out of scope, but with the addition of the WLM place state chip, the filter now takes up a large amount of screen real estate, see Screenshot 1. If possible, would be great to have a button that minimizes the card when tapped, similar to the "^" button in Step 1 of the upload process.

  • Unfortunately when I leave Nearby and go to Contributions, then back to Nearby, the same unmarshaling exception as above occurs and Nearby loads forever. In order to fix this I must kill the app and restart it. This happens every time I leave Nearby activity, without fail.

  • There seems to be an issue with the details displayed for all pins (both WLM and non-WLM), see Screenshot 2. The place details (after expanding the bottom sheet) only displays a repeat of the item name. For non-WLM pins this should follow the convention implemented at Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description #4390 , and for WLM pins this should display the address.

  • When uploading a monument, the description is prefilled again with only the monument name (see Screenshot 3). As discussed, for WLM monuments this should be monument-name + (address from P6375). For non-WLM uploads we should follow the convention at Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description #4390 .

  • I uploaded https://commons.wikimedia.org/wiki/File:New_Farm_Park_3.jpg . The template itself seems to work and it says "This image was uploaded as part of Wiki Loves Monuments 2021", nice! However, it also says:

English: No or incorrect country code indicated in the {{Wiki Loves Monuments 2021}} template
Deutsch: Kein oder fehlerhafer Ländercode in der {{Wiki Loves Monuments 2021}}-Vorlage angegeben
}}"

The summary says |1= AUS, which isn't the right ISO. We need the ISO2 code, not ISO3. Would https://developer.android.com/reference/java/util/Locale#getISOCountries() work?

As discussed, I would recommend using a sandbox "monument" for testing template additions, as suggested by @nicolas-raoul at #545 (comment) . @nicolas-raoul , do you know how we can add P1435 and also a location, to the sandbox Wikidata item that you mentioned? I'm not sure how to add Wikidata properties.

Screenshot 1:
Screenshot_20210715-180144_Commons

Screenshot 2:
Screenshot_20210715-180156_Commons

Screenshot 3:
Screenshot_20210715-181911_Commons

@nicolas-raoul
Copy link
Member

I added heritage designation and coordinate location statements to the sandbox Wikidata item using the + add statement button :-)

@misaochan
Copy link
Member

Thanks a lot @nicolas-raoul ! For some reason I didn't think to scroll all the way down... :)

@neslihanturan
Copy link
Collaborator

Hey @misaochan , I have tested it under Android 11 Nexus 6 device. Search this area button worked well and WLM markers appeared:
resim

… monuments - [P1435, P2186, P1459, P1460, P1216, P709, P718, P5694] 2. Append WikiData QID to descriptions template
<string name="display_monuments">Display monuments</string>
<string name="wlm_month_message">It\'s Wiki Loves Monuments month!</string>
<string name="learn_more">LEARN MORE</string>
<string name="wlm_campaign_title">Its WML season</string>
Copy link
Member

Choose a reason for hiding this comment

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

Should just say "Wiki Loves Monuments"

@misaochan
Copy link
Member

misaochan commented Aug 10, 2021

Tried testing again today on my real device, a few notes:

  • Cleaning the build has not solved my "Search this area" issue. So I cannot test for the union of other property types, as the ones near my place only use P1435. Hopefully @neslihanturan will be able to. (Hint: You just need to check both Ireland and Australia, as they use different properties - P2186 for Ireland and P1435 for Australia. You should be able to see WLM markers for both.). Edit: Managed to make it work on my emulator, and it seems to function as intended, but the map on my emulator has always had a strange rendering issue that makes it difficult to see the pins, so best to verify.
  • The QID addition works great!
  • The country template should be right but I am still getting the same error https://commons.wikimedia.org/wiki/File:Newstead_Gasworks_4.jpg#%7B%7Bint%3Afiledesc%7D%7D even after manually switching to a country that is actually on https://commons.wikimedia.org/wiki/Template:Wiki_Loves_Monuments_country_logos . Interestingly some countries like "ie" work, and others like "al" don't. I asked on mailing list, waiting for response.
  • These issues still exist:

There seems to be an issue with the details displayed for all pins (both WLM and non-WLM), see Screenshot 2. The place details (after expanding the bottom sheet) only displays a repeat of the item name. For non-WLM pins this should follow the convention implemented at Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description #4390 , and for WLM pins this should display the address.

When uploading a monument, the description is prefilled again with only the monument name (see Screenshot 3). As discussed, for WLM monuments this should be monument-name + (address from P6375). For non-WLM uploads we should follow the convention at Fix #4147 Pre-fill desc in Nearby uploads with Wikidata item's label + description #4390 .

Once we are done with testing (after this PR is merged), we need to:

  • Stop hardcoding the dates, only make everything appear from 1 Sep to 31 Oct. Since we have stopped auto-publishing alpha, I might actually do a release to alpha prior to this, so that alpha is always testable (but beta and production would only have the banner appear at the right time)

@neslihanturan
Copy link
Collaborator

Hey @misaochan , it worked for me with search this area for Ireland and Australia with pyhsical Android10 device. Here are screenshoots:
photo_2021-08-12_14-35-40
photo_2021-08-12_14-35-35

@ashishkumar468
Copy link
Collaborator Author

ashishkumar468 commented Aug 14, 2021

image

Hi @misaochan , the usual Nearby items, do show the pre-filled desc as they used to before. For the WLM pins, as I have mentioned before, the P6375 used for the "streetAddress" does not return anything for my location, attaching a sample response, and therefore that field in the details or in the Upload step is omitted.

Sharing a sample response for WLM query - https://gist.github.com/ashishkumar468/5d2eac4844d3c5c600de467e2558c6cb

As you can see the streetAddress property is empty.

@misaochan
Copy link
Member

misaochan commented Aug 16, 2021

Notes from discussions (on Zulip and mailing lists) and tests:

@misaochan
Copy link
Member

Made separate issues for everything else. Only thing pending for merge is "We have decided that due to the frequent lack of P6375, we will just use the standard label+desc used in non-WLM points for WLM points as well".

@misaochan
Copy link
Member

Great job, @ashishkumar468 ! Merging :)

@misaochan misaochan merged commit 6588a6f into commons-app:master Aug 18, 2021
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.

Add support for campaigns
5 participants