Skip to content

Commit

Permalink
Merge branch 'release-0.17-gitlab' into release-0.16-gitlab
Browse files Browse the repository at this point in the history
* release-0.17-gitlab:
  Weex render and other thin but critical issues should be classify to render container by call render of exception callback  close apache#920
  * [android] remove override post and postDelayed, wrap anonymous Runnable with WXThread.secure() close apache#919
  * [android] clear box-shadow when component has recycled close apache#917
  * [android] support multi box-shadow close apache#915
  * [doc] doc references: update weex.config.bundleUrl's description close apache#909
  [WEEX-145][iOS]fix: Crash in WXScrollerComponent scrollViewDidScroll,Collection NSHashTable was mutated while being enumerated close apache#910
  * [android] support role property to accessibility * [android] add license header close apache#912 * [android] remove cn strings * [android] fix en role
  [WEEX-138][android]WXParallax wat not reseted to right position, when scrollToElement with animated:false option. dx dy is zero when recycleview use scrollToPosition close apache#906
  [WEEX-142][android] PullToRefresh Loading Support Scroll Back when touch not release close apache#905
  [WEEX-140][android]layout animation supported more property close apache#904
  • Loading branch information
atomtong committed Nov 29, 2017
2 parents 250bb58 + 27ebb67 commit dab197d
Show file tree
Hide file tree
Showing 57 changed files with 1,285 additions and 464 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ public void onException(WXSDKInstance wxsdkInstance, String s, String s1) {
super.onException(wxsdkInstance,s,s1);
mProgressBar.setVisibility(View.GONE);
mTipView.setVisibility(View.VISIBLE);
if (TextUtils.equals(s, WXRenderErrorCode.WX_NETWORK_ERROR)) {
if (TextUtils.equals(s, WXRenderErrorCode.DegradPassivityCode.WX_DEGRAD_ERR_NETWORK_BUNDLE_DOWNLOAD_FAILED.getDegradErrorCode())) {
mTipView.setText(R.string.index_tip);
} else {
mTipView.setText("render error:" + s1);
mTipView.setText("network render error:" + s1);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.alibaba.weex.commons.adapter.DefaultWebSocketAdapterFactory;
import com.alibaba.weex.commons.adapter.ImageAdapter;
import com.alibaba.weex.commons.adapter.JSExceptionAdapter;
import com.alibaba.weex.extend.adapter.DefaultAccessibilityRoleAdapter;
import com.alibaba.weex.extend.adapter.InterceptWXHttpAdapter;
import com.alibaba.weex.extend.component.RichText;
import com.alibaba.weex.extend.component.WXComponentSyncTest;
Expand Down Expand Up @@ -71,6 +72,8 @@ public void onCreate() {
.build()
);

WXSDKManager.getInstance().setAccessibilityRoleAdapter(new DefaultAccessibilityRoleAdapter());

try {
Fresco.initialize(this);
WXSDKEngine.registerComponent("synccomponent", WXComponentSyncTest.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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.
*/
package com.alibaba.weex.extend.adapter;

import android.text.TextUtils;

import com.taobao.weex.adapter.IWXAccessibilityRoleAdapter;

import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

/**
* Created by moxun on 2017/11/13.
*/

public class DefaultAccessibilityRoleAdapter implements IWXAccessibilityRoleAdapter {
private static Map<String, String> ENRoles = new HashMap<>();

static {
ENRoles.put("button", "Button");
ENRoles.put("link", "HyperLink");
ENRoles.put("img", "Picture");
ENRoles.put("search", "Search");
ENRoles.put("header", "Title");
}

@Override
public String getRole(String key) {
if (isEN()) {
String enRole = ENRoles.get(key);
if (!TextUtils.isEmpty(enRole)) {
return enRole;
}
}
return key;
}

private static boolean isEN() {
try {
return "EN".equals(Locale.getDefault().getCountry());
} catch (Throwable t) {
}
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

import android.graphics.Color;
import android.support.annotation.Nullable;
import android.support.v4.view.ViewCompat;
import android.support.v7.widget.RecyclerView;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.Animation;
Expand All @@ -41,6 +43,9 @@
import com.taobao.weex.ui.component.WXComponent;
import com.taobao.weex.ui.component.WXDiv;
import com.taobao.weex.ui.component.WXVContainer;
import com.taobao.weex.ui.component.list.BasicListComponent;
import com.taobao.weex.ui.component.list.template.WXRecyclerTemplateList;
import com.taobao.weex.ui.view.listview.WXRecyclerView;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXResourceUtils;

Expand All @@ -62,6 +67,7 @@ public class WXParallax extends WXDiv implements OnWXScrollListener, ICheckBindi
ArrayList<TransformCreator> mTransformPropArrayList = new ArrayList<>();
BackgroundColorCreator mBackgroundColor;
String mBindingRef = "";
WXComponent mBindingComponent;

private int mBackGroundColor = 0;
private float mOffsetY = 0;
Expand Down Expand Up @@ -150,8 +156,22 @@ public boolean isNeedScroller(String ref, Object option) {

@Override
public void onScrolled(View view, int dx, int dy) {

mOffsetY = mOffsetY + dy;
if(ViewCompat.isInLayout(view)){
if(mBindingComponent == null && mBindingRef != null){
mBindingComponent = findComponent(mBindingRef);
}
if(mBindingComponent instanceof BasicListComponent
&& view instanceof RecyclerView){
BasicListComponent listComponent = (BasicListComponent) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}else if(mBindingComponent instanceof WXRecyclerTemplateList
&& view instanceof RecyclerView){
WXRecyclerTemplateList listComponent = (WXRecyclerTemplateList) mBindingComponent;
mOffsetY = Math.abs(listComponent.calcContentOffset((RecyclerView) view));
}
}else{
mOffsetY = mOffsetY + dy;
}

AnimationSet animationSet = new AnimationSet(true);
boolean hasAnimation = false;
Expand Down
6 changes: 4 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/WXEnvironment.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@

import com.taobao.weappplus_sdk.BuildConfig;
import com.taobao.weex.common.WXConfig;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.utils.LogLevel;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXSoInstallMgrSdk;
import com.taobao.weex.utils.WXUtils;
Expand Down Expand Up @@ -166,8 +168,8 @@ public static void addCustomOptions(String key, String value) {
*/
public static boolean isSupport() {
boolean isInitialized = WXSDKEngine.isInitialized();
if(WXEnvironment.isApkDebugable()){
WXLogUtils.d("WXSDKEngine.isInitialized():" + isInitialized);
if(!isInitialized){
WXLogUtils.e("WXSDKEngine.isInitialized():" + isInitialized);
}
return isHardwareSupport() && isInitialized;
}
Expand Down
65 changes: 62 additions & 3 deletions android/sdk/src/main/java/com/taobao/weex/WXRenderErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,68 @@

public class WXRenderErrorCode {

public static final String WX_CREATE_INSTANCE_ERROR = "wx_create_instance_error";
// public static final String WX_CREATE_INSTANCE_ERROR = "wx_create_instance_error";
//
// public static final String WX_NETWORK_ERROR = "wx_network_error";
//
// public static final String WX_USER_INTERCEPT_ERROR = "wx_user_intercept_error";

public static final String WX_NETWORK_ERROR = "wx_network_error";
public enum DegradPassivityCode{

public static final String WX_USER_INTERCEPT_ERROR = "wx_user_intercept_error";
/**
* degrade code.
*/
WX_DEGRAD_ERR("-1000", "degradeToH5|Weex DegradPassivity \n"),

/**
* degrade for instance create failed, once this case occured,detail js stack and other specific
* cause need track into errmsg.
*/
WX_DEGRAD_ERR_INSTANCE_CREATE_FAILED("-1001", "degradeToH5|createInstance fail|wx_create_instance_error"),

/**
* degrade for network failed download js bundle.once this case occured,network requist response header
* and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_NETWORK_BUNDLE_DOWNLOAD_FAILED("-1002", "|wx_network_error|js bundle download failed"),

/**
* degrade for network failed for bundlejs is unbroken , once this case occured,network requist response header
* and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_NETWORK_CHECK_CONTENT_LENGTH_FAILED("-1003", "degradeToH5|wx_network_error|js bundle content-length check failed"),

/**
* degrade for Response header Content-Type is null or not "application/javascript".
* once this case occured,network requist response header and statuscode need track into errmsg.
*/
WX_DEGRAD_ERR_BUNDLE_CONTENTTYPE_ERROR("-1004", "degradeToH5|wx_user_intercept_error |Content-Type is not application/javascript, " +
"Weex render template must be javascript, please check your request!"),

/**
* degrade for other reason. such as white screen which block error for some unknown reason.
* once this case occured,detail msg need track.
*/
WX_DEGRAD_ERR_OTHER_CAUSE_DEGRADTOH5("-1005", "degradeToH5|for other reason|");

private String degradCode;
private String degradMsg;
private String appendMsg = "";
private String args;

DegradPassivityCode(String degradCode, String degradMsg){
this.degradCode = degradCode;
this.degradMsg = degradMsg;
}

public String getDegradErrorCode() {
return degradCode;
}

public String getDegradErrorMsg() {
StringBuilder builder=new StringBuilder(degradMsg);
builder.append(appendMsg);
return builder.toString();
}
}
}
13 changes: 13 additions & 0 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKEngine.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
import com.taobao.weex.bridge.WXServiceManager;
import com.taobao.weex.common.Destroyable;
import com.taobao.weex.common.TypeModuleFactory;
import com.taobao.weex.common.WXErrorCode;
import com.taobao.weex.common.WXException;
import com.taobao.weex.common.WXInstanceWrap;
import com.taobao.weex.common.WXModule;
Expand Down Expand Up @@ -94,6 +95,7 @@
import com.taobao.weex.ui.module.WXTimerModule;
import com.taobao.weex.ui.module.WXWebViewModule;
import com.taobao.weex.utils.LogLevel;
import com.taobao.weex.utils.WXExceptionUtils;
import com.taobao.weex.utils.WXLogUtils;
import com.taobao.weex.utils.WXSoInstallMgrSdk;
import com.taobao.weex.utils.batch.BatchOperationHelper;
Expand Down Expand Up @@ -178,6 +180,11 @@ private static void doInitInternal(final Application application,final InitConfi
WXEnvironment.sApplication = application;
if(application == null){
WXLogUtils.e(TAG, " doInitInternal application is null");
WXExceptionUtils.commitCriticalExceptionRT(null,
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorCode(),
"doInitInternal",
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "WXEnvironment sApplication is null",
null);
}
WXEnvironment.JsFrameworkInit = false;

Expand All @@ -195,6 +202,12 @@ public void run() {
sm.getWXStatisticsListener());
boolean isSoInitSuccess = WXSoInstallMgrSdk.initSo(V8_SO_NAME, 1, config!=null?config.getUtAdapter():null);
if (!isSoInitSuccess) {
WXExceptionUtils.commitCriticalExceptionRT(null,
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorCode(),
"doInitInternal",
WXErrorCode.WX_KEY_EXCEPTION_SDK_INIT.getErrorMsg() + "isSoInit false",
null);

return;
}
sm.initScriptsFramework(config!=null?config.getFramework():null);
Expand Down
Loading

0 comments on commit dab197d

Please sign in to comment.