Skip to content
This repository has been archived by the owner on Jul 10, 2020. It is now read-only.

Commit

Permalink
Fixes and improvements
Browse files Browse the repository at this point in the history
- Fixed an issue that made the overlay disappear some times.
- Removed unnecessary logs
- Update README
- Automate sample APK publication
  • Loading branch information
jahirfiquitiva committed Feb 7, 2018
1 parent cde8a62 commit 8ebe8f4
Show file tree
Hide file tree
Showing 6 changed files with 149 additions and 68 deletions.
73 changes: 44 additions & 29 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,48 +1,63 @@
language: android

env:
global:
- ANDROID_API=27
- ANDROID_BUILD_TOOLS=27.0.3

android:
components:
# Uncomment the lines below if you want to
# use the latest revision of Android SDK Tools
- platform-tools
- tools

# The BuildTools version used by your project
- build-tools-27.0.2

# The SDK version used to compile your project
- android-27

# Additional components
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
- platform-tools
- tools
- build-tools-$ANDROID_BUILD_TOOLS
- android-$ANDROID_API
- extra-android-support
- extra-google-m2repository
- extra-android-m2repository
licenses:
- '.+'
- ".+"

jdk:
- oraclejdk8
- oraclejdk8

script: ./gradlew clean test
script: if [[ "$TRAVIS_TAG" ]]; then ./gradlew clean :app:assembleRelease --stacktrace; else ./gradlew clean test --stacktrace; fi

branches:
except:
- gh-pages

- images
- gh-pages
- travis-build
- i18n

notifications:
email: false
slack:
slack:
rooms: jahirfiquitiva:StCMaxV85iad38DdSMBY43xW
template:
- "Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}: '%{commit_subject}'>) by %{author} for %{repository_name}@%{branch}, %{result} in %{duration}. <%{build_url}|Check details>."
template:
- 'Build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}: ''%{commit_subject}''>) by
%{author} for %{repository_name}@%{branch}, %{result} in %{duration}. <%{build_url}|Check
details>.'
sudo: false
cache:
directories:
- $HOME/.m2
before_script:
- chmod +x gradlew
- "$HOME/.android/build-cache"
- "$HOME/.m2"
- "$HOME/.gradle"
- "$HOME/.gradle/caches/"
- "$HOME/.gradle/wrapper/"
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
before_script:
- rm -rf $TRAVIS_BUILD_DIR/app/build/outputs
- chmod +x gradlew
before_install:
- yes | sdkmanager "platforms;android-27"
- yes | sdkmanager "platforms;android-27"
after_success:
- chmod +x ./publish_apk.sh; ./publish_apk.sh
88 changes: 66 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,34 @@
# FloatingActionButtons Menu (FABsMenu)
<img src="https://www.jahirfiquitiva.me/assets/img/portfolio/libs/fabsmenu.png" width="192" align="right" hspace="20" />

FloatingActionButtons Menu (FABsMenu)
======

![API](https://img.shields.io/badge/API-14%2B-34bf49.svg)
[![JitPack Badge](https://jitpack.io/v/jahirfiquitiva/FABsMenu.svg)](https://jitpack.io/#jahirfiquitiva/FABsMenu)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3ab596acdd5648599c34d56dba1eea39)](https://www.codacy.com/app/jahirfiquitiva/FABsMenu?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=jahirfiquitiva/FABsMenu&amp;utm_campaign=Badge_Grade)
[![Build Status](https://travis-ci.org/jahirfiquitiva/FABsMenu.svg?branch=master)](https://travis-ci.org/jahirfiquitiva/FABsMenu)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/3ab596acdd5648599c34d56dba1eea39)](https://www.codacy.com/app/jahirfiquitiva/FABsMenu?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=jahirfiquitiva/FABsMenu&amp;utm_campaign=Badge_Grade)

Just a simple library to use a menu of `FloatingActionButton`s from Design Support Library that follows [Material Design guidelines](https://material.io/guidelines/components/buttons-floating-action-button.html#buttons-floating-action-button-transitions)

<a target="_blank" href="http://bit.ly/FABsMenuAPK">
<img src="http://jahirfiquitiva.me/share/download_sample.svg?maxAge=432000" width="200"/>
</a>

<a target="_blank" href="http://www.jahirfiquitiva.me/support/">
<img src="http://jahirfiquitiva.me/share/support_my_work.svg?maxAge=432000" width="200"/>
</a>

## Show some :blue_heart:
[![GitHub stars](https://img.shields.io/github/stars/jahirfiquitiva/FABsMenu.svg?style=social&label=Star)](https://github.com/jahirfiquitiva/FABsMenu)
[![GitHub forks](https://img.shields.io/github/forks/jahirfiquitiva/FABsMenu.svg?style=social&label=Fork)](https://github.com/jahirfiquitiva/FABsMenu/fork)
[![GitHub watchers](https://img.shields.io/github/watchers/jahirfiquitiva/FABsMenu.svg?style=social&label=Watch)](https://github.com/jahirfiquitiva/FABsMenu)

[![Follow on GitHub](https://img.shields.io/github/followers/jahirfiquitiva.svg?style=social&label=Follow)](https://github.com/jahirfiquitiva)
[![Twitter Follow](https://img.shields.io/twitter/follow/jahirfiquitiva.svg?style=social)](https://twitter.com/jahirfiquitiva)
[![Google+](https://img.shields.io/badge/Follow-Google%2B-ea4335.svg)](https://plus.google.com/+JahirFiquitivaR)

---

### Long story

Android Support/Design libraries still doesn't include a FloatingActionButtons menu, and the libraries found here and there are either too cluttered or filled with unnecessary stuff or using custom views that simply don't follow guidelines, which made me avoid them.
Expand All @@ -15,32 +38,38 @@ I was looking for a new library, and the ones I knew of, have been deprecated/ab
This library uses the design library FABs but wraps them inside a ViewGroup to make them look like the FloatingActionButtons menu suggested in Material Design guidelines.


## Preview
---

# Preview

![FABs Menu Preview](https://github.com/jahirfiquitiva/FABsMenu/raw/master/preview/preview.gif)

## Changelog
:radio_button: You can find it in the [Releases page](https://github.com/jahirfiquitiva/FABsMenu/releases)

---

## Usage
# Including in your project
FABsMenu is available via JitPack, so getting it as simple as adding it as a dependency, like this:

Add jitpack dependency to your root `build.gradle`:
```groovy
1. Add JitPack repository to your root `build.gradle` file
```gradle
allprojects {
repositories {
maven { url 'https://jitpack.io' }
}
}
```

Next, add the dependency to your `build.gradle`:
```groovy
2. Add the dependency in your project `build.gradle` file
```gradle
dependencies {
  implementation 'me.jahirfiquitiva:FABsMenu:1.1.1'
implementation 'me.jahirfiquitiva:FABsMenu:{latest version}'
}
```
where `{latest version}` corresponds to published version in [![JitPack](https://jitpack.io/v/jahirfiquitiva/FABsMenu.svg)](https://jitpack.io/#jahirfiquitiva/FABsMenu)

Then sync the gradle files.

Finally, use it in your layout, just like this:
## How to implement
You can use it in your layout, just like this:

```xml
<RelativeLayout
Expand Down Expand Up @@ -215,26 +244,41 @@ menu.attachToRecyclerView(rv);
4. As stated in guidelines, a FABsMenu should not have more than 6 items. If you use more than 6, you will get an `IllegalArgumentException`. Also, remember FABs menu should have **at least** 3 items too.
5. For now, the icon you set for FABsMenu will always rotate, so be sure you set an icon that looks good in both states (normal and rotated).

---

## Apps using FABsMenu

* Yours? Fill [an issue](https://github.com/jahirfiquitiva/FABsMenu/issues/new) and let me know ;)

## Developed by
---

# Developed by

### [Jahir Fiquitiva](https://www.jahirfiquitiva.me/)

[![Follow on GitHub](https://img.shields.io/github/followers/jahirfiquitiva.svg?style=social&label=Follow)](https://github.com/jahirfiquitiva)
[![Twitter Follow](https://img.shields.io/twitter/follow/jahirfiquitiva.svg?style=social)](https://twitter.com/jahirfiquitiva)
[![Google+](https://img.shields.io/badge/Follow-Google%2B-ea4335.svg)](https://plus.google.com/+JahirFiquitivaR)

If you found this app/library helpful and want to thank me, you can:

<a target="_blank" href="http://www.jahirfiquitiva.me/support/">
<img src="http://jahirfiquitiva.me/share/support_my_work.svg?maxAge=432000" width="200"/>
</a>

**Thanks in advance!** :pray:

* Jahir Fiquitiva
* [Website](https://www.jahirfiquitiva.me)
* [Google+](https://google.com/+JahirFiquitivaR)
* [Donate](https://paypal.me/jahirfiquitiva/5)
---

## Credits
# Credits

This project is based on Future Simple's [android-floating-action-button](https://github.com/futuresimple/android-floating-action-button) project, which is also based on [FloatingActionButton](https://github.com/makovkastar/FloatingActionButton) library by [Oleksandr Melnykov](https://github.com/makovkastar).


## License
# License


Copyright (c) 2017 Jahir Fiquitiva
Copyright (c) 2018 Jahir Fiquitiva

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -249,7 +293,7 @@ This project is based on Future Simple's [android-floating-action-button](https:
limitations under the License.


## Original license
# Original license


Copyright (c) 2014 Jerzy Chalupski
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
Expand Down Expand Up @@ -107,14 +106,10 @@ public void onClick(View view) {
}
});

Log.d("FABsMenu", "Current buttons count: " + menu.getButtonsCount());

// Removes a button
TitleFAB toRemove = findViewById(R.id.to_remove);
menu.removeButton(toRemove);

Log.d("FABsMenu", "Buttons count after removal: " + menu.getButtonsCount());

// Adds a button to the bottom
final TitleFAB toAdd = new TitleFAB(this);
toAdd.setTitle("A new added fab");
Expand All @@ -128,8 +123,6 @@ public void onClick(View view) {
}
});
menu.addButton(toAdd);

Log.d("FABsMenu", "Buttons count after addition: " + menu.getButtonsCount());
}

@Override
Expand All @@ -153,10 +146,8 @@ public void onClick(View view) {
}
});
menu.addButton(toAdd);
Log.d("FABsMenu", "Buttons count after addition: " + menu.getButtonsCount());
} else if (item.getItemId() == R.id.remove) {
menu.removeAllButtons();
Log.d("FABsMenu", "Buttons count after removing all: " + menu.getButtonsCount());
}
return super.onOptionsItemSelected(item);
}
Expand Down
6 changes: 3 additions & 3 deletions dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ ext.versions = [
minSdk : 14,
targetSdk : 27,
compileSdk : 27,
buildTools : '27.0.2',
versionCode : 110,
versionName : '1.1.0',
buildTools : '27.0.3',
versionCode : 112,
versionName : '1.1.2',
gradlePlugin: '3.0.1',
libPubPlugin: '2.0',
// Libraries versions
Expand Down
18 changes: 13 additions & 5 deletions library/src/main/java/jahirfiquitiva/libs/fabsmenu/FABsMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,14 +89,16 @@ public class FABsMenu extends ViewGroup {
private int labelsMargin;
private int labelsVerticalOffset;
private int labelsPosition;
private boolean expanded;
private AnimatorSet expandAnimation = new AnimatorSet().setDuration(animationDuration);
private AnimatorSet collapseAnimation = new AnimatorSet().setDuration(animationDuration);
private int buttonsCount;
private int maxButtonWidth;
private int maxButtonHeight;
private TouchDelegateGroup touchDelegateGroup;
private FABsMenuListener menuListener;
private boolean expanded;

private boolean animating = false;
private AnimatorSet expandAnimation = new AnimatorSet().setDuration(animationDuration);
private AnimatorSet collapseAnimation = new AnimatorSet().setDuration(animationDuration);

public FABsMenu(Context context) {
this(context, null);
Expand Down Expand Up @@ -622,12 +624,15 @@ public void onAnimationStart(Animator animation) {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
setMenuButtonsVisibility(false);
animating = false;
expanded = false;
}
};

private void collapse(boolean immediately) {
if (animating) return;
if (expanded) {
expanded = false;
animating = true;
touchDelegateGroup.setEnabled(false);
toggleOverlay(false, immediately);
collapseAnimation.setDuration(immediately ? 0 : animationDuration);
Expand Down Expand Up @@ -660,12 +665,15 @@ public void onAnimationStart(Animator animation) {
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
setMenuButtonsClickable(true);
animating = false;
expanded = true;
}
};

public void expand() {
if (animating) return;
if (!expanded) {
expanded = true;
animating = true;
touchDelegateGroup.setEnabled(true);
toggleOverlay(true, false);
collapseAnimation.cancel();
Expand Down
23 changes: 23 additions & 0 deletions publish_apk.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
if [ "$TRAVIS_PULL_REQUEST" = false ]; then
if [ "$TRAVIS_TAG" ]; then
cd $TRAVIS_BUILD_DIR/app/build/outputs/apk/release/

printf "\nGetting tag information\n"
tagInfo="$(curl https://api.github.com/repos/${TRAVIS_REPO_SLUG}/releases/tags/${TRAVIS_TAG})"
releaseId="$(echo "$tagInfo" | jq ".id")"

printf "\n\n"
for apk in $(find *.apk -type f); do
apkName="${apk::-4}"
printf "Uploading: $apkName.apk ...\n"
curl "https://uploads.github.com/repos/${TRAVIS_REPO_SLUG}/releases/${releaseId}/assets?access_token=${GITHUB_API_KEY}&name=${apkName}.apk" --header 'Content-Type: application/zip' --upload-file $apkName.apk -X POST
done

printf "\n\nFinished uploading APK(s)\n"
else
printf "\nSkipping APK(s) upload because this commit does not have a tag\n"
fi
else
printf "\nSkipping APK(s) upload because this is just a pull request\n"
fi

0 comments on commit 8ebe8f4

Please sign in to comment.