Skip to content

Added in swipe gestures to navigate pages #383

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Madmatt88
Copy link

Address issue #41 and adds the feature of being able to use swipe gestures to navigate the pages of a PDF.

@Madmatt88
Copy link
Author

While this is still pending, I will continue to test this build and fix any other issues with the implementation.

@thestinger thestinger force-pushed the main branch 13 times, most recently from 731a863 to 0d0cf10 Compare February 22, 2025 22:01
@thestinger thestinger force-pushed the main branch 2 times, most recently from be232f1 to 799b483 Compare March 22, 2025 20:47
@thestinger thestinger force-pushed the main branch 4 times, most recently from fbe15bf to 99736fc Compare April 11, 2025 04:40
@alt3r-3go
Copy link

This seems to be aiming at the same thing as #282, and both are in the queue for a while. What needs to happen for either of them to be merged? More testing? Anything else? Moving between pages using gestures would be a great UX enhancement (for me, anyway).

@Madmatt88
Copy link
Author

Yes, when I started this I didn’t realise that there was another PR doing the same thing. I would like to see this merged but I haven’t heard anything more on it. I think it needs some work to get it up to scratch with the rest of the code and would like that help.

@alt3r-3go
Copy link

@thestinger or maybe @octocorvus (as a GOS member who had a recent-ish PR here), I'd appreciate a comment. I'm willing to help out to make this one happen, but let's clarify the blockers.

@Madmatt88 could you please update the PR in the meanwhile, to trigger checks and see which ones are failing? The logs for the previous update are already gone.

@thestinger
Copy link
Member

It needs to be implemented as swiping between pages, not a gesture across the screen that's always there.

@Madmatt88
Copy link
Author

@thestinger Thank you for that piece of information, I will have a look and change the implementation to fit that requirement.

@alt3r-3go I will rebase the PR and re-trigger the action to find the build error. After that I'll start to make the changes to fit the new requirements and then update the PR, if I have any major issues I will reach out.

Copy link

@alt3r-3go alt3r-3go left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few comments, hopefully helpful. I'd also suggest taking a look at the other PR on this, as it seems to have pieces worth merging here.

@@ -24,9 +32,20 @@ static void attach(Context context, View gestureView, GestureListener listener)
final GestureDetector detector = new GestureDetector(context,
new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent motionEvent) {
public boolean onSingleTapUp(@NonNull MotionEvent motionEvent) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems unrelated to the PR topic, I'd suggest removing, to avoid polluting git history.

boolean onFling(@Nullable MotionEvent e1, @NonNull MotionEvent e2, float velocityX, float velocityY);
boolean onDown();
// Can be replaced with ratio when supported
void onZoomIn(float value);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder why would this and the next one are needed, given it's not about zooming?

public void onZoom(float scaleFactor, float focusX, float focusY) {
zoom(scaleFactor, focusX, focusY, false);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whitespace-only changes like this are usually discouraged, or at least should be split out to dedicated commits.

float deltaY = e2.getY() - e1.getY();

if (Math.abs(deltaX) > Math.abs(deltaY)){
if ((deltaX > 0) & (Math.abs(velocityX) > maxXVelocity)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bitwise & operator used instead of the boolean one.

if ((deltaX > 0) & (Math.abs(velocityX) > maxXVelocity)) {
Log.d("Horizontal", "Right movement Position");
onJumpToPageInDocument(mPage - 1);
} else if ((Math.abs(velocityX) > maxXVelocity)) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd suggest moving this condition over to the higher-level if clause, to simplify and avoid repeating it.

}

@Override
public boolean onDown() {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this one really necessary?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants