Skip to content
Open
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
17 changes: 17 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
*.iml
.gradle
/local.properties
/.idea/workspace.xml
/.idea/libraries
.DS_Store
/build
/tmp
/captures
.externalNativeBuild
app/link
*.log
.idea/codeStyles/Project.xml
.idea/statistic.xml
app/fabric.properties
.idea/caches/build_file_checksums.ser
*.ser
4 changes: 3 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
classpath 'com.android.tools.build:gradle:3.1.3'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand All @@ -15,5 +16,6 @@ buildscript {
allprojects {
repositories {
jcenter()
google()
}
}
14 changes: 7 additions & 7 deletions decoviewlib/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.library'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 27
buildToolsVersion "27.0.3"

defaultConfig {
minSdkVersion 8
targetSdkVersion 23
minSdkVersion 14
targetSdkVersion 27
versionCode 10
versionName "1.2"
}
Expand All @@ -24,7 +24,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile 'com.nineoldandroids:library:2.4.0'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.nineoldandroids:library:2.4.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.util.AttributeSet;
import android.util.Log;
import android.view.View;

import com.hookedonplay.decoviewlib.charts.ChartSeries;
import com.hookedonplay.decoviewlib.charts.DecoDrawEffect;
import com.hookedonplay.decoviewlib.charts.LineArcSeries;
Expand Down Expand Up @@ -348,24 +349,20 @@ protected void onDraw(Canvas canvas) {

if (mChartSeries != null) {
boolean labelsSupported = true;

for (int i = 0; i < mChartSeries.size(); i++) {
ChartSeries chartSeries = mChartSeries.get(i);
chartSeries.draw(canvas, mArcBounds);
// labels Unsupported if one or more series run anticlockwise
labelsSupported &= (!chartSeries.isVisible() || chartSeries.getSeriesItem().getSpinClockwise());
// labelsSupported &= (!chartSeries.isVisible() || chartSeries.getSeriesItem().getSpinClockwise());
mMeasureViewableArea[i] = getLabelPosition(i);
}

// Draw the labels as a second pass as we want all labels to be on top of all
// series data
if (labelsSupported) {
for (int i = 0; i < mMeasureViewableArea.length; i++) {
if (mMeasureViewableArea[i] >= 0f) {
ChartSeries chartSeries = mChartSeries.get(i);
chartSeries.drawLabel(canvas, mArcBounds, mMeasureViewableArea[i]);
//TODO: Keep bounds of all labels and don't allow overlap
}
}
for (int i = 0; i < mChartSeries.size(); i++) {
ChartSeries chartSeries = mChartSeries.get(i);
chartSeries.drawLabel(canvas, chartSeries.mBoundsInset, 100f);
}
}
}
Expand All @@ -391,7 +388,7 @@ private float getLabelPosition(final int index) {

if (max < chartSeries.getPositionPercent()) {
// Adjust for incomplete circles
float adjusted = ((chartSeries.getPositionPercent() + max) / 2) * ((float) mTotalAngle / 360f);
float adjusted = ((chartSeries.getPositionPercent())) * ((float) mTotalAngle / 360f);

// Adjust for rotation of start point
float adjust = adjusted + (((float) mRotateAngle + 90f) / 360f);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ abstract public class ChartSeries {
/**
* Drawing bounds for arc
*/
protected RectF mBounds;
public RectF mBounds;
/**
* Drawing bounds for arc after inset applied
*/
protected RectF mBoundsInset;
public RectF mBoundsInset;
/**
* Angle of drawing point origin.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,8 +130,8 @@ public RectF draw(@NonNull Canvas canvas, @NonNull RectF rect,
float radius = rect.width() / 2;
float radians = ((360f * percentAngle) - 90) * (float) (Math.PI / 180f);

float xVal = (float) Math.cos(radians) * radius + rect.centerX();
float yVal = (float) Math.sin(radians) * radius + rect.centerY();
float xVal = (float) Math.cos(radians) * radius + rect.left;
float yVal = (float) Math.sin(radians) * radius + rect.bottom;

final float halfWidth = (mTextBounds.width() / 2) + mBufferX;
final float halfHeight = (mTextBounds.height() / 2) + mBufferY;
Expand All @@ -153,11 +153,6 @@ public RectF draw(@NonNull Canvas canvas, @NonNull RectF rect,
xVal + halfWidth,
yVal + halfHeight);


canvas.drawRoundRect(
mTextDraw,
10f, 10f, mPaintBack);

yVal -= mTextCenter;
canvas.drawText(getDisplayString(percentComplete, positionValue), xVal, yVal, mPaintText);

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip
14 changes: 7 additions & 7 deletions sampleapp/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId 'com.hookedonplay.decoviewsample'
minSdkVersion 8
targetSdkVersion 23
minSdkVersion 14
targetSdkVersion 27
versionCode 10
versionName "1.2"
}
Expand All @@ -25,7 +25,7 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.3.0'
compile project(':decoviewlib')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation project(':decoviewlib')
}