From 735656ee428b25c8d58f352ffb8a29e9a1cb8ad1 Mon Sep 17 00:00:00 2001 From: narcher Date: Wed, 5 Jul 2017 16:08:03 -0600 Subject: [PATCH 01/10] Changes to support FAM-with-overflow for Andromeda: add setMenuButtonId() method, listeners for open/close animations, make default animation duration public, and split menuToggleListener into 2 listeners, for both starting & stopping toggle animation. Also made animation delay per item automatically be a division of total animation time by number of menu items. --- gradle.properties | 4 +- .../github/clans/fab/FloatingActionMenu.java | 102 ++++++++++++++---- .../clans/fab/sample/MenusFragment.java | 4 +- 3 files changed, 83 insertions(+), 27 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2e6a6c0..4838bfd 100755 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.6.4 -VERSION_CODE=10604 +VERSION_NAME=1.6.4-mod1 +VERSION_CODE=1060401 GROUP=com.github.clans POM_DESCRIPTION=Floating Action Button implementation for Android diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 0b80e4c..593db09 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -1,5 +1,6 @@ package com.github.clans.fab; +import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.ValueAnimator; @@ -30,7 +31,11 @@ public class FloatingActionMenu extends ViewGroup { - private static final int ANIMATION_DURATION = 300; + private String tag; + + public static final int TOTAL_ANIMATION_DURATION = 300; // Netscout change: made public + public static final int DEFAULT_ANIMATION_DELAY_PER_ITEM = 50; // Netscout change: new field + private static final float CLOSED_PLUS_ROTATION = 0f; private static final float OPENED_PLUS_ROTATION_LEFT = -90f - 45f; private static final float OPENED_PLUS_ROTATION_RIGHT = 90f + 45f; @@ -76,7 +81,7 @@ public class FloatingActionMenu extends ViewGroup { private int mMenuColorPressed; private int mMenuColorRipple; private Drawable mIcon; - private int mAnimationDelayPerItem; + private int mAnimationDelayPerItem = DEFAULT_ANIMATION_DELAY_PER_ITEM; // Netscout addition: default value private Interpolator mOpenInterpolator; private Interpolator mCloseInterpolator; private boolean mIsAnimated = true; @@ -95,7 +100,9 @@ public class FloatingActionMenu extends ViewGroup { private boolean mIsMenuButtonAnimationRunning; private boolean mIsSetClosedOnTouchOutside; private int mOpenDirection; - private OnMenuToggleListener mToggleListener; + // Netscout addition: FAM originally only supported a toggle listener which fired when finished + private OnMenuToggleStartedListener mToggleStartedListener; + private OnMenuToggleFinishedListener mToggleFinishedListener; private ValueAnimator mShowBackgroundAnimator; private ValueAnimator mHideBackgroundAnimator; @@ -106,8 +113,13 @@ public class FloatingActionMenu extends ViewGroup { private String mMenuLabelText; private boolean mUsingMenuLabel; - public interface OnMenuToggleListener { - void onMenuToggle(boolean opened); + // Netscout addition: FAM originally only supported a toggle listener which fired when finished + public interface OnMenuToggleStartedListener { + void onMenuToggleStarted(boolean opened); + } + + public interface OnMenuToggleFinishedListener { + void onMenuToggleFinished(boolean opened); } public FloatingActionMenu(Context context) { @@ -155,7 +167,6 @@ private void init(Context context, AttributeSet attrs) { mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336); mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043); mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF); - mAnimationDelayPerItem = attr.getInt(R.styleable.FloatingActionMenu_menu_animationDelayPerItem, 50); mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon); if (mIcon == null) { mIcon = getResources().getDrawable(R.drawable.fab_add); @@ -214,7 +225,7 @@ private void initBackgroundDimAnimation() { final int blue = Color.blue(mBackgroundColor); mShowBackgroundAnimator = ValueAnimator.ofInt(0, maxAlpha); - mShowBackgroundAnimator.setDuration(ANIMATION_DURATION); + mShowBackgroundAnimator.setDuration(TOTAL_ANIMATION_DURATION); mShowBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { @@ -224,7 +235,7 @@ public void onAnimationUpdate(ValueAnimator animation) { }); mHideBackgroundAnimator = ValueAnimator.ofInt(maxAlpha, 0); - mHideBackgroundAnimator.setDuration(ANIMATION_DURATION); + mHideBackgroundAnimator.setDuration(TOTAL_ANIMATION_DURATION); mHideBackgroundAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { @@ -300,8 +311,8 @@ private void createDefaultIconAnimation() { mOpenAnimatorSet.setInterpolator(mOpenInterpolator); mCloseAnimatorSet.setInterpolator(mCloseInterpolator); - mOpenAnimatorSet.setDuration(ANIMATION_DURATION); - mCloseAnimatorSet.setDuration(ANIMATION_DURATION); + mOpenAnimatorSet.setDuration(TOTAL_ANIMATION_DURATION); + mCloseAnimatorSet.setDuration(TOTAL_ANIMATION_DURATION); } @Override @@ -637,6 +648,11 @@ public void open(final boolean animate) { } } + // Netscout addition: + if (mToggleStartedListener != null) { + mToggleStartedListener.onMenuToggleStarted(true); + } + int delay = 0; int counter = 0; mIsMenuOpening = true; @@ -670,8 +686,8 @@ public void run() { public void run() { mMenuOpened = true; - if (mToggleListener != null) { - mToggleListener.onMenuToggle(true); + if (mToggleFinishedListener != null) { + mToggleFinishedListener.onMenuToggleFinished(true); } } }, ++counter * mAnimationDelayPerItem); @@ -693,6 +709,11 @@ public void close(final boolean animate) { } } + // Netscout addition: + if (mToggleStartedListener != null) { + mToggleStartedListener.onMenuToggleStarted(false); + } + int delay = 0; int counter = 0; mIsMenuOpening = false; @@ -726,8 +747,8 @@ public void run() { public void run() { mMenuOpened = false; - if (mToggleListener != null) { - mToggleListener.onMenuToggle(false); + if (mToggleFinishedListener != null) { + mToggleFinishedListener.onMenuToggleFinished(false); } } }, ++counter * mAnimationDelayPerItem); @@ -759,24 +780,24 @@ public void setIconAnimationCloseInterpolator(Interpolator closeInterpolator) { */ public void setAnimated(boolean animated) { mIsAnimated = animated; - mOpenAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0); - mCloseAnimatorSet.setDuration(animated ? ANIMATION_DURATION : 0); + mOpenAnimatorSet.setDuration(animated ? TOTAL_ANIMATION_DURATION : 0); + mCloseAnimatorSet.setDuration(animated ? TOTAL_ANIMATION_DURATION : 0); } public boolean isAnimated() { return mIsAnimated; } - public void setAnimationDelayPerItem(int animationDelayPerItem) { - mAnimationDelayPerItem = animationDelayPerItem; - } - public int getAnimationDelayPerItem() { return mAnimationDelayPerItem; } - public void setOnMenuToggleListener(OnMenuToggleListener listener) { - mToggleListener = listener; + public void setOnMenuToggleStartedListener(OnMenuToggleStartedListener listener) { + mToggleStartedListener = listener; + } + + public void setOnMenuToggleFinishedListener(OnMenuToggleFinishedListener listener) { + mToggleFinishedListener = listener; } public void setIconAnimated(boolean animated) { @@ -912,6 +933,9 @@ public void toggleMenuButton(boolean animate) { } } + // NJA: Note on setClosedOnTouchOutside(): this caused a weird flicker in our + // FAM-with-overflow. A better way to get the same effect is to make the scrim's onClick() + // handler (which we'll presumably keep using) close them. public void setClosedOnTouchOutside(boolean close) { mIsSetClosedOnTouchOutside = close; } @@ -958,16 +982,27 @@ public int getMenuButtonColorRipple() { return mMenuColorRipple; } + // Netscout addition: enforce delay-per-item to be total delay divided by # of buttons + private void updateAnimationDelay() { + // NJA: hacking the per-item animation to delay to be a little quicker so we have a little + // buffer period before post-animation stuff happens (which is in onAnimationEnd() in our + // FAM-with-overflow) code) + if (mButtonsCount > 0) mAnimationDelayPerItem = (90 * TOTAL_ANIMATION_DURATION / 100)/mButtonsCount; + else mAnimationDelayPerItem = DEFAULT_ANIMATION_DELAY_PER_ITEM; + } + public void addMenuButton(FloatingActionButton fab) { addView(fab, mButtonsCount - 2); mButtonsCount++; addLabel(fab); + updateAnimationDelay(); } public void removeMenuButton(FloatingActionButton fab) { removeView(fab.getLabelView()); removeView(fab); mButtonsCount--; + updateAnimationDelay(); } public void addMenuButton(FloatingActionButton fab, int index) { @@ -981,11 +1016,12 @@ public void addMenuButton(FloatingActionButton fab, int index) { addView(fab, index); mButtonsCount++; addLabel(fab); + updateAnimationDelay(); } public void removeAllMenuButtons() { close(true); - + List viewsToRemove = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); @@ -1013,4 +1049,24 @@ public void setOnMenuButtonClickListener(OnClickListener clickListener) { public void setOnMenuButtonLongClickListener(OnLongClickListener longClickListener) { mMenuButton.setOnLongClickListener(longClickListener); } + + // Netscout addition + public void setCloseAnimationListener(Animator.AnimatorListener listener) { + mCloseAnimatorSet.addListener(listener); + } + + // Netscout addition + public void setOpenAnimationListener(Animator.AnimatorListener listener) { + mOpenAnimatorSet.addListener(listener); + } + + // Netscout addition + public String getTag() { + return tag; + } + + // Netscout addition + public void setTag(String tag1) { + this.tag = tag; + } } diff --git a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java index af0a82c..47dac9f 100644 --- a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java +++ b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java @@ -111,9 +111,9 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { menus.add(menuBlue); menus.add(menuLabelsRight); - menuYellow.setOnMenuToggleListener(new FloatingActionMenu.OnMenuToggleListener() { + menuYellow.setOnMenuToggleFinishedListener(new FloatingActionMenu.OnMenuToggleFinishedListener() { @Override - public void onMenuToggle(boolean opened) { + public void onMenuToggleFinished(boolean opened) { String text; if (opened) { text = "Menu opened"; From ef5987dc952e3b58ac984126ca5c896d8ce274b7 Mon Sep 17 00:00:00 2001 From: narcher Date: Wed, 5 Jul 2017 16:10:41 -0600 Subject: [PATCH 02/10] Bump version name to 1.6.4-mod2 --- gradle.properties | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gradle.properties b/gradle.properties index 4838bfd..ccfa213 100755 --- a/gradle.properties +++ b/gradle.properties @@ -17,8 +17,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=1.6.4-mod1 -VERSION_CODE=1060401 +VERSION_NAME=1.6.4-mod2 +VERSION_CODE=1060402 GROUP=com.github.clans POM_DESCRIPTION=Floating Action Button implementation for Android From 581f251538ee92d39898d1160842eb7b668665dc Mon Sep 17 00:00:00 2001 From: narcher Date: Wed, 12 Jul 2017 17:48:40 -0600 Subject: [PATCH 03/10] Add setter for custom menu button icon --- .../com/github/clans/fab/FloatingActionMenu.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 593db09..d30fc78 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -80,7 +80,7 @@ public class FloatingActionMenu extends ViewGroup { private int mMenuColorNormal; private int mMenuColorPressed; private int mMenuColorRipple; - private Drawable mIcon; + private Drawable mIcon; // Netscout change: can now be set at runtime private int mAnimationDelayPerItem = DEFAULT_ANIMATION_DELAY_PER_ITEM; // Netscout addition: default value private Interpolator mOpenInterpolator; private Interpolator mCloseInterpolator; @@ -1069,4 +1069,15 @@ public String getTag() { public void setTag(String tag1) { this.tag = tag; } + + // Netscout addition + public Drawable getIcon() { + return mIcon; + } + + // Netscout addition + public void setIcon(Drawable icon) { + mIcon = icon; + mImageToggle.setImageDrawable(mIcon); + } } From 81992525acb93c6c676cc6e3a1a237c503ffe8a9 Mon Sep 17 00:00:00 2001 From: narcher Date: Fri, 14 Jul 2017 14:18:59 -0600 Subject: [PATCH 04/10] Add a separate close button to FAM, initialized to alpha=0, i.e. fully transparent. As the menu opens, animate the transparency of the open button from opaque to transparent, and the transparency of the close button the other way. Keep the rotation animation for both open & close buttons. --- library/build.gradle | 2 +- .../github/clans/fab/FloatingActionMenu.java | 153 +++++++++++++----- library/src/main/res/values/attrs.xml | 3 +- sample/build.gradle | 2 +- .../clans/fab/sample/MenusFragment.java | 2 +- sample/src/main/res/layout/menus_fragment.xml | 3 +- 6 files changed, 123 insertions(+), 42 deletions(-) diff --git a/library/build.gradle b/library/build.gradle index 5493a7b..89e962f 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion "23.0.3" defaultConfig { - minSdkVersion 14 + minSdkVersion 16 targetSdkVersion 23 versionCode Integer.parseInt(project.VERSION_CODE) versionName project.VERSION_NAME diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index d30fc78..1524e90 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -23,6 +23,7 @@ import android.view.animation.AnimationUtils; import android.view.animation.AnticipateInterpolator; import android.view.animation.Interpolator; +import android.view.animation.LinearInterpolator; import android.view.animation.OvershootInterpolator; import android.widget.ImageView; @@ -80,7 +81,8 @@ public class FloatingActionMenu extends ViewGroup { private int mMenuColorNormal; private int mMenuColorPressed; private int mMenuColorRipple; - private Drawable mIcon; // Netscout change: can now be set at runtime + private Drawable mOpenIcon; // Netscout change: can now be set at runtime, and open & close icons replace single (rotating) toggle icon + private Drawable mCloseIcon; // Netscout change: use this instead of the rotated mIcon. private int mAnimationDelayPerItem = DEFAULT_ANIMATION_DELAY_PER_ITEM; // Netscout addition: default value private Interpolator mOpenInterpolator; private Interpolator mCloseInterpolator; @@ -92,7 +94,8 @@ public class FloatingActionMenu extends ViewGroup { private int mLabelsStyle; private Typeface mCustomTypefaceFromFont; private boolean mIconAnimated = true; - private ImageView mImageToggle; + private ImageView mImageOpenButton; // Netscout: changed from mImageToggle + private ImageView mImageCloseButton; // Netscout: added private Animation mMenuButtonShowAnimation; private Animation mMenuButtonHideAnimation; private Animation mImageToggleShowAnimation; @@ -167,9 +170,13 @@ private void init(Context context, AttributeSet attrs) { mMenuColorNormal = attr.getColor(R.styleable.FloatingActionMenu_menu_colorNormal, 0xFFDA4336); mMenuColorPressed = attr.getColor(R.styleable.FloatingActionMenu_menu_colorPressed, 0xFFE75043); mMenuColorRipple = attr.getColor(R.styleable.FloatingActionMenu_menu_colorRipple, 0x99FFFFFF); - mIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_icon); - if (mIcon == null) { - mIcon = getResources().getDrawable(R.drawable.fab_add); + mOpenIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_open_icon); + if (mOpenIcon == null) { + mOpenIcon = getResources().getDrawable(R.drawable.fab_add); + } + mCloseIcon = attr.getDrawable(R.styleable.FloatingActionMenu_menu_close_icon); + if (mCloseIcon == null) { + mCloseIcon = getResources().getDrawable(R.drawable.fab_add); } mLabelsSingleLine = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_singleLine, false); mLabelsEllipsize = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_ellipsize, 0); @@ -197,8 +204,8 @@ private void init(Context context, AttributeSet attrs) { initPadding(padding); } - mOpenInterpolator = new OvershootInterpolator(); - mCloseInterpolator = new AnticipateInterpolator(); + mOpenInterpolator = new LinearInterpolator(); + mCloseInterpolator = new LinearInterpolator(); mLabelsContext = new ContextThemeWrapper(getContext(), mLabelsStyle); initBackgroundDimAnimation(); @@ -271,11 +278,18 @@ private void createMenuButton() { mMenuButton.updateBackground(); mMenuButton.setLabelText(mMenuLabelText); - mImageToggle = new ImageView(getContext()); - mImageToggle.setImageDrawable(mIcon); + mImageOpenButton = new ImageView(getContext()); + mImageOpenButton.setImageDrawable(mOpenIcon); + + mImageCloseButton = new ImageView(getContext()); + mImageCloseButton.setImageDrawable(mCloseIcon); addView(mMenuButton, super.generateDefaultLayoutParams()); - addView(mImageToggle); + + addView(mImageOpenButton); + addView(mImageCloseButton); + mImageCloseButton.bringToFront(); + mImageCloseButton.setImageAlpha(0); // We will fade this in using an animation createDefaultIconAnimation(); } @@ -291,22 +305,64 @@ private void createDefaultIconAnimation() { expandAngle = mLabelsPosition == LABELS_POSITION_LEFT ? OPENED_PLUS_ROTATION_RIGHT : OPENED_PLUS_ROTATION_LEFT; } - ObjectAnimator collapseAnimator = ObjectAnimator.ofFloat( - mImageToggle, + ObjectAnimator collapseCloseButtonRotationAnimator = ObjectAnimator.ofFloat( + mImageCloseButton, + "rotation", + collapseAngle, + CLOSED_PLUS_ROTATION + ); + + ObjectAnimator collapseOpenButtonRotationAnimator = ObjectAnimator.ofFloat( + mImageOpenButton, "rotation", collapseAngle, CLOSED_PLUS_ROTATION ); - ObjectAnimator expandAnimator = ObjectAnimator.ofFloat( - mImageToggle, + ObjectAnimator collapseCloseButtonAlphaAnimator = ObjectAnimator.ofInt( + mImageCloseButton, + "imageAlpha", + 255, + 0 + ); + + ObjectAnimator collapseOpenButtonAlphaAnimator = ObjectAnimator.ofInt( + mImageOpenButton, + "imageAlpha", + 0, + 255 + ); + + ObjectAnimator expandCloseButtonAlphaAnimator = ObjectAnimator.ofInt( + mImageCloseButton, + "imageAlpha", + 0, + 255 + ); + + ObjectAnimator expandOpenButtonAlphaAnimator = ObjectAnimator.ofInt( + mImageOpenButton, + "imageAlpha", + 255, + 0 + ); + + ObjectAnimator expandOpenButtonRotationAnimator = ObjectAnimator.ofFloat( + mImageOpenButton, + "rotation", + CLOSED_PLUS_ROTATION, + expandAngle + ); + + ObjectAnimator expandCloseButtonRotationAnimator = ObjectAnimator.ofFloat( + mImageCloseButton, "rotation", CLOSED_PLUS_ROTATION, expandAngle ); - mOpenAnimatorSet.play(expandAnimator); - mCloseAnimatorSet.play(collapseAnimator); + mOpenAnimatorSet.playTogether(expandCloseButtonRotationAnimator, expandOpenButtonRotationAnimator, expandCloseButtonAlphaAnimator, expandOpenButtonAlphaAnimator ); + mCloseAnimatorSet.playTogether(collapseCloseButtonRotationAnimator, collapseOpenButtonRotationAnimator, collapseCloseButtonAlphaAnimator, collapseOpenButtonAlphaAnimator ); mOpenAnimatorSet.setInterpolator(mOpenInterpolator); mCloseAnimatorSet.setInterpolator(mCloseInterpolator); @@ -322,12 +378,14 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { mMaxButtonWidth = 0; int maxLabelWidth = 0; - measureChildWithMargins(mImageToggle, widthMeasureSpec, 0, heightMeasureSpec, 0); + measureChildWithMargins(mImageOpenButton, widthMeasureSpec, 0, heightMeasureSpec, 0); + mImageCloseButton.setLayoutParams(mImageOpenButton.getLayoutParams()); + // measureChildWithMargins(mImageCloseButton, widthMeasureSpec, 0, heightMeasureSpec, 0);// crashes because leftMargin in layout params is null.... why? for (int i = 0; i < mButtonsCount; i++) { View child = getChildAt(i); - if (child.getVisibility() == GONE || child == mImageToggle) continue; + if (child.getVisibility() == GONE || child == mImageOpenButton || child == mImageCloseButton) continue; measureChildWithMargins(child, widthMeasureSpec, 0, heightMeasureSpec, 0); mMaxButtonWidth = Math.max(mMaxButtonWidth, child.getMeasuredWidth()); @@ -337,7 +395,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int usedWidth = 0; View child = getChildAt(i); - if (child.getVisibility() == GONE || child == mImageToggle) continue; + if (child.getVisibility() == GONE || child == mImageOpenButton || child == mImageCloseButton) continue; usedWidth += child.getMeasuredWidth(); height += child.getMeasuredHeight(); @@ -383,11 +441,14 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { mMenuButton.layout(menuButtonLeft, menuButtonTop, menuButtonLeft + mMenuButton.getMeasuredWidth(), menuButtonTop + mMenuButton.getMeasuredHeight()); - int imageLeft = buttonsHorizontalCenter - mImageToggle.getMeasuredWidth() / 2; - int imageTop = menuButtonTop + mMenuButton.getMeasuredHeight() / 2 - mImageToggle.getMeasuredHeight() / 2; + int imageLeft = buttonsHorizontalCenter - mImageOpenButton.getMeasuredWidth() / 2; + int imageTop = menuButtonTop + mMenuButton.getMeasuredHeight() / 2 - mImageOpenButton.getMeasuredHeight() / 2; - mImageToggle.layout(imageLeft, imageTop, imageLeft + mImageToggle.getMeasuredWidth(), - imageTop + mImageToggle.getMeasuredHeight()); + mImageOpenButton.layout(imageLeft, imageTop, imageLeft + mImageOpenButton.getMeasuredWidth(), + imageTop + mImageOpenButton.getMeasuredHeight()); + + mImageCloseButton.layout(imageLeft, imageTop, imageLeft + mImageOpenButton.getMeasuredWidth(), + imageTop + mImageOpenButton.getMeasuredHeight()); int nextY = openUp ? menuButtonTop + mMenuButton.getMeasuredHeight() + mButtonSpacing @@ -396,8 +457,9 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) { for (int i = mButtonsCount - 1; i >= 0; i--) { View child = getChildAt(i); - if (child == mImageToggle) continue; + if (child == mImageCloseButton || child == mImageOpenButton) continue; + if (!(child instanceof FloatingActionButton)) continue; FloatingActionButton fab = (FloatingActionButton) child; if (fab.getVisibility() == GONE) continue; @@ -457,7 +519,8 @@ private int adjustForOvershoot(int dimension) { protected void onFinishInflate() { super.onFinishInflate(); bringChildToFront(mMenuButton); - bringChildToFront(mImageToggle); + bringChildToFront(mImageOpenButton); + bringChildToFront(mImageCloseButton); mButtonsCount = getChildCount(); createLabels(); } @@ -465,7 +528,7 @@ protected void onFinishInflate() { private void createLabels() { for (int i = 0; i < mButtonsCount; i++) { - if (getChildAt(i) == mImageToggle) continue; + if (getChildAt(i) == mImageCloseButton || getChildAt(i) == mImageOpenButton) continue; final FloatingActionButton fab = (FloatingActionButton) getChildAt(i); @@ -583,9 +646,11 @@ private void hideMenuButtonWithImage(boolean animate) { if (!isMenuButtonHidden()) { mMenuButton.hide(animate); if (animate) { - mImageToggle.startAnimation(mImageToggleHideAnimation); + mImageCloseButton.startAnimation(mImageToggleHideAnimation); + mImageOpenButton.startAnimation(mImageToggleHideAnimation); } - mImageToggle.setVisibility(INVISIBLE); + mImageCloseButton.setVisibility(INVISIBLE); + mImageOpenButton.setVisibility(INVISIBLE); mIsMenuButtonAnimationRunning = false; } } @@ -594,9 +659,11 @@ private void showMenuButtonWithImage(boolean animate) { if (isMenuButtonHidden()) { mMenuButton.show(animate); if (animate) { - mImageToggle.startAnimation(mImageToggleShowAnimation); + mImageCloseButton.startAnimation(mImageToggleShowAnimation); + mImageOpenButton.startAnimation(mImageToggleShowAnimation); } - mImageToggle.setVisibility(VISIBLE); + mImageCloseButton.setVisibility(VISIBLE); + mImageOpenButton.setVisibility(VISIBLE); } } @@ -808,8 +875,9 @@ public boolean isIconAnimated() { return mIconAnimated; } + // NJA: This is probably broken with the latest animation changes public ImageView getMenuIconView() { - return mImageToggle; + return mImageOpenButton; } public void setIconToggleAnimatorSet(AnimatorSet toggleAnimatorSet) { @@ -1025,7 +1093,7 @@ public void removeAllMenuButtons() { List viewsToRemove = new ArrayList<>(); for (int i = 0; i < getChildCount(); i++) { View v = getChildAt(i); - if (v != mMenuButton && v != mImageToggle && v instanceof FloatingActionButton) { + if (v != mMenuButton && v != mImageCloseButton && v != mImageOpenButton && v instanceof FloatingActionButton) { viewsToRemove.add((FloatingActionButton) v); } } @@ -1071,13 +1139,24 @@ public void setTag(String tag1) { } // Netscout addition - public Drawable getIcon() { - return mIcon; + public Drawable getOpenIcon() { + return mOpenIcon; + } + + // Netscout addition + public Drawable getCloseIcon() { + return mCloseIcon; + } + + // Netscout addition + public void setOpenIcon(Drawable icon) { + mOpenIcon = icon; + mImageOpenButton.setImageDrawable(mOpenIcon); } // Netscout addition - public void setIcon(Drawable icon) { - mIcon = icon; - mImageToggle.setImageDrawable(mIcon); + public void setCloseIcon(Drawable icon) { + mCloseIcon = icon; + mImageCloseButton.setImageDrawable(mCloseIcon); } } diff --git a/library/src/main/res/values/attrs.xml b/library/src/main/res/values/attrs.xml index a88bc79..3fa15da 100755 --- a/library/src/main/res/values/attrs.xml +++ b/library/src/main/res/values/attrs.xml @@ -49,7 +49,8 @@ - + + diff --git a/sample/build.gradle b/sample/build.gradle index 0ed7dcc..2a0a200 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.github.fab.sample" - minSdkVersion 14 + minSdkVersion 16 targetSdkVersion 23 versionCode Integer.parseInt(project.VERSION_CODE) versionName project.VERSION_NAME diff --git a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java index 47dac9f..acaf645 100644 --- a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java +++ b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java @@ -157,7 +157,7 @@ public void onClick(View v) { } }); - createCustomAnimation(); + // createCustomAnimation(); } private void createCustomAnimation() { diff --git a/sample/src/main/res/layout/menus_fragment.xml b/sample/src/main/res/layout/menus_fragment.xml index ee76f6a..40e10b4 100644 --- a/sample/src/main/res/layout/menus_fragment.xml +++ b/sample/src/main/res/layout/menus_fragment.xml @@ -85,7 +85,8 @@ android:layout_marginBottom="10dp" android:layout_marginLeft="10dp" android:layout_marginTop="10dp" - fab:menu_icon="@drawable/ic_star" + fab:menu_open_icon="@drawable/ic_star" + fab:menu_close_icon="@drawable/ic_close" fab:menu_animationDelayPerItem="0" fab:menu_colorNormal="#43A047" fab:menu_colorPressed="#2E7D32" From b2289a678aca487cd19f2bab46bf9e753fef446c Mon Sep 17 00:00:00 2001 From: narcher Date: Fri, 14 Jul 2017 14:23:33 -0600 Subject: [PATCH 05/10] Cleanup - comments, and revert FloatingActionMenu.measure() to original state --- .../main/java/com/github/clans/fab/FloatingActionMenu.java | 6 ++++-- .../java/com/github/clans/fab/sample/MenusFragment.java | 3 ++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 1524e90..0229e68 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -294,6 +294,9 @@ private void createMenuButton() { createDefaultIconAnimation(); } + // Keep the rotation animation, but add to it a transparency transition where the open button + // fades to transparent and the close button fades to opaque when it opens (and the reverse when + // it closes). private void createDefaultIconAnimation() { float collapseAngle; float expandAngle; @@ -379,8 +382,7 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int maxLabelWidth = 0; measureChildWithMargins(mImageOpenButton, widthMeasureSpec, 0, heightMeasureSpec, 0); - mImageCloseButton.setLayoutParams(mImageOpenButton.getLayoutParams()); - // measureChildWithMargins(mImageCloseButton, widthMeasureSpec, 0, heightMeasureSpec, 0);// crashes because leftMargin in layout params is null.... why? + measureChildWithMargins(mImageCloseButton, widthMeasureSpec, 0, heightMeasureSpec, 0); for (int i = 0; i < mButtonsCount; i++) { View child = getChildAt(i); diff --git a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java index acaf645..8a01928 100644 --- a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java +++ b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java @@ -157,7 +157,8 @@ public void onClick(View v) { } }); - // createCustomAnimation(); + // createCustomAnimation(); // Netscout change: disable this so we can tested with the + // green menu. } private void createCustomAnimation() { From 3b3e4b2058d9e1af16a9346421fe52dc608f3761 Mon Sep 17 00:00:00 2001 From: narcher Date: Fri, 14 Jul 2017 18:14:23 -0600 Subject: [PATCH 06/10] Add test FAM to emulate appearance & settings of Andromeda FAM. This made it possible to reproduce a button spacing problem. That problem was fixed by correcting the mButtonsCount variable, offset by 1 to account for the new close button. Also updated targetSdkVersion to 23 to better match Andromeda project where we're using this. --- library/build.gradle | 2 +- .../github/clans/fab/FloatingActionMenu.java | 2 +- .../ic_common_more_horiz_white_36dp.png | Bin 0 -> 229 bytes .../ic_common_settings_white_36dp.png | Bin 0 -> 908 bytes library/src/main/res/values/ids.xml | 5 ++ sample/build.gradle | 2 +- .../clans/fab/sample/MenusFragment.java | 57 +++++++++++++++++- sample/src/main/res/layout/menus_fragment.xml | 16 +++++ sample/src/main/res/values/colors.xml | 2 + sample/src/main/res/values/strings.xml | 4 ++ sample/src/main/res/values/styles.xml | 19 ++++++ 11 files changed, 105 insertions(+), 4 deletions(-) create mode 100644 library/src/main/res/drawable-hdpi/ic_common_more_horiz_white_36dp.png create mode 100644 library/src/main/res/drawable-hdpi/ic_common_settings_white_36dp.png diff --git a/library/build.gradle b/library/build.gradle index 89e962f..9695295 100755 --- a/library/build.gradle +++ b/library/build.gradle @@ -5,7 +5,7 @@ android { buildToolsVersion "23.0.3" defaultConfig { - minSdkVersion 16 + minSdkVersion 23 targetSdkVersion 23 versionCode Integer.parseInt(project.VERSION_CODE) versionName project.VERSION_NAME diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 0229e68..fcb67b9 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -523,7 +523,7 @@ protected void onFinishInflate() { bringChildToFront(mMenuButton); bringChildToFront(mImageOpenButton); bringChildToFront(mImageCloseButton); - mButtonsCount = getChildCount(); + mButtonsCount = getChildCount() - 1; // Netscout change: adjusted for extra (i.e. close) button! createLabels(); } diff --git a/library/src/main/res/drawable-hdpi/ic_common_more_horiz_white_36dp.png b/library/src/main/res/drawable-hdpi/ic_common_more_horiz_white_36dp.png new file mode 100644 index 0000000000000000000000000000000000000000..09aa9d58e9665a00e69030742ab193868532a697 GIT binary patch literal 229 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpTCwj^(N7a$D;Kb?2i11Zh|kH}&m z?E%JaC$sH9f@KAc=|CE+pW)oQo^T+iz|+MsB;(%OD~?r-Gi0~c7qIJ|YRr9L zmKh=uxkTc7gR*?h{Rh@OlTsc3S~Xk=LPoAbaOt@vL*I6LOJCajuUAEYorJnQ*< z5f5?ZptpZ6{@9h6T+XG_S|0!WbjkiBzbDk~4+QG4UTUy1cxSvTy!*Oa4;ySNihV6 z+C*xLAc&wvkcOZl1vMwN!9deUe+}=v(8s&)o^$WH?`gh2yyczm`~Khme&?Qh?)k1% zM;&!!36n)o;GCp8l1|2$?nruWj9IJog>V%%hC9Zx$e|%4ZI?5$t+}v{jBK3|{2l{N zOWN>sYcj_C44Fq36}wm^pQ;N>GPQzFM<-!G3or@X2U;uGotM;`Adg<_8x^~cCLSx)K+U1 z5m=UV$r!U$Zm?3t1`n|)+1v)B2Fq3qXj7qDxmsr*gDn-Rwp=<8Rk4vkqShrnmDDZi ziv4xl|JDP<&q;dVYz=$}uxvj8nk#TLTbs0a>m#fkm`y>}@4?ldf@cSh;ba(U)sKX&ym@Fup!q-m~tdbwd6Z4^`)4?_W?~|OEs5(tcYrDspjz6 zQt=;bf=@*7E=Wpylirim1H6#*M$)4Fzg^M|Nj;LzrsR+!HV((@MbjFN);enkjFuB6 z9mm5Q>o8R7>?>d>N|bb54@|A&fTX<$lLZwHQ@#dF`iqUZ5HY?dX`qrQXK=77@f(;1 zZgQ|G@rZOyiC@4&;FOKoU^%8OXAxnV5|*UcMj9rjjRd?(AnGOYZKPpBw~;(ALOy}8 ze0t`C$l^uwTa|n&qTXD0g-vkP!(}zJs7!=e_)M+f(=bb6pE9y_MwTCm-IWw~Ot2y8 i*^&83td2VB_=mrPq8y`W9cB#x0000 + + + + + \ No newline at end of file diff --git a/sample/build.gradle b/sample/build.gradle index 2a0a200..a16727c 100755 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -6,7 +6,7 @@ android { defaultConfig { applicationId "com.github.fab.sample" - minSdkVersion 16 + minSdkVersion 23 targetSdkVersion 23 versionCode Integer.parseInt(project.VERSION_CODE) versionName project.VERSION_NAME diff --git a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java index 8a01928..7da4b37 100644 --- a/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java +++ b/sample/src/main/java/com/github/clans/fab/sample/MenusFragment.java @@ -24,12 +24,36 @@ import java.util.ArrayList; import java.util.List; +import static android.view.ViewGroup.LayoutParams.WRAP_CONTENT; + public class MenusFragment extends Fragment { + public class FabMenuItem { + public int textId = -1; + public int iconId = -1; + @SuppressWarnings("WeakerAccess") public int itemId = -1; + + @SuppressWarnings("WeakerAccess") public FabMenuItem(int itemId, int textId, int iconId) { + this.itemId = itemId; + this.textId = textId; + this.iconId = iconId; + } + }; + + public FabMenuItem FAB_MENU_ITEM_ADD_TO_AUTOTEST = new FabMenuItem(R.id.fabMenuItem_test_common_addToAutoTest, + R.string.common_test_Add_to_AutoTest, R.drawable.ic_common_settings_white_36dp); + + public FabMenuItem FAB_MENU_ITEM_BROWSE = new FabMenuItem(R.id.fabMenuItem_test_common_browse, + R.string.common_test_Browse, R.drawable.ic_common_settings_white_36dp); + + public FabMenuItem FAB_MENU_ITEM_MORE = new FabMenuItem(R.id.fabMenuItem_test_menu_more, + R.string.common_test_More, R.drawable.ic_common_more_horiz_white_36dp); + private FloatingActionMenu menuRed; private FloatingActionMenu menuYellow; private FloatingActionMenu menuGreen; private FloatingActionMenu menuBlue; + private FloatingActionMenu menuFabPrimaryMenu; private FloatingActionMenu menuDown; private FloatingActionMenu menuLabelsRight; @@ -48,6 +72,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa return inflater.inflate(R.layout.menus_fragment, container, false); } + private void styleFab(FloatingActionButton fab) { + fab.setColorNormal(getContext().getColor(R.color.fab_color)); + fab.setColorPressed(getContext().getColor(R.color.fab_color)); + fab.setButtonSize(FloatingActionButton.SIZE_MINI); + } + @Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); @@ -56,6 +86,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { menuYellow = (FloatingActionMenu) view.findViewById(R.id.menu_yellow); menuGreen = (FloatingActionMenu) view.findViewById(R.id.menu_green); menuBlue = (FloatingActionMenu) view.findViewById(R.id.menu_blue); + menuFabPrimaryMenu = (FloatingActionMenu) view.findViewById(R.id.fab_primary_menu); menuDown = (FloatingActionMenu) view.findViewById(R.id.menu_down); menuLabelsRight = (FloatingActionMenu) view.findViewById(R.id.menu_labels_right); @@ -93,6 +124,29 @@ public void onClick(View v) { menuYellow.hideMenuButton(false); menuGreen.hideMenuButton(false); menuBlue.hideMenuButton(false); + + // Initialize stand-in Andromeda FAM: + List primaryFabContents = new ArrayList<>(); + primaryFabContents.add(FAB_MENU_ITEM_ADD_TO_AUTOTEST); + primaryFabContents.add(FAB_MENU_ITEM_BROWSE); + primaryFabContents.add(FAB_MENU_ITEM_MORE); + + for (FabMenuItem fabMenuItem : primaryFabContents) { + FloatingActionButton fab = new FloatingActionButton(getContext()); + fab.setImageDrawable(getContext().getDrawable(fabMenuItem.iconId)); + fab.setLabelText(getContext().getString(fabMenuItem.textId)); + ViewGroup.LayoutParams lp = new ViewGroup.LayoutParams(WRAP_CONTENT, WRAP_CONTENT); + + fab.setLayoutParams(lp); + fab.setId(fabMenuItem.itemId); + styleFab(fab); + menuFabPrimaryMenu.addMenuButton(fab); + } + + menuFabPrimaryMenu.setOpenIcon(getContext().getDrawable(R.drawable.ic_star)); + + menuFabPrimaryMenu.setVisibility(View.VISIBLE); + menuLabelsRight.hideMenuButton(false); fabEdit = (FloatingActionButton) view.findViewById(R.id.fab_edit); @@ -109,6 +163,7 @@ public void onActivityCreated(@Nullable Bundle savedInstanceState) { menus.add(menuYellow); menus.add(menuGreen); menus.add(menuBlue); + menus.add(menuFabPrimaryMenu); menus.add(menuLabelsRight); menuYellow.setOnMenuToggleFinishedListener(new FloatingActionMenu.OnMenuToggleFinishedListener() { @@ -157,7 +212,7 @@ public void onClick(View v) { } }); - // createCustomAnimation(); // Netscout change: disable this so we can tested with the + // createCustomAnimation(); // Netscout change: disable this so we can test with the // green menu. } diff --git a/sample/src/main/res/layout/menus_fragment.xml b/sample/src/main/res/layout/menus_fragment.xml index 40e10b4..5a6fc8d 100644 --- a/sample/src/main/res/layout/menus_fragment.xml +++ b/sample/src/main/res/layout/menus_fragment.xml @@ -155,6 +155,22 @@ + + + + + #99FFFFFF #000 + #994878 + \ No newline at end of file diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml index cd830b4..1461f32 100755 --- a/sample/src/main/res/values/strings.xml +++ b/sample/src/main/res/values/strings.xml @@ -6,4 +6,8 @@ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis sed ultricies risus. Integer nisi orci, lacinia sit amet mi in, mollis scelerisque purus. Nunc risus ligula, maximus eu orci a, facilisis dictum velit. Proin nec laoreet magna. Nulla ut sagittis lorem. Morbi id enim fermentum, semper diam et, tempus leo. Aliquam vel congue orci. Suspendisse potenti. Curabitur finibus diam augue, vel bibendum sapien ultrices non. Navigation open Navigation close + Add to AutoTest + Browse + More + diff --git a/sample/src/main/res/values/styles.xml b/sample/src/main/res/values/styles.xml index 4619a1f..0381fdf 100755 --- a/sample/src/main/res/values/styles.xml +++ b/sample/src/main/res/values/styles.xml @@ -49,4 +49,23 @@ sans-serif-light + + + + + From e7145440bc10b38e58b84f8b16d82d9186e114db Mon Sep 17 00:00:00 2001 From: narcher Date: Fri, 14 Jul 2017 18:43:41 -0600 Subject: [PATCH 07/10] Add getter for open button ImageView, so we can close it when transitioning between primary & overflow FAMs --- .../main/java/com/github/clans/fab/FloatingActionMenu.java | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index fcb67b9..7278404 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -1161,4 +1161,8 @@ public void setCloseIcon(Drawable icon) { mCloseIcon = icon; mImageCloseButton.setImageDrawable(mCloseIcon); } + + public ImageView getOpenButton() { + return mImageOpenButton; + } } From 649c5746e8552cfe4e3cd03cdc538a08ee94ba70 Mon Sep 17 00:00:00 2001 From: narcher Date: Tue, 18 Jul 2017 20:15:06 -0600 Subject: [PATCH 08/10] Call Fab click listener from label up-action. --- library/src/main/java/com/github/clans/fab/Label.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/library/src/main/java/com/github/clans/fab/Label.java b/library/src/main/java/com/github/clans/fab/Label.java index 7d689cb..6bdb0b6 100755 --- a/library/src/main/java/com/github/clans/fab/Label.java +++ b/library/src/main/java/com/github/clans/fab/Label.java @@ -301,6 +301,9 @@ public boolean onTouchEvent(MotionEvent event) { } mGestureDetector.onTouchEvent(event); + + mFab.getOnClickListener().onClick(this); + return super.onTouchEvent(event); } From a54658f2f7f25028cc50553c3d704679d240f138 Mon Sep 17 00:00:00 2001 From: narcher Date: Tue, 18 Jul 2017 20:38:40 -0600 Subject: [PATCH 09/10] Call FAB's onClick() method rather than calling click listener directly- causes the View argument to be the FAB, which maintains the right ID for the FAM to handle it correctly. --- library/src/main/java/com/github/clans/fab/Label.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/src/main/java/com/github/clans/fab/Label.java b/library/src/main/java/com/github/clans/fab/Label.java index 6bdb0b6..16c74e0 100755 --- a/library/src/main/java/com/github/clans/fab/Label.java +++ b/library/src/main/java/com/github/clans/fab/Label.java @@ -302,7 +302,7 @@ public boolean onTouchEvent(MotionEvent event) { mGestureDetector.onTouchEvent(event); - mFab.getOnClickListener().onClick(this); + mFab.callOnClick(); return super.onTouchEvent(event); } From daf1af48a272968a223a52c17addc151b186f594 Mon Sep 17 00:00:00 2001 From: narcher Date: Tue, 18 Jul 2017 22:12:42 -0600 Subject: [PATCH 10/10] Reverted previous changes to Label click/touch event handling. Instead, just set the label's ID to that of the associated button. --- .../main/java/com/github/clans/fab/FloatingActionMenu.java | 1 + library/src/main/java/com/github/clans/fab/Label.java | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java index 7278404..763428b 100755 --- a/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java +++ b/library/src/main/java/com/github/clans/fab/FloatingActionMenu.java @@ -600,6 +600,7 @@ private void addLabel(FloatingActionButton fab) { label.setTypeface(mCustomTypefaceFromFont); } label.setText(text); + label.setId(fab.getId()); label.setOnClickListener(fab.getOnClickListener()); addView(label); diff --git a/library/src/main/java/com/github/clans/fab/Label.java b/library/src/main/java/com/github/clans/fab/Label.java index 16c74e0..ababf7f 100755 --- a/library/src/main/java/com/github/clans/fab/Label.java +++ b/library/src/main/java/com/github/clans/fab/Label.java @@ -19,6 +19,7 @@ import android.graphics.drawable.shapes.RoundRectShape; import android.os.Build; import android.util.AttributeSet; + import android.view.GestureDetector; import android.view.MotionEvent; import android.view.View; @@ -293,7 +294,6 @@ public boolean onTouchEvent(MotionEvent event) { onActionUp(); mFab.onActionUp(); break; - case MotionEvent.ACTION_CANCEL: onActionUp(); mFab.onActionUp(); @@ -302,8 +302,6 @@ public boolean onTouchEvent(MotionEvent event) { mGestureDetector.onTouchEvent(event); - mFab.callOnClick(); - return super.onTouchEvent(event); }