From ec12224eb1b6d07904ae07fe53696474946e5e6f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=93=E7=A8=8B?= <1019678117@qq.con> Date: Mon, 12 Jul 2021 17:06:16 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=BA=86=E7=89=88=E6=9D=83?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 7 ++-- README.md | 4 +-- entry/build.gradle | 5 +-- .../com/tyrantgit/sample/MainAbility.java | 9 +++-- .../com/tyrantgit/sample/MyApplication.java | 7 +++- .../sample/slice/MainAbilitySlice.java | 34 ++++++++++++------- .../com/tyrantgit/sample/ExampleOhosTest.java | 2 +- .../explosionfield/ExplosionAnimator.java | 1 + .../explosionfield/ExplosionField.java | 1 + .../com/tyrantgit/explosionfield/Utils.java | 1 + .../util/AnimatorValueUtil.java | 2 +- 11 files changed, 50 insertions(+), 23 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12b3324..c78ab15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ -## 0.0.2-SNAPSHOT +## 0.0.3-SNAPSHOT +ohos 第3个版本 + * 代码优化 +## 0.0.2-SNAPSHOT ohos 第2个版本 * 更新sdk6 ## 0.0.1-SNAPSHOT ohos 第1个版本 - * 实现了原库的全部ap \ No newline at end of file + * 实现了原库的全部api \ No newline at end of file diff --git a/README.md b/README.md index 0143cfe..8b049af 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ ``` dependencies { - implementation('com.gitee.chinasoft_ohos:ExplosionField:0.0.2-SNAPSHOT') + implementation('com.gitee.chinasoft_ohos:ExplosionField:0.0.3-SNAPSHOT') ...... } ``` @@ -58,7 +58,7 @@ CloudTest代码测试无异常 ## 版本迭代 -- 0.0.2-SNAPSHOT +- 0.0.3-SNAPSHOT ## 版本和许可信息 diff --git a/entry/build.gradle b/entry/build.gradle index 496a168..7db2b23 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -19,8 +19,9 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) testImplementation 'junit:junit:4.13' ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' - implementation('com.gitee.chinasoft_ohos:ExplosionField:0.0.2-SNAPSHOT') + implementation('com.gitee.chinasoft_ohos:ExplosionField:0.0.3-SNAPSHOT') +// implementation project(path : ":explosionfield") } decc { supportType = ['html', 'xml'] -} +} \ No newline at end of file diff --git a/entry/src/main/java/com/tyrantgit/sample/MainAbility.java b/entry/src/main/java/com/tyrantgit/sample/MainAbility.java index c872f9c..a9630ab 100644 --- a/entry/src/main/java/com/tyrantgit/sample/MainAbility.java +++ b/entry/src/main/java/com/tyrantgit/sample/MainAbility.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device 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 + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,12 +14,17 @@ */ package com.tyrantgit.sample; + import com.tyrantgit.sample.slice.MainAbilitySlice; import ohos.aafwk.ability.Ability; import ohos.aafwk.content.Intent; +/** + * MainAbility + * + * @since 2021-04-06 + */ public class MainAbility extends Ability { - @Override public void onStart(Intent intent) { super.onStart(intent); diff --git a/entry/src/main/java/com/tyrantgit/sample/MyApplication.java b/entry/src/main/java/com/tyrantgit/sample/MyApplication.java index 737d81d..f5b3e36 100644 --- a/entry/src/main/java/com/tyrantgit/sample/MyApplication.java +++ b/entry/src/main/java/com/tyrantgit/sample/MyApplication.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device 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 + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -17,6 +17,11 @@ package com.tyrantgit.sample; import ohos.aafwk.ability.AbilityPackage; +/** + * MyApplication + * + * @since 2021-04-06 + */ public class MyApplication extends AbilityPackage { @Override public void onInitialize() { diff --git a/entry/src/main/java/com/tyrantgit/sample/slice/MainAbilitySlice.java b/entry/src/main/java/com/tyrantgit/sample/slice/MainAbilitySlice.java index d611d36..31b969d 100644 --- a/entry/src/main/java/com/tyrantgit/sample/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/tyrantgit/sample/slice/MainAbilitySlice.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device 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 + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -14,11 +14,17 @@ */ package com.tyrantgit.sample.slice; + import com.tyrantgit.explosionfield.ExplosionField; import com.tyrantgit.sample.ResourceTable; import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.content.Intent; -import ohos.agp.components.*; +import ohos.agp.components.AttrHelper; +import ohos.agp.components.Component; +import ohos.agp.components.DirectionalLayout; +import ohos.agp.components.Image; +import ohos.agp.components.LayoutScatter; +import ohos.agp.components.Text; import ohos.agp.components.element.ShapeElement; import ohos.agp.utils.LayoutAlignment; import ohos.agp.window.dialog.PopupDialog; @@ -37,10 +43,14 @@ import java.util.Optional; * @since 2021-04-08 */ public class MainAbilitySlice extends AbilitySlice implements Component.TouchEventListener { + private final int num2 = 2; + private final int num4 = 4; + private final int num10 = 10; + private final int num130 = 130; private ExplosionField mExplosionField; private List components; private int[] ids = {ResourceTable.Id_image1, ResourceTable.Id_image2, ResourceTable.Id_image3, - ResourceTable.Id_image4, ResourceTable.Id_image5, ResourceTable.Id_image6, ResourceTable.Id_text }; + ResourceTable.Id_image4, ResourceTable.Id_image5, ResourceTable.Id_image6, ResourceTable.Id_text }; private Image undoBtn; /** @@ -66,23 +76,23 @@ public class MainAbilitySlice extends AbilitySlice implements Component.TouchEve undoBtn.setClickedListener(new Component.ClickedListener() { @Override public void onClick(Component component) { - Optional - display = DisplayManager.getInstance().getDefaultDisplay(getContext()); - DisplayAttributes displayAttributes = display.get().getAttributes(); - PopupDialog menuDialog = new PopupDialog(getContext(), null); DirectionalLayout menuComponent = (DirectionalLayout) LayoutScatter.getInstance(getContext()) .parse(ResourceTable.Layout_custom_setting_popup, null, false); Text textSetting = (Text) menuComponent.findComponentById(ResourceTable.Id_text); DirectionalLayout dl = (DirectionalLayout) menuComponent.findComponentById(ResourceTable.Id_dl); - textSetting.setWidth(getWindow().getLayoutConfig().get().width / 2); + textSetting.setWidth(getWindow().getLayoutConfig().get().width / num2); ShapeElement element = new ShapeElement(); - element.setCornerRadius(10); + element.setCornerRadius(num10); dl.setBackground(element); textSetting.setBackground(element); - menuDialog.setCornerRadius(10); - + Optional display = DisplayManager.getInstance().getDefaultDisplay(getContext()); + DisplayAttributes displayAttributes = display.get().getAttributes(); + PopupDialog menuDialog = new PopupDialog(getContext(), null); + menuDialog.setCornerRadius(num10); menuDialog.setCustomComponent(menuComponent); - menuDialog.showOnCertainPosition(1, displayAttributes.width / 4 - AttrHelper.vp2px(10, getContext()), -displayAttributes.width + 130); + menuDialog.showOnCertainPosition(1, + displayAttributes.width / num4 - AttrHelper.vp2px(num10, getContext()), + -displayAttributes.width + num130); menuDialog.setAutoClosable(true); menuDialog.setAlignment(LayoutAlignment.RIGHT | LayoutAlignment.TOP); menuDialog.show(); diff --git a/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java b/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java index 9e9a250..f3212a4 100644 --- a/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java +++ b/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device 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 + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java index a13ee91..5520224 100644 --- a/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java +++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.tyrantgit.explosionfield; import com.tyrantgit.explosionfield.util.AnimatorValueUtil; diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java index 753235b..ac5225a 100644 --- a/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java +++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.tyrantgit.explosionfield; import ohos.aafwk.ability.Ability; diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java index ef95a62..16b7350 100644 --- a/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java +++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java @@ -13,6 +13,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.tyrantgit.explosionfield; import ohos.agp.components.Component; diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java index d853cfa..dfb8d1d 100644 --- a/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java +++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java @@ -2,7 +2,7 @@ * Copyright (C) 2021 Huawei Device 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 + * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * -- Gitee