8
8
import android .util .AttributeSet ;
9
9
import android .util .Log ;
10
10
import android .view .MotionEvent ;
11
- import android .view .View ;
12
11
import android .widget .ImageView ;
13
12
import android .widget .LinearLayout ;
14
13
import android .widget .TextView ;
@@ -33,6 +32,7 @@ public class HoneycombButton extends LinearLayout {
33
32
private float mButtonTextSize ;
34
33
private String mSecondaryButtonText ;
35
34
private Drawable mButtonIcon ;
35
+ private boolean mButtonIconHover ;
36
36
37
37
public HoneycombButton (Context context , @ Nullable AttributeSet attrs ) {
38
38
this (context , attrs , R .style .honeycombButtonTheme );
@@ -44,6 +44,7 @@ public HoneycombButton(Context context, @Nullable AttributeSet attrs, int defSty
44
44
mButtonText = attributes .getString (R .styleable .HoneycombButton_honeycombButtonText );
45
45
mButtonTextSize = attributes .getDimension (R .styleable .HoneycombButton_honeycombButtonTextSize , 0.0f );
46
46
mButtonIcon = attributes .getDrawable (R .styleable .HoneycombButton_honeycombButtonIcon );
47
+ mButtonIconHover = attributes .getBoolean (R .styleable .HoneycombButton_honeycombButtonIconHover , true );
47
48
48
49
String iconIdStr = attributes .getString (R .styleable .HoneycombButton_honeycombButtonIcon );
49
50
int deviceTypeId = DeviceType .getType ();
@@ -123,14 +124,18 @@ public void setOnHoverListener(final OnHoverListener l) {
123
124
switch (motionEvent .getAction ()) {
124
125
case MotionEvent .ACTION_HOVER_ENTER :
125
126
if (mIcon != null && mText != null ) {
126
- mIcon .setColorFilter (new PorterDuffColorFilter (getResources ().getColor (R .color .asphalt , getContext ().getTheme ()), PorterDuff .Mode .MULTIPLY ));
127
+ if (mButtonIconHover ) {
128
+ mIcon .setColorFilter (new PorterDuffColorFilter (getResources ().getColor (R .color .asphalt , getContext ().getTheme ()), PorterDuff .Mode .MULTIPLY ));
129
+ }
127
130
mText .setTextColor (getContext ().getColor (R .color .asphalt ));
128
131
mSecondaryText .setTextColor (getContext ().getColor (R .color .asphalt ));
129
132
}
130
133
break ;
131
134
case MotionEvent .ACTION_HOVER_EXIT :
132
135
if (mIcon != null && mText != null ) {
133
- mIcon .setColorFilter (new PorterDuffColorFilter (getResources ().getColor (R .color .fog , getContext ().getTheme ()), PorterDuff .Mode .MULTIPLY ));
136
+ if (mButtonIconHover ) {
137
+ mIcon .setColorFilter (new PorterDuffColorFilter (getResources ().getColor (R .color .fog , getContext ().getTheme ()), PorterDuff .Mode .MULTIPLY ));
138
+ }
134
139
mText .setTextColor (getContext ().getColor (R .color .fog ));
135
140
mSecondaryText .setTextColor (getContext ().getColor (R .color .fog ));
136
141
}
0 commit comments