mirror of
https://github.com/geometer/FBReaderJ.git
synced 2025-10-04 02:09:35 +02:00
single/double tap support has been implemented; navigation window by douple tap
This commit is contained in:
parent
cd3225a8dc
commit
b46a440cbd
4 changed files with 102 additions and 34 deletions
|
@ -4,9 +4,8 @@ DONE Synchronize resources
|
||||||
DONE Option for opening ColorDict immediately by finger tap
|
DONE Option for opening ColorDict immediately by finger tap
|
||||||
DONE Synchronize resources
|
DONE Synchronize resources
|
||||||
DONE 3-mode tapping behaviour
|
DONE 3-mode tapping behaviour
|
||||||
* long tapping processing instead of short one?
|
DONE long tapping processing instead of short one
|
||||||
|
|
||||||
After 0.99:
|
After 0.99:
|
||||||
* More convenient mode changing
|
|
||||||
* Installation from the site if AM is not available
|
* Installation from the site if AM is not available
|
||||||
* Integration with other dictionaries
|
* Integration with other dictionaries
|
||||||
|
|
|
@ -76,6 +76,59 @@ public final class FBView extends ZLTextView {
|
||||||
private boolean myIsBrightnessAdjustmentInProgress;
|
private boolean myIsBrightnessAdjustmentInProgress;
|
||||||
private int myStartBrightness;
|
private int myStartBrightness;
|
||||||
|
|
||||||
|
public boolean onFingerSingleTap(int x, int y) {
|
||||||
|
if (super.onFingerSingleTap(x, y)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isScrollingActive()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (myReader.FooterIsSensitiveOption.getValue()) {
|
||||||
|
Footer footer = getFooterArea();
|
||||||
|
if (footer != null && y > myContext.getHeight() - footer.getTapHeight()) {
|
||||||
|
footer.setProgress(x);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextHyperlinkRegion.Filter);
|
||||||
|
if (region != null) {
|
||||||
|
selectRegion(region);
|
||||||
|
myReader.repaintView();
|
||||||
|
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
|
if (!preferences.FlickOption.getValue()) {
|
||||||
|
if (preferences.HorizontalOption.getValue()) {
|
||||||
|
if (x <= myContext.getWidth() / 3) {
|
||||||
|
doScrollPage(false);
|
||||||
|
} else if (x >= myContext.getWidth() * 2 / 3) {
|
||||||
|
doScrollPage(true);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (y <= myContext.getHeight() / 3) {
|
||||||
|
doScrollPage(false);
|
||||||
|
} else if (y >= myContext.getHeight() * 2 / 3) {
|
||||||
|
doScrollPage(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onFingerDoubleTap() {
|
||||||
|
if (super.onFingerDoubleTap()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
myReader.doAction(ActionCode.SHOW_NAVIGATION);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onFingerPress(int x, int y) {
|
public boolean onFingerPress(int x, int y) {
|
||||||
if (super.onFingerPress(x, y)) {
|
if (super.onFingerPress(x, y)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -100,37 +153,14 @@ public final class FBView extends ZLTextView {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final ZLTextElementRegion region = findRegion(x, y, 10, ZLTextHyperlinkRegion.Filter);
|
|
||||||
if (region != null) {
|
|
||||||
selectRegion(region);
|
|
||||||
myReader.repaintView();
|
|
||||||
myReader.doAction(ActionCode.PROCESS_HYPERLINK);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
final ScrollingPreferences preferences = ScrollingPreferences.Instance();
|
||||||
if (preferences.FlickOption.getValue()) {
|
if (preferences.FlickOption.getValue()) {
|
||||||
myStartX = x;
|
myStartX = x;
|
||||||
myStartY = y;
|
myStartY = y;
|
||||||
setScrollingActive(true);
|
setScrollingActive(true);
|
||||||
myIsManualScrollingActive = true;
|
myIsManualScrollingActive = true;
|
||||||
} else {
|
|
||||||
if (preferences.HorizontalOption.getValue()) {
|
|
||||||
if (x <= myContext.getWidth() / 3) {
|
|
||||||
doScrollPage(false);
|
|
||||||
} else if (x >= myContext.getWidth() * 2 / 3) {
|
|
||||||
doScrollPage(true);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (y <= myContext.getHeight() / 3) {
|
|
||||||
doScrollPage(false);
|
|
||||||
} else if (y >= myContext.getHeight() * 2 / 3) {
|
|
||||||
doScrollPage(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//activateSelection(x, y);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +275,6 @@ public final class FBView extends ZLTextView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//myReader.doAction(ActionCode.SHOW_NAVIGATION);
|
|
||||||
//return true;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -66,6 +66,18 @@ abstract public class ZLView {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean onFingerSingleTap(int x, int y) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean onFingerDoubleTap() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDoubleTapSupported() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean onTrackballRotated(int diffX, int diffY) {
|
public boolean onTrackballRotated(int diffX, int diffY) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -329,19 +329,29 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private volatile LongClickRunnable myPendingLongClickRunnable;
|
||||||
private LongClickRunnable myPendingLongClickRunnable;
|
private volatile boolean myLongClickPerformed;
|
||||||
private boolean myLongClickPerformed;
|
|
||||||
|
|
||||||
private void postLongClickRunnable() {
|
private void postLongClickRunnable() {
|
||||||
myLongClickPerformed = false;
|
myLongClickPerformed = false;
|
||||||
|
myPendingPress = false;
|
||||||
if (myPendingLongClickRunnable == null) {
|
if (myPendingLongClickRunnable == null) {
|
||||||
myPendingLongClickRunnable = new LongClickRunnable();
|
myPendingLongClickRunnable = new LongClickRunnable();
|
||||||
}
|
}
|
||||||
postDelayed(myPendingLongClickRunnable, 2 * ViewConfiguration.getLongPressTimeout());
|
postDelayed(myPendingLongClickRunnable, 2 * ViewConfiguration.getLongPressTimeout());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean myPendingPress;
|
private class ShortClickRunnable implements Runnable {
|
||||||
|
public void run() {
|
||||||
|
final ZLView view = ZLApplication.Instance().getCurrentView();
|
||||||
|
view.onFingerSingleTap(myPressedX, myPressedY);
|
||||||
|
myPendingPress = false;
|
||||||
|
myPendingShortClickRunnable = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private volatile ShortClickRunnable myPendingShortClickRunnable;
|
||||||
|
|
||||||
|
private volatile boolean myPendingPress;
|
||||||
private int myPressedX, myPressedY;
|
private int myPressedX, myPressedY;
|
||||||
private boolean myScreenIsTouched;
|
private boolean myScreenIsTouched;
|
||||||
@Override
|
@Override
|
||||||
|
@ -357,17 +367,32 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
} else {
|
} else {
|
||||||
if (myPendingLongClickRunnable != null) {
|
if (myPendingLongClickRunnable != null) {
|
||||||
removeCallbacks(myPendingLongClickRunnable);
|
removeCallbacks(myPendingLongClickRunnable);
|
||||||
|
myPendingLongClickRunnable = null;
|
||||||
}
|
}
|
||||||
if (myPendingPress) {
|
if (myPendingPress) {
|
||||||
view.onFingerPress(myPressedX, myPressedY);
|
if (view.isDoubleTapSupported()) {
|
||||||
|
if (myPendingShortClickRunnable == null) {
|
||||||
|
myPendingShortClickRunnable = new ShortClickRunnable();
|
||||||
}
|
}
|
||||||
|
postDelayed(myPendingShortClickRunnable, ViewConfiguration.getDoubleTapTimeout());
|
||||||
|
} else {
|
||||||
|
view.onFingerSingleTap(x, y);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
view.onFingerRelease(x, y);
|
view.onFingerRelease(x, y);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
myPendingPress = false;
|
myPendingPress = false;
|
||||||
myScreenIsTouched = false;
|
myScreenIsTouched = false;
|
||||||
break;
|
break;
|
||||||
case MotionEvent.ACTION_DOWN:
|
case MotionEvent.ACTION_DOWN:
|
||||||
|
if (myPendingShortClickRunnable != null) {
|
||||||
|
removeCallbacks(myPendingShortClickRunnable);
|
||||||
|
myPendingShortClickRunnable = null;
|
||||||
|
view.onFingerDoubleTap();
|
||||||
|
} else {
|
||||||
postLongClickRunnable();
|
postLongClickRunnable();
|
||||||
|
}
|
||||||
myScreenIsTouched = true;
|
myScreenIsTouched = true;
|
||||||
myPendingPress = true;
|
myPendingPress = true;
|
||||||
myPressedX = x;
|
myPressedX = x;
|
||||||
|
@ -378,6 +403,10 @@ public class ZLAndroidWidget extends View implements View.OnLongClickListener {
|
||||||
view.onFingerMoveAfterLongPress(x, y);
|
view.onFingerMoveAfterLongPress(x, y);
|
||||||
} else {
|
} else {
|
||||||
if (myPendingPress) {
|
if (myPendingPress) {
|
||||||
|
if (myPendingShortClickRunnable != null) {
|
||||||
|
removeCallbacks(myPendingShortClickRunnable);
|
||||||
|
myPendingShortClickRunnable = null;
|
||||||
|
}
|
||||||
final int slop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
|
final int slop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
|
||||||
if (Math.abs(myPressedX - x) > slop || Math.abs(myPressedY - y) > slop) {
|
if (Math.abs(myPressedX - x) > slop || Math.abs(myPressedY - y) > slop) {
|
||||||
if (myPendingLongClickRunnable != null) {
|
if (myPendingLongClickRunnable != null) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue