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
Enable swipe-to-refresh for browser tabs #864
Enable swipe-to-refresh for browser tabs #864
Conversation
- Including SwipeRefreshLayout dependencies & adapted fragment - Minor fix for DuckDuckGoWebView to work with SwipeRefreshLayout Resolves: duckduckgo#33
@malmstein do you want to take this PR since it's based on your previous code? |
Thanks for this @Usiel! I'll take a look in the following days and get back to you |
if (!viewState.isLoading) { | ||
swipeRefreshContainer.isRefreshing = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (!viewState.isLoading) { | |
swipeRefreshContainer.isRefreshing = false | |
} | |
swipeRefreshContainer.isRefreshing = viewState.isLoading |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since this callback is used for other loading operations (e.g. loading a link), we would show the refresh loading indicator in these cases too with the suggested change.
app:layout_constraintEnd_toEndOf="parent" | ||
app:layout_constraintStart_toStartOf="parent" | ||
app:layout_constraintTop_toTopOf="parent" | ||
tools:background="#4F00" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to use a color resource.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, will adapt this assuming the blocker (see comment below) can be resolved.
I found a blocker related to the scrollable content within the WebView unfortunately (see last point in the PR description). Same problem appears also when the page contains a full screen map or similar content. The user will not be able to drag up as the refresh will be triggered. Try https://www.openstreetmap.org/ for example. I'll have a look in a bit if I can find any solutions for this. |
OK found something that works. There's still some work to do (overscroll indicators), but happy to hear whether the approach is fine by you. New approach somewhat emulates Chrome's behavior: Edit: All done, there might still be a small issue here or there (inactive pointers). I can work on those once we can confirm this swipe behavior is something DuckDuckGo would be happy with. |
- Added callback to allow WebView control over SwipeRefreshLayout - Added logic to disable swipe refresh when WebView is not clampedY before
dd4b730
to
4ec4ffd
Compare
Great job @Usiel! I like the implementation and the feeling after your latest changes, but I'm going to ask for internal feedback before moving forward and get back to you. Thanks for taking care of it! |
@Usiel besides the overscroll indicators, I've found something that would love to have fixed. Some sites have already implemented their own version of Pull to Refresh (if you navigate to twitter.com from our app in Google Play and pull to refresh you'll see their own version) and we'd like that our implementation does not override the one from the site. A few ideas on how to overcome this:
What do you think? |
@malmstein I agree that should definitely be fixed. I think a combination of your ideas could make sense. It would be great if less known sites with PTR would also still work. By the way if it's more in line with the DDG workflow we can also make this PR a draft or close it & discuss on the issue if you prefer. I suspect there will be a few more cases that need to be handled to make this perfect. Apparently there's a reason I couldn't find any open source browser (using WebView) that implements this properly ;) |
- Added JavaScript interface to retrieve the css overscrollBehaviorY value - Added switch on custom WebView to allow disabling swipe to refresh completely - Minor fix for lastClampedY issue on pages where height <= window to detect whether we actually are clampedY at the top
c1bea60
to
04a343a
Compare
OK hope this one should do it. Solution is based on the CSS overscrollBehavior prop. Here's some additional information on that: https://developers.google.com/web/updates/2017/11/overscroll-behavior |
This is a very interesting approach @Usiel, thanks for taking the time to writing it. Although I'm not a huge fan of adding Javascript interfaces, I appreciate why this could be a good solution. Let me think about it and discuss with the rest of the team. Nonetheless, I really appreciate your effort here. Good job! |
We can avoid the JS interface with |
Hey @Usiel I really like how this is looking! Using
And then from the
After testing with different websites I've only found one issues. If you merge the current
Steps to test this PR:
If you then close the app and open it again the results are there I looked with the |
Thanks for the refactor suggestion @malmstein. Added that, seems much cleaner. Regarding the blank screen: I was not able to reproduce this on my physical device and a few virtual devices (API 25, 26, 28). Did you encounter the issue on a specific device? |
Thanks for the refactor @Usiel! The issue appeared in one of the emulators API 25 and my Nexus 3a. Will continue to test with your changes and come back to you. Other than that, this is looking good and. Thanks for putting in the work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this work @Usiel. Great addition to the app and nicely implemented! @cmonfortep we can move to Product Review after this!
@Usiel thanks for your work on this! This feature will be part of the next release that will likely be available next week. Good job! |
Great to hear! Thanks for the review @malmstein. By the way I have some additional changes lying around to allow cancelling a refresh/load, similar to Chrome. I can create an issue + PR for that in the coming days if you'd like. |
That sounds good @Usiel, I'll make sure to take a look once it's opened. |
I'm trying to eliminate my dependencies on Google by installing apps from F-Droid, instead. I noticed that the F-Droid version lacks swipe-to-refresh due to a non-free library. I have a few questions/suggeations:
Thanks for everything!!! |
Including SwipeRefreshLayout dependencies & adapted fragment
Minor fix for DuckDuckGoWebView to work with SwipeRefreshLayout
Resolves: #33
Description:
Based on PR by @malmstein #750. Fixes the weird swipe behavior in conjunction with the custom WebView (was too sensitive and did not block WebView scrolling/tapping during refresh swipe).
Some concerns and open issues:
l. 858 BrowserTabFragment
- there's probably a nicer way to do this? Sorry I'm not really much of an Android dev.