Skip to content

Commit

Permalink
Merge branch 'release-2.5.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
markormesher committed Feb 23, 2019
2 parents 15be67e + 92173d2 commit 86a34fa
Show file tree
Hide file tree
Showing 20 changed files with 38,043 additions and 15,404 deletions.
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@ You can try the demo in one of two ways:

### Gradle

implementation 'uk.co.markormesher:android-fab:2.4.1'
implementation 'uk.co.markormesher:android-fab:2.5.0'

### Maven

<dependency>
<groupId>uk.co.markormesher</groupId>
<artifactId>android-fab</artifactId>
<version>2.4.1</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>uk.co.markormesher</groupId>
<artifactId>android-fab</artifactId>
<version>2.5.0</version>
<type>pom</type>
</dependency>

---

**Note:** depending on your app's configuration, you may need to add the following to your ProGuard rules:

-dontwarn java.lang.invoke.*
-dontwarn java.lang.invoke.*

See [app/proguard-rules.pro](app/proguard-rules.pro) for an example.

Expand All @@ -42,20 +42,20 @@ See [app/proguard-rules.pro](app/proguard-rules.pro) for an example.
**Note:** all of the instructions below assume that the FAB is referenced by the variable `fab`, i.e.

// Java
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);

// Kotlin (without Android extensions)
val fab = findViewById(R.id.fab) as FloatingActionButton
// Kotlin (without Android extensions)
val fab = findViewById(R.id.fab) as FloatingActionButton

### Placing the FAB in Your Layout

The `FloatingActionButton` view must be placed at the **root** of your layout, **above** all other views, and with **maximum width and height**. This allows the semi-transparent layer to expand and cover the entire layout when the speed-dial menu is opened.

<uk.co.markormesher.android_fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<uk.co.markormesher.android_fab.FloatingActionButton
android:id="@+id/fab"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>

### FAB Position

Expand Down Expand Up @@ -92,7 +92,7 @@ The FAB can be offset from any of the four edges to precisely control its locati
app:internalOffsetEnd="@dimen/some_dimen"
/>

**Note:** any offset is applied *in addition to* the default spacing around the FAB. If you need to counter this, subtract the default spacing (`fab.getOriginalInternalOffset()` in Java or `fab.originalInternalOffset` in Kotlin) from the value you want to use.
**Note:** any offset is applied *in addition to* the default spacing around the FAB. If you need to counter this, subtract the default spacing (`fab.getOriginalInternalOffset()` in Java or `fab.originalInternalOffset` in Kotlin) from the value you want to use.

### FAB Icon

Expand Down Expand Up @@ -190,7 +190,9 @@ State change events are fired when the speed-dial menu opens or closes, which ca

### Show/Hide Controls

The FAB can be hidden and shown with the `fab.hide()` and `fab.show()` methods, and the method `fab.isShown()` will return a boolean indicating the current state. These methods animate the FAB in and out of visibility. If the speed-dial menu is open when `.hide()` is called it will be closed.
The FAB can be hidden and shown with the `fab.hide()` and `fab.show()` methods, and the method `fab.isShown()` will return a boolean indicating the current state. These methods animate the FAB in and out of visibility and set the entire view container's visibility to `GONE`. If the speed-dial menu is open when `.hide()` is called it will be closed.

If the FAB is hidden in the XML layout (i.e. with `android:visibility="gone"`) when initialise the FAB will start in the correct hidden state and can still be shown/hidden with the `fab.hide()` and `fab.show()` methods.

The speed-dial menu can be manually opened and closed with `fab.openSpeedDialMenu()` and `fab.closeSpeedDialMenu()`. These methods will do nothing if no speed-dial menu adapter is set, if an adapter is set but disabled, if the FAB is hidden, or if they are called when the menu is already in the indicated state (i.e. `fab.openSpeedDialMenu()` will do nothing if the menu is already open).

Expand Down
13 changes: 6 additions & 7 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand All @@ -20,14 +20,14 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
applicationId "uk.co.markormesher.android_fab.app"

minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28

versionCode properties['version_code']
versionName properties['version_name']
Expand Down Expand Up @@ -82,9 +82,8 @@ repositories {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation project(':fab')
}
3 changes: 1 addition & 2 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-dontwarn android.support.**

# hide warnings caused by Retrolamdba
-dontwarn java.lang.invoke.*
Expand Down Expand Up @@ -47,4 +46,4 @@

# keep line numbers intact
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package uk.co.markormesher.android_fab.app
import android.content.Context
import android.graphics.Typeface
import android.os.*
import android.support.annotation.StringRes
import android.support.design.widget.Snackbar
import android.support.v7.app.AppCompatActivity
import android.view.KeyEvent
import android.view.Menu
import android.view.MenuItem
import android.view.MotionEvent
import android.widget.TextView
import android.widget.Toast
import androidx.annotation.StringRes
import androidx.appcompat.app.AppCompatActivity
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.demo_activity.*
import uk.co.markormesher.android_fab.FloatingActionButton
import uk.co.markormesher.android_fab.SpeedDialMenuAdapter
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/res/layout/demo_activity.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
<androidx.coordinatorlayout.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/root_view"
Expand Down Expand Up @@ -364,4 +364,4 @@
android:layout_height="match_parent"
/>

</android.support.design.widget.CoordinatorLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
10 changes: 6 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
buildscript {
ext.kotlin_version = '1.2.60'
ext.kotlin_version = '1.3.21'

repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
classpath 'com.android.tools.build:gradle:3.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
Expand All @@ -21,6 +21,8 @@ allprojects {
}
}

apply plugin: "idea"

@SuppressWarnings("GroovyUnusedDeclaration")
static def getSecrets() {
try {
Expand All @@ -41,7 +43,7 @@ static def getSecrets() {
@SuppressWarnings("GroovyUnusedDeclaration")
static def getProps() {
Properties properties = new Properties()
properties['version_code'] = 21
properties['version_name'] = '2.4.1'
properties['version_code'] = 22
properties['version_name'] = '2.5.0'
return properties
}
26 changes: 12 additions & 14 deletions fab/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:3.1.2'
classpath 'com.android.tools.build:gradle:3.2.1'
}
}

Expand All @@ -19,12 +19,12 @@ apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'

android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
compileSdkVersion 28
buildToolsVersion '28.0.3'

defaultConfig {
minSdkVersion 14
targetSdkVersion 27
targetSdkVersion 28

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -40,10 +40,9 @@ repositories {

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:support-annotations:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'androidx.annotation:annotation:1.0.1'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}

Expand Down Expand Up @@ -87,14 +86,13 @@ task zipRelease(type: Zip) {
archiveName "release-${properties['version_name']}.zip"
}

task generateRelease << {
println "Release ${properties['version_name']} can be found at ${localReleaseDest}/"
println "Release ${properties['version_name']} zipped can be found ${buildDir}/release-${properties['version_name']}.zip"
task generateRelease(dependsOn: [uploadArchives, zipRelease]) {
doLast {
println "Release ${properties['version_name']} can be found at ${localReleaseDest}/"
println "Release ${properties['version_name']} zipped can be found ${buildDir}/release-${properties['version_name']}.zip"
}
}

generateRelease.dependsOn(uploadArchives)
generateRelease.dependsOn(zipRelease)

artifacts {
archives androidSourcesJar
archives androidJavadocsJar
Expand Down
3 changes: 1 addition & 2 deletions fab/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService
-dontwarn android.support.**

# hide warnings caused by Retrolamdba
-dontwarn java.lang.invoke.*
Expand Down Expand Up @@ -47,4 +46,4 @@

# keep line numbers intact
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-keepattributes SourceFile,LineNumberTable
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ import android.graphics.drawable.GradientDrawable
import android.os.Build
import android.os.Bundle
import android.os.Parcelable
import android.support.annotation.ColorInt
import android.support.annotation.Dimension
import android.support.annotation.DrawableRes
import android.support.design.widget.CoordinatorLayout
import android.support.design.widget.Snackbar
import android.support.v4.view.ViewCompat
import android.support.v7.widget.CardView
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.LinearLayout
import android.widget.RelativeLayout
import androidx.annotation.ColorInt
import androidx.annotation.Dimension
import androidx.annotation.DrawableRes
import androidx.cardview.widget.CardView
import androidx.coordinatorlayout.widget.CoordinatorLayout
import androidx.core.view.ViewCompat
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fab_container.view.*
import kotlinx.android.synthetic.main.floating_action_button.view.*
import kotlinx.android.synthetic.main.menu_item.view.*
Expand Down Expand Up @@ -173,6 +173,11 @@ class FloatingActionButton: RelativeLayout {

content_cover.alpha = 0f

isShown = visibility == View.VISIBLE
if (!isShown) {
hide(true)
}

addOnLayoutChangeListener { _, _, _, _, _, _, _, _, _ ->
if (layoutParams is CoordinatorLayout.LayoutParams) {
val lp = (layoutParams as CoordinatorLayout.LayoutParams)
Expand Down Expand Up @@ -397,7 +402,7 @@ class FloatingActionButton: RelativeLayout {
}

closeSpeedDialMenu()
fab_card.visibility = View.VISIBLE
visibility = View.VISIBLE
fab_card.clearAnimation()
fab_card.animate()
.scaleX(1f)
Expand All @@ -422,7 +427,7 @@ class FloatingActionButton: RelativeLayout {
.setDuration(if (immediate) 0L else HIDE_SHOW_ANIMATION_DURATION)
.setListener(object: AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator) {
fab_card.visibility = View.GONE
visibility = View.GONE
isShown = false
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ package uk.co.markormesher.android_fab

import android.content.Context
import android.graphics.Color
import android.support.annotation.ColorInt
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import androidx.annotation.ColorInt

abstract class SpeedDialMenuAdapter {

Expand Down Expand Up @@ -37,7 +37,8 @@ abstract class SpeedDialMenuAdapter {
* Note: this method should return an aRGB colour integer, *not* a colour resource ID.
* @return the colour of the card behind the icon at the specified position
*/
@ColorInt open fun getBackgroundColour(position: Int): Int = Color.argb(255, 192, 192, 192)
@ColorInt
open fun getBackgroundColour(position: Int): Int = Color.argb(255, 192, 192, 192)

/**
* Apply formatting to the `TextView` used for the label of the menu item at the given position.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package uk.co.markormesher.android_fab
import android.content.Context
import android.graphics.drawable.Drawable
import android.os.Build
import android.support.annotation.DrawableRes
import android.support.annotation.StringRes
import androidx.annotation.DrawableRes
import androidx.annotation.StringRes

/**
* Represents an item to display in the speed-dial menu.
Expand Down
10 changes: 5 additions & 5 deletions fab/src/main/res/layout-v21/floating_action_button.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>
>

<android.support.v7.widget.CardView
<androidx.cardview.widget.CardView
android:id="@+id/fab_card"
android:layout_width="@dimen/fab_size"
android:layout_height="@dimen/fab_size"
Expand All @@ -12,7 +12,7 @@
app:cardCornerRadius="@dimen/fab_radius"
app:cardPreventCornerOverlap="false"
style="@style/fab_card"
>
>

<LinearLayout
android:id="@+id/fab_icon_wrapper"
Expand All @@ -21,8 +21,8 @@
android:layout_margin="@dimen/fab_icon_margin"
android:gravity="center"
android:orientation="horizontal"
/>
/>

</android.support.v7.widget.CardView>
</androidx.cardview.widget.CardView>

</merge>
Loading

0 comments on commit 86a34fa

Please sign in to comment.