diff --git a/.project b/.project
index ee140b370..1430a6bb9 100644
--- a/.project
+++ b/.project
@@ -25,8 +25,14 @@
+
+ org.eclipse.m2e.core.maven2Builder
+
+
+
+ org.eclipse.m2e.core.maven2Nature
com.android.ide.eclipse.adt.AndroidNature
org.eclipse.jdt.core.javanature
diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..99f26c020
--- /dev/null
+++ b/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,2 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/example/.classpath b/example/.classpath
index 570891c68..98df56fc4 100644
--- a/example/.classpath
+++ b/example/.classpath
@@ -1,8 +1,9 @@
+
-
+
diff --git a/example/.settings/org.eclipse.jdt.core.prefs b/example/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..b080d2ddc
--- /dev/null
+++ b/example/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,4 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/library-maps-support/.classpath b/library-maps-support/.classpath
new file mode 100644
index 000000000..f7b0a5db4
--- /dev/null
+++ b/library-maps-support/.classpath
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/library-maps-support/.settings/org.eclipse.core.resources.prefs b/library-maps-support/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..7a5313928
--- /dev/null
+++ b/library-maps-support/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
+encoding/src=UTF-8
diff --git a/library-maps-support/.settings/org.eclipse.jdt.core.prefs b/library-maps-support/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..60105c1b9
--- /dev/null
+++ b/library-maps-support/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.6
diff --git a/library-maps-support/.settings/org.eclipse.m2e.core.prefs b/library-maps-support/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/library-maps-support/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/library-maps-support/pom.xml b/library-maps-support/pom.xml
index 571a6cb23..e7f453311 100644
--- a/library-maps-support/pom.xml
+++ b/library-maps-support/pom.xml
@@ -15,7 +15,12 @@
-
+
+ com.google.android
+ android
+ provided
+
+
com.jeremyfeinstein.slidingmenu
slidingmenu
true
@@ -38,6 +43,14 @@
ignored
+
+ maven-compiler-plugin
+ 3.0
+
+ 1.6
+ 1.6
+
+
diff --git a/library/.classpath b/library/.classpath
index 570891c68..0b92f1090 100644
--- a/library/.classpath
+++ b/library/.classpath
@@ -1,8 +1,22 @@
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/library/.settings/org.eclipse.core.resources.prefs b/library/.settings/org.eclipse.core.resources.prefs
new file mode 100644
index 000000000..7a5313928
--- /dev/null
+++ b/library/.settings/org.eclipse.core.resources.prefs
@@ -0,0 +1,3 @@
+eclipse.preferences.version=1
+encoding/=UTF-8
+encoding/src=UTF-8
diff --git a/library/.settings/org.eclipse.jdt.core.prefs b/library/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 000000000..abec6ca38
--- /dev/null
+++ b/library/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,5 @@
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.source=1.5
diff --git a/library/.settings/org.eclipse.m2e.core.prefs b/library/.settings/org.eclipse.m2e.core.prefs
new file mode 100644
index 000000000..f897a7f1c
--- /dev/null
+++ b/library/.settings/org.eclipse.m2e.core.prefs
@@ -0,0 +1,4 @@
+activeProfiles=
+eclipse.preferences.version=1
+resolveWorkspaceProjects=true
+version=1
diff --git a/library/libs/android-support-v4.jar b/library/libs/android-support-v4.jar
deleted file mode 100644
index 6080877d4..000000000
Binary files a/library/libs/android-support-v4.jar and /dev/null differ
diff --git a/library/pom.xml b/library/pom.xml
index 081bbc74b..12d72ad45 100644
--- a/library/pom.xml
+++ b/library/pom.xml
@@ -18,7 +18,8 @@
com.google.android
android
-
+ provided
+
com.google.android
support-v4
diff --git a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java
index 42b2973d2..3b4124366 100644
--- a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java
+++ b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewAbove.java
@@ -61,6 +61,7 @@ public float getInterpolation(float t) {
private boolean mIsUnableToDrag;
private int mTouchSlop;
private float mInitialMotionX;
+ private float mInitialMotionY;
/**
* Position of the last motion event.
*/
@@ -86,7 +87,7 @@ public float getInterpolation(float t) {
private int mFlingDistance;
private CustomViewBehind mViewBehind;
- // private int mMode;
+ // private int mMode;
private boolean mEnabled = true;
private OnPageChangeListener mOnPageChangeListener;
@@ -226,7 +227,12 @@ void setCurrentItemInternal(int item, boolean smoothScroll, boolean always, int
final boolean dispatchSelected = mCurItem != item;
mCurItem = item;
- final int destX = getDestScrollX(mCurItem);
+ int destX = 0;
+ int destY = 0;
+ if(mViewBehind.getMode() == SlidingMenu.TOP)
+ destY = getDestScrollY(mCurItem);
+ else
+ destX = getDestScrollX(mCurItem);
if (dispatchSelected && mOnPageChangeListener != null) {
mOnPageChangeListener.onPageSelected(item);
}
@@ -234,10 +240,10 @@ void setCurrentItemInternal(int item, boolean smoothScroll, boolean always, int
mInternalPageChangeListener.onPageSelected(item);
}
if (smoothScroll) {
- smoothScrollTo(destX, 0, velocity);
+ smoothScrollTo(destX, destY, velocity);
} else {
completeScroll();
- scrollTo(destX, 0);
+ scrollTo(destX, destY);
}
}
@@ -314,6 +320,17 @@ public int getDestScrollX(int page) {
return 0;
}
+ public int getDestScrollY(int page) {
+ switch (page) {
+ case 0:
+ case 2:
+ return mViewBehind.getMenuTop(mContent, page);
+ case 1:
+ return mContent.getTop();
+ }
+ return 0;
+ }
+
private int getLeftBound() {
return mViewBehind.getAbsLeftBound(mContent);
}
@@ -322,6 +339,14 @@ private int getRightBound() {
return mViewBehind.getAbsRightBound(mContent);
}
+ private int getTopBound() {
+ return mViewBehind.getAbsTopBound(mContent);
+ }
+
+ private int getBottomBound() {
+ return mViewBehind.getAbsBottomBound(mContent);
+ }
+
public int getContentLeft() {
return mContent.getLeft() + mContent.getPaddingLeft();
}
@@ -347,6 +372,14 @@ public int getBehindWidth() {
}
}
+ public int getBehindHeight() {
+ if (mViewBehind == null) {
+ return 0;
+ } else {
+ return mViewBehind.getBehindHeight();
+ }
+ }
+
public int getChildWidth(int i) {
switch (i) {
case 0:
@@ -460,12 +493,12 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
// Make sure scroll position is set correctly.
- if (w != oldw) {
+ if (w != oldw || h != oldh) {
// [ChrisJ] - This fixes the onConfiguration change for orientation issue..
// maybe worth having a look why the recomputeScroll pos is screwing
// up?
completeScroll();
- scrollTo(getDestScrollX(mCurItem), getScrollY());
+ scrollTo(getDestScrollX(mCurItem), getDestScrollY(mCurItem));
}
}
@@ -496,6 +529,7 @@ public void computeScroll() {
if (oldX != x || oldY != y) {
scrollTo(x, y);
pageScrolled(x);
+ pageScrolled(y);
}
// Keep on drawing until the animation has finished.
@@ -524,17 +558,17 @@ private void pageScrolled(int xpos) {
* (e.g. super.onPageScrolled(position, offset, offsetPixels)) before onPageScrolled
* returns.
*
- * @param position Position index of the first page currently being displayed.
+ * @param positionX Position index of the first page currently being displayed.
* Page position+1 will be visible if positionOffset is nonzero.
- * @param offset Value from [0, 1) indicating the offset from the page at position.
- * @param offsetPixels Value in pixels indicating the offset from position.
+ * @param offsetX Value from [0, 1) indicating the offset from the page at position.
+ * @param offsetPixelsX Value in pixels indicating the offset from position.
*/
- protected void onPageScrolled(int position, float offset, int offsetPixels) {
+ protected void onPageScrolled(int positionX, float offsetX, int offsetPixelsX) {
if (mOnPageChangeListener != null) {
- mOnPageChangeListener.onPageScrolled(position, offset, offsetPixels);
+ mOnPageChangeListener.onPageScrolled(positionX, offsetX, offsetPixelsX);
}
if (mInternalPageChangeListener != null) {
- mInternalPageChangeListener.onPageScrolled(position, offset, offsetPixels);
+ mInternalPageChangeListener.onPageScrolled(positionX, offsetX, offsetPixelsX);
}
}
@@ -574,8 +608,9 @@ public int getTouchMode() {
private boolean thisTouchAllowed(MotionEvent ev) {
int x = (int) (ev.getX() + mScrollX);
+ int y = (int) (ev.getY() + mScrollY);
if (isMenuOpen()) {
- return mViewBehind.menuOpenTouchAllowed(mContent, mCurItem, x);
+ return mViewBehind.menuOpenTouchAllowed(mContent, mCurItem, x, y);
} else {
switch (mTouchMode) {
case SlidingMenu.TOUCHMODE_FULLSCREEN:
@@ -638,7 +673,7 @@ public boolean onInterceptTouchEvent(MotionEvent ev) {
if (mActivePointerId == INVALID_POINTER)
break;
mLastMotionX = mInitialMotionX = MotionEventCompat.getX(ev, index);
- mLastMotionY = MotionEventCompat.getY(ev, index);
+ mLastMotionY = mInitialMotionY = MotionEventCompat.getY(ev, index);
if (thisTouchAllowed(ev)) {
mIsBeingDragged = false;
mIsUnableToDrag = false;
@@ -695,6 +730,7 @@ public boolean onTouchEvent(MotionEvent ev) {
int index = MotionEventCompat.getActionIndex(ev);
mActivePointerId = MotionEventCompat.getPointerId(ev, index);
mLastMotionX = mInitialMotionX = ev.getX();
+ mLastMotionY = mInitialMotionY = ev.getY();
break;
case MotionEvent.ACTION_MOVE:
if (!mIsBeingDragged) {
@@ -703,43 +739,81 @@ public boolean onTouchEvent(MotionEvent ev) {
return false;
}
if (mIsBeingDragged) {
- // Scroll to follow the motion event
- final int activePointerIndex = getPointerIndex(ev, mActivePointerId);
- if (mActivePointerId == INVALID_POINTER)
- break;
- final float x = MotionEventCompat.getX(ev, activePointerIndex);
- final float deltaX = mLastMotionX - x;
- mLastMotionX = x;
- float oldScrollX = getScrollX();
- float scrollX = oldScrollX + deltaX;
- final float leftBound = getLeftBound();
- final float rightBound = getRightBound();
- if (scrollX < leftBound) {
- scrollX = leftBound;
- } else if (scrollX > rightBound) {
- scrollX = rightBound;
- }
- // Don't lose the rounded component
- mLastMotionX += scrollX - (int) scrollX;
- scrollTo((int) scrollX, getScrollY());
- pageScrolled((int) scrollX);
+ // Scroll to follow the motion event
+ final int activePointerIndex = getPointerIndex(ev, mActivePointerId);
+ if (mActivePointerId == INVALID_POINTER)
+ break;
+
+ if(mViewBehind.getMode() == SlidingMenu.TOP) {
+ final float y = MotionEventCompat.getY(ev, activePointerIndex);
+ final float deltaY = mLastMotionY - y;
+ mLastMotionY = y;
+ float oldScrollY = getScrollY();
+ float scrollY = oldScrollY + deltaY;
+ final float topBound = getTopBound();
+ final float bottomBound = getBottomBound();
+ if (scrollY < topBound) {
+ scrollY = topBound;
+ } else if (scrollY > bottomBound) {
+ scrollY = bottomBound;
+ }
+ // Don't lose the rounded component
+ mLastMotionY += scrollY - (int) scrollY;
+ scrollTo(getScrollX(), (int)scrollY);
+ pageScrolled((int)scrollY);
+ }else {
+ final float x = MotionEventCompat.getX(ev, activePointerIndex);
+ final float deltaX = mLastMotionX - x;
+ mLastMotionX = x;
+ float oldScrollX = getScrollX();
+ float scrollX = oldScrollX + deltaX;
+ final float leftBound = getLeftBound();
+ final float rightBound = getRightBound();
+ if (scrollX < leftBound) {
+ scrollX = leftBound;
+ } else if (scrollX > rightBound) {
+ scrollX = rightBound;
+ }
+ // Don't lose the rounded component
+ mLastMotionX += scrollX - (int) scrollX;
+ scrollTo((int) scrollX, getScrollY());
+ pageScrolled((int) scrollX);
+ }
}
break;
case MotionEvent.ACTION_UP:
if (mIsBeingDragged) {
final VelocityTracker velocityTracker = mVelocityTracker;
velocityTracker.computeCurrentVelocity(1000, mMaximumVelocity);
- int initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
- velocityTracker, mActivePointerId);
+ int initialVelocity;
+ if(mViewBehind.getMode() == SlidingMenu.TOP) {
+ initialVelocity = (int) VelocityTrackerCompat.getYVelocity(
+ velocityTracker, mActivePointerId);
+ }else {
+ initialVelocity = (int) VelocityTrackerCompat.getXVelocity(
+ velocityTracker, mActivePointerId);
+ }
final int scrollX = getScrollX();
+ final int scrollY = getScrollY();
// final int widthWithMargin = getWidth();
// final float pageOffset = (float) (scrollX % widthWithMargin) / widthWithMargin;
// TODO test this. should get better flinging behavior
- final float pageOffset = (float) (scrollX - getDestScrollX(mCurItem)) / getBehindWidth();
+ float pageOffset;
+ if(mViewBehind.getMode() == SlidingMenu.TOP) {
+ pageOffset = (float) (scrollY - getDestScrollY(mCurItem)) / getBehindHeight();
+ } else {
+ pageOffset = (float) (scrollX - getDestScrollX(mCurItem)) / getBehindWidth();
+ }
final int activePointerIndex = getPointerIndex(ev, mActivePointerId);
if (mActivePointerId != INVALID_POINTER) {
- final float x = MotionEventCompat.getX(ev, activePointerIndex);
- final int totalDelta = (int) (x - mInitialMotionX);
+ int totalDelta;
+ if(mViewBehind.getMode() == SlidingMenu.TOP) {
+ final float y = MotionEventCompat.getY(ev, activePointerIndex);
+ totalDelta = (int) (y - mInitialMotionY);
+ }else {
+ final float x = MotionEventCompat.getX(ev, activePointerIndex);
+ totalDelta = (int) (x - mInitialMotionX);
+ }
int nextPage = determineTargetPage(pageOffset, initialVelocity, totalDelta);
setCurrentItemInternal(nextPage, true, true, initialVelocity);
} else {
@@ -788,14 +862,27 @@ private void determineDrag(MotionEvent ev) {
final float y = MotionEventCompat.getY(ev, pointerIndex);
final float dy = y - mLastMotionY;
final float yDiff = Math.abs(dy);
- if (xDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && xDiff > yDiff && thisSlideAllowed(dx)) {
- startDrag();
- mLastMotionX = x;
- mLastMotionY = y;
- setScrollingCacheEnabled(true);
- // TODO add back in touch slop check
- } else if (xDiff > mTouchSlop) {
- mIsUnableToDrag = true;
+
+ if(mViewBehind.getMode() == SlidingMenu.TOP) {
+ if (yDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && yDiff > xDiff && thisSlideAllowed(dy)) {
+ startDrag();
+ mLastMotionX = x;
+ mLastMotionY = y;
+ setScrollingCacheEnabled(true);
+ // TODO add back in touch slop check
+ } else if (yDiff > mTouchSlop) {
+ mIsUnableToDrag = true;
+ }
+ }else {
+ if (xDiff > (isMenuOpen()?mTouchSlop/2:mTouchSlop) && xDiff > yDiff && thisSlideAllowed(dx)) {
+ startDrag();
+ mLastMotionX = x;
+ mLastMotionY = y;
+ setScrollingCacheEnabled(true);
+ // TODO add back in touch slop check
+ } else if (xDiff > mTouchSlop) {
+ mIsUnableToDrag = true;
+ }
}
}
@@ -803,6 +890,7 @@ private void determineDrag(MotionEvent ev) {
public void scrollTo(int x, int y) {
super.scrollTo(x, y);
mScrollX = x;
+ mScrollY = y;
mViewBehind.scrollBehindTo(mContent, x, y);
((SlidingMenu)getParent()).manageLayers(getPercentOpen());
}
@@ -822,7 +910,10 @@ private int determineTargetPage(float pageOffset, int velocity, int deltaX) {
}
protected float getPercentOpen() {
- return Math.abs(mScrollX-mContent.getLeft()) / getBehindWidth();
+ if(mViewBehind.getMode() == SlidingMenu.TOP)
+ return Math.abs(mScrollY-mContent.getTop()) / getBehindHeight();
+ else
+ return Math.abs(mScrollX-mContent.getLeft()) / getBehindWidth();
}
@Override
@@ -836,6 +927,7 @@ protected void dispatchDraw(Canvas canvas) {
// variables for drawing
private float mScrollX = 0.0f;
+ private float mScrollY = 0.0f;
private void onSecondaryPointerUp(MotionEvent ev) {
if (DEBUG) Log.v(TAG, "onSecondaryPointerUp called");
diff --git a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java
index fa0544d5b..78ea0af3e 100644
--- a/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java
+++ b/library/src/com/jeremyfeinstein/slidingmenu/lib/CustomViewBehind.java
@@ -12,6 +12,7 @@
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.FrameLayout;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu.CanvasTransformer;
@@ -28,6 +29,7 @@ public class CustomViewBehind extends ViewGroup {
private View mSecondaryContent;
private int mMarginThreshold;
private int mWidthOffset;
+ private int mHeightOffset;
private CanvasTransformer mTransformer;
private boolean mChildrenEnabled;
@@ -53,6 +55,11 @@ public void setWidthOffset(int i) {
mWidthOffset = i;
requestLayout();
}
+
+ public void setHeightOffset(int i) {
+ mHeightOffset = i;
+ requestLayout();
+ }
public void setMarginThreshold(int marginThreshold) {
mMarginThreshold = marginThreshold;
@@ -66,6 +73,10 @@ public int getBehindWidth() {
return mContent.getWidth();
}
+ public int getBehindHeight() {
+ return mContent.getHeight();
+ }
+
public void setContent(View v) {
if (mContent != null)
removeView(mContent);
@@ -128,9 +139,9 @@ protected void dispatchDraw(Canvas canvas) {
protected void onLayout(boolean changed, int l, int t, int r, int b) {
final int width = r - l;
final int height = b - t;
- mContent.layout(0, 0, width-mWidthOffset, height);
+ mContent.layout(0, 0, width - mWidthOffset, height - mHeightOffset);
if (mSecondaryContent != null)
- mSecondaryContent.layout(0, 0, width-mWidthOffset, height);
+ mSecondaryContent.layout(0, 0, width - mWidthOffset, height - mHeightOffset);
}
@Override
@@ -138,8 +149,16 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int width = getDefaultSize(0, widthMeasureSpec);
int height = getDefaultSize(0, heightMeasureSpec);
setMeasuredDimension(width, height);
- final int contentWidth = getChildMeasureSpec(widthMeasureSpec, 0, width-mWidthOffset);
- final int contentHeight = getChildMeasureSpec(heightMeasureSpec, 0, height);
+
+ if (getMode() == SlidingMenu.TOP) {
+ mContent.measure(widthMeasureSpec, heightMeasureSpec);
+
+ int mh = mContent.getMeasuredHeight();
+ mHeightOffset = height - mh;
+ }
+
+ final int contentWidth = getChildMeasureSpec(widthMeasureSpec, 0, width - mWidthOffset);
+ final int contentHeight = getChildMeasureSpec(heightMeasureSpec, 0, height - mHeightOffset);
mContent.measure(contentWidth, contentHeight);
if (mSecondaryContent != null)
mSecondaryContent.measure(contentWidth, contentHeight);
@@ -231,6 +250,9 @@ public void scrollBehindTo(View content, int x, int y) {
scrollTo((int)(getBehindWidth() - getWidth() +
(x-getBehindWidth())*mScrollScale), y);
}
+ } else if (mMode == SlidingMenu.TOP) {
+ if (y >= content.getTop()) vis = View.INVISIBLE;
+ scrollTo(x, (int)((y + getBehindHeight())*mScrollScale));
}
if (vis == View.INVISIBLE)
Log.v(TAG, "behind INVISIBLE");
@@ -259,15 +281,26 @@ public int getMenuLeft(View content, int page) {
case 2:
return content.getLeft() + getBehindWidth();
}
- }
+ } else if (mMode == SlidingMenu.TOP) {
+ return content.getLeft();
+ }
return content.getLeft();
}
+ public int getMenuTop(View content, int page) {
+ if (mMode == SlidingMenu.TOP) {
+ return content.getTop() - getBehindHeight();
+ }
+ return content.getTop();
+ }
+
public int getAbsLeftBound(View content) {
if (mMode == SlidingMenu.LEFT || mMode == SlidingMenu.LEFT_RIGHT) {
return content.getLeft() - getBehindWidth();
} else if (mMode == SlidingMenu.RIGHT) {
return content.getLeft();
+ }else if (mMode == SlidingMenu.TOP) {
+ return content.getLeft();
}
return 0;
}
@@ -277,10 +310,26 @@ public int getAbsRightBound(View content) {
return content.getLeft();
} else if (mMode == SlidingMenu.RIGHT || mMode == SlidingMenu.LEFT_RIGHT) {
return content.getLeft() + getBehindWidth();
+ }else if (mMode == SlidingMenu.TOP) {
+ return content.getRight();
}
return 0;
}
+ public int getAbsTopBound(View content) {
+ if (mMode == SlidingMenu.TOP) {
+ return content.getTop() - getBehindHeight();
+ }
+ return 0;
+ }
+
+ public int getAbsBottomBound(View content) {
+ if (mMode == SlidingMenu.TOP) {
+ return content.getBottom();
+ }
+ return 0;
+ }
+
public boolean marginTouchAllowed(View content, int x) {
int left = content.getLeft();
int right = content.getRight();
@@ -299,7 +348,7 @@ public void setTouchMode(int i) {
mTouchMode = i;
}
- public boolean menuOpenTouchAllowed(View content, int currPage, float x) {
+ public boolean menuOpenTouchAllowed(View content, int currPage, float x, float y) {
switch (mTouchMode) {
case SlidingMenu.TOUCHMODE_FULLSCREEN:
return true;
@@ -325,7 +374,9 @@ public boolean menuClosedSlideAllowed(float dx) {
return dx < 0;
} else if (mMode == SlidingMenu.LEFT_RIGHT) {
return true;
- }
+ } else if (mMode == SlidingMenu.TOP) {
+ return dx > 0;
+ }
return false;
}
@@ -336,17 +387,22 @@ public boolean menuOpenSlideAllowed(float dx) {
return dx > 0;
} else if (mMode == SlidingMenu.LEFT_RIGHT) {
return true;
- }
+ } else if (mMode == SlidingMenu.TOP) {
+ return dx < 0;
+ }
return false;
}
public void drawShadow(View content, Canvas canvas) {
if (mShadowDrawable == null || mShadowWidth <= 0) return;
int left = 0;
+ int top = 0;
if (mMode == SlidingMenu.LEFT) {
left = content.getLeft() - mShadowWidth;
+ mShadowDrawable.setBounds(left, top, left + mShadowWidth, getHeight());
} else if (mMode == SlidingMenu.RIGHT) {
left = content.getRight();
+ mShadowDrawable.setBounds(left, top, left + mShadowWidth, getHeight());
} else if (mMode == SlidingMenu.LEFT_RIGHT) {
if (mSecondaryShadowDrawable != null) {
left = content.getRight();
@@ -354,8 +410,12 @@ public void drawShadow(View content, Canvas canvas) {
mSecondaryShadowDrawable.draw(canvas);
}
left = content.getLeft() - mShadowWidth;
+ mShadowDrawable.setBounds(left, top, left + mShadowWidth, getHeight());
+ }else if (mMode == SlidingMenu.TOP) {
+ left = 0;
+ top = content.getTop() - mShadowWidth;
+ mShadowDrawable.setBounds(left, top, content.getRight(), top);
}
- mShadowDrawable.setBounds(left, 0, left + mShadowWidth, getHeight());
mShadowDrawable.draw(canvas);
}
@@ -365,6 +425,8 @@ public void drawFade(View content, Canvas canvas, float openPercent) {
mFadePaint.setColor(Color.argb(alpha, 0, 0, 0));
int left = 0;
int right = 0;
+ int top = 0;
+ int bottom = getHeight();
if (mMode == SlidingMenu.LEFT) {
left = content.getLeft() - getBehindWidth();
right = content.getLeft();
@@ -377,8 +439,11 @@ public void drawFade(View content, Canvas canvas, float openPercent) {
canvas.drawRect(left, 0, right, getHeight(), mFadePaint);
left = content.getRight();
right = content.getRight() + getBehindWidth();
- }
- canvas.drawRect(left, 0, right, getHeight(), mFadePaint);
+ } else if (mMode == SlidingMenu.TOP) {
+ top = content.getTop() - getBehindHeight();
+ bottom = content.getTop();
+ }
+ canvas.drawRect(left, top, right, bottom, mFadePaint);
}
private boolean mSelectorEnabled = true;
@@ -403,6 +468,16 @@ public void drawSelector(View content, Canvas canvas, float openPercent) {
right = left + offset;
canvas.clipRect(left, 0, right, getHeight());
canvas.drawBitmap(mSelectorDrawable, right - mSelectorDrawable.getWidth(), getSelectorTop(), null);
+ }else if (mMode == SlidingMenu.TOP) {
+ int bottom;
+ int top;
+ left = 0;
+ right = content.getRight();
+
+ bottom = content.getTop();
+ top = bottom - offset;
+ canvas.clipRect(left, top, right, bottom);
+ canvas.drawBitmap(mSelectorDrawable, left, top, null);
}
canvas.restore();
}
diff --git a/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java b/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java
index b4483635f..f4c561c58 100644
--- a/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java
+++ b/library/src/com/jeremyfeinstein/slidingmenu/lib/SlidingMenu.java
@@ -64,6 +64,8 @@ public class SlidingMenu extends RelativeLayout {
*/
public static final int LEFT_RIGHT = 2;
+ public static final int TOP = 3;
+
private CustomViewAbove mViewAbove;
private CustomViewBehind mViewBehind;
@@ -73,6 +75,8 @@ public class SlidingMenu extends RelativeLayout {
private OnOpenListener mSecondaryOpenListner;
private OnCloseListener mCloseListener;
+
+ private View bg;
/**
* The listener interface for receiving onOpen events.
@@ -201,13 +205,17 @@ public SlidingMenu(Context context, AttributeSet attrs) {
*/
public SlidingMenu(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- LayoutParams behindParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+
+ // bg
+ bg = new View(context);
+ bg.setBackgroundColor(0xff000000);
+ addView(bg, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
+
mViewBehind = new CustomViewBehind(context);
- addView(mViewBehind, behindParams);
- LayoutParams aboveParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT);
+ addView(mViewBehind);
mViewAbove = new CustomViewAbove(context);
- addView(mViewAbove, aboveParams);
+ addView(mViewAbove);
+
// register the CustomViewBehind with the CustomViewAbove
mViewAbove.setCustomViewBehind(mViewBehind);
mViewBehind.setCustomViewAbove(mViewAbove);
@@ -257,11 +265,11 @@ public void onPageSelected(int position) {
if (offsetBehind != -1 && widthBehind != -1)
throw new IllegalStateException("Cannot set both behindOffset and behindWidth for a SlidingMenu");
else if (offsetBehind != -1)
- setBehindOffset(offsetBehind);
+ setBehindOffsetX(offsetBehind);
else if (widthBehind != -1)
setBehindWidth(widthBehind);
else
- setBehindOffset(0);
+ setBehindOffsetX(0);
float scrollOffsetBehind = ta.getFloat(R.styleable.SlidingMenu_behindScrollScale, 0.33f);
setBehindScrollScale(scrollOffsetBehind);
int shadowRes = ta.getResourceId(R.styleable.SlidingMenu_shadowDrawable, -1);
@@ -444,8 +452,8 @@ public boolean isSlidingEnabled() {
* @param mode must be either SlidingMenu.LEFT or SlidingMenu.RIGHT
*/
public void setMode(int mode) {
- if (mode != LEFT && mode != RIGHT && mode != LEFT_RIGHT) {
- throw new IllegalStateException("SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT");
+ if (mode != LEFT && mode != RIGHT && mode != LEFT_RIGHT && mode != TOP) {
+ throw new IllegalStateException("SlidingMenu mode must be LEFT, RIGHT, or LEFT_RIGHT or TOP");
}
mViewBehind.setMode(mode);
}
@@ -579,7 +587,7 @@ public int getBehindOffset() {
*
* @param i The margin, in pixels, on the right of the screen that the behind view scrolls to.
*/
- public void setBehindOffset(int i) {
+ public void setBehindOffsetX(int i) {
// RelativeLayout.LayoutParams params = ((RelativeLayout.LayoutParams)mViewBehind.getLayoutParams());
// int bottom = params.bottomMargin;
// int top = params.topMargin;
@@ -588,6 +596,15 @@ public void setBehindOffset(int i) {
mViewBehind.setWidthOffset(i);
}
+ public void setBehindOffsetY(int i) {
+ // RelativeLayout.LayoutParams params = ((RelativeLayout.LayoutParams)mViewBehind.getLayoutParams());
+ // int bottom = params.bottomMargin;
+ // int top = params.topMargin;
+ // int left = params.leftMargin;
+ // params.setMargins(left, top, i, bottom);
+ mViewBehind.setHeightOffset(i);
+ }
+
/**
* Sets the behind offset.
*
@@ -596,7 +613,7 @@ public void setBehindOffset(int i) {
*/
public void setBehindOffsetRes(int resID) {
int i = (int) getContext().getResources().getDimension(resID);
- setBehindOffset(i);
+ setBehindOffsetX(i);
}
/**
@@ -638,7 +655,7 @@ public void setBehindWidth(int i) {
} catch (Exception e) {
width = display.getWidth();
}
- setBehindOffset(width-i);
+ setBehindOffsetX(width-i);
}
/**
@@ -651,7 +668,7 @@ public void setBehindWidthRes(int res) {
int i = (int) getContext().getResources().getDimension(res);
setBehindWidth(i);
}
-
+
/**
* Gets the behind scroll scale.
*
@@ -1021,4 +1038,7 @@ public void run() {
}
}
+ public void setBackgroundViewColor(int i) {
+ bg.setBackgroundColor(i);
+ }
}
diff --git a/pom.xml b/pom.xml
index 8b0df6036..0090cc1f7 100644
--- a/pom.xml
+++ b/pom.xml
@@ -66,7 +66,7 @@
com.google.android.maps
maps
- 17_r1
+ 17_r3
com.google.android