Skip to content

Conversation

@maskaravivek
Copy link
Contributor

Description

Part of task described in #324.

Tests performed

Please test on prodDebug build. Apparently, the beta site doesn't have any featured images.

Screenshots showing what changed

featured_images

@codecov-io
Copy link

codecov-io commented Apr 19, 2018

Codecov Report

Merging #1456 into master will decrease coverage by 0.03%.
The diff coverage is 2.29%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master   #1456      +/-   ##
=========================================
- Coverage    3.21%   3.17%   -0.04%     
=========================================
  Files         132     135       +3     
  Lines        7091    7297     +206     
  Branches      682     708      +26     
=========================================
+ Hits          228     232       +4     
- Misses       6848    7050     +202     
  Partials       15      15
Impacted Files Coverage Δ
.../fr/free/nrw/commons/di/FragmentBuilderModule.java 0% <ø> (ø) ⬆️
.../fr/free/nrw/commons/di/ActivityBuilderModule.java 0% <ø> (ø) ⬆️
.../java/fr/free/nrw/commons/utils/ContinueUtils.java 0% <0%> (ø)
...va/fr/free/nrw/commons/category/QueryContinue.java 0% <0%> (ø)
...e/nrw/commons/category/CategoryImagesActivity.java 0% <0%> (ø)
.../fr/free/nrw/commons/category/GridViewAdapter.java 0% <0%> (ø)
.../free/nrw/commons/category/CategoryImageUtils.java 0% <0%> (ø)
...free/nrw/commons/theme/NavigationBaseActivity.java 22.82% <0%> (ø) ⬆️
...w/commons/category/CategoryImagesListFragment.java 0% <0%> (ø)
.../nrw/commons/category/CategoryImageController.java 0% <0%> (ø)
... and 10 more

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 228aa21...689df02. Read the comment docs.

implementation 'com.jakewharton.rxbinding2:rxbinding-appcompat-v7:2.0.0'
implementation 'com.jakewharton.rxbinding2:rxbinding-design:2.0.0'

implementation 'org.jsoup:jsoup:1.11.3'
Copy link
Member

Choose a reason for hiding this comment

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

Hi @maskaravivek , what is the reason for needing to add this library?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This library parses the artist name. The API returns the artist as a HTML string.

@misaochan
Copy link
Member

Thanks for this PR, @maskaravivek ! It works well for me in general, great job. A few issues:

  • It only loads 10 images, and the same images all the time. This will get boring very quickly for the user, and they will likely not bother to give this feature more than one cursory glance. I think that for our minimum viable product, we can load as many images as the user's "Set Recent Upload Limit" setting states? I know that that is meant for contributions, but IMO realistically if they can load 100 of their own images, they can load 100 of other people's images without any issue. Ideally we should randomize the pictures shown or dynamically load more after scrolling down, but that can be an enhancement for the future.
  • In the media details view (accessed when image is tapped), the author field says "Featured image author user name goes here". :)
  • The toast "Error! URL not found" is displayed when the media details view loads, even though the image and most of the fields are correct
  • After viewing a few images, I crashed with the error:
04-30 21:31:33.051 23958-23958/fr.free.nrw.commons.debug E/AndroidRuntime: FATAL EXCEPTION: main
    Process: fr.free.nrw.commons.debug, PID: 23958
    java.util.ConcurrentModificationException
        at java.util.HashMap$HashIterator.nextEntry(HashMap.java:851)
        at java.util.HashMap$KeyIterator.next(HashMap.java:885)
        at fr.free.nrw.commons.Media.setDescriptions(Media.java:359)
        at fr.free.nrw.commons.MediaDataExtractor.fill(MediaDataExtractor.java:303)
        at fr.free.nrw.commons.media.MediaDetailFragment$3.onPostExecute(MediaDetailFragment.java:256)
        at fr.free.nrw.commons.media.MediaDetailFragment$3.onPostExecute(MediaDetailFragment.java:229)
        at android.os.AsyncTask.finish(AsyncTask.java:667)
        at android.os.AsyncTask.-wrap1(AsyncTask.java)
        at android.os.AsyncTask$InternalHandler.handleMessage(AsyncTask.java:684)
        at android.os.Handler.dispatchMessage(Handler.java:102)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6119)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:886)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:776)

@commons-app commons-app deleted a comment May 1, 2018
@maskaravivek
Copy link
Contributor Author

@misaochan Thanks for reviewing and testing the PR.

I have fixed most of the issues reported by you.

  • "Error! URL not found" still isn't fixed since the MediaDetailFragment fetches the media details again from the server and is not able to fetch the license information. Thus the toast is displayed. Later on, we can pick refactoring of this fragment so that the data is fetched again only if there are missing data.
  • Have also implemented pagination here so that the user can scroll through as many images as he wishes. We can introduce randomization later on.
  • Have completely refactored the code so that it can be reused for displaying category images.

@ujjwalagrawal17 @neslihanturan Just adding you guys to the conversation so that you don't have to rewrite the whole thing when/if browsing images of a particular category are picked up.

Here's how to use it:

CategoryImagesActivity.startYourself(this, <page_title>, <category_name>);

@misaochan
Copy link
Member

misaochan commented May 1, 2018

Hi @maskaravivek ,

  • The pagination works very well! :) Nice work.
  • The author field seems to disappear completely now when I load an image's details. Sorry to nitpick, but I think we really need to have an author field if we are displaying other people's images, especially as some of them have licenses that require attribution.
  • Just noticed this: Pressing the "back" button on the device closes the Commons app entirely at the moment, whereas it should be bringing users back to Contributions activity. (Actually, even going to "Home" from the nav drawer on Featured activity closes the app, which isn't intended)
  • Should we just remove the "Error! URL not found" toast in that case, as a temporary measure, and add a TODO? It doesn't appear to be terribly informative to the user, at any rate.


private static Date getDateCreated(Node document) {
String dateTime = getMetaDataValue(document, "DateTime");
Timber.d("Date time is %s", dateTime);
Copy link
Member

Choose a reason for hiding this comment

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

Could you please make this verbose at least? It spams my entire logcat screen each time any page loads. :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Will remove it altogether. Was just for debugging purposes :D

@maskaravivek
Copy link
Contributor Author

@misaochan I have fixed all the issues reported by you. Thanks again for helping with testing. :)

@misaochan
Copy link
Member

misaochan commented May 2, 2018

@maskaravivek Does the author field in media details view work for you currently?

@maskaravivek
Copy link
Contributor Author

@misaochan Yes, it works for me. Moreover, now even the featured images list shows the author name(As designed by @neslihanturan)

Attached screenshots.

featured_images_author
media_detail_author

@misaochan
Copy link
Member

Thanks @maskaravivek , works well for me after restarting. :) Great job, I think users will really enjoy browsing through them!

There is just an issue with tests, causing Travis to fail. Once this is fixed, I think we can go right ahead with the merge.

13 PMD rule violations were found. See the report at: file:///home/travis/build/commons-app/apps-android-commons/app/build/reports/pmd/pmd.html
:app:kaptGenerateStubsBetaDebugUnitTestKotline: /home/travis/build/commons-app/apps-android-commons/app/src/test/kotlin/fr/free/nrw/commons/mwapi/ApacheHttpClientMediaWikiApiTest.kt: (34, 155): No value passed for parameter 'p3'
e: /home/travis/build/commons-app/apps-android-commons/app/src/test/kotlin/fr/free/nrw/commons/mwapi/ApacheHttpClientMediaWikiApiTest.kt: (34, 155): No value passed for parameter 'p4'
 FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:kaptGenerateStubsBetaDebugUnitTestKotlin'.

@maskaravivek
Copy link
Contributor Author

@misaochan Have fixed the travis build. :)

@commons-app commons-app deleted a comment May 3, 2018
@misaochan
Copy link
Member

The build was re-run 5 min ago, but it seems to still fail:

13 PMD rule violations were found. See the report at: file:///home/travis/build/commons-app/apps-android-commons/app/build/reports/pmd/pmd.html
:app:kaptGenerateStubsBetaDebugUnitTestKotlin
:app:kaptBetaDebugUnitTestKotlin
:app:compileBetaDebugUnitTestKotlin
:app:preBetaDebugUnitTestBuild UP-TO-DATE
:app:javaPreCompileBetaDebugUnitTest
:app:compileBetaDebugUnitTestJavaWithJavac NO-SOURCE
:app:mockableAndroidJar
:app:processBetaDebugJavaRes
:app:processBetaDebugUnitTestJavaRes NO-SOURCE
:app:testBetaDebugUnitTest
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > editToken FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > simpleLogin FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > simpleLoginWithWrongPassword FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > validateLoginForLoggedInUser FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > twoFactorLogin FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > validateLoginForLoggedOutUser FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > getUploadCount FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > fileExistsWithName_FileNotFound FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
fr.free.nrw.commons.mwapi.ApacheHttpClientMediaWikiApiTest > authCookiesAreHandled FAILED
    kotlin.UninitializedPropertyAccessException at ApacheHttpClientMediaWikiApiTest.kt:36
112 tests completed, 9 failed
:app:testBetaDebugUnitTest FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:testBetaDebugUnitTest'.
> There were failing tests. See the report at: file:///home/travis/build/commons-app/apps-android-commons/app/build/reports/tests/testBetaDebugUnitTest/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
* Get more help at https://help.gradle.org
BUILD FAILED in 6m 28s
76 actionable tasks: 76 executed

@commons-app commons-app deleted a comment May 3, 2018
@neslihanturan
Copy link
Collaborator

@maskaravivek , it gives me this screen in a loop:
loop

@maskaravivek
Copy link
Contributor Author

@neslihanturan Can you post the error logs from logcat. Are you testing on beta or prod?

@maskaravivek
Copy link
Contributor Author

@misaochan Finally the build succeeds. Sorry for having you test it multiple times.

@misaochan
Copy link
Member

Thanks @maskaravivek . All good on my end - we can merge after @neslihanturan 's issue is sorted. :)

@neslihanturan
Copy link
Collaborator

neslihanturan commented May 4, 2018

Sorry for not adding logs earlier, here:
Error occurred while loading featured images java.lang.NullPointerException: Attempt to invoke virtual method 'void fr.free.nrw.commons.category.GridViewAdapter.addItems(java.util.List)' on a null object reference at fr.free.nrw.commons.category.CategoryImagesListFragment.lambda$fetchMoreImages$4$CategoryImagesListFragment(CategoryImagesListFragment.java:127) at fr.free.nrw.commons.category.CategoryImagesListFragment$$Lambda$4.accept(Unknown Source) at io.reactivex.internal.observers.LambdaObserver.onNext(LambdaObserver.java:60) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.drainNormal(ObservableObserveOn.java:200) at io.reactivex.internal.operators.observable.ObservableObserveOn$ObserveOnObserver.run(ObservableObserveOn.java:252) at io.reactivex.android.schedulers.HandlerScheduler$ScheduledRunnable.run(HandlerScheduler.java:109) at android.os.Handler.handleCallback(Handler.java:739) at android.os.Handler.dispatchMessage(Handler.java:95) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

There is a possibility that it happens because of Turkey ban, but in that case, we should be using an information window instead of loop.

@misaochan misaochan mentioned this pull request May 4, 2018
16 tasks
@commons-app commons-app deleted a comment May 4, 2018
@maskaravivek
Copy link
Contributor Author

@neslihanturan I have added checks to gracefully handle the error cases.

no_images
no_internet

@commons-app commons-app deleted a comment May 5, 2018
@misaochan
Copy link
Member

Thanks for adding the Javadocs! :) @neslihanturan I would like to merge this once you can confirm that the error handling works for you.

@neslihanturan
Copy link
Collaborator

Works as expected, thanks you to include a great feature to our project @maskaravivek :)

@neslihanturan neslihanturan merged commit 9845a62 into commons-app:master May 7, 2018
maskaravivek pushed a commit that referenced this pull request May 18, 2018
* Integrate API for displaying featured images

* Add pagination and refactor code so that it can be reused for category images

* Add license info to the images

* Fix author view

* Remove unused values

* Fix minor issues with featured images

* Fix null license url issue

* Remove some log lines

* Fix back navigation issue

* fix tests

* fix test inits

* Gracefully handling various error situations

* Added java docs
misaochan pushed a commit that referenced this pull request May 31, 2018
…rby (#1495)

* Localisation updates from https://translatewiki.net.

* Integrate API for displaying featured images (#1456)

* Integrate API for displaying featured images

* Add pagination and refactor code so that it can be reused for category images

* Add license info to the images

* Fix author view

* Remove unused values

* Fix minor issues with featured images

* Fix null license url issue

* Remove some log lines

* Fix back navigation issue

* fix tests

* fix test inits

* Gracefully handling various error situations

* Added java docs

* Update pull_request_template.md (#1476)

* Update pull_request_template.md

* Remove Javadocs mention

* Added required/optional notes

* resolves #1464 : MediaDataExtractor is making inefficient (redundant) server calls (#1496)

* Open map of place where picture was taken (#1360)

* Intent to map added

*  Merge conflicts resolved

*  Added the functionality to hide FAB incase of null coordinate

*  Merge Conflict resolved

*  Improve pr quality

* Improve Quality

*  Added nested FAB animations

* Nested FAB implemented

*  Improve Quality

*  Added up arrow

*  Javadocs Added

* Add nearby tutorial (#1467)

* Add dependency for MaterialShowcase

* Add actionview class to get a reference to material showcase

* Create a NearbyMaterialShowcaseSequence class

* Apply sequence steps

* Add first three steps of nearby showcase

* Add sequence id constants to make sure they will be displayed only once

* Add last step of sequence to explain plus fab

* Create an object to prevent customize all sequences every time

* Fix typo

* Code cleanup

* Add strings to strings.xml

* Code cleanup

* Revert irrelevant change

* Revert irrelevant change

* Remove showcaseview for recenter button

* Use single showcaseView instead of sequence

* Add single showcase view insted of sequence to be able to edit text style

* Make sure it will be displayed only once

* Cleanup

* Update strings

* Change dismiss text style

* CONTRIBUTING: fix formatting of the gist of the guidelines (#1453)

* CONTRIBUTING: fix formatting of the gist of the guidelines

First level headings for a gist seems to be overkill.

So, replace first level headings with an ordered-list which
sounds more meaningful.

* CONTRIBUTING: specify clearly that 'blame' is a feature of "Git"

The contributing file specifies about the ability to know who wrote
something without the need of @author javadoc tags but incorrectly
attributes the feature to GitHub.

Correctly attribute the feature to where it belongs, Git, and specify
the name of the feature to help users easily take advantage of it.

* Feature/switch to butterknife (#1494)

* Implemented butterknife in MediaDetailFragment [issue #1491]

* Implemented butterknife in MediaDetailPagerFragment [[issue #1491]]

* post merge upstream master wip [[issue #1491]]

* Localisation updates from https://translatewiki.net.

* Bug fix #1504 (#1506)

* Bug fix #1504

* Filtered messages with ConnectException [issue #1504]

* A generalised message for exceptions in Nearby Activity [issue #1504]

* Localisation updates from https://translatewiki.net.

* Fix security exception crash while accessing network location provider (#1498)

* Fix security exception crash while accessing network location provider

* Added java docs

* Localisation updates from https://translatewiki.net.

* Log P18 edits to wikidata corresponding wikidata entity on uploading a nearby image

* Added java docs

* Fix test build

* Refresh nearby

* Refresh nearby list on successful edit

* Java docs

* Make authenticated wikidata edits

* Updated toast message to show entity name that was edited
@maskaravivek maskaravivek deleted the featuredImageImpl branch September 12, 2018 20:25
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.

4 participants