diff --git a/.gitignore b/.gitignore
index 5bbe16380e4404c1032844f80c5707a102940317..1fd5f31d1e70179d15f8087b5810e4571387e039 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,22 +1,16 @@
+*.iml
.gradle
/local.properties
-/.idea/workspace.xml
+/.idea/caches
/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
-
-# IntelliJ IDEA
+.externalNativeBuild
+/entry/.preview
+.cxx
.idea
-*.iml
-*.ipl
-*.iws
-classes/
-idea-classes/
-coverage-error.log
-
-# Android
-gen
-bin
-project.properties
-out
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..f34df314fc0005040171a4676224a53f5a5634d0
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.0.1-SNAPSHOT
+
+ohos 第一个版本,完整实现了原库的全部 api
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..f4af95b540d0038d168c5dd61b9f9e2c712db2bc
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,13 @@
+Copyright 2015 tyrantgit
+
+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 a 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.
\ No newline at end of file
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..5029f80462630bd4f70b840e2ed609c7255f85e7
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,19 @@
+[
+
+ {
+
+ "Name": "ExplosionField",
+
+ "License": "Apache License",
+
+ "License File": "LICENSE",
+
+ "Version Number": "2.0",
+
+ "Upstream URL": "https://github.com/tyrantgit/ExplosionField",
+
+ "Description": "爆炸性粉尘效果的视图"
+
+ }
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index dff56f57b56a4b2d90ad25494894f2a1aafeeb2f..41f68617b79a9c09329d4ad77e0835584b5ac2b7 100644
--- a/README.md
+++ b/README.md
@@ -1,38 +1,70 @@
# ExplosionField
-[](http://android-arsenal.com/details/1/2554)
+#### 项目介绍
+- 项目名称:爆炸性粉尘动画视图
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:自定义的一个炫酷爆炸性粉尘效果的动画视图
+- 项目移植状态:主功能完成
+- 调用差异:无
+- 开发版本:sdk5,DevEco Studio2.1 Release
+- 基线版本:Release master
+#### 效果演示
+
+#### 安装教程
+ 1.在项目根目录下的build.gradle文件中,
+ allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+ }
+ 2.在entry模块的build.gradle文件中,
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos3:hawk:0.0.1-SNAPSHOT')
+
-explosive dust effect for views
+在sdk5,DevEco Studio2.1 Release下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
-
+#### 使用说明
-## Getting started
-
-In your `build.gradle`:
+```java
+private ExplosionField mExplosionField;
-```gradle
- dependencies {
- compile 'tyrantgit:explosionfield:1.0.1'
- }
+ mExplosionField = ExplosionField.attach2Window(this.getAbility(), rootLayout);
+ mExplosionField.explode(comp);
```
-```java
-ExplosionField explosionField = ...;
-explosionField.explode(view);
-```
-## License
+#### 测试信息
+
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与原组件基本无差异
+
+
+#### 版本迭代
+
+0.0.1-SNAPSHOT
+
+#### License
- Copyright 2015 tyrantgit
+Copyright 2015 tyrantgit
- 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 a copy of the License at
+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 a copy of the License at
- http://www.apache.org/licenses/LICENSE-2.0
+ 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.
+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.
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index cf420efeae4a87dab2cb80ff6b99957eb753c47b..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,25 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 22
- buildToolsVersion "23.0.0"
-
- defaultConfig {
- applicationId "tyrantgit.sample"
- minSdkVersion 14
- targetSdkVersion 22
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile project(":explosionfield")
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index 3a976ab995eeffcc42886ae923376bb7b9bd84f4..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\develop\AndroidSdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/app/src/androidTest/java/tyrantgit/sample/ApplicationTest.java b/app/src/androidTest/java/tyrantgit/sample/ApplicationTest.java
deleted file mode 100644
index 957e2d2b9254fc72a0adc3f53cdd94c3a95a87a6..0000000000000000000000000000000000000000
--- a/app/src/androidTest/java/tyrantgit/sample/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package tyrantgit.sample;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 83a5572b2671ee781c0f79d3e85bb42c804e6503..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/tyrantgit/sample/MainActivity.java b/app/src/main/java/tyrantgit/sample/MainActivity.java
deleted file mode 100644
index ea2876117319c44aff97f8a879fec61dfd304312..0000000000000000000000000000000000000000
--- a/app/src/main/java/tyrantgit/sample/MainActivity.java
+++ /dev/null
@@ -1,73 +0,0 @@
-package tyrantgit.sample;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.Menu;
-import android.view.MenuItem;
-import android.view.View;
-import android.view.ViewGroup;
-
-import tyrantgit.explosionfield.ExplosionField;
-
-
-public class MainActivity extends Activity {
-
- private ExplosionField mExplosionField;
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- mExplosionField = ExplosionField.attach2Window(this);
- addListener(findViewById(R.id.root));
- }
-
- private void addListener(View root) {
- if (root instanceof ViewGroup) {
- ViewGroup parent = (ViewGroup) root;
- for (int i = 0; i < parent.getChildCount(); i++) {
- addListener(parent.getChildAt(i));
- }
- } else {
- root.setClickable(true);
- root.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- mExplosionField.explode(v);
- v.setOnClickListener(null);
- }
- });
- }
- }
-
- @Override
- public boolean onCreateOptionsMenu(Menu menu) {
- getMenuInflater().inflate(R.menu.menu_main,menu);
- return true;
- }
-
- @Override
- public boolean onOptionsItemSelected(MenuItem item) {
- if (item.getItemId() == R.id.action_reset) {
- View root = findViewById(R.id.root);
- reset(root);
- addListener(root);
- mExplosionField.clear();
- return true;
- }
- return super.onOptionsItemSelected(item);
- }
-
- private void reset(View root) {
- if (root instanceof ViewGroup) {
- ViewGroup parent = (ViewGroup) root;
- for (int i = 0; i < parent.getChildCount(); i++) {
- reset(parent.getChildAt(i));
- }
- } else {
- root.setScaleX(1);
- root.setScaleY(1);
- root.setAlpha(1);
- }
- }
-}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index cc0b292b75439507c0d76fb8be851d0ee6b6c379..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,79 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/res/menu/menu_main.xml b/app/src/main/res/menu/menu_main.xml
deleted file mode 100644
index 35ca25a58f72b69d3a6f3ccc2b5ba8ee95ca8a52..0000000000000000000000000000000000000000
--- a/app/src/main/res/menu/menu_main.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index 0b56887c7c5d4bd88ec2dac90f86a96410f5ce54..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
- ExplosionFieldSample
-
- Hello world!
- Reset
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 3869e71302aea0376db4365bba08f77470c56e77..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index 1b7886d148cb5729f5b4829af050c3d49efce033..d3c9f1fef7ce4e18162867c20c11bfc65e1a8d28 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,19 +1,37 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
buildscript {
repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.3.0'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.4.2'
+ classpath 'com.huawei.ohos:decctest:1.0.0.7'
}
}
allprojects {
repositories {
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
jcenter()
}
}
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 100%
rename from app/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..c19573e84358a9f0698ebb60fb9f02a41a1ab87a
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,26 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ compile project(path: ':explosionfield')
+}
+decc {
+ supportType = ['html','xml']
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..43775b027f048d118343808272dd888ad00ddb21
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,57 @@
+{
+ "app": {
+ "bundleName": "com.tyrantgit.sample",
+ "vendor": "tyrantgit",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.tyrantgit.sample",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "metaData":{
+ "customizeData":[
+ {
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.NoTitleBar",
+ "extra":""
+ }
+ ]
+ },
+ "orientation": "unspecified",
+ "name": "com.tyrantgit.sample.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ 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
new file mode 100644
index 0000000000000000000000000000000000000000..ef976c519d6c10c16d4670b6c830b2394dd9a45b
--- /dev/null
+++ b/entry/src/main/java/com/tyrantgit/sample/MainAbility.java
@@ -0,0 +1,28 @@
+/*
+ * 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.tyrantgit.sample;
+import com.tyrantgit.sample.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+public class MainAbility extends Ability {
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+}
diff --git a/entry/src/main/java/com/tyrantgit/sample/MyApplication.java b/entry/src/main/java/com/tyrantgit/sample/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..05b42ceb015356f066332de13d87c1032ed76726
--- /dev/null
+++ b/entry/src/main/java/com/tyrantgit/sample/MyApplication.java
@@ -0,0 +1,25 @@
+/*
+ * 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.tyrantgit.sample;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.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
new file mode 100644
index 0000000000000000000000000000000000000000..1b9c6184eb6acd6921e355a442ca1bd4dc348554
--- /dev/null
+++ b/entry/src/main/java/com/tyrantgit/sample/slice/MainAbilitySlice.java
@@ -0,0 +1,134 @@
+/*
+ * 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.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.element.ShapeElement;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.window.dialog.PopupDialog;
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.multimodalinput.event.TouchEvent;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Optional;
+
+/**
+ * DEMO样例
+ *
+ * @since 2021-04-08
+ */
+public class MainAbilitySlice extends AbilitySlice implements Component.TouchEventListener {
+ 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 };
+ private Image undoBtn;
+
+ /**
+ * 给组件设置监听
+ *
+ * @param component
+ */
+ public void setListener(Component component) {
+ component.setClickedListener(comp -> {
+ mExplosionField.explode(comp);
+ comp.setClickedListener(null);
+ });
+ }
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+
+ super.setUIContent(ResourceTable.Layout_ability_main);
+
+ Component rootLayout = this.findComponentById(ResourceTable.Id_root);
+ undoBtn = (Image) this.findComponentById(ResourceTable.Id_undo_btn);
+ 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);
+ ShapeElement element = new ShapeElement();
+ element.setCornerRadius(10);
+ dl.setBackground(element);
+ textSetting.setBackground(element);
+ menuDialog.setCornerRadius(10);
+
+ menuDialog.setCustomComponent(menuComponent);
+ menuDialog.showOnCertainPosition(1, displayAttributes.width / 4 - AttrHelper.vp2px(10, getContext()), -displayAttributes.width + 130);
+ menuDialog.setAutoClosable(true);
+ menuDialog.setAlignment(LayoutAlignment.RIGHT | LayoutAlignment.TOP);
+ menuDialog.show();
+ textSetting.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ reset();
+ menuDialog.destroy();
+ }
+ });
+ }
+ });
+ mExplosionField = ExplosionField.attach2Window(this.getAbility(), rootLayout);
+
+ components = new ArrayList();
+ for (int i = 0; i < ids.length; i++) {
+ Component component = this.findComponentById(ids[i]);
+ components.add(component);
+ setListener(component);
+ }
+ }
+
+ /**
+ * 重置
+ */
+ public void reset() {
+ for (Component component : components) {
+ component.setScaleX(1);
+ component.setScaleY(1);
+ component.setAlpha(1);
+ setListener(component);
+ }
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+
+ @Override
+ public boolean onTouchEvent(Component component, TouchEvent touchEvent) {
+ return false;
+ }
+}
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..e0fabc770e87b8c479f0febd627019368e20b735
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ExplosionFieldSample"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "button",
+ "value": "click to destory"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c64f23d2bc719d24a32d5bcc0b8904bea94f0a97
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,111 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/custom_setting_popup.xml b/entry/src/main/resources/base/layout/custom_setting_popup.xml
new file mode 100644
index 0000000000000000000000000000000000000000..ec775c123708333042228ee5d0d6556041ff54dc
--- /dev/null
+++ b/entry/src/main/resources/base/layout/custom_setting_popup.xml
@@ -0,0 +1,19 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/app/src/main/res/drawable-xxhdpi/p1.webp b/entry/src/main/resources/base/media/p1.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p1.webp
rename to entry/src/main/resources/base/media/p1.webp
diff --git a/app/src/main/res/drawable-xxhdpi/p2.webp b/entry/src/main/resources/base/media/p2.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p2.webp
rename to entry/src/main/resources/base/media/p2.webp
diff --git a/app/src/main/res/drawable-xxhdpi/p3.webp b/entry/src/main/resources/base/media/p3.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p3.webp
rename to entry/src/main/resources/base/media/p3.webp
diff --git a/app/src/main/res/drawable-xxhdpi/p4.webp b/entry/src/main/resources/base/media/p4.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p4.webp
rename to entry/src/main/resources/base/media/p4.webp
diff --git a/app/src/main/res/drawable-xxhdpi/p5.webp b/entry/src/main/resources/base/media/p5.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p5.webp
rename to entry/src/main/resources/base/media/p5.webp
diff --git a/app/src/main/res/drawable-xxhdpi/p6.webp b/entry/src/main/resources/base/media/p6.webp
similarity index 100%
rename from app/src/main/res/drawable-xxhdpi/p6.webp
rename to entry/src/main/resources/base/media/p6.webp
diff --git a/entry/src/main/resources/base/media/setting.png b/entry/src/main/resources/base/media/setting.png
new file mode 100644
index 0000000000000000000000000000000000000000..4a69006b3f8e01100230217cfc29a07c36797ec1
Binary files /dev/null and b/entry/src/main/resources/base/media/setting.png differ
diff --git a/entry/src/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..675b593db3fa4acf56d17c53d425015537baa98f
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,40 @@
+{
+ "app": {
+ "bundleName": "com.tyrantgit.sample",
+ "vendor": "tyrantgit",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.tyrantgit.sample",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java b/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..9e9a250c58b14f6a362268c77a721efa9cf0af49
--- /dev/null
+++ b/entry/src/ohosTest/java/com/tyrantgit/sample/ExampleOhosTest.java
@@ -0,0 +1,90 @@
+/*
+ * 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
+ *
+ * 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.tyrantgit.sample;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import ohos.app.Context;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ private Context context;
+ private Class unitClass;
+ private Object obj;
+
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.tyrantgit.sample", actualBundleName);
+ }
+
+ /**
+ * 开始
+ */
+ @Before
+ public void setUp() {
+ context = AbilityDelegatorRegistry.getAbilityDelegator().getCurrentTopAbility().getContext();
+ }
+
+ /**
+ * 结束
+ */
+ @After
+ public void tearDown() {
+ context = null;
+ }
+
+ @Test
+ public void initClass() {
+ try {
+ unitClass = Class.forName("com.tyrantgit.sample.slice.MainAbilitySlice");
+ obj = unitClass.getConstructor().newInstance(); //实例化一个对象
+ } catch (ClassNotFoundException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InstantiationException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ }
+ }
+ /**
+ * reset
+ */
+ @Test
+ public void reset() {
+ initClass();
+ try {
+ Method method = unitClass.getMethod("reset", int.class);
+ method.invoke(obj, null);
+ } catch (NoSuchMethodException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
+ } catch (InvocationTargetException e) {
+ e.printStackTrace();
+ }
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/tyrantgit/sample/ExampleTest.java b/entry/src/test/java/com/tyrantgit/sample/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..9c0a945852a17cd77336389309520006682eb3d1
--- /dev/null
+++ b/entry/src/test/java/com/tyrantgit/sample/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.tyrantgit.sample;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/explosionfield.gif b/explosionfield.gif
deleted file mode 100644
index a37d50a8cf98f6e6a8a1da5cdac1a5a3eb56ef14..0000000000000000000000000000000000000000
Binary files a/explosionfield.gif and /dev/null differ
diff --git a/explosionfield/build.gradle b/explosionfield/build.gradle
index b6d9f7a3e5e737db5cf76cbf3d3824282e20a3c8..25ddf0cf1daa8f1533639ebc05ce352f4019b8ff 100644
--- a/explosionfield/build.gradle
+++ b/explosionfield/build.gradle
@@ -1,23 +1,21 @@
-apply plugin: 'com.android.library'
-
-android {
- compileSdkVersion 22
- buildToolsVersion "23.0.0"
-
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 14
- targetSdkVersion 22
- versionCode 1
- versionName "1.0"
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
}
diff --git a/explosionfield/proguard-rules.pro b/explosionfield/proguard-rules.pro
index 3a976ab995eeffcc42886ae923376bb7b9bd84f4..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/explosionfield/proguard-rules.pro
+++ b/explosionfield/proguard-rules.pro
@@ -1,17 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\develop\AndroidSdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/explosionfield/src/androidTest/java/tyrantgit/explosionfield/ApplicationTest.java b/explosionfield/src/androidTest/java/tyrantgit/explosionfield/ApplicationTest.java
deleted file mode 100644
index f1abb692fc9c6de6a0519e8265fc219acbc3732d..0000000000000000000000000000000000000000
--- a/explosionfield/src/androidTest/java/tyrantgit/explosionfield/ApplicationTest.java
+++ /dev/null
@@ -1,13 +0,0 @@
-package tyrantgit.explosionfield;
-
-import android.app.Application;
-import android.test.ApplicationTestCase;
-
-/**
- * Testing Fundamentals
- */
-public class ApplicationTest extends ApplicationTestCase {
- public ApplicationTest() {
- super(Application.class);
- }
-}
\ No newline at end of file
diff --git a/explosionfield/src/main/AndroidManifest.xml b/explosionfield/src/main/AndroidManifest.xml
deleted file mode 100644
index 01dff5719728a10aecef1fb7bfcd504ae24c3b92..0000000000000000000000000000000000000000
--- a/explosionfield/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
-
-
-
-
-
-
diff --git a/explosionfield/src/main/config.json b/explosionfield/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..cc59addb45dee30ec69e4a1fee22bc675df3d333
--- /dev/null
+++ b/explosionfield/src/main/config.json
@@ -0,0 +1,27 @@
+{
+ "app": {
+ "bundleName": "com.tyrantgit.sample",
+ "vendor": "tyrantgit",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.tyrantgit.explosionfield",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "explosionfield",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionAnimator.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java
similarity index 55%
rename from explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionAnimator.java
rename to explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java
index 21f9a0090279169349650e0d5d27650a7f482c96..c527ac088048163deb6ea1e0bf979baf976f37fe 100644
--- a/explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionAnimator.java
+++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionAnimator.java
@@ -1,11 +1,10 @@
/*
- * Copyright (C) 2015 tyrantgit
- *
+ * 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 a copy of the License at
+ * You may obtain an copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -13,54 +12,74 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
- package tyrantgit.explosionfield;
-
-import android.animation.ValueAnimator;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Color;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.view.View;
-import android.view.animation.AccelerateInterpolator;
-import android.view.animation.Interpolator;
+package com.tyrantgit.explosionfield;
+
+import com.tyrantgit.explosionfield.util.AnimatorValueUtil;
+import com.tyrantgit.explosionfield.util.LogUtils;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Rect;
+import ohos.media.image.PixelMap;
+import ohos.media.image.common.Position;
import java.util.Random;
-public class ExplosionAnimator extends ValueAnimator {
+public class ExplosionAnimator extends AnimatorValue implements AnimatorValue.ValueUpdateListener {
- static long DEFAULT_DURATION = 0x400;
- private static final Interpolator DEFAULT_INTERPOLATOR = new AccelerateInterpolator(0.6f);
+ private static final String TAG = "ExplosionDemo_ExplosionAnimator";
+
+ public static final long DEFAULT_DURATION = 0x400;
private static final float END_VALUE = 1.4f;
- private static final float X = Utils.dp2Px(5);
- private static final float Y = Utils.dp2Px(20);
- private static final float V = Utils.dp2Px(2);
- private static final float W = Utils.dp2Px(1);
+ private static final float X = Utils.dp2Px(ExplosionField.context, 5);
+ private static final float Y = Utils.dp2Px(ExplosionField.context, 20);
+ private static final float V = Utils.dp2Px(ExplosionField.context, 2);
+ private static final float W = Utils.dp2Px(ExplosionField.context, 1);
private Paint mPaint;
private Particle[] mParticles;
private Rect mBound;
- private View mContainer;
+ private ExplosionField mContainer;
+ private float currentValue = 0;
+ private final AnimatorValueUtil animatorValueUtil;
+
+ public void ofFloat(float[] values) {
+ animatorValueUtil.setValues(values);
+ animatorValueUtil.ofFloat();
+ }
+
+ public ExplosionAnimator(ExplosionField container, PixelMap bitmap, Rect bound) {
- public ExplosionAnimator(View container, Bitmap bitmap, Rect bound) {
mPaint = new Paint();
+
mBound = new Rect(bound);
+
int partLen = 15;
+
mParticles = new Particle[partLen * partLen];
+
Random random = new Random(System.currentTimeMillis());
- int w = bitmap.getWidth() / (partLen + 2);
- int h = bitmap.getHeight() / (partLen + 2);
+ int w = bitmap.getImageInfo().size.width / (partLen + 2);
+ int h = bitmap.getImageInfo().size.height / (partLen + 2);
+
for (int i = 0; i < partLen; i++) {
for (int j = 0; j < partLen; j++) {
- mParticles[(i * partLen) + j] = generateParticle(bitmap.getPixel((j + 1) * w, (i + 1) * h), random);
+ Position position = new Position((j + 1) * w, (i + 1) * h);
+ mParticles[(i * partLen) + j] = generateParticle(bitmap.readPixel(position), random);
}
}
+
+ animatorValueUtil = new AnimatorValueUtil();
+
mContainer = container;
- setFloatValues(0f, END_VALUE);
- setInterpolator(DEFAULT_INTERPOLATOR);
+ setCurveType(CurveType.ACCELERATE_DECELERATE);
setDuration(DEFAULT_DURATION);
+ setValueUpdateListener(this::onUpdate);
+
}
private Particle generateParticle(int color, Random random) {
+
Particle particle = new Particle();
particle.color = color;
particle.radius = V;
@@ -70,45 +89,55 @@ public class ExplosionAnimator extends ValueAnimator {
particle.baseRadius = W + ((V - W) * random.nextFloat());
}
float nextFloat = random.nextFloat();
- particle.top = mBound.height() * ((0.18f * random.nextFloat()) + 0.2f);
+ particle.top = mBound.getHeight() * ((0.18f * random.nextFloat()) + 0.2f);
particle.top = nextFloat < 0.2f ? particle.top : particle.top + ((particle.top * 0.2f) * random.nextFloat());
- particle.bottom = (mBound.height() * (random.nextFloat() - 0.5f)) * 1.8f;
+ particle.bottom = (mBound.getHeight() * (random.nextFloat() - 0.5f)) * 1.8f;
float f = nextFloat < 0.2f ? particle.bottom : nextFloat < 0.8f ? particle.bottom * 0.6f : particle.bottom * 0.3f;
particle.bottom = f;
particle.mag = 4.0f * particle.top / particle.bottom;
particle.neg = (-particle.mag) / particle.bottom;
- f = mBound.centerX() + (Y * (random.nextFloat() - 0.5f));
+ f = mBound.getCenterX() + (Y * (random.nextFloat() - 0.5f));
particle.baseCx = f;
particle.cx = f;
- f = mBound.centerY() + (Y * (random.nextFloat() - 0.5f));
+ f = mBound.getCenterY() + (Y * (random.nextFloat() - 0.5f));
particle.baseCy = f;
particle.cy = f;
particle.life = END_VALUE / 10 * random.nextFloat();
particle.overflow = 0.4f * random.nextFloat();
particle.alpha = 1f;
return particle;
+
}
- public boolean draw(Canvas canvas) {
- if (!isStarted()) {
+ public boolean draw(Canvas canvas, float offsetTop) {
+ if (!isRunning()) {
return false;
}
for (Particle particle : mParticles) {
- particle.advance((float) getAnimatedValue());
+ particle.advance(currentValue);
if (particle.alpha > 0f) {
- mPaint.setColor(particle.color);
- mPaint.setAlpha((int) (Color.alpha(particle.color) * particle.alpha));
- canvas.drawCircle(particle.cx, particle.cy, particle.radius, mPaint);
+ mPaint.setColor(new Color(particle.color));
+ mPaint.setAlpha((Color.alpha(particle.color) * particle.alpha)/255);
+ canvas.drawCircle(particle.cx, particle.cy - offsetTop, particle.radius, mPaint);
}
}
- mContainer.invalidate();
return true;
}
@Override
public void start() {
super.start();
- mContainer.invalidate(mBound);
+ }
+
+ @Override
+ public void onUpdate(AnimatorValue animatorValue, float v) {
+
+ currentValue = animatorValueUtil.getValue(v);
+
+ LogUtils.info(TAG, "currentValue = " + currentValue + ", v = " + v);
+
+ mContainer.refresh();
+
}
private class Particle {
@@ -127,8 +156,8 @@ public class ExplosionAnimator extends ValueAnimator {
float life;
float overflow;
-
public void advance(float factor) {
+
float f = 0f;
float normalization = factor / END_VALUE;
if (normalization < life || normalization > 1f - overflow) {
diff --git a/explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionField.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java
similarity index 34%
rename from explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionField.java
rename to explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java
index f4f06e141303dc0c5510d459d978271ed9e4c83f..11d67ef8822c378baa2e417a13127932e2c1dd68 100644
--- a/explosionfield/src/main/java/tyrantgit/explosionfield/ExplosionField.java
+++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/ExplosionField.java
@@ -1,11 +1,10 @@
/*
- * Copyright (C) 2015 tyrantgit
- *
+ * 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 a copy of the License at
+ * You may obtain an copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * 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,
@@ -13,56 +12,76 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package tyrantgit.explosionfield;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.animation.ValueAnimator;
-import android.app.Activity;
-import android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.Rect;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.Window;
+package com.tyrantgit.explosionfield;
+
+import com.tyrantgit.explosionfield.util.LogUtils;
+import ohos.aafwk.ability.Ability;
+import ohos.agp.animation.Animator;
+import ohos.agp.animation.AnimatorValue;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.ComponentContainer;
+import ohos.agp.render.Canvas;
+import ohos.agp.utils.Rect;
+import ohos.app.Context;
+import ohos.media.image.PixelMap;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
+public class ExplosionField extends Component implements Component.DrawTask {
-public class ExplosionField extends View {
+ private static final String TAG = "ExplosionDemo_ExplosionField";
private List mExplosions = new ArrayList<>();
private int[] mExpandInset = new int[2];
- public ExplosionField(Context context) {
+ private Component component;
+
+ private static int offsetTop = 0;
+
+ public static Context context;
+
+ public ExplosionField(Context context, Component component) {
super(context);
+ this.component = component;
init();
+
}
- public ExplosionField(Context context, AttributeSet attrs) {
+ public void refresh(){
+ this.component.invalidate();
+ }
+
+ public ExplosionField(Context context, AttrSet attrs) {
super(context, attrs);
init();
}
- public ExplosionField(Context context, AttributeSet attrs, int defStyleAttr) {
+ public ExplosionField(Context context, AttrSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
private void init() {
- Arrays.fill(mExpandInset, Utils.dp2Px(32));
+
+ context = getContext();
+
+ Arrays.fill(mExpandInset, Utils.dp2Px(getContext(),32));
+
+ component.addDrawTask(this);
+
}
@Override
- protected void onDraw(Canvas canvas) {
- super.onDraw(canvas);
+ public void onDraw(Component component, Canvas canvas) {
+
+ offsetTop = component.getLocationOnScreen()[1];
+
for (ExplosionAnimator explosion : mExplosions) {
- explosion.draw(canvas);
+ explosion.draw(canvas, offsetTop);
}
}
@@ -71,42 +90,76 @@ public class ExplosionField extends View {
mExpandInset[1] = dy;
}
- public void explode(Bitmap bitmap, Rect bound, long startDelay, long duration) {
+ public void explode(PixelMap bitmap, Rect bound, long startDelay, long duration) {
+
final ExplosionAnimator explosion = new ExplosionAnimator(this, bitmap, bound);
- explosion.addListener(new AnimatorListenerAdapter() {
+
+ explosion.setStateChangedListener(new Animator.StateChangedListener() {
+
+ @Override
+ public void onStart(Animator animator) {
+ }
+
+ @Override
+ public void onStop(Animator animator) {
+ }
+
+ @Override
+ public void onCancel(Animator animator) {
+ }
+
@Override
- public void onAnimationEnd(Animator animation) {
- mExplosions.remove(animation);
+ public void onEnd(Animator animator) {
+ mExplosions.remove(animator);
+ }
+
+ @Override
+ public void onPause(Animator animator) {
+ }
+
+ @Override
+ public void onResume(Animator animator) {
}
});
- explosion.setStartDelay(startDelay);
+
+ explosion.setDelay(startDelay);
explosion.setDuration(duration);
+ explosion.ofFloat(new float[]{0, 1.4F});
mExplosions.add(explosion);
explosion.start();
}
- public void explode(final View view) {
+ public void explode(final Component view) {
+
Rect r = new Rect();
- view.getGlobalVisibleRect(r);
- int[] location = new int[2];
- getLocationOnScreen(location);
- r.offset(-location[0], -location[1]);
- r.inset(-mExpandInset[0], -mExpandInset[1]);
- int startDelay = 100;
- ValueAnimator animator = ValueAnimator.ofFloat(0f, 1f).setDuration(150);
- animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
+ Rect r2 = new Rect();
+ Rect r3 = new Rect();
+ view.getSelfVisibleRect(r2);
- Random random = new Random();
+ int[] location = view.getLocationOnScreen();
+ r.left = location[0];
+ r.top = location[1];
+ r.right = r.left + view.getWidth();
+ r.bottom = r.top + view.getHeight();
+
+ Utils.inset(r, -mExpandInset[0], -mExpandInset[1]);
+ int startDelay = 150;
+
+ AnimatorValue animator = new AnimatorValue();
+ animator.setDuration(startDelay);
+ animator.setValueUpdateListener(new AnimatorValue.ValueUpdateListener() {
+ Random random = new Random();
@Override
- public void onAnimationUpdate(ValueAnimator animation) {
+ public void onUpdate(AnimatorValue animatorValue, float v) {
view.setTranslationX((random.nextFloat() - 0.5f) * view.getWidth() * 0.05f);
view.setTranslationY((random.nextFloat() - 0.5f) * view.getHeight() * 0.05f);
-
}
});
animator.start();
- view.animate().setDuration(150).setStartDelay(startDelay).scaleX(0f).scaleY(0f).alpha(0f).start();
+
+ view.createAnimatorProperty().setDuration(150).setDelay(startDelay).scaleX(0f).scaleY(0f).alpha(0f).start();
+
explode(Utils.createBitmapFromView(view), r, startDelay, ExplosionAnimator.DEFAULT_DURATION);
}
@@ -115,11 +168,15 @@ public class ExplosionField extends View {
invalidate();
}
- public static ExplosionField attach2Window(Activity activity) {
- ViewGroup rootView = (ViewGroup) activity.findViewById(Window.ID_ANDROID_CONTENT);
- ExplosionField explosionField = new ExplosionField(activity);
- rootView.addView(explosionField, new ViewGroup.LayoutParams(
- ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
+ public static ExplosionField attach2Window(Ability ability, Component component) {
+
+ ability.setUIContent(ResourceTable.Layout_layout);
+ ComponentContainer componentContainer = (ComponentContainer)ability.findComponentById(ResourceTable.Id_explosion_field_root);
+ ExplosionField explosionField = new ExplosionField(ability, component);
+ componentContainer.addComponent(component);
+ componentContainer.addComponent(explosionField, new ComponentContainer.LayoutConfig(
+ ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT));
+
return explosionField;
}
diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java
new file mode 100644
index 0000000000000000000000000000000000000000..19ceb7eb6147ed693dfc74aea61ef425cd92ae52
--- /dev/null
+++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/Utils.java
@@ -0,0 +1,124 @@
+/*
+ * 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.tyrantgit.explosionfield;
+
+import com.tyrantgit.explosionfield.util.LogUtils;
+import ohos.agp.components.Component;
+import ohos.agp.components.Image;
+import ohos.agp.components.Text;
+import ohos.agp.render.Canvas;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.Rect;
+import ohos.agp.window.service.Display;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+import ohos.media.image.PixelMap;
+import ohos.media.image.common.PixelFormat;
+import ohos.media.image.common.Size;
+
+import java.util.Optional;
+
+public class Utils {
+
+ private static final Canvas sCanvas = new Canvas();
+
+ private static final String TAG = "ExplosionDemo_Utils";
+
+ public static DisplayAttributes getScreenPixel(Context context) {
+ // 获取屏幕密度
+ Optional display = DisplayManager.getInstance().getDefaultDisplay(context);
+ DisplayAttributes displayAttributes = display.get().getAttributes();
+ return displayAttributes;
+ }
+
+ public static int dp2Px(Context context, float dp) {
+ // 获取屏幕密度
+ DisplayAttributes displayAttributes = getScreenPixel(context);
+ return (int) (dp * displayAttributes.scalDensity);
+ }
+
+ public static PixelMap createBitmapFromView(Component view) {
+
+ LogUtils.info(TAG, "PixelMap");
+
+ if (view instanceof Image) {
+
+ return ((Image) view).getPixelMap();
+
+ }
+
+ if (view instanceof Text) {
+ Color textColor = ((Text)view).getTextColor();
+ PixelMap bitmap = createBitmapSafely(view.getWidth(),
+ view.getHeight(), textColor);
+
+ return bitmap;
+
+ }
+
+ return null;
+
+ }
+ public static PixelMap createBitmapSafely(int width, int height, Color color) {
+ PixelMap.InitializationOptions options = new PixelMap.InitializationOptions();
+ options.size = new Size(width, height);
+ options.pixelFormat = PixelFormat.ARGB_8888;
+ options.editable = true;
+ int alphaColor = Color.getIntColor("#00000000");
+ int colors[] = new int[width * height];
+ for (int i = 0; i < width * height; i++) {
+ if (i % 5 == 0) {
+ colors[i] = color.getValue();
+ } else {
+ colors[i] = alphaColor;
+ }
+ }
+ return PixelMap.create(colors, options);
+ }
+
+ public static PixelMap createBitmapSafely(int width, int height, int retryCount) {
+ try {
+
+ PixelMap.InitializationOptions options = new PixelMap.InitializationOptions();
+ options.size = new Size(width, height);
+ options.pixelFormat = PixelFormat.ARGB_8888;
+ options.editable = true;
+ return PixelMap.create(options);
+
+ } catch (OutOfMemoryError e) {
+ e.printStackTrace();
+ if (retryCount > 0) {
+ System.gc();
+ return createBitmapSafely(width, height, retryCount - 1);
+ }
+ return null;
+ }
+ }
+
+ public static void offset(Rect rect, int dx, int dy) {
+ rect.left += dx;
+ rect.top += dy;
+ rect.right += dx;
+ rect.bottom += dy;
+ }
+
+ public static void inset(Rect rect, int dx, int dy) {
+ rect.left += dx;
+ rect.top += dy;
+ rect.right -= dx;
+ rect.bottom -= dy;
+ }
+}
diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java
new file mode 100644
index 0000000000000000000000000000000000000000..d853cfa34d24268797f3c1f4fc51f50621017e80
--- /dev/null
+++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/AnimatorValueUtil.java
@@ -0,0 +1,105 @@
+/*
+ * 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
+ *
+ * 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.tyrantgit.explosionfield.util;
+
+import java.math.BigDecimal;
+
+/**
+ * ex.
+ * AnimatorValueUtil animatorValueUtil = new AnimatorValueUtil();
+ * animatorValueUtil.ofFloat(0.1f,-3f,2f)
+ * public void onUpdate(AnimatorValue animatorValue, float v) {
+ * float currentV = animatorValueUtil.getValue(v);
+ * }
+ *
+ * @since 2021-04-06
+ */
+public class AnimatorValueUtil {
+ private static final String TAG = "AnimatorValueUtil";
+ private static final int RATESIZE = 2;
+ private static final int NEGATIVE = -1;
+
+ private float[] values;
+ private float[][] rate;
+
+ /**
+ * 设置动画区间
+ *
+ * @param values 动画区间值
+ */
+ public void setValues(float[] values) {
+ if (values == null) {
+ this.values = null;
+ } else {
+ this.values = (float[]) values.clone();
+ }
+ }
+
+ /**
+ * 获取动画值区间
+ *
+ * @return float数组
+ */
+ public float[] getValues() {
+ return (float[]) values.clone();
+ }
+
+ /**
+ * 如传一个参数,则getValue 返回值与传入的 V 值一致
+ * 如传入连续两个相同参数,则会出现除0异常
+ * 传参试例: 0.8f,-1.2f,3.5f,0,5
+ *
+ */
+ public void ofFloat() {
+ rate = new float[this.getValues().length - 1][RATESIZE];
+ float sum = 0;
+ for (int index = 1; index < this.getValues().length; index++) {
+ sum += Math.abs(this.getValues()[index] - this.getValues()[index - 1]);
+ }
+
+ // 计算每个变化值的占比和达到该变化值系数
+ for (int index = 0; index < rate.length; index++) {
+ float tempRate = Math.abs((this.getValues()[index + 1] - this.getValues()[index]) / sum);
+ rate[index][0] = tempRate + (index == 0 ? 0 : rate[index - 1][0]);
+ float tempDuration = this.getValues()[index + 1] - this.getValues()[index];
+ rate[index][1] = (this.getValues()[index] > this.getValues()[index + 1]
+ ? NEGATIVE : 1) * Math.abs(tempDuration / tempRate);
+ }
+ }
+
+ /**
+ * 根据 属性动画中value的值,计算当前值
+ *
+ * @param value 属性动画中的value
+ * @return 通过计算后的值
+ */
+ public float getValue(float value) {
+ for (int index = 0; index < rate.length; index++) {
+ // 如果是进入当前变化值占比,则按当前系数进行计算实际值(bounce回弹效果最后v会大于1)
+ if (value <= rate[index][0] || value > 1) {
+ float amintorValue;
+ if (index == 0) {
+ amintorValue = value;
+ } else {
+ amintorValue = new BigDecimal(value).subtract(new BigDecimal(rate[index - 1][0])).floatValue();
+ }
+ return new BigDecimal(amintorValue).multiply(new BigDecimal(rate[index][1])).add(
+ new BigDecimal(getValues()[index])).floatValue();
+ }
+ }
+ return value;
+ }
+}
diff --git a/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/LogUtils.java b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/LogUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..bcbdf2ef3b7db34acb41f5f0fce83d9846900305
--- /dev/null
+++ b/explosionfield/src/main/java/com/tyrantgit/explosionfield/util/LogUtils.java
@@ -0,0 +1,43 @@
+/*
+ * 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
+ *
+ * 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.tyrantgit.explosionfield.util;
+
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * LogUtil
+ *
+ * @since 2021-04-06
+ */
+public class LogUtils {
+ private static final HiLogLabel LABEL_LOG = new HiLogLabel(3, 0xD000f00, "dqh");
+
+ private static final String LOG_FORMAT = "%{public}s:%{public}s";
+
+ private LogUtils() {
+ }
+
+ /**
+ * 打印info信息
+ *
+ * @param tag
+ * @param msg
+ */
+ public static void info(String tag, String msg) {
+ HiLog.info(LABEL_LOG, LOG_FORMAT, tag, msg);
+ }
+}
diff --git a/explosionfield/src/main/java/tyrantgit/explosionfield/Utils.java b/explosionfield/src/main/java/tyrantgit/explosionfield/Utils.java
deleted file mode 100644
index fedbc93a8c27798af8ba80d9b264e9e64905818d..0000000000000000000000000000000000000000
--- a/explosionfield/src/main/java/tyrantgit/explosionfield/Utils.java
+++ /dev/null
@@ -1,72 +0,0 @@
-/*
- * Copyright (C) 2015 tyrantgit
- *
- * 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 a 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 tyrantgit.explosionfield;
-
-
-import android.content.res.Resources;
-import android.graphics.Bitmap;
-import android.graphics.Canvas;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.view.View;
-import android.widget.ImageView;
-
-public class Utils {
-
- private Utils() {
- }
-
- private static final float DENSITY = Resources.getSystem().getDisplayMetrics().density;
- private static final Canvas sCanvas = new Canvas();
-
- public static int dp2Px(int dp) {
- return Math.round(dp * DENSITY);
- }
-
- public static Bitmap createBitmapFromView(View view) {
- if (view instanceof ImageView) {
- Drawable drawable = ((ImageView) view).getDrawable();
- if (drawable != null && drawable instanceof BitmapDrawable) {
- return ((BitmapDrawable) drawable).getBitmap();
- }
- }
- view.clearFocus();
- Bitmap bitmap = createBitmapSafely(view.getWidth(),
- view.getHeight(), Bitmap.Config.ARGB_8888, 1);
- if (bitmap != null) {
- synchronized (sCanvas) {
- Canvas canvas = sCanvas;
- canvas.setBitmap(bitmap);
- view.draw(canvas);
- canvas.setBitmap(null);
- }
- }
- return bitmap;
- }
-
- public static Bitmap createBitmapSafely(int width, int height, Bitmap.Config config, int retryCount) {
- try {
- return Bitmap.createBitmap(width, height, config);
- } catch (OutOfMemoryError e) {
- e.printStackTrace();
- if (retryCount > 0) {
- System.gc();
- return createBitmapSafely(width, height, config, retryCount - 1);
- }
- return null;
- }
- }
-}
diff --git a/explosionfield/src/main/res/values/strings.xml b/explosionfield/src/main/res/values/strings.xml
deleted file mode 100644
index 56b0f0fbbed2abaf6c16d2247ecbb35a322c98b6..0000000000000000000000000000000000000000
--- a/explosionfield/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- ExplosionField
-
diff --git a/explosionfield/src/main/resources/base/element/string.json b/explosionfield/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..77dca3b75e671515fabaace580269ed0e77204c1
--- /dev/null
+++ b/explosionfield/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "explosionfield"
+ }
+ ]
+}
diff --git a/explosionfield/src/main/resources/base/layout/layout.xml b/explosionfield/src/main/resources/base/layout/layout.xml
new file mode 100644
index 0000000000000000000000000000000000000000..bfdd9408835dd551090860dc3ec1cd14881be64c
--- /dev/null
+++ b/explosionfield/src/main/resources/base/layout/layout.xml
@@ -0,0 +1,8 @@
+
+
+
\ No newline at end of file
diff --git a/explosionfield/src/test/java/com/tyrantgit/explosionfield/ExampleTest.java b/explosionfield/src/test/java/com/tyrantgit/explosionfield/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..08d32654e00b0490525be8b36296915b3f6a5c29
--- /dev/null
+++ b/explosionfield/src/test/java/com/tyrantgit/explosionfield/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.tyrantgit.explosionfield;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 8c0fb64a8698b08ecc4158d828ca593c4928e9dd..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index 69758a6e86037bd1e78affb53762f32f97b4d191..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Wed Sep 23 17:18:18 CST 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.4-all.zip
diff --git a/gradlew b/gradlew
index 91a7e269e19dfc62e27137a0b57ef3e430cee4fd..536f0272dd995f3afdb5e34e0f42bdf3d1986c22 100644
--- a/gradlew
+++ b/gradlew
@@ -1,4 +1,20 @@
-#!/usr/bin/env bash
+#!/usr/bin/env sh
+
+#
+# Copyright 2015 the original author or authors.
+#
+# 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 a copy of the License at
+#
+# https://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.
+#
##############################################################################
##
@@ -6,159 +22,162 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
- echo "$*"
+warn() {
+ echo "$*"
}
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
esac
-# For Cygwin, ensure paths are in UNIX format before anything is touched.
-if $cygwin ; then
- [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"`
-fi
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >&-
-APP_HOME="`pwd -P`"
-cd "$SAVED" >&-
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ]; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
+ fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+ MAX_FD_LIMIT=$(ulimit -H -n)
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ MAX_FD="$MAX_FD_LIMIT"
fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ]; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@"; do
+ CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+ CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+ eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+ else
+ eval $(echo args$i)="\"$arg\""
fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
+ i=$(expr $i + 1)
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/img/ExplosionField.gif b/img/ExplosionField.gif
new file mode 100644
index 0000000000000000000000000000000000000000..38051383c94c62d52c787483cbf7f36b4bec8ed2
Binary files /dev/null and b/img/ExplosionField.gif differ
diff --git a/settings.gradle b/settings.gradle
index e2b5bfb24ccd2f0dd448c9ebb7133247110bf1f6..02b64916f4f16f4c62bbcb2a38cd6537b3c5d409 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':explosionfield'
+include ':entry', ':explosionfield'