diff --git a/CHANGELOG.md b/CHANGELOG.md index c5180bfb2f93a97eb996b7865251233dedab1e41..5a2fb272778f7055ab1513e149896746566fd2ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +## 0.0.2-SNAPSHOT +* 修改FindBugs + ## 0.0.1-SNAPSHOT ohos第一个版本 * 实现了原库的大部分api diff --git a/README.md b/README.md index ee81af35fa6f5f59b1795167beba5a5df5e16a01..597a74f821f41160bbe229b43b4d7fc05bbd3550 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ - 项目移植状态:TextField光标设置图片背景未实现 - 调用差异:无 - 基线版本:Release v1.4 -- 开发版本:sdk5,DevEco Studio 2.1 Release +- 开发版本:sdk6,DevEco Studio 2.2 Beta1 #### 效果演示 @@ -30,11 +30,11 @@ allprojects { 2.在entry模块的build.gradle文件中 ```gradle dependencies { - implementation('com.gitee.chinasoft_ohos:Pinview:0.0.1-SNAPSHOT') + implementation('com.gitee.chinasoft_ohos:Pinview:0.0.2-SNAPSHOT') ...... } ``` -在sdk5,DevEco Studio 2.1 Release下项目可直接运行 +在sdk6,DevEco Studio 2.2 Beta1 下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件, 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 @@ -90,7 +90,7 @@ CloudTest代码测试无异常 - 0.0.1-SNAPSHOT #### 版权和许可信息 -- ``` + ``` MIT License Copyright (c) 2017 GoodieBag diff --git a/build.gradle b/build.gradle index 5e5cfbed4ac000bc067561a8e01b5b4e7f91de4f..f0c73f75841a46b558f59b3d99e82c8f916c5dd3 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.huawei.ohos.app' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { compatibleSdkVersion 5 } @@ -19,8 +19,8 @@ buildscript { jcenter() } dependencies { - classpath 'com.huawei.ohos:hap:2.4.4.2' - classpath 'com.huawei.ohos:decctest:1.0.0.6' + classpath 'com.huawei.ohos:hap:2.4.5.0' + classpath 'com.huawei.ohos:decctest:1.2.4.1' } } diff --git a/example/build.gradle b/example/build.gradle index 642c86dd6b5fb1e4317202e0340f9f5fabce7c40..d6a0bc544ea1c0f5fba217a56f33fe637f96493f 100644 --- a/example/build.gradle +++ b/example/build.gradle @@ -1,7 +1,7 @@ apply plugin: 'com.huawei.ohos.hap' apply plugin: 'com.huawei.ohos.decctest' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { compatibleSdkVersion 5 } diff --git a/example/src/main/config.json b/example/src/main/config.json index 672e31ef70d7d74a33f5da4e8e6b21ae60e744ff..b5f3b6a526675935e0c4314b002b15141adc3473 100644 --- a/example/src/main/config.json +++ b/example/src/main/config.json @@ -5,11 +5,6 @@ "version": { "code": 1000000, "name": "1.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Release" } }, "deviceConfig": {}, @@ -22,7 +17,8 @@ "distro": { "deliveryWithInstall": true, "moduleName": "example", - "moduleType": "entry" + "moduleType": "entry", + "installationFree":false }, "abilities": [ { diff --git a/pinview/build.gradle b/pinview/build.gradle index 76741aef809a5b900f4c25a8644fd155b411554b..b9b04bcee7338e28479bc4820d2ad8d451a41010 100644 --- a/pinview/build.gradle +++ b/pinview/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.huawei.ohos.library' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { compatibleSdkVersion 5 } diff --git a/pinview/src/main/config.json b/pinview/src/main/config.json index c843cf48d5667463b0e175b2f6e4431563c3454b..c4e7e0bab885dc33b7166f97e862d198f68f8b45 100644 --- a/pinview/src/main/config.json +++ b/pinview/src/main/config.json @@ -5,11 +5,6 @@ "version": { "code": 1000000, "name": "1.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Release" } }, "deviceConfig": {}, diff --git a/pinview/src/main/java/com/goodiebag/pinview/MyValue.java b/pinview/src/main/java/com/goodiebag/pinview/MyValue.java index 2a522b343d24da6ec46d3ef19bf3e7b3f82555d2..ed2f94529774b585956ab59f53c2f81eba96fd6a 100644 --- a/pinview/src/main/java/com/goodiebag/pinview/MyValue.java +++ b/pinview/src/main/java/com/goodiebag/pinview/MyValue.java @@ -24,21 +24,87 @@ public class MyValue { /** * 所有子视图 */ - public static List pinviews = new ArrayList<>(); + private static List pinviews = new ArrayList<>(); /** * 所有输入框 */ - public static List fields = new ArrayList<>(); + private static List fields = new ArrayList<>(); /** * 位置 */ - public static int size = 0; + private static int size = 0; /** * 行数 */ - public static int page = 0; + private static int page = 0; /** * 存储临时输入框 */ - public static TextField temp = null; + private static TextField temp = null; + + /*** + * getPinviews + * + * @return List + */ + public static List getPinviews() { + return pinviews; + } + + /*** + * getFields + * + * @return List + */ + public static List getFields() { + return fields; + } + + /*** + * getSize + * + * @return int + */ + public static int getSize() { + return size; + } + + /*** + * setSize + */ + public static void setSize(int size) { + MyValue.size = size; + } + + /*** + * getPage + * + * @return int + */ + public static int getPage() { + return page; + } + + /*** + * setPage + */ + public static void setPage(int page) { + MyValue.page = page; + } + + /*** + * getTemp + * + * @return TextField + */ + public static TextField getTemp() { + return temp; + } + + /*** + * setTemp + */ + public static void setTemp(TextField temp) { + MyValue.temp = temp; + } } diff --git a/pinview/src/main/java/com/goodiebag/pinview/Pinview.java b/pinview/src/main/java/com/goodiebag/pinview/Pinview.java index c30ec2e496e7355fb6dbcff38142f8ad7ae4b53e..e5a99ebb8a5ccd1cb500240c7a1f38c4c49a534d 100644 --- a/pinview/src/main/java/com/goodiebag/pinview/Pinview.java +++ b/pinview/src/main/java/com/goodiebag/pinview/Pinview.java @@ -70,6 +70,7 @@ public class Pinview extends DirectionalLayout implements private int count = 0; private int number = 0; private boolean isDeleteOk = false; + private int size; /** * 构造 @@ -107,46 +108,48 @@ public class Pinview extends DirectionalLayout implements @Override public void onClick(Component component) { - if (MyValue.temp != null && MyValue.temp != component) { - if (MyValue.page == 4) { - selectFlag(MyValue.temp, 3); + if (MyValue.getTemp() != null && MyValue.getTemp() != component) { + if (MyValue.getPage() == 4) { + selectFlag(MyValue.getTemp(), 3); } else { - selectFlag(MyValue.temp, 2); + selectFlag(MyValue.getTemp(), 2); } - MyValue.temp.clearFocus(); + MyValue.getTemp().clearFocus(); } - MyValue.pinviews.clear(); - MyValue.fields.clear(); + MyValue.getPinviews().clear(); + MyValue.getFields().clear(); for (int index = 0; index < ((DirectionalLayout) getComponentParent()).getChildCount(); index++) { if (((DirectionalLayout) getComponentParent()).getComponentAt(index) instanceof Pinview) { - MyValue.pinviews.add((Pinview) ((DirectionalLayout) getComponentParent()).getComponentAt(index)); + MyValue.getPinviews().add((Pinview) ((DirectionalLayout) getComponentParent()).getComponentAt(index)); } } - for (int pinIndex = 0; pinIndex < MyValue.pinviews.size(); pinIndex++) { - Pinview pinView = MyValue.pinviews.get(pinIndex); + for (int pinIndex = 0; pinIndex < MyValue.getPinviews().size(); pinIndex++) { + Pinview pinView = MyValue.getPinviews().get(pinIndex); for (int index = 0; index < pinView.getChildCount(); index++) { - MyValue.fields.add((TextField) pinView.getComponentAt(index)); + MyValue.getFields().add((TextField) pinView.getComponentAt(index)); } } - if (MyValue.fields.size() > 0) { - for (TextField field : MyValue.fields) { - MyValue.size++; + if (MyValue.getFields().size() > 0) { + for (TextField field : MyValue.getFields()) { + size = MyValue.getSize(); + size++; + MyValue.setSize(size); if (field == component) { break; } } } - if (MyValue.size >= 0 && MyValue.size <= mPinLength - 1) { - MyValue.page = 0; - } else if (MyValue.size > mPinLength - 1 && MyValue.size <= mPinLength * 2 - 1) { - MyValue.page = 1; - } else if (MyValue.size > mPinLength * 2 - 1 && MyValue.size <= mPinLength * 3 - 1) { - MyValue.page = 2; - } else if (MyValue.size > mPinLength * 2 - 1 && MyValue.size <= mPinLength * 4 - 1) { - MyValue.page = 3; + if (MyValue.getSize() >= 0 && MyValue.getSize() <= mPinLength - 1) { + MyValue.setPage(0); + } else if (MyValue.getSize() > mPinLength - 1 && MyValue.getSize() <= mPinLength * 2 - 1) { + MyValue.setPage(1); + } else if (MyValue.getSize() > mPinLength * 2 - 1 && MyValue.getSize() <= mPinLength * 3 - 1) { + MyValue.setPage(2); + } else if (MyValue.getSize() > mPinLength * 3 - 1 && MyValue.getSize() <= mPinLength * 4 - 1) { + MyValue.setPage(3); } - MyValue.size = 0; + MyValue.setSize(0); if (!isCursorVisible) { for (int i = 0; i < Integer.parseInt(component.getTag().toString()); i++) { TextField textField = textFields.get(i); @@ -521,27 +524,27 @@ public class Pinview extends DirectionalLayout implements } } } - return false; + return true; } else if (keyEvent.isKeyDown() && keyEvent.getKeyCode() == KeyEvent.KEY_ENTER) { - if (MyValue.page == 0) { + if (MyValue.getPage() == 0) { enter(1); - MyValue.page = 1; - } else if (MyValue.page == 1) { + MyValue.setPage(1); + } else if (MyValue.getPage() == 1) { enter(2); - MyValue.page = 2; - } else if (MyValue.page == 2) { + MyValue.setPage(2); + } else if (MyValue.getPage() == 2) { enter(3); - MyValue.page = 3; - } else if (MyValue.page == 3) { + MyValue.setPage(3); + } else if (MyValue.getPage() == 3) { enter(4); - MyValue.page = 4; + MyValue.setPage(4); } } - return false; + return true; } private void enter(int page) { - Pinview pinview = MyValue.pinviews.get(page); + Pinview pinview = MyValue.getPinviews().get(page); int childCount = pinview.getChildCount(); for (int index = 0; index < childCount; index++) { TextField field = (TextField) pinview.getComponentAt(index); @@ -561,7 +564,7 @@ public class Pinview extends DirectionalLayout implements selectFlag(textField, 0); } } - MyValue.temp = field; + MyValue.setTemp(field); field.setFocusable(FOCUS_ENABLE); field.setEnabled(true); field.requestFocus();