Skip to content

Commit

Permalink
Merge branch 'release-1.3.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
markormesher committed May 25, 2017
2 parents 0aa867d + c971732 commit 4425f3b
Show file tree
Hide file tree
Showing 16 changed files with 234 additions and 122 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Some of the component views that make up the FAB can be accessed (useful for pos
|Method | Description|
|:--- | :---|
|`RelativeLayout getFabContainer()` | Gets the container layout used for the whole FAB arrangement.|
|`CardView getCardView()` | Gets the `CardView` used for the actual "button" of the FAB.|
|`ViewGroup getButton()` | Gets the `ViewGroup` used for the actual "button" of the FAB. On SDK >= 21 this can be safely cast to `CardView`.|

### Speed-Dial Menus

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

dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
Expand All @@ -13,8 +13,8 @@ buildscript {
}

def version = new Properties()
version['code'] = 9
version['name'] = '1.2.1'
version['code'] = 10
version['name'] = '1.3.0'

def secrets = getSecrets()

Expand All @@ -28,14 +28,14 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion "25.0.3"

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

minSdkVersion 12
targetSdkVersion 23
targetSdkVersion 25

versionCode version['code']
versionName version['name']
Expand Down Expand Up @@ -88,8 +88,8 @@ repositories {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.android.support:appcompat-v7:25.3.1'
compile project(':fab')

androidTestCompile 'junit:junit:4.12'
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.2.2'
}
}

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

dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
classpath 'com.android.tools.build:gradle:2.2.2'
classpath 'me.tatarka:gradle-retrolambda:3.2.3'
classpath 'me.tatarka.retrolambda.projectlombok:lombok.ast:0.2.3.a2'
}
Expand All @@ -13,8 +13,8 @@ buildscript {
}

def version = new Properties()
version['code'] = 9
version['name'] = '1.2.1'
version['code'] = 10
version['name'] = '1.3.0'

apply plugin: 'me.tatarka.retrolambda'

Expand All @@ -26,12 +26,12 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}

compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 25
buildToolsVersion "25.0.3"

defaultConfig {
minSdkVersion 12
targetSdkVersion 23
targetSdkVersion 25

testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Expand All @@ -43,8 +43,8 @@ repositories {

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:support-annotations:23.1.1'
compile 'com.android.support:cardview-v7:23.2.0'
compile 'com.android.support:support-annotations:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'

androidTestCompile 'junit:junit:4.12'
androidTestCompile 'org.hamcrest:hamcrest-library:1.3'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
Expand Down Expand Up @@ -51,7 +52,7 @@ public FloatingActionButton(Context context, AttributeSet attrs, int defStyleAtt
*==============*/

private RelativeLayout fabContainer;
private CardView cardView;
private ViewGroup button;
private ViewGroup iconContainer;
private View coverView;

Expand All @@ -66,17 +67,17 @@ private void initView() {

// collect views
fabContainer = (RelativeLayout) findViewById(R.id.fab_container);
cardView = (CardView) findViewById(R.id.card);
button = (ViewGroup) findViewById(R.id.card);
iconContainer = (ViewGroup) findViewById(R.id.icon_container);
coverView = findViewById(R.id.cover);

// fade out the cover
coverView.setAlpha(0F);

// clicks
cardView.setClickable(true);
cardView.setFocusable(true);
cardView.setOnClickListener(v -> onClick());
button.setClickable(true);
button.setFocusable(true);
button.setOnClickListener(v -> onClick());

// make sure Android knows we want to save this state
setSaveEnabled(true);
Expand Down Expand Up @@ -147,7 +148,11 @@ private void resetIcon() {
*/
public void setBackgroundColour(int colour) {
savedBgColour = colour;
cardView.setCardBackgroundColor(colour);
if (Build.VERSION.SDK_INT >= 21) {
((CardView) button).setCardBackgroundColor(colour);
} else {
((GradientDrawable) button.getBackground()).setColor(colour);
}
}

/**
Expand All @@ -166,15 +171,15 @@ private void hide(boolean fast) {
if (!shown && !fast) return;

closeSpeedDialMenu();
cardView.clearAnimation();
cardView.animate()
button.clearAnimation();
button.animate()
.scaleX(0F)
.scaleY(0F)
.setDuration(fast ? 0 : HIDE_SHOW_ANIMATION_DURATION)
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
cardView.setVisibility(GONE);
button.setVisibility(GONE);
shown = false;
}
});
Expand All @@ -186,9 +191,9 @@ public void onAnimationEnd(Animator animation) {
public void show() {
if (shown) return;

cardView.setVisibility(VISIBLE);
cardView.clearAnimation();
cardView.animate()
button.setVisibility(VISIBLE);
button.clearAnimation();
button.animate()
.scaleX(1F)
.scaleY(1F)
.setDuration(HIDE_SHOW_ANIMATION_DURATION)
Expand All @@ -215,18 +220,30 @@ public boolean isShown() {

/**
* Gets the container layout used for the whole FAB arrangement.
*
* @return the container layout used for the whole FAB arrangement
*/
public RelativeLayout getFabContainer() {
return fabContainer;
}

/**
* Gets the {@code CardView} used for the actual "button" of the FAB.
* @return the {@code CardView} used for the actual "button" of the FAB
* Gets the {@code ViewGroup} used for the actual "button" of the FAB.
*
* @return the {@code ViewGroup} used for the actual "button" of the FAB
* @deprecated Use {@code getButton()} instead.
*/
public CardView getCardView() {
return cardView;
public ViewGroup getCardView() {
return getButton();
}

/**
* Gets the {@code ViewGroup} used for the actual "button" of the FAB.
*
* @return the {@code ViewGroup} used for the actual "button" of the FAB
*/
public ViewGroup getButton() {
return button;
}

/*=============*
Expand Down Expand Up @@ -340,7 +357,11 @@ public void rebuildSpeedDialMenu() {
speedDialMenuItems.add(view);

// set background colour
((CardView) view.findViewById(R.id.card)).setCardBackgroundColor(menuAdapter.getBackgroundColour(i));
if (Build.VERSION.SDK_INT >= 21) {
((CardView) view.findViewById(R.id.card)).setCardBackgroundColor(menuAdapter.getBackgroundColour(i));
} else {
((GradientDrawable) view.findViewById(R.id.card).getBackground()).setColor(menuAdapter.getBackgroundColour(i));
}

// get child views
SpeedDialMenuAdapter.MenuItem itemViews = menuAdapter.getViews(getContext(), i);
Expand Down Expand Up @@ -474,7 +495,7 @@ private void setSpeedDialCoverVisible(boolean visible) {
coverView.animate()
.scaleX(visible ? 50F : 0F)
.scaleY(visible ? 50F : 0F)
.alpha(visible ? 1F : 0F)
//.alpha(visible ? 1F : 0F)
.setDuration(SPEED_DIAL_ANIMATION_DURATION)
.setListener(new AnimatorListenerAdapter() {
@Override
Expand All @@ -495,7 +516,7 @@ private void setSpeedDialMenuVisible(final boolean visible) {
busyAnimatingSpeedDialMenu = true;

// animate, setting visibility as well to prevent phantom clicks
int distance = cardView.getHeight();
int distance = button.getHeight();
for (int i = 0, n = speedDialMenuItems.size(); i < n; ++i) {
final View v = speedDialMenuItems.get(i);
if (visible) v.setVisibility(VISIBLE);
Expand Down Expand Up @@ -559,4 +580,4 @@ protected void onRestoreInstanceState(Parcelable state) {
}
super.onRestoreInstanceState(state);
}
}
}
8 changes: 8 additions & 0 deletions fab/src/main/res/drawable/circle_background.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid android:color="#3f51b5"/>

</shape>
6 changes: 3 additions & 3 deletions fab/src/main/res/drawable/fab_cover_circle.xml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">

<solid android:color="#99ffffff"/>

</shape>
</shape>
29 changes: 29 additions & 0 deletions fab/src/main/res/layout-v21/floating_action_button_inner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>

<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="@dimen/fab_size"
android:layout_height="@dimen/fab_size"
android:layout_margin="@dimen/fab_padding"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
app:cardElevation="6dp"
app:cardCornerRadius="@dimen/fab_radius"
app:cardPreventCornerOverlap="false"
style="@style/fab_card"
>

<LinearLayout
android:id="@+id/icon_container"
android:layout_width="@dimen/fab_icon_size"
android:layout_height="@dimen/fab_icon_size"
android:layout_margin="@dimen/fab_icon_margin"
android:gravity="center"
android:orientation="horizontal"
/>

</android.support.v7.widget.CardView>
</merge>
27 changes: 27 additions & 0 deletions fab/src/main/res/layout-v21/speed_dial_icon_inner.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<merge
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
>

<android.support.v7.widget.CardView
android:id="@+id/card"
android:layout_width="@dimen/speed_dial_disc_size"
android:layout_height="@dimen/speed_dial_disc_size"
android:layout_margin="@dimen/speed_dial_disc_padding"
app:cardElevation="2dp"
app:cardCornerRadius="@dimen/speed_dial_disc_radius"
app:cardPreventCornerOverlap="false"
style="@style/speed_dial_item_card"
>

<LinearLayout
android:id="@+id/icon_container"
android:layout_width="@dimen/speed_dial_disc_icon_size"
android:layout_height="@dimen/speed_dial_disc_icon_size"
android:layout_margin="@dimen/speed_dial_disc_icon_margin"
android:gravity="center"
android:orientation="vertical"
/>

</android.support.v7.widget.CardView>
</merge>
Loading

0 comments on commit 4425f3b

Please sign in to comment.