Skip to content

Fixes #4589 :- The empty screen while no images found in custom picture selector #4863

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 5 commits into from
Mar 7, 2022

Conversation

Rishavgupta12345
Copy link
Contributor

The empty screen while no images found in custom picture selector #4589 is fixed now

I was solving this issue in the Image fragment as mentioned by @4D17Y4 but it created a few unwanted bugs so I have to delete my previous pull request, I created a new one with a different approach and I as this is working perfectly so, for now, this can be an ideal solution

@nicolas-raoul screenshots added

No image found
Screenshot 2022-02-28 123014

Image found
Screenshot 2022-02-28 122831

@codecov
Copy link

codecov bot commented Feb 28, 2022

Codecov Report

Merging #4863 (c02f38c) into master (9431e37) will decrease coverage by 0.17%.
The diff coverage is 37.50%.

❗ Current head c02f38c differs from pull request most recent head 35ca4dc. Consider uploading reports for the commit 35ca4dc to get more accurate results

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4863      +/-   ##
============================================
- Coverage     50.57%   50.40%   -0.18%     
+ Complexity     2224     2215       -9     
============================================
  Files           338      338              
  Lines         15546    15561      +15     
  Branches       1359     1362       +3     
============================================
- Hits           7862     7843      -19     
- Misses         7100     7133      +33     
- Partials        584      585       +1     
Impacted Files Coverage Δ
...stomselector/ui/selector/CustomSelectorActivity.kt 72.00% <37.50%> (-6.83%) ⬇️
...ava/fr/free/nrw/commons/media/MwParseResponse.java 0.00% <0.00%> (-40.00%) ⬇️
...fr/free/nrw/commons/review/ReviewPagerAdapter.java 30.76% <0.00%> (-38.47%) ⬇️
...r/free/nrw/commons/explore/media/MediaConverter.kt 71.42% <0.00%> (-23.81%) ⬇️
...a/fr/free/nrw/commons/OkHttpConnectionFactory.java 52.27% <0.00%> (-20.46%) ⬇️
...main/java/fr/free/nrw/commons/media/MediaClient.kt 87.75% <0.00%> (-6.13%) ⬇️
.../java/fr/free/nrw/commons/review/ReviewHelper.java 77.77% <0.00%> (-5.56%) ⬇️
...ava/fr/free/nrw/commons/review/ReviewActivity.java 47.28% <0.00%> (-3.11%) ⬇️
...w/commons/contributions/ContributionsFragment.java 31.59% <0.00%> (-0.33%) ⬇️
... and 2 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 9431e37...35ca4dc. Read the comment docs.

@arinmodi
Copy link
Contributor

Review by student

  • Before the Changes :
before.mp4
  • After the Changes :
after.mp4



Status : issue solved

@Rishavgupta12345
Copy link
Contributor Author

Review by student

  • Before the Changes :

before.mp4

  • After the Changes :

after.mp4
Status : issue solved

thanks a lot for the review

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.

Wonderful! Thanks for adding javadoc.
Just a few requests added.

And thanks Arin for the review!

if(isImageGalleryEmpty()) {
val linearLayout: LinearLayout = findViewById<View>(R.id.linear_layout_noimage) as LinearLayout
val textView = TextView(this)
textView.text = "No Image Found"
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 string localizable? See how internationalization is done for other strings of the app.
Also, could you make the English one No images found. (plural, only first letter uppercase, point at the end)


// Checks if the Image gallery is empty.
if(isImageGalleryEmpty()) {
val linearLayout: LinearLayout = findViewById<View>(R.id.linear_layout_noimage) as LinearLayout
Copy link
Member

Choose a reason for hiding this comment

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

Unit test for this block

*/
private fun isImageGalleryEmpty(): Boolean {
try {
val projection = arrayOf(MediaStore.Images.Media._ID)
Copy link
Member

Choose a reason for hiding this comment

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

Unit test for this block

@4D17Y4
Copy link
Contributor

4D17Y4 commented Mar 2, 2022

Hey @Rishavgupta12345,
Seems like u have reverted to your previous approach. Any reasons ?
You mentioned unwanted bugs, would be nice if you could list them. I am sure we can figure out those.

The basic reason why we don't want to go with this approach is that it queries images again which is inefficient as we are just concerned with the number of images returned. So I suggested to handle this in the results function. On a plus point all the test are done on the custom selector functions, major changes wont be necessary.

@Rishavgupta12345
Copy link
Contributor Author

Hey @Rishavgupta12345, Seems like u have reverted to your previous approach. Any reasons ? You mentioned unwanted bugs, would be nice if you could list them. I am sure we can figure out those.

The basic reason why we don't want to go with this approach is that it queries images again which is inefficient as we are just concerned with the number of images returned. So I suggested to handle this in the results function. On a plus point all the test are done on the custom selector functions, major changes wont be necessary.

I am not getting the perfect way of implementing it on Image fragments, because there I tried some approaches and they are not working as they should

@4D17Y4
Copy link
Contributor

4D17Y4 commented Mar 2, 2022

@Rishavgupta12345 you can try again if you want. I'll unassign the issue for now so that others can work on it. In case you plan to work on it again you can ping us to get assigned.

@Rishavgupta12345
Copy link
Contributor Author

@Rishavgupta12345 you can try again if you want. I'll unassign the issue for now so that others can work on it. In case you plan to work on it again you can ping us to get assigned.

don't un assign me I will work on it

@Rishavgupta12345
Copy link
Contributor Author

Hey @Rishavgupta12345, Seems like u have reverted to your previous approach. Any reasons ? You mentioned unwanted bugs, would be nice if you could list them. I am sure we can figure out those.
The basic reason why we don't want to go with this approach is that it queries images again which is inefficient as we are just concerned with the number of images returned. So I suggested to handle this in the results function. On a plus point all the test are done on the custom selector functions, major changes wont be necessary.

I am not getting the perfect way of implementing it on Image fragments, because there I tried some approaches and they are not working as they should

@4D17Y4 If I am making this in image and folder fragment then can I make another function isImageGalleryEmpty() and call them inside the handleResult() funtion? like I did in this pull request

@4D17Y4
Copy link
Contributor

4D17Y4 commented Mar 4, 2022

Yes you can do that. This time you don't have to query for the images.

@Rishavgupta12345
Copy link
Contributor Author

Yes you can do that. This time you don't have to query for the images.

@4D17Y4 @nicolas-raoul finally done in best possible way. Ready to merge

Copy link
Contributor

@4D17Y4 4D17Y4 left a comment

Choose a reason for hiding this comment

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

Best approach indeed.
Nice work.
Just some minor changes.

@Rishavgupta12345
Copy link
Contributor Author

Best approach indeed. Nice work. Just some minor changes.

@4D17Y4 done the requested changes

@4D17Y4
Copy link
Contributor

4D17Y4 commented Mar 7, 2022

Works.
Good to merge.
Any final edits @nicolas-raoul ?

@nicolas-raoul nicolas-raoul merged commit c02d569 into commons-app:master Mar 7, 2022
@madhurgupta10
Copy link
Collaborator

@Rishavgupta12345 It seems like 2 of the tests are failing after this PR was merged, can you take a look into it, please?

fr.free.nrw.commons.customselector.ui.selector.ImageFragmentTest > testHandleResult FAILED
    java.lang.Exception at AndroidTestEnvironment.java:538
        Caused by: java.lang.reflect.InvocationTargetException at ImageFragmentTest.kt:128
            Caused by: java.lang.NullPointerException at ImageFragmentTest.kt:128

fr.free.nrw.commons.customselector.ui.selector.FolderFragmentTest > testHandleResult FAILED
    java.lang.Exception at AndroidTestEnvironment.java:538
        Caused by: java.lang.reflect.InvocationTargetException at FolderFragmentTest.kt:128
            Caused by: java.lang.NullPointerException at FolderFragmentTest.kt:128

@Rishavgupta12345
Copy link
Contributor Author

@Rishavgupta12345 It seems like 2 of the tests are failing after this PR was merged, can you take a look into it, please?

fr.free.nrw.commons.customselector.ui.selector.ImageFragmentTest > testHandleResult FAILED
    java.lang.Exception at AndroidTestEnvironment.java:538
        Caused by: java.lang.reflect.InvocationTargetException at ImageFragmentTest.kt:128
            Caused by: java.lang.NullPointerException at ImageFragmentTest.kt:128

fr.free.nrw.commons.customselector.ui.selector.FolderFragmentTest > testHandleResult FAILED
    java.lang.Exception at AndroidTestEnvironment.java:538
        Caused by: java.lang.reflect.InvocationTargetException at FolderFragmentTest.kt:128
            Caused by: java.lang.NullPointerException at FolderFragmentTest.kt:128

I have never faced any issue like this before , so can you please guide me what should I do now ?

BY my knowledge i think I have to make some changes in the tests as new things were added which doesn't have tests on it

@madhurgupta10
Copy link
Collaborator

You can run the tests locally from Android Studio and see the logs why they are failing and update the tests accordingly.

@madhurgupta10
Copy link
Collaborator

madhurgupta10 commented Mar 8, 2022

@Rishavgupta12345 can you prioritise this issue over others for the time, build fails make it difficult for us to review PRs.

@Rishavgupta12345
Copy link
Contributor Author

@Rishavgupta12345 can you prioritise this issue over others for the time, build fails make it difficult for us to review PRs.

okay

@Rishavgupta12345
Copy link
Contributor Author

Rishavgupta12345 commented Mar 9, 2022

@Rishavgupta12345 can you prioritise this issue over others for the time, build fails make it difficult for us to review PRs.

@madhurgupta10 I have done the changes, merge #4883 and its done

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.

5 participants