You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by lu...@apache.org on 2019/08/02 09:32:27 UTC

[incubator-weex] branch master updated: [Android] Fix problems in Android Lint (#2781)

This is an automated email from the ASF dual-hosted git repository.

luckychen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-weex.git


The following commit(s) were added to refs/heads/master by this push:
     new 24a30b3  [Android] Fix problems in Android Lint (#2781)
24a30b3 is described below

commit 24a30b31e759343668cfe6b8f3de264dd3f586fe
Author: YorkShen <sh...@gmail.com>
AuthorDate: Fri Aug 2 17:32:22 2019 +0800

    [Android] Fix problems in Android Lint (#2781)
    
    1. Fix permission problem of getSystemService(Context.TELEPHONY_SERVICE))
    2. Fix allocate new object problem in CircleProgressBra.onLayout
    3. Fix boxing/unboxing problem in WXScroller
    4. Add lint.xml to git
---
 android/sdk/.gitignore                               |  1 -
 android/sdk/lint.xml                                 |  7 +++++++
 .../src/main/java/com/taobao/weex/WXEnvironment.java | 20 ++++++++++++++------
 .../com/taobao/weex/ui/component/WXScroller.java     |  5 +++--
 .../ui/view/refresh/circlebar/CircleProgressBar.java | 13 ++++++++++---
 weex-playground                                      |  2 +-
 6 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/android/sdk/.gitignore b/android/sdk/.gitignore
index 02bab00..b173f6b 100755
--- a/android/sdk/.gitignore
+++ b/android/sdk/.gitignore
@@ -10,7 +10,6 @@ bin
 .settings
 gen
 *.iml
-lint.xml
 project.properties
 assets/main.js
 assets/weex-main-jsfm.js
diff --git a/android/sdk/lint.xml b/android/sdk/lint.xml
new file mode 100644
index 0000000..747992e
--- /dev/null
+++ b/android/sdk/lint.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<lint>
+  <!-- Ignore the UselessLeaf issue in the specified file -->
+  <issue id="IconLocation">
+    <ignore path="src/main/res/drawable/weex_error.png" />
+  </issue>
+</lint>
\ No newline at end of file
diff --git a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
index fc51378..daa1c3e 100644
--- a/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
+++ b/android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
@@ -18,6 +18,9 @@
  */
 package com.taobao.weex;
 
+import static android.content.Context.MODE_PRIVATE;
+
+import android.annotation.SuppressLint;
 import android.app.Application;
 import android.content.Context;
 import android.content.SharedPreferences;
@@ -28,8 +31,6 @@ import android.graphics.Typeface;
 import android.os.Environment;
 import android.telephony.TelephonyManager;
 import android.text.TextUtils;
-import android.util.Log;
-
 import com.taobao.weex.common.WXConfig;
 import com.taobao.weex.utils.FontDO;
 import com.taobao.weex.utils.LogLevel;
@@ -39,7 +40,6 @@ import com.taobao.weex.utils.WXLogUtils;
 import com.taobao.weex.utils.WXSoInstallMgrSdk;
 import com.taobao.weex.utils.WXUtils;
 import com.taobao.weex.utils.WXViewUtils;
-
 import dalvik.system.PathClassLoader;
 import java.io.BufferedReader;
 import java.io.File;
@@ -52,8 +52,6 @@ import java.util.Locale;
 import java.util.Map;
 import java.util.concurrent.ConcurrentHashMap;
 
-import static android.content.Context.MODE_PRIVATE;
-
 public class WXEnvironment {
 
   public static final String OS = "android";
@@ -279,6 +277,7 @@ public class WXEnvironment {
   }
 
 
+  @SuppressLint("SdCardPath")
   public static String copySoDesDir() {
     try {
       if (TextUtils.isEmpty(COPY_SO_DES_DIR)) {
@@ -397,9 +396,18 @@ public class WXEnvironment {
     return isPerf;
   }
 
+  @SuppressLint("HardwareIds")
   private static String getDevId() {
-    return sApplication == null ? "" : ((TelephonyManager) sApplication
+    String ret = "";
+    if(sApplication != null){
+      try{
+        ret = ((TelephonyManager) sApplication
             .getSystemService(Context.TELEPHONY_SERVICE)).getDeviceId();
+      }catch (SecurityException | NullPointerException e){
+        WXLogUtils.e(WXLogUtils.getStackTrace(e));
+      }
+    }
+    return ret;
   }
 
   public static Application getApplication() {
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
index 34ca774..c460849 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXScroller.java
@@ -443,6 +443,7 @@ public class WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewL
     return measureOutput;
   }
 
+  @SuppressLint("ClickableViewAccessibility")
   @Override
   protected ViewGroup initComponentHostView(@NonNull Context context) {
     String scroll;
@@ -492,7 +493,7 @@ public class WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewL
           scrollView.post(new Runnable() {
             @Override
             public void run() {
-              if (mIslastDirectionRTL != null && isLayoutRTL() != mIslastDirectionRTL.booleanValue()) {
+              if (mIslastDirectionRTL != null && isLayoutRTL() != mIslastDirectionRTL) {
                 // when layout direction changed we need convert x to RTL x for scroll to the same item
                 int currentX = getScrollX();
                 int totalWidth = getInnerView().getChildAt(0).getWidth();
@@ -507,7 +508,7 @@ public class WXScroller extends WXVContainer<ViewGroup> implements WXScrollViewL
                   scrollView.scrollBy(changedWidth, component.getScrollY());
                 }
               }
-              mIslastDirectionRTL = new Boolean(isLayoutRTL());
+              mIslastDirectionRTL = isLayoutRTL();
             }
           });
         }
diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/circlebar/CircleProgressBar.java b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/circlebar/CircleProgressBar.java
index 8d81d5e..7780624 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/circlebar/CircleProgressBar.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/view/refresh/circlebar/CircleProgressBar.java
@@ -143,11 +143,18 @@ public class CircleProgressBar extends ImageView {
       mShadowRadius = (int) (density * SHADOW_RADIUS);
 
       if (elevationSupported()) {
-        mBgCircle = new ShapeDrawable(new OvalShape());
+        if(mBgCircle == null) {
+          mBgCircle = new ShapeDrawable(new OvalShape());
+        }
         ViewCompat.setElevation(this, SHADOW_ELEVATION * density);
       } else {
-        OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2);
-        mBgCircle = new ShapeDrawable(oval);
+        if(!(mBgCircle != null &&
+            mBgCircle.getShape() instanceof  OvalShadow &&
+            ((OvalShadow) mBgCircle.getShape()).mCircleDiameter == (mDiameter - mShadowRadius * 2) &&
+            ((OvalShadow) mBgCircle.getShape()).mShadowRadius == mShadowRadius)) {
+          OvalShape oval = new OvalShadow(mShadowRadius, mDiameter - mShadowRadius * 2);
+          mBgCircle = new ShapeDrawable(oval);
+        }
         ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, mBgCircle.getPaint());
         mBgCircle.getPaint().setShadowLayer(mShadowRadius, shadowXOffset, shadowYOffset,
                                             KEY_SHADOW_COLOR);
diff --git a/weex-playground b/weex-playground
index e6e18a2..3b86e3c 160000
--- a/weex-playground
+++ b/weex-playground
@@ -1 +1 @@
-Subproject commit e6e18a2f9948d7fd57e839828c751d5b97d96b53
+Subproject commit 3b86e3cdfea2e2edddd32e11e8de0e5b83997f0a