Skip to content

Commit

Permalink
Backport to API 14+, customization of colors for FAB, background and …
Browse files Browse the repository at this point in the history
…buttons (at runtime) now available. (#22)

* Fix some issues when initing the FabOptions (close animation on startup), Fix #17

* Add travis config file

* Backport to API 14+, customization of colors for FAB, background and buttons (at runtime) now available. (#21)

* Null check on setButtonsMenu

* Initial icon

* Initial API support, style background and FAb colors

* Adds the ability to costumize menu item color via button Id or index, closes #16

* animation on compat

* backport to Api 16 without animations, customasable options (colors etc.)

* Backport to API 14 instead of 16

* Expose new customizable options, change README with new public APIs

* update readme

* version bumps, readme update

* Small updates for release
  • Loading branch information
JoaquimLey authored Jan 28, 2017
1 parent 6901f4b commit 8a81a43
Show file tree
Hide file tree
Showing 20 changed files with 387 additions and 100 deletions.
69 changes: 69 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
language: android

jdk:
# Jdk version used by your project
- oraclejdk8

sudo: false

android:
components:
- platform-tools
- tools
# The BuildTools version used by your project
- build-tools-24.0.3
- android-25
- extra-android-m2repository
- extra-google-m2repository
- extra-android-support
- extra-google-google_play_services
# Specify at least one system image, if you need to run emulator(s) during your tests
- sys-img-armeabi-v7a-android-25
- sys-img-x86-android-25

licenses:
- android-sdk-preview-license-.+
- android-sdk-license-.+
- google-gdk-license-.+

notifications:
email: false

before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock

# cache between builds
cache:
directories:
- $HOME/.m2
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/

before_install:
- chmod +x gradlew

install:
# Check install section: http://docs.travis-ci.com/user/build-configuration/#install
# If you'd like to skip the install stage entirely, set it to true and nothing will be run.
- true

before_script:
#- chmod +x gradlew
- echo no | android create avd --force -n test -t android-25 --abi armeabi-v7a
- emulator -avd test -no-skin -no-audio -no-window -no-boot-anim &
- android-wait-for-emulator
- adb shell input keyevent 82 &

# Build, and run tests
script:
# Once tests written should run the gradle task for both Mobile and Wear
# currently only doing a normal build to test Travis config
#- ./gradlew mobile:functionalTests
#- ./gradlew wear:functionalTests
#- ./gradlew build core:connectedCheck
- ./gradlew core:test --stacktrace
#- ./gradlew core:jacocoTestReport --stacktrace

# Codecov
after_success:
- bash <(curl -s https://codecov.io/bash)
71 changes: 50 additions & 21 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.2)
[![Bintray](https://img.shields.io/badge/Bintray-v1.1.0-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.2'
compile 'com.github.joaquimley:faboptions:1.1.0'
}

- 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,31 +66,19 @@ Android implementation
android:icon="@drawable/ic_share"
android:title="Share" />
</menu>
```

```

- Add the component to your layout:
**XML**:

```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**:

- 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(Menu).

```java
FabOptions fabOptions = (FabOptions) findViewById(R.id.fab_options);
fabOptions.setButtonsMenu(this, R.menu.your_fab_buttons);
fabOptions.setButtonsMenu(R.menu.your_fab_buttons);
```
Expand All @@ -92,6 +90,37 @@ fabOptions.setButtonsMenu(this, R.menu.your_fab_buttons);
- Handle the click events for each button id defined on the `menu.xml`.


## Customizing

You can change the color of the component, both the FAB and the "background" individually, **unless specified** the background will **always** adopt the same value as the ```app:fab_color``` attribute (default is the theme's accent color).


```xml
<com.joaquimley.faboptions.FabOptions
android:id="@+id/fab_options"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:background_color="@color/fabOptionsBackgroundColor"
app:fab_color="@color/fabOptionsFabColor" />
```

You can also use **Java**

```java
fabOptions.setFabColor(R.color.fabOptionsFabColor);
fabOptions.setBackgroundColor(R.color.fabOptionsBackgroundColor);
```

*Note: One is not depedent on the other, you can costomize individualy.*

**Changing button color**
```java
fabOptions.setButtonColor(R.id.faboptions_favorite, R.color.colorAccent)
```

This will return a boolean value if it's able to change the color.


###The sample is also available on the Playstore

[![Get it on Google Play](../master/art/google-play-badge.png)](https://play.google.com/store/apps/details?id=com.joaquimley.faboptions.sample)
Expand Down Expand Up @@ -130,4 +159,4 @@ Follow the "fork-and-pull" Git workflow.
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied.
See the License for the specific language governing permissions and
limitations under the License.
limitations under the License.
9 changes: 4 additions & 5 deletions faboptions/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ android {
buildToolsVersion "25.0.2"

defaultConfig {
minSdkVersion 21
minSdkVersion 14
targetSdkVersion 25
versionCode 7
versionName "1.0.2"
versionCode 9
versionName "1.1.0"
vectorDrawables.useSupportLibrary = true
}

Expand All @@ -41,7 +41,6 @@ android {
dependencies {
final DESIGN_LIBRARY_VERSION = '25.1.0'

compile fileTree(dir: 'libs', include: ['*.jar'])
compile "com.android.support:design:$DESIGN_LIBRARY_VERSION"
}
apply from: 'https://raw.githubusercontent.com/JoaquimLey/jcenter-config/master/deploy.gradle'
apply from: 'https://raw.githubusercontent.com/JoaquimLey/jcenter-config/master/deploy.gradle'
Loading

0 comments on commit 8a81a43

Please sign in to comment.