Commit 40bdcc85 authored by Star Diao's avatar Star Diao

Merge remote-tracking branch 'remotes/origin/master' into release

# Conflicts:
#	README.md
#	platforms/android/GSST/nexus/build.gradle
#	platforms/android/GSST/nexus/src/main/java/com/eros/framework/model/PlatformConfigBean.java
#	platforms/android/GSST/nexus/src/main/java/com/eros/widget/utils/BaseCommonUtil.java
#	platforms/android/GSST/nexus/src/main/java/com/eros/widget/view/BMLoding.java
#	platforms/android/GSST/nexus/src/main/java/com/eros/widget/view/loading/LoadingDialog.java
parents 544be0d1 ce894a8c

Too many changes to show.

To preserve performance only 1000 of ${real_size} files are displayed.

......@@ -95,3 +95,7 @@ Pods
*.xcworkspace
Podfile.lock
# END IOS
/platforms/android/GSST/com.gsst.ddl.store.keystore
/platforms/ios/GSST/GSST/bundle.config
/platforms/ios/GSST/GSST/bundle.zip
/platforms/ios/GSST/GSST/config.native.json
## 介绍
> sl-weex app 安装。
###手脚架安装命令
```
npm install -g sl-weex-cli --registry=http://nexus.gsstcloud.com:8090/nexus/repository/npm-public
```
> sl-weex app 快速开发模板,可通过脚手架 sl-weex-cli `init` 指令快速生成。
### 运行命令:```sl-weex dev```
### 项目构建:```sl-weex build```
### 打包到IOS:```sl-weex pack ios```
### 打包到安卓:```sl-weex pack android```
### 热更新:
``` sl-weex pack -s https://weex-publish.gsstcloud.com/app/add```
......@@ -15,10 +15,10 @@ module.exports = {
},
'url': {
'image': 'http://www.superlinksoft.com/img-company/XXX',
'bundleUpdate': 'http://localhosts:3001/app/check'
'bundleUpdate': 'https://weex-publish.gsstcloud.com/app/check'
},
'zipFolder': {
'iOS': '/ios/LMWeex/LMWeex',
'iOS': '/ios/GSST/GSST',
'android': '/android/GSST/app/src/main/assets'
},
'getui': {
......
......@@ -7,10 +7,10 @@ android {
flavorDimensions 'default'
defaultConfig {
applicationId APPLICATION_ID
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
versionName "1.0.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
......@@ -27,9 +27,9 @@ android {
signingConfigs {
ddlStaff {
keyAlias 'com.gsst.ddl.staff'
keyAlias 'com.gsst.ddl.store'
keyPassword '123qazwsx'
storeFile file('../com.gsst.ddl.staff.keystore')
storeFile file('../com.gsst.ddl.store.keystore')
storePassword '123qazwsx'
v2SigningEnabled false
}
......@@ -115,7 +115,7 @@ dependencies {
// compile 'com.gsst.mobile:gsst-weex-base-library:0.0.04-SNAPSHOT'
compile project(':nexus')
compile project(':weex-framework')
compile project(':gsstJPush')
compile project(':wechatplugin')
// compile project(':gsstJPush')
// compile project(':wechatplugin')
compile project(':pgyplugin')
}
......@@ -34,7 +34,6 @@
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS"/>
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
......@@ -42,9 +41,6 @@
android:name="com.gsst.App"
android:theme="@style/AppTheme.NoActionBar"
>
<activity android:name="com.eros.framework.activity.MainActivity" android:windowSoftInputMode="adjustResize">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
......
"vsTZAbrVE4WzjaMh45cmyMTRpo8pnrFXjK/Fh13RfV2druWzknbKsiZndLNw+pea3518fVjh//yOub1lZcpqguUBMs8QvdtwumTxdDYw6Pd3VWtIOZlKyHC+U6NK/bbMwI13Dz/2aVc6tfLbowXcIGnajYuQ0AsygHM3J1/Vlg8heIbN/Ma1owhjEvucKSal8YjTv7qWpdB9Y88DFilmviC4qRaGyoZWKxz93tp4hwamV8tCQ3rCqIwX3KpibC0cZX2j1F0nXA3dU/NBJo3oTKW1MVpkhPTnhAX6AIyKRiBtOGru8kUAY/NAqOvKqvwptl9oJbVxxBMmxfkr5zHthdLQ84Vc8gYldwwD2AnaHGmGklYmT1ZoGsScAxpucECZekiVbYV1ouLVuD4wpcy5Dq7rDxEX6MDI1QjQzaZUclxa6k/68FX2vJ19ym4aokAdZhW4WkTuO2v1PdUROWkWDBWWeIAizEdv/xCfvG59y+AXNQSvs+A1/geV0wU57THjOtOjMJSh5d36BYlIz+7gLOgkiS11KdAvFdjbsPLIlRsTnr0CKZM6HPWMjXgF87mrNTOoWyINsHxYk6q2byzAyp+I2AOZ9GFW808kGUV5NR25g28wOuNKXKSKGOyYuQjBiDct6vtkI3mN5IVBdBiZVZIaS8neHnsUTKjZuLQ7+AI0OlSCH3eWBgl/fgY3BgBE7ebdoA5UxRSJFrYfIGMEZ6k+HVBmbj6hdMoYakv0C9AXcsQuybtpeIOREifxn0qTSTdpfbnhRtPaQvLMcUc1ZVpZFqMg4SGfg5J1vjsvyPjK1LpDpVJ/MnrDBZjFgjbJ3VpxoJSZLL7nHloZDiL1bfwLBPeTBIV8fcx8/Iki/goKLCDWv8jkzutZ8HHoXxYTHp7nWyb3tOrY7Mrq5EGr4BXZNE+vqnJBgUYoSA8Ekc9EH4hRpV6CQ/FT68HBohbXdvCg0+7uqbluP1ykmMGv+X8xSf6zXhgrt77eONGYZVnSYwMfr4HThrAhjstw99VdepVBhqXz2Vy7BRABXKpC2Q7s1TtWJqQIKmi3aCmelwkpFIxK1OLDSRXXUm9mWG7tAx72jpA+7+QxWDUzocxeYahvJwAHLktWx5dz4DEUhXg="
"oC/SLCquKltHWNWQGXnxlo0WyJf77GB2heMLqxqQ5hhVC//kVtVx1BafVuCsa5NwWGmCg0O2IWxqxm1kcE552E4/S4HamDkiR9cocIzZbkNZmW9whe4QjiatXwgaNV46/H9h2MH5XXOD477MB7bmTQ77Y+NsL4u3u2mYmgsXT1F6w00Luw5JnSs8qs132Va/P12athbXa87VTDrMhhlYIGa3MIRFAj3bmQOsnpDF/x2q0wal4qt0x2QZ54zwVvpRh8C/fZYbNeir04EDakAAY950Uw15urnrJDXPhy+v2QHzkUVV6BWL0Ky1KG37QrhkVoFNchQxOSwd5hIUuXDcjpv6eJt+hoTq35Lg9VzswRA0jfhmnoY5Vej9Z8SxrhRsZoBAqBnJBq22VxoH6Gz5sJ4Q0H4qg8LL/ajlcwWtkjhz2DxMCTwmC067dT3zSFsFtQzzNtdKMMgQr4LVlilxVivum54cb3bg1rsco832i9xJTlEgGD0JplEfNshz/bsKpHZFfSqq7cgsg+VtEyaqLSLsfLhdD7DcexD0q7BQS7MzBMdesHnsHY6cjSsHv3ehjjJfH4elG4HehGXNAr6JRJHbBVCRlnzih/wUAnI7bCPJnP8YpbUEaGSz2zKA06087jWAcfXm6ojR6rgAvQsyO0TgA2zSXlhWRjBrtC0ebsFWB4pLjfV2nvV8YCiBFI0P6XNwz5hleVE2+AJzTE5/9yUl+JR+HnKjpBRipDPZuTsqT8iZeyaQylbL0I7wx6AThtNsZWwqJJp6WkrolRKe947pcCYk7UARWlqWZBl39SvxFBsZQ522uODmG9YdzqQznROy1UcFORUe68q68aDkndBlyAe1Hvs3LUma3nwwu3acneTlFk+NTw13Qy2UIPZuYLZMDbR6RO4q3X1dG7dB3Fo4bdHAlj9EE4Aqsywg6xLCuo+Sl1GDsuUTFeBpHi7nFXgasEnd/9rNM94wDtLFcxjU5s3bfJxAJ/4Ilb6fPhPUfaM9cCNLx7Y73jZd96k7VMDb349C3nwPCeyZvpCQ6irhfAsLhtrgJ6wtEWCjIZPmojKMyrJedtUUGCKgvSaMvG9URaU8CTD0xDMZGg/LxEKaepoz7UbWRNlVWC3HYI41e+TJ13LHvtMU95ex1G0e5NgUenK2lbdRCdw+MKCVyecpLn+/0PQWm+Znv8B7M/cLQKZbSjz1UqNWxuE7IRKIrBVwyDGmXJI69cWDCFFXV8H8hBKJHdq7UUgoz1UPZwg="
......@@ -2,6 +2,7 @@ package com.gsst.activity;
import android.app.Activity;
import android.os.Bundle;
import android.view.WindowManager;
import com.eros.framework.proxy.SplashActivityProxy;
import com.gsst.clotee.R;
......@@ -19,6 +20,13 @@ public class SplashActivity extends Activity {
setContentView(R.layout.activity_splash);
activityProxy = new SplashActivityProxy();
activityProxy.onCreateInit(this);
SystemUIUtils.setStickFullScreen(getWindow().getDecorView());
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(hasFocus);
SystemUIUtils.setStickFullScreen(getWindow().getDecorView());
}
@Override
......
package com.gsst.activity;
import android.view.View;
class SystemUIUtils {
public static void setStickFullScreen(View view) {
int systemUiVisibility = view.getSystemUiVisibility();
int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
systemUiVisibility |= flags;
view.setSystemUiVisibility(systemUiVisibility);
}
}
......@@ -2,5 +2,5 @@
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorAccent">#2db7f5</color>
</resources>
<resources>
<string name="app_name">店店联:服务人员</string>
<string name="app_name">店店联</string>
<string name="umeng_socialize_female"></string>
<string name="umeng_socialize_male"></string>
</resources>
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-yingyongbao-release.apk","properties":{"packageId":"com.gsst.ddlstaff","split":"","minSdkVersion":"16"}}]
\ No newline at end of file
[{"outputType":{"type":"APK"},"apkInfo":{"type":"MAIN","splits":[],"versionCode":1},"path":"app-yingyongbao-release.apk","properties":{"packageId":"com.gsst.ddl.store","split":"","minSdkVersion":"17"}}]
\ No newline at end of file
......@@ -7,7 +7,7 @@ android {
defaultConfig {
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
......@@ -29,8 +29,9 @@ android {
}
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
implementation 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
androidTestCompile('com.android.support.test.espresso:espresso-core:3.0.2', {
exclude group: 'com.android.support', module: 'support-annotations'
......@@ -38,23 +39,23 @@ dependencies {
/**
* debug调试要用到的
*/
compile 'com.taobao.android.weex_inspection:protocol:1.1.4.1'
compile 'com.taobao.android:weex_inspector:0.13.4'
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.8.0'
compile 'com.lzy.widget:imagepicker:0.6.1'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
compile 'com.github.chrisbanes.photoview:library:1.2.4'
compile 'com.android.support:multidex:1.0.1'
implementation 'com.taobao.android.weex_inspection:protocol:1.1.4.1'
implementation 'com.taobao.android:weex_inspector:0.13.4'
implementation 'com.squareup.okhttp:okhttp-ws:2.3.0'
implementation 'com.squareup.okhttp3:okhttp:3.8.0'
implementation 'com.lzy.widget:imagepicker:0.6.1'
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
implementation 'com.github.chrisbanes.photoview:library:1.2.4'
implementation 'com.android.support:multidex:1.0.1'
//bs patch
compile 'me.ele:bspatch:1.0.6'
implementation 'me.ele:bspatch:1.0.6'
//weex analyzer
compile 'com.taobao.android:weex_analyzer:0.1.0.5'
implementation 'com.taobao.android:weex_analyzer:0.1.0.5'
//Bindigx
compile 'com.alibaba.android:bindingx-core:1.0.1'
compile 'com.alibaba.android:bindingx_weex_plugin:1.0.2'
compile 'org.weex.plugin:plugin-loader:1.0.0'
compile ('com.github.niorgai:StatusBarCompat:2.1.4', {
implementation 'com.alibaba.android:bindingx-core:1.0.1'
implementation 'com.alibaba.android:bindingx_weex_plugin:1.0.2'
implementation 'org.weex.plugin:plugin-loader:1.0.0'
compile('com.github.niorgai:StatusBarCompat:2.1.4', {
exclude group: 'com.android.support'
})
// compile 'com.gsst.mobile:gsst-weex-base-plugin:0.0.03-SNAPSHOT'
......@@ -62,7 +63,6 @@ dependencies {
compile project(':nexus')
// debugImplementation "com.squareup.leakcanary:leakcanary-android:1.5.4"
// releaseImplementation "com.squareup.leakcanary:leakcanary-android-no-op:1.5.4"
}
......
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.eros.framework">
<application
tools:replace="android:allowBackup"
android:allowBackup="false"
android:label="@string/app_name"
android:supportsRtl="true"></application>
android:supportsRtl="true"
tools:replace="android:allowBackup">
<activity android:name=".activity.SubDisplayActivity"></activity>
</application>
</manifest>
</manifest>
\ No newline at end of file
......@@ -156,6 +156,12 @@ public class AbstractWeexActivity extends AppCompatActivity implements IWXRender
}
@Override
public void onWindowFocusChanged(boolean hasFocus) {
super.onWindowFocusChanged(true);
setStickFullScreen(getWindow().getDecorView());
}
private void initDebug() {
if (!DebugableUtil.isDebug()) return;
......@@ -930,20 +936,34 @@ public class AbstractWeexActivity extends AppCompatActivity implements IWXRender
}
public void statusBarHidden(boolean isFullScreen){
if (isFullScreen) {
setFullScreen(this);
} else {
quitFullScreen(this);
}
setFullScreen(this);
// if (isFullScreen) {
// setFullScreen(this);
// } else {
// quitFullScreen(this);
// }
}
private void setFullScreen(Activity activity) {
if (!isStatusBarHidden) {
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
activity.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN , WindowManager.LayoutParams.FLAG_FULLSCREEN);
isStatusBarHidden = true;
setStickFullScreen(getWindow().getDecorView());
}
}
public static void setStickFullScreen(View view) {
int systemUiVisibility = view.getSystemUiVisibility();
int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
systemUiVisibility |= flags;
view.setSystemUiVisibility(systemUiVisibility);
}
private void quitFullScreen(Activity activity) {
if (isStatusBarHidden) {
......
......@@ -4,10 +4,15 @@ import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.ActivityInfo;
import android.hardware.display.DisplayManager;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.content.LocalBroadcastManager;
import android.util.Log;
import android.view.Display;
import android.view.KeyEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewStub;
import android.view.WindowManager;
......@@ -22,10 +27,12 @@ import com.eros.framework.manager.impl.GlobalEventManager;
import com.eros.framework.model.RouterModel;
import com.eros.framework.model.TabbarBadgeModule;
import com.eros.framework.model.WeexEventBean;
import com.eros.framework.presentation.SubDisplay;
import com.eros.framework.utils.SharePreferenceUtil;
import com.eros.framework.view.TableView;
import com.taobao.weex.WXSDKEngine;
import com.taobao.weex.WXSDKInstance;
import com.taobao.weex.utils.WXLogUtils;
public class MainActivity extends AbstractWeexActivity {
private FrameLayout layout_container;
......@@ -38,6 +45,8 @@ public class MainActivity extends AbstractWeexActivity {
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// hideBottomUIMenu();
// AndroidBug5497Workaround.assistActivity(this);
routerModel = (RouterModel) getIntent().getSerializableExtra(Constant.ROUTERPARAMS);
if (Constant.TABBAR.equals(routerModel.url)) {
......@@ -50,7 +59,29 @@ public class MainActivity extends AbstractWeexActivity {
initReloadReceiver();
statusBarHidden(BMWXApplication.getWXApplication().IS_FULL_SCREEN);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
// 副屏内容展示
Display display = getPresentationDisplays();
if(display != null){
SubDisplay textDisplay = new SubDisplay(this, display);
textDisplay.show();
}
}
// protected void hideBottomUIMenu() {
// //隐藏虚拟按键,并且全屏
// if (Build.VERSION.SDK_INT > 11 && Build.VERSION.SDK_INT < 19) { // lower api
// View v = this.getWindow().getDecorView();
// v.setSystemUiVisibility(View.GONE);
// } else if (Build.VERSION.SDK_INT >= 19) {
// //for new api versions.
// View decorView = getWindow().getDecorView();
// int uiOptions = View.SYSTEM_UI_FLAG_HIDE_NAVIGATION
// | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY | View.SYSTEM_UI_FLAG_FULLSCREEN;
// decorView.setSystemUiVisibility(uiOptions);
// }
// }
private void initReloadReceiver() {
......@@ -142,6 +173,22 @@ public class MainActivity extends AbstractWeexActivity {
return -1;
}
// 获取副屏
public Display getPresentationDisplays() {
DisplayManager manager = (DisplayManager) getSystemService(Context.DISPLAY_SERVICE);
Display[] displays = manager.getDisplays();
for (int i = 0; i < displays.length; i++) {
Log.e("SUB_DISPLAY", "屏幕" + displays[i]);
if ((displays[i].getFlags() & Display.FLAG_SECURE) != 0
&& (displays[i].getFlags() & Display.FLAG_SUPPORTS_PROTECTED_BUFFERS) != 0
&& (displays[i].getFlags() & Display.FLAG_PRESENTATION) != 0) {
Log.e("SUB_DISPLAY", "第一个真实存在的副屏屏幕" + displays[i]);
return displays[i];
}
}
return null;
}
@Override
protected void onDestroy() {
super.onDestroy();
......
package com.eros.framework.activity;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import com.eros.framework.R;
public class SubDisplayActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub_display);
}
}
......@@ -104,6 +104,7 @@ public class ModalManager extends Manager {
Toast mToast = Toast.makeText(context, message, duration);
mToast.setDuration(duration);
mToast.setText(message);
mToast.setGravity(Gravity.CENTER, 0, 0);
mToast.show();
} else {
Log.i("BMModalManager", "toast can not show in child thread");
......
......@@ -3,6 +3,7 @@ package com.eros.framework.manager.impl;
import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.util.Log;
import com.eros.framework.BMWXEnvironment;
import com.eros.framework.constant.Constant;
......@@ -28,6 +29,7 @@ import java.util.HashMap;
*/
public class VersionManager extends Manager {
private static final String TAG = "VersionManager";
public long prepareJsBundle(Context context) {
long startTime = new Date().getTime();
......@@ -138,6 +140,7 @@ public class VersionManager extends Manager {
params.put("appName", BMWXEnvironment.mPlatformConfig.getAppName());
params.put("android", BaseCommonUtil.getVersionName(context));
String versionInfo = SharePreferenceUtil.getDownLoadVersion(context);
Log.e(TAG, "getDownLoadVersion:" + versionInfo);
if (TextUtils.isEmpty(versionInfo)) {
versionInfo = SharePreferenceUtil.getVersion(context);
}
......@@ -151,6 +154,7 @@ public class VersionManager extends Manager {
versionInfo = "";
} else {
versionInfo = jsVersionInfoBean.getJsVersion();
Log.e(TAG, "versionInfo:" + versionInfo);
}
}
if (TextUtils.isEmpty(versionInfo)) {
......@@ -164,6 +168,7 @@ public class VersionManager extends Manager {
public void downloadBundle(String url, FileCallBack fileCallBack) {
AxiosManager axiosManager = ManagerFactory.getManagerService(AxiosManager.class);
Log.e(TAG, "下载包:" + url);
axiosManager.download(url, fileCallBack);
}
......
package com.eros.framework.presentation;
import android.app.Presentation;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.view.Display;
import android.widget.ImageView;
import com.eros.framework.R;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;
public class SubDisplay extends Presentation {
private static final String TAG = "SubDisplay";
private ImageView imageView;
final String url = "https://file.cdn.sunmi.com/newebsite/home/P2Pro-banner-PC.jpg";
public SubDisplay(Context outerContext, Display display){
super(outerContext, display);
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_sub_display);
imageView = (ImageView) findViewById(R.id.sub_display2);
// new Thread(new Runnable() {
// @Override
// public void run() {
// Bitmap bmp = getURLimage(url);
// Message msg = new Message();
// msg.what = 0;
// msg.obj = bmp;
// System.out.println("000");
// handle.sendMessage(msg);
// }
// }).start();
}
//在消息队列中实现对控件的更改
private Handler handle = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
System.out.println("111");
Bitmap bmp=(Bitmap)msg.obj;
imageView.setImageBitmap(bmp);
break;
}
}
};
//加载图片
public Bitmap getURLimage(String url) {
Bitmap bmp = null;
try {
URL myurl = new URL(url);
// 获得连接
HttpURLConnection conn = (HttpURLConnection) myurl.openConnection();
conn.setConnectTimeout(6000);//设置超时
conn.setDoInput(true);
conn.setUseCaches(false);//不缓存
conn.connect();
InputStream is = conn.getInputStream();//获得图片的数据流
bmp = BitmapFactory.decodeStream(is);//读取图像数据
//读取文本数据
//byte[] buffer = new byte[100];
//inputStream.read(buffer);
//text = new String(buffer);
is.close();
} catch (Exception e) {
e.printStackTrace();
}
return bmp;
}
}
package com.eros.framework.proxy;
import android.view.View;
class SystemUIUtils {
public static void setStickFullScreen(View view) {
int systemUiVisibility = view.getSystemUiVisibility();
int flags = View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION
| View.SYSTEM_UI_FLAG_LAYOUT_STABLE
| View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN
| View.SYSTEM_UI_FLAG_HIDE_NAVIGATION // hide nav bar
| View.SYSTEM_UI_FLAG_FULLSCREEN // hide status bar
| View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
systemUiVisibility |= flags;
view.setSystemUiVisibility(systemUiVisibility);
}
}
......@@ -30,12 +30,14 @@ import com.eros.framework.utils.SharePreferenceUtil;
import com.squareup.otto.Subscribe;
import java.io.File;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Collections;
import java.util.List;
import me.ele.patch.BsPatch;
import okhttp3.Call;
import okhttp3.Response;
/**
* Created by Carry on 2017/11/23.
......@@ -58,7 +60,7 @@ public class VersionChecker {
public void checkVersion() {
if (mCurrentStatus == Constant.Version.UPDATING || mCustomerUpdate) return;
readyUpdate(null, true);
readyUpdate(null, false);
}
......@@ -93,12 +95,14 @@ public class VersionChecker {
Activity activity = RouterTracker.peekActivity();
//此时说明栈中没有可用activity 监听入栈事件
if (activity != null) {
Log.e(TAG, "弹出更新提示");
ModalManager.BmAlert.showAlert(activity, mContext.getResources()
.getString(R.string.str_update_title), mContext.getResources()
.getString(R.string.str_update_tips), mContext.getResources().getString(R.string
.str_ensure), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Log.e(TAG, "重启");
restartApp();
}
}, null, null, null, null, false);
......@@ -136,7 +140,7 @@ public class VersionChecker {
post(9, msg);
}
private void readyUpdate(String path, boolean diff) {
private void readyUpdate(String path, final boolean diff) {
mUpdateUrl = BMWXEnvironment.mPlatformConfig.getUrl().getBundleUpdate();
if (!TextUtils.isEmpty(path)) {
mUpdateUrl = path;
......@@ -150,6 +154,7 @@ public class VersionChecker {
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
versionManager.checkBundleUpdate(mContext, mUpdateUrl,
diff, new StringCallback() {
final Boolean _diff = diff;
@Override
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "获取更新失败");
......@@ -157,6 +162,11 @@ public class VersionChecker {
mCurrentStatus = Constant.Version.SLEEP;
}
@Override
public String parseNetworkResponse(Response response, int id) throws IOException {
return super.parseNetworkResponse(response, id);
}
@Override
public void onResponse(String response, int id) {
VersionBean version = ManagerFactory.getManagerService(ParseManager
......@@ -179,12 +189,12 @@ public class VersionChecker {
} else {
//下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
downloadCompleteZip(_diff);
}
} else {
//下载全量包
Log.e(TAG, "检查全量包");
downloadCompleteZip();
downloadCompleteZip(_diff);
}
break;
case 401:
......@@ -214,8 +224,9 @@ public class VersionChecker {
/**
* 下载全量包
*/
private void downloadCompleteZip() {
private void downloadCompleteZip(Boolean diff) {
VersionManager versionManager = ManagerFactory.getManagerService(VersionManager.class);
final Boolean _diff = diff;
versionManager.checkBundleUpdate(mContext, mUpdateUrl,
false, new StringCallback() {
@Override
......@@ -232,7 +243,7 @@ public class VersionChecker {
.class);
if (version != null && !TextUtils.isEmpty(version.data.path)) {
L.e(TAG, "检查全量包成功!,开始下载");
download(version, true);
download(version, _diff);
}
}
});
......@@ -255,7 +266,7 @@ public class VersionChecker {
public void onError(Call call, Exception e, int id) {
Log.e(TAG, "下载插分包出错");
if (!complete) {
downloadCompleteZip();
downloadCompleteZip(complete);
} else {
postFailed("下载全量包失败");
mCurrentStatus = Constant.Version.SLEEP;
......@@ -271,6 +282,7 @@ public class VersionChecker {
File download = new File(FileManager.getTempBundleDir(mContext)
, FileManager.TEMP_BUNDLE_NAME);
if (checkZipValidate(download)) {
Log.e(TAG, "更新包md5校验成功");
RenameDeleteFile();
//更改本地jsversion
SharePreferenceUtil.setDownLoadVersion(mContext,
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".activity.SubDisplayActivity"
>
<ImageView
android:id="@+id/sub_display2"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:src="@drawable/sub_display"
/>
</LinearLayout>
\ No newline at end of file
......@@ -2,6 +2,6 @@
<resources>
<color name="colorPrimary">#3F51B5</color>
<color name="colorPrimaryDark">#303F9F</color>
<color name="colorAccent">#FF4081</color>
<color name="colorAccent">#2db7f5</color>
<color name="msg_point_red">#ff1300</color>
</resources>
org.gradle.jvmargs=-Xmx1536m
android.enableAapt2=false
APPLICATION_ID=com.gsst.ddl.staff
APPLICATION_ID=com.gsst.ddl.store
GRADLE_TOOL_VERSION=3.0.0
GRADLE_VERSION=https\://services.gradle.org/distributions/gradle-4.1-all.zip
MIN_SDK_VERSION=14
......@@ -30,6 +30,46 @@ PROJECT_SUPPORTLIBVERSION=25.3.1
......
apply plugin: 'com.android.library'
android {
compileSdkVersion 25
defaultConfig {
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions { annotationProcessorOptions { includeCompileClasspath = true } }
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '26.0.2'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
compile "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
// compile project(':nexus')
compile 'cn.jiguang.sdk:jpush:3.1.6' // 此处以JPush 3.1.6 版本为例。
compile 'cn.jiguang.sdk:jcore:1.2.5' // 此处以JCore 1.2.5 版本为例。
compile project(':nexus')
compile project(':weex-framework')
}
repositories {
mavenCentral()
google()
maven { url 'http://192.168.12.122:8090/nexus/repository/maven-snapshots/' }
}
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontnote
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.app.IntentService
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-dontwarn cn.jpush.**
-keep class cn.jpush.** { *; }
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="com.gsst.eros" >
<!--jpush-->
<permission
android:name="com.eros.wx.permission.JPUSH_MESSAGE"
android:protectionLevel="signature" />
<!-- Required 一些系统要求的权限,如访问网络等-->
<uses-permission android:name="com.eros.wx.permission.JPUSH_MESSAGE" />
<uses-permission android:name="android.permission.RECEIVE_USER_PRESENT" />
<uses-permission android:name="android.permission.WRITE_SETTINGS" />
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS" />
<uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<application>
<!-- Required SDK 核心功能-->
<!-- 可配置android:process参数将PushService放在其他进程中 -->
<service
android:name="cn.jpush.android.service.PushService"
android:process=":pushcore"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTER" />
<action android:name="cn.jpush.android.intent.REPORT" />
<action android:name="cn.jpush.android.intent.PushService" />
<action android:name="cn.jpush.android.intent.PUSH_TIME" />
</intent-filter>
</service>
<receiver
android:name="com.gsst.plugin.JPushErosPlugin$JPushReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.REGISTRATION" /> <!--Required 用户注册SDK的intent-->
<action android:name="cn.jpush.android.intent.MESSAGE_RECEIVED" /> <!--Required 用户接收SDK消息的intent-->
<action android:name="cn.jpush.android.intent.NOTIFICATION_RECEIVED" /> <!--Required 用户接收SDK通知栏信息的intent-->
<action android:name="cn.jpush.android.intent.NOTIFICATION_OPENED" /> <!--Required 用户打开自定义通知栏的intent-->
<action android:name="cn.jpush.android.intent.ACTION_RICHPUSH_CALLBACK" /> <!--Optional 用户接受Rich Push Javascript 回调函数的intent-->
<action android:name="cn.jpush.android.intent.CONNECTION" /><!-- 接收网络变化 连接/断开 since 1.6.3 -->
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
<!-- User defined. For test only 用户自定义接收消息器,3.0.7开始支持,目前新tag/alias接口设置结果会在该广播接收器对应的方法中回调 暂时无用-->
<receiver android:name="com.gsst.plugin.JPushErosPlugin$MyJPushMessageReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="cn.jpush.android.intent.RECEIVE_MESSAGE" />
<category android:name="${applicationId}" />
</intent-filter>
</receiver>
</application>
</manifest>
package com.gsst.plugin;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.provider.OpenableColumns;
import android.util.Log;
import com.alibaba.weex.plugin.annotation.WeexModule;
import com.eros.framework.constant.WXEventCenter;
import com.eros.framework.event.mediator.EventCenter;
import com.eros.framework.manager.ManagerFactory;
import com.eros.framework.manager.impl.dispatcher.DispatchEventManager;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.common.WXModule;
import java.util.HashMap;
import java.util.Map;
import javax.security.auth.callback.Callback;
import cn.jpush.android.api.JPushInterface;
import cn.jpush.android.api.JPushMessage;
import cn.jpush.android.service.JPushMessageReceiver;
/**
* Created by liuyuanxiao on 2018/5/4.
*/
@WeexModule(name = "jpushWeexPlugin", lazyLoad = true)
public class JPushErosPlugin extends WXModule {
private static Bundle mCachedBundle;
private static Bundle mRidBundle;
private final static String RECEIVE_NOTIFICATION = "receiveNotification";
private final static String RECEIVE_NOTIFICATION_OPEN = "receiveNotificationOpen";
private final static String RECEIVE_CUSTOM_MESSAGE = "receivePushMsg";
private final static String OPEN_NOTIFICATION = "openNotification";
private final static String RECEIVE_REGISTRATION_ID = "getRegistrationId";
private final static String CONNECTION_CHANGE = "connectionChange";
@JSMethod(uiThread = true)
public void setup(JSCallback receiveNotificationCallback,JSCallback receiveNotificationOpenCallback) {
// Toast.makeText(mWXSDKInstance.getContext(), "Hello Eros test Plugin", Toast.LENGTH_LONG).show();
JPushInterface.init(mWXSDKInstance.getContext());
//接收消息被打开时的推送事件
EventCenter.Event openNotifyEvent = new EventCenter.Event(mWXSDKInstance.getInstanceId(),
false, receiveNotificationOpenCallback, mWXSDKInstance.getBundleUrl(), RECEIVE_NOTIFICATION_OPEN);
Intent on = new Intent(WXEventCenter.EVENT_JS_ON);
on.putExtra("data", openNotifyEvent);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(on);
//接收消息时的推送事件(普通消息,自定义消息)
EventCenter.Event notifyEvent = new EventCenter.Event(mWXSDKInstance.getInstanceId(),
false, receiveNotificationCallback, mWXSDKInstance.getBundleUrl(), RECEIVE_NOTIFICATION);
Intent inten = new Intent(WXEventCenter.EVENT_JS_ON);
inten.putExtra("data", notifyEvent);
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(inten);
Log.i("PLUGIN","init jpush") ;
}
@JSMethod(uiThread = true)
public void applyPushAuthority(){
JPushInterface.requestPermission(mWXSDKInstance.getContext());
}
@JSMethod(uiThread = true)
public void getLaunchAppNotification(){
}
@JSMethod(uiThread = true)
public void getRegistrationID(JSCallback callback){
Map<String,String> message = new HashMap<>() ;
String registrationID = "" ;
registrationID = JPushInterface.getRegistrationID(mWXSDKInstance.getContext()) ;
if((!"".equals(registrationID)) && registrationID != null){
callback.invoke(registrationID);
}
}
public static class JPushReceiver extends BroadcastReceiver {
public JPushReceiver() {
}
@Override
public void onReceive(Context context, Intent data) {
if (JPushInterface.ACTION_MESSAGE_RECEIVED.equals(data.getAction())) {
mCachedBundle = data.getExtras();
try {
String message = data.getStringExtra(JPushInterface.EXTRA_MESSAGE);
Intent emit = new Intent( WXEventCenter.EVENT_JS_EMIT);
emit.putExtra("data", new EventCenter.Emit(RECEIVE_CUSTOM_MESSAGE, message));
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(emit);
} catch (Exception e) {
e.printStackTrace();
}
}
else if (JPushInterface.ACTION_NOTIFICATION_RECEIVED.equals(data.getAction())) {
//收到推送下来的通知
mCachedBundle = data.getExtras();
try {
// 通知内容
String alertContent = mCachedBundle.getString(JPushInterface.EXTRA_ALERT);
// extra 字段的 json 字符串
String extras = mCachedBundle.getString(JPushInterface.EXTRA_EXTRA);
} catch (Exception e) {
e.printStackTrace();
}
} else if (JPushInterface.ACTION_NOTIFICATION_OPENED.equals(data.getAction())) {
mCachedBundle = data.getExtras();
try {
//用户点击打开了通知
// 通知内容
String alertContent = mCachedBundle.getString(JPushInterface.EXTRA_ALERT);
// extra 字段的 json 字符串
String extras = mCachedBundle.getString(JPushInterface.EXTRA_EXTRA);
//初始化activity
Intent intent = context.getPackageManager().getLaunchIntentForPackage(context.getPackageName());
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP | Intent.FLAG_ACTIVITY_CLEAR_TOP);
intent.putExtras(mCachedBundle);
context.startActivity(intent);
//发送事件
Intent emit = new Intent( WXEventCenter.EVENT_JS_EMIT);
emit.putExtra("data", new EventCenter.Emit(RECEIVE_NOTIFICATION_OPEN, extras));
ManagerFactory.getManagerService(DispatchEventManager.class).getBus().post(emit);
} catch (Exception e) {
e.printStackTrace();
}
// 应用注册完成后会发送广播,在 JS 中 JPushModule.addGetRegistrationIdListener 接口可以第一时间得到 registrationId
// After JPush finished registering, will send this broadcast, use JPushModule.addGetRegistrationIdListener
// to get registrationId in the first instance.
} else if (JPushInterface.ACTION_REGISTRATION_ID.equals(data.getAction())) {
mRidBundle = data.getExtras();
try {
} catch (Exception e) {
e.printStackTrace();
}
} else if (JPushInterface.ACTION_CONNECTION_CHANGE.equals(data.getAction())) {
try {
} catch (Exception e) {
e.printStackTrace();
}
}
}
}
//暂时无用
public static class MyJPushMessageReceiver extends JPushMessageReceiver {
@Override
public void onTagOperatorResult(Context context, JPushMessage jPushMessage) {
String log = "action - onTagOperatorResult, sequence:" + jPushMessage.getSequence()
+ ", tags: " + jPushMessage.getTags();
super.onTagOperatorResult(context, jPushMessage);
}
@Override
public void onCheckTagOperatorResult(Context context,JPushMessage jPushMessage){
String log = "action - onCheckTagOperatorResult, sequence:" + jPushMessage.getSequence()
+ ", checktag: " + jPushMessage.getCheckTag();
super.onCheckTagOperatorResult(context, jPushMessage);
}
@Override
public void onAliasOperatorResult(Context context, JPushMessage jPushMessage) {
String log = "action - onAliasOperatorResult, sequence:" + jPushMessage.getSequence()
+ ", alias: " + jPushMessage.getAlias();
super.onAliasOperatorResult(context, jPushMessage);
}
}
}
<resources>
<string name="app_name">pluginSimple</string>
</resources>
......@@ -14,10 +14,10 @@ android {
buildToolsVersion '26.0.2'
defaultConfig {
minSdkVersion 16
minSdkVersion 17
targetSdkVersion 25
versionCode 1
versionName "1.0"
versionName "1.0.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
......@@ -45,8 +45,10 @@ dependencies {
compile "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBV_NEXUS}"
compile 'com.alibaba:fastjson:1.1.68.android'
// compile 'com.taobao.android:weex_sdk:0.18.0'
// compile project(':sdk')
compile 'com.gsst.mobile:gsst-weex-base-sdk:0.0.02-SNAPSHOT'
// implementation 'org.apache.weex:sdk:0.28.0'
compile project(':sdk')
// compile 'com.gsst.mobile:gsst-weex-base-sdk:0.0.02-SNAPSHOT'
// compile project(':weex-framework')
compile 'com.squareup.okhttp:okhttp-ws:2.3.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
......
## Unit Test
Unit test code is under 'src/test'. You can run unit test use command:
```bash
./gradlew clean testDebugUnitTest jacocoTestReportDebug
```
This task will run all unit test and produce both unit test report and jacoco test coverage report in 'build/reports'.
This source diff could not be displayed because it is too large. You can view the blob instead.
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.vanniktech:gradle-android-junit-jacoco-plugin:0.5.0'
}
}
plugins {
id "com.github.hierynomus.license" version "0.14.0"
}
apply plugin: 'com.android.library'
apply plugin: 'checkstyle'
apply plugin: 'com.github.dcendents.android-maven'
group='myliuyx'
ext.disableCov = project.hasProperty('disableCov') ? project.getProperty('disableCov') : 'false'
if(!disableCov.toBoolean()){
apply plugin: 'com.vanniktech.android.junit.jacoco'
junitJacoco {
excludes = ['com/taobao/weex/dom/flex/**','com/taobao/weex/ui/view/refresh/circlebar/**']
}
}
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/config/quality/checkstyle.xml") // Where my checkstyle config is...
// configProperties.checkstyleSuppressionsPath = file("${project.rootDir}/config/quality/checkstyle/suppressions.xml").absolutePath // Where is my suppressions file for checkstyle is...
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/test/**'
exclude '**/com/taobao/weex/dom/flex/**'
classpath = files()
}
checkstyle {
toolVersion = '6.9'
}
version = "0.18.0"
android {
compileSdkVersion COMPILE_SDK_VERSION as int
buildToolsVersion BUILD_TOOLS_VERSION
resourcePrefix "weex"
useLibrary 'org.apache.http.legacy'
copy {
from '../../pre-build'
into new File(projectDir,"assets")
include 'native-bundle-main.js'
rename('native-bundle-main.js','main.js')
}
def line
new File(projectDir,"assets/main.js").withReader { line = it.readLine() }
def m = line =~ /[A-Z\s]+\s+([0-9\.]+),\s+Build\s+[0-9]+/;
def jsfmVersion = m[0][1]
println jsfmVersion
if(project.hasProperty('asfRelease')){
//download so file if not exist, when compile in source release
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/armeabi/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/armeabi/libweexjsc.so"
overwrite false
}
download{
src 'https://git-wip-us.apache.org/repos/asf?p=incubator-weex.git;a=blob_plain;f=android/sdk/libs/x86/libweexjsc.so;hb=refs/heads/master'
dest "${projectDir}/libs/x86/libweexjsc.so"
overwrite false
}
}
def ARMEABI_Size = new File(projectDir,"libs/armeabi/libweexjsc.so").length();
def X86_Size = new File(projectDir,"libs/x86/libweexjsc.so").length();
println "ARMEABI_Size: "+ARMEABI_Size;
println "X86_Size:" + X86_Size;
defaultConfig {
buildConfigField "long", "ARMEABI_Size", "${ARMEABI_Size}"
buildConfigField "long", "X86_Size", "${X86_Size}"
buildConfigField "String", "buildJavascriptFrameworkVersion", "\"${jsfmVersion}\""
buildConfigField "String", "buildVersion", "\"${version}\""
minSdkVersion 14
targetSdkVersion TARGET_SDK_VERSION as int
versionCode 1
versionName "1.0"
javaCompileOptions.annotationProcessorOptions.includeCompileClasspath = true
ndk {
abiFilters "armeabi","x86"
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "boolean", "ENABLE_TRACE", "false"
}
debug {
testCoverageEnabled true
buildConfigField "boolean", "ENABLE_TRACE", "true"
}
}
sourceSets {
main {
assets.srcDirs = ['assets']
jniLibs.srcDir(['libs'])
java {
srcDirs = ["src/main/java"];
}
}
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
compileOptions.encoding = "UTF-8"
lintOptions {
abortOnError false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
testOptions {
unitTests.returnDefaultValues = true
unitTests.all {
maxHeapSize = "1024m"
jvmArgs += ['-XX:-UseSplitVerifier', '-noverify','-Xverify:none']/* fix VerifyError */
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
provided "com.android.support:recyclerview-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:support-v4:${PROJECT_SUPPORTLIBVERSION}"
provided "com.android.support:appcompat-v7:${PROJECT_SUPPORTLIBVERSION}"
provided "com.alibaba:fastjson:1.1.46.android"
testCompile "com.alibaba:fastjson:1.1.46.android"
testCompile 'junit:junit:4.12'
testCompile 'org.hamcrest:hamcrest-core:1.3'
testCompile 'org.javassist:javassist:3.20.0-GA'
testCompile 'org.mockito:mockito-core:1.10.19'
testCompile 'org.objenesis:objenesis:2.1'
testCompile 'org.powermock:powermock-core:1.6.4'
testCompile 'org.powermock:powermock-api-mockito:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-common:1.6.4'
testCompile 'org.powermock:powermock-module-junit4:1.6.4'
testCompile 'org.powermock:powermock-module-junit4-legacy:1.6.4'
testCompile 'org.powermock:powermock-module-testng:1.6.4'
testCompile 'org.powermock:powermock-classloading-xstream:1.6.4'
testCompile "org.powermock:powermock-module-junit4-rule:1.6.4"
testCompile 'org.robolectric:robolectric:3.3.2'
testCompile "org.robolectric:shadows-httpclient:3.3.2"
testCompile 'org.json:json:20160212'
}
if(file('../license/LICENSE').exists()){
license {
header = file('../license/LICENSE')
excludes(["com/taobao/weex/dom/flex/*.java"])
}
preBuild.dependsOn licenseFormat
}
This diff is collapsed.
# Project-wide Gradle settings.
# IDE (e.g. Android Studio) users:
# Gradle settings configured through the IDE *will override*
# any settings specified in this file.
# For more details on how to configure your build environment visit
# http://www.gradle.org/docs/current/userguide/build_environment.html
# Specifies the JVM arguments used for the daemon process.
# The setting is particularly useful for tweaking memory settings.
# Default value: -Xmx10248m -XX:MaxPermSize=256m
# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.useDeprecatedNdk=true
org.gradle.daemon=false
org.gradle.parallel=false
org.gradle.jvmargs=-Xmx2048M
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/ouy/Library/AndroidStudio/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep class com.taobao.weex.bridge.** { *; }
-dontwarn com.taobao.weex.bridge.**
#!/usr/bin/env bash
./gradlew clean assemble publish
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
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.
-->
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.taobao.weappplus_sdk"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="21"/>
<application>
<receiver
android:name="com.taobao.weex.WXGlobalEventReceiver"
android:enabled="true"
android:exported="false">
</receiver>
</application>
</manifest>
\ No newline at end of file
/**
* 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.taobao.weex;
import android.view.View;
import com.taobao.weex.ui.component.WXComponent;
/**
* Created by sospartan on 14/06/2017.
*/
public interface ComponentObserver {
/**
* Called after component is create.
* Notice: View is not created at this moment.
* @param component
*/
void onCreate(WXComponent component);
/**
* Called before component destroy.
* @param component
*/
void onPreDestory(WXComponent component);
/**
* Called when component's view is created
* @param component
* @param view
*/
void onViewCreated(WXComponent component,View view);
}
/*
* 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.taobao.weex;
/**
* Listener class for activity lifecycle
*/
@Deprecated
public interface IWXActivityStateListener {
void onActivityCreate();
void onActivityStart();
void onActivityPause();
void onActivityResume();
void onActivityStop();
void onActivityDestroy();
boolean onActivityBack();
}
/*
* 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.taobao.weex;
import android.view.View;
public interface IWXRenderListener {
/**
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ASYNC} is applied, this method
* will be invoked when the rendering of first view is finish.
* If {@link com.taobao.weex.common.WXRenderStrategy#APPEND_ONCE} is applied, this method will
* be invoked when the rendering of the view tree is finished.
*/
void onViewCreated(WXSDKInstance instance, View view);
/**
* Called when the render view phase of weex has finished.
* It can be invoked at most once in the entire life of a {@link WXSDKInstance}
*/
void onRenderSuccess(WXSDKInstance instance, int width, int height);
/**
* Callback method, called when refresh is finished
*/
void onRefreshSuccess(WXSDKInstance instance, int width, int height);
/**
* Report exception occurred when weex instance is running. Exception <strong>may not</strong>
* cause user-noticeable failure of weex.
*/
void onException(WXSDKInstance instance, String errCode, String msg);
}
/*
* 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.taobao.weex;
public interface IWXStatisticsListener {
/**
* Called when weex sdk engine begin to initialize.
*/
void onSDKEngineInitialize();
/**
* Called when begin to load js framework.
*/
void onJsFrameworkStart();
/**
* Called when finish loading js framework.
*/
void onJsFrameworkReady();
/**
* Called when the render view phase of first view reached.
*/
void onFirstView();
/**
* Called when the render view phase of first screen reached.
*/
void onFirstScreen();
/**
* Called when to start a http request.
*/
void onHttpStart();
/**
* Called when received a http response header data.
*/
void onHeadersReceived();
/**
* Called when to finish a http request.
*/
void onHttpFinish();
/**
* Called when an exception occured.
*/
void onException(String instanceid, String errCode, String msg);
}
/*
* 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.taobao.weex;
import com.taobao.weex.adapter.IDrawableLoader;
import com.taobao.weex.adapter.IWXDebugAdapter;
import com.taobao.weex.adapter.IWXHttpAdapter;
import com.taobao.weex.adapter.IWXImgLoaderAdapter;
import com.taobao.weex.adapter.IWXJSExceptionAdapter;
import com.taobao.weex.adapter.IWXSoLoaderAdapter;
import com.taobao.weex.adapter.IWXTypefaceAdapter;
import com.taobao.weex.adapter.IWXUserTrackAdapter;
import com.taobao.weex.adapter.URIAdapter;
import com.taobao.weex.appfram.storage.IWXStorageAdapter;
import com.taobao.weex.appfram.websocket.IWebSocketAdapterFactory;
/**
* Created by sospartan on 5/31/16.
*/
public class InitConfig {
private IWXHttpAdapter httpAdapter;
private IDrawableLoader drawableLoader;
private IWXImgLoaderAdapter imgAdapter;
private IWXUserTrackAdapter utAdapter;
private IWXDebugAdapter debugAdapter;
private IWXStorageAdapter storageAdapter;
private IWXSoLoaderAdapter soLoader;
private URIAdapter mURIAdapter;
private IWebSocketAdapterFactory webSocketAdapterFactory;
private IWXJSExceptionAdapter mJSExceptionAdapter;
private String framework;
//本木自定义adapter
private IWXTypefaceAdapter mTypefaceAdapter;
public IWXHttpAdapter getHttpAdapter() {
return httpAdapter;
}
public IWXImgLoaderAdapter getImgAdapter() {
return imgAdapter;
}
public IDrawableLoader getDrawableLoader() {
return drawableLoader;
}
public IWXUserTrackAdapter getUtAdapter() {
return utAdapter;
}
public IWXDebugAdapter getDebugAdapter() {
return debugAdapter;
}
public IWXSoLoaderAdapter getIWXSoLoaderAdapter() {
return soLoader;
}
public String getFramework() {
return framework;
}
public IWXStorageAdapter getStorageAdapter() {
return storageAdapter;
}
public URIAdapter getURIAdapter() {
return mURIAdapter;
}
public IWebSocketAdapterFactory getWebSocketAdapterFactory() {
return webSocketAdapterFactory;
}
public IWXJSExceptionAdapter getJSExceptionAdapter() {
return mJSExceptionAdapter;
}
public IWXTypefaceAdapter getTypefaceAdapter() {
return mTypefaceAdapter;
}
private InitConfig() {
}
public static class Builder {
IWXHttpAdapter httpAdapter;
IWXImgLoaderAdapter imgAdapter;
IDrawableLoader drawableLoader;
IWXUserTrackAdapter utAdapter;
IWXDebugAdapter debugAdapter;
IWXStorageAdapter storageAdapter;
IWXSoLoaderAdapter soLoader;
URIAdapter mURIAdapter;
IWXJSExceptionAdapter mJSExceptionAdapter;
String framework;
IWebSocketAdapterFactory webSocketAdapterFactory;
//本木自定义adapter
private IWXTypefaceAdapter typefaceAdapter;
public Builder() {
}
public Builder setHttpAdapter(IWXHttpAdapter httpAdapter) {
this.httpAdapter = httpAdapter;
return this;
}
public Builder setImgAdapter(IWXImgLoaderAdapter imgAdapter) {
this.imgAdapter = imgAdapter;
return this;
}
public Builder setDrawableLoader(IDrawableLoader drawableLoader) {
this.drawableLoader = drawableLoader;
return this;
}
public Builder setUtAdapter(IWXUserTrackAdapter utAdapter) {
this.utAdapter = utAdapter;
return this;
}
public Builder setDebugAdapter(IWXDebugAdapter debugAdapter) {
this.debugAdapter = debugAdapter;
return this;
}
public Builder setStorageAdapter(IWXStorageAdapter storageAdapter) {
this.storageAdapter = storageAdapter;
return this;
}
public Builder setURIAdapter(URIAdapter URIAdapter) {
mURIAdapter = URIAdapter;
return this;
}
public Builder setJSExceptionAdapter(IWXJSExceptionAdapter JSExceptionAdapter) {
mJSExceptionAdapter = JSExceptionAdapter;
return this;
}
public Builder setSoLoader(IWXSoLoaderAdapter loader) {
this.soLoader = loader;
return this;
}
public Builder setFramework(String framework) {
this.framework = framework;
return this;
}
public Builder setWebSocketAdapterFactory(IWebSocketAdapterFactory factory) {
this.webSocketAdapterFactory = factory;
return this;
}
public Builder setTypefaceAdapter(IWXTypefaceAdapter adapter) {
this.typefaceAdapter = adapter;
return this;
}
public InitConfig build() {
InitConfig config = new InitConfig();
config.httpAdapter = this.httpAdapter;
config.imgAdapter = this.imgAdapter;
config.drawableLoader = this.drawableLoader;
config.utAdapter = this.utAdapter;
config.debugAdapter = this.debugAdapter;
config.storageAdapter = this.storageAdapter;
config.soLoader = this.soLoader;
config.framework = this.framework;
config.mURIAdapter = this.mURIAdapter;
config.webSocketAdapterFactory = this.webSocketAdapterFactory;
config.mJSExceptionAdapter = this.mJSExceptionAdapter;
config.mTypefaceAdapter = this.typefaceAdapter;
return config;
}
}
}
/**
* 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.taobao.weex;
import android.support.annotation.NonNull;
public interface LayoutFinishListener {
void onLayoutFinish(@NonNull WXSDKInstance instance);
}
/*
* 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.taobao.weex;
import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.FrameLayout;
import java.lang.ref.WeakReference;
/**
* Created by sospartan on 08/10/2016.
*/
public class RenderContainer extends FrameLayout {
private WeakReference<WXSDKInstance> mSDKInstance;
public RenderContainer(Context context) {
super(context);
}
public RenderContainer(Context context, AttributeSet attrs) {
super(context, attrs);
}
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public RenderContainer(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
super(context, attrs, defStyleAttr, defStyleRes);
}
public void setSDKInstance(WXSDKInstance instance) {
mSDKInstance = new WeakReference<>(instance);
}
@Override
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
super.onSizeChanged(w, h, oldw, oldh);
WXSDKInstance instance;
if (mSDKInstance != null && (instance = mSDKInstance.get()) != null) {
//re-render instance
instance.setSize(w, h);
}
}
}
/*
* 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.taobao.weex;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;
import java.util.Map;
/**
* Created by lixinke on 16/8/25.
*/
public class WXGlobalEventModule extends WXModule {
@JSMethod
public void addEventListener(String eventName, String callback) {
mWXSDKInstance.addEventListener(eventName,callback);
}
public void removeEventListener(String eventName, String callback) {
mWXSDKInstance.removeEventListener(eventName,callback);
}
@JSMethod
public void removeEventListener(String eventName){
mWXSDKInstance.removeEventListener(eventName);
}
@Override
public void addEventListener(String eventName, String callback, Map<String, Object> options) {
super.addEventListener(eventName, callback, options);
addEventListener(eventName,callback);
}
}
/*
* 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.taobao.weex;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import com.taobao.weex.utils.WXLogUtils;
import java.util.HashMap;
public class WXGlobalEventReceiver extends BroadcastReceiver {
public static final String EVENT_NAME = "eventName";
public static final String EVENT_PARAMS = "eventParams";
public static final String EVENT_ACTION = "wx_global_action";
public static final String EVENT_WX_INSTANCEID = "wx_instanceid";
private WXSDKInstance mWXSDKInstance;
public WXGlobalEventReceiver() {
}
public WXGlobalEventReceiver(WXSDKInstance instance) {
mWXSDKInstance = instance;
}
@Override
public void onReceive(Context context, Intent intent) {
String eventName = intent.getStringExtra(EVENT_NAME);
String params = intent.getStringExtra(EVENT_PARAMS);
HashMap<String, Object> maps = null;
try {
maps = com.alibaba.fastjson.JSON.parseObject(params, HashMap.class);
mWXSDKInstance.fireGlobalEventCallback(eventName, maps);
} catch (Exception e) {
WXLogUtils.e("global-receive",e);
}
}
}
/*
* 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.taobao.weex;
public class WXRenderErrorCode {
// 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 enum DegradPassivityCode{
/**
* 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();
}
}
}
/*
* 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.taobao.weex.adapter;
import android.net.Uri;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.taobao.weex.WXSDKInstance;
import java.util.List;
/**
* Default Uri adapter. Provide basic capability to handle relative path, local file path etc.
* Created by sospartan on 21/11/2016.
*/
public class DefaultUriAdapter implements URIAdapter {
@NonNull
@Override
public Uri rewrite(WXSDKInstance instance, String type, Uri uri) {
if (TextUtils.isEmpty(instance.getBundleUrl())) {
return uri;
}
Uri base = Uri.parse(instance.getBundleUrl());
Uri.Builder resultBuilder = uri.buildUpon();
if (uri.isRelative()) {
//When uri is empty, means use the base url instead. Web broswer behave this way.
if(uri.getEncodedPath().length() == 0){
if(URIAdapter.IMAGE.equals(type)){
if(TextUtils.isEmpty(uri.toString())){
return uri;
}
}
return base;
} else {
resultBuilder = buildRelativeURI(resultBuilder, base, uri);
return resultBuilder.build();
}
}
return uri;
}
private Uri.Builder buildRelativeURI(Uri.Builder resultBuilder, Uri base, Uri uri) {
if (uri.getAuthority() != null) {
return resultBuilder.scheme(base.getScheme());
} else {
resultBuilder
.encodedAuthority(base.getEncodedAuthority())
.scheme(base.getScheme())
.path(null);
if (uri.getPath().startsWith("/")) {
//relative to root
resultBuilder.appendEncodedPath(uri.getEncodedPath().substring(1));
} else {
List<String> segments = base.getPathSegments();
//ignore last segment if not end with /
int ignoreLast = 1;
if (base.getPath().endsWith("/")) {
ignoreLast = 0;
}
for (int i = 0, len = segments.size() - ignoreLast; i < len; i++) {
resultBuilder.appendEncodedPath(segments.get(i));
}
resultBuilder.appendEncodedPath(uri.getEncodedPath());
}
return resultBuilder;
}
}
}
/*
* 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.taobao.weex.adapter;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import com.taobao.weex.common.WXRequest;
import com.taobao.weex.common.WXResponse;
import java.io.BufferedReader;
import java.io.ByteArrayOutputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class DefaultWXHttpAdapter implements IWXHttpAdapter {
private static final IEventReporterDelegate DEFAULT_DELEGATE = new NOPEventReportDelegate();
private ExecutorService mExecutorService;
private void execute(Runnable runnable){
if(mExecutorService==null){
mExecutorService = Executors.newFixedThreadPool(3);
}
mExecutorService.execute(runnable);
}
@Override
public void sendRequest(final WXRequest request, final OnHttpListener listener) {
if (listener != null) {
listener.onHttpStart();
}
execute(new Runnable() {
@Override
public void run() {
WXResponse response = new WXResponse();
IEventReporterDelegate reporter = getEventReporterDelegate();
try {
HttpURLConnection connection = openConnection(request, listener);
reporter.preConnect(connection, request.body);
Map<String,List<String>> headers = connection.getHeaderFields();
int responseCode = connection.getResponseCode();
if(listener != null){
listener.onHeadersReceived(responseCode,headers);
}
reporter.postConnect();
response.statusCode = String.valueOf(responseCode);
if (responseCode >= 200 && responseCode<=299) {
InputStream rawStream = connection.getInputStream();
rawStream = reporter.interpretResponseStream(rawStream);
response.originalData = readInputStreamAsBytes(rawStream, listener);
} else {
response.errorMsg = readInputStream(connection.getErrorStream(), listener);
}
if (listener != null) {
listener.onHttpFinish(response);
}
} catch (IOException|IllegalArgumentException e) {
e.printStackTrace();
response.statusCode = "-1";
response.errorCode="-1";
response.errorMsg=e.getMessage();
if(listener!=null){
listener.onHttpFinish(response);
}
if (e instanceof IOException) {
try {
reporter.httpExchangeFailed((IOException) e);
} catch (Throwable t) {
t.printStackTrace();
}
}
}
}
});
}
/**
* Opens an {@link HttpURLConnection} with parameters.
*
* @param request
* @param listener
* @return an open connection
* @throws IOException
*/
private HttpURLConnection openConnection(WXRequest request, OnHttpListener listener) throws IOException {
URL url = new URL(request.url);
HttpURLConnection connection = createConnection(url);
connection.setConnectTimeout(request.timeoutMs);
connection.setReadTimeout(request.timeoutMs);
connection.setUseCaches(false);
connection.setDoInput(true);
if (request.paramMap != null) {
Set<String> keySets = request.paramMap.keySet();
for (String key : keySets) {
connection.addRequestProperty(key, request.paramMap.get(key));
}
}
if ("POST".equals(request.method) || "PUT".equals(request.method) || "PATCH".equals(request.method)) {
connection.setRequestMethod(request.method);
if (request.body != null) {
if (listener != null) {
listener.onHttpUploadProgress(0);
}
connection.setDoOutput(true);
DataOutputStream out = new DataOutputStream(connection.getOutputStream());
//TODO big stream will cause OOM; Progress callback is meaningless
out.write(request.body.getBytes());
out.close();
if (listener != null) {
listener.onHttpUploadProgress(100);
}
}
} else if (!TextUtils.isEmpty(request.method)) {
connection.setRequestMethod(request.method);
} else {
connection.setRequestMethod("GET");
}
return connection;
}
private byte[] readInputStreamAsBytes(InputStream inputStream,OnHttpListener listener) throws IOException{
if(inputStream == null){
return null;
}
ByteArrayOutputStream buffer = new ByteArrayOutputStream();
int nRead;
int readCount = 0;
byte[] data = new byte[2048];
while ((nRead = inputStream.read(data, 0, data.length)) != -1) {
buffer.write(data, 0, nRead);
readCount += nRead;
if (listener != null) {
listener.onHttpResponseProgress(readCount);
}
}
buffer.flush();
return buffer.toByteArray();
}
private String readInputStream(InputStream inputStream, OnHttpListener listener) throws IOException {
if(inputStream == null){
return null;
}
StringBuilder builder = new StringBuilder();
BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(inputStream));
char[] data = new char[2048];
int len;
while ((len = localBufferedReader.read(data)) != -1) {
builder.append(data, 0, len);
if (listener != null) {
listener.onHttpResponseProgress(builder.length());
}
}
localBufferedReader.close();
return builder.toString();
}
/**
* Create an {@link HttpURLConnection} for the specified {@code url}.
*/
protected HttpURLConnection createConnection(URL url) throws IOException {
return (HttpURLConnection) url.openConnection();
}
public @NonNull IEventReporterDelegate getEventReporterDelegate() {
return DEFAULT_DELEGATE;
}
public interface IEventReporterDelegate {
void preConnect(HttpURLConnection connection, @Nullable String body);
void postConnect();
InputStream interpretResponseStream(@Nullable InputStream inputStream);
void httpExchangeFailed(IOException e);
}
private static class NOPEventReportDelegate implements IEventReporterDelegate {
@Override
public void preConnect(HttpURLConnection connection, @Nullable String body) {
//do nothing
}
@Override
public void postConnect() {
//do nothing
}
@Override
public InputStream interpretResponseStream(@Nullable InputStream inputStream) {
return inputStream;
}
@Override
public void httpExchangeFailed(IOException e) {
//do nothing
}
}
}
/*
* 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.taobao.weex.adapter;
public class DrawableStrategy {
public int width;
public int height;
}
/**
* 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.taobao.weex.adapter;
/**
* Created by zhengshihan on 2017/5/23.
*/
public interface ICrashInfoReporter {
void addCrashInfo(String key ,String value);
}
/*
* 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.taobao.weex.adapter;
import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
public interface IDrawableLoader {
interface DrawableTarget {
}
interface StaticTarget extends DrawableTarget{
void setDrawable(@Nullable Drawable drawable, boolean resetBounds);
}
interface AnimatedTarget extends DrawableTarget{
void setAnimatedDrawable(@Nullable Drawable drawable);
}
void setDrawable(String url, DrawableTarget drawableTarget, DrawableStrategy drawableStrategy);
}
/**
* 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.taobao.weex.adapter;
import com.taobao.weex.tracing.WXTracing;
/**
* Created by moxun on 2017/7/6.
*/
public interface ITracingAdapter {
void enable();
void disable();
void submitTracingEvent(WXTracing.TraceEvent event);
}
/**
* 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.taobao.weex.adapter;
/**
* Created by moxun on 2017/11/13.
*/
public interface IWXAccessibilityRoleAdapter {
String getRole(String key);
}
/*
* 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.taobao.weex.adapter;
import android.app.Application;
import android.view.View;
import com.taobao.weex.WXSDKInstance;
/**
* Created by lixinke on 16/6/6.
*/
public interface IWXDebugAdapter {
void initDebug(Application application);
/**
* wrap weex container
*/
View wrapContainer(WXSDKInstance instance, View wxView);
void putDebugOptions(String key, String value);
String getDebugOptions(String key);
}
/*
* 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.taobao.weex.adapter;
import com.taobao.weex.common.WXRequest;
import com.taobao.weex.common.WXResponse;
import java.util.List;
import java.util.Map;
public interface IWXHttpAdapter {
/**
* http request method
*
* @param request weex assemble request
* @param listener http response notify
*/
void sendRequest(WXRequest request, OnHttpListener listener);
interface OnHttpListener {
/**
* start request
*/
void onHttpStart();
/**
* headers received
*/
void onHeadersReceived(int statusCode,Map<String,List<String>> headers);
/**
* post progress
* @param uploadProgress
*/
void onHttpUploadProgress(int uploadProgress);
/**
* response loaded length (bytes), full length should read from headers (content-length)
* @param loadedLength
*/
void onHttpResponseProgress(int loadedLength);
/**
* http response finish
* @param response
*/
void onHttpFinish(WXResponse response);
}
}
/*
* 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.taobao.weex.adapter;
import android.widget.ImageView;
import com.taobao.weex.common.WXImageStrategy;
import com.taobao.weex.dom.WXImageQuality;
/**
* Interface for ImageLoader. This interface works as an adapter for various image library.
*/
public interface IWXImgLoaderAdapter {
void setImage(String url, ImageView view, WXImageQuality quality, WXImageStrategy strategy);
}
/*
* 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.taobao.weex.adapter;
import com.taobao.weex.common.WXJSExceptionInfo;
public interface IWXJSExceptionAdapter {
/**
* report js exception
*
* @param exception {@link WXJSExceptionInfo}
*/
void onJSException(WXJSExceptionInfo exception);
}
/*
* 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.taobao.weex.adapter;
/**
* Interface for loading library.
*/
public interface IWXSoLoaderAdapter {
/**
* A method <code>doLoadLibrary</code> that
* helps embedders to load a shared library with a short name.
* <p>
*
* Embedders would have a chance to take charge of library loading,
* they could load libraries with different class loaders,
* or load libraries from specified library pathes.
*
* @param shortName the name of the library
*/
void doLoadLibrary(String shortName);
/**
* A method <code>doLoad</code> that
* helps embedders to load a shared library.
* <p>
*
* Embedders would have a chance to take charge of library loading,
* they could load libraries with different class loaders,
* or load libraries from specified library pathes.
*
* @param name the file to load.
*/
void doLoad(String name);
}
package com.taobao.weex.adapter;
import java.io.File;
/**
* Created by Carry on 2017/10/26. 本木iconFont适配器接口
*/
public interface IWXTypefaceAdapter {
//获取本地iconfont目录
File getTypefaceDir();
//获取拦截器状态
boolean isInterceptor();
//获取本地服务地址
String getJsServer();
}
/*
* 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.taobao.weex.adapter;
import android.content.Context;
import com.taobao.weex.common.WXPerformance;
import java.io.Serializable;
import java.util.Map;
/**
* Interface for commit log info. This interface works as an adapter for various log library.
*/
public interface IWXUserTrackAdapter {
String MODULE_NAME = "weex";
//Performance
String LOAD = "load";
//Alarm
String JS_FRAMEWORK = "jsFramework";
String JS_DOWNLOAD = "jsDownload";
String DOM_MODULE = "domModule";
String JS_BRIDGE = "jsBridge";
String STREAM_MODULE = "streamModule";
String INVOKE_MODULE = "invokeModule";
void commit(Context context, String eventId, String type, WXPerformance perf, Map<String, Serializable> params);
}
/*
* 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.taobao.weex.adapter;
import android.net.Uri;
import android.support.annotation.NonNull;
import com.taobao.weex.WXSDKInstance;
/**
* Created by sospartan on 15/11/2016.
*/
public interface URIAdapter {
/**
* Stream request url.
*/
String REQUEST = "request";
/**
* URI for image src.
*/
String IMAGE = "image";
/**
* Font file URI for text @font-face .
*/
String FONT = "font";
/**
* Video URI.
*/
String VIDEO = "video";
/**
* URI for a 'href' attribute.
*/
String LINK = "link";
/**
* Bundle URI for Weex instance.
*/
String BUNDLE = "bundle";
/**
* Web page src
*/
String WEB = "web";
/**
* Unknown URIs.
*/
String OTHERS = "others";
/**
*
* @param type URI type, see {@link #IMAGE}/{@link #LINK}/{@link #FONT}/{@link #BUNDLE}/{@link #VIDEO}/{@link #OTHERS}
* @param uri
* @return
*/
@NonNull Uri rewrite(WXSDKInstance instance, String type, Uri uri);
}
/*
* 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.taobao.weex.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by sospartan on 6/12/16.
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
public @interface Component {
boolean lazyload() default true;
}
/*
* 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.taobao.weex.annotation;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* Created by sospartan on 19/10/2016.
*/
@Retention(RetentionPolicy.RUNTIME)
@Inherited
@Target(ElementType.METHOD)
public @interface JSMethod {
boolean uiThread() default true;
String alias() default NOT_SET;
String NOT_SET = "_";
}
/*
* 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.taobao.weex.appfram.clipboard;
import android.support.annotation.Nullable;
import com.taobao.weex.bridge.JSCallback;
/**
* Created by yiyuan.zhangyy(xingjiu) <br/>
*/
interface IWXClipboard {
public void setString(String text);
public void getString(@Nullable JSCallback callback);
}
/*
* 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.taobao.weex.appfram.clipboard;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.AssetFileDescriptor;
import android.net.Uri;
import android.support.annotation.Nullable;
import com.taobao.weex.bridge.JSCallback;
import com.taobao.weex.annotation.JSMethod;
import com.taobao.weex.common.WXModule;
import com.taobao.weex.utils.WXLogUtils;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
public class WXClipboardModule extends WXModule implements IWXClipboard {
private final String CLIP_KEY = "WEEX_CLIP_KEY_MAIN";
private static final String RESULT = "result";
private static final String DATA = "data";
private static final String RESULT_OK = "success";
private static final String RESULT_FAILED = "failed";
@Override
@JSMethod
public void setString(String text) {
if(null == text) {
return;
}
Context context = mWXSDKInstance.getContext();
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(context.CLIPBOARD_SERVICE);
ClipData clip = ClipData.newPlainText(CLIP_KEY, text);
clipboard.setPrimaryClip(clip);
}
@Override
@JSMethod
public void getString(@Nullable JSCallback callback) {
Context context = mWXSDKInstance.getContext();
ClipboardManager clipboard = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
Map<String, Object> map = new HashMap<>(2);
ClipData clip = clipboard.getPrimaryClip();
if (clip != null && clip.getItemCount() > 0) {
ClipData.Item item = clip.getItemAt(0);
CharSequence text = coerceToText(context, item);
map.put(RESULT, text != null ? RESULT_OK : RESULT_FAILED);
map.put(DATA, text != null ? text : "");
} else {
map.put(RESULT, RESULT_FAILED);
map.put(DATA, "");
}
if (null != callback) {
callback.invoke(map);
}
}
@Nullable
private CharSequence coerceToText(Context context, ClipData.Item item) {
// Condition 1. just a simple text
CharSequence text = item.getText();
if (text != null) {
return text;
}
// Condition 2. a URI value
Uri uri = item.getUri();
if (uri != null) {
InputStreamReader reader = null;
FileInputStream stream = null;
try {
AssetFileDescriptor assetFileDescriptor = context.getContentResolver().openTypedAssetFileDescriptor(uri, "text/*", null);
stream = assetFileDescriptor.createInputStream();
reader = new InputStreamReader(stream, "UTF-8");
StringBuilder builder = new StringBuilder(128);
char[] buffer = new char[8192];
int len;
while ((len = reader.read(buffer)) > 0) {
builder.append(buffer, 0, len);
}
return builder.toString();
} catch (FileNotFoundException e) {
// ignore.
} catch (IOException e) {
WXLogUtils.w("ClippedData Failure loading text.", e);
} finally {
if (reader != null) {
try {
reader.close();
} catch (IOException e) {
// ignore
}
}
if (stream != null) {
try {
stream.close();
} catch (IOException e) {
// ignore
}
}
}
return uri.toString();
}
// Condition 3. an intent.
Intent intent = item.getIntent();
if (intent != null) {
return intent.toUri(Intent.URI_INTENT_SCHEME);
}
// else case
return null;
}
}
/*
* 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.taobao.weex.appfram.navigator;
/**
* Define the NavBarSetter api of the Activity
*/
public interface IActivityNavBarSetter {
boolean push(String param);
boolean pop(String param);
boolean setNavBarRightItem(String param);
boolean clearNavBarRightItem(String param);
boolean setNavBarLeftItem(String param);
boolean clearNavBarLeftItem(String param);
boolean setNavBarMoreItem(String param);
boolean clearNavBarMoreItem(String param);
boolean setNavBarTitle(String param);
}
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment