Comments (8)
Coding idea:
//where to get the actual view with visual positions x and y?
// probably the code below should make it into a new function
private void scrollTo(int x, int y) {
saveScrollPos = false; // should this be used only before scrolling?
Log.d(TAG, "Scroll to " + x + ", " + y);
// distinguish horizontal and vertical swipes
if (Math.abs(view.getX() - x) > (Math.abs(view.getY() - y))) { // page turning
if (x > view.getX()) {
if (!articleView.pageDown(false))
nextArticle();
} else
if (!articleView.pageUp(false))
goBack();
} else // scrolling
articleView.scrollTo(x, y);
saveScrollPos = true; // should this be used only after scrolling?
}
from android.
working code for paging by horizontal swipe
dispatchTouchEvent catches all touch events, so also the vertical scroll, need help to integrate.
Would make other scroll code obsolete.
Advantage: no buttons needed, full flicker-free page turns and (flickering) sub-page scroll by gestures.
float x,y;
@Override
public boolean dispatchTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x = event.getX();
y = event.getY();
break;
case MotionEvent.ACTION_UP:
if (Math.abs(event.getX() - x) >= Math.abs(event.getY() - y))
if (event.getX() >= x)
if (!articleView.pageDown(false)) {
nextArticle();
}
else
if (!articleView.pageUp(false)) {
goBack();
}
else
// does not work with this x, y
// articleView.scrollTo(x, y);
break;
}
return false;
}
from android.
previous code should read
if (event.getX() <= x) for correct page turn direction.
from android.
"final" version
add the snippet below in /aarddict-android/src/aarddict/android/ArticleViewActivity.java
- stroke left/right turns the page without flashing
- stroke up/down scrolls without flashing
float x,y;
@OverRide
public boolean dispatchTouchEvent(MotionEvent event) {
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN:
x = event.getX();
y = event.getY();
break;
case MotionEvent.ACTION_UP:
if (Math.abs(event.getX() - x) >= Math.abs(event.getY() - y))
if (event.getX() <= x)
articleView.pageDown(false);
else
articleView.pageUp(false);
else
articleView.scrollBy(0,(int)(y - event.getY()));
break;
}
return false;
}
from android.
Horizontal swipes turning "pages" - a concept that does not exist in the application - is very confusing in presence of multiple articles of the same title. Why would a right-to-left swipe, for example, turn "page" instead of going back? Also, swiping gestures where present in one of early versions, implemented with Adroid's gesture API, but that proved to be brittle and broke down completely in Android 2.2 and was removed. Also, there's no real difference between horizontal and vertical direction, even if horizontal scrolling shows up a lot less often because article text can usually be re-flowed to avoid it. Swipe gestures don't interact very well with regular scrolling, which is probably why they are not implemented in the standard Android Browser. Article viewing in aarddict is very much like viewing a web page. I think trying to implementn book-style navigation on it is a bad idea.
from android.
Horizontal swipes turning "pages" - a concept that does not exist in the application
Which application do you mean? Its the general way ebook pages are turned (Sony reader, Cool Reader, FB Reader, ..)
- is very confusing in presence of multiple articles of the same title.
I do not understand. Do you have an example?
The big advantage I see is to get rid of the hardware button discussion, which comes with the e-readers. They are originally conceived as market channels and have a proprietariy hardware as well as their shops.
If there are pictures or other content which does not reflow - you are right, a gesture which takes the horizontal scroll away and uses it for page turn would be counterproductive. But I have not met any examples.
Personally, I like the proposed navigation very much. Most of the time I can proceed pagewise with a little horizontal gesture like reading a book, if a table or other context needs alignment, I can tear it to where I want it.
So I actually like the book-style navigation. Probably a question of taste. But anyway, there is a need to implement full page turns, using scrolling had the two drawbacks:
- it flickered on e-ink (having 3-5 page refreshes turning the pages shortly to black and back)
- it needed a large gesture to move along.
Thanks again
from android.
I mean, of course, the application whose issue tracker this is - Aard Dictionary. I have nothing against the concept of pages and page turning in e-book readers, but Aard Dictionary is not an e-book reader, never had such ambitions or design goals. It is cool that it happens to run on a variety of devices including those I never thought of, but let's not get carried away, it doesn't change the fact that Wikipedia, Wiktionary and other similar data sources for which Aard Dictionary is made are not really books.
As for examples of horizontal scrolling, they are certainly not hard to come by: open any Wikipedia article with tables, such as "Periodic Table" or large formulas like "Table of Integrals".
from android.
OK, got me. I will think about other methods to combine/distinguish scrolls and full page turns, like speed of swipe.
One drawback of the dispatchTouchEvent command is that it also swallows the links.
Do you have an idea how to allow following a link on touching it within dispatchTouchEvent?
from android.
Related Issues (20)
- aard in nook simpletouch (none glowlight) "Failed to open file " error HOT 2
- unable to download English Wiktionary HOT 4
- dictionary file is too large for embedded device HOT 1
- Links within Wikipedia don't work any more HOT 2
- Links within Wikipedia don't work any more
- Aard error opening large files on reader Sony PRS-T1 HOT 6
- Restore scroll position feature doesn't work on KitKat HOT 3
- Aarddict can't find dictionaries on Blackberry 10 HOT 11
- french wiktonary cant be downloaded HOT 1
- Deutsch Wikipedia volume #2 HOT 1
- android saves dictionary as .bin and aard unable to fond it HOT 1
- Unable to load dictionary HOT 8
- Aarddict can't find dictionaries And exits the program on sony xperia l c2105 HOT 14
- Aarddict loses position when returning in articles HOT 1
- Table of Content issues with Wikipedia HOT 1
- "Not a dictionary file" HOT 2
- What are the required .aar files for aarddict? HOT 2
- Plurals in Wiktionary cause "loading dictionaries..." HOT 5
- Request for inclusion in Fdroid HOT 3
- Phone number links (URIs with tel: schema) are not properly handled HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from android.