From 9793199ad4ed4235c3a04564415d99b50104c05c Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Thu, 13 May 2021 17:16:08 +0800 Subject: [PATCH 1/5] =?UTF-8?q?checkStyle=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 2 +- .../java/com/littlejie/circleprogress/DialProgress.java | 2 ++ .../com/littlejie/circleprogress/RoundProgressView.java | 4 +++- .../com/littlejie/circleprogress/utils/MiscUtil.java | 9 ++++----- .../com/littlejie/circleprogress/utils/ViewUtils.java | 2 +- 5 files changed, 11 insertions(+), 8 deletions(-) diff --git a/build.gradle b/build.gradle index f3e6847..d554444 100644 --- a/build.gradle +++ b/build.gradle @@ -30,7 +30,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.2.5' + classpath 'com.huawei.ohos:hap:2.4.2.7' classpath 'com.huawei.ohos:decctest:1.0.0.6' } } diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java b/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java index 2e6126c..ceb4add 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java @@ -241,6 +241,7 @@ public class DialProgress extends Component implements Component.DrawTask, Compo /** * 初始化坐标点 + * @param component */ public void initPoint(Component component) { int minSize = Math.min(component.getWidth() - component.getPaddingLeft() - component.getPaddingRight() - 2 * (int) mArcWidth, @@ -287,6 +288,7 @@ public class DialProgress extends Component implements Component.DrawTask, Compo /** * 画扇形进度条 + * @param canvas */ private void updateArcPaint(Canvas canvas) { float angle = mPercent * 270; diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java b/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java index 24cfd8d..dc62207 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java @@ -232,6 +232,7 @@ public class RoundProgressView extends Component implements Component.DrawTask, /** * 初始化坐标点 + * @param component */ public void initPoint(Component component) { int minSize = Math.min(component.getWidth() - component.getPaddingLeft() - component.getPaddingRight() - 2 * (int) mArcWidth, @@ -276,6 +277,7 @@ public class RoundProgressView extends Component implements Component.DrawTask, /** * 画扇形进度条 + * @param canvas */ private void updateArcPaint(Canvas canvas) { float angle = mPercent * 270; @@ -321,7 +323,7 @@ public class RoundProgressView extends Component implements Component.DrawTask, /** * 绘制内容文字 - * + * @param component * @param canvas */ private void drawText(Component component, Canvas canvas) { diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/MiscUtil.java b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/MiscUtil.java index 0da870b..1ac8ae4 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/MiscUtil.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/MiscUtil.java @@ -32,7 +32,7 @@ public class MiscUtil { * * @param measureSpec * @param defaultSize View 的默认大小 - * @return + * @return int */ public static int measure(int measureSpec, int defaultSize) { int result = defaultSize; @@ -51,7 +51,7 @@ public class MiscUtil { * 获取数值精度格式化字符串 * * @param precision - * @return + * @return string */ public static String getPrecisionFormat(int precision) { return "%." + precision + "f"; @@ -62,7 +62,7 @@ public class MiscUtil { * * @param arrays * @param - * @return + * @return T */ public static T[] reverse(T[] arrays) { if (arrays == null) { @@ -79,9 +79,8 @@ public class MiscUtil { /** * 测量文字高度 - * * @param paint - * @return + * @return float */ public static float measureTextHeight(Paint paint) { Paint.FontMetrics fontMetrics = paint.getFontMetrics(); diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java index 877b0d7..a3ebb80 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java @@ -54,7 +54,7 @@ public class ViewUtils { * * @param context * @param vp - * @return + * @return float */ public float vp2Px(Context context, float vp) { // 获取屏幕密度 -- Gitee From b85d959b0053f88d12ae32cb9808cbb8ea7ba61b Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Thu, 13 May 2021 17:27:17 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E5=8D=8E=E4=B8=BA=E8=A7=84=E5=88=992.2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../circleprogress/DialProgress.java | 27 +------------------ .../circleprogress/RoundProgressView.java | 2 +- .../circleprogress/WaveProgress.java | 2 +- .../littlejie/app/slice/MainAbilitySlice.java | 4 +-- 4 files changed, 5 insertions(+), 30 deletions(-) diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java b/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java index ceb4add..2a2cf9b 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/DialProgress.java @@ -135,39 +135,14 @@ public class DialProgress extends Component implements Component.DrawTask, Compo mDialIntervalDegree = ViewUtils.getInstance().getAttrIntValue(attrSet, Constant.ROUNDPROGRESS_DIALINTERVALDEGREE, 10); mArcWidth = ViewUtils.getInstance().getDimensionValue(attrSet, Constant.ROUNDPROGRESS_ARCWIDTH, Constant.DEFAULT_ARC_WIDTH); - Color mArcColor = ViewUtils.getInstance().getAttrColorValue(attrSet, Constant.ROUNDPROGRESS_ARCCOLORS, Color.BLACK); mBgArcColor = ViewUtils.getInstance().getAttrColorValue(attrSet, Constant.ROUNDPROGRESS_BGARCCOLOR, Color.RED); -// mBgArcWidth = ViewUtils.getInstance().getDimensionValue(attrSet, Constant.ROUNDPROGRESS_BGARCWIDTH, Constant.DEFAULT_ARC_WIDTH); mTextOffsetPercentInRadius = ViewUtils.getInstance().getFloatValue(attrSet, Constant.ROUNDPROGRESS_TEXTOFFSETPERCENTINRADIUS, 0.33f); -// mStartAngle = ViewUtils.getInstance().getAttrIntValue(attrSet, Constant.ROUNDPROGRESS_STARTANGLE, 0); -// mSweepAngle = ViewUtils.getInstance().getAttrIntValue(attrSet, Constant.ROUNDPROGRESS_SWEEPANGLE, 360); - mDialWidth = ViewUtils.getInstance().getDimensionValue(attrSet, Constant.ROUNDPROGRESS_DIALWIDTH, 0); mDialColor = ViewUtils.getInstance().getAttrColorValue(attrSet, Constant.ROUNDPROGRESS_DIALCOLOR, Color.WHITE); -// int gradientArcColors = mArcColor; -// if (gradientArcColors != null) { -// try { -// int[] gradientColors = getResources().getIntArray(gradientArcColors); -// if (gradientColors.length == 0) { -// int color = getResources().getColor(gradientArcColors); -// mGradientColors = new int[2]; -// mGradientColors[0] = color; -// mGradientColors[1] = color; -// } else if (gradientColors.length == 1) { -// mGradientColors = new int[2]; -// mGradientColors[0] = gradientColors[0]; -// mGradientColors[1] = gradientColors[0]; -// } else { -// mGradientColors = gradientColors; -// } -// } catch (Resources.NotFoundException e) { -// throw new Resources.NotFoundException("the give resource not found."); -// } -// } } private void initPaint() { @@ -230,7 +205,7 @@ public class DialProgress extends Component implements Component.DrawTask, Compo * * @param widthMeasureSpec * @param heightMeasureSpec - * @return + * @return boolean */ @Override public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) { diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java b/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java index dc62207..5b2c5a5 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/RoundProgressView.java @@ -347,7 +347,7 @@ public class RoundProgressView extends Component implements Component.DrawTask, * * @param widthMeasureSpec * @param heightMeasureSpec - * @return + * @return boolean */ @Override public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) { diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/WaveProgress.java b/circleprogress/src/main/java/com/littlejie/circleprogress/WaveProgress.java index fdd458f..bd5ab1b 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/WaveProgress.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/WaveProgress.java @@ -143,7 +143,7 @@ public class WaveProgress extends Component implements Component.DrawTask, Compo * * @param widthMeasureSpec * @param heightMeasureSpec - * @return + * @return boolean */ @Override public boolean onEstimateSize(int widthMeasureSpec, int heightMeasureSpec) { diff --git a/entry/src/main/java/com/littlejie/app/slice/MainAbilitySlice.java b/entry/src/main/java/com/littlejie/app/slice/MainAbilitySlice.java index 33d6e33..e08996d 100644 --- a/entry/src/main/java/com/littlejie/app/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/littlejie/app/slice/MainAbilitySlice.java @@ -105,8 +105,8 @@ public class MainAbilitySlice extends AbilitySlice implements Component.ClickedL super.onForeground(intent); } - /** - * 点击事件 + /** 点击事件 + * @param component */ @Override public void onClick(Component component) { -- Gitee From e2e489d852ac4cee6483cea06611d287d7144e23 Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Fri, 14 May 2021 15:09:50 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E5=8D=8E=E4=B8=BA=E8=A7=84=E5=88=992.2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../utils/AnimatorValueUpdateUtil.java | 84 ++++++++++++++----- readme.md | 1 - 2 files changed, 63 insertions(+), 22 deletions(-) diff --git a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/AnimatorValueUpdateUtil.java b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/AnimatorValueUpdateUtil.java index b246385..ee3c8c0 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/AnimatorValueUpdateUtil.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/AnimatorValueUpdateUtil.java @@ -1,35 +1,77 @@ +/* + * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain an copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + package com.littlejie.circleprogress.utils; +/** + * 动画计算类 + * + * @author fuchi + * @since 2021-04-02 + */ public class AnimatorValueUpdateUtil { + private static final String TAG = "AnimatorValueUtil"; + private final int rateSize = 2; + private final int negative = -1; + private float[] values; + private float[][] rate; + private float currentValue; - private float values[]; - - private float rate[][]; - - private static final String TAG = "ExplosionDemo_Utils"; - - public void ofFloat(float... values) { - this.values = values; - rate = new float[this.values.length - 1][2]; + /** + * 如传一个参数,则getValue 返回值与传入的 V 值一致 + * 如传入连续两个相同参数,则会出现除0异常 + * 传参试例: 0.8f,-1.2f,3.5f,0,5 + * + * @param tempValues 说明 + */ + public void ofFloat(float... tempValues) { + this.values = tempValues; + rate = new float[this.values.length - 1][rateSize]; float sum = 0; - for (int i = 1; i < this.values.length; i++) { - sum += Math.abs(this.values[i] - this.values[i - 1]); + for (int ii = 1; ii < this.values.length; ii++) { + sum += Math.abs(this.values[ii] - this.values[ii - 1]); } - for (int i = 0; i < rate.length; i++) { - float tempRate = Math.abs((this.values[i + 1] - this.values[i]) / sum); - rate[i][0] = tempRate + (i == 0 ? 0 : rate[i - 1][0]); - float tempDuration = this.values[i + 1] - this.values[i]; - rate[i][1] = (this.values[i] > this.values[i + 1] ? -1 : 1) * Math.abs(tempDuration / tempRate); + + for (int ii = 0; ii < rate.length; ii++) { // 计算每个变化值的占比和达到该变化值系数 + float tempRate = Math.abs((this.values[ii + 1] - this.values[ii]) / sum); + rate[ii][0] = tempRate + (ii == 0 ? 0 : rate[ii - 1][0]); + float tempDuration = this.values[ii + 1] - this.values[ii]; + rate[ii][1] = (this.values[ii] > this.values[ii + 1] ? negative : 1) * Math.abs(tempDuration / tempRate); } } - public float getValue(float v) { - for (int i = 0; i < rate.length; i++) { - if (v <= rate[i][0] || v > 1) { - return values[i] + (i == 0 ? v : v - rate[i - 1][0]) * rate[i][1]; + /** + * 根据 属性动画中value的值,计算当前值 + * + * @param value 属性动画中的value + * @return 通过计算后的值 + */ + public float getValue(float value) { + currentValue = value; + for (int ii = 0; ii < rate.length; ii++) { + // 如果是进入当前变化值占比,则按当前系数进行计算实际值(bounce回弹效果最后v会大于1) + if (value <= rate[ii][0] || value > 1) { + currentValue = values[ii] + (ii == 0 ? value : value - rate[ii - 1][0]) * rate[ii][1]; + return currentValue; } } - return v; + return value; } + public float getCurrentValue() { + return currentValue; + } } diff --git a/readme.md b/readme.md index ae06b5f..887a762 100644 --- a/readme.md +++ b/readme.md @@ -3,7 +3,6 @@ **本项目是基于开源项目CircleProgress进行openharmony的移植和开发的,可以通过项目标签以及github地址 (https://github.com/MyLifeMyTravel/CircleProgress) 追踪到原项目版本** ## 项目介绍 -我们理解您需要更便捷更高效的工具记录思想,整理笔记、知识,并将其中承载的价值传播给他人,**Cmd Markdown** 是我们给出的答案 —— 我们为记录思想和分享知识提供更专业的工具。 您可以使用 Cmd Markdown: > * 项目名称:CircleProgress > * 所属系列:openharmony的第三方组件适配移植 -- Gitee From f072847d8c552d15f28deb086c30d982c769e1b7 Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Fri, 14 May 2021 17:03:34 +0800 Subject: [PATCH 4/5] =?UTF-8?q?readme=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/readme.md b/readme.md index 887a762..768888b 100644 --- a/readme.md +++ b/readme.md @@ -104,4 +104,4 @@ CloudTest代码测试无异常 当前版本demo功能与原组件基本无差异 测试员:李向涛 ## 版本迭代 -> * v0.0.1_SNAPSHOT +> * 0.0.1_SNAPSHOT -- Gitee From c206fd4214ebbf300bd72b8c587c52dc1745e864 Mon Sep 17 00:00:00 2001 From: 0000226003-fuchi Date: Thu, 20 May 2021 15:37:31 +0800 Subject: [PATCH 5/5] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8D=87=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle | 11 ----------- circleprogress/src/main/config.json | 3 +-- entry/build.gradle | 11 ----------- 3 files changed, 1 insertion(+), 24 deletions(-) diff --git a/build.gradle b/build.gradle index d554444..2368e1d 100644 --- a/build.gradle +++ b/build.gradle @@ -2,17 +2,6 @@ apply plugin: 'com.huawei.ohos.app' ohos { - signingConfigs { - debug { - storeFile file('D:\\证书\\fcDebug.p12') - storePassword '0000001846633BB02AD72B430D1D9B20C032DB6C23FFE94A57A4E91E2032CE5F1CC4670087B3922C' - keyAlias = 'HMFC' - keyPassword '000000182688B1577B5560C361EA0995735D94580E243CB10692E1845F5F8CCBD9325DB3F391229A' - signAlg = 'SHA256withECDSA' - profile file('D:\\证书\\环形进度条Debug.p7b') - certpath file('D:\\证书\\HMFC_cetif.cer') - } - } compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 diff --git a/circleprogress/src/main/config.json b/circleprogress/src/main/config.json index f3bcc56..2a1558b 100644 --- a/circleprogress/src/main/config.json +++ b/circleprogress/src/main/config.json @@ -8,8 +8,7 @@ }, "apiVersion": { "compatible": 5, - "target": 5, - "releaseType": "Beta1" + "target": 5 } }, "deviceConfig": {}, diff --git a/entry/build.gradle b/entry/build.gradle index 1440a6f..d782e49 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,16 +1,5 @@ apply plugin: 'com.huawei.ohos.hap' ohos { - signingConfigs { - debug { - storeFile file('D:\\证书\\fcDebug.p12') - storePassword '0000001846633BB02AD72B430D1D9B20C032DB6C23FFE94A57A4E91E2032CE5F1CC4670087B3922C' - keyAlias = 'HMFC' - keyPassword '000000182688B1577B5560C361EA0995735D94580E243CB10692E1845F5F8CCBD9325DB3F391229A' - signAlg = 'SHA256withECDSA' - profile file('D:\\证书\\环形进度条Debug.p7b') - certpath file('D:\\证书\\HMFC_cetif.cer') - } - } compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 -- Gitee