diff --git a/.gitignore b/.gitignore
index 0f41f1b186481904e6048793230a0573ed536e17..c5986840b05025a898d4ea39abbc0fbf237b6270 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,57 +1,15 @@
-### Android ###
-# Built application files
-*.apk
-*.ap_
-
-# Files for the Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-
-# Gradle files
-.gradle/
-build/
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-
-### Intellij ###
-# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm
-
-## Directory-based project format
-.idea/
-# if you remove the above rule, at least ignore user-specific stuff:
-# .idea/workspace.xml
-# .idea/tasks.xml
-# and these sensitive or high-churn files:
-# .idea/dataSources.ids
-# .idea/dataSources.xml
-# .idea/sqlDataSources.xml
-# .idea/dynamic.xml
-
-## File-based project format
-*.ipr
-*.iws
*.iml
-
-## Additional for IntelliJ
-out/
-
-# generated by mpeltonen/sbt-idea plugin
-.idea_modules/
-
-# generated by JIRA plugin
-atlassian-ide-plugin.xml
-
-# generated by Crashlytics plugin (for Android Studio and Intellij)
-com_crashlytics_export_strings.xml
-
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
+.DS_Store
+/build
+/captures
+.externalNativeBuild
+.cxx
+upload.gradle
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 94258adc35ba5f87b700119d462d2d776b0a4501..0114b71d0a8537d1fc82d6a53e4853bd2f62ba4d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,58 +1,13 @@
-## 1.0.4
-* Fixed issue #37 Broken normal text behaviour
-
-## 1.0.3
-* Added focused and selected states
-
-## 1.0.2
-* Added library description file for About AboutLibraries
-
-## 1.0.1
-* Fixed issue: buggy behavior when an endless button gets re-sized #14
-
-## 1.0.0
-* Fixed issue: Button padding are ignored #11
-* Added prefix 'pb_' for all custom attributes to avoid conflict #12
-
-## 0.0.7
-* Added api 10 compatibility
-* Fixed bug in ProgressGenerator class
-
-## 0.0.6
-Bug fixes
-
-## 0.0.5
-* Fixed repository name type from `android-process-buton` to `android-process-button`
-
-## 0.0.4
-**Attributes**
-
-Renamed attributes:
-
- * `progressText` -> `textProgress`
- * `completeText` -> `textComplete`
-
-Added attribute to control button corner roundness:
-
-* `cornerRadius`
-
-
-**ProcessButton**
-
-Now button state depends on progress:
-
-* normal state [0]
-* progress state [1-99]
-* success state [100]
-* error state [-1] *new
-
-Added abstract `drawProgress` method to simplify creation different progress buttons.
-
-General code clean-up.
-
-Thanks to **@avrahamshuk** for contribution.
-
-## 0.0.3
-
-* Fixed bug when all buttons where sharing the same drawable state
-* Uploaded proejct to Maven Central
+## 0.0.3-SNAPSHOT
+* modification: Update copyright
+
+## 0.0.2-SNAPSHOT
+* optimization: Optimize code
+
+## 0.0.1-SNAPSHOT
+ohos 第一个版本
+ * 实现了原库的大部分 api
+ * 因为 "TextField组件特性" 原因,"首次进入账户名文本框边框线为选中状态、高亮蓝色,密码框边框线为灰色" 功能未能实现
+ * 因为 "系统组件特性" 原因,"打开process-button组件,然后任选其中一个进度条进入,长按进度按钮不松开,然后在按钮范围之内移动,然后松开" 功能未能实现
+ * 因为 "TextField组件特性" 原因,"文本框上移动光标,内容会跟着光标的移动放大文本" 功能未能实现
+ * 因为 "TextField组件特性" 原因,"光标展示几秒后会消失、在输入内容时光标会消失" 功能未能实现
\ No newline at end of file
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..ed8e562f99b4f9b62f745b5c03cee825cc11fa45
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,19 @@
+[
+
+ {
+
+ "Name": "android-process-button",
+
+ "License": "The MIT License (MIT)",
+
+ "License File": "LICENSE",
+
+ "Version Number": "v0.0.7",
+
+ "Upstream URL": "https://github.com/dmytrodanylyk/android-process-button",
+
+ "Description": "带加载进度和Loading状态的Button组件库"
+
+ }
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 91ec00bd59ec21a9e7afa48cd36786407ec13a32..b17993e39810c698f8019656b298b794ec78f025 100644
--- a/README.md
+++ b/README.md
@@ -1,39 +1,213 @@
-### Description [![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.dmytrodanylyk.android-process-button/library/badge.png?style=flat)](http://goo.gl/GydnKe) [![Android Arsenal](https://img.shields.io/badge/Android%20Arsenal-Android%20Process%20Button-brightgreen.svg?style=flat)](https://android-arsenal.com/details/1/367)
+# ohos-process-button
+
+
+#### 项目介绍
+- 项目名称:ohos-process-button
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:显示Button各种加载状态
+- 项目移植状态:100%
+- 调用差异:无
+- 开发版本:sdk5,DevEco Studio2.1 beta4
+- 基线版本:Release v0.0.7
+
+#### 效果演示
+
+
+#### 安装教程
+
+1.在项目根目录下的build.gradle文件中,
+ ```gradle
+allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+}
+ ```
+
+2.在entry模块的build.gradle文件中,
+ ```gradle
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:ohos-process-button:0.0.1-SNAPSHOT')
+ ......
+ }
+```
-Android Buttons With Built-in Progress Meters.
+在sdk5,DevEco Studio2.1 beta4下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
-![](screenshots/sample1_small1.gif)
-![](screenshots/sample1_small2.gif)
+#### 使用说明
-### Wiki
+1.使用相关的类:
+- ProcessButton - 可拓展的基础类,实现drawProgress抽象方法可实现自己想要的Button效果
+- ActionProcessButton - 用来显示正在loading状态的Button
+- GenerateProcessButton - 用来显示当前进度的Button(水平方向)
+- SubmitProcessButton - 用来表示当前进度的Button(垂直方向)
-- [Home]
-- [Screenshots]
-- [User Guide]
-### Integration
+2.使用实例
+初始sample的构建
+```
+ public class StateSampleSlice extends Ability implements Component.ClickedListener {
+ private ActionProcessButton actionProcessButton;
+ private GenerateProcessButton generateProcessButton;
+ private SubmitProcessButton submitProcessButton;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_state_sample_silice);
+ actionProcessButton = (ActionProcessButton) findComponentById(ResourceTable.Id_state_sample_action);
+ actionProcessButton.setMode(ActionProcessButton.Mode.ENDLESS);
+ generateProcessButton = (GenerateProcessButton) findComponentById(ResourceTable.Id_state_sample_generate);
+ submitProcessButton = (SubmitProcessButton) findComponentById(ResourceTable.Id_state_sample_submit);
+
+ findComponentById(ResourceTable.Id_error_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_noramal_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_half_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_success_button).setClickedListener(this);
+ }
+
+ @Override
+ public void onClick(Component component) {
+ switch (component.getId()) {
+ case ResourceTable.Id_error_button:
+ actionProcessButton.setProgress(-1);
+ generateProcessButton.setProgress(-1);
+ submitProcessButton.setProgress(-1);
+ break;
+ case ResourceTable.Id_noramal_button:
+ actionProcessButton.setProgress(0);
+ generateProcessButton.setProgress(0);
+ submitProcessButton.setProgress(0);
+ break;
+ case ResourceTable.Id_half_button:
+ actionProcessButton.setProgress(50);
+ generateProcessButton.setProgress(50);
+ submitProcessButton.setProgress(50);
+ break;
+ case ResourceTable.Id_success_button:
+ actionProcessButton.setProgress(100);
+ generateProcessButton.setProgress(100);
+ submitProcessButton.setProgress(100);
+ break;
+ }
+ }
+
+ @Override
+ protected void onBackground() {
+ super.onBackground();
+ actionProcessButton.setProgress(0);
+ generateProcessButton.setProgress(0);
+ submitProcessButton.setProgress(0);
+ }
+
+ }
+```
-The lib is available on Maven Central, you can find it with [Gradle, please]
+3:相关属性的使用示例
+```
+
+
+
+
+
+
```
-dependencies {
- compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.4'
-}
+
+4:通用的ProcessButton相关方法的使用说明
```
+void setProgress(int progress); 设置按钮进度
+int getProgress(); 获取按钮进度
+
+void setMaxProgress(int mMaxProgress); 设置最大按钮进度
+int getMaxProgress(); 获取最大按钮进度
-### Sample
+void setMinProgress(int mMinProgress); 设置最小按钮进度
+int getMinProgress(); 获取最小按钮进度
-
-
-
-
-
-
+void setNormalText(CharSequence normalText); 设置正常状态下的Button文本
+String getNormalText(); 获取正常状态下的Button文本
-### License
+void setLoadingText(CharSequence loadingText); 设置loading状态下的Button文本
+String getLoadingText(); 获取loading状态下的Button文本
+
+void setCompleteText(CharSequence completeText); 设置完成后的Button文本
+String getCompleteText(); 获取完成后的Button文本
+
+void setErrorText(CharSequence errorText); 设置错误状态的Button文本
+String getErrorText(); 获取错误状态的Button文本
+
+void setProgressDrawable(ShapeElement progressDrawable); 设置加载中的Button样式
+ShapeElement getCompleteDrawable(); 获取加载中的Button样式
+
+void setCompleteDrawable(ShapeElement completeDrawable); 设置完成后的Button样式
+ShapeElement getCompleteDrawable(); 获取完成后的Button样式
+
+void setErrorDrawable(ShapeElement errorDrawable); 设置错误状态的Button样式
+ShapeElement getErrorDrawable(); 获取错误状态的Button样式
+
+```
+5:ActionProcessButton使用示例
+```
+ActionProcessButton actionProcessButton = (ActionProcessButton) findComponentById(ResourceTable.Id_btnSignIn);
+actionProcessButton.setMode(ActionProcessButton.Mode.ENDLESS);设置ActionProcessButton的loading样式为左右闪动
+actionProcessButton.setMode(ActionProcessButton.Mode.PROGRESS);设置ActionProcessButton的loading样式为Progress进度样式
+actionProcessButton.setColorScheme(int color1, int color2, int color3, int color4);设置ActionProcessButton的闪动样式颜色
+
+```
+
+#### 测试信息
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与原组件基本无差异
+
+
+#### 版本迭代
+
+- 0.0.1-SNAPSHOT
+
+#### 版权和许可信息
```
The MIT License (MIT)
@@ -56,12 +230,4 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
-```
-
-[SmoothProgressBar]:https://github.com/castorflex/SmoothProgressBar
-[Home]:https://github.com/dmytrodanylyk/android-process-buton/wiki
-[Screenshots]:https://github.com/dmytrodanylyk/android-process-buton/wiki/Screenshots
-[User Guide]:https://github.com/dmytrodanylyk/android-process-buton/wiki/User-Guide
-[Gradle, Please]:http://gradleplease.appspot.com/
-
-[![Analytics](https://ga-beacon.appspot.com/UA-44382495-2/android-process-buton/readme)](https://github.com/igrigorik/ga-beacon)
+```
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 25c1465a012f6fb7dc8453adda192fba2eecce2f..3e285905077f8453524f7aaf109135ce504899e5 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,26 +1,43 @@
// 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://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:1.2.2'
-
- // NOTE: Do not place your application dependencies here; they belong
- // in the individual module build.gradle files
+ classpath 'com.huawei.ohos:hap:2.4.2.7'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
-def isReleaseBuild() {
- return version.contains("SNAPSHOT") == false
-}
-
allprojects {
- version = VERSION_NAME
- group = GROUP
-
repositories {
+ maven {
+ url 'https://mirrors.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
jcenter()
}
-}
\ No newline at end of file
+}
diff --git a/sample/.gitignore b/entry/.gitignore
similarity index 100%
rename from sample/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..e314b9198c4c3232b1011c5ffec482afce0111b2
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,15 @@
+apply plugin: 'com.huawei.ohos.hap'
+
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testCompile'junit:junit:4.12'
+ compile project(path: ':library')
+}
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..39bbcbe4ed254a8e9396fa1ba24bbe0ea5151f44
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,100 @@
+{
+ "app": {
+ "bundleName": "com.dd.sample",
+ "vendor": "dd",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.dd.sample",
+ "name": ".MyApplication",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry"
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.dd.sample.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "skills": [
+ {
+ "actions": [
+ "action.process_button.state_sample"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.dd.sample.StateSampleAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.dd.sample.SignInAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.dd.sample.slice.GenerateButtonSlice",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.dd.sample.slice.StateSampleSlice",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ },
+ {
+ "orientation": "unspecified",
+ "name": "com.dd.sample.slice.SubmitAbilitySlice",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "ohos_process_button",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/dd/sample/MainAbility.java b/entry/src/main/java/com/dd/sample/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..71f64247bffd3b4758c968bb86703ea6224049b3
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/MainAbility.java
@@ -0,0 +1,92 @@
+/*
+ * 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 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 com.dd.sample;
+
+import com.dd.sample.slice.GenerateButtonSlice;
+import com.dd.sample.slice.StateSampleSlice;
+import com.dd.sample.slice.SubmitAbilitySlice;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.aafwk.content.Operation;
+
+/**
+ * 主测试页面
+ *
+ * @since 2021-03-01
+ */
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+
+ findComponentById(ResourceTable.Id_button_progress).setClickedListener(component -> {
+ Intent intent2 = new Intent();
+ Operation operation = getOperation(SignInAbility.class.getName());
+
+ intent2.setParam(SignInAbility.EXTRAS_ENDLESS_MODE, false);
+ intent2.setOperation(operation);
+ startAbility(intent2);
+ });
+ findComponentById(ResourceTable.Id_endless_progress).setClickedListener(component -> {
+ Intent intent2 = new Intent();
+ Operation operation = getOperation(SignInAbility.class.getName());
+
+ intent2.setParam(SignInAbility.EXTRAS_ENDLESS_MODE, true);
+ intent2.setOperation(operation);
+ startAbility(intent2);
+ });
+ findComponentById(ResourceTable.Id_submit_btn).setClickedListener(component -> {
+ Intent intent2 = new Intent();
+ Operation operation = getOperation(SubmitAbilitySlice.class.getName());
+
+ intent2.setParam(SignInAbility.EXTRAS_ENDLESS_MODE, true);
+ intent2.setOperation(operation);
+ startAbility(intent2);
+ });
+ findComponentById(ResourceTable.Id_generate_btn).setClickedListener(component -> {
+ Intent intent2 = new Intent();
+ Operation operation = getOperation(GenerateButtonSlice.class.getName());
+ intent2.setOperation(operation);
+ startAbility(intent2);
+ });
+ findComponentById(ResourceTable.Id_state_sample).setClickedListener(component -> {
+ Intent intent2 = new Intent();
+ Operation operation = getOperation(StateSampleSlice.class.getName());
+ intent2.setOperation(operation);
+ startAbility(intent2);
+ });
+ }
+
+ private Operation getOperation(String abilityName) {
+ return new Intent.OperationBuilder()
+ .withDeviceId("")
+ .withBundleName(getBundleName())
+ .withAbilityName(abilityName)
+ .build();
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/MyApplication.java b/entry/src/main/java/com/dd/sample/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..882250c1877abfef8561d349ee22bc8da1a428a6
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/MyApplication.java
@@ -0,0 +1,29 @@
+/*
+ * 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 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 com.dd.sample;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+/**
+ * Application
+ * @since 2021-03-01
+ */
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/SignInAbility.java b/entry/src/main/java/com/dd/sample/SignInAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..51c4a89d46d0c64e2f58c157dd6077cdb4a9bef1
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/SignInAbility.java
@@ -0,0 +1,74 @@
+package com.dd.sample;
+
+import com.dd.processbutton.iml.ActionProcessButton;
+import com.dd.sample.utils.ProgressGenerator;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+import ohos.agp.components.TextField;
+
+public class SignInAbility extends Ability {
+ static final String EXTRAS_ENDLESS_MODE = "EXTRAS_ENDLESS_MODE";
+
+ private ActionProcessButton actionProcessButton;
+ private TextField num;
+ private TextField pass;
+ private ProgressGenerator progressGenerator;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_button_progress_slice);
+ actionProcessButton = (ActionProcessButton) findComponentById(ResourceTable.Id_btnSignIn);
+ num = (TextField) findComponentById(ResourceTable.Id_user_num);
+ pass = (TextField) findComponentById(ResourceTable.Id_user_password);
+
+ if (progressGenerator == null) {
+ progressGenerator = new ProgressGenerator(new ProgressGenerator.OnCompleteListener() {
+ @Override
+ public void onComplete() {
+ Toast.showLong(getContext(), "Loading Complete, button is disabled");
+ actionProcessButton.setEnabled(false);
+ }
+ });
+ }
+
+ boolean booleanParam = intent.getBooleanParam(EXTRAS_ENDLESS_MODE, false);
+ if (booleanParam) {
+ actionProcessButton.setMode(ActionProcessButton.Mode.ENDLESS);
+ } else {
+ actionProcessButton.setMode(ActionProcessButton.Mode.PROGRESS);
+ }
+ actionProcessButton.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ num.setEnabled(false);
+ pass.setEnabled(false);
+ num.clearFocus();
+ pass.clearFocus();
+ progressGenerator.start(actionProcessButton);
+ actionProcessButton.setEnabled(false);
+ }
+ });
+
+ }
+
+ @Override
+ protected void onBackground() {
+ super.onBackground();
+ }
+
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ progressGenerator.stop();
+ actionProcessButton.setProgress(0);
+ actionProcessButton.setEnabled(true);
+ num.setText("jondoe");
+ pass.setText("123456789");
+ num.setEnabled(true);
+ pass.setEnabled(true);
+ }
+
+}
diff --git a/sample/src/main/java/com/dd/sample/StateSampleActivity.java b/entry/src/main/java/com/dd/sample/StateSampleAbility.java
similarity index 35%
rename from sample/src/main/java/com/dd/sample/StateSampleActivity.java
rename to entry/src/main/java/com/dd/sample/StateSampleAbility.java
index 96909eed4bb0c5ca6366547395ef773e69e87b68..7fb2ae93249803bd66364bd706726ad882c562ca 100644
--- a/sample/src/main/java/com/dd/sample/StateSampleActivity.java
+++ b/entry/src/main/java/com/dd/sample/StateSampleAbility.java
@@ -1,55 +1,47 @@
package com.dd.sample;
-import com.dd.processbutton.iml.ActionProcessButton;
import com.dd.processbutton.iml.GenerateProcessButton;
import com.dd.processbutton.iml.SubmitProcessButton;
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
-public class StateSampleActivity extends Activity implements View.OnClickListener {
+public class StateSampleAbility extends Ability implements Component.ClickedListener {
- private ActionProcessButton mBtnAction;
private GenerateProcessButton mBtnGenerate;
private SubmitProcessButton mBtnSubmit;
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.ac_states);
-
- mBtnAction = (ActionProcessButton) findViewById(R.id.btnAction);
- mBtnSubmit = (SubmitProcessButton) findViewById(R.id.btnSubmit);
- mBtnGenerate = (GenerateProcessButton) findViewById(R.id.btnGenerate);
-
- findViewById(R.id.btnProgressLoading).setOnClickListener(this);
- findViewById(R.id.btnProgressError).setOnClickListener(this);
- findViewById(R.id.btnProgressComplete).setOnClickListener(this);
- findViewById(R.id.btnProgressNormal).setOnClickListener(this);
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ac_states);
+ mBtnSubmit = (SubmitProcessButton) findComponentById(ResourceTable.Id_btnSubmit);
+ mBtnGenerate = (GenerateProcessButton) findComponentById(ResourceTable.Id_btnGenerate);
+
+ findComponentById(ResourceTable.Id_btnProgressLoading).setClickedListener(this);
+ findComponentById(ResourceTable.Id_btnProgressError).setClickedListener(this);
+ findComponentById(ResourceTable.Id_btnProgressComplete).setClickedListener(this);
+ findComponentById(ResourceTable.Id_btnProgressNormal).setClickedListener(this);
}
@Override
- public void onClick(View v) {
- switch (v.getId()) {
- case R.id.btnProgressLoading:
- mBtnAction.setProgress(50);
+ public void onClick(Component component) {
+ switch (component.getId()) {
+ case ResourceTable.Id_btnProgressLoading:
mBtnSubmit.setProgress(50);
mBtnGenerate.setProgress(50);
break;
- case R.id.btnProgressError:
- mBtnAction.setProgress(-1);
+ case ResourceTable.Id_btnProgressError:
mBtnSubmit.setProgress(-1);
mBtnGenerate.setProgress(-1);
break;
- case R.id.btnProgressComplete:
- mBtnAction.setProgress(100);
+ case ResourceTable.Id_btnProgressComplete:
mBtnSubmit.setProgress(100);
mBtnGenerate.setProgress(100);
break;
- case R.id.btnProgressNormal:
- mBtnAction.setProgress(0);
+ case ResourceTable.Id_btnProgressNormal:
mBtnSubmit.setProgress(0);
mBtnGenerate.setProgress(0);
break;
diff --git a/entry/src/main/java/com/dd/sample/StateTextFiled.java b/entry/src/main/java/com/dd/sample/StateTextFiled.java
new file mode 100644
index 0000000000000000000000000000000000000000..0d7ed11eabc90955182955017888b7129d266a8f
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/StateTextFiled.java
@@ -0,0 +1,66 @@
+/*
+ * 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 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 com.dd.sample;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.TextField;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+
+/**
+ * 自定义状态的TextField
+ *
+ * @since 2021-03-01
+ */
+public class StateTextFiled extends TextField {
+ private final ShapeElement normalElement = new ShapeElement();
+ private final ShapeElement disableElement = new ShapeElement();
+
+ public StateTextFiled(Context context) {
+ super(context);
+ init();
+ }
+
+ public StateTextFiled(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ init();
+ }
+
+ public StateTextFiled(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ init();
+ }
+
+ private void init() {
+ normalElement.setRgbColor(RgbColor.fromArgbInt(Color.BLACK.getValue()));
+ disableElement.setRgbColor(RgbColor.fromArgbInt(Color.getIntColor("#eeeeee")));
+ this.setMultipleLine(false);
+ }
+
+ @Override
+ public void setEnabled(boolean enabled) {
+ super.setEnabled(enabled);
+ if (enabled) {
+ setBasement(normalElement);
+ setTextColor(new Color(Color.getIntColor("#000000")));
+ } else {
+ setBasement(disableElement);
+ setTextColor(new Color(Color.getIntColor("#6C6C6C")));
+ }
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/Toast.java b/entry/src/main/java/com/dd/sample/Toast.java
new file mode 100644
index 0000000000000000000000000000000000000000..245c951126e694ef32af38997f4e34a578979579
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/Toast.java
@@ -0,0 +1,255 @@
+/*
+ * 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 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 com.dd.sample;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.DirectionalLayout;
+import ohos.agp.components.Text;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.LayoutAlignment;
+import ohos.agp.utils.TextAlignment;
+import ohos.agp.window.dialog.ToastDialog;
+import ohos.agp.window.service.DisplayAttributes;
+import ohos.agp.window.service.DisplayManager;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.WrongTypeException;
+
+import java.io.IOException;
+
+/**
+ * Toast
+ *
+ * @since 2021-03-01
+ */
+public class Toast {
+ private static final int LENGTH_LONG = 4000;
+ private static final int LENGTH_SHORT = 2000;
+
+ /**
+ * Toast显示的位置枚举类型
+ *
+ * @since 2021-03-01
+ */
+ public enum ToastLayout {
+ /**
+ * 系统默认
+ */
+ DEFAULT,
+ /**
+ * 中间
+ */
+ CENTER,
+ /**
+ * 顶部
+ */
+ TOP,
+ /**
+ * 底部
+ */
+ BOTTOM,
+ }
+
+ private Toast() {
+ }
+
+ /**
+ * 显示短时间的Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void showShort(Context context, String content) {
+ createTost(context, content, LENGTH_SHORT, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示长时间的Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void showLong(Context context, String content) {
+ createTost(context, content, LENGTH_LONG, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void show(Context context, String content) {
+ createTost(context, content, LENGTH_SHORT, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param duration 时间 ms
+ */
+ public static void show(Context context, String content, int duration) {
+ createTost(context, content, duration, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param layout 位置
+ */
+ public static void show(Context context, String content, ToastLayout layout) {
+ createTost(context, content, LENGTH_SHORT, layout);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param duration 时间
+ * @param layout 位置
+ */
+ public static void show(Context context, String content, int duration, ToastLayout layout) {
+ createTost(context, content, duration, layout);
+ }
+
+ /**
+ * 显示短时Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void showShort(Context context, int content) {
+ createTost(context, getString(context, content), LENGTH_SHORT, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示长时Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void showLong(Context context, int content) {
+ createTost(context, getString(context, content), LENGTH_LONG, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ */
+ public static void show(Context context, int content) {
+ createTost(context, getString(context, content), LENGTH_SHORT, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param duration 时间 ms
+ */
+ public static void show(Context context, int content, int duration) {
+ createTost(context, getString(context, content), duration, ToastLayout.DEFAULT);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param layout 位置
+ */
+ public static void show(Context context, int content, ToastLayout layout) {
+ createTost(context, getString(context, content), LENGTH_SHORT, layout);
+ }
+
+ /**
+ * 显示Toast
+ *
+ * @param context 上下文
+ * @param content 内容
+ * @param duration 时间 ms
+ * @param layout 位置
+ */
+ public static void show(Context context, int content, int duration, ToastLayout layout) {
+ createTost(context, getString(context, content), duration, layout);
+ }
+
+ private static void createTost(Context context, String content, int duration, ToastLayout layout) {
+ DirectionalLayout toastLayout = new DirectionalLayout(context);
+ DirectionalLayout.LayoutConfig textConfig = new DirectionalLayout.LayoutConfig(
+ DirectionalLayout.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT);
+ Text text = new Text(context);
+ text.setText(content);
+ text.setTextColor(new Color(Color.getIntColor("#000000")));
+ text.setPadding(vp2px(context, 16), vp2px(context, 12), vp2px(context, 16), vp2px(context, 12));
+ text.setTextSize(vp2px(context, 12));
+ text.setBackground(buildDrawableByColorRadius(Color.getIntColor("#eeeeee"), vp2px(context, 20)));
+ text.setLayoutConfig(textConfig);
+ text.setTextAlignment(TextAlignment.CENTER);
+ toastLayout.addComponent(text);
+ int mLayout = LayoutAlignment.BOTTOM;
+ switch (layout) {
+ case TOP:
+ mLayout = LayoutAlignment.TOP;
+ break;
+ case BOTTOM:
+ mLayout = LayoutAlignment.BOTTOM;
+ break;
+ case CENTER:
+ mLayout = LayoutAlignment.CENTER;
+ break;
+ default:
+ break;
+ }
+ ToastDialog toastDialog = new ToastDialog(context);
+ toastDialog.setComponent(toastLayout);
+ toastDialog.setSize(DirectionalLayout.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT);
+ toastDialog.setAlignment(mLayout);
+ toastDialog.setTransparent(true);
+ toastDialog.setDuration(duration);
+ toastDialog.show();
+ }
+
+ private static ohos.agp.components.element.Element buildDrawableByColorRadius(int color, float radius) {
+ ShapeElement drawable = new ShapeElement();
+ drawable.setShape(0);
+ drawable.setRgbColor(RgbColor.fromArgbInt(color));
+ drawable.setCornerRadius(radius);
+ return drawable;
+ }
+
+ private static String getString(Context context, int resId) {
+ try {
+ return context.getResourceManager().getElement(resId).getString();
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ e.getMessage();
+ }
+ return "";
+ }
+
+ private static int vp2px(Context context, float vp) {
+ DisplayAttributes attributes = DisplayManager.getInstance().getDefaultDisplay(context).get().getAttributes();
+ return (int) (attributes.densityPixels * vp);
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/slice/GenerateButtonSlice.java b/entry/src/main/java/com/dd/sample/slice/GenerateButtonSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..33708c89d7eabaf19d3f47f9c8ff471a982cf6ed
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/slice/GenerateButtonSlice.java
@@ -0,0 +1,73 @@
+/*
+ * 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 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 com.dd.sample.slice;
+
+import com.dd.processbutton.iml.GenerateProcessButton;
+import com.dd.sample.ResourceTable;
+import com.dd.sample.Toast;
+import com.dd.sample.utils.ProgressGenerator;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+
+/**
+ * 测试GenerateProcessButton
+ *
+ * @since 2021-03-01
+ */
+public class GenerateButtonSlice extends Ability {
+ private GenerateProcessButton generateProcessButton;
+ private ProgressGenerator progressGenerator;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_generate_button_slice);
+ generateProcessButton = (GenerateProcessButton) findComponentById(ResourceTable.Id_generate_process_btn);
+ progressGenerator = new ProgressGenerator(new ProgressGenerator.OnCompleteListener() {
+ @Override
+ public void onComplete() {
+ Toast.showLong(getContext(),"Loading Complete, button is disabled");
+ }
+ });
+ generateProcessButton.setClickedListener(new Component.ClickedListener() {
+ @Override
+ public void onClick(Component component) {
+ progressGenerator.start(generateProcessButton);
+ generateProcessButton.setEnabled(false);
+ }
+ });
+ }
+
+ @Override
+ protected void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ protected void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ generateProcessButton.setProgress(0);
+ generateProcessButton.setEnabled(true);
+ progressGenerator.stop();
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/slice/StateSampleSlice.java b/entry/src/main/java/com/dd/sample/slice/StateSampleSlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..4d29f00603f2b6ce5570d886faf7052321f7f4f2
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/slice/StateSampleSlice.java
@@ -0,0 +1,86 @@
+/*
+ * 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 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 com.dd.sample.slice;
+
+import com.dd.processbutton.iml.ActionProcessButton;
+import com.dd.processbutton.iml.GenerateProcessButton;
+import com.dd.processbutton.iml.SubmitProcessButton;
+import com.dd.sample.ResourceTable;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Component;
+
+/**
+ * 各种Button测试集合
+ * @since 2021-03-01
+ */
+public class StateSampleSlice extends Ability implements Component.ClickedListener {
+ private ActionProcessButton actionProcessButton;
+ private GenerateProcessButton generateProcessButton;
+ private SubmitProcessButton submitProcessButton;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_state_sample_silice);
+ actionProcessButton = (ActionProcessButton) findComponentById(ResourceTable.Id_state_sample_action);
+ actionProcessButton.setMode(ActionProcessButton.Mode.ENDLESS);
+ generateProcessButton = (GenerateProcessButton) findComponentById(ResourceTable.Id_state_sample_generate);
+ submitProcessButton = (SubmitProcessButton) findComponentById(ResourceTable.Id_state_sample_submit);
+
+ findComponentById(ResourceTable.Id_error_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_noramal_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_half_button).setClickedListener(this);
+ findComponentById(ResourceTable.Id_success_button).setClickedListener(this);
+ }
+
+ @Override
+ public void onClick(Component component) {
+ switch (component.getId()) {
+ case ResourceTable.Id_error_button:
+ actionProcessButton.setProgress(-1);
+ generateProcessButton.setProgress(-1);
+ submitProcessButton.setProgress(-1);
+ break;
+ case ResourceTable.Id_noramal_button:
+ actionProcessButton.setProgress(0);
+ generateProcessButton.setProgress(0);
+ submitProcessButton.setProgress(0);
+ break;
+ case ResourceTable.Id_half_button:
+ actionProcessButton.setProgress(50);
+ generateProcessButton.setProgress(50);
+ submitProcessButton.setProgress(50);
+ break;
+ case ResourceTable.Id_success_button:
+ actionProcessButton.setProgress(100);
+ generateProcessButton.setProgress(100);
+ submitProcessButton.setProgress(100);
+ break;
+ default:
+ break;
+ }
+ }
+
+ @Override
+ protected void onBackground() {
+ super.onBackground();
+ actionProcessButton.setProgress(0);
+ generateProcessButton.setProgress(0);
+ submitProcessButton.setProgress(0);
+ }
+}
diff --git a/entry/src/main/java/com/dd/sample/slice/SubmitAbilitySlice.java b/entry/src/main/java/com/dd/sample/slice/SubmitAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..e04284ea0dc58b963de4aa0ad4276fed679ff339
--- /dev/null
+++ b/entry/src/main/java/com/dd/sample/slice/SubmitAbilitySlice.java
@@ -0,0 +1,68 @@
+/*
+ * 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 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 com.dd.sample.slice;
+
+import com.dd.processbutton.iml.SubmitProcessButton;
+import com.dd.sample.ResourceTable;
+import com.dd.sample.Toast;
+import com.dd.sample.utils.ProgressGenerator;
+
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.TextField;
+
+/**
+ * 测试SubmitProcessButton
+ * @since 2021-03-01
+ */
+public class SubmitAbilitySlice extends Ability {
+ private SubmitProcessButton submitProcessButton;
+ private TextField input;
+ private ProgressGenerator progressGenerator;
+
+ @Override
+ protected void onStart(Intent intent) {
+ super.onStart(intent);
+ setUIContent(ResourceTable.Layout_submint_ablity_slice);
+ progressGenerator = new ProgressGenerator(() ->
+ Toast.showLong(getContext(),"Loading Complete, button is disabled"));
+
+ input = (TextField)findComponentById(ResourceTable.Id_input);
+ submitProcessButton = (SubmitProcessButton) findComponentById(ResourceTable.Id_sub_btn_sample);
+ submitProcessButton.setClickedListener(component -> {
+ progressGenerator.start(submitProcessButton);
+ submitProcessButton.setEnabled(false);
+ input.setEnabled(false);
+ input.clearFocus();
+ });
+ }
+
+ @Override
+ protected void onBackground() {
+ super.onBackground();
+ }
+
+ @Override
+ protected void onStop() {
+ super.onStop();
+ submitProcessButton.setText("SEND");
+ submitProcessButton.setProgress(0);
+ submitProcessButton.setEnabled(true);
+ input.setText("How are you?");
+ input.setEnabled(true);
+ progressGenerator.stop();
+ }
+}
diff --git a/sample/src/main/java/com/dd/sample/utils/ProgressGenerator.java b/entry/src/main/java/com/dd/sample/utils/ProgressGenerator.java
similarity index 44%
rename from sample/src/main/java/com/dd/sample/utils/ProgressGenerator.java
rename to entry/src/main/java/com/dd/sample/utils/ProgressGenerator.java
index d48db5488042bdc28541eb4e41c69faf8bba79e3..52c813c1bbc1d33f31c9a13ee3663cf8b38ae6f7 100644
--- a/sample/src/main/java/com/dd/sample/utils/ProgressGenerator.java
+++ b/entry/src/main/java/com/dd/sample/utils/ProgressGenerator.java
@@ -2,41 +2,65 @@ package com.dd.sample.utils;
import com.dd.processbutton.ProcessButton;
-import android.os.Handler;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
import java.util.Random;
public class ProgressGenerator {
+ private final EventHandler eventHandler = new EventHandler(EventRunner.getMainEventRunner());
- public interface OnCompleteListener {
+ private Runnable runnable;
- public void onComplete();
+ public interface OnCompleteListener {
+ void onComplete();
}
- private OnCompleteListener mListener;
+ private final OnCompleteListener mListener;
private int mProgress;
+ public OnCompleteListener getmListener() {
+ return mListener;
+ }
+
+ public int getmProgress() {
+ return mProgress;
+ }
+
+ public Random getRandom() {
+ return random;
+ }
+
public ProgressGenerator(OnCompleteListener listener) {
mListener = listener;
}
+ public void setmProgress(int mProgress) {
+ this.mProgress = mProgress;
+ }
+
public void start(final ProcessButton button) {
- final Handler handler = new Handler();
- handler.postDelayed(new Runnable() {
+ runnable = new Runnable() {
@Override
public void run() {
mProgress += 10;
button.setProgress(mProgress);
if (mProgress < 100) {
- handler.postDelayed(this, generateDelay());
+ eventHandler.postTask(this, generateDelay());
} else {
+ mProgress = 0;
mListener.onComplete();
}
}
- }, generateDelay());
+ };
+ eventHandler.postTask(runnable, generateDelay());
+ }
+
+ public void stop() {
+ eventHandler.removeTask(runnable);
}
- private Random random = new Random();
+ private final Random random = new Random();
private int generateDelay() {
return random.nextInt(1000);
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..65bb2ac50141afc0701d32db7fd897be9aa983e9
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,64 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "ohos_process_button"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "action_settings",
+ "value": "Settings"
+ },
+ {
+ "name": "dummy_email",
+ "value": "jondoe@gmail.com"
+ },
+ {
+ "name": "dummy_password",
+ "value": "123456789"
+ },
+ {
+ "name": "Sign_in",
+ "value": "Sign in"
+ },
+ {
+ "name": "Success",
+ "value": "Success"
+ },
+ {
+ "name": "Loading",
+ "value": "Loading.."
+ },
+ {
+ "name": "Question",
+ "value": "How are you?"
+ },
+ {
+ "name": "Send",
+ "value": "Send"
+ },
+ {
+ "name": "Done",
+ "value": "Done"
+ },
+ {
+ "name": "Upload",
+ "value": "Upload"
+ },
+ {
+ "name": "Beautiful_Picture",
+ "value": "Beautiful Picture"
+ },
+ {
+ "name": "Uploading",
+ "value": "Uploading"
+ },
+ {
+ "name": "Loading_Complete",
+ "value": "Loading Complete, button is disabled"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_button.xml b/entry/src/main/resources/base/graphic/background_ability_button.xml
new file mode 100644
index 0000000000000000000000000000000000000000..83e27062f1ff4845725b04a952204f77eee4e9e8
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_button.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+
+ -
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_edit.xml b/entry/src/main/resources/base/graphic/background_ability_edit.xml
new file mode 100644
index 0000000000000000000000000000000000000000..f6f017fcff599f9ad6dd6b91b48846e5fb615a3c
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_edit.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
\ 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..9eda45c21976766d811a0d3f581e8854fdcdcece
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,12 @@
+
+
+ -
+
+
+
+ -
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/text_press_background.xml b/entry/src/main/resources/base/graphic/text_press_background.xml
new file mode 100644
index 0000000000000000000000000000000000000000..d48a29ad0810f965c1ddb6d60ace11f750dd632d
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/text_press_background.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ 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..16c4427b49d54bf4b4a3ce2c354b3754fbad5ca9
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,122 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ac_states.xml b/entry/src/main/resources/base/layout/ac_states.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5ce109667947d6cc9bf0ed45ca5b0f59149e9c71
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ac_states.xml
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/entry/src/main/resources/base/layout/button_progress_slice.xml b/entry/src/main/resources/base/layout/button_progress_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..41f20aec123058e637beca2c126c41e2a412955e
--- /dev/null
+++ b/entry/src/main/resources/base/layout/button_progress_slice.xml
@@ -0,0 +1,54 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/generate_button_slice.xml b/entry/src/main/resources/base/layout/generate_button_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..59335ecca519faff59ed69b3aee2cd22473d4f4b
--- /dev/null
+++ b/entry/src/main/resources/base/layout/generate_button_slice.xml
@@ -0,0 +1,32 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/singin_sample_silice.xml b/entry/src/main/resources/base/layout/singin_sample_silice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..66b0277d659642625024698905ffb79c08b0c21f
--- /dev/null
+++ b/entry/src/main/resources/base/layout/singin_sample_silice.xml
@@ -0,0 +1,39 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/state_sample_silice.xml b/entry/src/main/resources/base/layout/state_sample_silice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..0b90c9d12ae5d1966678dcfcd0e1dbbed3b0c925
--- /dev/null
+++ b/entry/src/main/resources/base/layout/state_sample_silice.xml
@@ -0,0 +1,86 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/submint_ablity_slice.xml b/entry/src/main/resources/base/layout/submint_ablity_slice.xml
new file mode 100644
index 0000000000000000000000000000000000000000..644780a59857517f0049098f28cb8e9f118a489a
--- /dev/null
+++ b/entry/src/main/resources/base/layout/submint_ablity_slice.xml
@@ -0,0 +1,36 @@
+
+
+
+
+
+
+
+
+
\ 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/entry/src/test/java/com/dd/sample/ExampleTest.java b/entry/src/test/java/com/dd/sample/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..60d86bafccd90357426e5403ba392f9e9a6617a0
--- /dev/null
+++ b/entry/src/test/java/com/dd/sample/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.dd.sample;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
index 51af29abec93f91c6ab7278f3ec503796b2e7ff5..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,39 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Settings specified in this file will override any Gradle settings
-# configured through the IDE.
-
+# 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
-
-VERSION_NAME=1.0.4
-VERSION_CODE=11
-PACKAGE_NAME=com.dd.sample.processbutton
-GROUP=com.github.dmytrodanylyk.android-process-button
-
-POM_DESCRIPTION=Android button which can indicate progress.
-POM_URL=https://github.com/dmytrodanylyk/android-process-button
-POM_SCM_URL=https://github.com/dmytrodanylyk/android-process-button
-POM_SCM_CONNECTION=scm:git@github.com:dmytrodanylyk/android-process-button.git
-POM_SCM_DEV_CONNECTION=scm:git@github.com:dmytrodanylyk/android-process-button.git
-POM_LICENCE_NAME=The MIT License (MIT)
-POM_LICENCE_URL=https://github.com/dmytrodanylyk/android-process-button/blob/master/LICENSE.md
-POM_LICENCE_DIST=repo
-POM_DEVELOPER_ID=dmytrodanylyk
-POM_DEVELOPER_NAME=Dmytro Danylyk
-
-#storeFile=nice try
-#keyAlias=nice try
-#storePassword=nice try
-#keyPassword=nice try
\ 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 adffb657591fb9ab88071aee7738f2cdfc5c01f6..6623300bebd011bc5f7991f4f9c389e2f67b14ac 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Tue May 26 12:39:06 EDT 2015
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
diff --git a/gradlew b/gradlew
index 91a7e269e19dfc62e27137a0b57ef3e430cee4fd..2fe81a7d95e4f9ad2c9b2a046707d36ceb3980b3 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,20 +22,38 @@
##
##############################################################################
-# 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"`
+# 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 ( ) {
+warn () {
echo "$*"
}
-die ( ) {
+die () {
echo
echo "$*"
echo
@@ -30,6 +64,7 @@ die ( ) {
cygwin=false
msys=false
darwin=false
+nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
@@ -40,31 +75,11 @@ case "`uname`" in
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.
@@ -90,7 +105,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
+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
@@ -110,10 +125,11 @@ if $darwin; then
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
+# 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`
@@ -138,27 +154,30 @@ if $cygwin ; then
else
eval `echo args$i`="\"$arg\""
fi
- i=$((i+1))
+ 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" ;;
+ 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/demo.gif b/img/demo.gif
new file mode 100644
index 0000000000000000000000000000000000000000..db25bad9252b74dc85c79b942f99ac778645f2eb
Binary files /dev/null and b/img/demo.gif differ
diff --git a/library/build.gradle b/library/build.gradle
index fc4ad76acef7e6a15bd2aa943b30ce66dfc7214a..276eacf16b1058c5f85a69a0839b1ec585d19770 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,33 +1,14 @@
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:1.2.2'
- }
-}
-
-apply plugin: 'com.android.library'
-
-repositories {
- jcenter()
-}
-
-android {
- compileSdkVersion 21
- buildToolsVersion '21.1.2'
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 14
- targetSdkVersion 21
- versionCode Integer.parseInt(project.VERSION_CODE)
- versionName project.VERSION_NAME
+ compatibleSdkVersion 5
}
+
}
dependencies {
- compile 'com.android.support:support-v4:21.0.3'
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testCompile'junit:junit:4.12'
}
-
-// Used to push in maven
-//apply from: '../maven_push.gradle'
diff --git a/library/gradle.properties b/library/gradle.properties
deleted file mode 100644
index dcb06d1ae86a5d8a0e29a2cb0154cc9c71c9d683..0000000000000000000000000000000000000000
--- a/library/gradle.properties
+++ /dev/null
@@ -1,3 +0,0 @@
-POM_NAME=Android Process Buttons
-POM_ARTIFACT_ID=library
-POM_PACKAGING=aar
\ No newline at end of file
diff --git a/library/proguard-rules.txt b/library/proguard-rules.txt
deleted file mode 100644
index 88a1529fcfe9aaa62307386fb1d8c21f00e6980f..0000000000000000000000000000000000000000
--- a/library/proguard-rules.txt
+++ /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 C:/Work/android-sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# 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 *;
-#}
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index 537172a6d28a5ab23239e5cff6469f88fd0eb3d2..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
-
-
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..553ae3477cdfdd24e344e1140900fdf4256ea6bc
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,27 @@
+{
+ "app": {
+ "bundleName": "com.dd.sample",
+ "vendor": "dd",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 4,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.dd.library",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/dd/processbutton/FlatButton.java b/library/src/main/java/com/dd/processbutton/FlatButton.java
index d9ae2bbf7a2f18d60e2302f4b235d3768d457c5b..8898e52ab69c400c9ad153f5ede67993ab00b715 100644
--- a/library/src/main/java/com/dd/processbutton/FlatButton.java
+++ b/library/src/main/java/com/dd/processbutton/FlatButton.java
@@ -1,130 +1,125 @@
package com.dd.processbutton;
-import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.drawable.Drawable;
-import android.graphics.drawable.GradientDrawable;
-import android.graphics.drawable.LayerDrawable;
-import android.graphics.drawable.StateListDrawable;
-import android.os.Build;
-import android.util.AttributeSet;
-import android.widget.Button;
+import com.dd.library.ResourceTable;
-public class FlatButton extends Button {
+import com.dd.processbutton.utils.AttrUtils;
+import com.dd.processbutton.utils.HmsResourcesManager;
+import com.dd.processbutton.utils.Utils;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Button;
+import ohos.agp.components.ComponentState;
+import ohos.agp.components.element.*;
+import ohos.agp.utils.Color;
+import ohos.app.Context;
- private StateListDrawable mNormalDrawable;
+public class FlatButton extends Button {
+ private StateElement mNormalDrawable;
private CharSequence mNormalText;
private float cornerRadius;
- public FlatButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(context, attrs);
+ public FlatButton(Context context) {
+ super(context);
+ init(context, null);
}
- public FlatButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
+ public FlatButton(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ init(context, attrSet);
}
- public FlatButton(Context context) {
- super(context);
- init(context, null);
+ public FlatButton(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ init(context, attrSet);
}
- private void init(Context context, AttributeSet attrs) {
- mNormalDrawable = new StateListDrawable();
+ private void init(Context context, AttrSet attrs) {
+ mNormalDrawable = new StateElement();
if (attrs != null) {
initAttributes(context, attrs);
}
- mNormalText = getText().toString();
+ mNormalText = getText();
setBackgroundCompat(mNormalDrawable);
}
- private void initAttributes(Context context, AttributeSet attributeSet) {
- TypedArray attr = getTypedArray(context, attributeSet, R.styleable.FlatButton);
+ private void initAttributes(Context context, AttrSet attr) {
if (attr == null) {
return;
}
- try {
-
- float defValue = getDimension(R.dimen.corner_radius);
- cornerRadius = attr.getDimension(R.styleable.FlatButton_pb_cornerRadius, defValue);
-
- mNormalDrawable.addState(new int[]{android.R.attr.state_pressed},
- createPressedDrawable(attr));
- mNormalDrawable.addState(new int[]{android.R.attr.state_focused},
- createPressedDrawable(attr));
- mNormalDrawable.addState(new int[]{android.R.attr.state_selected},
- createPressedDrawable(attr));
- mNormalDrawable.addState(new int[]{}, createNormalDrawable(attr));
-
- } finally {
- attr.recycle();
- }
- }
-
- private LayerDrawable createNormalDrawable(TypedArray attr) {
- LayerDrawable drawableNormal =
- (LayerDrawable) getDrawable(R.drawable.rect_normal).mutate();
-
- GradientDrawable drawableTop =
- (GradientDrawable) drawableNormal.getDrawable(0).mutate();
- drawableTop.setCornerRadius(getCornerRadius());
-
- int blueDark = getColor(R.color.blue_pressed);
- int colorPressed = attr.getColor(R.styleable.FlatButton_pb_colorPressed, blueDark);
- drawableTop.setColor(colorPressed);
-
- GradientDrawable drawableBottom =
- (GradientDrawable) drawableNormal.getDrawable(1).mutate();
- drawableBottom.setCornerRadius(getCornerRadius());
-
- int blueNormal = getColor(R.color.blue_normal);
- int colorNormal = attr.getColor(R.styleable.FlatButton_pb_colorNormal, blueNormal);
- drawableBottom.setColor(colorNormal);
- return drawableNormal;
- }
-
- private Drawable createPressedDrawable(TypedArray attr) {
- GradientDrawable drawablePressed =
- (GradientDrawable) getDrawable(R.drawable.rect_pressed).mutate();
+ float defValue = getDimension(ResourceTable.Float_corner_radius);
+
+ cornerRadius = AttrUtils.getFloatValueByAttr(attr, "cornerRadius", defValue);
+
+ mNormalDrawable.addState(new int[]{ComponentState.COMPONENT_STATE_PRESSED},
+ createPressedDrawable(attr));
+ mNormalDrawable.addState(new int[]{ComponentState.COMPONENT_STATE_FOCUSED},
+ createPressedDrawable(attr));
+ mNormalDrawable.addState(new int[]{ComponentState.COMPONENT_STATE_SELECTED},
+ createPressedDrawable(attr));
+ mNormalDrawable.addState(new int[]{ComponentState.COMPONENT_STATE_EMPTY}, createNormalDrawable(attr));
+ }
+
+ private ShapeElement createNormalDrawable(AttrSet attr) {
+ ElementContainer elementContainer = new ElementContainer();
+ ElementContainer.ElementState elementState = new ElementContainer.ElementState();
+ ShapeElement drawableTop = new ShapeElement();
+ drawableTop.setShape(ShapeElement.RECTANGLE);
+ drawableTop.setCornerRadius(
+ HmsResourcesManager.getFloatValueByResources(getContext(),ResourceTable.Float_corner_radius));
+ drawableTop.setRgbColor(RgbColor.fromArgbInt(
+ HmsResourcesManager.getColorValueByResources(getContext(),ResourceTable.Color_blue_pressed)));
+ drawableTop.setRgbColor(RgbColor.fromArgbInt(
+ HmsResourcesManager.getColorValueByResources(getContext(),ResourceTable.Color_blue_normal)));
+ int blueDark = getColor(ResourceTable.Color_blue_pressed);
+ int blueDark1 = getColor(ResourceTable.Color_blue_normal);
+ int colorPressed = AttrUtils.getColorValueByAttr(attr,"pb_colorPressed", new Color(blueDark)).getValue();
+ int colorNormal = AttrUtils.getColorValueByAttr(attr,"pb_colorNormal", new Color(blueDark1)).getValue();
+ drawableTop.setRgbColor(RgbColor.fromArgbInt(colorPressed));
+ drawableTop.setRgbColor(RgbColor.fromArgbInt(colorNormal));
+ elementState.addChildElement(drawableTop);
+ ShapeElement drawableElement = new ShapeElement();
+ elementState.addChildElement(drawableElement);
+ elementContainer.setElementState(elementState);
+ return drawableTop;
+ }
+
+ private ShapeElement createPressedDrawable(AttrSet attr) {
+ ShapeElement drawablePressed = new ShapeElement();
+ drawablePressed.setCornerRadius(HmsResourcesManager.getFloatValueByResources(getContext(),ResourceTable.Float_corner_radius));
+ drawablePressed.setRgbColor(RgbColor.fromArgbInt(HmsResourcesManager.getColorValueByResources(getContext(),ResourceTable.Color_blue_pressed)));
drawablePressed.setCornerRadius(getCornerRadius());
- int blueDark = getColor(R.color.blue_pressed);
- int colorPressed = attr.getColor(R.styleable.FlatButton_pb_colorPressed, blueDark);
- drawablePressed.setColor(colorPressed);
+ int blueDark = getColor(ResourceTable.Color_blue_pressed);
+ int colorPressed = AttrUtils.getColorValueByAttr(attr,"pb_colorPressed",new Color(blueDark)).getValue();
+ drawablePressed.setRgbColor(RgbColor.fromArgbInt(colorPressed));
return drawablePressed;
}
- protected Drawable getDrawable(int id) {
- return getResources().getDrawable(id);
+ protected PixelMapElement getDrawable(int id) {
+ return Utils.getPixelMapElement(getContext(),id);
}
protected float getDimension(int id) {
- return getResources().getDimension(id);
+ return HmsResourcesManager.getFloatValueByResources(getContext(),id);
}
protected int getColor(int id) {
- return getResources().getColor(id);
- }
-
- protected TypedArray getTypedArray(Context context, AttributeSet attributeSet, int[] attr) {
- return context.obtainStyledAttributes(attributeSet, attr, 0, 0);
+ return HmsResourcesManager.getColorValueByResources(getContext(), id);
}
public float getCornerRadius() {
return cornerRadius;
}
- public StateListDrawable getNormalDrawable() {
+ public StateElement getNormalDrawable() {
return mNormalDrawable;
}
- public CharSequence getNormalText() {
- return mNormalText;
+ public String getNormalText() {
+ return mNormalText.toString();
}
public void setNormalText(CharSequence normalText) {
@@ -136,19 +131,14 @@ public class FlatButton extends Button {
*
* @param drawable
*/
- @SuppressWarnings("deprecation")
- @SuppressLint("NewApi")
- public void setBackgroundCompat(Drawable drawable) {
+ public void setBackgroundCompat(Element drawable) {
int pL = getPaddingLeft();
int pT = getPaddingTop();
int pR = getPaddingRight();
int pB = getPaddingBottom();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- setBackground(drawable);
- } else {
- setBackgroundDrawable(drawable);
- }
+ setBackground(drawable);
+
setPadding(pL, pT, pR, pB);
}
}
diff --git a/library/src/main/java/com/dd/processbutton/ProcessButton.java b/library/src/main/java/com/dd/processbutton/ProcessButton.java
index 8bedff5717f42054a1a76302a0d6a5dc8dc774e0..4ea5685c9ca17856cfd500661e675777daf837be 100644
--- a/library/src/main/java/com/dd/processbutton/ProcessButton.java
+++ b/library/src/main/java/com/dd/processbutton/ProcessButton.java
@@ -1,97 +1,167 @@
package com.dd.processbutton;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Canvas;
-import android.graphics.drawable.GradientDrawable;
-import android.os.Parcel;
-import android.os.Parcelable;
-import android.util.AttributeSet;
-
-public abstract class ProcessButton extends FlatButton {
+import com.dd.library.ResourceTable;
+import com.dd.processbutton.utils.AttrUtils;
+import com.dd.processbutton.utils.HmsResourcesManager;
+
+import ohos.agp.colors.RgbColor;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.components.element.ShapeElement;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.TextAlignment;
+import ohos.agp.utils.TextTool;
+import ohos.app.Context;
+import ohos.hiviewdfx.HiLog;
+
+public abstract class ProcessButton extends FlatButton implements Component.DrawTask {
+ private static final int DEFAULT_MAX_VALUE = 100;
private int mProgress;
private int mMaxProgress;
private int mMinProgress;
- private GradientDrawable mProgressDrawable;
- private GradientDrawable mCompleteDrawable;
- private GradientDrawable mErrorDrawable;
+ private ShapeElement mProgressDrawable;
+ private Paint mProgressPaint;
+ private ShapeElement mCompleteDrawable;
+ private ShapeElement mErrorDrawable;
private CharSequence mLoadingText;
private CharSequence mCompleteText;
private CharSequence mErrorText;
- public ProcessButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- init(context, attrs);
+ public ProcessButton(Context context) {
+ super(context);
+ init(context, null);
}
- public ProcessButton(Context context, AttributeSet attrs) {
- super(context, attrs);
- init(context, attrs);
+ public ProcessButton(Context context, AttrSet attrSet) {
+ super(context, attrSet);
+ init(context, attrSet);
}
- public ProcessButton(Context context) {
- super(context);
- init(context, null);
+ public ProcessButton(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ init(context, attrSet);
}
- private void init(Context context, AttributeSet attrs) {
- mMinProgress = 0;
- mMaxProgress = 100;
+ @Override
+ public void setTextSize(int size) {
+ super.setTextSize(size);
+ }
- mProgressDrawable = (GradientDrawable) getDrawable(R.drawable.rect_progress).mutate();
+ private void init(Context context, AttrSet attrs) {
+ mMinProgress = 0;
+ mMaxProgress = DEFAULT_MAX_VALUE;
+ addDrawTask(this, DrawTask.BETWEEN_BACKGROUND_AND_CONTENT);
+ mProgressDrawable = getRectProgressShapeElement();
mProgressDrawable.setCornerRadius(getCornerRadius());
- mCompleteDrawable = (GradientDrawable) getDrawable(R.drawable.rect_complete).mutate();
+ mProgressPaint = getRectProgressPaint();
+
+ mCompleteDrawable = getRectCompleteShapeElement();
mCompleteDrawable.setCornerRadius(getCornerRadius());
- mErrorDrawable = (GradientDrawable) getDrawable(R.drawable.rect_error).mutate();
+ mErrorDrawable = getRectErrorShapeElement();
mErrorDrawable.setCornerRadius(getCornerRadius());
+ setTextSize(60);
if (attrs != null) {
initAttributes(context, attrs);
}
}
- private void initAttributes(Context context, AttributeSet attributeSet) {
- TypedArray attr = getTypedArray(context, attributeSet, R.styleable.ProcessButton);
+ protected Paint getRectProgressPaint() {
+ Paint paint = new Paint();
+ paint.setColor(new Color(HmsResourcesManager.getColorValueByResources(getContext(), ResourceTable.Color_purple_progress)));
+ paint.setStyle(Paint.Style.FILL_STYLE);
+ return paint;
+ }
- if (attr == null) {
- return;
+ /**
+ * 设置绘制loading中文字的画笔属性
+ *
+ * @return 画笔
+ */
+ protected Paint getTextPaint() {
+ Paint paint = new Paint();
+ paint.setColor(new Color(
+ HmsResourcesManager.getColorValueByResources(getContext(), ResourceTable.Color_white_normal)));
+ paint.setStyle(Paint.Style.FILL_STYLE);
+ paint.setTextSize(getTextSize());
+ paint.setTextAlign(TextAlignment.CENTER);
+ return paint;
+ }
+
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ if (mProgress > mMinProgress && mProgress < mMaxProgress) {
+ drawProgress(canvas);
}
+ }
- try {
- mLoadingText = attr.getString(R.styleable.ProcessButton_pb_textProgress);
- mCompleteText = attr.getString(R.styleable.ProcessButton_pb_textComplete);
- mErrorText = attr.getString(R.styleable.ProcessButton_pb_textError);
+ private ShapeElement getRectCompleteShapeElement() {
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setCornerRadius(
+ HmsResourcesManager.getFloatValueByResources(getContext(), ResourceTable.Float_corner_radius));
+ shapeElement.setRgbColor(RgbColor.fromArgbInt(
+ HmsResourcesManager.getColorValueByResources(getContext(), ResourceTable.Color_purple_progress)));
+ return shapeElement;
+ }
- int purple = getColor(R.color.purple_progress);
- int colorProgress = attr.getColor(R.styleable.ProcessButton_pb_colorProgress, purple);
- mProgressDrawable.setColor(colorProgress);
+ public Paint getmProgressPaint() {
+ return mProgressPaint;
+ }
+
+ private ShapeElement getRectErrorShapeElement() {
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setCornerRadius(
+ HmsResourcesManager.getFloatValueByResources(getContext(), ResourceTable.Float_corner_radius));
+ shapeElement.setRgbColor(RgbColor.fromArgbInt(
+ HmsResourcesManager.getColorValueByResources(getContext(), ResourceTable.Color_red_error)));
+ return shapeElement;
+ }
- int green = getColor(R.color.green_complete);
- int colorComplete = attr.getColor(R.styleable.ProcessButton_pb_colorComplete, green);
- mCompleteDrawable.setColor(colorComplete);
+ private ShapeElement getRectProgressShapeElement() {
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setCornerRadius(
+ HmsResourcesManager.getFloatValueByResources(getContext(), ResourceTable.Float_corner_radius));
+ shapeElement.setRgbColor(RgbColor.fromArgbInt(
+ HmsResourcesManager.getColorValueByResources(getContext(), ResourceTable.Color_purple_progress)));
- int red = getColor(R.color.red_error);
- int colorError = attr.getColor(R.styleable.ProcessButton_pb_colorError, red);
- mErrorDrawable.setColor(colorError);
+ return shapeElement;
+ }
- } finally {
- attr.recycle();
+ private void initAttributes(Context context, AttrSet attributeSet) {
+ if (attributeSet == null) {
+ return;
}
+
+ mLoadingText = AttrUtils.getStringValueByAttr(attributeSet,"pb_textProgress", "");
+ mCompleteText = AttrUtils.getStringValueByAttr(attributeSet,"pb_textComplete", "");
+ mErrorText = AttrUtils.getStringValueByAttr(attributeSet,"pb_textError", "");
+
+ int purple = getColor(ResourceTable.Color_blue_pressed);
+ int colorProgress = AttrUtils.getColorValueByAttr(attributeSet,"pb_colorProgress", new Color(purple)).getValue();
+ mProgressDrawable.setRgbColor(RgbColor.fromArgbInt(colorProgress));
+
+ int green = getColor(ResourceTable.Color_green_complete);
+ int colorComplete = AttrUtils.getColorValueByAttr(attributeSet,"pb_colorComplete", new Color(green)).getValue();
+ mCompleteDrawable.setRgbColor(RgbColor.fromArgbInt(colorComplete));
+ int red = getColor(ResourceTable.Color_red_error);
+ int colorError = AttrUtils.getColorValueByAttr(attributeSet,"pb_colorError", new Color(red)).getValue();
+ mErrorDrawable.setRgbColor(RgbColor.fromArgbInt(colorError));
}
public void setProgress(int progress) {
mProgress = progress;
-
if (mProgress == mMinProgress) {
onNormalState();
} else if (mProgress == mMaxProgress) {
onCompleteState();
- } else if (mProgress < mMinProgress){
+ } else if (mProgress < mMinProgress) {
onErrorState();
} else {
onProgress();
@@ -100,86 +170,91 @@ public abstract class ProcessButton extends FlatButton {
invalidate();
}
- protected void onErrorState() {
- if(getErrorText() != null) {
+ private void onErrorState() {
+ if (!TextTool.isNullOrEmpty(getErrorText())) {
setText(getErrorText());
}
- setBackgroundCompat(getErrorDrawable());
+ ShapeElement shapeElement = new ShapeElement();
+ shapeElement.setRgbColor(RgbColor.fromArgbInt(Color.RED.getValue()));
+ setBackgroundCompat(shapeElement);
}
- protected void onProgress() {
- if(getLoadingText() != null) {
+ /**
+ * 状态变成加载中时背景和文字的切换
+ */
+ private void onProgress() {
+ String loadingText = getLoadingText();
+ if (!TextTool.isNullOrEmpty(getLoadingText())) {
setText(getLoadingText());
}
- setBackgroundCompat(getNormalDrawable());
+ setBackgroundCompat(getProgressDrawable());
}
- protected void onCompleteState() {
- if(getCompleteText() != null) {
+ private void onCompleteState() {
+ if (!TextTool.isNullOrEmpty(getCompleteText())) {
setText(getCompleteText());
}
setBackgroundCompat(getCompleteDrawable());
}
- protected void onNormalState() {
- if(getNormalText() != null) {
+ private void onNormalState() {
+ if (!TextTool.isNullOrEmpty(getNormalText())) {
setText(getNormalText());
}
setBackgroundCompat(getNormalDrawable());
}
- @Override
- protected void onDraw(Canvas canvas) {
- // progress
- if(mProgress > mMinProgress && mProgress < mMaxProgress) {
- drawProgress(canvas);
- }
-
- super.onDraw(canvas);
- }
-
public abstract void drawProgress(Canvas canvas);
public int getProgress() {
return mProgress;
}
+ public void setMaxProgress(int maxProgress) {
+ this.mMaxProgress = maxProgress;
+ }
+
public int getMaxProgress() {
return mMaxProgress;
}
+ public void setMinProgress(int minProgress) {
+ this.mMinProgress = minProgress;
+ }
+
public int getMinProgress() {
return mMinProgress;
}
- public GradientDrawable getProgressDrawable() {
+ public ShapeElement getProgressDrawable() {
return mProgressDrawable;
}
- public GradientDrawable getCompleteDrawable() {
+ public ShapeElement getCompleteDrawable() {
return mCompleteDrawable;
}
- public CharSequence getLoadingText() {
- return mLoadingText;
+ public String getLoadingText() {
+ return mLoadingText.toString();
}
- public CharSequence getCompleteText() {
- return mCompleteText;
+ public String getCompleteText() {
+ return mCompleteText.toString();
}
- public void setProgressDrawable(GradientDrawable progressDrawable) {
+ public void setProgressDrawable(ShapeElement progressDrawable) {
mProgressDrawable = progressDrawable;
}
- public void setCompleteDrawable(GradientDrawable completeDrawable) {
+ public void setCompleteDrawable(ShapeElement completeDrawable) {
mCompleteDrawable = completeDrawable;
}
+ @Override
public void setNormalText(CharSequence normalText) {
super.setNormalText(normalText);
if (mProgress == mMinProgress) {
- setText(normalText);
+ setText(normalText.toString());
}
}
@@ -191,77 +266,19 @@ public abstract class ProcessButton extends FlatButton {
mCompleteText = completeText;
}
- public GradientDrawable getErrorDrawable() {
+ public ShapeElement getErrorDrawable() {
return mErrorDrawable;
}
- public void setErrorDrawable(GradientDrawable errorDrawable) {
+ public void setErrorDrawable(ShapeElement errorDrawable) {
mErrorDrawable = errorDrawable;
}
- public CharSequence getErrorText() {
- return mErrorText;
+ public String getErrorText() {
+ return mErrorText.toString();
}
public void setErrorText(CharSequence errorText) {
mErrorText = errorText;
}
-
- @Override
- public Parcelable onSaveInstanceState() {
- Parcelable superState = super.onSaveInstanceState();
- SavedState savedState = new SavedState(superState);
- savedState.mProgress = mProgress;
-
- return savedState;
- }
-
- @Override
- public void onRestoreInstanceState(Parcelable state) {
- if (state instanceof SavedState) {
- SavedState savedState = (SavedState) state;
- mProgress = savedState.mProgress;
- super.onRestoreInstanceState(savedState.getSuperState());
- setProgress(mProgress);
- } else {
- super.onRestoreInstanceState(state);
- }
- }
-
- /**
- * A {@link android.os.Parcelable} representing the {@link com.dd.processbutton.ProcessButton}'s
- * state.
- */
- public static class SavedState extends BaseSavedState {
-
- private int mProgress;
-
- public SavedState(Parcelable parcel) {
- super(parcel);
- }
-
- private SavedState(Parcel in) {
- super(in);
- mProgress = in.readInt();
- }
-
- @Override
- public void writeToParcel(Parcel out, int flags) {
- super.writeToParcel(out, flags);
- out.writeInt(mProgress);
- }
-
- public static final Creator CREATOR = new Creator() {
-
- @Override
- public SavedState createFromParcel(Parcel in) {
- return new SavedState(in);
- }
-
- @Override
- public SavedState[] newArray(int size) {
- return new SavedState[size];
- }
- };
- }
}
diff --git a/library/src/main/java/com/dd/processbutton/iml/ActionProcessButton.java b/library/src/main/java/com/dd/processbutton/iml/ActionProcessButton.java
index 730eee0a20819b9ef1c502a027c991d0c418a566..53b6f19b55809d87af79ca82ef5dc11cbe9dd489 100644
--- a/library/src/main/java/com/dd/processbutton/iml/ActionProcessButton.java
+++ b/library/src/main/java/com/dd/processbutton/iml/ActionProcessButton.java
@@ -1,20 +1,19 @@
package com.dd.processbutton.iml;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.render.Canvas;
+import ohos.agp.render.Paint;
+import ohos.agp.utils.Color;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
+import ohos.eventhandler.EventHandler;
+import ohos.eventhandler.EventRunner;
+
+import com.dd.library.ResourceTable;
import com.dd.processbutton.ProcessButton;
-import com.dd.processbutton.R;
-
-import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.support.v4.view.ViewCompat;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.animation.AccelerateDecelerateInterpolator;
-import android.view.animation.AnimationUtils;
-import android.view.animation.Interpolator;
+import com.dd.processbutton.utils.AnimationUtils;
+import com.dd.processbutton.utils.HmsResourcesManager;
/*
* The MIT License (MIT)
@@ -39,8 +38,8 @@ import android.view.animation.Interpolator;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
public class ActionProcessButton extends ProcessButton {
+ private static final int INVALIDATE_TIME_INTERVAL = 25;
private ProgressBar mProgressBar;
@@ -52,7 +51,7 @@ public class ActionProcessButton extends ProcessButton {
private int mColor4;
public enum Mode {
- PROGRESS, ENDLESS;
+ PROGRESS, ENDLESS
}
public ActionProcessButton(Context context) {
@@ -60,25 +59,23 @@ public class ActionProcessButton extends ProcessButton {
init(context);
}
- public ActionProcessButton(Context context, AttributeSet attrs) {
+ public ActionProcessButton(Context context, AttrSet attrs) {
super(context, attrs);
init(context);
}
- public ActionProcessButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
+ public ActionProcessButton(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
init(context);
}
private void init(Context context) {
- Resources res = context.getResources();
-
mMode = Mode.ENDLESS;
- mColor1 = res.getColor(R.color.holo_blue_bright);
- mColor2 = res.getColor(R.color.holo_green_light);
- mColor3 = res.getColor(R.color.holo_orange_light);
- mColor4 = res.getColor(R.color.holo_red_light);
+ mColor1 = HmsResourcesManager.getColorValueByResources(context, ResourceTable.Color_holo_blue_bright);
+ mColor2 = HmsResourcesManager.getColorValueByResources(context, ResourceTable.Color_holo_green_light);
+ mColor3 = HmsResourcesManager.getColorValueByResources(context, ResourceTable.Color_holo_orange_light);
+ mColor4 = HmsResourcesManager.getColorValueByResources(context, ResourceTable.Color_holo_red_light);
}
public void setMode(Mode mode) {
@@ -92,10 +89,15 @@ public class ActionProcessButton extends ProcessButton {
mColor4 = color4;
}
+ @Override
+ public void invalidate() {
+ super.invalidate();
+ }
+
@Override
public void drawProgress(Canvas canvas) {
- if(getBackground() != getNormalDrawable()) {
- setBackgroundDrawable(getNormalDrawable());
+ if (getBackgroundElement() != getNormalDrawable()) {
+ setBackground(getNormalDrawable());
}
switch (mMode) {
@@ -105,25 +107,19 @@ public class ActionProcessButton extends ProcessButton {
case PROGRESS:
drawLineProgress(canvas);
break;
- }
- }
-
- @Override
- protected void onSizeChanged(int w, int h, int oldw, int oldh) {
- super.onSizeChanged(w, h, oldw, oldh);
- if (mProgressBar != null) {
- setupProgressBarBounds();
+ default:
+ break;
}
}
private void drawLineProgress(Canvas canvas) {
float scale = (float) getProgress() / (float) getMaxProgress();
- float indicatorWidth = (float) getMeasuredWidth() * scale;
-
+ float indicatorWidth = (float) getWidth() * scale;
double indicatorHeightPercent = 0.05; // 5%
- int bottom = (int) (getMeasuredHeight() - getMeasuredHeight() * indicatorHeightPercent);
- getProgressDrawable().setBounds(0, bottom, (int) indicatorWidth, getMeasuredHeight());
- getProgressDrawable().draw(canvas);
+ int bottom = (int) (getHeight() - getHeight() * indicatorHeightPercent);
+ getProgressDrawable().setBounds(0, bottom, (int) indicatorWidth, getHeight());
+ RectFloat rectFloat = new RectFloat(0, bottom, (int) indicatorWidth, getHeight());
+ canvas.drawRect(rectFloat, getmProgressPaint());
}
private void drawEndlessProgress(Canvas canvas) {
@@ -135,23 +131,23 @@ public class ActionProcessButton extends ProcessButton {
}
if (getProgress() > 0) {
- mProgressBar.draw(canvas);
+ mProgressBar.draw(canvas, this);
}
}
private void setupProgressBarBounds() {
- double indicatorHeight = getDimension(R.dimen.layer_padding);
- int bottom = (int) (getMeasuredHeight() - indicatorHeight);
- mProgressBar.setBounds(0, bottom, getMeasuredWidth(), getMeasuredHeight());
+ double indicatorHeight = getDimension(ResourceTable.Float_layer_padding);
+ int bottom = (int) (getHeight() - indicatorHeight);
+ mProgressBar.setBounds(0, bottom, getWidth(), getHeight());
}
public static class ProgressBar {
// Default progress animation colors are grays.
- private final static int COLOR1 = 0xB3000000;
- private final static int COLOR2 = 0x80000000;
- private final static int COLOR3 = 0x4d000000;
- private final static int COLOR4 = 0x1a000000;
+ private static final int COLOR1 = 0xB3000000;
+ private static final int COLOR2 = 0x80000000;
+ private static final int COLOR3 = 0x4d000000;
+ private static final int COLOR4 = 0x1a000000;
// The duration of the animation cycle.
private static final int ANIMATION_DURATION_MS = 2000;
@@ -160,10 +156,8 @@ public class ActionProcessButton extends ProcessButton {
private static final int FINISH_ANIMATION_DURATION_MS = 1000;
// Interpolator for varying the speed of the animation.
- private static final Interpolator INTERPOLATOR = new AccelerateDecelerateInterpolator();
-
private final Paint mPaint = new Paint();
- private final RectF mClipRect = new RectF();
+ private final RectFloat mClipRect = new RectFloat();
private float mTriggerPercentage;
private long mStartTime;
private long mFinishTime;
@@ -174,11 +168,13 @@ public class ActionProcessButton extends ProcessButton {
private int mColor2;
private int mColor3;
private int mColor4;
- private View mParent;
+ private final Component mParent;
- private Rect mBounds = new Rect();
+ private final RectFloat mBounds = new RectFloat();
- public ProgressBar(View parent) {
+ private EventHandler eventHandler;
+
+ public ProgressBar(Component parent) {
mParent = parent;
mColor1 = COLOR1;
mColor2 = COLOR2;
@@ -210,25 +206,25 @@ public class ActionProcessButton extends ProcessButton {
if (!mRunning) {
mTriggerPercentage = 0;
mStartTime = AnimationUtils.currentAnimationTimeMillis();
+
mRunning = true;
- mParent.postInvalidate();
+ mParent.invalidate();
}
}
- void draw(Canvas canvas) {
- final int width = mBounds.width();
- final int height = mBounds.height();
+ void draw(Canvas canvas, ActionProcessButton actionProcessButton) {
+ final int width = (int) mBounds.getWidth();
+ final int height = (int) mBounds.getHeight();
final int cx = width / 2;
final int cy = height / 2;
boolean drawTriggerWhileFinishing = false;
int restoreCount = canvas.save();
canvas.clipRect(mBounds);
-
if (mRunning || (mFinishTime > 0)) {
long now = AnimationUtils.currentAnimationTimeMillis();
long elapsed = (now - mStartTime) % ANIMATION_DURATION_MS;
long iterations = (now - mStartTime) / ANIMATION_DURATION_MS;
- float rawProgress = (elapsed / (ANIMATION_DURATION_MS / 100f));
+ float rawProgress = elapsed / (ANIMATION_DURATION_MS / 100f);
// If we're not running anymore, that means we're running through
// the finish animation.
@@ -244,12 +240,14 @@ public class ActionProcessButton extends ProcessButton {
// from the inside out. This layer will prevent the circles from
// drawing within its bounds.
long finishElapsed = (now - mFinishTime) % FINISH_ANIMATION_DURATION_MS;
- float finishProgress = (finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f));
- float pct = (finishProgress / 100f);
+ float finishProgress = finishElapsed / (FINISH_ANIMATION_DURATION_MS / 100f);
+ float pct = finishProgress / 100f;
+
// Radius of the circle is half of the screen.
- float clearRadius = width / 2 * INTERPOLATOR.getInterpolation(pct);
- mClipRect.set(cx - clearRadius, 0, cx + clearRadius, height);
- canvas.saveLayerAlpha(mClipRect, 0, 0);
+ float clearRadius = width / 2f * getInterpolation(pct);
+ mClipRect.fuse(cx - clearRadius, 0, cx + clearRadius, height);
+ canvas.saveLayerAlpha(mClipRect, 0);
+
// Only draw the trigger if there is a space in the center of
// this refreshing view that needs to be filled in by the
// trigger. If the progress view is just still animating, let it
@@ -259,16 +257,16 @@ public class ActionProcessButton extends ProcessButton {
// First fill in with the last color that would have finished drawing.
if (iterations == 0) {
- canvas.drawColor(mColor1);
+ canvas.drawColor(mColor1, Canvas.PorterDuffMode.SRC_OVER);
} else {
if (rawProgress >= 0 && rawProgress < 25) {
- canvas.drawColor(mColor4);
+ canvas.drawColor(mColor4, Canvas.PorterDuffMode.SRC_OVER);
} else if (rawProgress >= 25 && rawProgress < 50) {
- canvas.drawColor(mColor1);
+ canvas.drawColor(mColor1, Canvas.PorterDuffMode.SRC_OVER);
} else if (rawProgress >= 50 && rawProgress < 75) {
- canvas.drawColor(mColor2);
+ canvas.drawColor(mColor2, Canvas.PorterDuffMode.SRC_OVER);
} else {
- canvas.drawColor(mColor3);
+ canvas.drawColor(mColor3, Canvas.PorterDuffMode.SRC_OVER);
}
}
@@ -278,24 +276,24 @@ public class ActionProcessButton extends ProcessButton {
// progress 25-75 draw mColor3
// progress 50-100 draw mColor4
// progress 75 (wrap to 25) draw mColor1
- if ((rawProgress >= 0 && rawProgress <= 25)) {
- float pct = (((rawProgress + 25) * 2) / 100f);
+ if (rawProgress >= 0 && rawProgress <= 25) {
+ float pct = ((rawProgress + 25) * 2) / 100f;
drawCircle(canvas, cx, cy, mColor1, pct);
}
if (rawProgress >= 0 && rawProgress <= 50) {
- float pct = ((rawProgress * 2) / 100f);
+ float pct = (rawProgress * 2) / 100f;
drawCircle(canvas, cx, cy, mColor2, pct);
}
if (rawProgress >= 25 && rawProgress <= 75) {
- float pct = (((rawProgress - 25) * 2) / 100f);
+ float pct = ((rawProgress - 25) * 2) / 100f;
drawCircle(canvas, cx, cy, mColor3, pct);
}
if (rawProgress >= 50 && rawProgress <= 100) {
- float pct = (((rawProgress - 50) * 2) / 100f);
+ float pct = ((rawProgress - 50) * 2) / 100f;
drawCircle(canvas, cx, cy, mColor4, pct);
}
- if ((rawProgress >= 75 && rawProgress <= 100)) {
- float pct = (((rawProgress - 75) * 2) / 100f);
+ if (rawProgress >= 75 && rawProgress <= 100) {
+ float pct = ((rawProgress - 75) * 2) / 100f;
drawCircle(canvas, cx, cy, mColor1, pct);
}
if (mTriggerPercentage > 0 && drawTriggerWhileFinishing) {
@@ -308,8 +306,9 @@ public class ActionProcessButton extends ProcessButton {
canvas.clipRect(mBounds);
drawTrigger(canvas, cx, cy);
}
+
// Keep running until we finish out the last cycle.
- ViewCompat.postInvalidateOnAnimation(mParent);
+ startDelay(mParent);
} else {
// Otherwise if we're in the middle of a trigger, draw that.
if (mTriggerPercentage > 0 && mTriggerPercentage <= 1.0) {
@@ -319,8 +318,20 @@ public class ActionProcessButton extends ProcessButton {
canvas.restoreToCount(restoreCount);
}
+ private void startDelay(Component mParent) {
+ if (eventHandler == null) {
+ eventHandler = new EventHandler(EventRunner.getMainEventRunner());
+ }
+ eventHandler.postTask(new Runnable() {
+ @Override
+ public void run() {
+ mParent.invalidate();
+ }
+ }, INVALIDATE_TIME_INTERVAL);
+ }
+
private void drawTrigger(Canvas canvas, int cx, int cy) {
- mPaint.setColor(mColor1);
+ mPaint.setColor(new Color(mColor1));
canvas.drawCircle(cx, cy, cx * mTriggerPercentage, mPaint);
}
@@ -328,16 +339,16 @@ public class ActionProcessButton extends ProcessButton {
* Draws a circle centered in the view.
*
* @param canvas the canvas to draw on
- * @param cx the center x coordinate
- * @param cy the center y coordinate
- * @param color the color to draw
- * @param pct the percentage of the view that the circle should cover
+ * @param cx the center x coordinate
+ * @param cy the center y coordinate
+ * @param color the color to draw
+ * @param pct the percentage of the view that the circle should cover
*/
private void drawCircle(Canvas canvas, float cx, float cy, int color, float pct) {
- mPaint.setColor(color);
+ mPaint.setColor(new Color(color));
canvas.save();
canvas.translate(cx, cy);
- float radiusScale = INTERPOLATOR.getInterpolation(pct);
+ float radiusScale = getInterpolation(pct);
canvas.scale(radiusScale, radiusScale);
canvas.drawCircle(0, 0, cx, mPaint);
canvas.restore();
@@ -345,6 +356,11 @@ public class ActionProcessButton extends ProcessButton {
/**
* Set the drawing bounds of this SwipeProgressBar.
+ *
+ * @param left left point
+ * @param top top point
+ * @param right right point
+ * @param bottom bottom point
*/
void setBounds(int left, int top, int right, int bottom) {
mBounds.left = left;
@@ -354,4 +370,13 @@ public class ActionProcessButton extends ProcessButton {
}
}
+ /**
+ * 计算插值
+ *
+ * @param input 输入值
+ * @return 结果
+ */
+ public static float getInterpolation(float input) {
+ return (float) (Math.cos((input + 1) * Math.PI) / 2.0f) + 0.5f;
+ }
}
diff --git a/library/src/main/java/com/dd/processbutton/iml/GenerateProcessButton.java b/library/src/main/java/com/dd/processbutton/iml/GenerateProcessButton.java
index 09fcbbfebdf55ea37ec188066cc4f1bfe1449261..1dc255d61100e95b9bad02f63b7f624934a04425 100644
--- a/library/src/main/java/com/dd/processbutton/iml/GenerateProcessButton.java
+++ b/library/src/main/java/com/dd/processbutton/iml/GenerateProcessButton.java
@@ -2,9 +2,10 @@ package com.dd.processbutton.iml;
import com.dd.processbutton.ProcessButton;
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
+import ohos.agp.components.AttrSet;
+import ohos.agp.render.Canvas;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
/*
* The MIT License (MIT)
@@ -29,28 +30,21 @@ import android.util.AttributeSet;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
public class GenerateProcessButton extends ProcessButton {
public GenerateProcessButton(Context context) {
super(context);
}
- public GenerateProcessButton(Context context, AttributeSet attrs) {
+ public GenerateProcessButton(Context context, AttrSet attrs) {
super(context, attrs);
}
- public GenerateProcessButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
@Override
public void drawProgress(Canvas canvas) {
float scale = (float) getProgress() / (float) getMaxProgress();
- float indicatorHeight = (float) getMeasuredHeight() * scale;
-
- getProgressDrawable().setBounds(0, 0, getMeasuredWidth(), (int) indicatorHeight);
- getProgressDrawable().draw(canvas);
+ float indicatorHeight = (float) getHeight() * scale;
+ RectFloat rectFloat = new RectFloat(0, 0, getWidth(), (int) indicatorHeight);
+ canvas.drawRect(rectFloat, getmProgressPaint());
}
-
}
diff --git a/library/src/main/java/com/dd/processbutton/iml/SubmitProcessButton.java b/library/src/main/java/com/dd/processbutton/iml/SubmitProcessButton.java
index cad5ca5fd729661ffbf5af47f39d522aa8d9c1bd..0d9e9fa1e6eed9898a4a0ce10ce1cea5a5b28339 100644
--- a/library/src/main/java/com/dd/processbutton/iml/SubmitProcessButton.java
+++ b/library/src/main/java/com/dd/processbutton/iml/SubmitProcessButton.java
@@ -2,9 +2,11 @@ package com.dd.processbutton.iml;
import com.dd.processbutton.ProcessButton;
-import android.content.Context;
-import android.graphics.Canvas;
-import android.util.AttributeSet;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Component;
+import ohos.agp.render.Canvas;
+import ohos.agp.utils.RectFloat;
+import ohos.app.Context;
/*
* The MIT License (MIT)
@@ -29,28 +31,26 @@ import android.util.AttributeSet;
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
-
public class SubmitProcessButton extends ProcessButton {
public SubmitProcessButton(Context context) {
super(context);
}
- public SubmitProcessButton(Context context, AttributeSet attrs) {
+ public SubmitProcessButton(Context context, AttrSet attrs) {
super(context, attrs);
}
- public SubmitProcessButton(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
@Override
public void drawProgress(Canvas canvas) {
float scale = (float) getProgress() / (float) getMaxProgress();
- float indicatorWidth = (float) getMeasuredWidth() * scale;
-
- getProgressDrawable().setBounds(0, 0, (int) indicatorWidth, getMeasuredHeight());
- getProgressDrawable().draw(canvas);
+ float indicatorWidth = (float) getWidth() * scale;
+ RectFloat rectFloat = new RectFloat(0, 0, (int) indicatorWidth, getHeight());
+ canvas.drawRect(rectFloat, getmProgressPaint());
}
+ @Override
+ public void onDraw(Component component, Canvas canvas) {
+ super.onDraw(component, canvas);
+ }
}
diff --git a/library/src/main/java/com/dd/processbutton/utils/AnimationUtils.java b/library/src/main/java/com/dd/processbutton/utils/AnimationUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..5aa34028aaaf0abb9aa0abf308e1c6b086239a27
--- /dev/null
+++ b/library/src/main/java/com/dd/processbutton/utils/AnimationUtils.java
@@ -0,0 +1,61 @@
+/*
+ * 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 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 com.dd.processbutton.utils;
+
+/**
+ * 动画工具类
+ *
+ * @since 2021-03-01
+ */
+public class AnimationUtils {
+ private AnimationUtils() {
+ }
+
+ /**
+ * 动画状态
+ *
+ * @since 2021-03-01
+ */
+ private static class AnimationState {
+ boolean animationClockLocked;
+ long currentVsyncTimeMillis;
+ long lastReportedTimeMillis;
+ }
+
+ private static final ThreadLocal ANIMATION_STATE
+ = new ThreadLocal() {
+ @Override
+ protected AnimationState initialValue() {
+ return new AnimationState();
+ }
+ };
+
+ /**
+ * 当前动画时长
+ *
+ * @return 时长 ms
+ */
+ public static long currentAnimationTimeMillis() {
+ AnimationState state = ANIMATION_STATE.get();
+ if (state.animationClockLocked) {
+ // It's important that time never rewinds
+ return Math.max(state.currentVsyncTimeMillis,
+ state.lastReportedTimeMillis);
+ }
+ state.lastReportedTimeMillis = System.currentTimeMillis();
+ return state.lastReportedTimeMillis;
+ }
+}
diff --git a/library/src/main/java/com/dd/processbutton/utils/AttrUtils.java b/library/src/main/java/com/dd/processbutton/utils/AttrUtils.java
new file mode 100644
index 0000000000000000000000000000000000000000..865178aad923de9bde4c41e7eb1a4f36248df9f6
--- /dev/null
+++ b/library/src/main/java/com/dd/processbutton/utils/AttrUtils.java
@@ -0,0 +1,138 @@
+/*
+ * 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 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 com.dd.processbutton.utils;
+
+import ohos.agp.components.Attr;
+import ohos.agp.components.AttrSet;
+import ohos.agp.utils.Color;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+/**
+ * 获取自定义属性工具类,如果没有配置这个自定义属性则使用默认值。
+ *
+ * @since 2021-03-01
+ */
+public class AttrUtils {
+ private static final HiLogLabel LABEL = new HiLogLabel(HiLog.LOG_APP, 0x78002, AttrUtils.class.getSimpleName());
+
+ private AttrUtils() {
+ }
+
+ /**
+ * 获取Float资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static float getFloatValueByAttr(AttrSet attrSet, String filedName, float defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getFloatValue();
+ }
+ return defaultValue;
+ }
+
+ /**
+ * 获取Int资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static int getIntValueByAttr(AttrSet attrSet, String filedName, int defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getIntegerValue();
+ }
+ return defaultValue;
+ }
+
+ /**
+ * 获取Color资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static Color getColorValueByAttr(AttrSet attrSet, String filedName, Color defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getColorValue();
+ }
+ HiLog.info(LABEL, "getColorValueByAttr return defaultValue");
+ return defaultValue;
+ }
+
+ /**
+ * 获取Dimension资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static int getDimensionValueByAttr(AttrSet attrSet, String filedName, int defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getDimensionValue();
+ }
+ return defaultValue;
+ }
+
+ /**
+ * 获取String资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static String getStringValueByAttr(AttrSet attrSet, String filedName, String defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getStringValue();
+ }
+ return defaultValue;
+ }
+
+ /**
+ * 获取Boolean资源值
+ *
+ * @param attrSet 属性集合
+ * @param filedName 属性名称
+ * @param defaultValue 默认值
+ * @return 资源值
+ */
+ public static boolean getBooleanValueByAttr(AttrSet attrSet, String filedName, boolean defaultValue) {
+ Attr attr = get(attrSet, filedName);
+ if (attr != null) {
+ return attr.getBoolValue();
+ }
+ return defaultValue;
+ }
+
+ private static Attr get(AttrSet attrSet, String filedName) {
+ if (attrSet != null && attrSet.getAttr(filedName).isPresent()) {
+ return attrSet.getAttr(filedName).get();
+ }
+ return null;
+ }
+}
diff --git a/library/src/main/java/com/dd/processbutton/utils/HmsResourcesManager.java b/library/src/main/java/com/dd/processbutton/utils/HmsResourcesManager.java
new file mode 100644
index 0000000000000000000000000000000000000000..46df8938f64ca400f40dedcdef0924651f5b12cc
--- /dev/null
+++ b/library/src/main/java/com/dd/processbutton/utils/HmsResourcesManager.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 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 com.dd.processbutton.utils;
+
+import ohos.app.Context;
+import ohos.global.resource.Element;
+import ohos.global.resource.NotExistException;
+import ohos.global.resource.WrongTypeException;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
+
+import java.io.IOException;
+
+/**
+ * 资源获取管理类
+ *
+ * @since 2021-03-01
+ */
+public class HmsResourcesManager {
+ private static final HiLogLabel hiLogLabel = new HiLogLabel(HiLog.LOG_APP,
+ 0x78002, HmsResourcesManager.class.getSimpleName());
+
+ private HmsResourcesManager() {
+ }
+
+ /**
+ * 获取float值
+ *
+ * @param context 上下文
+ * @param resourcesId 资源id
+ * @return float值
+ */
+ public static float getFloatValueByResources(Context context, int resourcesId) {
+ Element element = get(context, resourcesId);
+ if (element != null) {
+ try {
+ return element.getFloat();
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ HiLog.info(hiLogLabel, "getFloatValueByResources err exception = " + e);
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 获取Color值
+ *
+ * @param context 上下文
+ * @param resourcesId 资源id
+ * @return color值
+ */
+ public static int getColorValueByResources(Context context, int resourcesId) {
+ Element element = get(context, resourcesId);
+ if (element != null) {
+ try {
+ return element.getColor();
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ HiLog.info(hiLogLabel, "getColorValueByResources err exception = " + e);
+ }
+ }
+ return 0;
+ }
+
+ /**
+ * 获取String值
+ *
+ * @param context 上下文
+ * @param resourcesId 资源id
+ * @return String值
+ */
+ public static String getStringValueByResources(Context context, int resourcesId) {
+ Element element = get(context, resourcesId);
+ if (element != null) {
+ try {
+ return element.getString();
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ HiLog.info(hiLogLabel, "getColorValueByResources err exception = " + e);
+ }
+ }
+ return "";
+ }
+
+ private static Element get(Context context, int resourcesId) {
+ Element element = null;
+ try {
+ element = context.getResourceManager().getElement(resourcesId);
+ } catch (NotExistException | WrongTypeException | IOException e) {
+ HiLog.info(hiLogLabel, "get err exception = " + e);
+ }
+ return element;
+ }
+}
diff --git a/library/src/main/java/com/dd/processbutton/utils/Utils.java b/library/src/main/java/com/dd/processbutton/utils/Utils.java
new file mode 100644
index 0000000000000000000000000000000000000000..7905aca025bba76e182bf6337abbeaf78efc243c
--- /dev/null
+++ b/library/src/main/java/com/dd/processbutton/utils/Utils.java
@@ -0,0 +1,158 @@
+/*
+ * 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 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 com.dd.processbutton.utils;
+
+import ohos.agp.components.element.PixelMapElement;
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+import ohos.global.resource.NotExistException;
+import ohos.media.image.ImageSource;
+import ohos.media.image.PixelMap;
+import ohos.media.image.common.PixelFormat;
+import ohos.media.image.common.Rect;
+import ohos.media.image.common.Size;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+/**
+ * 工具类
+ *
+ * @since 2021-03-01
+ */
+public final class Utils {
+ private Utils() {
+ }
+
+ /**
+ * Darkens a color by a given factor.
+ *
+ * @param color the color to darken
+ * @param factor The factor to darken the color.
+ * @return darker version of specified color.
+ */
+ static int darker(int color, float factor) {
+ return Color.argb(Color.alpha(color), Math.max((int) (Integer.parseInt(red(color)) * factor), 0),
+ Math.max((int) (Integer.parseInt(green(color)) * factor), 0),
+ Math.max((int) (Integer.parseInt(blue(color)) * factor), 0));
+ }
+
+ /**
+ * Lightens a color by a given factor.
+ *
+ * @param color The color to lighten
+ * @param factor The factor to lighten the color. 0 will make the color unchanged. 1 will make the
+ * color white.
+ *
+ * @return lighter version of the specified color.
+ */
+ static int lighter(int color, float factor) {
+ int red = (int) ((Integer.parseInt(red(color), 16) * (1 - factor) / 255 + factor) * 255);
+ int green = (int) ((Integer.parseInt(green(color), 16) / 255 + factor) * 255);
+ int blue = (int) ((Integer.parseInt(blue(color), 16) * (1 - factor) / 255 + factor) * 255);
+ return Color.argb(Color.alpha(color), red, green, blue);
+ }
+
+ static String red(int color) {
+ String toHexString = Integer.toHexString((color >> 16) & 0xFF);
+ if (toHexString.length() == 1) {
+ toHexString = "0" + toHexString;
+ }
+ return toHexString;
+ }
+
+ static String green(int color) {
+ String toHexString = Integer.toHexString((color >> 8) & 0xFF);
+ if (toHexString.length() == 1) {
+ toHexString = "0" + toHexString;
+ }
+ return toHexString;
+ }
+
+ static String blue(int color) {
+ String toHexString = Integer.toHexString(color & 0xFF);
+ if (toHexString.length() == 1) {
+ toHexString = "0" + toHexString;
+ }
+ return toHexString;
+ }
+
+ /**
+ * Check if layout direction is RTL
+ *
+ * @param context the current context
+ * @return {@code true} if the layout direction is right-to-left
+ */
+ static boolean isRtl(Context context) {
+ return context.getResourceManager().getConfiguration().isLayoutRTL;
+ }
+
+ /**
+ * Return a drawable object associated with a particular resource ID.
+ *
+ * @param context env
+ * @param drawableId The desired resource identifier, as generated by the aapt tool.
+ * This integer encodes the package, type, and resource entry.
+ * The value 0 is an invalid identifier.
+ *
+ * @return Drawable An object that can be used to draw this resource.
+ */
+ public static PixelMapElement getPixelMapElement(Context context, int drawableId) {
+ PixelMap pixelMap = getPixelMap(context, drawableId);
+ if (pixelMap == null) {
+ return null;
+ }
+ return new PixelMapElement(pixelMap);
+ }
+
+ /**
+ * 获取pixmap
+ *
+ * @param context env
+ * @param drawableId drawableId
+ * @return pixmap
+ */
+ public static PixelMap getPixelMap(Context context, int drawableId) {
+ InputStream drawableInputStream = null;
+ try {
+ drawableInputStream = context.getResourceManager().getResource(drawableId);
+ ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions();
+ sourceOptions.formatHint = "image/png";
+ ImageSource imageSource = ImageSource.create(drawableInputStream, sourceOptions);
+ ImageSource.DecodingOptions decodingOptions = new ImageSource.DecodingOptions();
+ decodingOptions.desiredSize = new Size(0, 0);
+ decodingOptions.desiredRegion = new Rect(0, 0, 0, 0);
+ decodingOptions.desiredPixelFormat = PixelFormat.ARGB_8888;
+ PixelMap pixelMap = imageSource.createPixelmap(decodingOptions);
+ return pixelMap;
+ } catch (IOException | NotExistException e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ if (drawableInputStream != null) {
+ drawableInputStream.close();
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ return null;
+ }
+
+ static boolean isEmpty(CharSequence str) {
+ return str == null || str.length() == 0;
+ }
+}
diff --git a/library/src/main/res/drawable/rect_complete.xml b/library/src/main/res/drawable/rect_complete.xml
deleted file mode 100644
index b95bfb54a42ed2adf3a8710378a1c902bc491ebf..0000000000000000000000000000000000000000
--- a/library/src/main/res/drawable/rect_complete.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable/rect_error.xml b/library/src/main/res/drawable/rect_error.xml
deleted file mode 100644
index 04d593d809a8a35f9012bba0c281fce19545ba8f..0000000000000000000000000000000000000000
--- a/library/src/main/res/drawable/rect_error.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable/rect_normal.xml b/library/src/main/res/drawable/rect_normal.xml
deleted file mode 100644
index f665149cee4915d75dd336b9adf7e7e1608e1b3c..0000000000000000000000000000000000000000
--- a/library/src/main/res/drawable/rect_normal.xml
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
- -
-
-
-
-
-
-
- -
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable/rect_pressed.xml b/library/src/main/res/drawable/rect_pressed.xml
deleted file mode 100644
index 86e166a831a4d62eb62cf4fe1ccde13ba6cedd9c..0000000000000000000000000000000000000000
--- a/library/src/main/res/drawable/rect_pressed.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/drawable/rect_progress.xml b/library/src/main/res/drawable/rect_progress.xml
deleted file mode 100644
index bf984f39f5b2ee71f4faef8126a75148891f6e1e..0000000000000000000000000000000000000000
--- a/library/src/main/res/drawable/rect_progress.xml
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/library/src/main/res/values/colors.xml b/library/src/main/res/values/colors.xml
deleted file mode 100644
index 49fba6a645cc2cd0c79702e58857f94a4f0d9edb..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- #ff0099cc
- #ff33b5e5
- #ff99cc00
- #ffaa66cc
- #ffff4444
-
- #ff00ddff
- #ff99cc00
- #ffffbb33
- #ffff4444
-
\ No newline at end of file
diff --git a/library/src/main/res/values/dimen.xml b/library/src/main/res/values/dimen.xml
deleted file mode 100644
index f690990bdedae4a90f691eab7109f5ec8f65ac03..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/dimen.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 2dp
- 3dp
-
\ No newline at end of file
diff --git a/library/src/main/res/values/library_processbutton_strings.xml b/library/src/main/res/values/library_processbutton_strings.xml
deleted file mode 100644
index 5774a28156e4dd74abd4ea56394d3b63b68d5646..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/library_processbutton_strings.xml
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
- processbutton
- Dmytro Danylyk
- http://dmytrodanylyk.com/
- Process Button
- Android Buttons With Built-in Progress Meters.
- 1.0.1
- http://dmytrodanylyk.com/pages/portfolio/portfolio-process-button.html
- mit
- true
- https://github.com/dmytrodanylyk/android-process-button
-
\ No newline at end of file
diff --git a/library/src/main/res/values/styles.xml b/library/src/main/res/values/styles.xml
deleted file mode 100644
index 4bddb0a46daf86cea06bef68f633ce3615b3108d..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,16 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/library/src/main/resources/base/element/color.json b/library/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..f476991e8324307fffe3cca58daff5309a8843fe
--- /dev/null
+++ b/library/src/main/resources/base/element/color.json
@@ -0,0 +1,45 @@
+{
+ "color": [
+ {
+ "name": "purple_progress",
+ "value": "#ffaa66cc"
+ },
+ {
+ "name": "green_complete",
+ "value": "#ff99cc00"
+ },
+ {
+ "name": "red_error",
+ "value": "#ffff4444"
+ },
+ {
+ "name": "blue_pressed",
+ "value": "#ff0099cc"
+ },
+
+ {
+ "name": "holo_blue_bright",
+ "value": "#FF00DDFF"
+ },
+ {
+ "name": "holo_green_light",
+ "value": "#ff99cc00"
+ },
+ {
+ "name": "holo_orange_light",
+ "value": "#ffffbb33"
+ },
+ {
+ "name": "holo_red_light",
+ "value": "#ffff4444"
+ },
+ {
+ "name": "blue_normal",
+ "value": "#ff33b5e5"
+ },
+ {
+ "name": "white_normal",
+ "value": "#FFFFFFFF"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/library/src/main/resources/base/element/float.json b/library/src/main/resources/base/element/float.json
new file mode 100644
index 0000000000000000000000000000000000000000..95ec69ad11419e151d4a9cb8e300c2d444171387
--- /dev/null
+++ b/library/src/main/resources/base/element/float.json
@@ -0,0 +1,12 @@
+{
+ "float": [
+ {
+ "name": "corner_radius",
+ "value": "2fp"
+ },
+ {
+ "name": "layer_padding",
+ "value": "3fp"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/library/src/main/resources/base/element/string.json b/library/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..1e2b219ccdd1183e23968586e5e2e404b41c38c9
--- /dev/null
+++ b/library/src/main/resources/base/element/string.json
@@ -0,0 +1,8 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "library"
+ }
+ ]
+}
diff --git a/maven_push.gradle b/maven_push.gradle
deleted file mode 100644
index 77427244e7f6c195385d09a3d83690eeb229c002..0000000000000000000000000000000000000000
--- a/maven_push.gradle
+++ /dev/null
@@ -1,82 +0,0 @@
-apply plugin: 'maven'
-apply plugin: 'signing'
-
-def sonatypeRepositoryUrl
-if (isReleaseBuild()) {
- println 'RELEASE BUILD'
- sonatypeRepositoryUrl = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
-} else {
- println 'DEBUG BUILD'
- sonatypeRepositoryUrl = "https://oss.sonatype.org/content/repositories/snapshots/"
-}
-
-afterEvaluate { project ->
- uploadArchives {
- repositories {
- mavenDeployer {
- beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
-
- pom.artifactId = POM_ARTIFACT_ID
-
- repository(url: sonatypeRepositoryUrl) {
- authentication(userName: nexusUsername, password: nexusPassword)
- }
-
- pom.project {
- name POM_NAME
- packaging POM_PACKAGING
- description POM_DESCRIPTION
- url POM_URL
-
- scm {
- url POM_SCM_URL
- connection POM_SCM_CONNECTION
- developerConnection POM_SCM_DEV_CONNECTION
- }
-
- licenses {
- license {
- name POM_LICENCE_NAME
- url POM_LICENCE_URL
- distribution POM_LICENCE_DIST
- }
- }
-
- developers {
- developer {
- id POM_DEVELOPER_ID
- name POM_DEVELOPER_NAME
- }
- }
- }
- }
- }
- }
-
- signing {
- required { isReleaseBuild() && gradle.taskGraph.hasTask("uploadArchives") }
- sign configurations.archives
- }
-
- task androidJavadocs(type: Javadoc) {
- source = 'src/main/java'
- }
-
- task androidJavadocsJar(type: Jar) {
- classifier = 'javadoc'
- //basename = artifact_id
- from androidJavadocs.destinationDir
- }
-
- task androidSourcesJar(type: Jar) {
- classifier = 'sources'
- //basename = artifact_id
- from 'src/main/java'
- }
-
- artifacts {
- //archives packageReleaseJar
- archives androidSourcesJar
- archives androidJavadocsJar
- }
-}
diff --git a/sample/build.gradle b/sample/build.gradle
deleted file mode 100644
index 5d3d12a395e12fb7e73c9da6680e7bd22af43955..0000000000000000000000000000000000000000
--- a/sample/build.gradle
+++ /dev/null
@@ -1,79 +0,0 @@
-import java.text.SimpleDateFormat
-
-buildscript {
- repositories {
- jcenter()
- }
- dependencies {
- classpath 'com.android.tools.build:gradle:1.2.2'
- }
-}
-apply plugin: 'com.android.application'
-
-repositories {
- jcenter()
- maven {
- url "https://oss.sonatype.org/content/repositories/snapshots/"
- }
-}
-
-android {
- compileSdkVersion 21
- buildToolsVersion '21.1.2'
-
- defaultConfig {
- minSdkVersion 14
- targetSdkVersion 21
- applicationId project.PACKAGE_NAME
- versionCode Integer.parseInt(project.VERSION_CODE)
- versionName project.VERSION_NAME
- }
-
- signingConfigs {
- release
- }
-
- buildTypes {
- debug {
- }
-
- release {
- signingConfig project.hasProperty('storeFile') ? signingConfigs.release : signingConfigs.debug
- }
- }
-
- applicationVariants.all { variant ->
- variant.outputs.each { output ->
- "${variant.versionName}" + "_" + "${variant.versionCode}" + "_" + getDate() + ".apk";
- def oldFile = output.outputFile
- def newPath = "${variant.name}" + "_" + "${variant.versionName}" + "_" + "${variant.versionCode}" + "_" + getDate() + ".apk";
- output.outputFile = new File(oldFile.parentFile, newPath)
- }
- }
-}
-
-
-def getDate() {
- def formatter = new SimpleDateFormat('dd-MM-yyyy');
- def date = new Date();
- return formatter.format(date);
-}
-
-dependencies {
- compile fileTree(dir: 'libs', include: ['*.jar'])
- compile project(':library')
-// compile 'com.github.dmytrodanylyk.android-process-button:library:1.0.2-SNAPSHOT@aar'
-}
-
-if (project.hasProperty('storeFile')) {
- android.signingConfigs.release.storeFile = file(storeFile)
-}
-if (project.hasProperty('keyAlias')) {
- android.signingConfigs.release.keyAlias = keyAlias
-}
-if (project.hasProperty('storePassword')) {
- android.signingConfigs.release.storePassword = storePassword
-}
-if (project.hasProperty('keyPassword')) {
- android.signingConfigs.release.keyPassword = keyPassword
-}
diff --git a/sample/proguard-rules.txt b/sample/proguard-rules.txt
deleted file mode 100644
index 88a1529fcfe9aaa62307386fb1d8c21f00e6980f..0000000000000000000000000000000000000000
--- a/sample/proguard-rules.txt
+++ /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 C:/Work/android-sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the ProGuard
-# include property in project.properties.
-#
-# 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 *;
-#}
\ No newline at end of file
diff --git a/sample/src/main/AndroidManifest.xml b/sample/src/main/AndroidManifest.xml
deleted file mode 100644
index ae7350acf39daf975139a600b12fe985d69f4bf7..0000000000000000000000000000000000000000
--- a/sample/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,42 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/src/main/java/com/dd/sample/MainActivity.java b/sample/src/main/java/com/dd/sample/MainActivity.java
deleted file mode 100644
index 46d4bf7073a63eba2f93a68e28be40264e90f174..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/dd/sample/MainActivity.java
+++ /dev/null
@@ -1,64 +0,0 @@
-package com.dd.sample;
-
-import android.app.ListActivity;
-import android.content.Intent;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.ArrayAdapter;
-import android.widget.ListView;
-
-public class MainActivity extends ListActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
-
- String[] items = getResources().getStringArray(R.array.sample_list);
-
- ArrayAdapter adapter =
- new ArrayAdapter(this, android.R.layout.simple_list_item_1, items);
- setListAdapter(adapter);
- }
-
- @Override
- protected void onListItemClick(ListView l, View v, int position, long id) {
- switch (position) {
- case 0:
- startSignInActivity(false);
- break;
- case 1:
- startSignInActivity(true);
- break;
- case 2:
- startMessageActivity();
- break;
- case 3:
- startUploadActivity();
- break;
- case 4:
- startStateSampleActivity();
- break;
- }
- }
-
- private void startStateSampleActivity() {
- Intent intent = new Intent(this, StateSampleActivity.class);
- startActivity(intent);
- }
-
- private void startUploadActivity() {
- Intent intent = new Intent(this, UploadActivity.class);
- startActivity(intent);
- }
-
- private void startSignInActivity(boolean isEndlessMode) {
- Intent intent = new Intent(this, SignInActivity.class);
- intent.putExtra(SignInActivity.EXTRAS_ENDLESS_MODE, isEndlessMode);
- startActivity(intent);
- }
-
- private void startMessageActivity() {
- Intent intent = new Intent(this, MessageActivity.class);
- startActivity(intent);
- }
-}
diff --git a/sample/src/main/java/com/dd/sample/MessageActivity.java b/sample/src/main/java/com/dd/sample/MessageActivity.java
deleted file mode 100644
index 59a56969352a2d9b1fc348d3b249045e5742212d..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/dd/sample/MessageActivity.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package com.dd.sample;
-
-import com.dd.processbutton.iml.SubmitProcessButton;
-import com.dd.sample.utils.ProgressGenerator;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.Toast;
-
-
-public class MessageActivity extends Activity implements ProgressGenerator.OnCompleteListener {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.ac_message);
-
- final EditText editMessage = (EditText) findViewById(R.id.editMessage);
-
- final ProgressGenerator progressGenerator = new ProgressGenerator(this);
- final SubmitProcessButton btnSend = (SubmitProcessButton) findViewById(R.id.btnSend);
- btnSend.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- progressGenerator.start(btnSend);
- btnSend.setEnabled(false);
- editMessage.setEnabled(false);
- }
- });
- }
-
- @Override
- public void onComplete() {
- Toast.makeText(this, R.string.Loading_Complete, Toast.LENGTH_LONG).show();
- }
-
-}
diff --git a/sample/src/main/java/com/dd/sample/SignInActivity.java b/sample/src/main/java/com/dd/sample/SignInActivity.java
deleted file mode 100644
index d562e0067d3a619b2b69b6114a8d51910e697643..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/dd/sample/SignInActivity.java
+++ /dev/null
@@ -1,49 +0,0 @@
-package com.dd.sample;
-
-import com.dd.processbutton.iml.ActionProcessButton;
-import com.dd.sample.utils.ProgressGenerator;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.EditText;
-import android.widget.Toast;
-
-
-public class SignInActivity extends Activity implements ProgressGenerator.OnCompleteListener {
-
- public static final String EXTRAS_ENDLESS_MODE = "EXTRAS_ENDLESS_MODE";
-
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.ac_sign_in);
-
- final EditText editEmail = (EditText) findViewById(R.id.editEmail);
- final EditText editPassword = (EditText) findViewById(R.id.editPassword);
-
- final ProgressGenerator progressGenerator = new ProgressGenerator(this);
- final ActionProcessButton btnSignIn = (ActionProcessButton) findViewById(R.id.btnSignIn);
- Bundle extras = getIntent().getExtras();
- if(extras != null && extras.getBoolean(EXTRAS_ENDLESS_MODE)) {
- btnSignIn.setMode(ActionProcessButton.Mode.ENDLESS);
- } else {
- btnSignIn.setMode(ActionProcessButton.Mode.PROGRESS);
- }
- btnSignIn.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- progressGenerator.start(btnSignIn);
- btnSignIn.setEnabled(false);
- editEmail.setEnabled(false);
- editPassword.setEnabled(false);
- }
- });
- }
-
- @Override
- public void onComplete() {
- Toast.makeText(this, R.string.Loading_Complete, Toast.LENGTH_LONG).show();
- }
-
-}
diff --git a/sample/src/main/java/com/dd/sample/UploadActivity.java b/sample/src/main/java/com/dd/sample/UploadActivity.java
deleted file mode 100644
index 197343e6ef1f41a7b9e284cd984067d0f15d2151..0000000000000000000000000000000000000000
--- a/sample/src/main/java/com/dd/sample/UploadActivity.java
+++ /dev/null
@@ -1,35 +0,0 @@
-package com.dd.sample;
-
-import com.dd.processbutton.iml.GenerateProcessButton;
-import com.dd.sample.utils.ProgressGenerator;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-import android.widget.Toast;
-
-
-public class UploadActivity extends Activity implements ProgressGenerator.OnCompleteListener {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.ac_upload);
-
- final ProgressGenerator progressGenerator = new ProgressGenerator(this);
- final GenerateProcessButton btnUpload =
- (GenerateProcessButton) findViewById(R.id.btnUpload);
- btnUpload.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- progressGenerator.start(btnUpload);
- btnUpload.setEnabled(false);
- }
- });
- }
-
- @Override
- public void onComplete() {
- Toast.makeText(this, R.string.Loading_Complete, Toast.LENGTH_LONG).show();
- }
-}
diff --git a/sample/src/main/res/drawable-hdpi/ic_launcher.png b/sample/src/main/res/drawable-hdpi/ic_launcher.png
deleted file mode 100644
index d3c7138a01defe8e6b4b14e923773bf92396965e..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-hdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-mdpi/ic_launcher.png b/sample/src/main/res/drawable-mdpi/ic_launcher.png
deleted file mode 100644
index daebd08b18338c74d56c8a4c4c0262e4b7714f12..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-mdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xhdpi/ic_launcher.png b/sample/src/main/res/drawable-xhdpi/ic_launcher.png
deleted file mode 100644
index 371331e8a0551e4c1270735f5eaf0dfea0f98042..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxhdpi/ic_launcher.png b/sample/src/main/res/drawable-xxhdpi/ic_launcher.png
deleted file mode 100644
index b8b5a70349a41d8734e76c018e0173fa6031e6e8..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png b/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png
deleted file mode 100644
index 1545f6762d7fd9a0a88c7a490d079cac9845c8c2..0000000000000000000000000000000000000000
Binary files a/sample/src/main/res/drawable-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/sample/src/main/res/layout/ac_message.xml b/sample/src/main/res/layout/ac_message.xml
deleted file mode 100644
index a4fbc05e9c4f57eec3d9467851ae3730cbad5b7c..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/ac_message.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
diff --git a/sample/src/main/res/layout/ac_sign_in.xml b/sample/src/main/res/layout/ac_sign_in.xml
deleted file mode 100644
index f0aa7d7e883ed3b5c80bc00132d510c3bab44fdb..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/ac_sign_in.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/sample/src/main/res/layout/ac_states.xml b/sample/src/main/res/layout/ac_states.xml
deleted file mode 100644
index 72ec03d103e7a486e4403f4f9d4bdf484778a726..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/ac_states.xml
+++ /dev/null
@@ -1,72 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/sample/src/main/res/layout/ac_upload.xml b/sample/src/main/res/layout/ac_upload.xml
deleted file mode 100644
index f4d4d172d194f15c1d066a7e652519ab0b5a8571..0000000000000000000000000000000000000000
--- a/sample/src/main/res/layout/ac_upload.xml
+++ /dev/null
@@ -1,28 +0,0 @@
-
-
-
-
-
-
-
diff --git a/sample/src/main/res/values/strings.xml b/sample/src/main/res/values/strings.xml
deleted file mode 100644
index 313dd27afa548fabeebacf4de3faa0cb0b6a0920..0000000000000000000000000000000000000000
--- a/sample/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-
-
-
- Process Button Sample
- Settings
- jondoe@gmail.com
- 123456789
- Sign in
- Success
- Loading..
- How are you?
- Send
- Done
- Upload
- Beautiful Picture
- Uploading
- Loading Complete, button is disabled
-
-
- - Action Button Progress sample
- - Action Button Endless Progress sample
- - Submit Button Progress sample
- - Generate Button Progress sample
- - Button State sample
-
-
-
diff --git a/screenshots/diagram-v-0-0-2.png b/screenshots/diagram-v-0-0-2.png
deleted file mode 100644
index b276f53085388ea3a5438db498f65d55e639956e..0000000000000000000000000000000000000000
Binary files a/screenshots/diagram-v-0-0-2.png and /dev/null differ
diff --git a/screenshots/sample1.gif b/screenshots/sample1.gif
deleted file mode 100644
index d7dfb008df34a4cee6c65c45a178ec4984d72d67..0000000000000000000000000000000000000000
Binary files a/screenshots/sample1.gif and /dev/null differ
diff --git a/screenshots/sample1_small1.gif b/screenshots/sample1_small1.gif
deleted file mode 100644
index 40e7ac86f302ce7447823670a76049f6af7101d5..0000000000000000000000000000000000000000
Binary files a/screenshots/sample1_small1.gif and /dev/null differ
diff --git a/screenshots/sample1_small2.gif b/screenshots/sample1_small2.gif
deleted file mode 100644
index 64745a4417e58c96206494cbca80c46c45353cdf..0000000000000000000000000000000000000000
Binary files a/screenshots/sample1_small2.gif and /dev/null differ
diff --git a/screenshots/sample2.gif b/screenshots/sample2.gif
deleted file mode 100644
index bb500299b3db21584bcb83da691992ef278e900c..0000000000000000000000000000000000000000
Binary files a/screenshots/sample2.gif and /dev/null differ
diff --git a/screenshots/sample3.gif b/screenshots/sample3.gif
deleted file mode 100644
index 04f2a6161e90ae2492420fef251f0e6a63c563f7..0000000000000000000000000000000000000000
Binary files a/screenshots/sample3.gif and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index f171b1ff730a37cbe8b10d273a5af81dcf1ad8a6..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':library', ':sample'
\ No newline at end of file
+include ':entry', ':library'