Skip to content

Commit

Permalink
Merge pull request #8 from saurabharora90/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
saurabharora90 committed Jan 20, 2016
2 parents bf97820 + 09d79c1 commit 86aaa26
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 17 deletions.
11 changes: 6 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ An android custom view which allows you to have a arc style-menu on your pages a

It inserts a FAB menu on the bottom left or bottom right of the screen and allows you to control the menu options.

It also implements the CoordinatorLayout Behaviour to work with Snackbar
It also implements the CoordinatorLayout Behaviour to work with Snackbar.

Change-logs
-------
Check out the [Release Notes](https://github.com/saurabharora90/MaterialArcMenu/releases "Releases") for the change-logs in each release.
Demo
-------
![Arc Menu](https://raw.githubusercontent.com/saurabharora90/MaterialArcMenu/develop/assets/show_menu.gif)
Expand All @@ -20,18 +23,17 @@ Usage
Add a dependency to your `build.gradle`:

dependencies {
compile 'com.sa90.materialarcmenu:library:1.2'
compile 'com.sa90.materialarcmenu:library:1.3'
}

and include the `com.sa90.materialarcmenu.ArcMenu` as a viewgroup (with the sub-menu's as child) in your layout.
and include the `com.sa90.materialarcmenu.ArcMenu` as a viewgroup (with the sub-menu's as child) in your layout. The menu (floating action button) has a margin of 16dp added to it by default to follow the material design guidelines.
Example:

<com.sa90.materialarcmenu.ArcMenu
android:id="@+id/arcMenu"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="16dp"
app:menu_scr="@drawable/ic_dialog_dialer"
app:menu_open="arc_left">

Expand Down Expand Up @@ -65,7 +67,6 @@ The sub-menu's (child) can be anything. Here is an ImageButton example:
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="@dimen/fab_margin"
app:menu_color="@color/colorPrimaryDark"
app:menu_radius="200dp"
app:menu_ripple_color="@color/darker_gray"
Expand Down
4 changes: 2 additions & 2 deletions library/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ android {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.2"
versionName "1.3"
}
buildTypes {
release {
Expand All @@ -32,7 +32,7 @@ ext {
artifact = 'library'

libraryDescription = 'An android custom view which allows you to have a arc style-menu on your pages'
libraryVersion = '1.2'
libraryVersion = '1.3'

developerId = 'saurabharora90'
developerName = 'Saurabh Arora'
Expand Down
19 changes: 12 additions & 7 deletions library/src/main/java/com/sa90/materialarcmenu/ArcMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.AccelerateInterpolator;
import android.widget.FrameLayout;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -26,7 +26,7 @@
* Created by Saurabh on 14/12/15.
*/
@CoordinatorLayout.DefaultBehavior(MoveUpwardBehaviour.class)
public class ArcMenu extends ViewGroup {
public class ArcMenu extends FrameLayout {

private static final double POSITIVE_QUADRANT = 90;
private static final double NEGATIVE_QUADRANT = -90;
Expand All @@ -38,7 +38,8 @@ public class ArcMenu extends ViewGroup {
ColorStateList mColorStateList;
int mRippleColor;
long mAnimationTime;
float mCurrentRadius, mFinalRadius, mElevation, mMargin;
float mCurrentRadius, mFinalRadius, mElevation;
int menuMargin;
boolean mIsOpened = false;
double mQuadrantAngle;
MenuSideEnum mMenuSideEnum;
Expand Down Expand Up @@ -84,6 +85,8 @@ private void init(TypedArray attr) {
mQuadrantAngle = POSITIVE_QUADRANT;
else
mQuadrantAngle = NEGATIVE_QUADRANT;

menuMargin = resources.getDimensionPixelSize(R.dimen.fab_margin);
}

/**
Expand Down Expand Up @@ -158,13 +161,13 @@ private void layoutChildrenArc() {
//TODO: work on fixing this
private void layoutMenu() {
if(mMenuSideEnum == MenuSideEnum.ARC_RIGHT) {
cx = 0;
cy = getMeasuredHeight() - fabMenu.getMeasuredHeight();
cx = 0 + menuMargin;
cy = getMeasuredHeight() - fabMenu.getMeasuredHeight() - menuMargin;
}

else {
cx = getMeasuredWidth() - fabMenu.getMeasuredWidth();
cy = getMeasuredHeight() - fabMenu.getMeasuredHeight();
cx = getMeasuredWidth() - fabMenu.getMeasuredWidth() - menuMargin;
cy = getMeasuredHeight() - fabMenu.getMeasuredHeight() - menuMargin;
}

fabMenu.layout(cx, cy, cx + fabMenu.getMeasuredWidth(), cy + fabMenu.getMeasuredHeight());
Expand Down Expand Up @@ -206,6 +209,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
height+=(radius + maxHeight);
}

width+= menuMargin;
height+= menuMargin;
setMeasuredDimension(width, height);
}

Expand Down
1 change: 1 addition & 0 deletions library/src/main/res/values/dimens.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<resources>
<dimen name="default_radius">150dp</dimen>
<dimen name="default_elevation">6dp</dimen>
<dimen name="fab_margin">16dp</dimen> <!-- In accordance with the material design guidelines -->
</resources>
1 change: 0 additions & 1 deletion samples/src/main/res/layout/activity_animation_time.xml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:menu_scr="@android:drawable/ic_dialog_dialer"
app:menu_open="arc_left">

Expand Down
1 change: 0 additions & 1 deletion samples/src/main/res/layout/activity_image_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|start"
android:layout_margin="@dimen/fab_margin"
app:menu_color="@color/colorPrimaryDark"
app:menu_radius="200dp"
app:menu_ripple_color="@android:color/darker_gray"
Expand Down
1 change: 0 additions & 1 deletion samples/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom|end"
android:layout_margin="@dimen/fab_margin"
app:menu_open="arc_left"
app:menu_scr="@android:drawable/ic_dialog_dialer">

Expand Down

0 comments on commit 86aaa26

Please sign in to comment.