Skip to content

Commit 48a5e44

Browse files
committed
New update
Floating Button, Tooltip and Arc menu Updated.
1 parent a1525a5 commit 48a5e44

File tree

19 files changed

+402
-96
lines changed

19 files changed

+402
-96
lines changed

ArcMenuLibrary/ArcMenuLibrary.iml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,6 @@
6767
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
6868
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
6969
<sourceFolder url="file://$MODULE_DIR$/src/main/shaders" isTestSource="false" />
70-
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
71-
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
72-
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
73-
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
74-
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
75-
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
76-
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
77-
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
7870
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />
7971
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/resources" type="java-test-resource" />
8072
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/assets" type="java-test-resource" />
@@ -83,6 +75,14 @@
8375
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/jni" isTestSource="true" />
8476
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/rs" isTestSource="true" />
8577
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/shaders" isTestSource="true" />
78+
<sourceFolder url="file://$MODULE_DIR$/src/test/res" type="java-test-resource" />
79+
<sourceFolder url="file://$MODULE_DIR$/src/test/resources" type="java-test-resource" />
80+
<sourceFolder url="file://$MODULE_DIR$/src/test/assets" type="java-test-resource" />
81+
<sourceFolder url="file://$MODULE_DIR$/src/test/aidl" isTestSource="true" />
82+
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
83+
<sourceFolder url="file://$MODULE_DIR$/src/test/jni" isTestSource="true" />
84+
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
85+
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
8686
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
8787
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/blame" />
8888
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/bundles" />

ArcMenuLibrary/build.gradle

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ apply plugin: 'com.github.dcendents.android-maven'
44

55
buildscript {
66
group = 'com.github.BrotherV'
7-
version = '1.0.6'
7+
version = VERSION_NAME
88
repositories {
99
mavenCentral()
1010
}
@@ -15,14 +15,14 @@ buildscript {
1515
}
1616

1717
android {
18-
compileSdkVersion rootProject.ext.compileSdkVersion
19-
buildToolsVersion rootProject.ext.buildToolsVersion
18+
compileSdkVersion COMPILE_SDK_VERSION as int
19+
buildToolsVersion BUILD_TOOLS_VERSION as String
2020

2121
defaultConfig {
22-
minSdkVersion rootProject.ext.minSdkVersion
23-
targetSdkVersion rootProject.ext.targetSdkVersion
24-
versionCode 4
25-
versionName "1.0.6"
22+
minSdkVersion MIN_SDK_VERSION as int
23+
targetSdkVersion TARGET_SDK_VERSION as int
24+
versionCode VERSION_CODE as int
25+
versionName VERSION_NAME as String
2626

2727
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
2828

@@ -40,8 +40,7 @@ dependencies {
4040
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
4141
exclude group: 'com.android.support', module: 'support-annotations'
4242
})
43-
compile 'com.android.support:appcompat-v7:25.0.1'
44-
compile 'com.android.support:design:25.0.1'
43+
compile supportDependencies.appCompat
44+
compile supportDependencies.design
4545
testCompile 'junit:junit:4.12'
46-
compile files('libs/nineoldandroids-2.4.0.jar')
4746
}
-108 KB
Binary file not shown.

ArcMenuLibrary/src/main/java/com/bvapp/arcmenulibrary/ArcLayout.java

Lines changed: 76 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,9 @@
1717
package com.bvapp.arcmenulibrary;
1818

1919
import android.content.Context;
20-
import android.content.res.ColorStateList;
2120
import android.content.res.Resources;
2221
import android.graphics.Rect;
23-
import android.graphics.Typeface;
24-
import android.os.Build;
25-
import android.support.annotation.ColorInt;
26-
import android.support.annotation.DimenRes;
27-
import android.support.design.widget.CoordinatorLayout;
2822
import android.util.AttributeSet;
29-
import android.util.DisplayMetrics;
30-
import android.util.Log;
31-
import android.view.Gravity;
3223
import android.view.View;
3324
import android.view.animation.AccelerateInterpolator;
3425
import android.view.animation.AlphaAnimation;
@@ -40,7 +31,6 @@
4031
import android.view.animation.LinearInterpolator;
4132
import android.view.animation.OvershootInterpolator;
4233
import android.view.animation.RotateAnimation;
43-
import android.widget.FrameLayout;
4434
import android.widget.RelativeLayout;
4535

4636
import java.util.ArrayList;
@@ -79,6 +69,11 @@ public interface OnMenuItemOpenClose{
7969

8070
private static final int MIN_RADIUS = 100;
8171

72+
public static final int TOOLTIP_UP= 0xF20;
73+
public static final int TOOLTIP_DOWN= 0xF21;
74+
public static final int TOOLTIP_RIGHT= 0xF22;
75+
public static final int TOOLTIP_LEFT= 0xF23;
76+
8277
private Context mContext;
8378
private int mLayoutCenterX;
8479
private int mLayoutCenterY;
@@ -104,17 +99,20 @@ public interface OnMenuItemOpenClose{
10499
private float tPerDeg = DEFAULT_TO_DEGREES;
105100

106101
/* the distance between the layout's center and any child's center */
107-
private int mRadius;
102+
private int mRadius = 0;
108103
private int mMinRadius = MIN_RADIUS;
109104
private boolean mExpanded = false;
110105
private boolean mExpandDone;
111106
private boolean mAnimDone = true;
107+
private boolean mRaiusCtrl;
112108

113109
/* */
114110
private ArrayList<TextStructure> textStructure = new ArrayList<>();
115111
private boolean menuItemRotatationInClosing;
116112
private boolean checkCenterGravity;
117113
private boolean toolTipCtrl;
114+
private int mToolTipSide;
115+
private int mPreChildOffset;
118116

119117
/**
120118
*
@@ -217,9 +215,10 @@ private static double computeOffsetX(final int offset, final float degrees) {
217215
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
218216
//super.onMeasure(widthMeasureSpec, heightMeasureSpec);
219217

220-
final int radius = mRadius = computeRadius(
218+
int radius = mRadius = computeRadius(
221219
Math.abs(mToDegrees - mFromDegrees), getChildCount()/2,
222220
mChildSize, mChildPadding, mMinRadius);
221+
223222
final int size = radius * 3 + mChildSize + mChildPadding
224223
+ mLayoutPadding * 2 + mMenuSize + 4 * mDefaultShift + mViewWidth;
225224

@@ -382,12 +381,26 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
382381
if(toolTipCtrl){
383382
tStructure = textStructure.get(j);
384383
j++;
385-
int shift = getShift(mFromDegrees, mToDegrees, tDeg, tStructure.w);
386-
387-
frame = computeChildFrame(centerX, centerY, mExpanded ? mRadius : 0, mChildSize, shift, tDeg,
384+
int l1, r1, t1, b1;
385+
l1 = r1 = t1 = b1 = 0;
386+
frame = computeChildFrame(centerX, centerY, mExpanded ? mRadius : 0, 0, 0, degrees,
388387
getChildAt(childAt).getMeasuredHeight(), getChildAt(childAt).getMeasuredWidth());
388+
if(mToolTipSide == TOOLTIP_UP){
389+
t1 = getFrameOffsetY(tStructure.h);
390+
}else if(mToolTipSide == TOOLTIP_DOWN){
391+
b1 = getFrameOffsetY(tStructure.h);
392+
}else if(mToolTipSide == TOOLTIP_RIGHT){
393+
r1 = getFrameOffsetX(tStructure.w);
394+
}else if(mToolTipSide == TOOLTIP_LEFT){
395+
l1 = getFrameOffsetX(tStructure.w);
396+
}else {
397+
int shiftX = getShift(mFromDegrees, mToDegrees, tDeg, tStructure.w);
398+
int shiftY = mChildSize;
399+
frame = computeChildFrame(centerX, centerY, mExpanded ? mRadius : 0, shiftY, shiftX, tDeg,
400+
getChildAt(childAt).getMeasuredHeight(), getChildAt(childAt).getMeasuredWidth());
401+
}
389402

390-
getChildAt(childAt).layout(frame.left, frame.top, frame.right, frame.bottom);
403+
getChildAt(childAt).layout(frame.left - l1 + r1, frame.top - t1 + b1, frame.right - l1 + r1, frame.bottom - t1 + b1);
391404
getChildAt(childAt).setVisibility(mExpanded ? VISIBLE :INVISIBLE);
392405
}else{
393406
getChildAt(childAt).setVisibility(INVISIBLE);
@@ -399,6 +412,22 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
399412
}
400413
}
401414

415+
private int getFrameOffsetX(int w){
416+
/*
417+
mPreChildOffset = w;
418+
for(TextStructure str: textStructure){
419+
if(str.w > mPreChildOffset){
420+
mPreChildOffset = str.w;
421+
}
422+
}
423+
return (mPreChildOffset + mChildSize + (int) dpToPx(4))/2;
424+
*/
425+
return (w + mChildSize + (int) dpToPx(4))/2 ;
426+
}
427+
428+
private int getFrameOffsetY(int h){
429+
return h > mChildSize ? h : mChildSize;
430+
}
402431
/**
403432
*
404433
* @param fDeg
@@ -486,9 +515,27 @@ private void bindChildAnimation(final View child, final int index, final int ord
486515
final float perDegrees = (mToDegrees - mFromDegrees) / (childCount - 1);
487516
Rect frame;
488517
if(order % 2 != 0){
489-
int shift = getShift(mFromDegrees, mToDegrees, tDeg + index * tPerDeg, child.getMeasuredWidth());
490-
frame = computeChildFrame(centerX, centerY, mExpanded ? 0 : mRadius, mChildSize, shift,tDeg
491-
+ index * tPerDeg, child.getMeasuredHeight(), child.getMeasuredWidth());
518+
frame = computeChildFrame(centerX, centerY, mExpanded ? 0 : mRadius, 0, 0,mFromDegrees
519+
+ index * perDegrees, child.getMeasuredHeight(), child.getMeasuredWidth());
520+
int offsetX = getFrameOffsetX(child.getMeasuredWidth());
521+
int offsetY = getFrameOffsetY(child.getMeasuredHeight());
522+
if(mToolTipSide == TOOLTIP_UP){
523+
frame.top -= offsetY;
524+
frame.bottom -= offsetY;
525+
}else if(mToolTipSide == TOOLTIP_DOWN){
526+
frame.top += offsetY;
527+
frame.bottom += offsetY;
528+
}else if(mToolTipSide == TOOLTIP_RIGHT){
529+
frame.left += offsetX;
530+
frame.right += offsetX;
531+
}else if(mToolTipSide == TOOLTIP_LEFT){
532+
frame.left -= offsetX;
533+
frame.right -= offsetX;
534+
}else{
535+
int shift = getShift(mFromDegrees, mToDegrees, tDeg + index * tPerDeg, child.getMeasuredWidth());
536+
frame = computeChildFrame(centerX, centerY, mExpanded ? 0 : mRadius, mChildSize, shift,tDeg
537+
+ index * tPerDeg, child.getMeasuredHeight(), child.getMeasuredWidth());
538+
}
492539
}else{
493540
frame = computeChildFrame(centerX, centerY, radius, mFromDegrees
494541
+ index * perDegrees, mChildSize);
@@ -752,6 +799,10 @@ public void setArc(float fromDegrees, float toDegrees) {
752799
requestLayout();
753800
}
754801

802+
public void setToolTipSide(int mToolTipSide) {
803+
this.mToolTipSide = mToolTipSide;
804+
}
805+
755806
/**
756807
*
757808
* @param left
@@ -862,6 +913,12 @@ public int getRadius() {
862913
return mRadius;
863914
}
864915

916+
public void setRadius(int mRadius) {
917+
this.mRadius = mRadius;
918+
mRaiusCtrl = true;
919+
requestLayout();
920+
}
921+
865922
/**
866923
*
867924
* @param l

ArcMenuLibrary/src/main/java/com/bvapp/arcmenulibrary/ArcMenu.java

Lines changed: 46 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,13 @@
2525
import android.graphics.drawable.Drawable;
2626
import android.graphics.drawable.GradientDrawable;
2727
import android.os.Build;
28+
import android.support.annotation.ColorRes;
2829
import android.support.annotation.NonNull;
2930
import android.support.v7.widget.RecyclerView;
3031
import android.util.AttributeSet;
3132
import android.util.Log;
3233
import android.view.Gravity;
3334
import android.view.LayoutInflater;
34-
import android.view.MotionEvent;
3535
import android.view.View;
3636
import android.view.ViewGroup;
3737
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -88,6 +88,11 @@ public class ArcMenu extends RelativeLayout {
8888
public static final int ANIM_INTERPOLATOR_ANTICIPATE= 0xF19;
8989
public static final int ANIM_INTERPOLATOR_BOUNCE = 0xF1A;
9090

91+
public static final int TOOLTIP_UP= 0xF20;
92+
public static final int TOOLTIP_DOWN= 0xF21;
93+
public static final int TOOLTIP_RIGHT= 0xF22;
94+
public static final int TOOLTIP_LEFT= 0xF23;
95+
9196

9297
private static final int ANIM_DURATION = 300;
9398

@@ -245,14 +250,8 @@ private void applyAttrs(Context context, AttributeSet attrs) {
245250
color = b.getColor(R.styleable.ArcMenu_menuRippleColor, Color.BLUE);
246251
fabMenu.setColorRipple(color);
247252

248-
Drawable drawable = b.getDrawable(R.styleable.ArcMenu_menuImage);
249-
if (drawable != null) {
250-
fabMenu.setImageDrawable(drawable);
251-
//fabMenu.setBackground(drawable);
252-
}
253-
254253
isShadow = b.getBoolean(R.styleable.ArcMenu_menuShadowElevation,false);
255-
mShadowElevation = fabMenu.getEleationSize();
254+
mShadowElevation = fabMenu.getShadowSize();
256255
if (isShadow) {
257256
//defaultMenuSize += mShadowElevation * 2;
258257
fabMenu.setShadow(true);
@@ -273,9 +272,15 @@ private void applyAttrs(Context context, AttributeSet attrs) {
273272
mArcLayout.setTextViewSize(mChildSize * 2, mChildSize/2);
274273

275274
mMenuSize = defaultMenuSize;
276-
fabMenu.setFabSize(mType);
275+
fabMenu.setFabType(mType);
277276
mArcLayout.setMenuSize(mMenuSize);
278277

278+
Drawable drawable = b.getDrawable(R.styleable.ArcMenu_menuImage);
279+
if (drawable != null) {
280+
fabMenu.setTopIcon(drawable, defaultMenuSize);
281+
//fabMenu.setImageDrawable(drawable);
282+
}
283+
279284
mMarginBottom = b.getDimensionPixelSize(R.styleable.ArcMenu_menuMarginBottom, 0);
280285
mMarginTop = b.getDimensionPixelSize(R.styleable.ArcMenu_menuMarginTop, 0);
281286
mMarginRight = b.getDimensionPixelSize(R.styleable.ArcMenu_menuMarginRight, 0);
@@ -353,10 +358,10 @@ private TextView getContentView(String str) {
353358
FrameLayout mContentView = new FrameLayout(mContext);
354359
mContentView.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
355360

356-
final int w = TextUtil.getWidth(mContext, str, mTextSize == 0 ? 10:mTextSize,
357-
TextUtil.getDeviceWidth(),mTypeface,mPadding);
358-
final int h = TextUtil.getHeight(mContext, str, mTextSize == 0 ? 10:mTextSize,
359-
TextUtil.getDeviceWidth(),mTypeface,mPadding);
361+
final int w = Util.getWidth(mContext, str, mTextSize == 0 ? 10:mTextSize,
362+
Util.getDeviceWidth(),mTypeface,mPadding);
363+
final int h = Util.getHeight(mContext, str, mTextSize == 0 ? 10:mTextSize,
364+
Util.getDeviceWidth(),mTypeface,mPadding);
360365

361366
Log.i("Child measure", "Size Height: " + h + " Size Width: " + w);
362367
setArcLayoutTextSize(w, h);
@@ -573,6 +578,15 @@ public boolean performClick() {
573578
clickMenu();
574579
return false;
575580
}
581+
582+
public void setMinRadius(int radius) {
583+
mArcLayout.setMinRadius((int) dpToPx(radius));
584+
}
585+
586+
public void setRadius(int radius) {
587+
mArcLayout.setRadius((int) dpToPx(radius));
588+
}
589+
576590
/**
577591
*
578592
* @param fromDegree
@@ -582,6 +596,25 @@ public void setArc(float fromDegree, float toDegree) {
582596
mArcLayout.setArc(fromDegree,toDegree);
583597
}
584598

599+
public void setColorNormal(int color) {
600+
fabMenu.setColorNormal(color);
601+
}
602+
603+
public void setColorPressed(int color) {
604+
fabMenu.setColorRipple(color);
605+
}
606+
607+
public void setColorRipple(int color) {
608+
fabMenu.setColorRipple(color);
609+
}
610+
/**
611+
*
612+
* @param side
613+
*/
614+
public void setToolTipSide(int side) {
615+
mArcLayout.setToolTipSide(side);
616+
}
617+
585618
public void setToolTipTextSize(int size) {
586619
mTextSize = size;
587620
}

0 commit comments

Comments
 (0)