Skip to content

Commit

Permalink
Merge branch 'tb-dev' into tb-dev-new-playground
Browse files Browse the repository at this point in the history
* tb-dev: (80 commits)
  * [android] update js-framework
  * [android] fix move child from index to index b within the same parent
  * [android] jsfm update to 0.16.12
  * [android] callNative &nativeLog api  support emoji
  * [android] support emoji
  * [android] update WXImageView support gif
  * [android] update WXImageView support gif
  * [android] jsfm update to 0.16.11
  * [android] add fixed size property
  Fix alibaba/weex#1200
  Fix NPE in WXEmbed
  * [android] update getComponentSize size location screen
  * [android] reformat code in WXBorderDrawable
  * [android] change wxattr and wxstyle from concurrentHashMap to HashMap
  * [android] update bottom,top,right,left
  * [android] update unit test
  * [android] update getcomponentsize return Rect
  * [android] update unit test
  * [android] update unit test
  * [android] update unit test
  ...
  • Loading branch information
xkli committed Oct 9, 2016
2 parents 05128d2 + 46422b6 commit d7fae5f
Show file tree
Hide file tree
Showing 75 changed files with 4,517 additions and 381 deletions.
6 changes: 4 additions & 2 deletions README.md
Expand Up @@ -64,9 +64,11 @@ On Android Platform , Weex code is executed in [weex_v8core](https://github.com/
See [SCRIPTS.md](./SCRIPTS.md) for more information.


## IDE Plugin & Syntax Highlight
## IDE Plugin & Syntax Highlight & DevTool

See [Weex Community](https://github.com/alibaba/weex/wiki/Weex-Community) Wiki page
See [Weex Community](https://github.com/alibaba/weex/wiki/Weex-Community) Wiki page

Weex team have developed a [DevTool](https://github.com/weexteam/weex-devtool) to help you to improve `we file` debug efficiency.

## FAQ

Expand Down
Expand Up @@ -246,8 +246,8 @@ public static void setCurrentWxPageActivity(Activity activity) {
@Override
public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
Intent intent = new Intent("requestPermission");
intent.putExtra("REQUEST_PERMISSION_CODE", requestCode);
Intent intent = new Intent("actionRequestPermissionsResult");
intent.putExtra("requestCode", requestCode);
intent.putExtra("permissions", permissions);
intent.putExtra("grantResults", grantResults);
LocalBroadcastManager.getInstance(this).sendBroadcast(intent);
Expand Down
Expand Up @@ -21,6 +21,7 @@
import java.util.Map;

/**
* Created by lixinke on 16/9/10.
*/
public class GeolocationModule extends WXModule implements Destroyable {

Expand All @@ -31,45 +32,44 @@ public GeolocationModule() {
}

/**
* Get current location information, the callback only once
* 获取当前位置信息,只回调一次。
*
* @param successCallback success callback function id.
* @param errorCallback error callback function id.(example:no persimmon)
* @param params JSON parameter(example:address).
* @param successCallback 成功回调function id.
* @param errorCallback 错误回调function id.(例如:没有权限)
* @param params JSON格式的参数(例如:准确度等).
*/
@WXModuleAnno
public void getCurrentPosition(String successCallback, String errorCallback, String params) {
mILocatable.setWXSDKInstance(mWXSDKInstance);
if (ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (checkPermission()) {
mILocatable.getCurrentPosition(successCallback, errorCallback, params);
} else {
ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, ILocatable.REQUEST_CUR_PERMISSION_CODE);
LocalBroadcastManager.getInstance(mWXSDKInstance.getContext()).registerReceiver(new PerReceiver(mWXSDKInstance.getInstanceId(), mILocatable, successCallback, errorCallback, params), new IntentFilter("requestPermission"));
requestPermission(successCallback, errorCallback, params, ILocatable.REQUEST_CUR_PERMISSION_CODE);
}
}


/**
* register global location listener,if location change,you will be notify.
* 注册监听全局定位
*
* @param successCallback location success callback function id.
* @param errorCallback location error callback (example:no persimmon).
* @param params JSON parameter(example:address).
* @param successCallback 定位成功回调function id.
* @param errorCallback 错误回调(例如:没有权限等).
* @param params SON格式的参数(例如:准确度等).
*/
@WXModuleAnno
public void watchPosition(String successCallback, String errorCallback, String params) {
mILocatable.setWXSDKInstance(mWXSDKInstance);
if (ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED && ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED) {
if (checkPermission()) {
mILocatable.watchPosition(successCallback, errorCallback, params);
} else {
ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(), new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, ILocatable.REQUEST_WATCH_PERMISSION_CODE);
LocalBroadcastManager.getInstance(mWXSDKInstance.getContext()).registerReceiver(new PerReceiver(mWXSDKInstance.getInstanceId(), mILocatable, successCallback, errorCallback, params), new IntentFilter("requestPermission"));
requestPermission(successCallback, errorCallback, params, ILocatable.REQUEST_WATCH_PERMISSION_CODE);
}
}

/**
* remove global location listener.
* 注销监听全局定位
*
* @param registerID register id,you can get from watchPosition method
* @param registerID 注册时返回的唯一ID
*/
@WXModuleAnno
public void clearWatch(String registerID) {
Expand All @@ -83,6 +83,18 @@ public void destroy() {
mILocatable.destroy();
}

private void requestPermission(String successCallback, String errorCallback, String params, int requestCurPermissionCode) {
ActivityCompat.requestPermissions((Activity) mWXSDKInstance.getContext(),
new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION}, requestCurPermissionCode);
LocalBroadcastManager.getInstance(mWXSDKInstance.getContext())
.registerReceiver(new PerReceiver(mWXSDKInstance.getInstanceId(), mILocatable, successCallback, errorCallback, params), new IntentFilter("actionRequestPermissionsResult"));
}

private boolean checkPermission() {
return ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_FINE_LOCATION) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mWXSDKInstance.getContext(), Manifest.permission.ACCESS_COARSE_LOCATION) == PackageManager.PERMISSION_GRANTED;
}

static class PerReceiver extends BroadcastReceiver {

String mInstanceId;
Expand Down
Expand Up @@ -15,6 +15,7 @@
import android.support.v4.app.ActivityCompat;
import android.text.TextUtils;

import com.taobao.weex.WXEnvironment;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.WXSDKManager;
import com.taobao.weex.utils.WXLogUtils;
Expand Down Expand Up @@ -56,7 +57,9 @@ public void setWXSDKInstance(WXSDKInstance WXSDKInstance) {

@Override
public void getCurrentPosition(final String successCallback, final String errorCallback, final String params) {
WXLogUtils.d(TAG, "into--[getCurrentPosition] successCallback:" + successCallback + " \nerrorCallback:" + errorCallback + " \nparams:" + params);
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "into--[getCurrentPosition] successCallback:" + successCallback + " \nerrorCallback:" + errorCallback + " \nparams:" + params);
}
if (!TextUtils.isEmpty(params)) {
try {
org.json.JSONObject jsObj = new org.json.JSONObject(params);
Expand All @@ -78,7 +81,7 @@ public void getCurrentPosition(final String successCallback, final String errorC
}

private WXLocationListener findLocation(String watchId, String sucCallback, String errorCallback, boolean enableHighAccuracy, boolean enableAddress) {
WXLogUtils.d(TAG, "into--[findLocation] mWatchId:" + watchId + "\nsuccessCallback:" + sucCallback + "\nerrorCallback:" + errorCallback + "\nenableHighAccuracy:" + enableHighAccuracy + "\nmEnableAddress:" + enableAddress);
// WXLogUtils.d(TAG, "into--[findLocation] mWatchId:" + watchId + "\nsuccessCallback:" + sucCallback + "\nerrorCallback:" + errorCallback + "\nenableHighAccuracy:" + enableHighAccuracy + "\nmEnableAddress:" + enableAddress);

if (mLocationManager == null) {
mLocationManager = (LocationManager) mWXSDKInstance.getContext().getSystemService(Context.LOCATION_SERVICE);
Expand Down Expand Up @@ -202,7 +205,9 @@ private WXLocationListener(LocationManager locationManager, WXSDKInstance instan
@Override
public void onLocationChanged(Location location) {
mHandler.removeMessages(TIME_OUT_WHAT);
WXLogUtils.d(TAG, "into--[onLocationChanged] location:" + location == null ? "Location is NULL!" : location.toString());
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "into--[onLocationChanged] location:" + location == null ? "Location is NULL!" : location.toString());
}

if (mWXSDKInstance == null || mWXSDKInstance.isDestroy()) {
return;
Expand Down Expand Up @@ -284,7 +289,9 @@ public void onProviderDisabled(String provider) {
@Override
public boolean handleMessage(Message msg) {
if (msg.what == TIME_OUT_WHAT) {
WXLogUtils.d(TAG, "into--[handleMessage] Location Time Out!");
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "into--[handleMessage] Location Time Out!");
}
if (mWXSDKInstance == null || mWXSDKInstance.isDestroy() || mLocationManager == null) {
return false;
}
Expand All @@ -307,7 +314,9 @@ public boolean handleMessage(Message msg) {
* get address info
*/
private Address getAddress(double latitude, double longitude) {
WXLogUtils.d(TAG, "into--[getAddress] latitude:" + latitude + " longitude:" + longitude);
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d(TAG, "into--[getAddress] latitude:" + latitude + " longitude:" + longitude);
}
try {
if (mWXSDKInstance == null || mWXSDKInstance.isDestroy()) {
return null;
Expand Down
Expand Up @@ -10,7 +10,7 @@ public interface ILocatable {
int REQUEST_WATCH_PERMISSION_CODE = 0x13;


String REQUEST_PERMISSION_CODE = "REQUEST_PERMISSION_CODE";
String REQUEST_PERMISSION_CODE = "requestCode";
String ERROR_CODE = "errorCode";
String ERROR_MSG = "errorMsg";
String COORDS = "coords";
Expand Down
12 changes: 7 additions & 5 deletions android/sdk/assets/main.js

Large diffs are not rendered by default.

Binary file modified android/sdk/libs/armeabi/libweexv8.so
Binary file not shown.
Binary file modified android/sdk/libs/x86/libweexv8.so
Binary file not shown.
12 changes: 10 additions & 2 deletions android/sdk/src/main/java/com/taobao/weex/WXSDKInstance.java
Expand Up @@ -208,6 +208,7 @@
import android.net.Uri;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ScrollView;
Expand Down Expand Up @@ -762,7 +763,9 @@ public void onRenderSuccess(final int width, final int height) {
mWXPerformance.screenRenderTime = time;
}
mWXPerformance.componentCount = WXComponent.mComponentNum;
WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, "mComponentNum:" + WXComponent.mComponentNum);
if(WXEnvironment.isApkDebugable()) {
WXLogUtils.d(WXLogUtils.WEEX_PERF_TAG, "mComponentNum:" + WXComponent.mComponentNum);
}
WXComponent.mComponentNum = 0;
if (mRenderListener != null && mContext != null) {
runOnUiThread(new Runnable() {
Expand All @@ -783,6 +786,9 @@ public void run() {
}
});
}
if(!WXEnvironment.isApkDebugable()){
Log.e("weex_perf",mWXPerformance.getPerfData());
}
}

public void onRefreshSuccess(final int width, final int height) {
Expand Down Expand Up @@ -902,7 +908,9 @@ public void run() {
WXLogUtils.d(performance.toString());
}
}
mUserTrackAdapter.commit(mContext, null, type, performance, null);
if( mUserTrackAdapter!= null) {
mUserTrackAdapter.commit(mContext, null, type, performance, null);
}
}
});
}
Expand Down

0 comments on commit d7fae5f

Please sign in to comment.