Skip to content

Fix 4615: Option for editing caption and description #4672

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 34 commits into from
Dec 6, 2021

Conversation

Ayan-10
Copy link
Contributor

@Ayan-10 Ayan-10 commented Oct 13, 2021

Description (required)

Fetched current wikitext, extracted descriptions from it by in-built algorithm, compare and merge them with caption according to language code, reflected description and caption in an activity for adding and editing, get new description and made new wikitext and put it into the server.

Fixes #4615

Tests performed (required)

Tested master on Pixel 3 with API level 30.

@neslihanturan
Copy link
Collaborator

Hey @Ayan-10 , it would be amazing if you could fix the conflicts :)

@codecov
Copy link

codecov bot commented Oct 16, 2021

Codecov Report

Merging #4672 (a60f8c1) into master (ab9e3e4) will decrease coverage by 0.37%.
The diff coverage is 15.05%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4672      +/-   ##
============================================
- Coverage     40.04%   39.67%   -0.38%     
- Complexity     1719     1732      +13     
============================================
  Files           354      356       +2     
  Lines         14887    15141     +254     
  Branches       1277     1304      +27     
============================================
+ Hits           5962     6007      +45     
- Misses         8509     8706     +197     
- Partials        416      428      +12     
Impacted Files Coverage Δ
...nrw/commons/description/DescriptionEditActivity.kt 0.00% <0.00%> (ø)
...e/nrw/commons/notification/NotificationHelper.java 100.00% <ø> (ø)
...e/nrw/commons/upload/UploadMediaDetailAdapter.java 8.33% <0.00%> (-1.05%) ⬇️
...nrw/commons/description/DescriptionEditHelper.java 10.52% <10.52%> (ø)
...fr/free/nrw/commons/media/MediaDetailFragment.java 28.74% <23.89%> (+0.14%) ⬆️
...main/java/fr/free/nrw/commons/media/MediaClient.kt 93.87% <50.00%> (-1.87%) ⬇️
...ain/java/fr/free/nrw/commons/MediaDataExtractor.kt 18.18% <100.00%> (+3.89%) ⬆️
...java/fr/free/nrw/commons/actions/PageEditClient.kt 80.00% <100.00%> (+5.00%) ⬆️
...va/fr/free/nrw/commons/upload/UploadMediaDetail.kt 57.14% <100.00%> (+3.29%) ⬆️

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 ab9e3e4...a60f8c1. Read the comment docs.

@madhurgupta10
Copy link
Collaborator

Hi @neslihanturan and @Ayan-10 I noticed that Butterknife is used here, we are actually moving away from it (#4664)

If the changes are not urgent, I would suggest you wait till the view binding dependencies are added.

@Ayan-10 Ayan-10 changed the title Fix 4615: Option for editing description [WIP] Fix 4615: Option for editing description Oct 20, 2021
Copy link
Collaborator

@neslihanturan neslihanturan left a comment

Choose a reason for hiding this comment

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

Otherwise, the code looks okay to me. Please ping us when the code is no more [WIP] :)

</application>

</manifest>
xmlns:tools="http://schemas.android.com/tools"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh seems like some auto indentation fix is made with this file. I don't thnik this file should be edited for this PR @Ayan-10 , shall we revert these changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@neslihanturan Yes, The manifest file got auto intended. I revert the changes now.

 into 4615_edit_description

� Conflicts:
�	app/src/main/AndroidManifest.xml
@madhurgupta10
Copy link
Collaborator

madhurgupta10 commented Oct 23, 2021

@Ayan-10 View Binding support is now added, you can use it instead of butterknife (#4681) :)

Also, I noticed that code coverage will decrease significantly, could you please add some tests for the new lines?

@Ayan-10
Copy link
Contributor Author

Ayan-10 commented Oct 23, 2021

@neslihanturan The PR is ready to use. I made the PR [WIP] because of the butterknife issue. Now as @madhurgupta10 said, I can use view binding. I will replace butterknife with view binding as soon as possible and will remove the WIP.

@madhurgupta10 Sure, I will add the required tests.

Thanks.

@Ayan-10
Copy link
Contributor Author

Ayan-10 commented Oct 31, 2021

@madhurgupta10 I was trying to add test for GET call for getting Wikitext. But I am getting this error at the last line. Is this error occurring because of asynchronize call? I was trying to find some solution but can't find any.
Test

    @Test
    fun `getWikiText`() {
        val wikiText = mock<MwQueryResponse>()
        whenever(mediaDetailInterface.getWikiText("File:Test.jpg")).thenReturn(Single.just(wikiText))
        mediaClient.getCurrentWikiText("File:Test.jpg").test()
            .assertValues(wikiText.query()?.pages()?.get(0)?.revisions()?.get(0)?.content())
    }

Error

Value count differs; expected: 1 [null] but was: 0 [] (latch = 0, values = 0, errors = 1, completions = 0)
java.lang.AssertionError: Value count differs; expected: 1 [null] but was: 0 [] (latch = 0, values = 0, errors = 1, completions = 0)

@Ayan-10 Ayan-10 changed the title [WIP] Fix 4615: Option for editing description Fix 4615: Option for editing description Oct 31, 2021
@Ayan-10 Ayan-10 requested a review from neslihanturan October 31, 2021 04:35
@madhurgupta10
Copy link
Collaborator

@madhurgupta10 I was trying to add test for GET call for getting Wikitext. But I am getting this error at the last line. Is this error occurring because of asynchronize call? I was trying to find some solution but can't find any. Test

    @Test
    fun `getWikiText`() {
        val wikiText = mock<MwQueryResponse>()
        whenever(mediaDetailInterface.getWikiText("File:Test.jpg")).thenReturn(Single.just(wikiText))
        mediaClient.getCurrentWikiText("File:Test.jpg").test()
            .assertValues(wikiText.query()?.pages()?.get(0)?.revisions()?.get(0)?.content())
    }

Error

Value count differs; expected: 1 [null] but was: 0 [] (latch = 0, values = 0, errors = 1, completions = 0)
java.lang.AssertionError: Value count differs; expected: 1 [null] but was: 0 [] (latch = 0, values = 0, errors = 1, completions = 0)

It seems like there is a NPE in your expected result wikiText.query()?.pages()?.get(0)?.revisions()?.get(0)?.content()
You don't need to assert for the exact result here, just a type check or even no assert here is fine :)

@Ayan-10 Ayan-10 changed the title Fix 4615: Option for editing description Fix 4615: Option for editing caption and description Dec 5, 2021
@Ayan-10
Copy link
Contributor Author

Ayan-10 commented Dec 5, 2021

@neslihanturan @madhurgupta10 Can you please review this PR?

Copy link
Collaborator

@neslihanturan neslihanturan left a comment

Choose a reason for hiding this comment

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

Hey @Ayan-10 , thanks a lot it works as intended:)

@neslihanturan neslihanturan merged commit 0269894 into commons-app:master Dec 6, 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.

Media details: Make caption and description editable
3 participants