Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.

Commit b0a15b8

Browse files
committed
Merge pull request #137 from KandyzowanaPapaja/dev
Added ColorStateList for Label class
2 parents 48ff7d9 + 4561964 commit b0a15b8

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

library/src/main/java/com/github/clans/fab/FloatingActionMenu.java

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import android.animation.ObjectAnimator;
55
import android.animation.ValueAnimator;
66
import android.content.Context;
7+
import android.content.res.ColorStateList;
78
import android.content.res.TypedArray;
89
import android.graphics.Color;
910
import android.graphics.drawable.Drawable;
@@ -58,7 +59,7 @@ public class FloatingActionMenu extends ViewGroup {
5859
private int mLabelsPaddingRight = Util.dpToPx(getContext(), 8f);
5960
private int mLabelsPaddingBottom = Util.dpToPx(getContext(), 4f);
6061
private int mLabelsPaddingLeft = Util.dpToPx(getContext(), 8f);
61-
private int mLabelsTextColor;
62+
private ColorStateList mLabelsTextColor;
6263
private float mLabelsTextSize;
6364
private int mLabelsCornerRadius = Util.dpToPx(getContext(), 3f);
6465
private boolean mLabelsShowShadow;
@@ -131,7 +132,11 @@ private void init(Context context, AttributeSet attrs) {
131132
mLabelsPaddingRight = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingRight, mLabelsPaddingRight);
132133
mLabelsPaddingBottom = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingBottom, mLabelsPaddingBottom);
133134
mLabelsPaddingLeft = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_paddingLeft, mLabelsPaddingLeft);
134-
mLabelsTextColor = attr.getColor(R.styleable.FloatingActionMenu_menu_labels_textColor, Color.WHITE);
135+
mLabelsTextColor = attr.getColorStateList(R.styleable.FloatingActionMenu_menu_labels_textColor);
136+
// set default value if null same as for textview
137+
if (mLabelsTextColor == null) {
138+
mLabelsTextColor = ColorStateList.valueOf(Color.WHITE);
139+
}
135140
mLabelsTextSize = attr.getDimension(R.styleable.FloatingActionMenu_menu_labels_textSize, getResources().getDimension(R.dimen.labels_text_size));
136141
mLabelsCornerRadius = attr.getDimensionPixelSize(R.styleable.FloatingActionMenu_menu_labels_cornerRadius, mLabelsCornerRadius);
137142
mLabelsShowShadow = attr.getBoolean(R.styleable.FloatingActionMenu_menu_labels_showShadow, true);
@@ -504,6 +509,7 @@ private void addLabel(FloatingActionButton fab) {
504509
}
505510

506511
label.setText(text);
512+
label.setOnClickListener(fab.getOnClickListener());
507513

508514
addView(label);
509515
fab.setTag(R.id.fab_label, label);

library/src/main/java/com/github/clans/fab/Label.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ void onActionDown() {
207207
ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
208208
ripple.setVisible(true, true);
209209
}
210+
setPressed(true);
210211
}
211212

212213
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@@ -224,6 +225,7 @@ void onActionUp() {
224225
ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
225226
ripple.setVisible(true, true);
226227
}
228+
setPressed(false);
227229
}
228230

229231
void setFab(FloatingActionButton fab) {

library/src/main/res/values/attrs.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
<attr name="menu_labels_paddingRight" format="dimension" />
3939
<attr name="menu_labels_paddingBottom" format="dimension" />
4040
<attr name="menu_labels_padding" format="dimension" />
41-
<attr name="menu_labels_textColor" format="color" />
41+
<attr name="menu_labels_textColor" format="reference|color" />
4242
<attr name="menu_labels_textSize" format="dimension" />
4343
<attr name="menu_labels_cornerRadius" format="dimension" />
4444
<attr name="menu_labels_showShadow" format="boolean" />

0 commit comments

Comments
 (0)