diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..26d33521af10bcc7fd8cea344038eaaeb78d0ef5
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,3 @@
+# Default ignored files
+/shelf/
+/workspace.xml
diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser
index 6654f3193dc166295bdf3aadcd5cb3193119890c..9692dd821a73c77803e81147e7817b3a643dfb80 100644
Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ
diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000000000000000000000000000000000000..9d45f4369697246b4bb01e1cb33f15a0252f36ba
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,16 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
deleted file mode 100644
index 30aa626c23142d59e94cc76327172301f159b618..0000000000000000000000000000000000000000
--- a/.idea/codeStyles/Project.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/compiler.xml b/.idea/compiler.xml
new file mode 100644
index 0000000000000000000000000000000000000000..61a9130cd9669c3843e6445dfe1fee2d493869bc
--- /dev/null
+++ b/.idea/compiler.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gradle.xml b/.idea/gradle.xml
index 66e2f6f1ca027a5cf366172ece62895986ce1e99..9108ab03b1e76b80feeeeb96d477196c11c82b00 100644
--- a/.idea/gradle.xml
+++ b/.idea/gradle.xml
@@ -1,18 +1,22 @@
+
diff --git a/.idea/jarRepositories.xml b/.idea/jarRepositories.xml
new file mode 100644
index 0000000000000000000000000000000000000000..1dfcd020d2b2774ad414ac5c0acc344e9b9479b4
--- /dev/null
+++ b/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index 99202cc2d646ceed792bbfa449bc73a840cd6f95..58918f50335428f2efb3af4d621f9f405ed659d4 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,34 +1,4 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 5d87a44476c4efaa12eb34b975624b3627885926..30ad0dca95945588a24aa9fbc2f3f59546469604 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -2,9 +2,9 @@
-
-
-
+
+
+
\ No newline at end of file
diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml
deleted file mode 100644
index 7f68460d8b38ac04e3a3224d7c79ef719b1991a9..0000000000000000000000000000000000000000
--- a/.idea/runConfigurations.xml
+++ /dev/null
@@ -1,12 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 35eb1ddfbbc029bcab630581847471d7f238ec53..94a25f7f4cb416c083d265558da75d457237d671 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 9fb3d456e20e9774cad8aef4deb5d20d23eff738..0000000000000000000000000000000000000000
--- a/LICENSE
+++ /dev/null
@@ -1,201 +0,0 @@
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "{}"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright (c) 2016 smuyyh. All right reserved.
-
- 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.
diff --git a/README.md b/README.md
index 971d3b3a3a677b482669d8e23914260ea94081bf..9d4c9861ca87e265965722c0d40ddf42dbacddb2 100644
--- a/README.md
+++ b/README.md
@@ -1,45 +1,358 @@
-# BankCardFormat
+# BankCardFormat_ohos
-## 自动格式化银行卡号的EditText,每四位增加一个空格,并根据银行卡号判断该银行卡归属的银行及卡别
+**本项目基于开源项目BankCardFormat 进行openharmony化的移植和开发,可以通过项目标签以及github地址( https://github.com/smuyyh/BankCardFormat )追踪到原安卓项目版本**
-
+#### 项目介绍
+- 项目名称:自动格式化银行卡号的EditText控件
+- 所属系列:openharmony的第三方组件适配移植
+- 功能:自动格式化银行卡号的EditText,每四位增加一个空格,并根据银行卡号判断该银行卡归属的银行及卡别
+- 项目移植状态:主功能完成
+- 调用差异:无
+- 开发版本:sdk5,DevEco Studio2.1 beta3
+- 项目作者和维护人:李佳晓
+- 联系方式:lijiaxiao073@chinasoftinc.com
+- 原项目Doc地址:https://github.com/smuyyh/BankCardFormat
+
+#### 效果演示
+
+
+#### 安装教程
+
+1.下载library的har包library.har(位于: )。
+
+2.启动 DevEco Studio,将下载的har包,导入工程目录“demo->libs”下。
+
+3.在moudle级别下的build.gradle文件中添加依赖,在dependencies标签中增加对libs目录下jar包的引用。
+
+ ```
+ dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ ......
+ }
+ ```
+
+在sdk5,DevEco Studio2.1 beta3下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
+
+#### 使用说明
+
+组件主要由EditText控件和检索 TextWatcher组成。
+
+原开源项目重写EditText,现在openharmony项目重写DependentLayout包含TextField的组合控件。
+
+XML中添加自定义控件:
-### 使用
-```
-dependencies {
- compile 'com.yuyh.bankcardformat:library:1.0.3'
-}
-```
```xml
-
+
+
+
+
+
+
+
```
+
+输入控件加入自动检索和格式化功能,并且在输入信息后自动格式化和检索所属信息进行显示:
+
```java
- tv = (TextView) findViewById(R.id.tv);
- editText = (BandCardEditText) findViewById(R.id.et);
- editText.setBankCardListener(new BankCardListener() {
@Override
- public void success(String name) {
- tv.setText("所属银行:" + name);
- }
-
- @Override
- public void failure() {
- tv.setText("所属银行:");
- }
- });
-
- // 或者直接检测
- String carnum = "622700187301032701";
- if (BankCardUtils.checkBankCard(carnum)) {
- char[] ss = carnum.toCharArray();
- String bank = BankCardUtils.getNameOfBank(ss, 0);
- }
+ public void onTextUpdated(String s, int start, int before, int count) {
+ if (s.length() >= 24) {
+ setText(s.substring(0, 23));
+ format(s.substring(0, 23));
+ } else {
+ format(s);
+ }
+ }
+
+ private void format(String editable) {
+ if (shouldStopChange) {
+ shouldStopChange = false;
+ return;
+ }
+
+ shouldStopChange = true;
+
+ String str = editable.trim().replaceAll(WHITE_SPACE, "");
+ int len = str.length();
+ int courPos;
+
+ StringBuilder builder = new StringBuilder();
+ for (int i = 0; i < len; i++) {
+ builder.append(str.charAt(i));
+ if (i == 3 || i == 7 || i == 11 || i == 15) {
+ if (i != len - 1)
+ builder.append(WHITE_SPACE);
+ }
+ }
+ courPos = builder.length();
+ setText(builder.toString());
+
+ //setSelection(courPos);
+
+ if (listener != null) {
+ if (BankCardUtils.checkBankCard(getBankCardText())) {
+ char[] ss = getBankCardText().toCharArray();
+ listener.success(BankCardUtils.getNameOfBank(ss, 0));
+ } else {
+ listener.failure();
+ }
+ }
+ }
```
+自定义BankCardFormat_ohos控件,使用到的主要属性,具体属性如下:
+
+| name | type | info |
+|-------------------------|-----------|--------------------------------------------------------|
+| background_element | color | sets the background color |
+| text_input_type | integer | set to input content type |
+
+
+#### 测试信息
+
+CodeCheck代码测试无异常
+
+CloudTest代码测试无异常
+
+火绒安全病毒安全检测通过
+
+当前版本demo功能与安卓原组件基本无差异
+
+测试员:常万里
+
+#### 版本迭代
+
+- v0.0.1_alpha
+
+#### 版权和许可信息
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "{}"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright (c) 2016 smuyyh. All right reserved.
+
+ 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.
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index c7b981a6a91dea2c942e9977801bdca048979bd5..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,26 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 23
- buildToolsVersion "26.0.0"
-
- defaultConfig {
- applicationId "com.yuyh.bankcardformat"
- minSdkVersion 15
- targetSdkVersion 23
- versionCode 1
- versionName "1.0"
- }
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-}
-
-dependencies {
- compile fileTree(include: ['*.jar'], dir: 'libs')
- compile 'com.android.support:appcompat-v7:23.4.0'
- compile project(':library')
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index fdc36508f2e9b8681b7b0b9472fc1819bc0cce40..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\AndroidDev\sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index cffed1c4e56ad270d60025208155e2b0bfda5fad..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 8714749cdbc9e29d363fadd9e40a6cd8f1de4809..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
-
-
-
-
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 47c82246738c4d056e8030d3a259206f42e8e15d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
- 16dp
- 16dp
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index fe8c554e59bec781b62cfedb040987c88719b5be..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- BankCardFormat
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 5885930df6d10edf3d6df40d6556297d11f953da..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index d92d62f068be94a8ed0d6b56c99a9b6fd8c2f8c9..bbb5d8b3bebfa3a7c406747c636f6dc51ab06748 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,30 +1,37 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
+apply plugin: 'com.huawei.ohos.app'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
+
buildscript {
-
repositories {
- google()
- jcenter()
- mavenCentral()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.1.0-alpha08'
-
- classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
- classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
- // 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.5'
+ classpath 'com.huawei.ohos:decctest:1.0.0.6'
}
}
allprojects {
repositories {
- google()
- jcenter()
- mavenCentral()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
+ jcenter()
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 100%
rename from app/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..5a04d972dc55df408b95c75947b3ebccf52f9ecf
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,26 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 5
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100'
+ compile project(":library")
+}
+decc {
+ supportType = ['html','xml']
+}
diff --git a/entry/proguard-rules.pro b/entry/proguard-rules.pro
new file mode 100644
index 0000000000000000000000000000000000000000..f7666e47561d514b2a76d5a7dfbb43ede86da92a
--- /dev/null
+++ b/entry/proguard-rules.pro
@@ -0,0 +1 @@
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..517d580c041c38835182ffff7d6780269ff44888
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,49 @@
+{
+ "app": {
+ "bundleName": "com.lijiaxiao.bankcard",
+ "vendor": "yuyh",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.yuyh.bankcardformat",
+ "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.yuyh.bankcardformat.MainAbility",
+ "icon": "$media:icon",
+ "description": "$string:mainability_description",
+ "label": "$string:app_name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/yuyh/bankcardformat/MainAbility.java b/entry/src/main/java/com/yuyh/bankcardformat/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..2739b1062e3e763f22445f68f7a4b1a525a8748e
--- /dev/null
+++ b/entry/src/main/java/com/yuyh/bankcardformat/MainAbility.java
@@ -0,0 +1,15 @@
+package com.yuyh.bankcardformat;
+
+import com.yuyh.bankcardformat.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+
+public class MainAbility extends Ability {
+
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ }
+
+}
diff --git a/entry/src/main/java/com/yuyh/bankcardformat/MyApplication.java b/entry/src/main/java/com/yuyh/bankcardformat/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..5ce5bab852157d708ad2afccd8ede0a54d6d6c6e
--- /dev/null
+++ b/entry/src/main/java/com/yuyh/bankcardformat/MyApplication.java
@@ -0,0 +1,10 @@
+package com.yuyh.bankcardformat;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/app/src/main/java/com/yuyh/bankcardformat/MainActivity.java b/entry/src/main/java/com/yuyh/bankcardformat/slice/MainAbilitySlice.java
similarity index 35%
rename from app/src/main/java/com/yuyh/bankcardformat/MainActivity.java
rename to entry/src/main/java/com/yuyh/bankcardformat/slice/MainAbilitySlice.java
index af22c16fb818d7b21a3e2de8298eedbcce0a50cf..72ce662860ed5d450d3ab705b7a7731c43aeb000 100644
--- a/app/src/main/java/com/yuyh/bankcardformat/MainActivity.java
+++ b/entry/src/main/java/com/yuyh/bankcardformat/slice/MainAbilitySlice.java
@@ -1,26 +1,28 @@
-package com.yuyh.bankcardformat;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.util.Log;
-import android.widget.TextView;
+package com.yuyh.bankcardformat.slice;
import com.example.library.BandCardEditText;
import com.example.library.BankCardListener;
+import com.yuyh.bankcardformat.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+import ohos.agp.components.Text;
+import ohos.hiviewdfx.HiLog;
+import ohos.hiviewdfx.HiLogLabel;
-public class MainActivity extends AppCompatActivity {
+public class MainAbilitySlice extends AbilitySlice {
- BandCardEditText editText;
- TextView tv;
+ private BandCardEditText editText;
+ private Text tv;
@Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
- tv = (TextView) findViewById(R.id.tv);
- editText = (BandCardEditText) findViewById(R.id.et);
+ tv = (Text) findComponentById(ResourceTable.Id_text);
+ editText = (BandCardEditText) findComponentById(ResourceTable.Id_et);
editText.setBankCardListener(new BankCardListener() {
+
@Override
public void success(String name) {
tv.setText("所属银行:" + name);
@@ -28,9 +30,18 @@ public class MainActivity extends AppCompatActivity {
@Override
public void failure() {
- Log.i("TAG", "failure");
tv.setText("所属银行:");
}
});
}
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
}
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..374af86ac1e4c9d56213797a9e415ab2cb4f1660
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "BankCardFormat"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..dfaa51f167f96a0a800720bbab525c5929917736
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
\ 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/ohosTest/config.json b/entry/src/ohosTest/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..b5b92e1499736d2adc18caae66b5d87d307ed67b
--- /dev/null
+++ b/entry/src/ohosTest/config.json
@@ -0,0 +1,41 @@
+{
+ "app": {
+ "bundleName": "com.yuyh.bankcardformat",
+ "vendor": "yuyh",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.yuyh.bankcardformat",
+ "name": "testModule",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry_test",
+ "moduleType": "feature",
+ "installationFree": true
+ },
+ "abilities": [
+ {
+ "name": "decc.testkit.runner.EntryAbility",
+ "description": "Test Entry Ability",
+ "icon": "$media:icon",
+ "label": "$string:app_name",
+ "launchType": "standard",
+ "orientation": "landscape",
+ "visible": true,
+ "type": "page"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/yuyh/bankcardformat/ExampleOhosTest.java b/entry/src/ohosTest/java/com/yuyh/bankcardformat/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..162c282168a882ccc94a788ceb6caf7ead93a50c
--- /dev/null
+++ b/entry/src/ohosTest/java/com/yuyh/bankcardformat/ExampleOhosTest.java
@@ -0,0 +1,14 @@
+package com.yuyh.bankcardformat;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.yuyh.bankcardformat", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/yuyh/bankcardformat/ExampleTest.java b/entry/src/test/java/com/yuyh/bankcardformat/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..afb2262dbc9cf3b4d70a4debc17ec6a141e05912
--- /dev/null
+++ b/entry/src/test/java/com/yuyh/bankcardformat/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.yuyh.bankcardformat;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gif/bankcardformat.gif b/gif/bankcardformat.gif
new file mode 100644
index 0000000000000000000000000000000000000000..049193da8484c8165834f3586b592f9ada78f2d2
Binary files /dev/null and b/gif/bankcardformat.gif differ
diff --git a/gradle.properties b/gradle.properties
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0daf1830fbdef07e50a44d74210c8c82f1b66278 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,18 +1,10 @@
# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
+# IDE (e.g. DevEco Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
-
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
-
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
+# If the Chinese output is garbled, please configure the following parameter.
+# org.gradle.jvmargs=-Dfile.encoding=GBK
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 13372aef5e24af05341d49695ee84e5f9b594659..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 5d9a6fff2711f612d0b0b5693c843d3e93308afa..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Tue Jan 23 15:53:01 CST 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
diff --git a/gradlew b/gradlew
index 9d82f78915133e1c35a6ea51252590fb38efac2f..536f0272dd995f3afdb5e34e0f42bdf3d1986c22 100755
--- 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,155 +22,162 @@
##
##############################################################################
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname \"$PRG\")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
+APP_BASE_NAME=$(basename "$0")
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
-warn ( ) {
- echo "$*"
+warn() {
+ echo "$*"
}
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
+die() {
+ echo
+ echo "$*"
+ echo
+ exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
+nonstop=false
+case "$(uname)" in
+CYGWIN*)
+ cygwin=true
+ ;;
+Darwin*)
+ darwin=true
+ ;;
+MINGW*)
+ msys=true
+ ;;
+NONSTOP*)
+ nonstop=true
+ ;;
esac
-# 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
-
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+if [ -n "$JAVA_HOME" ]; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ]; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ]; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
- fi
+ fi
else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ]; then
+ MAX_FD_LIMIT=$(ulimit -H -n)
+ if [ $? -eq 0 ]; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
+ MAX_FD="$MAX_FD_LIMIT"
fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ]; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if [ "$cygwin" = "true" -o "$msys" = "true" ]; then
+ APP_HOME=$(cygpath --path --mixed "$APP_HOME")
+ CLASSPATH=$(cygpath --path --mixed "$CLASSPATH")
+ JAVACMD=$(cygpath --unix "$JAVACMD")
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=$(find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null)
+ SEP=""
+ for dir in $ROOTDIRSRAW; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ]; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@"; do
+ CHECK=$(echo "$arg" | egrep -c "$OURCYGPATTERN" -)
+ CHECK2=$(echo "$arg" | egrep -c "^-") ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ]; then ### Added a condition
+ eval $(echo args$i)=$(cygpath --path --ignore --mixed "$arg")
+ else
+ eval $(echo args$i)="\"$arg\""
fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
+ i=$(expr $i + 1)
+ done
+ case $i in
+ 0) set -- ;;
+ 1) set -- "$args0" ;;
+ 2) set -- "$args0" "$args1" ;;
+ 3) set -- "$args0" "$args1" "$args2" ;;
+ 4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
fi
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
+# Escape application args
+save() {
+ for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
+ echo " "
}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
+exec "$JAVACMD" "$@"
diff --git a/gradlew.bat b/gradlew.bat
index 8a0b282aa6885fb573c106b3551f7275c5f17e8e..62bd9b9ccefea2b65ae41e5d9a545e2021b90a1d 100644
--- a/gradlew.bat
+++ b/gradlew.bat
@@ -1,3 +1,19 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@@ -8,14 +24,17 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,10 +65,9 @@ echo location of your Java installation.
goto fail
:init
-@rem Get command-line arguments, handling Windowz variants
+@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -60,11 +78,6 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
diff --git a/library/build.gradle b/library/build.gradle
index a4a9ba0e652d383db0061b4615a42b11c885e5b8..25ddf0cf1daa8f1533639ebc05ce352f4019b8ff 100644
--- a/library/build.gradle
+++ b/library/build.gradle
@@ -1,99 +1,21 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.github.dcendents.android-maven'
-apply plugin: 'com.jfrog.bintray'
-// This is the library version used when deploying the artifact
-version = "1.0.3"
-android {
- compileSdkVersion 23
- buildToolsVersion "26.0.6"
- resourcePrefix "bankcardformat"
-
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 5
defaultConfig {
- minSdkVersion 8
- targetSdkVersion 23
- versionCode 4
- versionName "1.0.3"
+ compatibleSdkVersion 5
}
buildTypes {
release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
}
}
+
}
dependencies {
- compile 'com.android.support:appcompat-v7:23.+'
- compile fileTree(dir: 'libs', include: ['*.jar'])
- testCompile 'junit:junit:4.12'
-}
-
-def siteUrl = 'https://github.com/smuyyh/BankCardFormat' // 项目的主页
-def gitUrl = 'https://github.com/smuyyh/BankCardFormat.git' // Git仓库的url
-group = "com.yuyh.bankcardformat" // Maven Group ID for the artifact,一般填你唯一的包名
-
-install {
- repositories.mavenInstaller {
- // This generates POM.xml with proper parameters
- pom {
- project {
- packaging 'aar'
- // Add your description here
- name 'Android BankCardFormat' //项目描述
- url siteUrl
- // Set your license
- licenses {
- license {
- name 'The Apache Software License, Version 2.0'
- url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
- }
- }
- developers {
- developer {
- id 'smuyyh' //填写的一些基本信息
- name 'smuyyh'
- email 'smuyyh@gmail.com'
- }
- }
- scm {
- connection gitUrl
- developerConnection gitUrl
- url siteUrl
- }
- }
- }
- }
-}
-task sourcesJar(type: Jar) {
- from android.sourceSets.main.java.srcDirs
- classifier = 'sources'
-}
-task javadoc(type: Javadoc) {
- tasks.findByPath(":library:javadoc").enabled = false
- options.encoding = "UTF-8"
- source = android.sourceSets.main.java.srcDirs
- classpath += project.files(android.getBootClasspath().join(File.pathSeparator))
-}
-task javadocJar(type: Jar, dependsOn: javadoc) {
- classifier = 'javadoc'
- from javadoc.destinationDir
-}
-artifacts {
- archives javadocJar
- archives sourcesJar
-}
-Properties properties = new Properties()
-properties.load(project.rootProject.file('local.properties').newDataInputStream())
-bintray {
- user = properties.getProperty("bintray.user")
- key = properties.getProperty("bintray.apikey")
- configurations = ['archives']
- pkg {
- repo = "maven"
- name = "BankCardFormat" //发布到JCenter上的项目名字
- websiteUrl = siteUrl
- vcsUrl = gitUrl
- licenses = ["Apache-2.0"]
- publish = true
- }
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
}
diff --git a/library/proguard-rules.pro b/library/proguard-rules.pro
index fdc36508f2e9b8681b7b0b9472fc1819bc0cce40..f7666e47561d514b2a76d5a7dfbb43ede86da92a 100644
--- a/library/proguard-rules.pro
+++ b/library/proguard-rules.pro
@@ -1,17 +1 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in D:\AndroidDev\sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# If your project uses WebView with JS, uncomment the following
-# and specify the fully qualified class name to the JavaScript interface
-# class:
-#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
-# public *;
-#}
+# config module specific ProGuard rules here.
\ No newline at end of file
diff --git a/library/src/main/AndroidManifest.xml b/library/src/main/AndroidManifest.xml
deleted file mode 100644
index fec0ee4e33056c18a36d24a647e2c15f912738d4..0000000000000000000000000000000000000000
--- a/library/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,11 +0,0 @@
-
-
-
-
-
-
-
diff --git a/library/src/main/config.json b/library/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..387a920aed0a5d72b9bea53f6e9efb55e5f52a4c
--- /dev/null
+++ b/library/src/main/config.json
@@ -0,0 +1,28 @@
+{
+ "app": {
+ "bundleName": "com.yuyh.bankcardformat",
+ "vendor": "example",
+ "version": {
+ "code": 1,
+ "name": "1.0"
+ },
+ "apiVersion": {
+ "compatible": 5,
+ "target": 5,
+ "releaseType": "Beta1"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.example.library",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "library",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/library/src/main/java/com/example/library/BandCardEditText.java b/library/src/main/java/com/example/library/BandCardEditText.java
index f65f0ddeb9e36369db4537ac48aafc9d657f5a08..ee75ed362e8533a8270dfdf52314b9e96f1a2799 100644
--- a/library/src/main/java/com/example/library/BandCardEditText.java
+++ b/library/src/main/java/com/example/library/BandCardEditText.java
@@ -1,11 +1,12 @@
package com.example.library;
-import android.content.Context;
-import android.text.Editable;
-import android.text.TextWatcher;
-import android.util.AttributeSet;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.InputAttribute;
+import ohos.agp.components.Text;
+import ohos.agp.components.TextField;
+import ohos.app.Context;
-public class BandCardEditText extends android.support.v7.widget.AppCompatEditText {
+public class BandCardEditText extends TextField implements Text.TextObserver {
private boolean shouldStopChange = false;
private final String WHITE_SPACE = " ";
@@ -16,11 +17,11 @@ public class BandCardEditText extends android.support.v7.widget.AppCompatEditTex
this(context, null);
}
- public BandCardEditText(Context context, AttributeSet attrs) {
- this(context, attrs, 0);
+ public BandCardEditText(Context context, AttrSet attrs) {
+ this(context, attrs, "0");
}
- public BandCardEditText(Context context, AttributeSet attrs, int defStyleAttr) {
+ public BandCardEditText(Context context, AttrSet attrs, String defStyleAttr) {
super(context, attrs, defStyleAttr);
init();
}
@@ -28,31 +29,26 @@ public class BandCardEditText extends android.support.v7.widget.AppCompatEditTex
private void init() {
format(getText());
shouldStopChange = false;
- setFocusable(true);
+ setFocusable(1);
setEnabled(true);
- setFocusableInTouchMode(true);
- addTextChangedListener(new CardTextWatcher());
+ setTouchFocusable(true);
+ addTextObserver(this);
+ setTextInputType(InputAttribute.PATTERN_NUMBER);
+// setMaxTextWidth(19);
+// setMaxTextLines(19);
}
- class CardTextWatcher implements TextWatcher {
-
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
-
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
-
- }
-
- @Override
- public void afterTextChanged(Editable editable) {
- format(editable);
+ @Override
+ public void onTextUpdated(String s, int start, int before, int count) {
+ if (s.length() >= 24) {
+ setText(s.substring(0, 23));
+ format(s.substring(0, 23));
+ } else {
+ format(s);
}
}
- private void format(Editable editable) {
+ private void format(String editable) {
if (shouldStopChange) {
shouldStopChange = false;
return;
@@ -60,7 +56,7 @@ public class BandCardEditText extends android.support.v7.widget.AppCompatEditTex
shouldStopChange = true;
- String str = editable.toString().trim().replaceAll(WHITE_SPACE, "");
+ String str = editable.trim().replaceAll(WHITE_SPACE, "");
int len = str.length();
int courPos;
@@ -74,7 +70,9 @@ public class BandCardEditText extends android.support.v7.widget.AppCompatEditTex
}
courPos = builder.length();
setText(builder.toString());
- setSelection(courPos);
+
+ //setSelection(courPos);
+
if (listener != null) {
if (BankCardUtils.checkBankCard(getBankCardText())) {
char[] ss = getBankCardText().toCharArray();
@@ -86,7 +84,7 @@ public class BandCardEditText extends android.support.v7.widget.AppCompatEditTex
}
public String getBankCardText() {
- return getText().toString().trim().replaceAll(WHITE_SPACE, "");
+ return getText().trim().replaceAll(WHITE_SPACE, "");
}
public void setBankCardListener(BankCardListener listener) {
diff --git a/library/src/main/java/com/example/library/BankCardInfo.java b/library/src/main/java/com/example/library/BankCardInfo.java
index 29093ccea7c4314f744f96c99b2c8b833e920bce..8bdeb38ca84a5a00481182dbad6d1d9e8fa5f1f4 100644
--- a/library/src/main/java/com/example/library/BankCardInfo.java
+++ b/library/src/main/java/com/example/library/BankCardInfo.java
@@ -1,7 +1,5 @@
package com.example.library;
-import android.util.Log;
-
public class BankCardInfo {
public final static long[] bankBin =
diff --git a/library/src/main/java/com/example/library/BankCardListener.java b/library/src/main/java/com/example/library/BankCardListener.java
index 50ad6abee48197b9199e1a853455dd52cdd1aacb..dbf755adba86fde384b0c1e5ef2b76160cf999b9 100644
--- a/library/src/main/java/com/example/library/BankCardListener.java
+++ b/library/src/main/java/com/example/library/BankCardListener.java
@@ -1,6 +1,7 @@
package com.example.library;
public interface BankCardListener {
+
void success(String name);
void failure();
diff --git a/library/src/main/java/com/example/library/BankCardUtils.java b/library/src/main/java/com/example/library/BankCardUtils.java
index 958cdf477040f9890550129aebfb84f67c8244a7..9bff04f3a6bd71897b09764eff78610392abdaa1 100644
--- a/library/src/main/java/com/example/library/BankCardUtils.java
+++ b/library/src/main/java/com/example/library/BankCardUtils.java
@@ -1,8 +1,5 @@
package com.example.library;
-import android.text.TextUtils;
-import android.util.Log;
-
import static com.example.library.BankCardInfo.bankBin;
import static com.example.library.BankCardInfo.bankName;
@@ -11,14 +8,12 @@ import static com.example.library.BankCardInfo.bankName;
*/
public class BankCardUtils {
-
public static String getNameOfBank(char[] charBin, int offset) {
long longBin = 0;
for (int i = 0; i < 6; i++) {
longBin = (longBin * 10) + (charBin[i + offset] - 48);
}
- Log.i("BankCardInfo", "bankBin: " + longBin);
int index = binarySearch(bankBin, longBin);
@@ -50,7 +45,8 @@ public class BankCardUtils {
* 校验银行卡卡号
*/
public static boolean checkBankCard(String cardId) {
- if (TextUtils.isEmpty(cardId)) return false;
+ if (cardId.isEmpty())
+ return false;
char bit = getBankCardCheckCode(cardId.substring(0, cardId.length() - 1));
return bit != 'N' && cardId.charAt(cardId.length() - 1) == bit;
@@ -60,7 +56,7 @@ public class BankCardUtils {
* 从不含校验位的银行卡卡号采用 Luhm 校验算法获得校验位
*/
public static char getBankCardCheckCode(String nonCheckCodeCardId) {
- if (TextUtils.isEmpty(nonCheckCodeCardId)
+ if (nonCheckCodeCardId.isEmpty()
|| !nonCheckCodeCardId.matches("\\d+")
|| nonCheckCodeCardId.length() < 16
|| nonCheckCodeCardId.length() > 19) {
@@ -79,5 +75,4 @@ public class BankCardUtils {
}
return (luhmSum % 10 == 0) ? '0' : (char) ((10 - luhmSum % 10) + '0');
}
-
-}
+}
\ No newline at end of file
diff --git a/library/src/main/res/values/strings.xml b/library/src/main/res/values/strings.xml
deleted file mode 100644
index 49fc91e1dd831bf7eb837809f992376b78077d4d..0000000000000000000000000000000000000000
--- a/library/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,3 +0,0 @@
-
- library
-
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/library/src/test/java/com/example/library/ExampleTest.java b/library/src/test/java/com/example/library/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..865af7d0c936e5e195851c9c7a19c8e4153c7fd8
--- /dev/null
+++ b/library/src/test/java/com/example/library/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.example.library;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/screenshot/device-1.png b/screenshot/device-1.png
deleted file mode 100644
index c6a16ab61f72de3c9989d8d74e7a0799e35f0002..0000000000000000000000000000000000000000
Binary files a/screenshot/device-1.png and /dev/null differ
diff --git a/screenshot/device.png b/screenshot/device.png
deleted file mode 100644
index 05bd0bc24555b8ee18b2f80c3e987de344666bc8..0000000000000000000000000000000000000000
Binary files a/screenshot/device.png and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index 33069973b21ca48fd9db7889bf3865384837327a..d0c7ee8440156d4a9324ac5357770747425fef57 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':library'
+include ':entry', ':library'