Skip to content

Commit

Permalink
Master refactor (#19)
Browse files Browse the repository at this point in the history
* Revert "Version 1.0.2 (#13)"

This reverts commit 4a7ad10.

* Revert to pre wrong PRs, bump various versions

* Update library version
  • Loading branch information
JoaquimLey authored Jan 19, 2017
1 parent 4a7ad10 commit 6901f4b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 45 deletions.
34 changes: 18 additions & 16 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.2-brightgreen.svg?style=flat)](https://bintray.com/joaquimleyapps/opensource/com.github.joaquimley%3Afaboptions/1.0.2)
[![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.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 @@ -29,17 +29,7 @@ Android implementation
dependencies {
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 @@ -66,15 +56,27 @@ 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" />
```

**XML**:
Via **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
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.4.1'
}
}
Expand Down
4 changes: 2 additions & 2 deletions faboptions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ apply plugin: 'com.jfrog.bintray'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 21
Expand All @@ -39,7 +39,7 @@ android {
}

dependencies {
final DESIGN_LIBRARY_VERSION = '25.0.1'
final DESIGN_LIBRARY_VERSION = '25.1.0'

compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:design:$DESIGN_LIBRARY_VERSION"
Expand Down
27 changes: 15 additions & 12 deletions faboptions/src/main/java/com/joaquimley/faboptions/FabOptions.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ public FabOptions(Context context, AttributeSet attrs, int defStyleAttr) {
if (attrs != null) {
inflateButtonsFromAttrs(context, attrs);
}
close();
}

private void initViews(Context context) {
Expand All @@ -93,8 +92,10 @@ 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 @@ -134,7 +135,19 @@ 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 @@ -157,17 +170,6 @@ 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 @@ -187,6 +189,7 @@ 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,30 +19,24 @@
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<FrameLayout> {
public class FabOptionsBehavior extends CoordinatorLayout.Behavior {

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

@Override
public boolean onDependentViewChanged(CoordinatorLayout parent, FrameLayout child, View dependency) {
public boolean onDependentViewChanged(CoordinatorLayout parent, View 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;
}

@Override
public void onDependentViewRemoved(CoordinatorLayout parent, FrameLayout child, View dependency) {
super.onDependentViewRemoved(parent, child, dependency);
child.setTranslationY(0);
}
//FabOptions component default {@link CoordinatorLayout.Behavior} to react to {@link Snackbar}
}
4 changes: 2 additions & 2 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ apply plugin: 'com.android.application'

android {
compileSdkVersion 25
buildToolsVersion "25.0.0"
buildToolsVersion "25.0.2"

defaultConfig {
applicationId "com.joaquimley.faboptions.sample"
Expand All @@ -37,7 +37,7 @@ android {
}

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

compile "com.android.support:design:$DESIGN_LIBRARY_VERSION"
Expand Down
1 change: 0 additions & 1 deletion sample/src/main/res/layout/activity_sample_java.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
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: 0 additions & 1 deletion sample/src/main/res/layout/activity_sample_xml.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
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 6901f4b

Please sign in to comment.