From 8649ae606735f4aba98c92fc2204405ad01c1022 Mon Sep 17 00:00:00 2001 From: HaegonKoh Date: Wed, 27 Jul 2016 11:21:20 +0900 Subject: [PATCH 1/2] If user wanna use system font --- .../sakout/fancybuttons/FancyButton.java | 17 +++++++++++--- .../src/main/res/values/attrs.xml | 23 ++++++++++--------- 2 files changed, 26 insertions(+), 14 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 3fb6670..e8a8dcc 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -77,6 +77,7 @@ public class FancyButton extends LinearLayout{ private TextView mTextView; private boolean mGhost = false ; // Default is a solid button ! + private boolean mUseSystemFont = false; // Default is using robotoregular.ttf /** * Default constructor @@ -185,7 +186,7 @@ private TextView setupTextView(){ textView.setTextSize(Utils.pxToSp(getContext(), mDefaultTextSize)); textView.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); - if (!isInEditMode() && mTextTypeFace!=null) { + if (!isInEditMode() && mTextTypeFace!=null && !mUseSystemFont) { textView.setTypeface(mTextTypeFace); } return textView; @@ -283,7 +284,7 @@ private void initAttributesArray(TypedArray attrsArray){ mDefaultTextSize = (int) attrsArray.getDimension(R.styleable.FancyButtonsAttrs_fb_textSize, mDefaultTextSize); mDefaultTextGravity = attrsArray.getInt(R.styleable.FancyButtonsAttrs_fb_textGravity, mDefaultTextGravity); - mBorderColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_fb_borderColor,mBorderColor); + mBorderColor = attrsArray.getColor(R.styleable.FancyButtonsAttrs_fb_borderColor, mBorderColor); mBorderWidth = (int) attrsArray.getDimension(R.styleable.FancyButtonsAttrs_fb_borderWidth,mBorderWidth); mRadius = (int)attrsArray.getDimension(R.styleable.FancyButtonsAttrs_fb_radius,mRadius); @@ -296,7 +297,8 @@ private void initAttributesArray(TypedArray attrsArray){ mTextAllCaps = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_textAllCaps, false); - mGhost = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_ghost, mGhost); + mGhost = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_ghost, mGhost); + mUseSystemFont = attrsArray.getBoolean(R.styleable.FancyButtonsAttrs_fb_useSystemFont, mUseSystemFont); String text = attrsArray.getString(R.styleable.FancyButtonsAttrs_fb_text); mIconPosition = attrsArray.getInt(R.styleable.FancyButtonsAttrs_fb_iconPosition,mIconPosition); @@ -685,6 +687,15 @@ public void setGhost(boolean ghost) { } + /** + * Setting the button use system font + * + * @param use + */ + public void setUsingSystemFont(boolean use) { + this.mUseSystemFont = use; + } + /** * Return Text of the button * @return Text diff --git a/fancybuttons_library/src/main/res/values/attrs.xml b/fancybuttons_library/src/main/res/values/attrs.xml index 5c62fe6..f87b531 100644 --- a/fancybuttons_library/src/main/res/values/attrs.xml +++ b/fancybuttons_library/src/main/res/values/attrs.xml @@ -1,19 +1,19 @@ - - + + - - + + - - + + - - - - + + + + @@ -51,12 +51,13 @@ - + + \ No newline at end of file From e30c6f7a73d33d88732c9ad5166fefc5c8c831d3 Mon Sep 17 00:00:00 2001 From: medyo Date: Sun, 23 Oct 2016 12:05:55 +0100 Subject: [PATCH 2/2] improve the commit --- .../main/java/mehdi/sakout/fancybuttons/FancyButton.java | 8 ++++---- fancybuttons_library/src/main/res/values/attrs.xml | 4 ++-- samples/src/main/res/layout/activity_xml_buttons.xml | 3 +-- 3 files changed, 7 insertions(+), 8 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 e8a8dcc..49abef0 100644 --- a/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java +++ b/fancybuttons_library/src/main/java/mehdi/sakout/fancybuttons/FancyButton.java @@ -688,12 +688,12 @@ public void setGhost(boolean ghost) { } /** - * Setting the button use system font + * If enabled, the button title will ignore its custom font and use the default system font * - * @param use + * @param status : true || false */ - public void setUsingSystemFont(boolean use) { - this.mUseSystemFont = use; + public void setUsingSystemFont(boolean status) { + this.mUseSystemFont = status; } /** diff --git a/fancybuttons_library/src/main/res/values/attrs.xml b/fancybuttons_library/src/main/res/values/attrs.xml index f87b531..28abf8a 100644 --- a/fancybuttons_library/src/main/res/values/attrs.xml +++ b/fancybuttons_library/src/main/res/values/attrs.xml @@ -56,8 +56,8 @@ - - + + \ No newline at end of file diff --git a/samples/src/main/res/layout/activity_xml_buttons.xml b/samples/src/main/res/layout/activity_xml_buttons.xml index e052b36..bcecdab 100644 --- a/samples/src/main/res/layout/activity_xml_buttons.xml +++ b/samples/src/main/res/layout/activity_xml_buttons.xml @@ -2,8 +2,7 @@ xmlns:android="http://schemas.android.com/apk/res/android" xmlns:fancy="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" - android:layout_height="wrap_content" - tools:context="mehdi.sakout.fancybuttons.MainActivity$PlaceholderFragment" > + android:layout_height="wrap_content">