Skip to content

#4730 - Nothing happens on clicking media in the Contribution tab of User's Profile#4736

Merged
neslihanturan merged 3 commits intocommons-app:masterfrom
Pratham2305:fix-issue-4730
Apr 18, 2022
Merged

#4730 - Nothing happens on clicking media in the Contribution tab of User's Profile#4736
neslihanturan merged 3 commits intocommons-app:masterfrom
Pratham2305:fix-issue-4730

Conversation

@Pratham2305
Copy link
Contributor

Description (required)

Fixes #4730

What changes did you make and why?

  • Added ContributionFragment to the ViewPager instead of ContributionListFragment in Profile Activity

  • Used the ContributionFragment similar to the way it used in Contribution Tab, to handle MediaDetailPagerFragment and ContributionListFragment transition.

  • Disable unnecessary ContributionFragment features when it is used in ProfileActivity, like campaigns, nearby notification, etc.

  • Added onBackPressed() method in ProfileActivity, and also replaced viewPager with ParentViewPager.

Tests performed (required)

Tested ProdDebug on Pixel 3 with API level 29.

@codecov
Copy link

codecov bot commented Dec 16, 2021

Codecov Report

Merging #4736 (bad88de) into master (d834ce3) will increase coverage by 0.22%.
The diff coverage is 35.04%.

❗ Current head bad88de differs from pull request most recent head 580d3b9. Consider uploading reports for the commit 580d3b9 to get more accurate results
Impacted file tree graph

@@             Coverage Diff              @@
##             master    #4736      +/-   ##
============================================
+ Coverage     40.01%   40.24%   +0.22%     
- Complexity     1760     1802      +42     
============================================
  Files           358      363       +5     
  Lines         15295    15659     +364     
  Branches       1320     1358      +38     
============================================
+ Hits           6121     6302     +181     
- Misses         8725     8889     +164     
- Partials        449      468      +19     
Impacted Files Coverage Δ
...n/java/fr/free/nrw/commons/CommonsApplication.java 1.86% <0.00%> (-0.02%) ⬇️
...mmons/contributions/ContributionsListFragment.java 58.62% <0.00%> (-1.03%) ⬇️
...in/java/fr/free/nrw/commons/data/DBOpenHelper.java 0.00% <0.00%> (ø)
...fr/free/nrw/commons/media/MediaDetailFragment.java 28.69% <0.00%> (-0.05%) ⬇️
...ee/nrw/commons/media/MediaDetailPagerFragment.java 24.75% <0.00%> (-0.13%) ⬇️
...fr/free/nrw/commons/mwapi/OkHttpJsonApiClient.java 16.20% <0.00%> (-0.19%) ⬇️
...nrw/commons/nearby/NearbyNotificationCardView.java 24.09% <0.00%> (ø)
...commons/nearby/fragments/NearbyParentFragment.java 1.08% <0.00%> (-0.03%) ⬇️
...e/nrw/commons/upload/UploadMediaDetailAdapter.java 6.33% <0.00%> (-2.00%) ⬇️
...ns/upload/categories/UploadCategoriesFragment.java 86.95% <ø> (ø)
... and 27 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 d834ce3...580d3b9. Read the comment docs.

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.

Looks good to me, works well.
Just some documentation on the added function, variables and conditional statements.

Also, I think it would be better to have the top bar with bookmark, share, download options as in contribution and explore. @nicolas-raoul views ?

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.

Other than my review, the code looks nice. Thanks a lot @Pratham2305 :)

super.onCreate(savedInstanceState);
if (getArguments() != null) {
userName = getArguments().getString(KEY_USERNAME);
isUserProfile = true;
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we create ContributionsFragment with arguments in some other pieces of the code than ProfileActivity, the bundle may still be not null and this code will set isUserProfile boolean to true. However, this may not necessarily be the case. So, I think this boolean should be set when KEY_USERNAME argument is not null rather than when any kind of argument is not null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done!


@Override
public void onBackPressed() {
if(contributionsFragment != null && contributionsFragment.getMediaDetailPagerFragment() != null && contributionsFragment.getMediaDetailPagerFragment().isVisible()) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe adding a comment to explain this if condition?

}
}

if (getActivity() instanceof ProfileActivity) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

adding some comment to explain this iftoo would be nice

((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
((MainActivity)getActivity()).showTabs();
fetchCampaigns();
//((BaseActivity)getActivity()).getSupportActionBar().setDisplayHomeAsUpEnabled(false);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Removing this line and explaining the lines at the bottom would be cool

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.

Some comments should be added and style issues should be fixed


setNotificationCount();
fetchCampaigns();
if(!isUserProfile) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

The if needs explanation comment

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.

Thanks a lot @Pratham2305 :)

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.

Nothing happens on clicking media in the Contribution tab of User's Profile

3 participants