diff --git a/README.md b/README.md index 55921594e9042557645de2b9a1d32ee98db6130d..bf057734897cf935e93d271273442f78131cbd57 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ CircleView - 功能:包含标题和副标题的圆形视图 - 项目移植状态:完成 - 调用差异:无 -- 开发版本:sdk5,DevEco Studio2.1 release +- 开发版本:sdk6,DevEco Studio2.2 Beat1 - 基线版本:基于原组件的master分支 @@ -35,7 +35,7 @@ allprojects { } ``` -在sdk5,DevEco Studio 2.1 Release下项目可直接运行 +在sdk6,DevEco Studio 2.2 Beat1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, @@ -74,7 +74,7 @@ CodeCheck代码测试无异常 CloudTest代码测试无异常 -病毒安全检测通过 +病毒安全检测通过 当前版本demo功能与原组件基本无差异 diff --git a/build.gradle b/build.gradle index 9a54b53c5030481f3b3600036889c6cf761affd7..8c592a611e3fcbe90cf76d82e59ca599eaa8ce2b 100644 --- a/build.gradle +++ b/build.gradle @@ -1,14 +1,13 @@ // Top-level build file where you can add configuration options common to all sub-projects/modules. apply plugin: 'com.huawei.ohos.app' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } } - + buildscript { repositories { maven { @@ -17,11 +16,11 @@ buildscript { maven { url 'https://developer.huawei.com/repo/' } - jcenter() + jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - classpath 'com.huawei.ohos:decctest:1.2.4.0' + classpath 'com.huawei.ohos:hap:2.4.5.0' + classpath 'com.huawei.ohos:decctest:1.2.4.1' } } @@ -33,6 +32,6 @@ allprojects { maven { url 'https://developer.huawei.com/repo/' } - jcenter() + jcenter() } } diff --git a/circleview/build.gradle b/circleview/build.gradle index 29231934ac368ab9c0731b0dca261212f7e289d4..d56506a9e6c433b0aa62cb97d27af8350c0d8099 100644 --- a/circleview/build.gradle +++ b/circleview/build.gradle @@ -1,9 +1,8 @@ apply plugin: 'com.huawei.ohos.library' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { - compatibleSdkVersion 5 + compatibleSdkVersion 6 } buildTypes { release { @@ -13,7 +12,7 @@ ohos { } } } - + } dependencies { diff --git a/circleview/src/main/java/com/github/pavlospt/CircleView.java b/circleview/src/main/java/com/github/pavlospt/CircleView.java index f8f00ddea06d7ccd47555109d07e74a49b0ae71a..0ffdaf5faa595697d92f67a2796a6d4b4d4a667e 100644 --- a/circleview/src/main/java/com/github/pavlospt/CircleView.java +++ b/circleview/src/main/java/com/github/pavlospt/CircleView.java @@ -24,7 +24,7 @@ public class CircleView extends Component { private static final int NUM_25 = 25; private static final int NUM_360 = 360; private static final int NUM_30 = 30; - private static final float NUM_5F = 0.1f; + private static final float NUM_5F = 0.5f; private static int DEFAULT_TITLE_COLOR = Color.CYAN.getValue(); private static int DEFAULT_SUBTITLE_COLOR = Color.WHITE.getValue(); private static String DEFAULT_TITLE = "title"; @@ -51,7 +51,8 @@ public class CircleView extends Component { private int mStrokeColor = DEFAULT_STROKE_COLOR; private int mBackgroundColor = DEFAULT_BACKGROUND_COLOR; private int mFillColor = DEFAULT_FILL_COLOR; - + private int weight; + private int height; private String mTitleText = DEFAULT_TITLE; private String mSubtitleText = DEFAULT_SUBTITLE; @@ -133,7 +134,9 @@ public class CircleView extends Component { mFillRadius = AttrUtils.getFloatFromAttr(attrs, "cv_fillRadius", DEFAULT_FILL_RADIUS); mTitleSubtitleSpace = AttrUtils.getFloatFromAttr(attrs, "cv_titleSubtitleSpace", DEFAULT_TITLE_SUBTITLE_SPACE); initPaint(); - mInnerRectF = new RectFloat(NUM_10, NUM_10, getWidth() - NUM_10, getHeight() - NUM_10); + + weight = getWidth(); + mInnerRectF = new RectFloat(0, 0, weight + NUM_10, getHeight()); addDrawTask(new DrawTask() { @Override public void onDraw(Component component, Canvas canvas) { @@ -141,9 +144,8 @@ public class CircleView extends Component { float centerY = mInnerRectF.getCenter().getPointY(); Arc arc = new Arc(0, NUM_360, false); canvas.drawArc(mInnerRectF, arc, mTitleTextPaint); - - float radius = (mViewSize / NUM_2) * mFillRadius; - canvas.drawCircle(new Circle(centerX, centerY, + float radius = (weight / NUM_2) * mFillRadius; + canvas.drawCircle(new Circle(getWidth()/2, getHeight()/2, radius + NUM_5F - mStrokePaint.getStrokeWidth()), mBackgroundPaint); canvas.drawOval(mInnerRectF, mStrokePaint); @@ -165,6 +167,42 @@ public class CircleView extends Component { } + /** + * getWeight + * + * @return intNUm + */ + public int getWeight() { + return weight; + } + + /** + * setWeight + * + * @param weight weight + */ + public void setWeight(int weight) { + this.weight = weight; + mInnerRectF = new RectFloat(0, 0, weight, getHeight() - NUM_10); + postLayout(); + invalidate(); + } + + public int getHeight() { + return height; + } + + /** + * setHeight + * @param height height + */ + public void setHeight(int height) { + this.height = height; + mInnerRectF = new RectFloat(0, 0, weight, height - NUM_10); + postLayout(); + invalidate(); + } + private void initPaint() { mTitleTextPaint = new Paint(); mTitleTextPaint.setStyle(Paint.Style.FILLANDSTROKE_STYLE); diff --git a/entry/build.gradle b/entry/build.gradle index c68c36ca826b93920a4571bd27a7458083cf18bf..6fd7edb8b09c521851db5e2920191ee2ddca1033 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' -//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#ZH-CN_TOPIC_0000001154985555__section1112183053510 + ohos { compileSdkVersion 5 defaultConfig { diff --git a/entry/src/main/config.json b/entry/src/main/config.json index a4aea8de8502f781229f9953172d01b9b46eb28c..958d912456391408517f19cd0d973e2f7dfb402b 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -28,7 +28,7 @@ "deliveryWithInstall": true, "moduleName": "entry", "moduleType": "entry", - "installationFree": true + "installationFree": false }, "abilities": [ { diff --git a/entry/src/main/java/com/github/pavlospt/slice/MainAbilitySlice.java b/entry/src/main/java/com/github/pavlospt/slice/MainAbilitySlice.java index 4e1ead9651a2e24a7c4ffc7dd34b1f77a8c40192..486bc4037a1065c5e8526ab0b0a548e6c2bca231 100644 --- a/entry/src/main/java/com/github/pavlospt/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/github/pavlospt/slice/MainAbilitySlice.java @@ -5,6 +5,7 @@ import com.github.pavlospt.ResourceTable; import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.content.Intent; +import ohos.agp.window.service.DisplayManager; /** * MainAbilitySlice @@ -19,6 +20,12 @@ public class MainAbilitySlice extends AbilitySlice { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_main); circleView = (CircleView) findComponentById(ResourceTable.Id_circle_view); + int width = DisplayManager.getInstance().getDefaultDisplay(this) + .get().getAttributes().width; + int height = DisplayManager.getInstance().getDefaultDisplay(this) + .get().getAttributes().height; + circleView.setWeight(width); + circleView.setHeight(height/2); } @Override diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json index c2a6b66cf9bbe3634a9332007717dfd5f2db38bf..710571f9d494fea58499f6cb76594875277678b6 100644 --- a/entry/src/main/resources/base/element/string.json +++ b/entry/src/main/resources/base/element/string.json @@ -2,11 +2,11 @@ "string": [ { "name": "entry_MainAbility", - "value": "entry_MainAbility" + "value": "CircleView" }, { "name": "mainability_description", - "value": "Java_Empty Ability" + "value": "CircleView" }, { "name": "mainability_HelloWorld", diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml index e6b3cf92fbeb68a7ce76e8e0ca9b212030c755ac..3cd4fb8f8ee1a66aaf4517c75abff060de98a5f9 100644 --- a/entry/src/main/resources/base/layout/ability_main.xml +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -8,9 +8,10 @@ ohos:orientation="vertical">