From cfff8c6c494c2e866012d2c829a49efbfc560f03 Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 01:52:37 +0200 Subject: [PATCH 1/6] Font icons colors are edited programmatically Editing font icons using setTextColor(int color) --- .../main/java/mehdi/sakout/fancybuttons/FancyButton.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java index ff7c595..1014cd8 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -411,9 +411,11 @@ public void setTextColor(int color){ this.mDefaultTextColor = color; if(mTextView == null) initializeFancyButton(); - else + else { mTextView.setTextColor(color); - + if(mFontIconView != null) + mFontIconView.setTextColor(color); + } } /** From 4e1100c0ade5009824a9c0c82021cef9273e0332 Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 15:16:17 +0200 Subject: [PATCH 2/6] Removing Icon color setting from setTextColor --- .../main/java/mehdi/sakout/fancybuttons/FancyButton.java | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java index 1014cd8..ff7c595 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -411,11 +411,9 @@ public void setTextColor(int color){ this.mDefaultTextColor = color; if(mTextView == null) initializeFancyButton(); - else { + else mTextView.setTextColor(color); - if(mFontIconView != null) - mFontIconView.setTextColor(color); - } + } /** From 98512cf397db71e4c36e93b9151c4994ece34b38 Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 15:20:00 +0200 Subject: [PATCH 3/6] Adding setIconColor --- .../java/mehdi/sakout/fancybuttons/FancyButton.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java index ff7c595..d7a2252 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -416,6 +416,16 @@ public void setTextColor(int color){ } + /** + * Setting the icon's color independent of the text color + * @param color : Color + */ + public void setIconColor(int color){ + if(mFontIconView != null) { + mFontIconView.setTextColor(color); + } + } + /** * Set Background color of the button * @param color : use Color.parse('#code') From 04cd0c225efa96648996c02b977041ea014344d6 Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 16:36:15 +0200 Subject: [PATCH 4/6] Adding iconColor attribute --- fancybuttons_library/src/main/res/values/attrs.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/fancybuttons_library/src/main/res/values/attrs.xml b/fancybuttons_library/src/main/res/values/attrs.xml index b9ee786..7df9489 100644 --- a/fancybuttons_library/src/main/res/values/attrs.xml +++ b/fancybuttons_library/src/main/res/values/attrs.xml @@ -5,6 +5,7 @@ + From 62bec392b97b0dfebcfe75be0d9e81422e427b0d Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 16:43:14 +0200 Subject: [PATCH 5/6] Adding defaultIconColor and reading it from attributes If the icon's color is not set the default will be the text's color --- .../src/main/java/mehdi/sakout/fancybuttons/FancyButton.java | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java index d7a2252..3deed56 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -30,6 +30,7 @@ public class FancyButton extends LinearLayout{ // # Text Attributes private int mDefaultTextColor = Color.WHITE; + private int mDefaultIconColor = Color.WHITE; private int mTextPosition = 1; private int mDefaultTextSize = 15; private int mDefaultTextGravity = 0x11; // Gravity.CENTER @@ -269,6 +270,8 @@ private void initAttributsArray(TypedArray attrsArray){ mFocusBackgroundColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_focusColor,mFocusBackgroundColor); mDefaultTextColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_textColor,mDefaultTextColor); + // if default color is set then the icon's color is the same (the default for icon's color) + mDefaultIconColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_iconColor,mDefaultTextColor); mDefaultTextSize = (int) attrsArray.getDimension(R.styleable.FancyButtonsAttrs_textSize,mDefaultTextSize); mDefaultTextGravity = attrsArray.getInt(R.styleable.FancyButtonsAttrs_textGravity, mDefaultTextGravity); From 2f911e12a088ad56270460519e8df4d618d52d6e Mon Sep 17 00:00:00 2001 From: kady Date: Sun, 12 Apr 2015 16:50:59 +0200 Subject: [PATCH 6/6] Setting icon color to default color in setupFontIconView --- .../src/main/java/mehdi/sakout/fancybuttons/FancyButton.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java index 3deed56..f113788 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -194,7 +194,7 @@ private TextView setupFontIconView(){ if(mFontIcon!=null){ TextView fontIconView = new TextView(mContext); - fontIconView.setTextColor(mDefaultTextColor); + fontIconView.setTextColor(mDefaultIconColor); LayoutParams iconTextViewParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT,1f); iconTextViewParams.rightMargin = mIconPaddingRight;