diff --git a/build.gradle b/build.gradle index 4d8e12c..e1dadaf 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:0.14.2' + classpath 'com.android.tools.build:gradle:1.0.0' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9abc27d..ac9b0bb 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Thu Jan 01 15:09:54 EET 2015 +#Thu Jan 08 13:08:07 CET 2015 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip diff --git a/library/src/main/java/com/dd/processbutton/FlatButton.java b/library/src/main/java/com/dd/processbutton/FlatButton.java index 24ad18a..09c1415 100644 --- a/library/src/main/java/com/dd/processbutton/FlatButton.java +++ b/library/src/main/java/com/dd/processbutton/FlatButton.java @@ -65,9 +65,19 @@ private void initAttributes(Context context, AttributeSet attributeSet) { } } - private LayerDrawable createNormalDrawable(TypedArray attr) { + private Drawable createNormalDrawable(TypedArray attr) { + Drawable drawableNormal; + if (attr.getBoolean(R.styleable.FlatButton_pb_hasBottom, true)) { + drawableNormal = createLayeredNormalDrawable(attr); + } else { + drawableNormal = createGradientNormalDrawable(attr); + } + return drawableNormal; + } + + private Drawable createLayeredNormalDrawable(TypedArray attr) { LayerDrawable drawableNormal = - (LayerDrawable) getDrawable(R.drawable.rect_normal).mutate(); + (LayerDrawable) getDrawable(R.drawable.rect_normal_with_bottom).mutate(); GradientDrawable drawableTop = (GradientDrawable) drawableNormal.getDrawable(0).mutate(); @@ -87,6 +97,18 @@ private LayerDrawable createNormalDrawable(TypedArray attr) { return drawableNormal; } + private Drawable createGradientNormalDrawable(TypedArray attr) { + GradientDrawable drawableNormal = + (GradientDrawable) getDrawable(R.drawable.rect_normal).mutate(); + drawableNormal.setCornerRadius(getCornerRadius()); + + int blueNormal = getColor(R.color.blue_normal); + int colorNormal = attr.getColor(R.styleable.FlatButton_pb_colorNormal, blueNormal); + drawableNormal.setColor(colorNormal); + + return drawableNormal; + } + private Drawable createPressedDrawable(TypedArray attr) { GradientDrawable drawablePressed = (GradientDrawable) getDrawable(R.drawable.rect_pressed).mutate(); diff --git a/library/src/main/res/drawable/rect_normal.xml b/library/src/main/res/drawable/rect_normal.xml index f665149..e2d3b8c 100644 --- a/library/src/main/res/drawable/rect_normal.xml +++ b/library/src/main/res/drawable/rect_normal.xml @@ -1,17 +1,7 @@ - - - - - - - - - - - - - - - \ No newline at end of file + + + + \ No newline at end of file diff --git a/library/src/main/res/drawable/rect_normal_with_bottom.xml b/library/src/main/res/drawable/rect_normal_with_bottom.xml new file mode 100644 index 0000000..f665149 --- /dev/null +++ b/library/src/main/res/drawable/rect_normal_with_bottom.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml index 4bddb0a..0491e81 100644 --- a/library/src/main/res/values/styles.xml +++ b/library/src/main/res/values/styles.xml @@ -9,6 +9,7 @@ + diff --git a/sample/build.gradle b/sample/build.gradle index a316b3c..f5c4cfa 100644 --- a/sample/build.gradle +++ b/sample/build.gradle @@ -43,9 +43,11 @@ android { } applicationVariants.all { variant -> - def oldFile = variant.outputFile - def newPath = "${variant.name}" + "_" + "${variant.versionName}" + "_" + "${variant.versionCode}" + "_" + getDate() + ".apk"; - variant.outputFile = new File(oldFile.parentFile, newPath) + variant.outputs.each { output -> + def oldFile = output.outputFile + def newPath = "${variant.name}" + "_" + "${variant.versionName}" + "_" + "${variant.versionCode}" + "_" + getDate() + ".apk"; + output.outputFile = new File(oldFile.parentFile, newPath) + } } }