diff --git a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java b/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java index 74cfe6fc7b..61de43edfe 100644 --- a/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java +++ b/OsmAnd/src/net/osmand/plus/dashboard/DashRateUsFragment.java @@ -5,8 +5,6 @@ import android.content.Intent; import android.net.Uri; import android.os.Bundle; import android.support.annotation.Nullable; -import android.support.design.widget.Snackbar; -import android.support.v4.view.ViewCompat; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -49,7 +47,7 @@ public class DashRateUsFragment extends DashBaseFragment { new PositiveButtonListener(header, subheader, positiveButton, negativeButton)); negativeButton.setOnClickListener( new NegativeButtonListener(header, subheader, positiveButton, negativeButton)); - mRateUsDismissListener = new RateUsDismissListener(getParentView(), dashboard, TAG, view, settings); + mRateUsDismissListener = new RateUsDismissListener(dashboard, settings); return view; } @@ -228,50 +226,19 @@ public class DashRateUsFragment extends DashBaseFragment { } private static class RateUsDismissListener implements DismissListener { - private View parentView; private DashboardOnMap dashboardOnMap; - private String fragmentTag; - private View fragmentView; private OsmandSettings settings; - private int exNumberOfRuns; - private long exLastDisplayTime; - public RateUsDismissListener(View parentView, DashboardOnMap dashboardOnMap, - String fragmentTag, View fragmentView, OsmandSettings settings) { - this.parentView = parentView; + public RateUsDismissListener(DashboardOnMap dashboardOnMap, OsmandSettings settings) { this.dashboardOnMap = dashboardOnMap; - this.fragmentTag = fragmentTag; - this.fragmentView = fragmentView; this.settings = settings; } @Override public void onDismiss() { - dashboardOnMap.hideFragmentByTag(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); - Snackbar.make(parentView, dashboardOnMap.getMyApplication().getResources() - .getString(R.string.shared_string_card_was_hidden), Snackbar.LENGTH_LONG) - .setAction(R.string.shared_string_undo, new View.OnClickListener() { - @Override - public void onClick(View view) { - RateUsDismissListener.this.onUndo(exNumberOfRuns, exLastDisplayTime); - } - }) - .show(); settings.RATE_US_STATE.set(RateUsState.IGNORED); - exNumberOfRuns = settings.NUMBER_OF_APPLICATION_STARTS.get(); settings.NUMBER_OF_APPLICATION_STARTS.set(0); - exLastDisplayTime = settings.LAST_DISPLAY_TIME.get(); settings.LAST_DISPLAY_TIME.set(System.currentTimeMillis()); - } - - public void onUndo(int numberOfRuns, long lastDisplayTime) { - dashboardOnMap.unhideFragmentByTag(fragmentTag); - ViewCompat.setTranslationX(fragmentView, 0); - ViewCompat.setAlpha(fragmentView, 1); - settings.NUMBER_OF_APPLICATION_STARTS.set(numberOfRuns); - settings.LAST_DISPLAY_TIME.set(lastDisplayTime); - + dashboardOnMap.refreshDashboardFragments(); } } } diff --git a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java index cb3b1910b8..d0b50e20e8 100644 --- a/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java +++ b/OsmAnd/src/net/osmand/plus/widgets/tools/SwipeDismissTouchListener.java @@ -143,7 +143,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener { dismiss = (velocityX < 0) == (deltaX < 0); dismissRight = mVelocityTracker.getXVelocity() > 0; } - if (dismiss) { + if (dismiss && dismissRight) { // dismiss final boolean finalDismissRight = dismissRight; ViewCompat.animate(mView) @@ -210,7 +210,7 @@ public class SwipeDismissTouchListener implements View.OnTouchListener { mVelocityTracker.addMovement(motionEvent); float deltaX = motionEvent.getRawX() - mDownX; float deltaY = motionEvent.getRawY() - mDownY; - if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) { + if (deltaX > mSlop && Math.abs(deltaY) < deltaX / 2) { mSwiping = true; mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop); mView.getParent().requestDisallowInterceptTouchEvent(true);