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 67ce51b5d22b51106b529da9b2d871651d40db28..56cd5ff463a932c1897375df9ac1e295c135d94e 100644 --- a/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java +++ b/circleprogress/src/main/java/com/littlejie/circleprogress/utils/ViewUtils.java @@ -3,9 +3,9 @@ * 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. @@ -41,6 +41,9 @@ import java.util.Optional; public class ViewUtils { private static ViewUtils instance = null; + /** 构造方法 + * @return ViewUtils + */ public static synchronized ViewUtils getInstance() { if (instance == null) { instance = new ViewUtils(); @@ -61,6 +64,12 @@ public class ViewUtils { return vp * displayAttributes.scalDensity; } + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return String + */ public String getAttrStringValue(AttrSet attrSet, String key, String defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getStringValue(); @@ -69,7 +78,13 @@ public class ViewUtils { } } - public Integer getAttrIntValue(AttrSet attrSet, String key, Integer defValue) { + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Integer + */ + public int getAttrIntValue(AttrSet attrSet, String key, int defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getIntegerValue(); } else { @@ -77,7 +92,13 @@ public class ViewUtils { } } - public Boolean getAttrBoolValue(AttrSet attrSet, String key, Boolean defValue) { + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Boolean + */ + public boolean getAttrBoolValue(AttrSet attrSet, String key, boolean defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getBoolValue(); } else { @@ -85,7 +106,13 @@ public class ViewUtils { } } - public Float getFloatValue(AttrSet attrSet, String key, float defValue) { + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Float + */ + public float getFloatValue(AttrSet attrSet, String key, float defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getFloatValue(); } else { @@ -93,7 +120,13 @@ public class ViewUtils { } } - public Integer getDimensionValue(AttrSet attrSet, String key, int defValue) { + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Integer + */ + public int getDimensionValue(AttrSet attrSet, String key, int defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getDimensionValue(); } else { @@ -101,6 +134,12 @@ public class ViewUtils { } } + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Element + */ public Element getAttrElementValue(AttrSet attrSet, String key, Element defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getElement(); @@ -109,6 +148,12 @@ public class ViewUtils { } } + /** 获取自定义值 + * @param attrSet + * @param key + * @param defValue + * @return Color + */ public Color getAttrColorValue(AttrSet attrSet, String key, Color defValue) { if (attrSet.getAttr(key).isPresent()) { return attrSet.getAttr(key).get().getColorValue(); @@ -117,9 +162,17 @@ public class ViewUtils { } } - public PixelMap getPixelMapFromMedia(Context context, int mediaId) throws NotExistException, WrongTypeException, IOException { + /** 从资源文件获取bitmap + * @param context + * @param mediaId + * @return PixelMap + * @throws NotExistException + * @throws WrongTypeException + * @throws IOException + */ + public PixelMap getPixelMapFromMedia(Context context, int mediaId) throws + NotExistException, WrongTypeException, IOException { ImageSource.SourceOptions options = new ImageSource.SourceOptions(); -// options.formatHint = "image/jpg"; ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions(); ResourceManager manager = context.getResourceManager(); String path = manager.getMediaPath(mediaId); @@ -128,11 +181,20 @@ public class ViewUtils { return source.createPixelmap(decodingOptions); } + /** vp转px + * @param context + * @param dpValue + * @return float + */ protected static float dip2px(Context context, float dpValue) { DisplayAttributes displayAttributes = getScreenPiex(context); return dpValue * displayAttributes.scalDensity; } + /** 获取屏幕密度 + * @param context + * @return DisplayAttributes + */ public static DisplayAttributes getScreenPiex(Context context) { // 获取屏幕密度 Optional display = DisplayManager.getInstance().getDefaultDisplay(context); diff --git a/entry/build.gradle b/entry/build.gradle index aacce66b5a3ea86f354d5fbfc90b9f903d610489..a9377bbac7d3f52e8e4c742db40f458a29bd51c3 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,26 +1,6 @@ apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' 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') - } - release { - 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/entry/src/main/config.json b/entry/src/main/config.json index 805e078830d81604f31bc315b8b65274ab565d91..2039482a54ed265fceebf3557501003a5cab785a 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -40,7 +40,7 @@ "name": "com.littlejie.app.MainAbility", "icon": "$media:icon", "description": "$string:mainability_description", - "label": "HM_CircleProgress", + "label": "CircleProgress", "type": "page", "launchType": "standard" } diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index f92076320e2dae359bf5dde8c0a39908c782ebef..100af8fdefe02775db50791b449466bb23d30d1f 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -2,7 +2,7 @@ "string": [ { "name": "app_name", - "value": "HM_CircleProgress" + "value": "CircleProgress" }, { "name": "mainability_description", diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json index 3c7ce97c1a817bae8b70a2c59e821e1ca1529c85..dfd09625326a3969e815c91d779f15474750417a 100644 --- a/entry/src/ohosTest/config.json +++ b/entry/src/ohosTest/config.json @@ -30,7 +30,7 @@ "name": "decc.testkit.runner.EntryAbility", "description": "Test Entry Ability", "icon": "$media:icon", - "label": "HM_CircleProgress", + "label": "CircleProgress", "launchType": "standard", "orientation": "landscape", "visible": true, diff --git a/gif/round.gif b/gif/round.gif index e8559e225fd213754e8e2b9ff0a0058a8f71b55d..b4ae82ecf874c43f8d36a753ae534124b71e3781 100644 Binary files a/gif/round.gif and b/gif/round.gif differ diff --git a/gif/speedwave.gif b/gif/speedwave.gif index 56c577b29294c370565edbc462b33533c30ca53d..005a52aa40d183a0bf642ec6a5912843b6ba105a 100644 Binary files a/gif/speedwave.gif and b/gif/speedwave.gif differ