Skip to content

Commit

Permalink
text all caps feature added
Browse files Browse the repository at this point in the history
  • Loading branch information
Sushant Devkota authored and Sushant Devkota committed Mar 28, 2016
1 parent f3b1a45 commit 444b86e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ public class FancyButton extends LinearLayout{

private int mRadius = 0;

private boolean mTextAllCaps = false;

private Typeface mTextTypeFace = null;
private Typeface mIconTypeFace = null;

Expand Down Expand Up @@ -291,6 +293,8 @@ private void initAttributesArray(TypedArray attrsArray){
mIconPaddingTop = (int)attrsArray.getDimension(R.styleable.FancyButtonsAttrs_fb_iconPaddingTop,mIconPaddingTop);
mIconPaddingBottom = (int)attrsArray.getDimension(R.styleable.FancyButtonsAttrs_fb_iconPaddingBottom,mIconPaddingBottom);

mTextAllCaps = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_textAllCaps, false);

mGhost = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_ghost, mGhost);

String text = attrsArray.getString(R.styleable.FancyButtonsAttrs_fb_text);
Expand All @@ -313,7 +317,7 @@ private void initAttributesArray(TypedArray attrsArray){
mFontIcon = fontIcon;

if(text!=null)
mText = text;
mText = mTextAllCaps ? text.toUpperCase():text;

if(!isInEditMode()){
if(iconFontFamily!=null){
Expand Down Expand Up @@ -426,13 +430,23 @@ private void initializeButtonContainer(){
* @param text : Text
*/
public void setText(String text){
text = mTextAllCaps ? text.toUpperCase() : text;
this.mText = text;
if(mTextView == null)
initializeFancyButton();
else
mTextView.setText(text);
}

/** Set the capitalization of text
*
* @param textAllCaps : is text to be capitalized
*/
public void setTextAllCaps(boolean textAllCaps){
this.mTextAllCaps = textAllCaps;
setText(mText);
}

/**
* Set the color of text
* @param color : Color
Expand Down
1 change: 1 addition & 0 deletions fancybuttons_library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
<attr name="fb_borderWidth" format="dimension"/>
<attr name="fb_focusColor" format="color" />
<attr name="fb_radius" format="dimension" />
<attr name="fb_textAllCaps" format="boolean" />

<attr name="fb_ghost" format="boolean"></attr>
</declare-styleable>
Expand Down

0 comments on commit 444b86e

Please sign in to comment.