Skip to content

Commit

Permalink
新增arcTickOffsetAngle属性
Browse files Browse the repository at this point in the history
  • Loading branch information
jenly1314 committed Sep 1, 2021
1 parent 5580c7d commit 25768b7
Show file tree
Hide file tree
Showing 11 changed files with 143 additions and 33 deletions.
44 changes: 23 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

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

## 引入

### Maven:
```maven
<dependency>
<groupId>com.king.view</groupId>
<artifactId>arcseekbar</artifactId>
<version>1.0.2</version>
<type>pom</type>
</dependency>
```
### Gradle:
```gradle
implementation 'com.king.view:arcseekbar:1.0.2'
```

### Lvy:
```lvy
<dependency org='com.king.view' name='arcseekbar' rev='1.0.2'>
<artifact name='$AID' ext='pom'></artifact>
</dependency>
```

###### 如果Gradle出现compile失败的情况,可以在Project的build.gradle里面添加如下:(也可以使用上面的GitPack来complie)
1. 在Project的 **build.gradle** 里面添加远程仓库

```gradle
allprojects {
repositories {
maven { url 'https://dl.bintray.com/jenly/maven' }
//...
mavenCentral()
}
}
```

2. 在Module的 **build.gradle** 里面添加引入依赖项
```gradle
implementation 'com.github.jenly1314:arcseekbar:1.0.3'
```


以前发布至JCenter的版本
```gradle
implementation 'com.king.view:arcseekbar:1.0.2'
```


## 示例

布局示例
Expand All @@ -113,6 +111,10 @@ allprojects {

## 版本记录

#### v1.0.3:2021-9-1 (从v1.0.3开始发布至 MavenCentral)
* 对外暴露更多getter和setter方法
* 新增arcTickOffsetAngle属性

#### v1.0.2:2020-12-2
* 优化设置渐变色过程处理

Expand Down
Binary file modified app/release/app-release.apk
Binary file not shown.
2 changes: 1 addition & 1 deletion app/release/output.json
Original file line number Diff line number Diff line change
@@ -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":{}}]
[{"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":{}}]
1 change: 1 addition & 0 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
app:arcStartAngle="155"
app:arcSweepAngle="230"
app:arcLabelPaddingBottom="10dp"
app:arcTickOffsetAngle="3"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent" />
Expand Down
3 changes: 2 additions & 1 deletion arcseekbar/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'
apply from: 'bintray.gradle'
//apply from: 'bintray.gradle'
apply plugin: "com.vanniktech.maven.publish"

android {

Expand Down
3 changes: 3 additions & 0 deletions arcseekbar/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
POM_NAME=ArcSeekBar
POM_ARTIFACT_ID=arcseekbar
POM_PACKAGING=aar
92 changes: 86 additions & 6 deletions arcseekbar/src/main/java/com/king/view/arcseekbar/ArcSeekBar.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,11 @@ public class ArcSeekBar extends View {
*/
private float mBlockAngle = 1;

/**
* 刻度偏移的角度大小
*/
private float mTickOffsetAngle = 0;

/**
* 总刻度数
*/
Expand Down Expand Up @@ -320,6 +325,8 @@ private void init(Context context,AttributeSet attrs){
mTickSplitAngle = a.getInt(attr,5);
}else if(attr == R.styleable.ArcSeekBar_arcBlockAngle){
mBlockAngle = a.getInt(attr,1);
}else if(attr == R.styleable.ArcSeekBar_arcTickOffsetAngle){
mTickOffsetAngle = a.getInt(attr,0);
}else if(attr == R.styleable.ArcSeekBar_arcThumbStrokeWidth){
mThumbStrokeWidth = a.getDimension(attr,mThumbStrokeWidth);
}else if(attr == R.styleable.ArcSeekBar_arcThumbColor){
Expand Down Expand Up @@ -464,14 +471,14 @@ private void drawArc(Canvas canvas){
mPaint.setColor(mProgressColor);
}
//绘制刻度
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle, mBlockAngle, false, mPaint);
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle + mTickOffsetAngle, mBlockAngle, false, mPaint);
} else {
if(mNormalColor != 0){
//未选中的刻度
mPaint.setShader(null);
mPaint.setColor(mNormalColor);
//绘制刻度
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle, mBlockAngle, false, mPaint);
canvas.drawArc(rectF, i * (mBlockAngle + mTickSplitAngle) + mStartAngle + mTickOffsetAngle, mBlockAngle, false, mPaint);
}
}
}
Expand Down Expand Up @@ -545,9 +552,9 @@ private void drawText(Canvas canvas){
mTextPaint.setTextAlign(Paint.Align.CENTER);

Paint.FontMetrics fontMetrics = mTextPaint.getFontMetrics();
// 计算文字高度 
// 计算文字高度
float fontHeight = fontMetrics.bottom - fontMetrics.top;
// 计算文字baseline 
// 计算文字baseline
float textBaseX = getWidth() / 2 + mLabelPaddingLeft - mLabelPaddingRight;
float textBaseY = getHeight() - (getHeight() - fontHeight) / 2 - fontMetrics.bottom + mLabelPaddingTop - mLabelPaddingBottom;
if(isShowPercentText){//是否显示百分比
Expand Down Expand Up @@ -906,7 +913,6 @@ public float getThumbCenterY() {
return mThumbCenterY;
}


public float getAllowableOffsets() {
return mAllowableOffsets;
}
Expand All @@ -915,6 +921,53 @@ public boolean isEnabledDrag() {
return isEnabledDrag;
}

public boolean isEnabledSingle() {
return isEnabledSingle;
}

public boolean isShowPercentText() {
return isShowPercentText;
}

public boolean isShowTick() {
return isShowTick;
}

public boolean isShowThumb() {
return isShowThumb;
}


public float getThumbRadiusEnlarges() {
return mThumbRadiusEnlarges;
}

/**
* 触摸时按钮半径放大量
* @param thumbRadiusEnlarges
*/
public void setThumbRadiusEnlarges(float thumbRadiusEnlarges) {
this.mThumbRadiusEnlarges = thumbRadiusEnlarges;
}

/**
* 是否默认显示百分比为标签文字
* @param showPercentText
*/
public void setShowPercentText(boolean showPercentText) {
isShowPercentText = showPercentText;
invalidate();
}

/**
* 是否显示拖动按钮
* @param showThumb
*/
public void setShowThumb(boolean showThumb) {
isShowThumb = showThumb;
invalidate();
}

/**
* 触摸时可偏移距离:偏移量越大,触摸精度越小
* @param allowableOffsets
Expand All @@ -925,12 +978,21 @@ public void setAllowableOffsets(float allowableOffsets) {

/**
* 是否启用拖拽
* @param enabledDrag 默认为true,为false时 相当于{@link android.widget.ProgressBar}
* @param enabledDrag 默认为 true,为 false 时 相当于{@link android.widget.ProgressBar}
*/
public void setEnabledDrag(boolean enabledDrag) {
isEnabledDrag = enabledDrag;
}


/**
* 设置是否启用点击改变进度
* @param enabledSingle
*/
public void setEnabledSingle(boolean enabledSingle){
isEnabledSingle = enabledSingle;
}

/**
* 设置中间文本标签内间距
* @param left
Expand Down Expand Up @@ -1032,9 +1094,27 @@ public void setOnChangeListener(OnChangeListener onChangeListener){


public interface OnChangeListener{
/**
* 跟踪触摸事件开始时回调此方法 {@link MotionEvent#ACTION_DOWN}
* @param isCanDrag
*/
void onStartTrackingTouch(boolean isCanDrag);

/**
* 进度改变时回调此方法
* @param progress
* @param max
* @param fromUser
*/
void onProgressChanged(float progress, float max, boolean fromUser);
/**
* 跟踪触摸事件停止时回调此方法 {@link MotionEvent#ACTION_UP}
*/
void onStopTrackingTouch(boolean isCanDrag);

/**
* 通过点击事件改变进度后回调此方法 {@link GestureDetector#GestureDetector#onSingleTapUp()}
*/
void onSingleTapUp();
}

Expand Down
1 change: 1 addition & 0 deletions arcseekbar/src/main/res/values/attrs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
<attr name="arcTickPadding" format="dimension"/>
<attr name="arcTickSplitAngle" format="integer"/>
<attr name="arcBlockAngle" format="integer"/>
<attr name="arcTickOffsetAngle" format="integer"/>
<attr name="arcThumbStrokeWidth" format="dimension"/>
<attr name="arcThumbColor" format="color"/>
<attr name="arcThumbRadius" format="dimension"/>
Expand Down
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ buildscript {

}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.1'
classpath 'com.novoda:bintray-release:0.9.2'
classpath "com.android.tools.build:gradle:$versions.gradle"
// classpath 'com.novoda:bintray-release:0.9.2'
classpath "com.vanniktech:gradle-maven-publish-plugin:$versions.mavenPublish"

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Expand Down
19 changes: 19 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,22 @@ android.useAndroidX=true
# Automatically convert third-party libraries to use AndroidX
android.enableJetifier=true

VERSION_NAME=1.0.3
VERSION_CODE=4
GROUP=com.github.jenly1314

POM_DESCRIPTION=ArcSeekBar for Android
POM_URL=https://github.com/jenly1314/ArcSeekBar
POM_SCM_URL=https://github.com/jenly1314/ArcSeekBar
POM_SCM_CONNECTION=scm:git@github.com:jenly1314/ArcSeekBar.git
POM_SCM_DEV_CONNECTION=scm:git@github.com:jenly1314/ArcSeekBar.git
#POM_LICENCE_NAME=The MIT License
#POM_LICENCE_URL=https://opensource.org/licenses/mit-license.php
POM_LICENCE_NAME=The Apache Software License, Version 2.0
POM_LICENCE_URL=http://www.apache.org/licenses/LICENSE-2.0.txt
POM_DEVELOPER_ID=jenly
POM_DEVELOPER_NAME=Jenly Yu
RELEASE_REPOSITORY_URL=https://s01.oss.sonatype.org/service/local/staging/deploy/maven2/
SNAPSHOT_REPOSITORY_URL=https://s01.oss.sonatype.org/content/repositories/snapshots/
RELEASE_SIGNING_ENABLED=false

6 changes: 4 additions & 2 deletions versions.gradle
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//App
def app_version = [:]
app_version.versionCode = 3
app_version.versionName = "1.0.2"
app_version.versionCode = 4
app_version.versionName = "1.0.3"
ext.app_version = app_version

//build version
Expand All @@ -14,6 +14,8 @@ ext.build_versions = build_versions

// App dependencies
def versions = [:]
versions.mavenPublish = '0.13.0'
versions.gradle = '3.6.1'
versions.junit = "1.1.1"
versions.runner = "1.2.0"
versions.espressoCore = "3.2.0"
Expand Down

0 comments on commit 25768b7

Please sign in to comment.