From e63762d7d22c1974acf3d1614452cb3f3a2412b0 Mon Sep 17 00:00:00 2001 From: Anton Danshin Date: Wed, 29 Oct 2014 23:28:46 +0300 Subject: [PATCH] 0.1.1 - removed custom attributes to resolve possible attribute name conflicts --- README.md | 28 ++--------- gradle.properties | 2 +- main/build.gradle | 6 +-- main/src/main/AndroidManifest.xml | 2 +- .../controls/gauge/BatteryIndicatorGauge.java | 29 ++++++------ .../controls/gauge/SpeedometerGauge.java | 29 ++++++------ .../progress/CircularProgressBar.java | 47 +++++++++++-------- main/src/main/res/values/attrs.xml | 28 ----------- 8 files changed, 64 insertions(+), 107 deletions(-) diff --git a/README.md b/README.md index e059b46..7d4bea5 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ The labrary is available in maven repository. You can include your library in your **build.gradle**: ``` -compile 'com.cardiomood.android:android-widgets:0.1' +compile 'com.cardiomood.android:android-widgets:0.1.1' ``` If you are using Maven, add the following dependency to **pom.xml**: @@ -18,7 +18,7 @@ If you are using Maven, add the following dependency to **pom.xml**: com.cardiomood.android android-widgets - 0.1 + 0.1.1 aar ``` @@ -81,26 +81,4 @@ Configure SpeedometerGuge: speedometer.addColoredRange(140, 180, Color.YELLOW); speedometer.addColoredRange(180, 400, Color.RED); -``` - -### Version History - -**SpeedometerView 1.0.1** - -- added attribute labelTextSize -- text is drawn in dp (looks the same on all screens now) -- fixed needle artifact - -Download: [SpeedometerView-v1.0.1](https://github.com/ntoskrnl/SpeedometerView/releases/tag/SpeedometerView-v1.0.1) - -**SpeedometerView 1.0** - -Minimal Android SDK version: 9 (Android 2.3) - -**Supported features**: -- Major and minor tick marks -- Custom labels -- Colored value ranges -- Animation of arrow (*requires Android API level 11+*) - -Download: [SpeedometerView-v1.0](https://github.com/ntoskrnl/SpeedometerView/releases/tag/SpeedometerView-v1.0) +``` \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index ce3637a..719657f 100644 --- a/gradle.properties +++ b/gradle.properties @@ -17,7 +17,7 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true -VERSION_NAME=0.1 +VERSION_NAME=0.1.1 VERSION_CODE=1 GROUP=com.cardiomood.android diff --git a/main/build.gradle b/main/build.gradle index 86f83f0..f2fa860 100644 --- a/main/build.gradle +++ b/main/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.android.library' android { - compileSdkVersion 19 + compileSdkVersion 21 buildToolsVersion "20.0.0" defaultConfig { applicationId "com.cardiomood.android.controls" minSdkVersion 9 - targetSdkVersion 19 + targetSdkVersion 21 versionCode 1 - versionName "0.1" + versionName "0.1.1" } buildTypes { release { diff --git a/main/src/main/AndroidManifest.xml b/main/src/main/AndroidManifest.xml index 859a499..a626e5e 100644 --- a/main/src/main/AndroidManifest.xml +++ b/main/src/main/AndroidManifest.xml @@ -2,7 +2,7 @@ package="com.cardiomood.android.controls"> - + diff --git a/main/src/main/java/com/cardiomood/android/controls/gauge/BatteryIndicatorGauge.java b/main/src/main/java/com/cardiomood/android/controls/gauge/BatteryIndicatorGauge.java index a3fdf42..f115d0b 100644 --- a/main/src/main/java/com/cardiomood/android/controls/gauge/BatteryIndicatorGauge.java +++ b/main/src/main/java/com/cardiomood/android/controls/gauge/BatteryIndicatorGauge.java @@ -3,7 +3,6 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.BlurMaskFilter; @@ -75,20 +74,20 @@ public BatteryIndicatorGauge(Context context, AttributeSet attrs) { super(context, attrs); density = getResources().getDisplayMetrics().density; - TypedArray attributes = context.getTheme().obtainStyledAttributes( - attrs, - R.styleable.BatteryIndicatorGauge, - 0, 0); - - try { - // read attributes - setMax(attributes.getFloat(R.styleable.BatteryIndicatorGauge_max, (float) DEFAULT_MAX)); - setMin(attributes.getFloat(R.styleable.BatteryIndicatorGauge_min, (float) DEFAULT_MIN)); - setValue(attributes.getFloat(R.styleable.BatteryIndicatorGauge_value, DEFAULT_VALUE)); - setOrientation(attributes.getInt(R.styleable.BatteryIndicatorGauge_orientation, DEFAULT_ORIENTATION)); - } finally { - attributes.recycle(); - } +// TypedArray attributes = context.getTheme().obtainStyledAttributes( +// attrs, +// R.styleable.BatteryIndicatorGauge, +// 0, 0); +// +// try { +// // read attributes +// setMax(attributes.getFloat(R.styleable.BatteryIndicatorGauge_max, (float) DEFAULT_MAX)); +// setMin(attributes.getFloat(R.styleable.BatteryIndicatorGauge_min, (float) DEFAULT_MIN)); +// setValue(attributes.getFloat(R.styleable.BatteryIndicatorGauge_value, DEFAULT_VALUE)); +// setOrientation(attributes.getInt(R.styleable.BatteryIndicatorGauge_orientation, DEFAULT_ORIENTATION)); +// } finally { +// attributes.recycle(); +// } init(); } diff --git a/main/src/main/java/com/cardiomood/android/controls/gauge/SpeedometerGauge.java b/main/src/main/java/com/cardiomood/android/controls/gauge/SpeedometerGauge.java index 12e7e5e..8825138 100644 --- a/main/src/main/java/com/cardiomood/android/controls/gauge/SpeedometerGauge.java +++ b/main/src/main/java/com/cardiomood/android/controls/gauge/SpeedometerGauge.java @@ -4,7 +4,6 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.Canvas; @@ -67,20 +66,20 @@ public SpeedometerGauge(Context context) { public SpeedometerGauge(Context context, AttributeSet attrs) { super(context, attrs); - float density = getResources().getDisplayMetrics().density; - TypedArray attributes = context.getTheme().obtainStyledAttributes( - attrs, - R.styleable.SpeedometerGauge, - 0, 0); - - try { - // read attributes - setMaxSpeed(attributes.getFloat(R.styleable.SpeedometerGauge_maxSpeed, (float) DEFAULT_MAX_SPEED)); - setSpeed(attributes.getFloat(R.styleable.SpeedometerGauge_speed, 0)); - setLabelTextSize(attributes.getDimensionPixelSize(R.styleable.SpeedometerGauge_labelTextSize, Math.round(DEFAULT_LABEL_TEXT_SIZE_DP * density))); - } finally { - attributes.recycle(); - } +// float density = getResources().getDisplayMetrics().density; +// TypedArray attributes = context.getTheme().obtainStyledAttributes( +// attrs, +// R.styleable.SpeedometerGauge, +// 0, 0); +// +// try { +// // read attributes +// setMaxSpeed(attributes.getFloat(R.styleable.SpeedometerGauge_maxSpeed, (float) DEFAULT_MAX_SPEED)); +// setSpeed(attributes.getFloat(R.styleable.SpeedometerGauge_speed, 0)); +// setLabelTextSize(attributes.getDimensionPixelSize(R.styleable.SpeedometerGauge_labelTextSize, Math.round(DEFAULT_LABEL_TEXT_SIZE_DP * density))); +// } finally { +// attributes.recycle(); +// } init(); } diff --git a/main/src/main/java/com/cardiomood/android/controls/progress/CircularProgressBar.java b/main/src/main/java/com/cardiomood/android/controls/progress/CircularProgressBar.java index 9b7c318..47ffd9b 100644 --- a/main/src/main/java/com/cardiomood/android/controls/progress/CircularProgressBar.java +++ b/main/src/main/java/com/cardiomood/android/controls/progress/CircularProgressBar.java @@ -3,7 +3,6 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.content.Context; -import android.content.res.TypedArray; import android.graphics.Canvas; import android.graphics.Color; import android.graphics.Paint; @@ -11,8 +10,6 @@ import android.util.AttributeSet; import android.view.View; -import com.cardiomood.android.controls.R; - /** * Created by danon on 01.03.14. */ @@ -50,22 +47,34 @@ public CircularProgressBar(Context context, AttributeSet attrs) { super(context, attrs); density = getResources().getDisplayMetrics().density; - TypedArray attributes = context.getTheme().obtainStyledAttributes( - attrs, - R.styleable.CircularProgressBar, - 0, 0); - - try { - // read attributes - setMax(attributes.getFloat(R.styleable.CircularProgressBar_max, (float) DEFAULT_MAX)); - setMin(attributes.getFloat(R.styleable.CircularProgressBar_min, (float) DEFAULT_MIN)); - setProgress(attributes.getFloat(R.styleable.CircularProgressBar_progress, 0)); - setLineWidth(attributes.getDimensionPixelSize(R.styleable.CircularProgressBar_lineWidth, DEFAULT_LINE_WIDTH)); - setColor(attributes.getColor(R.styleable.CircularProgressBar_color, DEFAULT_COLOR)); - setTextSize(attributes.getDimensionPixelSize(R.styleable.CircularProgressBar_textSize, Math.round(DEFAULT_TEXT_SIZE * density))); - } finally { - attributes.recycle(); - } + textSize = DEFAULT_TEXT_SIZE*density; + +// density = getResources().getDisplayMetrics().density; +// TypedArray attributes = context.getTheme().obtainStyledAttributes( +// attrs, +// R.styleable.CircularProgressBar, +// 0, 0); +// +// try { +// // read attributes +// setMax(attributes.getFloat(R.styleable.CircularProgressBar_max, (float) DEFAULT_MAX)); +// setMin(attributes.getFloat(R.styleable.CircularProgressBar_min, (float) DEFAULT_MIN)); +// setProgress(attributes.getFloat(R.styleable.CircularProgressBar_progress, 0)); +// setLineWidth(attributes.getDimensionPixelSize(R.styleable.CircularProgressBar_lineWidth, DEFAULT_LINE_WIDTH)); +// setColor(attributes.getColor(R.styleable.CircularProgressBar_color, DEFAULT_COLOR)); +// setTextSize(attributes.getDimensionPixelSize(R.styleable.CircularProgressBar_textSize, Math.round(DEFAULT_TEXT_SIZE * density))); +// } finally { +// attributes.recycle(); +// } + + init(); + } + + public CircularProgressBar(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + + density = getResources().getDisplayMetrics().density; + textSize = DEFAULT_TEXT_SIZE*density; init(); } diff --git a/main/src/main/res/values/attrs.xml b/main/src/main/res/values/attrs.xml index 45c9d2e..0d2c4cc 100644 --- a/main/src/main/res/values/attrs.xml +++ b/main/src/main/res/values/attrs.xml @@ -1,32 +1,4 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file