From 3910c17b1b123d7bc673ec3eb2d26a6934f1817d Mon Sep 17 00:00:00 2001 From: James Charlesworth Date: Tue, 15 Mar 2016 15:27:09 +0000 Subject: [PATCH] rippleColor attribute, variables and Readme.md entries renamed to "rippleEffectColor" --- README.md | 6 ++-- docs/RippleButton.md | 10 +++---- docs/RippleImageButton.md | 10 +++---- .../ripplebutton/widget/RippleButton.java | 28 +++++++++---------- .../widget/RippleImageButton.java | 19 ++++++------- ripplebutton/src/main/res/values/attrs.xml | 2 +- .../main/res/layout/ripple_button_demo.xml | 2 +- .../res/layout/ripple_image_button_demo.xml | 2 +- 8 files changed, 39 insertions(+), 40 deletions(-) diff --git a/README.md b/README.md index 43d85b0..5fbfd16 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ with xml: android:id="@+id/btn2" android:text="Android button modified in layout" app:buttonColor="@android:color/black" - app:rippleColor="@android:color/white"/> + app:rippleEffectColor="@android:color/white"/> ``` diff --git a/docs/RippleImageButton.md b/docs/RippleImageButton.md index 3ab1d52..a505120 100644 --- a/docs/RippleImageButton.md +++ b/docs/RippleImageButton.md @@ -14,7 +14,7 @@ Inherits from [android.widget.ImageButton](http://developer.android.com/referenc | Attribute | Type | Description | | ------------- | ------------- | ------------- | | app:buttonColor | color | The color of the button. | -| app:rippleColor | color | The color of the ripple effect in v21, in previous versions is the color of the button while pressed. | +| app:rippleEffectColor | color | The color of the ripple effect in v21, in previous versions is the color of the button while pressed. | ###Style | Attribute | Type | Description | @@ -30,8 +30,8 @@ Inherits from [android.widget.ImageButton](http://developer.android.com/referenc | Method | Description | | ------------- | ------------- | | setButtonColor(int color) | The color of the button. | -| setRippleColor(int color) | The color of the ripple effect in v21, in previous versions is the color of the button while pressed. | -| setColors(int buttonColor, int rippleColor) | The color of the button and the ripple effect in v21, in previous versions is the color of the button while pressed. | +| setrippleEffectColor(int color) | The color of the ripple effect in v21, in previous versions is the color of the button while pressed. | +| setColors(int buttonColor, int rippleEffectColor) | The color of the button and the ripple effect in v21, in previous versions is the color of the button while pressed. | ##Examples From java @@ -49,7 +49,7 @@ From java //java int buttonColor = 0xff33b5e5; //holo_blue_light - int rippleColor = 0x80ffffff; //transparent white + int rippleEffectColor = 0x80ffffff; //transparent white final RippleImageButton rib = (RippleImageButton)findViewById(R.id.rippleImageButton); rib.setColors(colors[1], colors[2]); ``` @@ -63,7 +63,7 @@ From xml android:layout_height="wrap_content" android:id="@+id/rippleImageButton" android:text="Click me!" - app:rippleColor="#ff33b5e5" + app:rippleEffectColor="#ff33b5e5" app:buttonColor="#80ffffff" app:/> ``` diff --git a/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleButton.java b/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleButton.java index caf0126..6bd2978 100644 --- a/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleButton.java +++ b/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleButton.java @@ -24,7 +24,7 @@ public RippleButton(Context context) { // TODO get style color; private int buttonColor = 0xffd6d7d7; - private int rippleColor = 0x40000000; + private int rippleEffectColor = 0x40000000; public RippleButton(Context context, AttributeSet attrs) { super(context, attrs); @@ -45,16 +45,16 @@ public RippleButton(Context context, AttributeSet attrs, int defStyleAttr, int d @TargetApi(Build.VERSION_CODES.LOLLIPOP) public void setColors(int buttonColor, int controlHighlightColor) { this.buttonColor = buttonColor; - rippleColor = controlHighlightColor; + rippleEffectColor = controlHighlightColor; setButtonColor(buttonColor); - setRippleColor(controlHighlightColor); + setRippleEffectColor(controlHighlightColor); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public void setRippleColor(final int color) { - rippleColor = color; + public void setRippleEffectColor(final int color) { + rippleEffectColor = color; - if (rippleColor == 0) { + if (rippleEffectColor == 0) { return; } if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { @@ -68,7 +68,7 @@ public void setRippleColor(final int color) { new int[]{0} }, new int[]{ - rippleColor, + rippleEffectColor, buttonColor } ); @@ -115,13 +115,13 @@ private void manageAttibuteSet(AttributeSet attrs) { int[] tAttrs = {android.R.attr.colorControlHighlight, android.R.attr.colorButtonNormal}; TypedArray ta = getContext().getTheme().obtainStyledAttributes(tAttrs); buttonColor = ta.getColor(1, 0); - rippleColor = ta.getColor(0, 0); + rippleEffectColor = ta.getColor(0, 0); ta.recycle(); } else { int[] tAttrs = {R.attr.colorControlHighlight, R.attr.colorButtonNormal}; TypedArray ta = getContext().getTheme().obtainStyledAttributes(s, tAttrs); buttonColor = ta.getColor(1, 0); - rippleColor = ta.getColor(0, 0); + rippleEffectColor = ta.getColor(0, 0); ta.recycle(); } @@ -129,14 +129,14 @@ private void manageAttibuteSet(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RippleButton); int nColor = a.getColor(R.styleable.RippleButton_buttonColor, buttonColor); - int hColor = a.getColor(R.styleable.RippleButton_rippleColor, rippleColor); + int hColor = a.getColor(R.styleable.RippleButton_rippleEffectColor, rippleEffectColor); a.recycle(); buttonColor = nColor; - rippleColor = hColor; + rippleEffectColor = hColor; setButtonColor(nColor); - setRippleColor(hColor); + setRippleEffectColor(hColor); } } @@ -152,9 +152,9 @@ public boolean onTouchEvent(MotionEvent event) { getBackground().clearColorFilter(); } } else { - if (rippleColor != 0) { + if (rippleEffectColor != 0) { setBackground(getResources().getDrawable(R.drawable.btn_default_normal_ripple)); - getBackground().setColorFilter(rippleColor, PorterDuff.Mode.MULTIPLY); + getBackground().setColorFilter(rippleEffectColor, PorterDuff.Mode.MULTIPLY); } } } diff --git a/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleImageButton.java b/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleImageButton.java index 5b78689..b5c2744 100644 --- a/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleImageButton.java +++ b/ripplebutton/src/main/java/com/xgc1986/ripplebutton/widget/RippleImageButton.java @@ -13,7 +13,6 @@ import android.util.AttributeSet; import android.util.Log; import android.view.MotionEvent; -import android.widget.Button; import android.widget.ImageButton; import com.xgc1986.ripplebutton.R; @@ -23,7 +22,7 @@ public class RippleImageButton extends ImageButton { // TODO get style color; private int buttonColor = 0xffd6d7d7; - private int rippleColor = 0x40000000; + private int rippleEffectColor = 0x40000000; public RippleImageButton(Context context) { super(context); @@ -48,12 +47,12 @@ public RippleImageButton(Context context, AttributeSet attrs, int defStyleAttr, @TargetApi(Build.VERSION_CODES.LOLLIPOP) public void setColors(int buttonColor, int controlHighlightColor) { setButtonColor(buttonColor); - setRippleColor(controlHighlightColor); + setRippleEffectColor(controlHighlightColor); } @TargetApi(Build.VERSION_CODES.LOLLIPOP) - public void setRippleColor(final int color) { - rippleColor = color; + public void setRippleEffectColor(final int color) { + rippleEffectColor = color; if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { Drawable drawable = getBackground(); @@ -65,7 +64,7 @@ public void setRippleColor(final int color) { new int[]{android.R.attr.state_pressed} }, new int[]{ - rippleColor + rippleEffectColor } ); @@ -102,10 +101,10 @@ private void manageAttibuteSet(AttributeSet attrs) { TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.RippleButton); int nColor = a.getInt(R.styleable.RippleButton_buttonColor, buttonColor); - int hColor = a.getInt(R.styleable.RippleButton_rippleColor, rippleColor); + int hColor = a.getInt(R.styleable.RippleButton_rippleEffectColor, rippleEffectColor); setButtonColor(nColor); - setRippleColor(hColor); + setRippleEffectColor(hColor); a.recycle(); } @@ -123,9 +122,9 @@ public boolean onTouchEvent(MotionEvent event) { getBackground().clearColorFilter(); } } else { - if (rippleColor != 0) { + if (rippleEffectColor != 0) { setBackground(getResources().getDrawable(R.drawable.btn_default_normal_ripple)); - getBackground().setColorFilter(rippleColor, PorterDuff.Mode.MULTIPLY); + getBackground().setColorFilter(rippleEffectColor, PorterDuff.Mode.MULTIPLY); } } } diff --git a/ripplebutton/src/main/res/values/attrs.xml b/ripplebutton/src/main/res/values/attrs.xml index 83bf35c..0789449 100644 --- a/ripplebutton/src/main/res/values/attrs.xml +++ b/ripplebutton/src/main/res/values/attrs.xml @@ -7,7 +7,7 @@ - + diff --git a/ripplebuttonsample/src/main/res/layout/ripple_button_demo.xml b/ripplebuttonsample/src/main/res/layout/ripple_button_demo.xml index 1a5debe..a2f7e76 100644 --- a/ripplebuttonsample/src/main/res/layout/ripple_button_demo.xml +++ b/ripplebuttonsample/src/main/res/layout/ripple_button_demo.xml @@ -16,7 +16,7 @@ android:id="@+id/btn2" android:text="Click me!" android:textColor="#ff000000" - app:rippleColor="#ffff4444"/> + app:rippleEffectColor="#ffff4444"/> + app:rippleEffectColor="#ffff4444"/>