Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
classpath 'com.android.tools.build:gradle:1.0.0'
}
}

ext.groupId = 'net.simonvt.menudrawer'
ext.compileSdkVersion = 19
ext.buildToolsVersion = "19.0.3"
ext.buildToolsVersion = "20.0.0"
ext.minSdkVersion = 7;
ext.targetSdkVersion = 19;

Expand All @@ -19,7 +19,7 @@ allprojects {
mavenCentral()
}

tasks.withType(Compile) {
tasks.withType(com.sun.org.apache.xalan.internal.xsltc.cmdline.Compile) {
options.encoding = "UTF-8"
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.11-all.zip
distributionUrl=http\://services.gradle.org/distributions/gradle-2.2.1-all.zip
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
package net.simonvt.menudrawer.samples;

import net.simonvt.menudrawer.MenuDrawer;
import net.simonvt.menudrawer.Position;

import android.app.Activity;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -14,6 +11,9 @@
import android.view.View.OnClickListener;
import android.widget.TextView;

import net.simonvt.menudrawer.MenuDrawer;
import net.simonvt.menudrawer.Position;

/**
* Sample class illustrating how to add a menu drawer above the content area.
*/
Expand All @@ -32,6 +32,8 @@ protected void onCreate(Bundle inState) {
mMenuDrawer.setTouchMode(MenuDrawer.TOUCH_MODE_FULLSCREEN);
mMenuDrawer.setContentView(R.layout.activity_topmenu);
mMenuDrawer.setMenuView(R.layout.menu_top);
mMenuDrawer.setOffsetMenuRadio(1.0f);
mMenuDrawer.setClickToClose(false);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
getActionBar().setDisplayHomeAsUpEnabled(true);
Expand Down
144 changes: 72 additions & 72 deletions menudrawer/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -30,80 +30,80 @@ signing {
}

task androidJavadocs(type: Javadoc) {
source = android.sourceSets.main.allJava
// source = android.sourceSets.main.allJava
}

task androidJavadocsJar(type: Jar) {
classifier = 'javadoc'
basename = project.artifactId
from androidJavadocs.destinationDir
}

task androidSourcesJar(type: Jar) {
classifier = 'sources'
basename = project.artifactId
from android.sourceSets.main.allSource
}

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
}

uploadArchives {
configuration = configurations.archives

repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }

repository(url: sonatypeRepo) {
authentication(userName: sonatypeUsername, password: sonatypePassword)
}
pom.groupId = parent.ext.groupId
pom.artifactId = project.ext.artifactId
pom.version = parent.version

pom.project {
name 'MenuDrawer'
packaging 'aar'
description 'A menu drawer implementation which allows dragging of both the content, and the entire window.'
url 'https://github.com/SimonVT/android-menudrawer'

scm {
url 'http://github.com/SimonVT/android-menudrawer/'
connection 'scm:git:git://github.com/SimonVT/android-menudrawer.git'
developerConnection 'scm:git:[email protected]:SimonVT/android-menudrawer.git'
}

licenses {
license {
name 'Apache License Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
distribution 'repo'
}
}

issueManagement {
system 'GitHub Issues'
url 'https://github.com/SimonVT/android-menudrawer/issues'
}

developers {
developer {
id 'simonvt'
name 'Simon Vig Therkildsen'
email '[email protected]'
url 'http://simonvt.net'
timezone '1'
roles {
role 'developer'
}
}
}
}
}
}
//task androidJavadocsJar(type: Jar) {
// classifier = 'javadoc'
// basename = project.artifactId
// from androidJavadocs.destinationDir
//}

//task androidSourcesJar(type: Jar) {
// classifier = 'sources'
// basename = project.artifactId
//// from android.sourceSets.main.allSource
//}

//artifacts {
// archives androidSourcesJar
// archives androidJavadocsJar
//}

//uploadArchives {
// configuration = configurations.archives
//
// repositories.mavenDeployer {
//// beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
//
// repository(url: sonatypeRepo) {
// authentication(userName: sonatypeUsername, password: sonatypePassword)
// }
//
// pom.groupId = parent.ext.groupId
// pom.artifactId = project.ext.artifactId
// pom.version = parent.version
//
// pom.project {
// name 'MenuDrawer'
// packaging 'aar'
// description 'A menu drawer implementation which allows dragging of both the content, and the entire window.'
// url 'https://github.com/SimonVT/android-menudrawer'
//
// scm {
// url 'http://github.com/SimonVT/android-menudrawer/'
// connection 'scm:git:git://github.com/SimonVT/android-menudrawer.git'
// developerConnection 'scm:git:[email protected]:SimonVT/android-menudrawer.git'
// }
//
// licenses {
// license {
// name 'Apache License Version 2.0'
// url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
// distribution 'repo'
// }
// }
//
// issueManagement {
// system 'GitHub Issues'
// url 'https://github.com/SimonVT/android-menudrawer/issues'
// }
//
// developers {
// developer {
// id 'simonvt'
// name 'Simon Vig Therkildsen'
// email '[email protected]'
// url 'http://simonvt.net'
// timezone '1'
// roles {
// role 'developer'
// }
// }
// }
// }
// }
//}

checkstyle {
configFile project.file('../checkstyle.xml')
Expand Down
28 changes: 28 additions & 0 deletions menudrawer/src/net/simonvt/menudrawer/DraggableDrawer.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public void run() {
*/
protected boolean mOffsetMenu = true;

/**
* Offset value whether the menu should be offset when dragging the drawer.
*/
protected float mOffsetMenuRadio = 0.25f;

/**
* Distance in px from closed position from where the drawer is considered closed with regards to touch events.
*/
Expand All @@ -150,6 +155,11 @@ public void run() {
*/
private Scroller mScroller;

/**
* Indicates whether the menu should be close when content click.
*/
private boolean clickToClose = true;

/**
* Indicates whether the current layer type is {@link android.view.View#LAYER_TYPE_HARDWARE}.
*/
Expand Down Expand Up @@ -218,6 +228,14 @@ public boolean getOffsetMenuEnabled() {
return mOffsetMenu;
}

public void setOffsetMenuRadio(float value) {
this.mOffsetMenuRadio = value;
}

public float getOffsetMenuRadio() {
return mOffsetMenuRadio;
}

public void peekDrawer() {
peekDrawer(DEFAULT_PEEK_START_DELAY, DEFAULT_PEEK_DELAY);
}
Expand Down Expand Up @@ -621,4 +639,14 @@ public void restoreState(Parcelable in) {
}
mDrawerState = menuOpen ? STATE_OPEN : STATE_CLOSED;
}



public boolean isClickToClose() {
return clickToClose;
}

public void setClickToClose(boolean clickToClose) {
this.clickToClose = clickToClose;
}
}
48 changes: 42 additions & 6 deletions menudrawer/src/net/simonvt/menudrawer/MenuDrawer.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package net.simonvt.menudrawer;

import net.simonvt.menudrawer.compat.ActionBarHelper;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.TypedArray;
Expand Down Expand Up @@ -868,7 +868,8 @@ protected Position getPosition() {
return mPosition;
}

@Override
@SuppressLint("NewApi")
@Override
public void onRtlPropertiesChanged(int layoutDirection) {
super.onRtlPropertiesChanged(layoutDirection);

Expand Down Expand Up @@ -1088,7 +1089,15 @@ protected void updateTouchAreaSize() {
if (mTouchMode == TOUCH_MODE_BEZEL) {
mTouchSize = mTouchBezelSize;
} else if (mTouchMode == TOUCH_MODE_FULLSCREEN) {
mTouchSize = getMeasuredWidth();
switch (mPosition){
case TOP:
case BOTTOM:
mTouchSize = getMeasuredHeight();
break;
default:
mTouchSize = getMeasuredWidth();
break;
}
} else {
mTouchSize = 0;
}
Expand Down Expand Up @@ -1134,6 +1143,33 @@ private void completeAnimatingIndicator() {
*/
public abstract boolean getOffsetMenuEnabled();

/**
* Set the offset value when dragging the drawer.
*
* @param offset value in 0-1.0f. Default value is 0.25f.
*/
public abstract void setOffsetMenuRadio(float offsetMenuRadio);

/**
* Get the offset menu value
*
* @return The offset value. Default value is 0.25f.
*/
public abstract float getOffsetMenuRadio();


/**
* Indicates whether the menu should be closed when the content is closed.
* @return
*/
public abstract boolean isClickToClose();

/**
* Enables or disables close the menu when content is click.
* @param b
*/
public abstract void setClickToClose(boolean b);

/**
* Get the current state of the drawer.
*
Expand Down Expand Up @@ -1550,7 +1586,8 @@ protected void logDrawerState(int state) {
*/
public abstract int getTouchBezelSize();

@Override
@SuppressLint("NewApi")
@Override
public void postOnAnimation(Runnable action) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
super.postOnAnimation(action);
Expand All @@ -1564,8 +1601,7 @@ protected boolean fitSystemWindows(Rect insets) {
if (mDragMode == MENU_DRAG_WINDOW && mPosition != Position.BOTTOM) {
mMenuContainer.setPadding(0, insets.top, 0, 0);
}
return super.fitSystemWindows(insets);
}
return super.fitSystemWindows(insets); }

protected void dispatchOnDrawerSlide(float openRatio, int offsetPixels) {
if (mOnDrawerStateChangeListener != null) {
Expand Down
Loading