├── .gitignore
├── .idea
├── compiler.xml
├── copyright
│ └── profiles_settings.xml
├── gradle.xml
├── misc.xml
├── modules.xml
└── runConfigurations.xml
├── LICENSE.txt
├── README.md
├── app
├── .gitignore
├── build.gradle
├── proguard-rules.pro
└── src
│ ├── androidTest
│ └── java
│ │ └── com
│ │ └── emredavarci
│ │ └── floatingactionmenu
│ │ └── ExampleInstrumentedTest.java
│ ├── main
│ ├── AndroidManifest.xml
│ ├── java
│ │ └── com
│ │ │ └── emredavarci
│ │ │ └── floatingactionmenu
│ │ │ ├── ActionCircle.java
│ │ │ ├── FloatingActionMenu.java
│ │ │ └── MainActivity.java
│ └── res
│ │ ├── drawable
│ │ ├── default_menu_icon.png
│ │ ├── fav_icon.png
│ │ ├── search_icon.png
│ │ ├── settings_icon.png
│ │ └── share_icon.png
│ │ ├── layout
│ │ └── activity_main.xml
│ │ ├── mipmap-hdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-mdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ ├── mipmap-xxxhdpi
│ │ ├── ic_launcher.png
│ │ └── ic_launcher_round.png
│ │ └── values
│ │ ├── attrs.xml
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ └── test
│ └── java
│ └── com
│ └── emredavarci
│ └── floatingactionmenu
│ └── ExampleUnitTest.java
├── build.gradle
├── gradle.properties
├── gradle
└── wrapper
│ ├── gradle-wrapper.jar
│ └── gradle-wrapper.properties
├── gradlew
├── gradlew.bat
└── settings.gradle
/.gitignore:
--------------------------------------------------------------------------------
1 | *.iml
2 | .gradle
3 | /local.properties
4 | /.idea/workspace.xml
5 | /.idea/libraries
6 | .DS_Store
7 | /build
8 | /captures
9 | .externalNativeBuild
10 |
--------------------------------------------------------------------------------
/.idea/compiler.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
--------------------------------------------------------------------------------
/.idea/copyright/profiles_settings.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
--------------------------------------------------------------------------------
/.idea/gradle.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/.idea/runConfigurations.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE.txt:
--------------------------------------------------------------------------------
1 | Copyright 2017 M. Emre Davarci
2 |
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 |
7 | http://www.apache.org/licenses/LICENSE-2.0
8 |
9 | Unless required by applicable law or agreed to in writing, software
10 | distributed under the License is distributed on an "AS IS" BASIS,
11 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 | See the License for the specific language governing permissions and
13 | limitations under the License.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # CircleProgressBar
2 |
3 | 
4 | 
5 | 
6 | 
7 |
8 | A simple library for creating circular progressbars for Android.
9 |
10 | ## Examples
11 |
12 | 
13 |
14 | ## Installation
15 |
16 | - Get it via gradle: ``` compile 'com.emredavarci:floatingactionmenu:1.0.0' ```
17 | ## Usage
18 |
19 | 1) Add CircleProgressBar to your layout
20 |
21 | Warning: This library allows only 4 menu actions. Not 3, not 5.
22 |
23 | ```xml
24 |
44 |
45 | ```
46 |
47 | 2) Reach it from your activity/fragment etc.
48 |
49 | ```java
50 | FloatingActionMenu menu = (FloatingActionMenu) findViewById(R.id.actionmenu);
51 | menu.setClickEvent(new FloatingActionMenu.ClickEvent() {
52 | @Override
53 | public void onClick(int index) {
54 | Log.d("TAG", String.valueOf(index)); // index of clicked menu item
55 | }
56 | });
57 | ```
58 |
59 | You can modify it programmatically if you want
60 |
61 | Setters
62 |
63 | ```java
64 | menu.setRadius(radius); // set radius of button
65 | menu.setShadowWitdth(2); // set shadow width
66 | menu.setScaleRatio(3); // set scale ratio of button
67 | menu.setDuration(300); // set duration of opening animation
68 | menu.setBgColor("#FF6FD99D"); // set background color of button
69 | menu.setMenuIconRotateAngle(225); // set menu icon rotate angle
70 | menu.setMenuIconWidth(30); // set menu icon width
71 | menu.setMenuIconHeight(30); // set menu icon height
72 | enu.setMenuIcon(R.drawable.menu_icon); // set menu icon
73 | menu.setFirstActionIcon(R.drawable.first_icon); // set first action icon
74 | menu.setSecondActionIcon(R.drawable.second_icon); // set second action icon
75 | menu.setThirdActionIcon(R.drawable.third_icon); // set third action icon
76 | menu.setFourthActionIcon(R.drawable.fourth_icon); // set fourth action icon
77 | ```
78 |
79 | Getters
80 |
81 | ```java
82 | menu.getRadius(); // get radius of button
83 | menu.getShadowWitdth(); // get shadow width
84 | menu.getScaleRatio(); // get scale ratio of button
85 | menu.getDuration(); // get duration of opening animation
86 | menu.getBgColor(); // get background color of button
87 | menu.getMenuIconRotateAngle(); // get menu icon rotate angle
88 | menu.getMenuIconWidth(); // get menu icon width
89 | menu.getMenuIconHeight(); // get menu icon height
90 | menu.getMenuIcon(); // get menu icon
91 | menu.getFirstActionIcon(); // get first action icon
92 | menu.getSecondActionIcon(); // get second action icon
93 | menu.getThirdActionIcon(); // get third action icon
94 | menu.getFourthActionIcon(); // get fourth action icon
95 | ```
96 |
97 | ## LICENSE
98 |
99 | Copyright 2017 M. Emre Davarci
100 |
101 | Licensed under the Apache License, Version 2.0 (the "License");
102 | you may not use this file except in compliance with the License.
103 | You may obtain a copy of the License at
104 |
105 | http://www.apache.org/licenses/LICENSE-2.0
106 |
107 | Unless required by applicable law or agreed to in writing, software
108 | distributed under the License is distributed on an "AS IS" BASIS,
109 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
110 | See the License for the specific language governing permissions and
111 | limitations under the License.
112 |
113 |
114 |
115 |
116 |
117 |
118 |
--------------------------------------------------------------------------------
/app/.gitignore:
--------------------------------------------------------------------------------
1 | /build
2 |
--------------------------------------------------------------------------------
/app/build.gradle:
--------------------------------------------------------------------------------
1 | apply plugin: 'com.android.library'
2 | apply plugin: 'com.github.dcendents.android-maven'
3 | apply plugin: "com.jfrog.bintray"
4 |
5 | ext {
6 | PUBLISH_GROUP_ID = 'com.emredavarci'
7 | PUBLISH_ARTIFACT_ID = 'floatingactionmenu'
8 | PUBLISH_VERSION = '1.0.0'
9 | }
10 |
11 | android {
12 | compileSdkVersion 26
13 | buildToolsVersion "26.0.0"
14 | defaultConfig {
15 | minSdkVersion 16
16 | targetSdkVersion 26
17 | versionCode 1
18 | versionName "1.0"
19 | testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
20 | }
21 | buildTypes {
22 | release {
23 | minifyEnabled false
24 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
25 | }
26 | }
27 | }
28 |
29 | dependencies {
30 | compile fileTree(dir: 'libs', include: ['*.jar'])
31 | androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
32 | exclude group: 'com.android.support', module: 'support-annotations'
33 | })
34 | compile 'com.android.support:appcompat-v7:26.+'
35 | compile 'com.android.support.constraint:constraint-layout:1.0.2'
36 | testCompile 'junit:junit:4.12'
37 | }
38 |
39 |
40 | apply from: 'https://raw.githubusercontent.com/blundell/release-android-library/master/android-release-aar.gradle'
41 |
42 | def siteUrl = 'https://github.com/emre1512/FloatingActionMenu' // Homepage URL of the library
43 | def gitUrl = 'https://github.com/emre1512/FloatingActionMenu.git' // Git repository URL
44 | group = "com.emredavarci"
45 |
46 | install {
47 | repositories.mavenInstaller {
48 | pom {
49 | project {
50 | packaging 'aar'
51 |
52 | name 'com.emredavarci:floatingactionmenu' // TODO
53 | description = 'Floating Action Menu' // TODO
54 | url siteUrl
55 |
56 | // Set your license
57 | licenses {
58 | license {
59 | name 'The Apache Software License, Version 2.0'
60 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
61 | }
62 | }
63 | developers {
64 | developer {
65 | id 'emre1512' // TODO
66 | name 'M. Emre Davarci' // TODO
67 | email 'emre151291@gmail.com' // TODO
68 | }
69 | }
70 | scm {
71 | connection gitUrl
72 | developerConnection gitUrl
73 | url siteUrl
74 | }
75 | }
76 | }
77 | }
78 | }
--------------------------------------------------------------------------------
/app/proguard-rules.pro:
--------------------------------------------------------------------------------
1 | # Add project specific ProGuard rules here.
2 | # By default, the flags in this file are appended to flags specified
3 | # in C:\Users\user\android-sdks/tools/proguard/proguard-android.txt
4 | # You can edit the include path and order by changing the proguardFiles
5 | # directive in build.gradle.
6 | #
7 | # For more details, see
8 | # http://developer.android.com/guide/developing/tools/proguard.html
9 |
10 | # Add any project specific keep options here:
11 |
12 | # If your project uses WebView with JS, uncomment the following
13 | # and specify the fully qualified class name to the JavaScript interface
14 | # class:
15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview {
16 | # public *;
17 | #}
18 |
19 | # Uncomment this to preserve the line number information for
20 | # debugging stack traces.
21 | #-keepattributes SourceFile,LineNumberTable
22 |
23 | # If you keep the line number information, uncomment this to
24 | # hide the original source file name.
25 | #-renamesourcefileattribute SourceFile
26 |
--------------------------------------------------------------------------------
/app/src/androidTest/java/com/emredavarci/floatingactionmenu/ExampleInstrumentedTest.java:
--------------------------------------------------------------------------------
1 | package com.emredavarci.floatingactionmenu;
2 |
3 | import android.content.Context;
4 | import android.support.test.InstrumentationRegistry;
5 | import android.support.test.runner.AndroidJUnit4;
6 |
7 | import org.junit.Test;
8 | import org.junit.runner.RunWith;
9 |
10 | import static org.junit.Assert.*;
11 |
12 | /**
13 | * Instrumentation test, which will execute on an Android device.
14 | *
15 | * @see Testing documentation
16 | */
17 | @RunWith(AndroidJUnit4.class)
18 | public class ExampleInstrumentedTest {
19 | @Test
20 | public void useAppContext() throws Exception {
21 | // Context of the app under test.
22 | Context appContext = InstrumentationRegistry.getTargetContext();
23 |
24 | assertEquals("com.emredavarci.floatingactionmenu", appContext.getPackageName());
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/app/src/main/java/com/emredavarci/floatingactionmenu/ActionCircle.java:
--------------------------------------------------------------------------------
1 | package com.emredavarci.floatingactionmenu;
2 |
3 | import android.animation.ValueAnimator;
4 | import android.content.Context;
5 | import android.graphics.Canvas;
6 | import android.graphics.Color;
7 | import android.graphics.Paint;
8 | import android.graphics.drawable.GradientDrawable;
9 | import android.os.Build;
10 | import android.support.annotation.Nullable;
11 | import android.support.annotation.RequiresApi;
12 | import android.util.AttributeSet;
13 | import android.view.View;
14 | import android.view.ViewGroup;
15 | import android.widget.RelativeLayout;
16 |
17 | /**
18 | * Created by M. Emre Davarci on 14.08.2017.
19 | */
20 |
21 | public class ActionCircle extends View{
22 |
23 | private Paint paint;
24 |
25 | private int parentW,parentH;
26 | private float scaleR;
27 |
28 | private int defStyleAttr;
29 |
30 | GradientDrawable shape = new GradientDrawable();
31 |
32 | Context context;
33 | private float scaleRatio;
34 | private int duration;
35 | private int color;
36 | private float shadowWidth = 4;
37 |
38 | float radius;
39 |
40 | public ActionCircle(Context context) {
41 | super(context);
42 | this.context = context;
43 | }
44 |
45 | public ActionCircle(Context context, @Nullable AttributeSet attrs) {
46 | super(context, attrs);
47 | this.context = context;
48 |
49 | }
50 |
51 | public ActionCircle(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
52 | super(context, attrs, defStyleAttr);
53 | this.defStyleAttr = defStyleAttr;
54 | this.context = context;
55 |
56 | }
57 |
58 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
59 | public ActionCircle(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
60 | super(context, attrs, defStyleAttr, defStyleRes);
61 | this.defStyleAttr = defStyleAttr;
62 | this.context = context;
63 |
64 | }
65 |
66 | public void setScaleRatio(float scaleRatio) {
67 | this.scaleRatio = scaleRatio;
68 | }
69 |
70 | public void setDuration(int duration) {
71 | this.duration = duration;
72 | }
73 |
74 | public void setColor(int color) {
75 | this.color = color;
76 | }
77 |
78 | public void setRadius(float radius) {
79 | this.radius = radius;
80 | }
81 |
82 | public void setShadowWidth(float shadowWidth) {
83 | this.shadowWidth = shadowWidth;
84 | }
85 |
86 | public void init(){
87 |
88 | RelativeLayout.LayoutParams lp = new RelativeLayout.LayoutParams
89 | (ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
90 | setLayoutParams(lp);
91 |
92 | scaleR = 0;
93 | paint = new Paint(Paint.ANTI_ALIAS_FLAG);
94 | paint.setColor(color);
95 | paint.setStrokeWidth(radius-shadowWidth*2);
96 | paint.setShadowLayer(shadowWidth, 0, 0, Color.parseColor("#b5b5b5"));
97 | setLayerType(LAYER_TYPE_SOFTWARE, paint);
98 |
99 | setCustomAnimation();
100 |
101 | }
102 |
103 | @Override
104 | protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
105 | super.onMeasure(widthMeasureSpec, heightMeasureSpec);
106 |
107 | parentW = ((View) getParent()).getMeasuredWidth();
108 | parentH = ((View) getParent()).getMeasuredHeight();
109 | }
110 |
111 | private void setCustomShape(){
112 |
113 | float f= radius/2;
114 | shape.setCornerRadii(new float[]{f,f,f,f,f,f,f,f});
115 | shape.setColor(color);
116 | setBackground(shape);
117 | }
118 |
119 | ValueAnimator openAnim,closeAnim;
120 | private void setCustomAnimation(){
121 | openAnim = ValueAnimator.ofFloat(0f, scaleRatio);
122 | openAnim.setDuration(duration);
123 | openAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
124 | public void onAnimationUpdate(ValueAnimator animation) {
125 | float scale = (float)animation.getAnimatedValue();
126 | scaleR = scale*radius;
127 | invalidate();
128 | }
129 | });
130 |
131 | closeAnim = ValueAnimator.ofFloat(scaleRatio, 0f);
132 | closeAnim.setDuration(duration);
133 | closeAnim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
134 | public void onAnimationUpdate(ValueAnimator animation) {
135 | float scale = (float)animation.getAnimatedValue();
136 | scaleR = scale*radius;
137 | invalidate();
138 | }
139 | });
140 |
141 | }
142 |
143 | public void openMenu(){
144 | openAnim.start();
145 | }
146 |
147 | public void closeMenu(){
148 | closeAnim.start();
149 | }
150 |
151 | @Override
152 | protected void onSizeChanged(int w, int h, int oldw, int oldh) {
153 | super.onSizeChanged(w, h, oldw, oldh);
154 | }
155 |
156 | @Override
157 | protected void onDraw(Canvas canvas) {
158 | super.onDraw(canvas);
159 |
160 | paint.setStrokeCap(Paint.Cap.ROUND);
161 | canvas.drawLine((parentW-scaleR-shadowWidth)/2, (radius)/2,
162 | (parentW+scaleR+shadowWidth)/2+0.001f, (radius)/2,
163 | paint);
164 |
165 | }
166 |
167 | }
168 |
--------------------------------------------------------------------------------
/app/src/main/java/com/emredavarci/floatingactionmenu/FloatingActionMenu.java:
--------------------------------------------------------------------------------
1 | package com.emredavarci.floatingactionmenu;
2 |
3 | import android.content.Context;
4 | import android.content.res.TypedArray;
5 | import android.graphics.Color;
6 | import android.os.Build;
7 | import android.support.annotation.RequiresApi;
8 | import android.util.AttributeSet;
9 | import android.view.Gravity;
10 | import android.view.View;
11 | import android.view.animation.AlphaAnimation;
12 | import android.view.animation.Animation;
13 | import android.view.animation.RotateAnimation;
14 | import android.view.animation.ScaleAnimation;
15 | import android.widget.ImageView;
16 | import android.widget.LinearLayout;
17 | import android.widget.RelativeLayout;
18 |
19 | /**
20 | * Created by M. Emre Davarci on 15.08.2017.
21 | */
22 |
23 | public class FloatingActionMenu extends RelativeLayout {
24 |
25 | private int defStyleAttr;
26 |
27 | private float scaleRatio;
28 |
29 | private int duration;
30 | private int bgColor;
31 | private float radius;
32 | private int menuIconRotateAngle;
33 | private float menuIconWidth;
34 | private float menuIconHeight;
35 | private float shadowWidth;
36 | private int menuIconId;
37 | private int firstActionId;
38 | private int secondActionId;
39 | private int thirdActionId;
40 | private int fourthActionId;
41 |
42 | private int[] actions;
43 |
44 | private int fadeOutFadeInDuration = 100;
45 |
46 | private static float itemContainerScaleRatio = 1.25f;
47 |
48 | private ClickEvent clickEvent;
49 |
50 | RelativeLayout menuIconContainer;
51 | RelativeLayout menuItemsContainer;
52 |
53 | private ActionCircle fs;
54 | private Animation menuIconOpenAnim, menuIconCloseAnim, menuRevealAnim, menuFadeOutAnim,
55 | scaleDownAnim,scaleUpAnim;
56 |
57 | private boolean isOpen = false;
58 | private boolean isAnimating = false;
59 |
60 | public FloatingActionMenu(Context context) {
61 | super(context);
62 | }
63 |
64 | public FloatingActionMenu(Context context, AttributeSet attrs) {
65 | super(context, attrs);
66 | createMenu(context, attrs);
67 | }
68 |
69 | public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr) {
70 | super(context, attrs, defStyleAttr);
71 | this.defStyleAttr = defStyleAttr;
72 | createMenu(context, attrs);
73 | }
74 |
75 | @RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
76 | public FloatingActionMenu(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
77 | super(context, attrs, defStyleAttr, defStyleRes);
78 | this.defStyleAttr = defStyleAttr;
79 | createMenu(context, attrs);
80 | }
81 |
82 | private void createMenu(Context c, AttributeSet attrs){
83 |
84 | TypedArray ta = c.obtainStyledAttributes(attrs, R.styleable.ActionCircle, defStyleAttr, 0);
85 |
86 | scaleRatio = ta.getFloat(R.styleable.ActionCircle_scaleRatio, 3.5f);
87 | duration = ta.getInt(R.styleable.ActionCircle_duration, 200);
88 | bgColor = ta.getColor(R.styleable.ActionCircle_bgColor, Color.parseColor("#4ad6bd"));
89 | radius = ta.getDimension(R.styleable.ActionCircle_radius, 80);
90 | menuIconRotateAngle = (-1) * ta.getInt(R.styleable.ActionCircle_menuIconRotateAngle, 225);
91 | menuIconHeight = ta.getDimension(R.styleable.ActionCircle_menuIconHeight, radius);
92 | menuIconWidth = ta.getDimension(R.styleable.ActionCircle_menuIconWidth, radius);
93 | shadowWidth = ta.getDimension(R.styleable.ActionCircle_shadowWidth, 2);
94 | menuIconId = ta.getResourceId(R.styleable.ActionCircle_menuIcon, R.drawable.default_menu_icon);
95 | firstActionId = ta.getResourceId(R.styleable.ActionCircle_firstActionIcon, R.drawable.fav_icon);
96 | secondActionId = ta.getResourceId(R.styleable.ActionCircle_secondActionIcon, R.drawable.share_icon);
97 | thirdActionId = ta.getResourceId(R.styleable.ActionCircle_thirdActionIcon, R.drawable.search_icon);
98 | fourthActionId = ta.getResourceId(R.styleable.ActionCircle_fourthActionIcon, R.drawable.settings_icon);
99 |
100 | ta.recycle();
101 |
102 | addMenuCircle(c);
103 | addMenuItems(c);
104 | addMenuIcon(c);
105 | }
106 |
107 | private void addMenuItems(Context c){
108 |
109 | actions = new int[5];
110 |
111 | actions[0] = firstActionId;
112 | actions[1] = secondActionId;
113 | actions[2] = secondActionId;
114 | actions[3] = thirdActionId;
115 | actions[4] = fourthActionId;
116 |
117 | menuItemsContainer = new RelativeLayout(c);
118 | menuItemsContainer.setVisibility(INVISIBLE);
119 | LayoutParams rlParams = new LayoutParams((int)(radius*scaleRatio*itemContainerScaleRatio),(int)radius);
120 | rlParams.addRule(CENTER_HORIZONTAL,TRUE);
121 | menuItemsContainer.setLayoutParams(rlParams);
122 |
123 | LinearLayout layout = new LinearLayout(c);
124 | LinearLayout.LayoutParams params = new LinearLayout.LayoutParams((int)(radius*scaleRatio*itemContainerScaleRatio),(int)radius);
125 | layout.setWeightSum(actions.length);
126 | layout.setLayoutParams(params);
127 |
128 | for (int i = 0; i < actions.length; i++){
129 | final ImageView v = new ImageView(c);
130 | LayoutParams p = new LayoutParams((int)menuIconWidth, (int)menuIconHeight);
131 | p.addRule(CENTER_HORIZONTAL,TRUE);
132 | v.setAdjustViewBounds(true);
133 | v.setScaleType(ImageView.ScaleType.FIT_XY);
134 | v.setLayoutParams(p);
135 |
136 | LinearLayout r = new LinearLayout(c);
137 | LinearLayout.LayoutParams rParams = new LinearLayout.LayoutParams((int)menuIconWidth,
138 | (int)menuIconHeight);
139 | rParams.gravity = Gravity.CENTER;
140 | r.setPadding((int)(((radius*scaleRatio*itemContainerScaleRatio)/actions.length-menuIconWidth))/2,0,0,0);
141 | rParams.weight = 1;
142 | r.setLayoutParams(rParams);
143 | r.addView(v);
144 | layout.addView(r);
145 |
146 | if(i != actions.length/2){
147 | v.setBackgroundResource(actions[i]);
148 | setClickAnim(v);
149 |
150 | final int finalI;
151 | if(i > actions.length/2){
152 | finalI = i-1;
153 | }else{
154 | finalI = i;
155 | }
156 | layout.getChildAt(i).setOnClickListener(new OnClickListener() {
157 | @Override
158 | public void onClick(View view) {
159 | if(clickEvent != null){
160 | clickEvent.onClick(finalI);
161 | }
162 | fs.closeMenu();
163 | menuIconContainer.startAnimation(menuIconCloseAnim);
164 | animateClick(v);
165 | }
166 | });
167 | }
168 |
169 | }
170 | menuItemsContainer.addView(layout);
171 | addView(menuItemsContainer);
172 |
173 | setItemConteinerAnim();
174 | }
175 |
176 | private void addMenuCircle(Context c){
177 | fs = new ActionCircle(c);
178 | fs.setDuration(duration);
179 | fs.setColor(bgColor);
180 | fs.setScaleRatio(scaleRatio);
181 | fs.setRadius(radius);
182 | fs.setShadowWidth(shadowWidth);
183 | fs.init();
184 | addView(fs);
185 | }
186 |
187 | private void addMenuIcon(Context c){
188 | menuIconContainer = new RelativeLayout(c);
189 | LayoutParams containerParams = new LayoutParams((int)radius, (int)radius);
190 | containerParams.addRule(CENTER_HORIZONTAL,TRUE);
191 | containerParams.addRule(CENTER_VERTICAL,TRUE);
192 | menuIconContainer.setLayoutParams(containerParams);
193 | containerParams.setMargins(0,0,0,0);
194 |
195 | ImageView menuIcon = new ImageView(c);
196 | LayoutParams lp = new LayoutParams((int)menuIconWidth, (int)menuIconHeight);
197 | lp.addRule(CENTER_HORIZONTAL,TRUE);
198 | lp.addRule(CENTER_VERTICAL,TRUE);
199 | menuIcon.setPadding(0,0,0,0);
200 | menuIcon.setAdjustViewBounds(true);
201 | menuIcon.setScaleType(ImageView.ScaleType.FIT_XY);
202 | menuIcon.setLayoutParams(lp);
203 | menuIcon.setBackgroundResource(menuIconId);
204 |
205 | menuIconContainer.addView(menuIcon);
206 | addView(menuIconContainer);
207 |
208 | setMenuIconAnim();
209 | }
210 |
211 | private void setMenuIconAnim(){
212 | menuIconOpenAnim = new RotateAnimation(0, menuIconRotateAngle, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
213 | menuIconOpenAnim.setFillAfter(true);
214 | menuIconOpenAnim.setDuration(duration);
215 | menuIconOpenAnim.setAnimationListener(new Animation.AnimationListener() {
216 | @Override
217 | public void onAnimationStart(Animation animation) {
218 | isAnimating = true;
219 | }
220 |
221 | @Override
222 | public void onAnimationEnd(Animation animation) {
223 | isAnimating = false;
224 | isOpen = true;
225 | menuItemsContainer.startAnimation(menuRevealAnim);
226 | }
227 |
228 | @Override
229 | public void onAnimationRepeat(Animation animation) {
230 |
231 | }
232 | });
233 |
234 | menuIconCloseAnim = new RotateAnimation(menuIconRotateAngle, 0, Animation.RELATIVE_TO_SELF, 0.5f,
235 | Animation.RELATIVE_TO_SELF, 0.5f);
236 | menuIconCloseAnim.setFillAfter(true);
237 | menuIconCloseAnim.setDuration(duration);
238 | menuIconCloseAnim.setAnimationListener(new Animation.AnimationListener() {
239 | @Override
240 | public void onAnimationStart(Animation animation) {
241 | isAnimating = true;
242 | menuItemsContainer.startAnimation(menuFadeOutAnim);
243 | }
244 |
245 | @Override
246 | public void onAnimationEnd(Animation animation) {
247 | isAnimating = false;
248 | isOpen = false;
249 | }
250 |
251 | @Override
252 | public void onAnimationRepeat(Animation animation) {
253 |
254 | }
255 | });
256 |
257 |
258 | menuIconContainer.setOnClickListener(new OnClickListener() {
259 | @Override
260 | public void onClick(View view) {
261 | if(!isAnimating){
262 | if(!isOpen){
263 | fs.openMenu();
264 | menuIconContainer.startAnimation(menuIconOpenAnim);
265 | }else{
266 | fs.closeMenu();
267 | menuIconContainer.startAnimation(menuIconCloseAnim);
268 | }
269 | }
270 | }
271 | });
272 |
273 | }
274 |
275 | private void setItemConteinerAnim(){
276 | menuRevealAnim = new AlphaAnimation(0, 1.0f);
277 | menuRevealAnim.setDuration(fadeOutFadeInDuration);
278 | menuRevealAnim.setFillAfter(true);
279 |
280 | menuFadeOutAnim = new AlphaAnimation(1.0f, 0);
281 | menuFadeOutAnim.setDuration(fadeOutFadeInDuration);
282 | menuFadeOutAnim.setFillAfter(true);
283 | }
284 |
285 | public interface ClickEvent{
286 | void onClick(int index);
287 | }
288 |
289 | public void setClickEvent(ClickEvent clickEvent){
290 | this.clickEvent = clickEvent;
291 | }
292 |
293 | private void setClickAnim(View v){
294 | scaleDownAnim = new ScaleAnimation(1f, 0.8f, 1f, 0.8f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
295 | scaleDownAnim.setFillAfter(true);
296 | scaleDownAnim.setDuration(20);
297 |
298 | scaleUpAnim = new ScaleAnimation(0.8f, 1f,0.8f, 1f,Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
299 | scaleUpAnim.setFillAfter(true);
300 | scaleUpAnim.setDuration(20);
301 | scaleUpAnim.setStartOffset(20);
302 | }
303 |
304 | private void animateClick(View v){
305 | v.startAnimation(scaleDownAnim);
306 | v.startAnimation(scaleUpAnim);
307 | }
308 |
309 | public float getScaleRatio() {
310 | return scaleRatio;
311 | }
312 |
313 | public void setScaleRatio(float scaleRatio) {
314 | this.scaleRatio = scaleRatio;
315 | invalidate();
316 | }
317 |
318 | public int getDuration() {
319 | return duration;
320 | }
321 |
322 | public void setDuration(int duration) {
323 | this.duration = duration;
324 | invalidate();
325 | }
326 |
327 | public int getBgColor() {
328 | return bgColor;
329 | }
330 |
331 | public void setBgColor(int bgColor) {
332 | this.bgColor = bgColor;
333 | invalidate();
334 | }
335 |
336 | public float getRadius() {
337 | return radius;
338 | }
339 |
340 | public void setRadius(float radius) {
341 | this.radius = radius;
342 | invalidate();
343 | }
344 |
345 | public int getMenuIconRotateAngle() {
346 | return menuIconRotateAngle;
347 | }
348 |
349 | public void setMenuIconRotateAngle(int menuIconRotateAngle) {
350 | this.menuIconRotateAngle = menuIconRotateAngle;
351 | invalidate();
352 | }
353 |
354 | public float getMenuIconWidth() {
355 | return menuIconWidth;
356 | }
357 |
358 | public void setMenuIconWidth(float menuIconWidth) {
359 | this.menuIconWidth = menuIconWidth;
360 | invalidate();
361 | }
362 |
363 | public float getMenuIconHeight() {
364 | return menuIconHeight;
365 | }
366 |
367 | public void setMenuIconHeight(float menuIconHeight) {
368 | this.menuIconHeight = menuIconHeight;
369 | invalidate();
370 | }
371 |
372 | public float getShadowWidth() {
373 | return shadowWidth;
374 | }
375 |
376 | public void setShadowWidth(float shadowWidth) {
377 | this.shadowWidth = shadowWidth;
378 | invalidate();
379 | }
380 |
381 | public int getMenuIconId() {
382 | return menuIconId;
383 | }
384 |
385 | public void setMenuIconId(int menuIconId) {
386 | this.menuIconId = menuIconId;
387 | invalidate();
388 | }
389 |
390 | public int getFirstActionId() {
391 | return firstActionId;
392 | }
393 |
394 | public void setFirstActionId(int firstActionId) {
395 | this.firstActionId = firstActionId;
396 | invalidate();
397 | }
398 |
399 | public int getSecondActionId() {
400 | return secondActionId;
401 | }
402 |
403 | public void setSecondActionId(int secondActionId) {
404 | this.secondActionId = secondActionId;
405 | invalidate();
406 | }
407 |
408 | public int getThirdActionId() {
409 | return thirdActionId;
410 | }
411 |
412 | public void setThirdActionId(int thirdActionId) {
413 | this.thirdActionId = thirdActionId;
414 | invalidate();
415 | }
416 |
417 | public int getFourthActionId() {
418 | return fourthActionId;
419 | }
420 |
421 | public void setFourthActionId(int fourthActionId) {
422 | this.fourthActionId = fourthActionId;
423 | invalidate();
424 | }
425 |
426 |
427 | }
428 |
--------------------------------------------------------------------------------
/app/src/main/java/com/emredavarci/floatingactionmenu/MainActivity.java:
--------------------------------------------------------------------------------
1 | package com.emredavarci.floatingactionmenu;
2 |
3 | import android.support.v7.app.AppCompatActivity;
4 | import android.os.Bundle;
5 | import android.util.Log;
6 |
7 | public class MainActivity extends AppCompatActivity {
8 |
9 | @Override
10 | protected void onCreate(Bundle savedInstanceState) {
11 | super.onCreate(savedInstanceState);
12 | setContentView(R.layout.activity_main);
13 | FloatingActionMenu menu = (FloatingActionMenu) findViewById(R.id.floatingMenu);
14 | menu.setClickEvent(new FloatingActionMenu.ClickEvent() {
15 | @Override
16 | public void onClick(int index) {
17 | Log.d("TAG", String.valueOf(index)); // index of clicked menu item
18 | }
19 | });
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/app/src/main/res/drawable/default_menu_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/drawable/default_menu_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/fav_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/drawable/fav_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/search_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/drawable/search_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/settings_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/drawable/settings_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/drawable/share_icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/drawable/share_icon.png
--------------------------------------------------------------------------------
/app/src/main/res/layout/activity_main.xml:
--------------------------------------------------------------------------------
1 |
2 |
9 |
10 |
11 |
32 |
33 |
34 |
35 |
36 |
37 |
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-hdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-mdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
--------------------------------------------------------------------------------
/app/src/main/res/values/attrs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
--------------------------------------------------------------------------------
/app/src/main/res/values/colors.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 | #3F51B5
4 | #303F9F
5 | #FF4081
6 |
7 |
--------------------------------------------------------------------------------
/app/src/main/res/values/strings.xml:
--------------------------------------------------------------------------------
1 |
2 | FloatingActionMenu
3 |
4 |
--------------------------------------------------------------------------------
/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/app/src/test/java/com/emredavarci/floatingactionmenu/ExampleUnitTest.java:
--------------------------------------------------------------------------------
1 | package com.emredavarci.floatingactionmenu;
2 |
3 | import org.junit.Test;
4 |
5 | import static org.junit.Assert.*;
6 |
7 | /**
8 | * Example local unit test, which will execute on the development machine (host).
9 | *
10 | * @see Testing documentation
11 | */
12 | public class ExampleUnitTest {
13 | @Test
14 | public void addition_isCorrect() throws Exception {
15 | assertEquals(4, 2 + 2);
16 | }
17 | }
--------------------------------------------------------------------------------
/build.gradle:
--------------------------------------------------------------------------------
1 | // Top-level build file where you can add configuration options common to all sub-projects/modules.
2 |
3 | buildscript {
4 | repositories {
5 | jcenter()
6 | }
7 | dependencies {
8 | classpath 'com.android.tools.build:gradle:2.3.0+'
9 | classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
10 | classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | jcenter()
17 | }
18 | }
19 |
20 | task clean(type: Delete) {
21 | delete rootProject.buildDir
22 | }
23 |
--------------------------------------------------------------------------------
/gradle.properties:
--------------------------------------------------------------------------------
1 | # Project-wide Gradle settings.
2 |
3 | # IDE (e.g. Android Studio) users:
4 | # Gradle settings configured through the IDE *will override*
5 | # any settings specified in this file.
6 |
7 | # For more details on how to configure your build environment visit
8 | # http://www.gradle.org/docs/current/userguide/build_environment.html
9 |
10 | # Specifies the JVM arguments used for the daemon process.
11 | # The setting is particularly useful for tweaking memory settings.
12 | org.gradle.jvmargs=-XX\:MaxHeapSize\=256m -Xmx256m
13 |
14 | # When configured, Gradle will run in incubating parallel mode.
15 | # This option should only be used with decoupled projects. More details, visit
16 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
17 | # org.gradle.parallel=true
18 |
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/emre1512/FloatingActionMenu/bebf4991e2e20dbfe060d2671d671987bf1cac99/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Aug 18 14:01:25 EEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
7 |
--------------------------------------------------------------------------------
/gradlew:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 |
3 | ##############################################################################
4 | ##
5 | ## Gradle start up script for UN*X
6 | ##
7 | ##############################################################################
8 |
9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
10 | DEFAULT_JVM_OPTS=""
11 |
12 | APP_NAME="Gradle"
13 | APP_BASE_NAME=`basename "$0"`
14 |
15 | # Use the maximum available, or set MAX_FD != -1 to use that value.
16 | MAX_FD="maximum"
17 |
18 | warn ( ) {
19 | echo "$*"
20 | }
21 |
22 | die ( ) {
23 | echo
24 | echo "$*"
25 | echo
26 | exit 1
27 | }
28 |
29 | # OS specific support (must be 'true' or 'false').
30 | cygwin=false
31 | msys=false
32 | darwin=false
33 | case "`uname`" in
34 | CYGWIN* )
35 | cygwin=true
36 | ;;
37 | Darwin* )
38 | darwin=true
39 | ;;
40 | MINGW* )
41 | msys=true
42 | ;;
43 | esac
44 |
45 | # Attempt to set APP_HOME
46 | # Resolve links: $0 may be a link
47 | PRG="$0"
48 | # Need this for relative symlinks.
49 | while [ -h "$PRG" ] ; do
50 | ls=`ls -ld "$PRG"`
51 | link=`expr "$ls" : '.*-> \(.*\)$'`
52 | if expr "$link" : '/.*' > /dev/null; then
53 | PRG="$link"
54 | else
55 | PRG=`dirname "$PRG"`"/$link"
56 | fi
57 | done
58 | SAVED="`pwd`"
59 | cd "`dirname \"$PRG\"`/" >/dev/null
60 | APP_HOME="`pwd -P`"
61 | cd "$SAVED" >/dev/null
62 |
63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
64 |
65 | # Determine the Java command to use to start the JVM.
66 | if [ -n "$JAVA_HOME" ] ; then
67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
68 | # IBM's JDK on AIX uses strange locations for the executables
69 | JAVACMD="$JAVA_HOME/jre/sh/java"
70 | else
71 | JAVACMD="$JAVA_HOME/bin/java"
72 | fi
73 | if [ ! -x "$JAVACMD" ] ; then
74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
75 |
76 | Please set the JAVA_HOME variable in your environment to match the
77 | location of your Java installation."
78 | fi
79 | else
80 | JAVACMD="java"
81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
82 |
83 | Please set the JAVA_HOME variable in your environment to match the
84 | location of your Java installation."
85 | fi
86 |
87 | # Increase the maximum file descriptors if we can.
88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
89 | MAX_FD_LIMIT=`ulimit -H -n`
90 | if [ $? -eq 0 ] ; then
91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
92 | MAX_FD="$MAX_FD_LIMIT"
93 | fi
94 | ulimit -n $MAX_FD
95 | if [ $? -ne 0 ] ; then
96 | warn "Could not set maximum file descriptor limit: $MAX_FD"
97 | fi
98 | else
99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
100 | fi
101 | fi
102 |
103 | # For Darwin, add options to specify how the application appears in the dock
104 | if $darwin; then
105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
106 | fi
107 |
108 | # For Cygwin, switch paths to Windows format before running java
109 | if $cygwin ; then
110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"`
111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
112 | JAVACMD=`cygpath --unix "$JAVACMD"`
113 |
114 | # We build the pattern for arguments to be converted via cygpath
115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
116 | SEP=""
117 | for dir in $ROOTDIRSRAW ; do
118 | ROOTDIRS="$ROOTDIRS$SEP$dir"
119 | SEP="|"
120 | done
121 | OURCYGPATTERN="(^($ROOTDIRS))"
122 | # Add a user-defined pattern to the cygpath arguments
123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then
124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
125 | fi
126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh
127 | i=0
128 | for arg in "$@" ; do
129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
131 |
132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
134 | else
135 | eval `echo args$i`="\"$arg\""
136 | fi
137 | i=$((i+1))
138 | done
139 | case $i in
140 | (0) set -- ;;
141 | (1) set -- "$args0" ;;
142 | (2) set -- "$args0" "$args1" ;;
143 | (3) set -- "$args0" "$args1" "$args2" ;;
144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
150 | esac
151 | fi
152 |
153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
154 | function splitJvmOpts() {
155 | JVM_OPTS=("$@")
156 | }
157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
159 |
160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
161 |
--------------------------------------------------------------------------------
/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
12 | set DEFAULT_JVM_OPTS=
13 |
14 | set DIRNAME=%~dp0
15 | if "%DIRNAME%" == "" set DIRNAME=.
16 | set APP_BASE_NAME=%~n0
17 | set APP_HOME=%DIRNAME%
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windowz variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 | if "%@eval[2+2]" == "4" goto 4NT_args
53 |
54 | :win9xME_args
55 | @rem Slurp the command line arguments.
56 | set CMD_LINE_ARGS=
57 | set _SKIP=2
58 |
59 | :win9xME_args_slurp
60 | if "x%~1" == "x" goto execute
61 |
62 | set CMD_LINE_ARGS=%*
63 | goto execute
64 |
65 | :4NT_args
66 | @rem Get arguments from the 4NT Shell from JP Software
67 | set CMD_LINE_ARGS=%$
68 |
69 | :execute
70 | @rem Setup the command line
71 |
72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
73 |
74 | @rem Execute Gradle
75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
76 |
77 | :end
78 | @rem End local scope for the variables with windows NT shell
79 | if "%ERRORLEVEL%"=="0" goto mainEnd
80 |
81 | :fail
82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
83 | rem the _cmd.exe /c_ return code!
84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
85 | exit /b 1
86 |
87 | :mainEnd
88 | if "%OS%"=="Windows_NT" endlocal
89 |
90 | :omega
91 |
--------------------------------------------------------------------------------
/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
--------------------------------------------------------------------------------