From e8035c6121de96f0fd97bb59f10ff26743d7883e Mon Sep 17 00:00:00 2001 From: Oscar Salguero Date: Thu, 2 Nov 2017 12:32:59 -0400 Subject: [PATCH 1/2] chore: Upgraded gradle and build tools version and support library version to the latest ones and increased app and library version codes to 2 and versions to 1.1 --- FitChart/build.gradle | 8 ++++---- app/build.gradle | 10 +++++----- build.gradle | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/FitChart/build.gradle b/FitChart/build.gradle index 41ad21d..7445438 100644 --- a/FitChart/build.gradle +++ b/FitChart/build.gradle @@ -35,13 +35,13 @@ Properties properties = new Properties() properties.load(project.rootProject.file('local.properties').newDataInputStream()) android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion 27 + buildToolsVersion "27.0.0" defaultConfig { minSdkVersion 14 - targetSdkVersion 23 - versionCode 1 + targetSdkVersion 27 + versionCode 2 versionName version } buildTypes { diff --git a/app/build.gradle b/app/build.gradle index 5ad4190..07228e3 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -25,15 +25,15 @@ apply plugin: 'com.android.application' android { - compileSdkVersion 23 - buildToolsVersion "23.0.2" + compileSdkVersion 27 + buildToolsVersion "27.0.0" defaultConfig { applicationId "com.txusballesteros.widgets.app" minSdkVersion 14 - targetSdkVersion 23 - versionCode 1 - versionName "1.0" + targetSdkVersion 27 + versionCode 2 + versionName "1.1" } buildTypes { release { diff --git a/build.gradle b/build.gradle index 638d3de..735219d 100644 --- a/build.gradle +++ b/build.gradle @@ -30,15 +30,15 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.5.0' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' - classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' + classpath 'com.android.tools.build:gradle:3.0.0' + classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3' + classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5' } } allprojects { ext { - libraryVersion = '1.0' + libraryVersion = '1.1' mavenGroupId = 'com.txusballesteros' siteUrl = 'https://github.com/txusballesteros/fit-chart' gitUrl = 'https://github.com/txusballesteros/fit-chart.git' From 98079df49781dfebe6088fca5b1fb64f64e4d57e Mon Sep 17 00:00:00 2001 From: Oscar Salguero Date: Thu, 2 Nov 2017 12:33:53 -0400 Subject: [PATCH 2/2] feat: Added a new attribute to control the shape of the stroke cap, now you can set it as square or round very easily --- .../com/txusballesteros/widgets/FitChart.java | 10 ++++++- FitChart/src/main/res/values/attributes.xml | 4 +++ app/src/main/res/layout/activity_main.xml | 30 +++++++++---------- 3 files changed, 28 insertions(+), 16 deletions(-) diff --git a/FitChart/src/main/java/com/txusballesteros/widgets/FitChart.java b/FitChart/src/main/java/com/txusballesteros/widgets/FitChart.java index c35ad87..bad58e9 100644 --- a/FitChart/src/main/java/com/txusballesteros/widgets/FitChart.java +++ b/FitChart/src/main/java/com/txusballesteros/widgets/FitChart.java @@ -52,12 +52,15 @@ public class FitChart extends View { static final float INITIAL_ANIMATION_PROGRESS = 0.0f; static final float MAXIMUM_SWEEP_ANGLE = 360f; static final int DESIGN_MODE_SWEEP_ANGLE = 216; + static final int STROKE_CAP_ROUND = 0; + static final int STROKE_CAP_SQUARE = 1; private RectF drawingArea; private Paint backStrokePaint; private Paint valueDesignPaint; private int backStrokeColor; private int valueStrokeColor; private float strokeSize; + private int strokeCap; private float minValue = DEFAULT_MIN_VALUE; private float maxValue = DEFAULT_MAX_VALUE; private List chartValues; @@ -121,7 +124,11 @@ private Paint buildPaintForValue() { Paint paint = getPaint(); paint.setStyle(Paint.Style.STROKE); paint.setStrokeWidth(strokeSize); - paint.setStrokeCap(Paint.Cap.ROUND); + if (strokeCap == STROKE_CAP_SQUARE) { + paint.setStrokeCap(Paint.Cap.SQUARE); + } else { + paint.setStrokeCap(Paint.Cap.ROUND); + } return paint; } @@ -176,6 +183,7 @@ private void readAttributes(AttributeSet attrs) { .getTheme().obtainStyledAttributes(attrs, R.styleable.FitChart, 0, 0); strokeSize = attributes .getDimensionPixelSize(R.styleable.FitChart_strokeSize, (int) strokeSize); + strokeCap = attributes.getInt(R.styleable.FitChart_strokeCap, strokeCap); valueStrokeColor = attributes .getColor(R.styleable.FitChart_valueStrokeColor, valueStrokeColor); backStrokeColor = attributes diff --git a/FitChart/src/main/res/values/attributes.xml b/FitChart/src/main/res/values/attributes.xml index e547224..1d745c5 100644 --- a/FitChart/src/main/res/values/attributes.xml +++ b/FitChart/src/main/res/values/attributes.xml @@ -26,6 +26,10 @@ + + + + diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 187b381..abc96dd 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -1,5 +1,4 @@ - -