diff --git a/.github/issue_template.md b/.github/issue_template.md deleted file mode 100644 index 7bb689473f5fb244e6c389963fada721aad82407..0000000000000000000000000000000000000000 --- a/.github/issue_template.md +++ /dev/null @@ -1,20 +0,0 @@ -What kind of issue is this? - - - [ ] Question. If you want to ask how to do something, or to understand why something isn't - working the way you expect it to. - - - [ ] Bug report. Please provide your device name, device OS version, and describe the reproduction steps. - - - [ ] Feature Request. Telling us what problem you’re trying to solve. - -##### Info: - - * PinView version: - * Device OS version: - * Device Name: - -##### Description: - -##### Reproduction Steps: - -##### What did I do: \ No newline at end of file diff --git a/LICENSE b/LICENSE deleted file mode 100644 index 8dada3edaf50dbc082c9a125058f25def75e625a..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 {yyyy} {name of copyright owner} - - 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 ecead4747650147c35946aa29f68e38ec28805d1..8a23dfbedd5d49fc2f369496786620cbadf8c18e 100644 --- a/README.md +++ b/README.md @@ -1,183 +1,120 @@ # PinView +本项目是基于开源项目PinView进行openharmony的移植和开发的,可以通过项目地址()追踪到原项目版本 -Provides a widget for enter PIN/OTP/password etc on Android 4.1+ (API 16). +## 项目介绍 +项目名称:PinView输入框的各种事件的改变 -

-

+所属系列:openharmony的第三方组件适配移植 -## Dependency +功能:输入框的背景颜色的动态变化,基线的显示与隐藏,明文密文的切换 -### ~~JCenter~~([Deprecated](https://jfrog.com/blog/into-the-sunset-bintray-jcenter-gocenter-and-chartcenter/)) +基线版本:PinView组件 Release版本号 v1.4.3 -``` Groovy -repositories { - maven { - jcenter() - } -} +项目移植状态:无差异 -dependencies { - implementation 'com.chaos.view:pinview:1.4.4' -} -``` +调用差异:无 -### MavenCentral +开发版本:sdk5,DevEco Studio2.1 beta4 -``` Groovy -repositories { - maven { - mavenCentral() - } -} +原项目Doc地址: -dependencies { - implementation 'io.github.chaosleung:pinview:1.4.4' -} -``` - -> Note that `MavenCentral` uses `io.github.chaosleung` as the group id - -## Usage +编程语言:Java -PinView inherits from EditText, which means you can use all the APIs from EditText. +外部库依赖:PinView项目中的pinView库 -### Step 1: -Add PinView in your layout. +## 效果展示 -#### XML + -``` xml - +## 安装教程 +1、在项目根目录下的build.gradle文件中 + ```gradle +allprojects { + repositories { + maven { + url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + } + } +} ``` - -#### Java - -``` Java -final PinView pinView = findViewById(R.id.secondPinView); -pinView.setTextColor( - ResourcesCompat.getColor(getResources(), R.color.colorAccent, getTheme())); -pinView.setTextColor( - ResourcesCompat.getColorStateList(getResources(), R.color.text_colors, getTheme())); -pinView.setLineColor( - ResourcesCompat.getColor(getResources(), R.color.colorPrimary, getTheme())); -pinView.setLineColor( - ResourcesCompat.getColorStateList(getResources(), R.color.line_colors, getTheme())); -pinView.setItemCount(4); -pinView.setItemHeight(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size)); -pinView.setItemWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_size)); -pinView.setItemRadius(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_radius)); -pinView.setItemSpacing(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_spacing)); -pinView.setLineWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_item_line_width)); -pinView.setAnimationEnable(true);// start animation when adding text -pinView.setCursorVisible(false); -pinView.setCursorColor( - ResourcesCompat.getColor(getResources(), R.color.line_selected, getTheme())); -pinView.setCursorWidth(getResources().getDimensionPixelSize(R.dimen.pv_pin_view_cursor_width)); -pinView.addTextChangedListener(new TextWatcher() {...}); -pinView.setItemBackgroundColor(Color.BLACK); -pinView.setItemBackground(getResources().getDrawable(R.drawable.item_background)); -pinView.setItemBackgroundResources(R.drawable.item_background); -pinView.setHideLineWhenFilled(false); -pinView.setPasswordHidden(false); -pinView.setTransformationMethod(new PasswordTransformationMethod()); +2.在entry模块的build.gradle文件中 + ```gradle + dependencies { + implementation('com.gitee.chinasoft_ohos:PinView:0.0.1-SNAPSHOT') + ...... + } ``` -### Step 2: - -Specifies `pinViewStyle` in your theme, - -``` xml - -``` +在sdk5,DevEco Studio2.1 beta4下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 -or use the `PinWidget.PinView` style. -``` xml - -``` +## 使用说明 -### Step 3 (Optional): +1.在xml中使用自定义的控件PinView -To highlight current item, use 'selected' state, in other words, +2.自定义显示的背景的颜色和选中的颜色 -add `android:state_selected="true"` to `app:lineColor` +3.点击按钮获取焦点 -``` xml - - - - - - +``` + ``` -or add `android:cursorVisible="true"`. - -## Attributes - -* **itemCount**, the length of your pin code. -* **itemWidth**, the width of each item. -* **itemHeight**, the height of each item. -* **itemSpacing**, the spacing between two items. -* **lineWidth**, the line (border) width. -* **lineColor**, the line (border) colors. -* **viewType**, the view type of PinView, currently this will be one of `rectangle`, `line` or `none`. -* **cursorVisible**, show cursor or not. -* **cursorColor**, the cursor color. -* **cursorWidth**, the width of cursor. -* **itemBackground**, the item background. -* **hideLineWhenFilled**, specifies whether the line (border) should be hidden or visible when text entered. - -## Thanks - - * Inspired by [PasswordInput](https://github.com/EthanCo/PasswordInput) in [EthanCo](https://github.com/EthanCo) +## 测试信息 +CodeCheck代码测试无异常 -## License +CloudTest代码测试无异常 +火绒安全病毒安全检测通过 - Copyright 2017-2018 Chaos Leong +当前版本demo功能与原组件基本无差异 - 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 +## 版本迭代 +- 0.0.1-SNAPSHOT - http://www.apache.org/licenses/LICENSE-2.0 +## 版权和许可信息 +Copyright 2017-2018 Chaos Leong - 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. +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + http://www.apache.org/licenses/LICENSE-2.0 +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. \ No newline at end of file diff --git a/build.gradle b/build.gradle index abff695117ca6621eab4ccc87974f5ff4acf346f..bc30f7f6c2a4c9d16641f0397d5249050c7268ca 100644 --- a/build.gradle +++ b/build.gradle @@ -1,27 +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 4 + } +} buildscript { repositories { - google() + maven { + url 'https://mirrors.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } jcenter() - mavenCentral() } dependencies { - classpath 'com.android.tools.build:gradle:4.0.1' - classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5' - // 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' } } allprojects { repositories { - google() + maven { + url 'https://mirrors.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } jcenter() - mavenCentral() } } - -task clean(type: Delete) { - delete rootProject.buildDir -} diff --git a/changeLog.md b/changeLog.md new file mode 100644 index 0000000000000000000000000000000000000000..63dc57e41e7130a4cc2bde0ed41b7c10830b041c --- /dev/null +++ b/changeLog.md @@ -0,0 +1,8 @@ +# 基本功能: +- 输入框的背景颜色的动态变化,基线的显示与隐藏,明文密文的切换 + +# 修改点: +1. EditText 鸿蒙使用TextField替换实现 + +# 遗留问题(暂不支持的功能): +无 \ 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..c75cfa0b1f4fedf5386ea2384e569ae999e4e97a --- /dev/null +++ b/entry/build.gradle @@ -0,0 +1,29 @@ +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' + } + } + } +} +repositories { + maven { + url 'https://s01.oss.sonatype.org/content/repositories/snapshots/' + } +} +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + implementation project(path: ':pinview') + testImplementation 'junit:junit:4.13' +} +decc { + supportType = ['html', 'xml'] +} diff --git a/entry/src/main/config.json b/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..a579c6fa6116280e5b76dbb663bf09390ffa19ee --- /dev/null +++ b/entry/src/main/config.json @@ -0,0 +1,71 @@ +{ + "app": { + "bundleName": "com.chaos.view.example", + "vendor": "chaos", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 5, + "target": 5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.chaos.view.example", + "name": ".MyApplication", + "deviceType": [ + "phone", + "tablet", + "tv" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "orientation": "unspecified", + "name": "com.chaos.view.example.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "$string:app_name", + "type": "page", + "launchType": "standard" + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.MULTIMODAL_INTERACTIVE", + "reason": "多模输入", + "usedScene": { + "ability": [ + "com.chaos.view.MainAbility" + ], + "when": "always" + } + } + ], + "metaData": { + "customizeData": [ + { + "name": "hwc-theme", + "value": "androidhwext:style/Theme.Emui.NoTitleBar", + "extra": "" + } + ] + } + } +} \ No newline at end of file diff --git a/entry/src/main/java/com/chaos/view/example/MainAbility.java b/entry/src/main/java/com/chaos/view/example/MainAbility.java new file mode 100644 index 0000000000000000000000000000000000000000..6dc227b22bf1010e1ca862b6b4d7f75682701b07 --- /dev/null +++ b/entry/src/main/java/com/chaos/view/example/MainAbility.java @@ -0,0 +1,13 @@ +package com.chaos.view.example; + +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/chaos/view/example/MainAbilitySlice.java b/entry/src/main/java/com/chaos/view/example/MainAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..019fee90e4a52aa4b26b6c20424358479c7f3ea1 --- /dev/null +++ b/entry/src/main/java/com/chaos/view/example/MainAbilitySlice.java @@ -0,0 +1,50 @@ +package com.chaos.view.example; + +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.aafwk.content.Operation; +import ohos.agp.components.Button; +import ohos.agp.components.Component; +import ohos.agp.window.service.WindowManager; + +public class MainAbilitySlice extends AbilitySlice { + + @Override + public void onStart(Intent intent) { + super.onStart(intent); + try { + getWindow().setStatusBarColor(getResourceManager().getElement(ResourceTable.Color_status).getColor()); + getWindow().setInputPanelDisplayType(WindowManager.LayoutConfig.INPUT_ADJUST_PAN); + } catch (Exception exception) { + exception.getMessage(); + } + super.setUIContent(ResourceTable.Layout_ability_main); + Button button = (Button) findComponentById(ResourceTable.Id_button); + if (button != null) { + button.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { +// Intent intent = new Intent(); +// Operation operation = new Intent.OperationBuilder() +// .withDeviceId("") +// .withBundleName(getBundleName()) +// .withAbilityName(SecondAbility.class.getName()) +// .build(); +// intent.setOperation(operation); +// startAbility(intent); + present(new SecondAbilitySlice(), new Intent()); + } + }); + } + } + + @Override + public void onActive() { + super.onActive(); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } +} diff --git a/entry/src/main/java/com/chaos/view/example/MyApplication.java b/entry/src/main/java/com/chaos/view/example/MyApplication.java new file mode 100644 index 0000000000000000000000000000000000000000..17149ed219749cffbf19834210ac01809ab2e7f7 --- /dev/null +++ b/entry/src/main/java/com/chaos/view/example/MyApplication.java @@ -0,0 +1,10 @@ +package com.chaos.view.example; + +import ohos.aafwk.ability.AbilityPackage; + +public class MyApplication extends AbilityPackage { + @Override + public void onInitialize() { + super.onInitialize(); + } +} diff --git a/entry/src/main/java/com/chaos/view/example/SecondAbilitySlice.java b/entry/src/main/java/com/chaos/view/example/SecondAbilitySlice.java new file mode 100644 index 0000000000000000000000000000000000000000..7f6df217f71019430a1b007117f1de203aa54793 --- /dev/null +++ b/entry/src/main/java/com/chaos/view/example/SecondAbilitySlice.java @@ -0,0 +1,110 @@ +package com.chaos.view.example; + +import com.chaos.view.LogUtil; +import com.chaos.view.PinView; +import ohos.aafwk.ability.AbilitySlice; +import ohos.aafwk.content.Intent; +import ohos.agp.components.Checkbox; +import ohos.agp.components.ComponentState; +import ohos.agp.components.element.PixelMapElement; +import ohos.agp.components.element.StateElement; +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; + +public class SecondAbilitySlice extends AbilitySlice { + @Override + public void onStart(Intent intent) { + super.onStart(intent); + super.setUIContent(ResourceTable.Layout_ability_second); + } + + @Override + public void onActive() { + super.onActive(); + Checkbox checkPin = (Checkbox) findComponentById(ResourceTable.Id_check_pin); + Checkbox checkPassWord = (Checkbox) findComponentById(ResourceTable.Id_check_pass_word); + checkBoxAddStatus(ResourceTable.Media_check_yes, ResourceTable.Media_check_no, this, checkPin); + checkBoxAddStatus(ResourceTable.Media_check_yes, ResourceTable.Media_check_no, this, checkPassWord); + PinView pinview6 = (PinView) findComponentById(ResourceTable.Id_pinView6); + PinView pinview7 = (PinView) findComponentById(ResourceTable.Id_pinView7); + checkPin.setCheckedStateChangedListener((absButton, b) -> { + if (b) { + pinview6.setContentShowMode(1); + } else { + pinview6.setContentShowMode(2); + } + }); + checkPassWord.setCheckedStateChangedListener((absButton, b) -> { + if (b) { + pinview7.setContentShowMode(1); + } else { + pinview7.setContentShowMode(2); + } + }); + pinview7.setContentShowMode(1); + } + + @Override + public void onForeground(Intent intent) { + super.onForeground(intent); + } + + /** + * 通过资源ID获取位图对象 + * + * @param drawableId drawableId + * @param context context + * @return PixelMap + **/ + private static PixelMap getPixelMap(int drawableId, Context context) { + InputStream drawableInputStream = null; + try { + drawableInputStream = context.getResourceManager().getResource(drawableId); + ImageSource.SourceOptions sourceOptions = new ImageSource.SourceOptions(); + 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; + + return imageSource.createPixelmap(decodingOptions); + } catch (IOException | NotExistException e) { + LogUtil.d(e.getMessage()); + } finally { + try { + if (drawableInputStream != null) { + drawableInputStream.close(); + } + } catch (IOException e) { + LogUtil.d(e.getMessage()); + } + } + return null; + } + + /** + * checkBox的状态 + * + * @param drawableCheckedId drawableCheckedId + * @param drawableEmptyId drawableEmptyId + * @param context context + * @param checkbox checkbox + */ + private static void checkBoxAddStatus(int drawableCheckedId, int drawableEmptyId, + Context context, Checkbox checkbox) { + StateElement stateElement = new StateElement(); + stateElement.addState(new int[]{ComponentState.COMPONENT_STATE_CHECKED}, + new PixelMapElement(getPixelMap(drawableCheckedId, context))); + stateElement.addState(new int[]{ComponentState.COMPONENT_STATE_EMPTY}, + new PixelMapElement(getPixelMap(drawableEmptyId, context))); + checkbox.setButtonElement(stateElement); + } +} diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..70436dd2ebad72795acf2bd679cec33907706c8d --- /dev/null +++ b/entry/src/main/resources/base/element/color.json @@ -0,0 +1,60 @@ +{ + "color": [ + { + "name": "wihte", + "value": "#FFFFFF" + }, + { + "name": "black", + "value": "#ff000000" + }, + { + "name": "colorAccent", + "value": "#FF4081" + }, + { + "name": "colorPrimary", + "value": "#3F51B5" + }, + { + "name": "transparent", + "value": "#00000000" + }, + { + "name": "colorPrimaryDark", + "value": "#C5CAE9" + }, + { + "name": "text_hint_default", + "value": "#BDBDBD" + }, + { + "name": "gray", + "value": "#FF7A7979" + }, + { + "name": "shape", + "value": "#FFFFFFFF" + }, + { + "name": "title_bg", + "value": "#D51611C9" + }, + { + "name": "status", + "value": "#B71611C9" + }, + { + "name": "text_selected", + "value": "#b0003a" + }, + { + "name": "text_focused", + "value": "#E91E63" + }, + { + "name": "text_default", + "value": "#F8BBD0" + } + ] +} \ No newline at end of file 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..feb8d3e28fd1ee29f28bd5f9cbe0fda119f79672 --- /dev/null +++ b/entry/src/main/resources/base/element/string.json @@ -0,0 +1,36 @@ +{ + "string": [ + { + "name": "app_name", + "value": "PinView" + }, + { + "name": "mainability_description", + "value": "Java_Phone_Empty Feature Ability" + }, + { + "name": "HelloWorld", + "value": "Hello World" + }, + { + "name": "verification_code_subtext", + "value": "Please type the verification code sent to +xxxxxxxxxx" + }, + { + "name": "Verification_code", + "value": "Verification Code" + }, + { + "name": "validate_button", + "value": "Validate" + }, + { + "name": "secondabilityslice_description", + "value": "Java_Phone_Empty Feature Ability" + }, + { + "name": "secondabilityslice_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/graphic/background_ability_second.xml b/entry/src/main/resources/base/graphic/background_ability_second.xml new file mode 100644 index 0000000000000000000000000000000000000000..a002c2353e78af3a15235e00738328ff566bc085 --- /dev/null +++ b/entry/src/main/resources/base/graphic/background_ability_second.xml @@ -0,0 +1,8 @@ + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/graphic/background_button.xml b/entry/src/main/resources/base/graphic/background_button.xml new file mode 100644 index 0000000000000000000000000000000000000000..abe9214ffcedb4e9686638b41636c1d31940e7e4 --- /dev/null +++ b/entry/src/main/resources/base/graphic/background_button.xml @@ -0,0 +1,8 @@ + + + + + \ 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..dd0d9d9d875b887a9a711fa4c257905033746190 --- /dev/null +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -0,0 +1,190 @@ + + + + + +