Skip to content
This repository has been archived by the owner on Mar 11, 2022. It is now read-only.

Font Family Implementation #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added app/src/main/res/font/cairo.ttf
Binary file not shown.
40 changes: 21 additions & 19 deletions app/src/main/res/layout/content_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,66 +14,67 @@
android:id="@+id/swipeBtnDisabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
app:button_background="@drawable/shape_button"
app:button_bottom_padding="18dp"
app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
app:button_background="@drawable/shape_button"
app:button_image_height="60dp"
app:button_image_width="100dp"
app:button_bottom_padding="18dp"
app:button_left_padding="38dp"
app:button_right_padding="38dp"
app:button_top_padding="18dp"
app:font_family="@font/cairo"
app:initial_state="disabled"
app:inner_text="SWIPE"
app:inner_text_background="@drawable/shape_rounded"
app:inner_text_bottom_padding="18dp"
app:inner_text_color="@android:color/white"
app:inner_text_size="16sp"
app:inner_text_top_padding="18dp"
app:inner_text_bottom_padding="18dp" />
app:inner_text_top_padding="18dp" />

<com.ebanx.swipebtn.SwipeButton
android:id="@+id/swipeNoState"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:layout_marginBottom="20dp"
app:button_trail_enabled="true"
app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
app:button_background="@drawable/shape_button_squared"
app:button_bottom_padding="18dp"
app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
app:button_left_padding="18dp"
app:button_right_padding="18dp"
app:button_top_padding="18dp"
app:button_trail_enabled="true"
app:has_activate_state="true"
app:initial_state="disabled"
app:inner_text="SWIPE TO ACTIVATE"
app:inner_text_background="@drawable/shape_squared"
app:inner_text_bottom_padding="18dp"
app:inner_text_color="@android:color/white"
app:inner_text_size="16sp"
app:inner_text_top_padding="18dp"
app:inner_text_bottom_padding="18dp"
app:has_activate_state="true"/>
app:inner_text_top_padding="18dp" />

<!--app:button_trail_drawable="@drawable/shape_button_squared"-->
<!--app:button_trail_drawable="@drawable/shape_button_squared"-->

<com.ebanx.swipebtn.SwipeButton
android:id="@+id/swipeBtnEnabled"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginEnd="20dp"
android:layout_marginStart="20dp"
app:button_trail_enabled="false"
app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
android:layout_marginEnd="20dp"
app:button_background="@drawable/shape_button"
app:button_bottom_padding="20dp"
app:button_image_disabled="@drawable/ic_lock_open_black_24dp"
app:button_image_enabled="@drawable/ic_lock_outline_black_24dp"
app:button_left_padding="20dp"
app:button_right_padding="20dp"
app:button_top_padding="20dp"
app:button_trail_enabled="false"
app:initial_state="enabled"
app:inner_text="UNBLOCK"
app:inner_text_background="@drawable/shape_rounded"
Expand All @@ -86,7 +87,8 @@
android:id="@+id/toggleBtn"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="TOGGLE"
android:layout_marginTop="20dp"/>
android:layout_marginTop="20dp"
android:fontFamily="@font/cairo"
android:text="TOGGLE" />

</LinearLayout>
10 changes: 8 additions & 2 deletions swipe-button/src/main/java/com/ebanx/swipebtn/SwipeButton.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.res.ResourcesCompat;
import android.util.AttributeSet;
import android.view.Gravity;
import android.view.MotionEvent;
Expand Down Expand Up @@ -204,6 +205,11 @@ private void init(Context context, AttributeSet attrs, int defStyleAttr, int def
centerText.setText(typedArray.getText(R.styleable.SwipeButton_inner_text));
centerText.setTextColor(typedArray.getColor(R.styleable.SwipeButton_inner_text_color,
Color.WHITE));
//Add font family to inner text
if (typedArray.hasValue(R.styleable.SwipeButton_font_family)) {
int fontId = typedArray.getResourceId(R.styleable.SwipeButton_font_family, -1);
centerText.setTypeface(ResourcesCompat.getFont(context, fontId));
}

float textSize = DimentionUtils.converPixelsToSp(
typedArray.getDimension(R.styleable.SwipeButton_inner_text_size, 0), context);
Expand Down Expand Up @@ -403,7 +409,7 @@ public void onAnimationUpdate(ValueAnimator animation) {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (layer!=null) {
if (layer != null) {
layer.setVisibility(View.GONE);
}
}
Expand Down Expand Up @@ -449,7 +455,7 @@ public void onAnimationEnd(Animator animation) {
if (onStateChangeListener != null) {
onStateChangeListener.onStateChange(active);
}
if (layer!=null) {
if (layer != null) {
layer.setVisibility(View.GONE);
}
}
Expand Down
2 changes: 1 addition & 1 deletion swipe-button/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
<enum name="enabled" value="0"/>
<enum name="disabled" value="1"/>
</attr>

<attr name="font_family" format="integer" />

</declare-styleable>
</resources>