Skip to content
This repository was archived by the owner on Oct 23, 2020. It is now read-only.

Bugfix 349: update label shadow size #397

Open
wants to merge 3 commits 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
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
classpath 'com.android.tools.build:gradle:3.0.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,5 +16,6 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Mon Apr 11 11:06:38 EEST 2016
#Mon Nov 06 13:05:32 KRAT 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
18 changes: 14 additions & 4 deletions library/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 27
buildToolsVersion "26.0.2"

defaultConfig {
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 27
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
Expand All @@ -25,6 +25,16 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:27.0.0'
}

apply from: '../gradle-mvn-push.gradle'
task sourcesJar(type: Jar) {
from android.sourceSets.main.java.srcDirs
classifier = 'sources'
}

artifacts {
archives sourcesJar
}

//apply from: '../gradle-mvn-push.gradle'
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Handler;
import android.support.v4.content.res.ResourcesCompat;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.util.TypedValue;
Expand Down Expand Up @@ -165,10 +166,10 @@ private void init(Context context, AttributeSet attrs) {
mLabelsMaxLines = attr.getInt(R.styleable.FloatingActionMenu_menu_labels_maxLines, -1);
mMenuFabSize = attr.getInt(R.styleable.FloatingActionMenu_menu_fab_size, FloatingActionButton.SIZE_NORMAL);
mLabelsStyle = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_style, 0);
String customFont = attr.getString(R.styleable.FloatingActionMenu_menu_labels_customFont);
int customFont = attr.getResourceId(R.styleable.FloatingActionMenu_menu_labels_customFont, 0);
try {
if (!TextUtils.isEmpty(customFont)) {
mCustomTypefaceFromFont = Typeface.createFromAsset(getContext().getAssets(), customFont);
if (customFont > 0) {
mCustomTypefaceFromFont = ResourcesCompat.getFont(getContext(), customFont);
}
} catch (RuntimeException ex) {
throw new IllegalArgumentException("Unable to load specified custom font: " + customFont, ex);
Expand Down
12 changes: 4 additions & 8 deletions library/src/main/java/com/github/clans/fab/Label.java
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,13 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
}

private int calculateMeasuredWidth() {
if (mRawWidth == 0) {
mRawWidth = getMeasuredWidth();
}
return getMeasuredWidth() + calculateShadowWidth();
mRawWidth = getMeasuredWidth();
return mRawWidth + calculateShadowWidth();
}

private int calculateMeasuredHeight() {
if (mRawHeight == 0) {
mRawHeight = getMeasuredHeight();
}
return getMeasuredHeight() + calculateShadowHeight();
mRawHeight = getMeasuredHeight();
return mRawHeight + calculateShadowHeight();
}

int calculateShadowWidth() {
Expand Down
2 changes: 1 addition & 1 deletion library/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<enum name="mini" value="1" />
</attr>
<attr name="menu_labels_style" format="reference" />
<attr name="menu_labels_customFont" format="string" />
<attr name="menu_labels_customFont" format="reference" />
<attr name="menu_shadowColor" format="color" />
<attr name="menu_shadowRadius" format="dimension" />
<attr name="menu_shadowXOffset" format="dimension" />
Expand Down
12 changes: 6 additions & 6 deletions sample/build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 27
buildToolsVersion "26.0.2"

defaultConfig {
applicationId "com.github.fab.sample"
minSdkVersion 14
targetSdkVersion 23
targetSdkVersion 27
versionCode Integer.parseInt(project.VERSION_CODE)
versionName project.VERSION_NAME
}
Expand All @@ -28,8 +28,8 @@ android {

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.android.support:recyclerview-v7:23.3.0'
compile 'com.android.support:design:23.3.0'
compile 'com.android.support:appcompat-v7:27.0.0'
compile 'com.android.support:recyclerview-v7:27.0.0'
compile 'com.android.support:design:27.0.0'
compile project(':library')
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ public class MenusFragment extends Fragment {
private List<FloatingActionMenu> menus = new ArrayList<>();
private Handler mUiHandler = new Handler();

private boolean mShowLongText = false;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Expand All @@ -65,7 +67,7 @@ public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {

final FloatingActionButton programFab1 = new FloatingActionButton(getActivity());
programFab1.setButtonSize(FloatingActionButton.SIZE_MINI);
programFab1.setLabelText(getString(R.string.lorem_ipsum));
programFab1.setLabelText(getString(mShowLongText ? R.string.lorem_ipsum : R.string.app_name));
programFab1.setImageResource(R.drawable.ic_edit);
menuRed.addMenuButton(programFab1);
programFab1.setOnClickListener(new View.OnClickListener() {
Expand All @@ -75,6 +77,8 @@ public void onClick(View v) {
ContextCompat.getColor(getActivity(), R.color.light_grey),
ContextCompat.getColor(getActivity(), R.color.white_transparent));
programFab1.setLabelTextColor(ContextCompat.getColor(getActivity(), R.color.black));
programFab1.setLabelText(getString(mShowLongText ? R.string.app_name : R.string.lorem_ipsum));
mShowLongText = !mShowLongText;
}
});

Expand Down
Binary file added sample/src/main/res/font/font_montserrat_bold.otf
Binary file not shown.
9 changes: 9 additions & 0 deletions sample/src/main/res/font/montserrat_bold.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">

<font
android:font="@font/font_montserrat_bold"
app:font="@font/font_montserrat_bold"/>

</font-family>
1 change: 1 addition & 0 deletions sample/src/main/res/layout/menus_fragment.xml
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@
android:paddingLeft="10dp"
fab:menu_labels_ellipsize="end"
fab:menu_labels_singleLine="true"
fab:menu_labels_customFont="@font/montserrat_bold"
fab:menu_backgroundColor="#ccffffff"
fab:menu_fab_label="Menu label">

Expand Down