Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android visibility flag #48

Merged
merged 6 commits into from
Feb 23, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>
6 changes: 4 additions & 2 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 Down
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>
10 changes: 5 additions & 5 deletions fab/src/main/res/layout-v21/menu_item_icon.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/menu_item_card"
android:layout_width="@dimen/speed_dial_disc_size"
android:layout_height="@dimen/speed_dial_disc_size"
Expand All @@ -12,7 +12,7 @@
app:cardCornerRadius="@dimen/speed_dial_disc_radius"
app:cardPreventCornerOverlap="false"
style="@style/speed_dial_item_card"
>
>

<LinearLayout
android:id="@+id/menu_item_icon_wrapper"
Expand All @@ -21,8 +21,8 @@
android:layout_margin="@dimen/speed_dial_disc_icon_margin"
android:gravity="center"
android:orientation="vertical"
/>
/>

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

</merge>
4 changes: 2 additions & 2 deletions fab/src/main/res/layout/fab_container.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
android:clipChildren="false"
android:clipToPadding="false"
android:padding="@dimen/fab_offset"
>
>

<View
android:id="@+id/content_cover"
Expand All @@ -20,7 +20,7 @@
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:background="@drawable/content_cover_circle"
/>
/>

<include layout="@layout/floating_action_button"/>

Expand Down
4 changes: 2 additions & 2 deletions fab/src/main/res/layout/floating_action_button.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
android:layout_height="@dimen/fab_size"
android:layout_margin="@dimen/fab_padding"
style="@style/fab_card"
>
>

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

</LinearLayout>

Expand Down
4 changes: 2 additions & 2 deletions fab/src/main/res/layout/menu_item.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
android:orientation="horizontal"
android:gravity="center_vertical"
android:padding="@dimen/speed_dial_disc_offset"
>
>

<TextView
android:id="@+id/menu_item_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
/>

<include layout="@layout/menu_item_icon"/>

Expand Down
Loading