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 Issue #5832: Navigation Banner Appears in Media Details Screen #5839

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

Jason-Whitmore
Copy link
Contributor

Description (required)

Fixes #5832

What changes did you make and why?

There were two changes made.

First, a helper method was created to easily retrieve the ContributionsFragment. Accessing the ContributionsFragment is required to hide the navigation banner.

(One concern I have with this helper method is that it attempts to find the ContributionsFragment by looping through the parent fragments repeatedly in a while loop. The advantage of this strategy is that it can retrieve the ContributionsFragment anywhere in the Fragment parent-child structure if it exists. The primary disadvantage is that if the Fragment parent-child structure is a loop with no ContributionsFragment, then the while loop will never terminate.

I can rewrite this method to retrieve the ContributionsFragment directly (using two calls to getParentFragment()), but this strategy is less flexible. Should I rewrite this helper method to not use a while loop or is the current implementation okay?)

Second, old code which attempted to hide the navigation banner (but was unsuccessful) was replaced with a call to the helper method and then checking for null objects. If the objects are not null, then the navigation banner is successfully hidden.

Tests performed (required)

Tested betaDebug on Android Studio Emulator with API level 34.

Screenshots (for UI changes only)

issue_5832_compressed.webm

In this video, the navigation banner is visible from the contributions menu. When a specific contribution is selected, the navigation banner is hidden. Once the back button is pressed, the contributions menu appears with the navigation banner visible again.

…ragment instance

Before this commit, there was no easy way to check for and retrieve the ContributionFragment instance that
was either the parent or grandparent (parent's parent) fragment. A complicated if check was required to
retrieve it.

After this commit, there is a simple helper method which will retrieve the ContributionFragment instance.
Existing code can now be replaced by calling this method.
Before this commit, code would attempt to find and hide the nearby card that would appear
when the user was looking at media details. However, this code did not work.

After this commit, the old code has been replaced with code that correctly hides the
nearby card. Also, this new code uses a helper method call and is overall easier to read.
@nicolas-raoul
Copy link
Member

I guess the loop will at least terminate when there is no parent, so I don't worry about infinite loop here.

}

//Hide the Nearby card when looking at media details
ContributionsFragment cf = this.getContributionsFragmentParent();
Copy link
Member

Choose a reason for hiding this comment

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

In Java we prefer explicit variable names, even if long. So unless there is a reason I missed, would you mind renaming cf to contributionFragment?

* be found, null is returned.
*/
private ContributionsFragment getContributionsFragmentParent(){
Fragment f = this;
Copy link
Member

Choose a reason for hiding this comment

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

Similarly, f to fragment.


//Hide the Nearby card when looking at media details
ContributionsFragment cf = this.getContributionsFragmentParent();
if(cf != null && cf.binding != null){
Copy link
Member

Choose a reason for hiding this comment

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

Sorry for nitpicking, but would you mind inserting a space character before if and while, here and below?

@nicolas-raoul
Copy link
Member

Before:

screen-20240928-231429.mp4

After:

screen-20240928-225158.mp4

@nicolas-raoul
Copy link
Member

@rohit9625 If you have time, would you mind seeing whether this PR fixes the issue? As seen in my previous post above, for me both before and after are fast enough haha.

@rohit9625
Copy link
Contributor

@rohit9625 If you have time, would you mind seeing whether this PR fixes the issue? As seen in my previous post above, for me both before and after are fast enough haha.

I'm looking into it :》

@rohit9625
Copy link
Contributor

It's still the same behavior on my device. Did you reproduce the issue before fixing it @Jason-Whitmore?

@rohit9625
Copy link
Contributor

Screen_recording_20240930_225134.mp4

Explanation:-

The Nearby Banner was still present even after opening MediaDetailsFragment. However, it disappeared after some time but not in the second case.
I observed that it only hides when the value of the distance updates. You can see when I clicked the contribution the very first time, the value of 293m, and when I changed my location, it was updated to 294m and hence, removed from the screen. However, on the second try, I didn't change my location so that value remained the same, and as a result, the banner did not hide.

I just realized @nicolas-raoul that Nearby Banner was not showing on your screen-cast even on the contributions list. Please check on that :)

@nicolas-raoul
Copy link
Member

@rohit9625 Ah thanks for pointing this out, I can replicate on main now. 🙂 I am out so I cannot test the PR now.

@rohit9625
Copy link
Contributor

No problem @nicolas-raoul :)
Could you please look for a fix @Jason-Whitmore ?

@Jason-Whitmore
Copy link
Contributor Author

Thank you all for the large discussion here. I'll try and address what I can.

When I was developing the changes in this pull request, I was working on betaDebug. I had reproduced most of the issue there (on main), but the navigation banner never disappeared at all (rather than disappearing after a few seconds). Once the changes had been made, it appeared the bug was fixed. I assumed that fixing the bug on betaDebug would fix it on prodDebug. I did not test these changes directly on prodDebug before I submitted this pull request. I apologize.

Just now I tested these changes on prodDebug and the bug appears fixed for me. However, I only have one contribution uploaded for my testing, rather than the 8 that @rohit9625 has in the most recent video. Could the number of contributions have some kind of effect on whether or not the bug appears?

Thanks again for all the feedback. I'll keep working on this.

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.

[Bug]: Navigation Banner Appears in Media Details Screen
3 participants