Skip to content

Commit 25768b7

Browse files
committed
新增arcTickOffsetAngle属性
1 parent 5580c7d commit 25768b7

File tree

11 files changed

+143
-33
lines changed

11 files changed

+143
-33
lines changed

README.md

Lines changed: 23 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
[![Download](https://img.shields.io/badge/download-App-blue.svg)](https://raw.githubusercontent.com/jenly1314/ArcSeekBar/master/app/release/app-release.apk)
44
[![JCenter](https://img.shields.io/badge/JCenter-1.0.2-46C018.svg)](https://bintray.com/beta/#/jenly/maven/arcseekbar)
5+
[![MavenCentral](https://img.shields.io/maven-central/v/com.github.jenly1314/arcseekbar)](https://repo1.maven.org/maven2/com/github/jenly1314/arcseekbar)
56
[![JitPack](https://jitpack.io/v/jenly1314/ArcSeekBar.svg)](https://jitpack.io/#jenly1314/ArcSeekBar)
67
[![CI](https://travis-ci.org/jenly1314/ArcSeekBar.svg?branch=master)](https://travis-ci.org/jenly1314/ArcSeekBar)
78
[![CircleCI](https://circleci.com/gh/jenly1314/ArcSeekBar.svg?style=svg)](https://circleci.com/gh/jenly1314/ArcSeekBar)
@@ -47,6 +48,7 @@ ArcSeekBar for Android 是一个弧形的拖动条进度控件,配置参数完
4748
| arcTickPadding | dimension | 2dp | 环刻度与环间距 |
4849
| arcTickSplitAngle | integer | 5 | 刻度间隔的角度大小 |
4950
| arcBlockAngle | integer | 1 | 刻度的角度大小 |
51+
| arcTickOffsetAngle | integer | 0 | 刻度偏移的角度大小 |
5052
| arcThumbStrokeWidth | dimension |8dp| 拖动按钮描边宽度 |
5153
| arcThumbColor | color |<font color=#E8D30F>#FFE8D30F</font>| 拖动按钮颜色 |
5254
| arcThumbRadius | dimension |10dp| 拖动按钮半径 |
@@ -58,36 +60,32 @@ ArcSeekBar for Android 是一个弧形的拖动条进度控件,配置参数完
5860

5961
## 引入
6062

61-
### Maven:
62-
```maven
63-
<dependency>
64-
<groupId>com.king.view</groupId>
65-
<artifactId>arcseekbar</artifactId>
66-
<version>1.0.2</version>
67-
<type>pom</type>
68-
</dependency>
69-
```
7063
### Gradle:
71-
```gradle
72-
implementation 'com.king.view:arcseekbar:1.0.2'
73-
```
7464

75-
### Lvy:
76-
```lvy
77-
<dependency org='com.king.view' name='arcseekbar' rev='1.0.2'>
78-
<artifact name='$AID' ext='pom'></artifact>
79-
</dependency>
80-
```
81-
82-
###### 如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
65+
1. 在Project的 **build.gradle** 里面添加远程仓库
66+
8367
```gradle
8468
allprojects {
8569
repositories {
86-
maven { url 'https://dl.bintray.com/jenly/maven' }
70+
//...
71+
mavenCentral()
8772
}
8873
}
8974
```
9075

76+
2. 在Module的 **build.gradle** 里面添加引入依赖项
77+
```gradle
78+
implementation 'com.github.jenly1314:arcseekbar:1.0.3'
79+
80+
```
81+
82+
83+
以前发布至JCenter的版本
84+
```gradle
85+
implementation 'com.king.view:arcseekbar:1.0.2'
86+
```
87+
88+
9189
## 示例
9290

9391
布局示例
@@ -113,6 +111,10 @@ allprojects {
113111

114112
## 版本记录
115113

114+
#### v1.0.3:2021-9-1 (从v1.0.3开始发布至 MavenCentral)
115+
* 对外暴露更多getter和setter方法
116+
* 新增arcTickOffsetAngle属性
117+
116118
#### v1.0.2:2020-12-2
117119
* 优化设置渐变色过程处理
118120

app/release/app-release.apk

292 Bytes
Binary file not shown.

app/release/output.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":3,"versionName":"1.0.2","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]
1+
[{"outputType":{"type":"APK"},"apkData":{"type":"MAIN","splits":[],"versionCode":4,"versionName":"1.0.3","enabled":true,"outputFile":"app-release.apk","fullName":"release","baseName":"release","dirName":""},"path":"app-release.apk","properties":{}}]

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
app:arcStartAngle="155"
1515
app:arcSweepAngle="230"
1616
app:arcLabelPaddingBottom="10dp"
17+
app:arcTickOffsetAngle="3"
1718
app:layout_constraintLeft_toLeftOf="parent"
1819
app:layout_constraintRight_toRightOf="parent"
1920
app:layout_constraintTop_toTopOf="parent" />

arcseekbar/build.gradle

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
apply plugin: 'com.android.library'
2-
apply from: 'bintray.gradle'
2+
//apply from: 'bintray.gradle'
3+
apply plugin: "com.vanniktech.maven.publish"
34

45
android {
56

arcseekbar/gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
POM_NAME=ArcSeekBar
2+
POM_ARTIFACT_ID=arcseekbar
3+
POM_PACKAGING=aar

arcseekbar/src/main/java/com/king/view/arcseekbar/ArcSeekBar.java

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,11 @@ public class ArcSeekBar extends View {
107107
*/
108108
private float mBlockAngle = 1;
109109

110+
/**
111+
* 刻度偏移的角度大小
112+
*/
113+
private float mTickOffsetAngle = 0;
114+
110115
/**
111116
* 总刻度数
112117
*/
@@ -320,6 +325,8 @@ private void init(Context context,AttributeSet attrs){
320325
mTickSplitAngle = a.getInt(attr,5);
321326
}else if(attr == R.styleable.ArcSeekBar_arcBlockAngle){
322327
mBlockAngle = a.getInt(attr,1);
328+
}else if(attr == R.styleable.ArcSeekBar_arcTickOffsetAngle){
329+
mTickOffsetAngle = a.getInt(attr,0);
323330
}else if(attr == R.styleable.ArcSeekBar_arcThumbStrokeWidth){
324331
mThumbStrokeWidth = a.getDimension(attr,mThumbStrokeWidth);
325332
}else if(attr == R.styleable.ArcSeekBar_arcThumbColor){
@@ -464,14 +471,14 @@ private void drawArc(Canvas canvas){
464471
mPaint.setColor(mProgressColor);
465472
}
466473
//绘制刻度
467-
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle, mBlockAngle, false, mPaint);
474+
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle + mTickOffsetAngle, mBlockAngle, false, mPaint);
468475
} else {
469476
if(mNormalColor != 0){
470477
//未选中的刻度
471478
mPaint.setShader(null);
472479
mPaint.setColor(mNormalColor);
473480
//绘制刻度
474-
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle, mBlockAngle, false, mPaint);
481+
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle + mTickOffsetAngle, mBlockAngle, false, mPaint);
475482
}
476483
}
477484
}
@@ -545,9 +552,9 @@ private void drawText(Canvas canvas){
545552
mTextPaint.setTextAlign(Paint.Align.CENTER);
546553

547554
Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
548-
// 计算文字高度 
555+
// 计算文字高度
549556
float fontHeight = fontMetrics.bottom - fontMetrics.top;
550-
// 计算文字baseline 
557+
// 计算文字baseline
551558
float textBaseX = getWidth() / 2 + mLabelPaddingLeft - mLabelPaddingRight;
552559
float textBaseY = getHeight() - (getHeight() - fontHeight) / 2 - fontMetrics.bottom + mLabelPaddingTop - mLabelPaddingBottom;
553560
if(isShowPercentText){//是否显示百分比
@@ -906,7 +913,6 @@ public float getThumbCenterY() {
906913
return mThumbCenterY;
907914
}
908915

909-
910916
public float getAllowableOffsets() {
911917
return mAllowableOffsets;
912918
}
@@ -915,6 +921,53 @@ public boolean isEnabledDrag() {
915921
return isEnabledDrag;
916922
}
917923

924+
public boolean isEnabledSingle() {
925+
return isEnabledSingle;
926+
}
927+
928+
public boolean isShowPercentText() {
929+
return isShowPercentText;
930+
}
931+
932+
public boolean isShowTick() {
933+
return isShowTick;
934+
}
935+
936+
public boolean isShowThumb() {
937+
return isShowThumb;
938+
}
939+
940+
941+
public float getThumbRadiusEnlarges() {
942+
return mThumbRadiusEnlarges;
943+
}
944+
945+
/**
946+
* 触摸时按钮半径放大量
947+
* @param thumbRadiusEnlarges
948+
*/
949+
public void setThumbRadiusEnlarges(float thumbRadiusEnlarges) {
950+
this.mThumbRadiusEnlarges = thumbRadiusEnlarges;
951+
}
952+
953+
/**
954+
* 是否默认显示百分比为标签文字
955+
* @param showPercentText
956+
*/
957+
public void setShowPercentText(boolean showPercentText) {
958+
isShowPercentText = showPercentText;
959+
invalidate();
960+
}
961+
962+
/**
963+
* 是否显示拖动按钮
964+
* @param showThumb
965+
*/
966+
public void setShowThumb(boolean showThumb) {
967+
isShowThumb = showThumb;
968+
invalidate();
969+
}
970+
918971
/**
919972
* 触摸时可偏移距离:偏移量越大,触摸精度越小
920973
* @param allowableOffsets
@@ -925,12 +978,21 @@ public void setAllowableOffsets(float allowableOffsets) {
925978

926979
/**
927980
* 是否启用拖拽
928-
* @param enabledDrag 默认为true,为false时 相当于{@link android.widget.ProgressBar}
981+
* @param enabledDrag 默认为 true,为 false 时 相当于{@link android.widget.ProgressBar}
929982
*/
930983
public void setEnabledDrag(boolean enabledDrag) {
931984
isEnabledDrag = enabledDrag;
932985
}
933986

987+
988+
/**
989+
* 设置是否启用点击改变进度
990+
* @param enabledSingle
991+
*/
992+
public void setEnabledSingle(boolean enabledSingle){
993+
isEnabledSingle = enabledSingle;
994+
}
995+
934996
/**
935997
* 设置中间文本标签内间距
936998
* @param left
@@ -1032,9 +1094,27 @@ public void setOnChangeListener(OnChangeListener onChangeListener){
10321094

10331095

10341096
public interface OnChangeListener{
1097+
/**
1098+
* 跟踪触摸事件开始时回调此方法 {@link MotionEvent#ACTION_DOWN}
1099+
* @param isCanDrag
1100+
*/
10351101
void onStartTrackingTouch(boolean isCanDrag);
1102+
1103+
/**
1104+
* 进度改变时回调此方法
1105+
* @param progress
1106+
* @param max
1107+
* @param fromUser
1108+
*/
10361109
void onProgressChanged(float progress, float max, boolean fromUser);
1110+
/**
1111+
* 跟踪触摸事件停止时回调此方法 {@link MotionEvent#ACTION_UP}
1112+
*/
10371113
void onStopTrackingTouch(boolean isCanDrag);
1114+
1115+
/**
1116+
* 通过点击事件改变进度后回调此方法 {@link GestureDetector#GestureDetector#onSingleTapUp()}
1117+
*/
10381118
void onSingleTapUp();
10391119
}
10401120

arcseekbar/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<attr name="arcTickPadding" format="dimension"/>
2929
<attr name="arcTickSplitAngle" format="integer"/>
3030
<attr name="arcBlockAngle" format="integer"/>
31+
<attr name="arcTickOffsetAngle" format="integer"/>
3132
<attr name="arcThumbStrokeWidth" format="dimension"/>
3233
<attr name="arcThumbColor" format="color"/>
3334
<attr name="arcThumbRadius" format="dimension"/>

build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ buildscript {
88

99
}
1010
dependencies {
11-
classpath 'com.android.tools.build:gradle:3.6.1'
12-
classpath 'com.novoda:bintray-release:0.9.2'
11+
classpath "com.android.tools.build:gradle:$versions.gradle"
12+
// classpath 'com.novoda:bintray-release:0.9.2'
13+
classpath "com.vanniktech:gradle-maven-publish-plugin:$versions.mavenPublish"
1314

1415
// NOTE: Do not place your application dependencies here; they belong
1516
// in the individual module build.gradle files

gradle.properties

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,22 @@ android.useAndroidX=true
1818
# Automatically convert third-party libraries to use AndroidX
1919
android.enableJetifier=true
2020

21+
VERSION_NAME=1.0.3
22+
VERSION_CODE=4
23+
GROUP=com.github.jenly1314
24+
25+
POM_DESCRIPTION=ArcSeekBar for Android
26+
POM_URL=https://github.com/jenly1314/ArcSeekBar
27+
POM_SCM_URL=https://github.com/jenly1314/ArcSeekBar
28+
POM_SCM_CONNECTION=scm:[email protected]:jenly1314/ArcSeekBar.git
29+
POM_SCM_DEV_CONNECTION=scm:[email protected]:jenly1314/ArcSeekBar.git
30+
#POM_LICENCE_NAME=The MIT License
31+
#POM_LICENCE_URL=https://opensource.org/licenses/mit-license.php
32+
POM_LICENCE_NAME=The Apache Software License, Version 2.0
33+
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
34+
POM_DEVELOPER_ID=jenly
35+
POM_DEVELOPER_NAME=Jenly Yu
36+
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
37+
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
38+
RELEASE_SIGNING_ENABLED=false
39+

0 commit comments

Comments
 (0)