kiwix / kiwix-xulrunner

[ARCHIVED] Legacy Kiwix desktop solution for Windows/macOS/Linux
https://download.kiwix.org/release/kiwix-xulrunner/
GNU General Public License v3.0
112 stars 28 forks source link

Add option to autohide app toolbar when reading #359

Closed mhutti1 closed 7 years ago

mhutti1 commented 7 years ago

This would allow users with small screens to have a better reading experience.

mhutti1 commented 7 years ago

Steps to reproduce:

  1. Download a ZIM file through our app.
  2. Scroll down the page.

What you get:

What we want:

GEOFBOT commented 7 years ago

I tried to get this to work using CoordinatorLayout, AppBarLayout, etc. but apparently WebViews don't play nicely with NestedScrollView (http://stackoverflow.com/a/37913484). Would it be sufficient to just to listen for scroll events in the content WebView and to have the toolbar disappear when the WebView scrolls down and vice versa? It wouldn't have the nice animations and behavior that the scrolling behavior with CoordinatorLayout and the support design library offer.

mhutti1 commented 7 years ago

Yes this is fine. If you feel you are up to it you can try implement scroll animation behaviour by looking here https://github.com/wikimedia/apps-android-wikipedia/blob/master/app/src/main/java/org/wikipedia/page/ViewHideHandler.java but it might be a bit tricky.

mhutti1 commented 7 years ago

Or try this second answer http://stackoverflow.com/questions/28770530/how-to-hide-actionbar-toolbar-while-scrolling-down-in-webview

GEOFBOT commented 7 years ago

I've tried to incorporate org.wikipedia.page.ViewHideHandler into Kiwix (see above commit), but the result is very glitchy. The main problem is that the WebView has to move in some cases while the user is dragging to scroll, which leads to inaccurate scrolling changes and flickering. One alternative would be to shrink the WebView's height while keeping it stationary relative to the bottom of the screen.

We wouldn't have to worry about the movement of the toolbar and the scrolling if CoordinatorLayout scroll behavior worked with WebViews. I've found an implementation of a WebView class that is supposed to work with the scroll behavior (https://github.com/takahirom/webview-in-coordinatorlayout) which looks very promising and I'm also trying to get that to work.

mhutti1 commented 7 years ago

@GEOFBOT Great work, either solutions should work, once you have something working (even if its a bit glitchy) you can submit a pull request and I can review and see if I can help.

kelson42 commented 7 years ago

Will have a look, can not wait to see this :)

kelson42 commented 7 years ago

I think the feature looks good in general. On my side I only see a "flash" if I click on the title (to get the searchbox). But if this is fixed, this ticket get my vote to be closed (further problems can be handle in separate tickets).

mhutti1 commented 7 years ago

@EladKeyshawn Can you look into 8e4f3ad06a29e33f11aa36407069df07d4560cc0 . Its causing the search activity to flash in a weird way when launching.

EladKeyshawn commented 7 years ago

@mhutti1 Do you have any idea why the method overridePendingTransition(android.R.anim.fade_in,android.R.anim.fade_out); works only works from search activity to main and not the opposite? cause that's what causing it.

mhutti1 commented 7 years ago

@EladKeyshawn perhaps because we arn't overriding the finish method of KiwixMobileActivity.

EladKeyshawn commented 7 years ago

@mhutti1 I tried now and still doesn't work... so for now I just removed the code causing the flash.

mhutti1 commented 7 years ago

@EladKeyshawn Ok cool