Skip to content
This repository has been archived by the owner on Jun 3, 2021. It is now read-only.

Commit

Permalink
[Android] Fix problems in Android Lint (#2781)
Browse files Browse the repository at this point in the history
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
  • Loading branch information
YorkShen authored and lucky-chen committed Aug 2, 2019
1 parent 9ea64b9 commit 24a30b3
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
1 change: 0 additions & 1 deletion android/sdk/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ bin
.settings
gen
*.iml
lint.xml
project.properties
assets/main.js
assets/weex-main-jsfm.js
Expand Down
7 changes: 7 additions & 0 deletions android/sdk/lint.xml
Original file line number Diff line number Diff line change
@@ -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>
20 changes: 14 additions & 6 deletions android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -28,8 +31,6 @@
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;
Expand All @@ -39,7 +40,6 @@
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;
Expand All @@ -52,8 +52,6 @@
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";
Expand Down Expand Up @@ -279,6 +277,7 @@ public static String getCustomOptions(String key){
}


@SuppressLint("SdCardPath")
public static String copySoDesDir() {
try {
if (TextUtils.isEmpty(COPY_SO_DES_DIR)) {
Expand Down Expand Up @@ -397,9 +396,18 @@ public static boolean isPerf() {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ protected MeasureOutput measure(int width, int height) {
return measureOutput;
}

@SuppressLint("ClickableViewAccessibility")
@Override
protected ViewGroup initComponentHostView(@NonNull Context context) {
String scroll;
Expand Down Expand Up @@ -492,7 +493,7 @@ public void onLayoutChange(View view, final int left, int top, final int right,
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();
Expand All @@ -507,7 +508,7 @@ public void run() {
scrollView.scrollBy(changedWidth, component.getScrollY());
}
}
mIslastDirectionRTL = new Boolean(isLayoutRTL());
mIslastDirectionRTL = isLayoutRTL();
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,11 +143,18 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
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);
Expand Down
2 changes: 1 addition & 1 deletion weex-playground
Submodule weex-playground updated 1 files
+0 −6 .travis.yml

0 comments on commit 24a30b3

Please sign in to comment.