@@ -647,7 +647,7 @@ public void copyToClipboard( String text ) {
647647// private int selectionEndX = 0;
648648// private int selectionEndY = 0;
649649 private boolean doubleTapSelectionEnabled = false ;
650- private boolean gesturePageFlippingEnabled = true ;
650+ private int mGesturePageFlipsPerFullSwipe ;
651651 private boolean mIsPageMode ;
652652 private int secondaryTapActionType = TAP_ACTION_TYPE_LONGPRESS ;
653653 private boolean selectionModeActive = false ;
@@ -937,6 +937,7 @@ public class TapHandler {
937937 private final static int STATE_WAIT_FOR_DOUBLE_CLICK = 5 ; // flipping is in progress
938938 private final static int STATE_DONE = 6 ; // done: no more tracking
939939 private final static int STATE_BRIGHTNESS = 7 ; // brightness change in progress
940+ private final static int STATE_FLIP_TRACKING = 8 ; // pages flip tracking in progress
940941
941942 private final static int EXPIRATION_TIME_MS = 180000 ;
942943
@@ -980,6 +981,7 @@ private boolean cancel() {
980981 case STATE_WAIT_FOR_DOUBLE_CLICK :
981982 case STATE_DONE :
982983 case STATE_BRIGHTNESS :
984+ case STATE_FLIP_TRACKING :
983985 stopBrightnessControl (-1 , -1 );
984986 break ;
985987 }
@@ -989,6 +991,41 @@ private boolean cancel() {
989991 return true ;
990992 }
991993
994+ private void adjustStartValuesOnDrag (int swipeDistance , int distanceForFlip ) {
995+ if (Math .abs (swipeDistance ) < distanceForFlip ) {
996+ return ; // Nothing to do
997+ }
998+ int direction = swipeDistance > 0 ? 1 : -1 ; // Left-to-right or right-to-left swipe?
999+ int value = direction * distanceForFlip ;
1000+ while (Math .abs (swipeDistance ) >= distanceForFlip ) {
1001+ if (mIsPageMode ) {
1002+ start_x += value ;
1003+ } else {
1004+ start_y += value ;
1005+ }
1006+ swipeDistance -= value ;
1007+ }
1008+ }
1009+
1010+ private void updatePageFlipTracking (final int x , final int y ) {
1011+ final int swipeDistance = mIsPageMode ? x - start_x : y - start_y ;
1012+ final int distanceForFlip = surface .getWidth () / mGesturePageFlipsPerFullSwipe ;
1013+ int pagesToFlip = swipeDistance / distanceForFlip ;
1014+ if (pagesToFlip == 0 ) {
1015+ return ; // Nothing to do
1016+ }
1017+ adjustStartValuesOnDrag (swipeDistance , distanceForFlip );
1018+ ReaderAction action = pagesToFlip > 0 ? ReaderAction .PAGE_DOWN : ReaderAction .PAGE_UP ;
1019+ while (pagesToFlip != 0 ) {
1020+ onAction (action );
1021+ if (pagesToFlip > 0 ) {
1022+ pagesToFlip --;
1023+ } else {
1024+ pagesToFlip ++;
1025+ }
1026+ }
1027+ }
1028+
9921029 /// perform action and reset touch tracking state
9931030 private boolean performAction (final ReaderAction action , boolean checkForLinks ) {
9941031 log .d ("performAction on touch: " + action );
@@ -1191,6 +1228,10 @@ public boolean onTouchEvent(MotionEvent event) {
11911228 selectionModeActive = false ;
11921229 state = STATE_DONE ;
11931230 return cancel ();
1231+ case STATE_FLIP_TRACKING :
1232+ updatePageFlipTracking (x , y );
1233+ state = STATE_DONE ;
1234+ return cancel ();
11941235 }
11951236 } else if (event .getAction () == MotionEvent .ACTION_DOWN ) {
11961237 switch (state ) {
@@ -1215,6 +1256,7 @@ public boolean onTouchEvent(MotionEvent event) {
12151256 case STATE_BRIGHTNESS :
12161257 case STATE_FLIPPING :
12171258 case STATE_SELECTION :
1259+ case STATE_FLIP_TRACKING :
12181260 return unexpectedEvent ();
12191261 case STATE_WAIT_FOR_DOUBLE_CLICK :
12201262 if (doubleTapAction == ReaderAction .START_SELECTION )
@@ -1243,7 +1285,7 @@ public boolean onTouchEvent(MotionEvent event) {
12431285 }
12441286 }
12451287 int dir = mIsPageMode ? x - start_x : y - start_y ;
1246- if (gesturePageFlippingEnabled ) {
1288+ if (mGesturePageFlipsPerFullSwipe == 1 ) {
12471289 if (pageFlipAnimationSpeedMs == 0 || DeviceInfo .EINK_SCREEN ) {
12481290 // no animation
12491291 return performAction (dir < 0 ? ReaderAction .PAGE_DOWN : ReaderAction .PAGE_UP , false );
@@ -1252,13 +1294,20 @@ public boolean onTouchEvent(MotionEvent event) {
12521294 updateAnimation (x , y );
12531295 state = STATE_FLIPPING ;
12541296 }
1297+ if (mGesturePageFlipsPerFullSwipe > 1 ) {
1298+ state = STATE_FLIP_TRACKING ;
1299+ updatePageFlipTracking (start_x , start_y );
1300+ }
12551301 return true ;
12561302 case STATE_FLIPPING :
12571303 updateAnimation (x , y );
12581304 return true ;
12591305 case STATE_BRIGHTNESS :
12601306 updateBrightnessControl (x , y );
12611307 return true ;
1308+ case STATE_FLIP_TRACKING :
1309+ updatePageFlipTracking (x , y );
1310+ return true ;
12621311 case STATE_WAIT_FOR_DOUBLE_CLICK :
12631312 return true ;
12641313 case STATE_SELECTION :
@@ -2625,7 +2674,7 @@ public void applyAppSetting( String key, String value )
26252674 } else if ( key .equals (PROP_APP_DOUBLE_TAP_SELECTION ) ) {
26262675 doubleTapSelectionEnabled = flg ;
26272676 } else if ( key .equals (PROP_APP_GESTURE_PAGE_FLIPPING ) ) {
2628- gesturePageFlippingEnabled = flg ;
2677+ mGesturePageFlipsPerFullSwipe = Integer . valueOf ( value ) ;
26292678 } else if ( key .equals (PROP_PAGE_VIEW_MODE )) {
26302679 mIsPageMode = flg ;
26312680 } else if ( key .equals (PROP_APP_SECONDARY_TAP_ACTION_TYPE ) ) {
0 commit comments