From 5ef5596a728477b699fddb59bfcec0a3871a449f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=85=B5=E5=85=B5?= Date: Mon, 5 Jul 2021 19:17:34 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88=E9=80=82=E9=85=8D=E7=89=88=E6=9C=AC=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 8 ++++---- build.gradle | 6 +++--- exampleapp/build.gradle | 6 +++--- exampleapp/src/main/config.json | 5 ----- tracker/build.gradle | 2 +- tracker/src/main/config.json | 5 ----- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 14e2390..ab62dc3 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,13 @@ 功能:可以解析每个按钮的点击事件所上报的数据 -基线版本: Release v4.1.2 +基线版本:Release v4.1.2 项目移植状态:有差异 调用差异:无 -开发版本:sdk5,DevEco Studio 2.1 Release +开发版本:sdk6,DevEco Studio 2.2 Beta1 外部库依赖:matomo-sdk-ohos项目中的tracker库 @@ -41,7 +41,7 @@ allprojects { } ``` -在sdk5,DevEco Studio 2.1 Release下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 +在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行 如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件 并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下 ## 使用说明 @@ -70,7 +70,7 @@ CodeCheck代码测试无异常 CloudTest代码测试无异常 -火绒安全病毒安全检测通过 +病毒安全检测通过 当前版本demo功能与原组件基本无差异 diff --git a/build.gradle b/build.gradle index 7422686..8726113 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/exampleapp/build.gradle b/exampleapp/build.gradle index e83affd..f6c14e9 100644 --- a/exampleapp/build.gradle +++ b/exampleapp/build.gradle @@ -1,15 +1,15 @@ apply plugin: 'com.huawei.ohos.hap' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { compatibleSdkVersion 5 } - + } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) - testCompile'junit:junit:4.12' + testCompile 'junit:junit:4.12' ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.100' implementation project(':tracker') } diff --git a/exampleapp/src/main/config.json b/exampleapp/src/main/config.json index 4ea68ed..43c25ef 100644 --- a/exampleapp/src/main/config.json +++ b/exampleapp/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/tracker/build.gradle b/tracker/build.gradle index 72b9947..befb002 100644 --- a/tracker/build.gradle +++ b/tracker/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.huawei.ohos.library' ohos { - compileSdkVersion 5 + compileSdkVersion 6 defaultConfig { compatibleSdkVersion 5 } diff --git a/tracker/src/main/config.json b/tracker/src/main/config.json index 0c36584..42569ea 100644 --- a/tracker/src/main/config.json +++ b/tracker/src/main/config.json @@ -5,11 +5,6 @@ "version": { "code": 1000000, "name": "1.0" - }, - "apiVersion": { - "compatible": 5, - "target": 5, - "releaseType": "Release" } }, "deviceConfig": {}, -- Gitee From 3d485921146044ad40e2a828347720da9ea3344e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9C=E5=85=B5=E5=85=B5?= Date: Tue, 6 Jul 2021 19:55:03 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88=E9=80=82=E9=85=8D=E7=89=88=E6=9C=ACFindbugs=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/org/matomo/demo/button/RText.java | 8 +- .../org/matomo/demo/chechbox/AttrUtils.java | 8 +- .../org/matomo/demo/chechbox/ClipHelper.java | 4 +- .../matomo/demo/chechbox/ClipPathManager.java | 4 +- .../matomo/demo/chechbox/DensityUtils.java | 4 +- .../matomo/demo/chechbox/DrawableUtils.java | 12 +- .../com/org/matomo/demo/chechbox/IClip.java | 4 +- .../demo/chechbox/ITextViewFeature.java | 4 +- .../org/matomo/demo/chechbox/RBaseHelper.java | 142 ++---------------- .../org/matomo/demo/chechbox/RCheckBox.java | 2 +- .../matomo/demo/chechbox/RCheckHelper.java | 8 +- .../com/org/matomo/demo/chechbox/RHelper.java | 4 +- .../org/matomo/demo/chechbox/RTextHelper.java | 28 +--- .../matomo/demo/chechbox/ShadowDrawable.java | 15 +- .../org/matomo/demo/chechbox/TextUtils.java | 6 +- .../matomo/demo/chechbox/TypedAttrUtils.java | 4 +- .../com/org/matomo/demo/util/StrUtil.java | 4 +- .../src/main/java/org/matomo/sdk/Logger.java | 4 +- .../src/main/java/org/matomo/sdk/Matomo.java | 2 +- .../java/org/matomo/sdk/PackageManager.java | 1 + .../org/matomo/sdk/PackageManagerImpl.java | 1 + .../sdk/dispatcher/DefaultDispatcher.java | 2 +- .../sdk/dispatcher/DefaultPacketSender.java | 4 +- .../matomo/sdk/extra/MatomoApplication.java | 2 +- 24 files changed, 71 insertions(+), 206 deletions(-) diff --git a/exampleapp/src/main/java/com/org/matomo/demo/button/RText.java b/exampleapp/src/main/java/com/org/matomo/demo/button/RText.java index 32b8fe5..eef12c3 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/button/RText.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/button/RText.java @@ -1,12 +1,12 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * + * 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. diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/AttrUtils.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/AttrUtils.java index 1c45ea2..fd3e834 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/AttrUtils.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/AttrUtils.java @@ -1,12 +1,12 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - *

- * http://www.apache.org/licenses/LICENSE-2.0 - *

+ * + * 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. diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipHelper.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipHelper.java index 8bc8569..4a13706 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipHelper.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipHelper.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipPathManager.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipPathManager.java index 41d78ea..1f64c31 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipPathManager.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ClipPathManager.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DensityUtils.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DensityUtils.java index f65314e..cb58833 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DensityUtils.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DensityUtils.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DrawableUtils.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DrawableUtils.java index 393ce2e..f2f0209 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DrawableUtils.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/DrawableUtils.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -54,15 +54,15 @@ public final class DrawableUtils { * @return lighter version of the specified color. */ static int lighter(int color, float factor) { - int red = (int) ((Integer.parseInt(red(color), 16) * (1 - factor) / 255 + factor) * 255); - int green = (int) ((Integer.parseInt(green(color), 16) / 255 + factor) * 255); - int blue = (int) ((Integer.parseInt(blue(color), 16) * (1 - factor) / 255 + factor) * 255); + int red = (int) ((Integer.parseInt(red(color), (int) 16d) * (1d - factor) / 255d + factor) * 255d); + int green = (int) ((Integer.parseInt(green(color), (int) 16d) / 255d + factor) * 255d); + int blue = (int) ((Integer.parseInt(blue(color), (int) 16d) * (1d - factor) / 255d + factor) * 255d); return Color.argb(Color.alpha(color), red, green, blue); } static String red(int color) { String toHexString = Integer.toHexString((color >> 16) & 0xFF); - if (toHexString.length() == 1) { + if (toHexString.length() == 1d) { toHexString = "0" + toHexString; } return toHexString; diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/IClip.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/IClip.java index f07945d..5a5b939 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/IClip.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/IClip.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ITextViewFeature.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ITextViewFeature.java index 9e19884..5adc822 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ITextViewFeature.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ITextViewFeature.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RBaseHelper.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RBaseHelper.java index 841782a..9eb083a 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RBaseHelper.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RBaseHelper.java @@ -1,12 +1,12 @@ package com.org.matomo.demo.chechbox; -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -145,8 +145,7 @@ public class RBaseHelper implements IClip, Component.Layout private float mGradientRadius; private float mGradientCenterX, mGradientCenterY; private ShapeElement.Orientation mGradientOrientation = ShapeElement.Orientation.BOTTOM_TO_TOP; - //shadow - private ShadowDrawable mShadowDrawable; + private int mShadowDx; private int mShadowDy; private Color mShadowColor; @@ -159,10 +158,8 @@ public class RBaseHelper implements IClip, Component.Layout private boolean isUseRipple; private Color mRippleColor; private Element mRippleMaskDrawable; - //Ripple波纹限制样式{null, normal=控件矩形, drawable=自定义drawable} - private int mRippleMaskStyle; //null normal drawable - private final int MASK_STYLE_NULL = 1; + private static final int MASK_STYLE_NULL = 1; private Element mViewBackground;//控件默认背景Drawable @@ -203,7 +200,7 @@ public class RBaseHelper implements IClip, Component.Layout //clipLayout private boolean isClipLayout = false; - private int sy; + private float sy; private float sx; AnimatorValue animatorValue = new AnimatorValue(); private float zj; @@ -305,8 +302,6 @@ public class RBaseHelper implements IClip, Component.Layout isUseRipple = getBool(attrs, "ripple", "false"); mRippleColor = getStringColor(attrs, "ripple_color", null); mRippleMaskDrawable = AttrUtils.getElement(attrs, "ripple_mask", null); - int MASK_STYLE_NORMAL = 2; - mRippleMaskStyle = AttrUtils.getInt(attrs, "ripple_mask_style", MASK_STYLE_NORMAL); } catch (Exception e) { e.printStackTrace(); } @@ -577,28 +572,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public RBaseHelper setStateBackgroundColorArray(Color[] normalArray, Color[] pressedArray, Color[] unableArray, Color[] checkedArray, Color[] selectedArray) { - mBackgroundColorNormalArray = normalArray; - mBackgroundColorPressedArray = pressedArray; - mBackgroundColorUnableArray = unableArray; - mBackgroundColorCheckedArray = checkedArray; - mBackgroundColorSelectedArray = selectedArray; - isHasPressedBgColor = true; - isHasUnableBgColor = true; - isHasCheckedBgColor = true; - isHasSelectedBgColor = true; - mBackgroundNormal = setColors(mBackgroundNormal, ColorArrayToIntArray(mBackgroundColorNormalArray)); - mBackgroundPressed = setColors(mBackgroundPressed, ColorArrayToIntArray(mBackgroundColorPressedArray)); - mBackgroundUnable = setColors(mBackgroundUnable, ColorArrayToIntArray(mBackgroundColorUnableArray)); - mBackgroundChecked = setColors(mBackgroundChecked, ColorArrayToIntArray(mBackgroundColorCheckedArray)); - mBackgroundSelected = setColors(mBackgroundSelected, ColorArrayToIntArray(mBackgroundColorSelectedArray)); - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - public RBaseHelper setStateBackgroundColor(Element normal, Element pressed, Element unable, Element checked, Element selected) { mBackgroundNormalBmp = normal; mBackgroundPressedBmp = pressed; @@ -634,23 +607,23 @@ public class RBaseHelper implements IClip, Component.Layout return mBackgroundColorSelected; } - public Color[] getBackgroundColorNormalArray() { + protected Color[] getBackgroundColorNormalArray() { return mBackgroundColorNormalArray; } - public Color[] getBackgroundColorPressedArray() { + protected Color[] getBackgroundColorPressedArray() { return mBackgroundColorPressedArray; } - public Color[] getBackgroundColorUnableArray() { + protected Color[] getBackgroundColorUnableArray() { return mBackgroundColorUnableArray; } - public Color[] getBackgroundColorCheckedArray() { + protected Color[] getBackgroundColorCheckedArray() { return mBackgroundColorCheckedArray; } - public Color[] getBackgroundColorSelectedArray() { + protected Color[] getBackgroundColorSelectedArray() { return mBackgroundColorSelectedArray; } @@ -697,33 +670,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public RBaseHelper setBackgroundColorNormalArray(Color[] colorNormalArray) { - this.mBackgroundColorNormalArray = colorNormalArray; - if (!isHasPressedBgColor) { - mBackgroundColorPressedArray = isHasCheckedBgColor ? mBackgroundColorCheckedArray : mBackgroundColorNormalArray; - mBackgroundPressed = setColors(mBackgroundPressed, ColorArrayToIntArray(mBackgroundColorPressedArray)); - } - if (!isHasUnableBgColor) { - mBackgroundColorUnableArray = mBackgroundColorNormalArray; - mBackgroundUnable = setColors(mBackgroundUnable, ColorArrayToIntArray(mBackgroundColorUnableArray)); - } - if (!isHasCheckedBgColor) { - mBackgroundColorCheckedArray = mBackgroundColorNormalArray; - mBackgroundChecked = setColors(mBackgroundChecked, ColorArrayToIntArray(mBackgroundColorCheckedArray)); - } - if (!isHasSelectedBgColor) { - mBackgroundColorSelectedArray = mBackgroundColorNormalArray; - mBackgroundSelected = setColors(mBackgroundSelected, ColorArrayToIntArray(mBackgroundColorSelectedArray)); - } - mBackgroundNormal = setColors(mBackgroundNormal, ColorArrayToIntArray(mBackgroundColorNormalArray)); - - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - public RBaseHelper setBackgroundDrawableNormal(Element drawableNormal) { this.mBackgroundNormalBmp = drawableNormal; if (!isHasPressedBgBmp) { @@ -751,25 +697,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public RBaseHelper setBackgroundColorPressedArray(Color[] colorPressedArray) { - this.mBackgroundColorPressedArray = colorPressedArray; - this.isHasPressedBgColor = true; - mBackgroundPressed = setColors(mBackgroundPressed, ColorArrayToIntArray(mBackgroundColorPressedArray)); - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - - public RBaseHelper setBackgroundDrawablePressed(Element drawablePressed) { - this.mBackgroundPressedBmp = drawablePressed; - this.isHasPressedBgBmp = true; - refreshStateListDrawable(); - setBackgroundState(); - return this; - } - public RBaseHelper setBackgroundColorUnable(Color colorUnable) { this.mBackgroundColorUnable = colorUnable; this.isHasUnableBgColor = true; @@ -786,17 +713,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public RBaseHelper setBackgroundColorUnableArray(Color[] colorUnableArray) { - this.mBackgroundColorUnableArray = colorUnableArray; - this.isHasUnableBgColor = true; - mBackgroundUnable = setColors(mBackgroundUnable, ColorArrayToIntArray(mBackgroundColorUnableArray)); - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - public RBaseHelper setBackgroundColorChecked(Color colorChecked) { this.mBackgroundColorChecked = colorChecked; this.isHasCheckedBgColor = true; @@ -817,32 +733,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public RBaseHelper setBackgroundColorCheckedArray(Color[] colorCheckedArray) { - this.mBackgroundColorCheckedArray = colorCheckedArray; - this.isHasCheckedBgColor = true; - mBackgroundChecked = setColors(mBackgroundChecked, ColorArrayToIntArray(mBackgroundColorCheckedArray)); - if (!isHasPressedBgColor) { - mBackgroundColorPressedArray = isHasCheckedBgColor ? mBackgroundColorCheckedArray : mBackgroundColorNormalArray; - mBackgroundPressed = setColors(mBackgroundPressed, ColorArrayToIntArray(mBackgroundColorPressedArray)); - } - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - - public RBaseHelper setBackgroundColorSelectedArray(Color[] colorSelectedArray) { - this.mBackgroundColorSelectedArray = colorSelectedArray; - this.isHasSelectedBgColor = true; - mBackgroundSelected = setColors(mBackgroundSelected, ColorArrayToIntArray(mBackgroundColorSelectedArray)); - setBorder(); - setRadiusUI(); - setGradient(); - setBackgroundState(); - return this; - } - public RBaseHelper setBackgroundDrawableChecked(Element drawableChecked) { this.mBackgroundCheckedBmp = drawableChecked; this.isHasCheckedBgBmp = true; @@ -1013,8 +903,6 @@ public class RBaseHelper implements IClip, Component.Layout public RBaseHelper setRippleMaskDrawable(Element rippleMaskDrawable) { this.mRippleMaskDrawable = rippleMaskDrawable; this.isUseRipple = true; - int MASK_STYLE_DRAWABLE = 3; - this.mRippleMaskStyle = MASK_STYLE_DRAWABLE; setBackgroundState(); return this; } @@ -1288,10 +1176,6 @@ public class RBaseHelper implements IClip, Component.Layout return this; } - public float getCornerRadiusTopLeft() { - return mCornerRadiusTopLeft; - } - public RBaseHelper setCornerRadiusTopRight(float topRight) { this.mCornerRadius = -1; this.mCornerRadiusTopRight = topRight; @@ -1473,7 +1357,7 @@ public class RBaseHelper implements IClip, Component.Layout * @return ShapeElement */ private ShapeElement setColors(ShapeElement drawable, int[] colors) { - if (drawable == null) drawable = new ShapeElement(); + //if (drawable == null) drawable = new ShapeElement(); drawable = new ShapeElement(); drawable.setOrientation(mGradientOrientation); RgbColor[] rgbColors = new RgbColor[colors.length]; @@ -1546,9 +1430,9 @@ public class RBaseHelper implements IClip, Component.Layout float x = pointerPosition.getX(); float y = pointerPosition.getY(); int[] parentLocationOnScreen = mView.getLocationOnScreen(); - int yy = (int) (y - parentLocationOnScreen[1]); + float yy = (y - parentLocationOnScreen[1]); sx = x - parentLocationOnScreen[0]; - sy = yy + 300; + sy = (float) (yy + 300d); animatorValue.start(); } return false; diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckBox.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckBox.java index 3dc82d5..ef14414 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckBox.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckBox.java @@ -5,7 +5,7 @@ package com.org.matomo.demo.chechbox; * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckHelper.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckHelper.java index 0b2fec8..47040cc 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckHelper.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RCheckHelper.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -71,7 +71,7 @@ public class RCheckHelper extends RTextHelper implements Component.TouchEventLis return; } - Element a = TypedAttrUtils.getDrawable(attrs, "RRadioButton", null); + //Element a = TypedAttrUtils.getDrawable(attrs, "RRadioButton", null); //text mTextColorChecked = AttrUtils.getColor(attrs, "text_color_checked", null); @@ -175,7 +175,7 @@ public class RCheckHelper extends RTextHelper implements Component.TouchEventLis @Override protected void setTextColor() { //unable,focused,pressed,checked,selected,normal - Color[] colors = new Color[]{mTextColorUnable, mTextColorPressed, mTextColorPressed, mTextColorChecked, mTextColorSelected, mTextColorNormal}; + //Color[] colors = new Color[]{mTextColorUnable, mTextColorPressed, mTextColorPressed, mTextColorChecked, mTextColorSelected, mTextColorNormal}; // mTextColorStateList = new ColorStateList(states, colors); mView.setTextColor(mTextColorNormal); } diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RHelper.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RHelper.java index 32e101e..4b2e58e 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RHelper.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RHelper.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RTextHelper.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RTextHelper.java index 43189d9..7ec5d5b 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RTextHelper.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/RTextHelper.java @@ -96,8 +96,6 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, protected int mPaddingLeft, mPaddingRight, mPaddingTop, mPaddingBottom; private EventHandler eventHandler; - // 水波纹相关属性 - private MmiPoint pointerPosition; private int sy; private float sx; AnimatorValue animatorValue = new AnimatorValue(); @@ -159,7 +157,7 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, return; } - Element a = TypedAttrUtils.getDrawable(attrs, "RTextView", null); + //Element a = TypedAttrUtils.getDrawable(attrs, "RTextView", null); // icon text_ripple_color = AttrUtils.getStringToColor(attrs, "text_ripple_color", Color.TRANSPARENT); @@ -355,8 +353,8 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, /** * 设置图片 * - * @param icon - * @return 图 + * @param icon Element + * @return RTextHelper */ @Deprecated public RTextHelper setIconUnable(Element icon) { @@ -944,9 +942,9 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, public void run() { // 水平方向计算 float textWidth = TextUtils.get().getTextWidth(mView, drawableWidthFinal, mPaddingLeft, mPaddingRight, drawablePaddingHorizontalFinal); - float bodyWidth = textWidth + drawableWidthFinal + drawablePaddingHorizontalFinal + 200; // 内容宽度 + float bodyWidth = (float) (textWidth + drawableWidthFinal + drawablePaddingHorizontalFinal + 200d); // 内容宽度 float actualWidth = mView.getWidth() - (mPaddingLeft + mPaddingRight); // 实际可用宽度 - int translateX = (int) (actualWidth - bodyWidth) / 2; // 两边使用 + int translateX = (int) ((int) (actualWidth - bodyWidth) / 2d); // 两边使用 if (0 > translateX) { translateX = 0; } @@ -956,7 +954,7 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, mPaddingTop, mPaddingBottom, drawablePaddingVerticalFinal); float bodyHeight = textHeight + drawableHeightFinal + drawablePaddingVerticalFinal; // 内容高度 float actualHeight = mView.getHeight() - (mPaddingTop + mPaddingBottom); // 实际可用高度 - int translateY = (int) (actualHeight - bodyHeight) / 2; + int translateY = (int) ((int) (actualHeight - bodyHeight) / 2d); if (0 > translateY) { translateY = 0; } @@ -1070,11 +1068,6 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, */ protected void setTextColor() { // unable,focused,pressed,selected,normal - Color[] colors = new Color[]{mTextColorUnable, mTextColorPressed, - mTextColorPressed, mTextColorSelected, mTextColorNormal}; - - ShapeElement element = new ShapeElement(); - mView.setTextColor(mTextColorNormal); } @@ -1266,13 +1259,8 @@ public class RTextHelper extends RBaseHelper implements ITextViewFeature, mIcon = mIconPressed; } if (isRipple && mView.isEnabled()) { - pointerPosition = event.getPointerPosition(0); - float px = pointerPosition.getX(); - float py = pointerPosition.getY(); - int[] parentLocationOnScreen = mView.getLocationOnScreen(); - int yy = (int) (py - parentLocationOnScreen[1]); - sx = component.getWidth()/2; - sy = component.getHeight()/ 2; + sx = (float) (component.getWidth()/2d); + sy = (int) (component.getHeight()/ 2d); animatorValue.start(); isTouch = false; } diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ShadowDrawable.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ShadowDrawable.java index 9523d76..3977833 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ShadowDrawable.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/ShadowDrawable.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -47,17 +47,6 @@ public class ShadowDrawable extends Element implements Component.DrawTask { mPaint = new Paint(); } - public void updateParameter(Color shadowColor, float shadowRadius, int shadowDx, int shadowDy, float[] roundRadii) { - //阴影颜色 - this.mRoundRadii = roundRadii; - this.mShadowRadius = shadowRadius; - this.mShadowDx = shadowDx; - this.mShadowDy = shadowDy; - mPaint.setColor(shadowColor); - BlurDrawLooper blurDrawLooper = new BlurDrawLooper(mShadowRadius,mShadowDx, mShadowDy, shadowColor); - mPaint.setBlurDrawLooper(blurDrawLooper); - } - @Override public void setBounds(Rect bounds) { super.setBounds(bounds); diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TextUtils.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TextUtils.java index e9fc7da..8d15f0c 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TextUtils.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TextUtils.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -27,7 +27,7 @@ import java.util.Collections; * */ public class TextUtils { - private static TextUtils instance = null; + private volatile static TextUtils instance = null; private Paint paint; private TextUtils() { diff --git a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TypedAttrUtils.java b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TypedAttrUtils.java index 2d9e62a..c8fa198 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TypedAttrUtils.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/chechbox/TypedAttrUtils.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/exampleapp/src/main/java/com/org/matomo/demo/util/StrUtil.java b/exampleapp/src/main/java/com/org/matomo/demo/util/StrUtil.java index 7499bc9..9bf77ec 100644 --- a/exampleapp/src/main/java/com/org/matomo/demo/util/StrUtil.java +++ b/exampleapp/src/main/java/com/org/matomo/demo/util/StrUtil.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/tracker/src/main/java/org/matomo/sdk/Logger.java b/tracker/src/main/java/org/matomo/sdk/Logger.java index baf6957..8f6920d 100644 --- a/tracker/src/main/java/org/matomo/sdk/Logger.java +++ b/tracker/src/main/java/org/matomo/sdk/Logger.java @@ -1,11 +1,11 @@ -/** +/* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, diff --git a/tracker/src/main/java/org/matomo/sdk/Matomo.java b/tracker/src/main/java/org/matomo/sdk/Matomo.java index b071f50..a988ce7 100644 --- a/tracker/src/main/java/org/matomo/sdk/Matomo.java +++ b/tracker/src/main/java/org/matomo/sdk/Matomo.java @@ -23,7 +23,7 @@ public class Matomo { private static final String TAG = Matomo.tag(Matomo.class); private static final String BASE_PREFERENCE_FILE = "org.matomo.sdk"; - private static Matomo sInstance; + private volatile static Matomo sInstance; private final Map mPreferenceMap = new HashMap<>(); private final Context mContext; diff --git a/tracker/src/main/java/org/matomo/sdk/PackageManager.java b/tracker/src/main/java/org/matomo/sdk/PackageManager.java index 33c7e4c..d81d323 100644 --- a/tracker/src/main/java/org/matomo/sdk/PackageManager.java +++ b/tracker/src/main/java/org/matomo/sdk/PackageManager.java @@ -1,3 +1,4 @@ + /* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java b/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java index dd5a241..b6396d4 100644 --- a/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java +++ b/tracker/src/main/java/org/matomo/sdk/PackageManagerImpl.java @@ -1,3 +1,4 @@ + /* * Copyright (C) 2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultDispatcher.java b/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultDispatcher.java index b030f66..0bfe958 100644 --- a/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultDispatcher.java +++ b/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultDispatcher.java @@ -230,7 +230,7 @@ public class DefaultDispatcher implements Dispatcher { sleepTime += Math.min(mRetryCounter * mDispatchInterval, 5 * mDispatchInterval); // Either we wait the interval or forceDispatch() granted us one free pass - mSleepToken.tryAcquire(sleepTime, TimeUnit.MILLISECONDS); + boolean b = mSleepToken.tryAcquire(sleepTime, TimeUnit.MILLISECONDS); } catch (InterruptedException e) { Logger.error(e.getMessage()); } diff --git a/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultPacketSender.java b/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultPacketSender.java index b08fe52..278c234 100644 --- a/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultPacketSender.java +++ b/tracker/src/main/java/org/matomo/sdk/dispatcher/DefaultPacketSender.java @@ -44,6 +44,8 @@ public class DefaultPacketSender implements PacketSender { try { gzipStream = new GZIPOutputStream(byteArrayOS); gzipStream.write(toPost.getBytes(Charset.forName("UTF8"))); + } catch (IOException e) { + e.printStackTrace(); } finally { // If closing fails we assume the written data to be invalid. // Don't catch the exception and let it abort the `send(Packet)` call. @@ -112,7 +114,7 @@ public class DefaultPacketSender implements PacketSender { } return successful; - } catch (Exception e) { + } catch (IOException e) { return false; } finally { if (urlConnection != null) urlConnection.disconnect(); diff --git a/tracker/src/main/java/org/matomo/sdk/extra/MatomoApplication.java b/tracker/src/main/java/org/matomo/sdk/extra/MatomoApplication.java index eb69c64..cf31f5e 100644 --- a/tracker/src/main/java/org/matomo/sdk/extra/MatomoApplication.java +++ b/tracker/src/main/java/org/matomo/sdk/extra/MatomoApplication.java @@ -34,7 +34,7 @@ public abstract class MatomoApplication extends AbilityPackage { * * @return a shared Tracker */ - public synchronized Tracker getTracker() { + public Tracker getTracker() { if (mMatomoTracker == null) mMatomoTracker = onCreateTrackerConfig().build(getMatomo()); return mMatomoTracker; } -- Gitee