Skip to content

Commit

Permalink
Version 1.0.2 (#13)
Browse files Browse the repository at this point in the history
* Update library version on sample, add description to deploy script, update README

* Sample version code bump

* Standard code style, fix offset in close icon state

* Library version bump

* Removed script from VC, add remote raw version

* sample: include the latest version of the library

* Update version on readme

* React to Snackbar dismiss (#9)

* Fix #8

* Compile with project

* Fix #11 (#12)

* Library versions bump

* Update readme version bump, ordering xml
  • Loading branch information
JoaquimLey authored Dec 9, 2016
1 parent b41b267 commit 4a7ad10
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 41 deletions.
36 changes: 17 additions & 19 deletions README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#FabOptions
[![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-FabOptions-brightgreen.svg?style=flat)](http://android-arsenal.com/details/1/4734)
[![MaterialUp](https://img.shields.io/badge/MaterialUp-FabOptions-blue.svg?style=flat)](https://material.uplabs.com/posts/faboptions)
[![Bintray](https://img.shields.io/badge/Bintray-v1.0.1-brightgreen.svg?style=flat)](https://bintray.com/joaquimleyapps/opensource/com.github.joaquimley%3Afaboptions/1.0.1)
[![Bintray](https://img.shields.io/badge/Bintray-v1.0.2-brightgreen.svg?style=flat)](https://bintray.com/joaquimleyapps/opensource/com.github.joaquimley%3Afaboptions/1.0.2)
![minSdkVersion](https://img.shields.io/badge/minSdkVersion-21-red.svg?style=true)
![compileSdkVersion](https://img.shields.io/badge/compileSdkVersion-25-green.svg?style=true)

Expand All @@ -27,9 +27,19 @@ Android implementation
- Import gradle dependency:

dependencies {
compile 'com.github.joaquimley:faboptions:1.0.1'
compile 'com.github.joaquimley:faboptions:1.0.2'
}

- Add the component to your layout:

```xml
<com.joaquimley.faboptions.FabOptions
android:id="@+id/fab_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
```


- Define a `menu.xml` file with your buttons information **e.g.**

Expand All @@ -56,27 +66,15 @@ Android implementation
android:icon="@drawable/ic_share"
android:title="Share" />
</menu>
```


- Add the component to your layout:

```xml
<com.joaquimley.faboptions.FabOptions
android:id="@+id/fab_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom" />
```
```

Via **XML**:
**XML**:

- Bind the buttons menu by adding the **custom attribute** `app:button_menu="@menu/your_fab_buttons"` to your component XML
- Bind the buttons menu by adding the **custom attribute** `app:button_menu="@menu/your_fab_buttons"` to your component XML.

**Programmatically**

- Bind the buttons menu on your FabOptions instance with FabOptions#setMenu()
- Bind the buttons menu on your FabOptions instance with FabOptions#setMenu.

```java
FabOptions fabOptions = (FabOptions) findViewById(R.id.fab_options);
Expand Down
4 changes: 2 additions & 2 deletions faboptions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 25
versionCode 6
versionName "1.0.1"
versionCode 7
versionName "1.0.2"
vectorDrawables.useSupportLibrary = true
}

Expand Down
27 changes: 12 additions & 15 deletions faboptions/src/main/java/com/joaquimley/faboptions/FabOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ public FabOptions(Context context, AttributeSet attrs, int defStyleAttr) {
if (attrs != null) {
inflateButtonsFromAttrs(context, attrs);
}
close();
}

private void initViews(Context context) {
Expand All @@ -92,10 +93,8 @@ public void setButtonsMenu(Context context, @MenuRes int menuId) {
mMenu = new MenuBuilder(context);
SupportMenuInflater menuInf = new SupportMenuInflater(context);
menuInf.inflate(menuId, mMenu);

addButtonsFromMenu(context, mMenu);
mSeparator = mButtonContainer.addSeparator(context);
close();
}

private void addButtonsFromMenu(Context context, Menu menu) {
Expand Down Expand Up @@ -135,19 +134,7 @@ public void setOnClickListener(View.OnClickListener listener) {
@Override
protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
super.onLayout(changed, left, top, right, bottom);
if (mSeparator != null) {
ViewGroup.LayoutParams separatorLayoutParams = mSeparator.getLayoutParams();
separatorLayoutParams.width = mFab.getMeasuredWidth();
separatorLayoutParams.height = mFab.getMeasuredHeight();
mSeparator.setLayoutParams(separatorLayoutParams);
}

if (mIsOpen) {
ViewGroup.LayoutParams backgroundLayoutParams = mBackground.getLayoutParams();
backgroundLayoutParams.width = mButtonContainer.getMeasuredWidth();
backgroundLayoutParams.height = mButtonContainer.getMeasuredHeight();
mBackground.setLayoutParams(backgroundLayoutParams);
}
}

private void open() {
Expand All @@ -170,6 +157,17 @@ private void close() {
mIsOpen = false;
}

@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
if (mSeparator != null) {
ViewGroup.LayoutParams separatorLayoutParams = mSeparator.getLayoutParams();
separatorLayoutParams.width = mFab.getMeasuredWidth();
separatorLayoutParams.height = mFab.getMeasuredHeight();
mSeparator.setLayoutParams(separatorLayoutParams);
}
}

private void animateBackground(final boolean isOpen) {
ViewGroup.LayoutParams backgroundLayoutParams = mBackground.getLayoutParams();
backgroundLayoutParams.width = isOpen ? mButtonContainer.getMeasuredWidth() : NO_DIMENSION;
Expand All @@ -189,7 +187,6 @@ public boolean isOpen() {

private static class OpenMorphTransition extends TransitionSet {
OpenMorphTransition(ViewGroup viewGroup) {

ChangeBounds changeBound = new ChangeBounds();
changeBound.excludeChildren(R.id.button_container, true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,30 @@
import android.support.design.widget.CoordinatorLayout;
import android.support.design.widget.Snackbar;
import android.view.View;
import android.widget.FrameLayout;

/**
* FabOptions component default CoordinatorLayout.Behavior to react Snackbar
*/

public class FabOptionsBehavior extends CoordinatorLayout.Behavior {
public class FabOptionsBehavior extends CoordinatorLayout.Behavior<FrameLayout> {

@Override
public boolean layoutDependsOn(CoordinatorLayout parent, View child, View dependency) {
public boolean layoutDependsOn(CoordinatorLayout parent, FrameLayout child, View dependency) {
return dependency instanceof Snackbar.SnackbarLayout;
}

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, View child, View dependency) {
public boolean onDependentViewChanged(CoordinatorLayout parent, FrameLayout child, View dependency) {
float translationY = Math.min(0, dependency.getTranslationY() - dependency.getHeight());
child.setTranslationY(translationY);
// TODO: 21/11/2016 Handle instanceof Bottomsheetnav & others
return true;
}
//FabOptions component default {@link CoordinatorLayout.Behavior} to react to {@link Snackbar}

@Override
public void onDependentViewRemoved(CoordinatorLayout parent, FrameLayout child, View dependency) {
super.onDependentViewRemoved(parent, child, dependency);
child.setTranslationY(0);
}
}
2 changes: 1 addition & 1 deletion sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ android {

dependencies {
final DESIGN_LIBRARY_VERSION = '25.0.1'
final FABOPTIONS_VERSION = '1.0.1'
final FABOPTIONS_VERSION = '1.0.2'

compile "com.android.support:design:$DESIGN_LIBRARY_VERSION"
compile "com.github.joaquimley:faboptions:$FABOPTIONS_VERSION"
Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_sample_java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
style=":?attr/textAppearanceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:layout_gravity="center"
android:text="@string/website" />

Expand Down
1 change: 1 addition & 0 deletions sample/src/main/res/layout/activity_sample_xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
style=":?attr/textAppearanceButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:autoLink="web"
android:layout_gravity="center"
android:text="@string/website" />

Expand Down

0 comments on commit 4a7ad10

Please sign in to comment.