diff --git a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java index aced6faad..a2e4ac8d5 100644 --- a/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java +++ b/src/pandroid/app/src/main/java/com/panda3ds/pandroid/app/GameActivity.java @@ -2,6 +2,7 @@ import android.content.Intent; import android.os.Bundle; +import android.view.GestureDetector; import android.view.KeyEvent; import android.view.MotionEvent; import android.view.View; @@ -25,6 +26,7 @@ public class GameActivity extends BaseActivity { private final DrawerFragment drawerFragment = new DrawerFragment(); private final AlberInputListener inputListener = new AlberInputListener(this::onBackPressed); + private GestureDetector gestureDetector; @Override protected void onCreate(@Nullable Bundle savedInstanceState) { @@ -58,6 +60,28 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportFragmentManager().beginTransaction().replace(R.id.drawer_fragment, drawerFragment).commitNow(); } + // Initialize gesture detector + @Override + public boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY) { + float distanceX = e2.getX() - e1.getX(); + float distanceY = e2.getY() - e1.getY(); + if (Math.abs(distanceX) > Math.abs(distanceY) && distanceX > 0) { + //// Open the drawer when swiping from left to right + if (drawerFragment.isOpened()) { + } else { + drawerFragment.open(); + } + return true; + } + return false; +} + + @Override + public boolean dispatchTouchEvent(MotionEvent ev) { + gestureDetector.onTouchEvent(ev); + return super.dispatchTouchEvent(ev); + } + @Override protected void onResume() { super.onResume();