Skip to content

Commit 3dc0234

Browse files
author
jfeinstein10
committed
Added fullscreen touch mode. Now you can set if the entire screen is a valid touch to slide the menu open.
1 parent 0f00680 commit 3dc0234

3 files changed

Lines changed: 64 additions & 2 deletions

File tree

example/src/com/slidingmenu/example/ExampleActivity.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import com.actionbarsherlock.app.ActionBar.TabListener;
99
import com.actionbarsherlock.view.Menu;
1010
import com.actionbarsherlock.view.MenuItem;
11+
import com.slidingmenu.lib.SlidingMenu;
1112
import com.slidingmenu.lib.app.SlidingListActivity;
1213

1314
public class ExampleActivity extends SlidingListActivity implements TabListener {
@@ -18,6 +19,7 @@ public void onCreate(Bundle savedInstanceState) {
1819
setBehindContentView(R.layout.main2);
1920
getSlidingMenu().setBehindOffsetRes(R.dimen.actionbar_home_width);
2021
getSlidingMenu().setBehindScrollScale(0.5f);
22+
getSlidingMenu().setAboveTouchMode(SlidingMenu.TOUCHMODE_FULLSCREEN);
2123
ActionBar actionBar = getSupportActionBar();
2224
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
2325
actionBar.setDisplayHomeAsUpEnabled(true);

library/src/com/slidingmenu/lib/CustomViewAbove.java

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1182,11 +1182,44 @@ private void completeScroll() {
11821182
}
11831183
}
11841184

1185+
private int mAboveTouchMode = SlidingMenu.TOUCHMODE_MARGIN;
1186+
private int mBehindTouchMode = SlidingMenu.TOUCHMODE_MARGIN;
1187+
1188+
public void setAboveTouchMode(int i) {
1189+
mAboveTouchMode = i;
1190+
}
1191+
1192+
public int getAboveTouchMode() {
1193+
return mAboveTouchMode;
1194+
}
1195+
1196+
public void setBehindTouchMode(int i) {
1197+
mBehindTouchMode = i;
1198+
}
1199+
1200+
public int getBehindTouchMode() {
1201+
return mBehindTouchMode;
1202+
}
1203+
11851204
private boolean thisTouchAllowed(float x) {
11861205
if (isMenuOpen()) {
1187-
return x >= getBehindWidth() && x <= getWidth();
1206+
switch (mBehindTouchMode) {
1207+
case SlidingMenu.TOUCHMODE_FULLSCREEN:
1208+
return true;
1209+
case SlidingMenu.TOUCHMODE_MARGIN:
1210+
return x >= getBehindWidth() && x <= getWidth();
1211+
default:
1212+
return false;
1213+
}
11881214
} else {
1189-
return x >= 0 && x <= mSlidingMenuThreshold;
1215+
switch (mAboveTouchMode) {
1216+
case SlidingMenu.TOUCHMODE_FULLSCREEN:
1217+
return true;
1218+
case SlidingMenu.TOUCHMODE_MARGIN:
1219+
return x >= 0 && x <= mSlidingMenuThreshold;
1220+
default:
1221+
return false;
1222+
}
11901223
}
11911224
}
11921225

library/src/com/slidingmenu/lib/SlidingMenu.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@
99
import android.widget.RelativeLayout;
1010

1111
public class SlidingMenu extends RelativeLayout {
12+
13+
public static final int TOUCHMODE_FULLSCREEN = 0;
14+
public static final int TOUCHMODE_MARGIN = 1;
1215

1316
private CustomViewAbove mViewAbove;
1417
private CustomViewBehind mViewBehind;
@@ -156,4 +159,28 @@ public void setBehindScrollScale(float f) {
156159
mViewAbove.setScrollScale(f);
157160
}
158161

162+
public int getAboveTouchMode() {
163+
return mViewAbove.getAboveTouchMode();
164+
}
165+
166+
public void setAboveTouchMode(int i) {
167+
if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN) {
168+
throw new IllegalStateException("TouchMode must be set to either" +
169+
"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN.");
170+
}
171+
mViewAbove.setAboveTouchMode(i);
172+
}
173+
174+
public int getBehindTouchMode() {
175+
return mViewAbove.getBehindTouchMode();
176+
}
177+
178+
public void setBehindTouchMode(int i) {
179+
if (i != TOUCHMODE_FULLSCREEN && i != TOUCHMODE_MARGIN) {
180+
throw new IllegalStateException("TouchMode must be set to either" +
181+
"TOUCHMODE_FULLSCREEN or TOUCHMODE_MARGIN.");
182+
}
183+
mViewAbove.setBehindTouchMode(i);
184+
}
185+
159186
}

0 commit comments

Comments
 (0)