From 73015baaadda9bd2e83f9de032ff749c73342112 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E7=BB=A7=E8=8F=B2?= Date: Sun, 24 Jan 2016 15:40:40 +0800 Subject: [PATCH 01/25] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E9=9A=90=E8=97=8F?= =?UTF-8?q?=E5=92=8C=E6=98=BE=E7=A4=BA=E5=AE=B9=E5=99=A8=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/universalex/EUExScript.java | 2 + .../engine/universalex/EUExWindow.java | 94 ++++++++++++++++++- 2 files changed, 94 insertions(+), 2 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java index f89b8893..0a410149 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java @@ -226,6 +226,8 @@ public class EUExScript { + "setPageInContainer:function(){uexDispatcher.dispatch('uexWindow','setPageInContainer',jo(arguments));}," + "closePluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','closePluginViewContainer',jo(arguments));}," + "createPluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','createPluginViewContainer',jo(arguments));}," + + "showPluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','showPluginViewContainer',jo(arguments));}," + + "hidePluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','hidePluginViewContainer',jo(arguments));}," + "getUrlQuery:function(){return uexDispatcher.dispatch('uexWindow','getUrlQuery',jo(arguments))}};" + // // DataAnalysis diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index e943c402..45ab4560 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -159,6 +159,8 @@ public class EUExWindow extends EUExBase { private static final int MSG_PLUGINVIEW_CONTAINER_CREATE = 52; private static final int MSG_PLUGINVIEW_CONTAINER_CLOSE = 53; private static final int MSG_PLUGINVIEW_CONTAINER_SET = 54; + private static final int MSG_PLUGINVIEW_CONTAINER_SHOW = 55; + private static final int MSG_PLUGINVIEW_CONTAINER_HIDE = 56; private AlertDialog mAlert; private AlertDialog.Builder mConfirm; private PromptDialog mPrompt; @@ -3163,6 +3165,88 @@ public void onPageScrollStateChanged(int arg0) { } } + public void showPluginViewContainer(String[] parm) { + Message msg = mHandler.obtainMessage(); + msg.what = MSG_PLUGINVIEW_CONTAINER_SHOW; + msg.obj = this; + Bundle bd = new Bundle(); + bd.putStringArray(TAG_BUNDLE_PARAM, parm); + msg.setData(bd); + mHandler.sendMessage(msg); + } + + /** + * 显示隐藏的容器 + * + * @param params + */ + private void showPluginViewContainerMsg(String[] params) { + if (params == null || params.length < 1) { + errorCallback(0, 0, "error params!"); + return; + } + try { + JSONObject json = new JSONObject(params[0]); + String opid = json.getString("id"); + + EBrowserWindow mWindow = mBrwView.getBrowserWindow(); + int count = mWindow.getChildCount(); + for (int i = 0; i < count; i++) { + View view = mWindow.getChildAt(i); + if (view instanceof ContainerViewPager) { + ContainerViewPager pager = (ContainerViewPager) view; + if (opid.equals(pager.getContainerVO().getId())) { + pager.setVisibility(View.VISIBLE); + return; + } + }//end instance + }//end for + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void hidePluginViewContainer(String[] parm) { + Message msg = mHandler.obtainMessage(); + msg.what = MSG_PLUGINVIEW_CONTAINER_HIDE; + msg.obj = this; + Bundle bd = new Bundle(); + bd.putStringArray(TAG_BUNDLE_PARAM, parm); + msg.setData(bd); + mHandler.sendMessage(msg); + } + + /** + * 隐藏显示的容器 + * + * @param params + */ + private void hidePluginViewContainerMsg(String[] params) { + if (params == null || params.length < 1) { + errorCallback(0, 0, "error params!"); + return; + } + try { + JSONObject json = new JSONObject(params[0]); + String opid = json.getString("id"); + + EBrowserWindow mWindow = mBrwView.getBrowserWindow(); + int count = mWindow.getChildCount(); + for (int i = 0; i < count; i++) { + View view = mWindow.getChildAt(i); + if (view instanceof ContainerViewPager) { + ContainerViewPager pager = (ContainerViewPager) view; + if (opid.equals(pager.getContainerVO().getId())) { + pager.setVisibility(View.GONE); + return; + } + }//end instance + }//end for + } catch (Exception e) { + e.printStackTrace(); + } + } + public void closePluginViewContainer(String[] parm) { Message msg = mHandler.obtainMessage(); msg.what = MSG_PLUGINVIEW_CONTAINER_CLOSE; @@ -3184,7 +3268,7 @@ private void closePluginViewContainerMsg(String[] params) { return; } try { - JSONObject json = new JSONObject(params[0].toString()); + JSONObject json = new JSONObject(params[0]); String opid = json.getString("id"); EBrowserWindow mWindow = mBrwView.getBrowserWindow(); @@ -3193,7 +3277,7 @@ private void closePluginViewContainerMsg(String[] params) { View view = mWindow.getChildAt(i); if (view instanceof ContainerViewPager) { ContainerViewPager pager = (ContainerViewPager) view; - if (opid.equals((String) pager.getContainerVO().getId())) { + if (opid.equals(pager.getContainerVO().getId())) { removeViewFromCurrentWindow(pager); ContainerAdapter adapter = (ContainerAdapter) pager.getAdapter(); Vector views = adapter.getViewList(); @@ -3498,6 +3582,12 @@ public void run() { case MSG_PLUGINVIEW_CONTAINER_SET: setPageInContainerMsg(param); break; + case MSG_PLUGINVIEW_CONTAINER_SHOW: + showPluginViewContainerMsg(param); + break; + case MSG_PLUGINVIEW_CONTAINER_HIDE: + hidePluginViewContainerMsg(param); + break; default: break; } From dd0272007f6c8c859f6976e56b2c9a30a059d5b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=91=A3=E7=BB=A7=E8=8F=B2?= Date: Sun, 24 Jan 2016 16:56:42 +0800 Subject: [PATCH 02/25] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/engine/universalex/EUExWindow.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index 45ab4560..fef9ed25 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -93,6 +93,8 @@ public class EUExWindow extends EUExBase { public static final String function_cbslipedDownEdge = "uexWindow.slipedDownEdge";//不建议使用 public static final String function_cbCreatePluginViewContainer = "uexWindow.cbCreatePluginViewContainer"; public static final String function_cbClosePluginViewContainer = "uexWindow.cbClosePluginViewContainer"; + public static final String function_cbShowPluginViewContainer = "uexWindow.cbShowPluginViewContainer"; + public static final String function_cbHidePluginViewContainer = "uexWindow.cbHidePluginViewContainer"; public static final String function_onPluginContainerPageChange = "uexWindow.onPluginContainerPageChange"; public static final String function_onSlipedUpward = "uexWindow.onSlipedUpward"; @@ -3197,6 +3199,10 @@ private void showPluginViewContainerMsg(String[] params) { ContainerViewPager pager = (ContainerViewPager) view; if (opid.equals(pager.getContainerVO().getId())) { pager.setVisibility(View.VISIBLE); + String js = SCRIPT_HEADER + "if(" + function_cbShowPluginViewContainer + "){" + + function_cbShowPluginViewContainer + "(" + opid + "," + EUExCallback.F_C_TEXT + ",'" + + "success" + "'" + SCRIPT_TAIL; + onCallback(js); return; } }//end instance @@ -3238,6 +3244,10 @@ private void hidePluginViewContainerMsg(String[] params) { ContainerViewPager pager = (ContainerViewPager) view; if (opid.equals(pager.getContainerVO().getId())) { pager.setVisibility(View.GONE); + String js = SCRIPT_HEADER + "if(" + function_cbHidePluginViewContainer + "){" + + function_cbHidePluginViewContainer + "(" + opid + "," + EUExCallback.F_C_TEXT + ",'" + + "success" + "'" + SCRIPT_TAIL; + onCallback(js); return; } }//end instance From f93c802fbe753d54bb6c49cd9cddcf579d1308f7 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Fri, 29 Jan 2016 11:06:27 +0800 Subject: [PATCH 03/25] =?UTF-8?q?=E8=A7=A3=E5=86=B3=E5=9B=BE=E7=89=87?= =?UTF-8?q?=E6=B2=A1=E6=9C=89=E7=BC=93=E5=AD=98=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/base/ACEImageLoader.java | 39 ++++++++++++++++++- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java b/Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java index dd9ad121..94eebff5 100644 --- a/Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java +++ b/Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java @@ -1,3 +1,22 @@ +/* + * Copyright (c) 2016. The AppCan Open Source Project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * + */ + package org.zywx.wbpalmstar.base; import android.widget.ImageView; @@ -35,9 +54,10 @@ private ACEImageLoader() { .diskCache(new UnlimitedDiskCache(DiskCache.cacheFolder))//自定义缓存路径 .diskCacheFileNameGenerator(new Md5FileNameGenerator()) .diskCacheSize(200 * 1024 * 1024) + .diskCacheFileCount(100) .defaultDisplayImageOptions(DisplayImageOptions.createSimple()) .imageDownloader(new BaseImageDownloader(BConstant.app, 5 * 1000, 30 * 1000)) // connectTimeout (5 s), - // readTimeout (30 s)超时时间 + // readTimeout (30 s)超时时间 .writeDebugLogs() // Remove for release app .build();//开始构建 ImageLoader.getInstance().init(config); @@ -65,8 +85,23 @@ public void displayImage(T imageView, String imgUrl) { } else { realImgUrl = imgUrl; } - ImageLoader.getInstance().displayImage(realImgUrl, imageView); + displayImageWithOptions(realImgUrl,imageView,true); } + public void displayImageWithOptions(String imgUrl, T imageView,boolean cacheOnDisk) + { + if (cacheOnDisk){ + DisplayImageOptions options; + options=new DisplayImageOptions.Builder() + .cacheOnDisk(true) + .build(); + ImageLoader.getInstance().displayImage(imgUrl, imageView,options); + }else{ + ImageLoader.getInstance().displayImage(imgUrl, imageView); + } + + } + + } From f332effd8e9fee3d63efc5aac99fdbbb83b530c8 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Fri, 29 Jan 2016 15:56:43 +0800 Subject: [PATCH 04/25] =?UTF-8?q?startApp=E6=B7=BB=E5=8A=A0=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/base/vo/StartAppVO.java | 40 +++++++++++++++++++ .../engine/universalex/EUExWidget.java | 9 +++++ 2 files changed, 49 insertions(+) create mode 100644 Engine/src/org/zywx/wbpalmstar/base/vo/StartAppVO.java diff --git a/Engine/src/org/zywx/wbpalmstar/base/vo/StartAppVO.java b/Engine/src/org/zywx/wbpalmstar/base/vo/StartAppVO.java new file mode 100644 index 00000000..36bbbeca --- /dev/null +++ b/Engine/src/org/zywx/wbpalmstar/base/vo/StartAppVO.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2016. The AppCan Open Source Project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * + */ + +package org.zywx.wbpalmstar.base.vo; + +import java.io.Serializable; + +/** + * Created by ylt on 16/1/29. + */ +public class StartAppVO implements Serializable { + + private static final long serialVersionUID = -644923159386862574L; + + private String data; + + public String getData() { + return data; + } + + public void setData(String data) { + this.data = data; + } +} diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java index 4dd5fd63..39f54964 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java @@ -45,6 +45,7 @@ import org.zywx.wbpalmstar.base.JsConst; import org.zywx.wbpalmstar.base.ResoureFinder; import org.zywx.wbpalmstar.base.vo.AppInstalledVO; +import org.zywx.wbpalmstar.base.vo.StartAppVO; import org.zywx.wbpalmstar.engine.DataHelper; import org.zywx.wbpalmstar.engine.EBrowserActivity; import org.zywx.wbpalmstar.engine.EBrowserAnimation; @@ -227,6 +228,10 @@ public void startApp(String[] params) { if ("0".equals(startMode)) { String pkgName = params[1]; String clsName = null; + StartAppVO extraVO=null; + if (params.length>4) { + extraVO = DataHelper.gson.fromJson(params[4],StartAppVO.class); + } if (TextUtils.isEmpty(pkgName)) { Log.e(tag, "startApp has error params!!!"); callBackPluginJs(JsConst.CALLBACK_START_APP, "error params"); @@ -246,6 +251,10 @@ public void startApp(String[] params) { } ComponentName component = new ComponentName(pkgName, clsName); intent = new Intent(); + if (extraVO!=null&&extraVO.getData()!=null){ + Uri contentUrl=Uri.parse(extraVO.getData()); + intent.setData(contentUrl); + } intent.setComponent(component); } else if ("1".equals(startMode)) { String action = params[1]; From cd9ef6467dddb2718768fc1805a4ca9aeb76a806 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Mon, 1 Feb 2016 18:22:52 +0800 Subject: [PATCH 05/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0share()=E5=88=86?= =?UTF-8?q?=E4=BA=AB=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/assets/widget/index.html | 11 +- .../widget/wintestNormal/uexWindowFunc.html | 102 +++++++++++++++++ Engine/build.gradle | 2 +- .../zywx/wbpalmstar/base/vo/ShareInputVO.java | 105 ++++++++++++++++++ .../src/org/zywx/wbpalmstar/engine/EUtil.java | 96 ++++++++++++---- .../engine/universalex/EUExScript.java | 1 + .../engine/universalex/EUExWindow.java | 22 +++- 7 files changed, 310 insertions(+), 29 deletions(-) create mode 100755 Engine/assets/widget/wintestNormal/uexWindowFunc.html create mode 100644 Engine/src/org/zywx/wbpalmstar/base/vo/ShareInputVO.java diff --git a/Engine/assets/widget/index.html b/Engine/assets/widget/index.html index 938fd4da..4e58ad23 100755 --- a/Engine/assets/widget/index.html +++ b/Engine/assets/widget/index.html @@ -59,11 +59,9 @@ } function openTest(name){ - if(name == "uexWindow"){ - openNewWin("uexWindow", "uexWindow.html?index=1&page=wind"); - }else{ - openNewWin(name, name+".html"); - } + var optInfo = "{'key1':'value1'},{'key2':'value1'}"; + var extra='{data:"http://www.cnblogs.com"}'; + uexWidget.startApp(0, "com.tencent.mtt","com.tencent.mtt.MainActivity",optInfo,extra); } function openTestController(name){ @@ -122,7 +120,8 @@
打开普通窗口

-
打开侧边栏窗口

+
window接口测试

+
打开侧边栏窗口

打开导航视图窗口(iOS)

uexWidget

diff --git a/Engine/assets/widget/wintestNormal/uexWindowFunc.html b/Engine/assets/widget/wintestNormal/uexWindowFunc.html new file mode 100755 index 00000000..230b4b40 --- /dev/null +++ b/Engine/assets/widget/wintestNormal/uexWindowFunc.html @@ -0,0 +1,102 @@ + + + + + + + + + + + + + + + + + + +
+
+ + 1.分享(share) +
+ + + 2.窗口前进后退(windowForward, windowBack forward, back, pageForward, pageBack) +
+ + 5.打开浮动窗口2(测试closePopover) +
+
+ + 6.打开多页面浮动窗口(openMultiPopover) +
+
+
+
+ + diff --git a/Engine/build.gradle b/Engine/build.gradle index 4f46fcca..b6ec85f0 100644 --- a/Engine/build.gradle +++ b/Engine/build.gradle @@ -9,7 +9,7 @@ dependencies { android { compileSdkVersion 22 - buildToolsVersion '23.0.0' + buildToolsVersion '23.0.2' packagingOptions { exclude 'META-INF/MANIFEST.MF' exclude 'META-INF/LICENSE.txt' diff --git a/Engine/src/org/zywx/wbpalmstar/base/vo/ShareInputVO.java b/Engine/src/org/zywx/wbpalmstar/base/vo/ShareInputVO.java new file mode 100644 index 00000000..b315c248 --- /dev/null +++ b/Engine/src/org/zywx/wbpalmstar/base/vo/ShareInputVO.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2016. The AppCan Open Source Project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * + */ + +package org.zywx.wbpalmstar.base.vo; + +import java.io.Serializable; +import java.util.List; + +/** + * Created by ylt on 16/2/1. + */ +public class ShareInputVO implements Serializable { + + private static final long serialVersionUID = 8080883114713052859L; + + private int type=-1; + + private List imgPaths; + private String imgPath; + private String text; + private String packageName; + private String className; + private String title; + private String subject; + + public List getImgPaths() { + return imgPaths; + } + + public void setImgPaths(List imgPaths) { + this.imgPaths = imgPaths; + } + + public String getImgPath() { + return imgPath; + } + + public void setImgPath(String imgPath) { + this.imgPath = imgPath; + } + + public String getText() { + return text; + } + + public void setText(String text) { + this.text = text; + } + + public String getPackageName() { + return packageName; + } + + public void setPackageName(String packageName) { + this.packageName = packageName; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public String getClassName() { + return className; + } + + public void setClassName(String className) { + this.className = className; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getSubject() { + return subject; + } + + public void setSubject(String subject) { + this.subject = subject; + } +} diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EUtil.java b/Engine/src/org/zywx/wbpalmstar/engine/EUtil.java index 3d8971d9..5809d621 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EUtil.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EUtil.java @@ -18,27 +18,7 @@ package org.zywx.wbpalmstar.engine; -import java.io.BufferedOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.InetSocketAddress; -import java.net.Proxy; -import java.util.List; - -import org.apache.http.HttpHost; -import org.apache.http.util.ByteArrayBuffer; -import org.zywx.wbpalmstar.acedes.ACEDes; -import org.zywx.wbpalmstar.base.BUtility; -import org.zywx.wbpalmstar.base.ResoureFinder; -import org.zywx.wbpalmstar.platform.encryption.PEncryption; - -import dalvik.system.DexClassLoader; - +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.content.pm.PackageManager; @@ -52,10 +32,34 @@ import android.os.Bundle; import android.os.Environment; import android.os.Parcelable; +import android.text.TextUtils; import android.util.Log; import android.view.View; import android.webkit.MimeTypeMap; +import org.apache.http.HttpHost; +import org.apache.http.util.ByteArrayBuffer; +import org.zywx.wbpalmstar.acedes.ACEDes; +import org.zywx.wbpalmstar.base.BUtility; +import org.zywx.wbpalmstar.base.ResoureFinder; +import org.zywx.wbpalmstar.base.vo.ShareInputVO; +import org.zywx.wbpalmstar.platform.encryption.PEncryption; + +import java.io.BufferedOutputStream; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.InetSocketAddress; +import java.net.Proxy; +import java.util.ArrayList; +import java.util.List; + +import dalvik.system.DexClassLoader; + public class EUtil { public static boolean debug = false; @@ -544,4 +548,54 @@ public final void createSystemSwitcherShortCut(Context context, String shortCutN addIntent.putExtra(Intent.EXTRA_SHORTCUT_INTENT, targetIntent); context.sendBroadcast(addIntent); } + + public static void share(Context context, ShareInputVO inputVO){ + Intent intent=new Intent(); + if (inputVO.getImgPaths()!=null&&inputVO.getImgPaths().size()>0){ + //分享多张图片 + intent.setAction(Intent.ACTION_SEND_MULTIPLE); + ArrayList imagePathList = new ArrayList(); + for(String picPath: inputVO.getImgPaths()){ + File file=new File(picPath); + imagePathList.add(Uri.fromFile(file)); + } + intent.putParcelableArrayListExtra(Intent.EXTRA_STREAM,imagePathList); + }else{ + intent.setAction(Intent.ACTION_SEND); + } + if (!TextUtils.isEmpty(inputVO.getPackageName())&& + !TextUtils.isEmpty(inputVO.getClassName())) { + intent.setComponent(new ComponentName(inputVO.getPackageName(), inputVO.getClassName())); + } + if (!TextUtils.isEmpty(inputVO.getTitle())){ + intent.putExtra(Intent.EXTRA_TITLE,inputVO.getTitle()); + } + if (!TextUtils.isEmpty(inputVO.getText())){ + intent.putExtra(Intent.EXTRA_TEXT,inputVO.getText()); + } + if (!TextUtils.isEmpty(inputVO.getSubject())){ + intent.putExtra(Intent.EXTRA_SUBJECT,inputVO.getSubject()); + } + if (!TextUtils.isEmpty(inputVO.getImgPath())||inputVO.getImgPaths()!=null) { + intent.setType("image/*"); + }else{ + intent.setType("text/plain"); + } + if (inputVO.getType()==0){ + //微信朋友圈 + intent.putExtra("Kdescription", inputVO.getText()); + intent.setComponent(new ComponentName("com.tencent.mm", + "com.tencent.mm.ui.tools.ShareToTimeLineUI")); + } + + if (intent.getComponent()!=null){ + context.startActivity(intent); + }else{ + context.startActivity(Intent.createChooser(intent,"请选择")); + } + + } + + + } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java index 0a410149..5ea9166e 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java @@ -205,6 +205,7 @@ public class EUExScript { + "setHardwareEnable:function(){uexDispatcher.dispatch('uexWindow','setHardwareEnable',jo(arguments));}," + "setPopHardwareEnable:function(){uexDispatcher.dispatch('uexWindow','setPopHardwareEnable',jo(arguments));}," + "setSwipeCloseEnable:function(){uexDispatcher.dispatch('uexWindow','setSwipeCloseEnable',jo(arguments));}," + + "share:function(){uexDispatcher.dispatch('uexWindow','share',jo(arguments));}," + "setSlidingWindow:function(){uexDispatcher.dispatch('uexWindow','setSlidingWindow',jo(arguments));}," diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index fef9ed25..62f21e69 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -54,6 +54,7 @@ import org.zywx.wbpalmstar.base.ResoureFinder; import org.zywx.wbpalmstar.base.vo.CreateContainerVO; import org.zywx.wbpalmstar.base.vo.SetSwipeCloseEnableVO; +import org.zywx.wbpalmstar.base.vo.ShareInputVO; import org.zywx.wbpalmstar.engine.DataHelper; import org.zywx.wbpalmstar.engine.EBrowser; import org.zywx.wbpalmstar.engine.EBrowserActivity; @@ -64,6 +65,7 @@ import org.zywx.wbpalmstar.engine.EBrwViewEntry; import org.zywx.wbpalmstar.engine.EDialogTask; import org.zywx.wbpalmstar.engine.ESystemInfo; +import org.zywx.wbpalmstar.engine.EUtil; import org.zywx.wbpalmstar.engine.EViewEntry; import org.zywx.wbpalmstar.platform.window.ActionSheetDialog; import org.zywx.wbpalmstar.platform.window.ActionSheetDialog.ActionSheetDialogItemClickListener; @@ -72,6 +74,7 @@ import java.security.MessageDigest; import java.util.ArrayList; +import java.util.List; import java.util.Vector; public class EUExWindow extends EUExBase { @@ -3048,7 +3051,7 @@ public void publishChannelNotificationMsg(String[] params) { } String channelId = params[0]; if (TextUtils.isEmpty(channelId)) { - Log.e("publishChannelNotificationMsg", "channelId is empty!!!"); + BDebug.e("channelId is empty!!!"); return; } String des = params[1]; @@ -3414,6 +3417,23 @@ public void destroyItem(ViewGroup container, int position, Object object) { } } + + public void share(String[] params){ + String jsonStr=params[0]; + ShareInputVO inputVO=DataHelper.gson.fromJson(jsonStr,ShareInputVO.class); + if (!TextUtils.isEmpty(inputVO.getImgPath())){ + inputVO.setImgPath(BUtility.makeRealPath(inputVO.getImgPath(),mBrwView)); + } + if (inputVO.getImgPaths()!=null){ + List realImagePaths=new ArrayList(); + for (String path:inputVO.getImgPaths()){ + realImagePaths.add(BUtility.makeRealPath(path,mBrwView)); + } + inputVO.setImgPaths(realImagePaths); + } + EUtil.share(mContext,inputVO); + } + @Override public void onHandleMessage(Message msg) { if (mBrwView == null || mBrwView.getBrowserWindow() == null || msg == null) { From 81b08ac8ad83c8b4b89bf0b553e7d76b61e932cf Mon Sep 17 00:00:00 2001 From: jiangpingping <1626794969@qq.cm> Date: Tue, 2 Feb 2016 09:46:45 +0800 Subject: [PATCH 06/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8DuexWidget.reloadWidgetB?= =?UTF-8?q?yAppId()=E6=97=A0=E6=95=88=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wbpalmstar/engine/EBrowserWidget.java | 20 +++++++ .../wbpalmstar/engine/EBrowserWindow.java | 54 +++++++------------ .../engine/universalex/EUExWidget.java | 7 ++- en_baseEngineProject/androidEngine.xml | 6 +-- 4 files changed, 48 insertions(+), 39 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java index 71174623..7ffdf701 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java @@ -1111,4 +1111,24 @@ public void onLoadAppData(JSONObject json) { public void setSpaceEnable(SpaceClickListener listener) { mBrw.setSpaceEnable(listener); } + + public void reloadWidget() { + //Sliding window + EBrowserWindow leftSlidingWin = mEWindowStack + .getSlidingWind(EBrowserWindow.rootLeftSlidingWinName); + if (leftSlidingWin != null) { + leftSlidingWin.reloadWindow(); + } + EBrowserWindow rightSlidingWin = mEWindowStack + .getSlidingWind(EBrowserWindow.rootRightSlidingWinName); + if (rightSlidingWin != null) { + rightSlidingWin.reloadWindow(); + } + // normal window + ELinkedList eBrwWins = mEWindowStack.getAll(); + for (int i = 0; i < eBrwWins.size(); i++) { + EBrowserWindow eBrwWin = eBrwWins.get(i); + eBrwWin.reloadWindow(); + } + } } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java index e8455c28..3618cd15 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java @@ -2667,41 +2667,6 @@ public void publishChannelNotification(String channelId, String des) { } } - public void reloadWidgetByAppId(String appId) { - EBrowserWidget eBrwWidget = mBroWidget.getWidgetStack().get(appId); - // normal window - ELinkedList eBrwWins = eBrwWidget.getWindowStack() - .getAll(); - for (int i = 0; i < eBrwWins.size(); i++) { - EBrowserWindow eBrwWin = eBrwWins.get(i); - List> list = eBrwWin.mChannelList; - if (list == null || list.size() == 0) { - continue; - } - eBrwWin.mMainView.reload(); - - // popover window - Collection eBrwViews = eBrwWin.mPopTable.values(); - for (EBrowserView entry : eBrwViews) { - entry.reload(); - } - - // multiPopover window - if (eBrwWin.mMultiPopTable != null - && eBrwWin.mMultiPopTable.size() > 0) { - for (Map.Entry> entry : eBrwWin.mMultiPopTable - .entrySet()) { - ArrayList temp = entry.getValue(); - if (null != temp && temp.size() > 0) { - for (int j = 0; j < temp.size(); j++) { - temp.get(j).reload(); - } - } - } - } - } - } - private void setCallback(final EBrowserView brwView, List> list, String channelId, String data, String type) { String js; for (int i = 0; i < list.size(); i++) { @@ -2834,4 +2799,23 @@ public void addUriTaskSpeci(String winName, String js) { } } + public void reloadWindow() { + mMainView.reload(); + // popover + Collection eBrwViews = mPopTable.values(); + for (EBrowserView entry : eBrwViews) { + entry.reload(); + } + // multiPopover + if (mMultiPopTable != null && mMultiPopTable.size() > 0) { + for (Map.Entry> entry : mMultiPopTable.entrySet()) { + ArrayList temp = entry.getValue(); + if (null != temp && temp.size() > 0) { + for (int j = 0; j < temp.size(); j++) { + temp.get(j).reload(); + } + } + } + } + } } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java index 39f54964..26086f6c 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java @@ -50,6 +50,7 @@ import org.zywx.wbpalmstar.engine.EBrowserActivity; import org.zywx.wbpalmstar.engine.EBrowserAnimation; import org.zywx.wbpalmstar.engine.EBrowserView; +import org.zywx.wbpalmstar.engine.EBrowserWidget; import org.zywx.wbpalmstar.engine.EBrowserWindow; import org.zywx.wbpalmstar.engine.EWgtResultInfo; import org.zywx.wbpalmstar.widgetone.WidgetOneApplication; @@ -903,7 +904,11 @@ private void reloadWidgetByAppIdMsg(String[] params) { if (null == curWind) { return; } - curWind.reloadWidgetByAppId(appId); + EBrowserWidget widget = curWind.getWGT(appId); + if (null == widget) { + return; + } + widget.reloadWidget(); } private void callBackPluginJs(String methodName, String jsonData) { String js = SCRIPT_HEADER + "if(" + methodName + "){" diff --git a/en_baseEngineProject/androidEngine.xml b/en_baseEngineProject/androidEngine.xml index 24b4d296..c5e7f768 100755 --- a/en_baseEngineProject/androidEngine.xml +++ b/en_baseEngineProject/androidEngine.xml @@ -1,6 +1,6 @@ - sdksuit_3.2_151118_01 - android_Engine_3.2_151118_01 - 1、未传递第三方intent参数问题 + sdksuit_3.2_160202_01 + android_Engine_3.2_160202_01 + 1、修复uexWidget.reloadWidgetByAppId()无效问题。 From 575b2a25abf8fbf782dcf5393a264a7a8c55c08b Mon Sep 17 00:00:00 2001 From: jiangpingping <1626794969@qq.cm> Date: Tue, 2 Feb 2016 14:51:38 +0800 Subject: [PATCH 07/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=92=8C=E5=88=A0?= =?UTF-8?q?=E9=99=A4=E6=8F=92=E4=BB=B6view=E6=97=B6=E4=B8=8D=E4=BD=BF?= =?UTF-8?q?=E7=94=A8Handler=E5=8F=91=E9=80=81=E6=B6=88=E6=81=AF=E7=9A=84?= =?UTF-8?q?=E6=96=B9=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wbpalmstar/engine/EBrowserWindow.java | 28 +++++++++++++------ en_baseEngineProject/androidEngine.xml | 2 +- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java index 3618cd15..4a17ee92 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java @@ -202,17 +202,29 @@ public void clearFlag() { } public void addViewToCurrentWindow(View child) { - Message msg = mWindLoop.obtainMessage(); - msg.what = F_WHANDLER_ADD_VIEW; - msg.obj = child; - mWindLoop.sendMessage(msg); + //Message msg = mWindLoop.obtainMessage(); + //msg.what = F_WHANDLER_ADD_VIEW; + //msg.obj = child; + //mWindLoop.sendMessage(msg); + child.setTag(EViewEntry.F_PLUGIN_VIEW_TAG); + Animation anim = child.getAnimation(); + addView(child); + if (null != anim) { + anim.start(); + } + bringChildToFront(child); } public void removeViewFromCurrentWindow(View child) { - Message msg = mWindLoop.obtainMessage(); - msg.what = F_WHANDLER_REMOVE_VIEW; - msg.obj = child; - mWindLoop.sendMessage(msg); + //Message msg = mWindLoop.obtainMessage(); + //msg.what = F_WHANDLER_REMOVE_VIEW; + //msg.obj = child; + //mWindLoop.sendMessage(msg); + Animation removeAnim = child.getAnimation(); + if (null != removeAnim) { + removeAnim.start(); + } + removeView(child); } diff --git a/en_baseEngineProject/androidEngine.xml b/en_baseEngineProject/androidEngine.xml index c5e7f768..4c48186c 100755 --- a/en_baseEngineProject/androidEngine.xml +++ b/en_baseEngineProject/androidEngine.xml @@ -2,5 +2,5 @@ sdksuit_3.2_160202_01 android_Engine_3.2_160202_01 - 1、修复uexWidget.reloadWidgetByAppId()无效问题。 + 1、修复uexWidget.reloadWidgetByAppId()无效问题;2、添加和删除插件view时不使用Handler发送消息的方式。 From a12bbc7e1b0c16a480f9e14a67bf6db38af4bc11 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Tue, 2 Feb 2016 14:59:45 +0800 Subject: [PATCH 08/25] =?UTF-8?q?=E5=8D=95=E4=BE=8B=E6=8F=92=E4=BB=B6?= =?UTF-8?q?=E5=8F=AA=E5=9B=9E=E8=B0=83=E5=88=B0root=E9=A1=B5=E9=9D=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/zywx/wbpalmstar/engine/universalex/EUExManager.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExManager.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExManager.java index 159f6085..abfd2bb3 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExManager.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExManager.java @@ -77,10 +77,9 @@ public void addJavascriptInterface(EBrowserView brwView) { EUExBase objectIntance = null; try { - if (scriptObj.isGlobal == true && scriptObj.pluginObj != null) { + if (scriptObj.isGlobal && scriptObj.pluginObj != null) { objectIntance = scriptObj.pluginObj; - objectIntance.mBrwView = brwView; } else { Constructor init = scriptObj.jobject; @@ -95,7 +94,7 @@ public void addJavascriptInterface(EBrowserView brwView) { objectIntance.setUexName(uName); // brwView.addJavascriptInterface(objectIntance, uexName); - if (scriptObj.isGlobal == true) { + if (scriptObj.isGlobal) { scriptObj.pluginObj = objectIntance; } else { mThirdPlugins.add(objectIntance); From 2c6269a1ec236b1f1e7f5f1b5033cf99f7221fdb Mon Sep 17 00:00:00 2001 From: jiangpingping <1626794969@qq.cm> Date: Tue, 2 Feb 2016 15:26:27 +0800 Subject: [PATCH 09/25] =?UTF-8?q?uexWindow=E5=A2=9E=E5=8A=A0setAutorotateE?= =?UTF-8?q?nable=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wbpalmstar/engine/EBrowserActivity.java | 31 +++++++++++++++++++ .../engine/universalex/EUExScript.java | 3 +- .../engine/universalex/EUExWindow.java | 30 ++++++++++++++++++ en_baseEngineProject/androidEngine.xml | 2 +- 4 files changed, 64 insertions(+), 2 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java index 7d6be7e6..0562eab7 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java @@ -33,6 +33,7 @@ import android.support.v4.app.FragmentActivity; import android.support.v4.content.LocalBroadcastManager; import android.view.KeyEvent; +import android.view.Surface; import android.view.View; import android.view.Window; import android.view.WindowManager; @@ -534,6 +535,36 @@ private final void clean() { Runtime.getRuntime().gc(); } + public final void setAutorotateEnable(int enabled) { + int ori = ActivityInfo.SCREEN_ORIENTATION_USER; + if (enabled == 1) { + ori = getOrientationForRotation(); + } + final int orientation = ori; + new Handler(Looper.getMainLooper()) { + @Override + public void handleMessage(Message msg) { + setRequestedOrientation(orientation); + ; + } + }.sendEmptyMessageDelayed(0, 100); + } + + private int getOrientationForRotation() { + int ori = ActivityInfo.SCREEN_ORIENTATION_USER; + int rotation = this.getWindowManager().getDefaultDisplay().getRotation(); + if (rotation == Surface.ROTATION_0) { + ori = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; + } else if (rotation == Surface.ROTATION_90) { + ori = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; + } else if (rotation == Surface.ROTATION_180) { + ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; + } else if (rotation == Surface.ROTATION_270) { + ori = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; + } + return ori; + } + public final void changeConfiguration(int orientation) { final int ori = intoOrientation(orientation); new Handler(Looper.getMainLooper()) { diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java index 5ea9166e..24248ab8 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java @@ -229,7 +229,8 @@ public class EUExScript { + "createPluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','createPluginViewContainer',jo(arguments));}," + "showPluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','showPluginViewContainer',jo(arguments));}," + "hidePluginViewContainer:function(){uexDispatcher.dispatch('uexWindow','hidePluginViewContainer',jo(arguments));}," - + "getUrlQuery:function(){return uexDispatcher.dispatch('uexWindow','getUrlQuery',jo(arguments))}};" + + "getUrlQuery:function(){return uexDispatcher.dispatch('uexWindow','getUrlQuery',jo(arguments));}," + + "setAutorotateEnable:function(){return uexDispatcher.dispatch('uexWindow','setAutorotateEnable',jo(arguments))}};" + // // DataAnalysis // "window.uexDataAnalysis={" diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index 62f21e69..1db813c3 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -166,6 +166,7 @@ public class EUExWindow extends EUExBase { private static final int MSG_PLUGINVIEW_CONTAINER_SET = 54; private static final int MSG_PLUGINVIEW_CONTAINER_SHOW = 55; private static final int MSG_PLUGINVIEW_CONTAINER_HIDE = 56; + private static final int MSG_FUNCTION_SETAUTOROTATEENABLE= 60; private AlertDialog mAlert; private AlertDialog.Builder mConfirm; private PromptDialog mPrompt; @@ -386,6 +387,32 @@ public void setOrientationMsg(String[] parm) { } } + public void setAutorotateEnable(String[] parm) { + if (parm.length < 1) { + return; + } + Message msg = new Message(); + msg.obj = this; + msg.what = MSG_FUNCTION_SETAUTOROTATEENABLE; + Bundle bd = new Bundle(); + bd.putStringArray(TAG_BUNDLE_PARAM, parm); + msg.setData(bd); + mHandler.sendMessage(msg); + } + + public void setAutorotateEnableMsg(String[] parm) { + int enabled = 0; + try { + enabled = Integer.parseInt(parm[0]); + } catch (Exception e) { + e.printStackTrace(); + } + if (null != mBrwView) { + EBrowserActivity activity = (EBrowserActivity) mContext; + activity.setAutorotateEnable(enabled); + } + } + public void setWindowFrame(String[] parm) { if (parm.length < 3) { return; @@ -3545,6 +3572,9 @@ public void onHandleMessage(Message msg) { case MSG_FUNCTION_SETORIENTATION: if (param != null) setOrientationMsg(param); break; + case MSG_FUNCTION_SETAUTOROTATEENABLE: + if(param != null) setAutorotateEnableMsg(param); + break; case MSG_FUNCTION_SETSLIDINGWIN: handleSetSlidingWin(param); break; diff --git a/en_baseEngineProject/androidEngine.xml b/en_baseEngineProject/androidEngine.xml index 4c48186c..0fb1af04 100755 --- a/en_baseEngineProject/androidEngine.xml +++ b/en_baseEngineProject/androidEngine.xml @@ -2,5 +2,5 @@ sdksuit_3.2_160202_01 android_Engine_3.2_160202_01 - 1、修复uexWidget.reloadWidgetByAppId()无效问题;2、添加和删除插件view时不使用Handler发送消息的方式。 + 1、修复uexWidget.reloadWidgetByAppId()无效问题;2、添加和删除插件view时不使用Handler发送消息的方式;3、uexWindow增加setAutorotateEnable接口。 From 127e8f476934f7d53d4a2855b26e1a45e5a0f09c Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Fri, 19 Feb 2016 15:43:40 +0800 Subject: [PATCH 10/25] =?UTF-8?q?mavenUrl=20=E6=94=AF=E6=8C=81=E9=85=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- en_baseEngineProject/WebkitCorePalm/build.gradle | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/en_baseEngineProject/WebkitCorePalm/build.gradle b/en_baseEngineProject/WebkitCorePalm/build.gradle index 337664be..2ea099a1 100644 --- a/en_baseEngineProject/WebkitCorePalm/build.gradle +++ b/en_baseEngineProject/WebkitCorePalm/build.gradle @@ -10,9 +10,15 @@ project.plugins.whenPluginAdded { plugin -> } buildscript { + + def mavenUrl=System.getenv("GRADLE_M2_HOME"); + if(mavenUrl==null){ + mavenUrl="/usr/share/gradle/m2repository" + } + repositories { maven { - url "/usr/share/gradle/m2repository" + url mavenUrl } } dependencies { From a771f9e53a89400cc998f5bc952b40cf7f47bf8d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E8=90=8D=E8=90=8D?= Date: Tue, 23 Feb 2016 15:10:17 +0800 Subject: [PATCH 11/25] =?UTF-8?q?=E6=8E=A8=E9=80=81=E8=BF=9E=E6=8E=A5?= =?UTF-8?q?=E6=9C=8D=E5=8A=A1=E5=99=A8ANR=E5=BC=82=E5=B8=B8,=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E6=8E=A8=E9=80=81=E5=BF=83=E8=B7=B3=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E4=B8=BA5=E5=88=86=E9=92=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../platform/push/mqttpush/MQTTService.java | 61 +++++++++++-------- 1 file changed, 36 insertions(+), 25 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java index 4ef0f87a..44a282f1 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java @@ -12,8 +12,8 @@ import org.json.JSONObject; import org.zywx.wbpalmstar.platform.push.report.PushReportUtility; +import android.R.integer; import android.app.AlarmManager; -import android.app.NotificationManager; import android.app.PendingIntent; import android.app.Service; import android.content.BroadcastReceiver; @@ -25,6 +25,7 @@ import android.net.NetworkInfo; import android.net.wifi.WifiInfo; import android.net.wifi.WifiManager; +import android.os.AsyncTask; import android.os.Binder; import android.os.PowerManager; import android.os.PowerManager.WakeLock; @@ -143,7 +144,7 @@ public enum MQTTConnectionStatus { // long running, idle connections. Ideally, to keep a connection open // you want to use a keep alive value that is less than the period of // time after which a network operator will kill an idle connection - private short keepAliveSeconds = 20 * 60; + private short keepAliveSeconds = 5 * 60; // This is how the Android client app will identify itself to the // message broker. @@ -295,16 +296,7 @@ synchronized void handleStart() { if (isOnline()) { // we think we have an Internet connection, so try to connect // to the message broker - if (connectToBroker()) { - // we subscribe to a topic - registering to receive push - // notifications with a particular key - // in a 'real' app, you might want to subscribe to multiple - // topics - I'm just subscribing to one as an example - // note that this topicName could include a wildcard, so - // even just with one subscription, we could receive - // messages for multiple topics - subscribeToTopic(topicName); - } + new ConnectAsyncTask().execute(new String[] {}); } else { // we can't do anything now because we don't have a working // data connection @@ -544,9 +536,7 @@ public void connectionLost() throws Exception { broadcastServiceStatus("Connection lost - reconnecting..."); // try to reconnect - if (connectToBroker()) { - subscribeToTopic(topicName); - } + new ConnectAsyncTask().execute(new String[] {}); } // we're finished - if the phone is switched off, it's okay for the CPU @@ -701,6 +691,28 @@ private String getMac() { return macSerial; } + private class ConnectAsyncTask extends AsyncTask { + @Override + protected Boolean doInBackground(String[]... string) { + return connectToBroker(); + } + + @Override + protected void onPostExecute(Boolean result) { + super.onPostExecute(result); + if (result.booleanValue()) { + // we subscribe to a topic - registering to receive push + // notifications with a particular key + // in a 'real' app, you might want to subscribe to multiple + // topics - I'm just subscribing to one as an example + // note that this topicName could include a wildcard, so + // even just with one subscription, we could receive + // messages for multiple topics + subscribeToTopic(topicName); + } + } + } + /* * (Re-)connect to the message broker */ @@ -834,9 +846,9 @@ private void disconnectFromBroker() { // we can now remove the ongoing notification that warns users that // there was a long-running ongoing service running - NotificationManager nm = (NotificationManager) _context - .getSystemService(Service.NOTIFICATION_SERVICE); - nm.cancelAll(); + // NotificationManager nm = (NotificationManager) _context + // .getSystemService(Service.NOTIFICATION_SERVICE); + // nm.cancelAll(); } /* @@ -908,10 +920,10 @@ public void onReceive(Context ctx, Intent intent) { if (isOnline()) { // we have an internet connection - have another try at // connecting - if (connectToBroker()) { - // we subscribe to a topic - registering to receive push - // notifications with a particular key - subscribeToTopic(topicName); + if (!connectionStatus.equals(MQTTConnectionStatus.CONNECTING) + && !connectionStatus.equals(MQTTConnectionStatus.CONNECTED)) { + connectionStatus = MQTTConnectionStatus.CONNECTING; + new ConnectAsyncTask().execute(new String[] {}); } } @@ -982,6 +994,7 @@ public void onReceive(Context context, Intent intent) { // This is good enough for our needs. try { + PushReportUtility.log("PingSender mqttClient.ping()"); mqttClient.ping(); } catch (MqttException e) { // if something goes wrong, it should result in connectionLost @@ -996,9 +1009,7 @@ public void onReceive(Context context, Intent intent) { } // reconnect - if (connectToBroker()) { - subscribeToTopic(topicName); - } + new ConnectAsyncTask().execute(new String[] {}); } // start the next keep alive period From 23feadd04a27eae9dd7abed27fcde13e19475788 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E8=90=8D=E8=90=8D?= Date: Tue, 23 Feb 2016 15:19:48 +0800 Subject: [PATCH 12/25] =?UTF-8?q?=E5=90=88=E5=85=A54.0=E6=8E=A8=E9=80=81,M?= =?UTF-8?q?DM=E5=AF=B9=E6=8E=A54.0=E6=8E=A8=E9=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/universalex/EUExWidget.java | 30 +- .../wbpalmstar/platform/push/EUExPush.java | 2 +- .../platform/push/PushBroadCastReceiver.java | 2 +- .../platform/push/PushDataInfo.java | 137 ++++++++ .../platform/push/PushRecieveMsgReceiver.java | 317 ++++++++++++++---- .../wbpalmstar/platform/push/PushService.java | 51 ++- .../platform/push/mqttpush/MQTTService.java | 57 ++-- .../push/mqttpush/PushDataCallback.java | 1 + .../push/report/PushReportConstants.java | 3 + 9 files changed, 505 insertions(+), 95 deletions(-) create mode 100644 Engine/src/org/zywx/wbpalmstar/platform/push/PushDataInfo.java diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java index 26086f6c..f69787a9 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java @@ -53,6 +53,7 @@ import org.zywx.wbpalmstar.engine.EBrowserWidget; import org.zywx.wbpalmstar.engine.EBrowserWindow; import org.zywx.wbpalmstar.engine.EWgtResultInfo; +import org.zywx.wbpalmstar.platform.push.report.PushReportConstants; import org.zywx.wbpalmstar.widgetone.WidgetOneApplication; import org.zywx.wbpalmstar.widgetone.dataservice.ReData; import org.zywx.wbpalmstar.widgetone.dataservice.WDataManager; @@ -762,7 +763,7 @@ public void run() { public void getPushState(String[] parm) { SharedPreferences sp = mContext.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); String pushMes = sp.getString("pushMes", "0"); String localPushMes = sp.getString("localPushMes", pushMes); jsCallback(function_getPushState, 0, EUExCallback.F_C_INT, @@ -774,21 +775,22 @@ public void getPushInfo(String[] parm) { if (parm.length >= 1) { type = parm[0]; } + SharedPreferences sp = mContext.getSharedPreferences( + PushReportConstants.PUSH_DATA_SHAREPRE, Context.MODE_PRIVATE); String userInfo = null; - try { - if (PUSH_MSG_ALL.equals(type)) { - // 获取推送消息所有内容 - userInfo = ((EBrowserActivity) mContext).getIntent() - .getStringExtra(BUNDLE_MESSAGE); - } else { - userInfo = ((EBrowserActivity) mContext).getIntent() - .getStringExtra(BUNDLE_DATA); - } - } catch (Exception e) { + if (PUSH_MSG_ALL.equals(type)) { + // 获取推送消息所有内容 + userInfo = sp.getString( + PushReportConstants.PUSH_DATA_SHAREPRE_MESSAGE, ""); + } else { + userInfo = sp.getString( + PushReportConstants.PUSH_DATA_SHAREPRE_DATA, ""); + } + if (!TextUtils.isEmpty(userInfo)) { + ((WidgetOneApplication) mContext.getApplicationContext()).getPushInfo( + userInfo, System.currentTimeMillis() + ""); + jsCallback(function_getPushInfo, 0, EUExCallback.F_C_TEXT, userInfo); } - ((WidgetOneApplication) mContext.getApplicationContext()).getPushInfo( - userInfo, System.currentTimeMillis() + ""); - jsCallback(function_getPushInfo, 0, EUExCallback.F_C_TEXT, userInfo); } public void share(String inShareTitle, String inSubject, String inContent) { diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/EUExPush.java b/Engine/src/org/zywx/wbpalmstar/platform/push/EUExPush.java index e59726a0..cf5882d6 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/EUExPush.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/EUExPush.java @@ -67,7 +67,7 @@ public void setPushState(String[] parm) { */ public void getPushState(String[] parm) { SharedPreferences sp = mContext.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); String pushMes = sp.getString("pushMes", "0"); String localPushMes = sp.getString("localPushMes", pushMes); jsCallback(function_getPushState, 0, EUExCallback.F_C_INT, diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/PushBroadCastReceiver.java b/Engine/src/org/zywx/wbpalmstar/platform/push/PushBroadCastReceiver.java index b89ac41c..0020ec9c 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/PushBroadCastReceiver.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/PushBroadCastReceiver.java @@ -31,7 +31,7 @@ public class PushBroadCastReceiver extends BroadcastReceiver { public void onReceive(Context context, Intent intent) { if (ACTION.equals(intent.getAction())) { SharedPreferences sp = context.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); String pushMes = sp.getString("pushMes", "0"); String localPushMes = sp.getString("localPushMes", pushMes); if (!TextUtils.isEmpty(pushMes) && "1".equals(pushMes) diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/PushDataInfo.java b/Engine/src/org/zywx/wbpalmstar/platform/push/PushDataInfo.java new file mode 100644 index 00000000..3f9b581c --- /dev/null +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/PushDataInfo.java @@ -0,0 +1,137 @@ +/* + * Copyright (C) 2014 The AppCan Open Source Project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + */ + +package org.zywx.wbpalmstar.platform.push; + +import java.io.Serializable; + +public class PushDataInfo implements Serializable { + + private static final long serialVersionUID = 1L; + private String pushDataString; + private int contentAvailable; //静默方式;透传(静默):1,通知:0 + private String appId; + private String taskId; + private String title; + private String alert; + private int badge; + private String[] remindType; //声音:sound,震动:shake,呼吸灯:breathe + private String iconUrl; + private String fontColor; + private String behavior; + private String tenantId; + + public PushDataInfo() { + } + + public int getContentAvailable() { + return contentAvailable; + } + + public void setContentAvailable(int contentAvailable) { + this.contentAvailable = contentAvailable; + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getTaskId() { + return taskId; + } + + public void setTaskId(String taskId) { + this.taskId = taskId; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getAlert() { + return alert; + } + + public void setAlert(String alert) { + this.alert = alert; + } + + public String getPushDataString() { + return pushDataString; + } + + public void setPushDataString(String pushDataString) { + this.pushDataString = pushDataString; + } + + public int getBadge() { + return badge; + } + + public void setBadge(int badge) { + this.badge = badge; + } + + public String[] getRemindType() { + return remindType; + } + + public void setRemindType(String[] remindType) { + this.remindType = remindType; + } + + public String getIconUrl() { + return iconUrl; + } + + public void setIconUrl(String iconUrl) { + this.iconUrl = iconUrl; + } + + public String getFontColor() { + return fontColor; + } + + public void setFontColor(String fontColor) { + this.fontColor = fontColor; + } + + public String getBehavior() { + return behavior; + } + + public void setBehavior(String behavior) { + this.behavior = behavior; + } + + public String getTenantId() { + return tenantId; + } + + public void setTenantId(String tenantId) { + this.tenantId = tenantId; + } +} \ No newline at end of file diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/PushRecieveMsgReceiver.java b/Engine/src/org/zywx/wbpalmstar/platform/push/PushRecieveMsgReceiver.java index a3d05df7..1dddab80 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/PushRecieveMsgReceiver.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/PushRecieveMsgReceiver.java @@ -18,10 +18,21 @@ package org.zywx.wbpalmstar.platform.push; +import java.io.File; +import java.io.FileOutputStream; +import java.io.InputStream; +import java.io.OutputStream; import java.lang.reflect.Field; +import java.net.HttpURLConnection; +import java.net.URL; +import java.text.SimpleDateFormat; +import org.apache.http.cookie.SM; import org.json.JSONObject; +import org.zywx.wbpalmstar.base.BUtility; import org.zywx.wbpalmstar.engine.EBrowserActivity; +import org.zywx.wbpalmstar.engine.universalex.EUExUtil; +import org.zywx.wbpalmstar.platform.push.report.PushReportConstants; import org.zywx.wbpalmstar.platform.push.report.PushReportUtility; import android.app.Notification; @@ -31,8 +42,14 @@ import android.content.Context; import android.content.Intent; import android.content.res.Resources; +import android.graphics.Bitmap; +import android.graphics.BitmapFactory; import android.os.Build; +import android.os.Bundle; +import android.os.Environment; import android.text.TextUtils; +import android.webkit.CookieManager; +import android.widget.RemoteViews; public class PushRecieveMsgReceiver extends BroadcastReceiver { @@ -43,74 +60,262 @@ public class PushRecieveMsgReceiver extends BroadcastReceiver { @Override public void onReceive(Context context, Intent intent) { - PushReportUtility - .log("PushRecieveMsgReceiver onReceive->isForground = " - + EBrowserActivity.isForground); - String packg = intent.getStringExtra("packg"); + String packg = intent.getPackage(); if (TextUtils.isEmpty(packg) || !packg.equals(context.getPackageName().toString())) { return; } if (ACTION_PUSH.equals(intent.getAction())) { - if (EBrowserActivity.isForground) { - if (mContext != null) { - intent.putExtra("ntype", F_TYPE_PUSH); - ((EBrowserActivity) mContext).handleIntent(intent); + if (intent.hasExtra(PushReportConstants.PUSH_DATA_INFO_KEY)) { + newPushNotification(context, intent); + } else { + oldPushNotification(context, intent); + } + } + } + + private void newPushNotification(Context context, Intent intent) { + Bundle bundle = intent.getExtras(); + PushDataInfo dataInfo = (PushDataInfo) bundle + .get(PushReportConstants.PUSH_DATA_INFO_KEY); + int contentAvailable = dataInfo.getContentAvailable(); + if (contentAvailable == 0 && !EBrowserActivity.isForground) { + buildPushNotification(context, intent, dataInfo); + } else { + if (mContext != null) { + intent.putExtra("ntype", F_TYPE_PUSH); + intent.putExtra("data", dataInfo.getAlert()); + intent.putExtra("message", dataInfo.getPushDataString()); + ((EBrowserActivity) mContext).handleIntent(intent); + } + } + } + + private void buildPushNotification(Context context, Intent intent, + PushDataInfo dataInfo) { + String title = dataInfo.getTitle(); + String body = dataInfo.getAlert(); + String message = dataInfo.getPushDataString(); + Notification.Builder builder = new Notification.Builder(context); + builder.setAutoCancel(true); + builder.setContentTitle(title); // 通知标题 + builder.setContentText(body); // 通知内容 + builder.setTicker(body); // 通知栏信息 + + String[] remindType = dataInfo.getRemindType(); + if (remindType != null) { + if (remindType.length == 3) { + builder.setDefaults(Notification.DEFAULT_ALL); + } else { + int defaults = 0; + for (int i = 0; i < remindType.length; i++) { + if ("sound".equalsIgnoreCase(remindType[i])) { + defaults = Notification.DEFAULT_SOUND; + continue; + } + if ("shake".equalsIgnoreCase(remindType[i])) { + defaults = defaults + | Notification.DEFAULT_VIBRATE; + continue; + } + if ("breathe".equalsIgnoreCase(remindType[i])) { + defaults = defaults + | Notification.DEFAULT_LIGHTS; + continue; + } } + builder.setDefaults(defaults); + } + } + + Resources res = context.getResources(); + int icon = res.getIdentifier("icon", "drawable", + intent.getPackage()); + builder.setSmallIcon(icon); + builder.setWhen(System.currentTimeMillis()); // 通知时间 + + String iconUrl = dataInfo.getIconUrl(); + boolean isDefaultIcon = !TextUtils.isEmpty(iconUrl) + && "default".equalsIgnoreCase(iconUrl); + Bitmap bitmap = null; + if (!isDefaultIcon) { + bitmap = getIconBitmap(context, iconUrl); + } + String fontColor = dataInfo.getFontColor(); + RemoteViews remoteViews = null; + if (!TextUtils.isEmpty(fontColor)) { + int color = BUtility.parseColor(fontColor); + int alphaColor = parseAlphaColor(fontColor); + remoteViews = new RemoteViews(intent.getPackage(), + EUExUtil.getResLayoutID("push_notification_view")); + // Title + remoteViews.setTextViewText( + EUExUtil.getResIdID("notification_title"), title); + remoteViews.setTextColor( + EUExUtil.getResIdID("notification_title"), color); + // Body + remoteViews.setTextViewText( + EUExUtil.getResIdID("notification_body"), body); + remoteViews.setTextColor( + EUExUtil.getResIdID("notification_body"), + alphaColor); + // LargeIcon + if (bitmap != null) { + remoteViews.setImageViewBitmap( + EUExUtil.getResIdID("notification_largeIcon"), + bitmap); } else { - CharSequence tickerText = intent.getStringExtra("title"); // 状态栏显示的通知文本提示 - Resources res = context.getResources(); - int icon = res.getIdentifier("icon", "drawable", packg); - long when = System.currentTimeMillis(); // 通知产生的时间,会在通知信息里显示 - // 用上面的属性初始化Nofification - - String notifyTitle = null; - String pushMessage = intent.getStringExtra("message"); - String value = intent.getStringExtra("data"); // 推送消息内容json + remoteViews.setImageViewResource( + EUExUtil.getResIdID("notification_largeIcon"), + EUExUtil.getResDrawableID("icon")); + } + // Time + SimpleDateFormat format = new SimpleDateFormat("HH:mm"); + remoteViews.setTextViewText( + EUExUtil.getResIdID("notification_time"), + format.format(System.currentTimeMillis())); + remoteViews.setTextColor( + EUExUtil.getResIdID("notification_time"), + alphaColor); + builder.setContent(remoteViews); + } + + Intent notiIntent = new Intent(context, EBrowserActivity.class); + notiIntent.putExtra("ntype", F_TYPE_PUSH); + notiIntent.putExtra("data", body); + notiIntent.putExtra("message", message); + Bundle bundle = new Bundle(); + bundle.putSerializable(PushReportConstants.PUSH_DATA_INFO_KEY, dataInfo); + notiIntent.putExtras(bundle); + PendingIntent pendingIntent = PendingIntent.getActivity( + context, notificationNB, notiIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + builder.setContentIntent(pendingIntent); + + NotificationManager manager = (NotificationManager) context + .getSystemService(Context.NOTIFICATION_SERVICE); + Notification notification = builder.build(); + // 由于Android v4包的bug,在2.3及以下系统,Builder创建出来的Notification,并没有设置RemoteView,故需要添加此代码 + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB + && remoteViews != null) { + notification.contentView = remoteViews; + } + manager.notify(notificationNB, notification); + notificationNB++; + } + + private int parseAlphaColor(String fontColor) { + if (4 == fontColor.length()) { + String tmpColor = fontColor.substring(1); + char[] t = new char[6]; + t[0] = tmpColor.charAt(0); + t[1] = tmpColor.charAt(0); + t[2] = tmpColor.charAt(1); + t[3] = tmpColor.charAt(1); + t[4] = tmpColor.charAt(2); + t[5] = tmpColor.charAt(2); + fontColor = "#" + String.valueOf(t); + } + return BUtility.parseColor(fontColor.replaceFirst("#", "#AA")); + } + + private Bitmap getIconBitmap(Context context, String iconUrl) { + try { + URL uRL = new URL(iconUrl); + HttpURLConnection connection = (HttpURLConnection) uRL + .openConnection(); + String cookie = CookieManager.getInstance().getCookie(iconUrl); + if (null != cookie) { + connection.setRequestProperty(SM.COOKIE, cookie); + } + connection.connect(); + if (200 == connection.getResponseCode()) { + InputStream input = connection.getInputStream(); + if (input != null) { + Environment.getDownloadCacheDirectory(); + File ecd = context.getExternalCacheDir(); + File file = new File(ecd, "pushIcon.png"); + OutputStream outStream = new FileOutputStream(file); + byte buf[] = new byte[8 * 1024]; + while (true) { + int numread = input.read(buf); + if (numread == -1) { + break; + } + outStream.write(buf, 0, numread); + } + Bitmap bitmap = BitmapFactory.decodeFile(file + .getAbsolutePath()); + return bitmap; + } + } + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + + private void oldPushNotification(Context context, Intent intent) { + PushReportUtility.log("oldPushNotification->isForground = " + + EBrowserActivity.isForground); + if(EBrowserActivity.isForground){ + if(mContext != null){ + intent.putExtra("ntype", F_TYPE_PUSH); + ((EBrowserActivity) mContext).handleIntent(intent); + } + }else{ + CharSequence tickerText = intent.getStringExtra("title"); // 状态栏显示的通知文本提示 + Resources res = context.getResources(); + int icon = res.getIdentifier("icon", "drawable", intent.getPackage()); + long when = System.currentTimeMillis(); // 通知产生的时间,会在通知信息里显示 + // 用上面的属性初始化Nofification + + String notifyTitle = null; + String pushMessage = intent.getStringExtra("message"); + String value = intent.getStringExtra("data"); // 推送消息内容json + try { + JSONObject bodyJson = new JSONObject(value); + notifyTitle = bodyJson.getString("msgName");// 自定义标题解析 + } catch (Exception e) { + PushReportUtility.oe("onReceive", e); + } + if (TextUtils.isEmpty(notifyTitle)) { + notifyTitle = intent.getStringExtra("widgetName");// 若msgName为空,则使用widgetName作为消息标题 + } + if (TextUtils.isEmpty(notifyTitle)) { + notifyTitle = "APPCAN";// 若widgetName为空,则使用APPCAN作为消息标题 + } + CharSequence contentTitle = notifyTitle; // 通知栏标题 + Intent notificationIntent = new Intent(context, EBrowserActivity.class); // 点击该通知后要跳转的Activity + notificationIntent.putExtra("data", value); + notificationIntent.putExtra("message", pushMessage); + notificationIntent.putExtra("ntype", F_TYPE_PUSH); + String ns = Context.NOTIFICATION_SERVICE; + NotificationManager mNotificationManager = (NotificationManager) context + .getSystemService(ns); + Notification notification = new Notification(icon, tickerText, + when); + notification.flags = Notification.FLAG_AUTO_CANCEL; + notification.defaults |= Notification.DEFAULT_SOUND; + if (Build.VERSION.SDK_INT >= 16) { try { - JSONObject bodyJson = new JSONObject(value); - notifyTitle = bodyJson.getString("msgName");// 自定义标题解析 + Field priorityField = Notification.class + .getField("priority"); + priorityField.setAccessible(true); + priorityField.set(notification, 1); } catch (Exception e) { PushReportUtility.oe("onReceive", e); } - if (TextUtils.isEmpty(notifyTitle)) { - notifyTitle = intent.getStringExtra("widgetName");// 若msgName为空,则使用widgetName作为消息标题 - } - if (TextUtils.isEmpty(notifyTitle)) { - notifyTitle = "APPCAN";// 若widgetName为空,则使用APPCAN作为消息标题 - } - CharSequence contentTitle = notifyTitle; // 通知栏标题 - Intent notificationIntent = new Intent(context, EBrowserActivity.class); // 点击该通知后要跳转的Activity - notificationIntent.putExtra("data", value); - notificationIntent.putExtra("message", pushMessage); - notificationIntent.putExtra("ntype", F_TYPE_PUSH); - String ns = Context.NOTIFICATION_SERVICE; - NotificationManager mNotificationManager = (NotificationManager) context - .getSystemService(ns); - Notification notification = new Notification(icon, tickerText, - when); - notification.flags = Notification.FLAG_AUTO_CANCEL; - notification.defaults |= Notification.DEFAULT_SOUND; - if (Build.VERSION.SDK_INT >= 16) { - try { - Field priorityField = Notification.class - .getField("priority"); - priorityField.setAccessible(true); - priorityField.set(notification, 1); - } catch (Exception e) { - PushReportUtility.oe("onReceive", e); - } - } - PendingIntent contentIntent = PendingIntent.getActivity( - context, - notificationNB, notificationIntent, - PendingIntent.FLAG_UPDATE_CURRENT); - notification.setLatestEventInfo(context, contentTitle, tickerText, - contentIntent); - // 把Notification传递给NotificationManager - mNotificationManager.notify(notificationNB, notification); - notificationNB++; } + PendingIntent contentIntent = PendingIntent.getActivity( + context, + notificationNB, notificationIntent, + PendingIntent.FLAG_UPDATE_CURRENT); + notification.setLatestEventInfo(context, contentTitle, tickerText, + contentIntent); + // 把Notification传递给NotificationManager + mNotificationManager.notify(notificationNB, notification); + notificationNB++; } } diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/PushService.java b/Engine/src/org/zywx/wbpalmstar/platform/push/PushService.java index dee69fda..7d8af05c 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/PushService.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/PushService.java @@ -26,6 +26,7 @@ import android.net.ConnectivityManager; import android.net.NetworkInfo; import android.os.AsyncTask; +import android.os.Bundle; import android.os.IBinder; import android.text.TextUtils; import android.util.Log; @@ -139,7 +140,7 @@ private void start() { // mamPush_port = host_and_port.split(":")[1]; // } SharedPreferences sp = this.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); String pushMes = sp.getString("pushMes", "0"); String localPushMes = sp.getString("localPushMes", pushMes); if ("1".equals(localPushMes) && "1".equals(pushMes)) { @@ -317,7 +318,6 @@ private void runningNotification(JSONObject text) throws JSONException { Intent intent = new Intent(PushRecieveMsgReceiver.ACTION_PUSH); intent.putExtra("data", value); intent.putExtra("title", tickerText); - intent.putExtra("packg", packg); intent.putExtra("widgetName", widgetName); intent.setPackage(packg); intent.putExtra("message", pushMessage); @@ -521,4 +521,51 @@ public void pushData(JSONObject text) { } } + @Override + public void pushDataInfo(JSONObject data) { + PushDataInfo dataInfo = new PushDataInfo(); + dataInfo.setPushDataString(data.toString()); + dataInfo.setContentAvailable(data + .optInt(PushReportConstants.PUSH_DATA_JSON_KEY_CONTENT_AVAILABLE)); + dataInfo.setAppId(data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_APPID)); + dataInfo.setTaskId(data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_TASKID)); + dataInfo.setTitle(data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_TITLE)); + dataInfo.setAlert(data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_ALERT)); + dataInfo.setBadge(data + .optInt(PushReportConstants.PUSH_DATA_JSON_KEY_BADGE)); + dataInfo.setTenantId(data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_TENANTID)); + String remindStrs = data + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_REMINDTYPE); + if (!TextUtils.isEmpty(remindStrs)) { + dataInfo.setRemindType(remindStrs.split(",")); + } + + JSONObject styleJsonObject = data + .optJSONObject(PushReportConstants.PUSH_DATA_JSON_KEY_STYLE); + if (null != styleJsonObject) { + dataInfo.setIconUrl(styleJsonObject + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_ICON)); + dataInfo.setFontColor(styleJsonObject + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_RGB)); + } + + JSONObject behaviorJsonObject = data + .optJSONObject(PushReportConstants.PUSH_DATA_JSON_KEY_BEHAVIOR); + if (null != behaviorJsonObject) { + dataInfo.setBehavior(behaviorJsonObject + .optString(PushReportConstants.PUSH_DATA_JSON_KEY_BEHAVIOR)); + } + + Intent intent = new Intent(PushRecieveMsgReceiver.ACTION_PUSH); + Bundle bundle = new Bundle(); + bundle.putSerializable(PushReportConstants.PUSH_DATA_INFO_KEY, dataInfo); + intent.putExtras(bundle); + intent.setPackage(getPackageName()); + sendBroadcast(intent); + } } diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java index 44a282f1..575b1809 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/MQTTService.java @@ -572,39 +572,54 @@ public void publishArrived(String topic, byte[] payloadbytes, int qos, JSONObject json; try { + PushReportUtility.log("publishArrived reData "+reData); String decryptedData = Rc4Encrypt.decry_RC4(reData, mAppId); + PushReportUtility.log("publishArrived decryptedData "+decryptedData); json = new JSONObject(decryptedData); - if (json.has("mdm") && json.getString("mdm") != null) { - Intent intent = new Intent(); - intent.setAction(ACTION_MDM); - intent.setPackage(_context.getPackageName()); - intent.putExtra("mdmtoken", json.getString("mdm")); - _context.sendBroadcast(intent); - + String turn = json.optString("turn"); + if ("on".equalsIgnoreCase(turn)) { + JSONObject data = json.getJSONObject("data"); + if (data.has("sysMsg")) { + JSONObject sysMsg = data.getJSONObject("sysMsg"); + if (sysMsg.has("mdm") && sysMsg.getString("mdm") != null) { + Intent intent = new Intent(); + intent.setAction(ACTION_MDM); + intent.setPackage(_context.getPackageName()); + intent.putExtra("mdmtoken", sysMsg.getString("mdm")); + _context.sendBroadcast(intent); + } + } else { + if (pushDataCallback != null) { + pushDataCallback.pushDataInfo(data); + } + } } else { - - String status = json.getString("status"); - if ("ok".equals(status)) { - String messageList = json.getString("messageList"); - JSONArray jsonArray = new JSONArray(messageList); - for (int i = 0; i < jsonArray.length(); i++) { - // runningNotification(jsonArray.getJSONObject(i)); - if (pushDataCallback != null) { - pushDataCallback.pushData(jsonArray - .getJSONObject(i)); + if (json.has("mdm") && json.getString("mdm") != null) { + Intent intent = new Intent(); + intent.setAction(ACTION_MDM); + intent.setPackage(_context.getPackageName()); + intent.putExtra("mdmtoken", json.getString("mdm")); + _context.sendBroadcast(intent); + } else { + String status = json.getString("status"); + if ("ok".equals(status)) { + String messageList = json.getString("messageList"); + JSONArray jsonArray = new JSONArray(messageList); + for (int i = 0; i < jsonArray.length(); i++) { + // runningNotification(jsonArray.getJSONObject(i)); + if (pushDataCallback != null) { + pushDataCallback.pushData(jsonArray + .getJSONObject(i)); + } } - } - } } - } catch (Exception e) { PushReportUtility.oe("publishArrived", e); e.printStackTrace(); } - } // receiving this message will have kept the connection alive for us, so diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/PushDataCallback.java b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/PushDataCallback.java index 790aae8d..926f8b8e 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/PushDataCallback.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/mqttpush/PushDataCallback.java @@ -22,4 +22,5 @@ public interface PushDataCallback { public void pushData(JSONObject text); + public void pushDataInfo(JSONObject data); } diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java index 517cdf1a..36fc8c13 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java @@ -36,6 +36,9 @@ public interface PushReportConstants { public static final String KEY_PUSH_REPORT_SOFTTOKEN = "softToken"; public static final String KEY_PUSH_REPORT_EVENTTYPE = "eventType"; public static final String KEY_PUSH_REPORT_OCCUREDAT = "occuredAt"; + public static final String PUSH_DATA_SHAREPRE = "pushData_sharePre"; + public static final String PUSH_DATA_SHAREPRE_DATA = "pushData_data"; + public static final String PUSH_DATA_SHAREPRE_MESSAGE = "pushData_message"; public final static int TYPE_INIT_PUSH = 0; public final static int TYPE_PUSH_BINDUSER = 1; From 96e0cb248156d66dc0c10dde2a2412c5bbb713b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E8=90=8D=E8=90=8D?= Date: Tue, 23 Feb 2016 15:58:37 +0800 Subject: [PATCH 13/25] =?UTF-8?q?=E6=8E=A8=E9=80=81=E6=B6=88=E6=81=AFnotif?= =?UTF-8?q?y=E7=9A=84=E5=9B=9E=E8=B0=83=E9=9C=80=E8=A6=81=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E5=8F=82=E6=95=B0=E5=8C=BA=E5=88=86=E7=8A=B6=E6=80=81?= =?UTF-8?q?=EF=BC=8C=E6=8E=A8=E9=80=814.0=E5=A2=9E=E5=8A=A0=E6=8E=A8?= =?UTF-8?q?=E9=80=81=E6=B6=88=E6=81=AF=E6=89=93=E5=BC=80=E7=9A=84=E4=B8=8A?= =?UTF-8?q?=E6=8A=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/zywx/wbpalmstar/base/BConstant.java | 87 ++++++++++--------- .../org/zywx/wbpalmstar/engine/EBrowser.java | 4 +- .../wbpalmstar/engine/EBrowserActivity.java | 81 ++++++++++++----- .../wbpalmstar/engine/EBrowserWidget.java | 9 +- .../wbpalmstar/engine/EBrowserWidgetPool.java | 20 ++++- .../wbpalmstar/engine/EBrowserWindow.java | 4 +- .../engine/universalex/EUExWidget.java | 3 +- .../platform/push/report/PushReportAgent.java | 61 ++++++++----- .../push/report/PushReportConstants.java | 17 ++++ .../push/report/PushReportHttpClient.java | 61 +++++++++++++ .../push/report/PushReportThread.java | 31 ++++++- .../push/report/PushReportUtility.java | 40 +++++++++ 12 files changed, 322 insertions(+), 96 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java index c0831c31..ed5417f4 100755 --- a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java +++ b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java @@ -27,54 +27,55 @@ public class BConstant { public static final String ENGINE_VERSION="3.2.2"; - public static final String F_URL = "url"; - public static final String F_WIDGET = "widget"; - public static final String F_MULTIPLEWINDOW = "MultipleWindow"; - public static final String F_WIDGETONE = "widgetone"; - public static final String F_USER_AGENT = "userAgent"; - public static final String F_CONTENT_DISPOSITION = "contentDisposition"; - public static final String F_MIMETYPE = "mimeType"; - public static final String F_CONTENTLENGTH = "contentLength"; - public static final String F_DIALOG_TYPE = "dialogType"; - public static final String F_ASSETS_ROOT = "android_asset/"; - public static final String F_SDCARD_ROOT = "file:///sdcard/"; - public static final String F_PUSH_WIN_NAME = "winName"; - public static final String F_PUSH_NOTI_FUN_NAME = "funName"; + public static final String F_URL = "url"; + public static final String F_WIDGET = "widget"; + public static final String F_MULTIPLEWINDOW = "MultipleWindow"; + public static final String F_WIDGETONE = "widgetone"; + public static final String F_USER_AGENT = "userAgent"; + public static final String F_CONTENT_DISPOSITION = "contentDisposition"; + public static final String F_MIMETYPE = "mimeType"; + public static final String F_CONTENTLENGTH = "contentLength"; + public static final String F_DIALOG_TYPE = "dialogType"; + public static final String F_ASSETS_ROOT = "android_asset/"; + public static final String F_SDCARD_ROOT = "file:///sdcard/"; + public static final String F_PUSH_APPID = "appId"; + public static final String F_PUSH_WIN_NAME = "winName"; + public static final String F_PUSH_NOTI_FUN_NAME = "funName"; - public static Application app=null; + public static Application app = null; - public static String byteChange(int size) { - DecimalFormat df = new DecimalFormat("0.00"); - float f; - if (size < 1024 * 1024) { - f = (float) ((float) size / (float) 1024); - return (df.format(new Float(f).doubleValue()) + " KB"); - } else { - f = (float) ((float) size / (float) (1024 * 1024)); - return (df.format(new Float(f).doubleValue()) + " MB"); - } + public static String byteChange(int size) { + DecimalFormat df = new DecimalFormat("0.00"); + float f; + if (size < 1024 * 1024) { + f = (float) ((float) size / (float) 1024); + return (df.format(new Float(f).doubleValue()) + " KB"); + } else { + f = (float) ((float) size / (float) (1024 * 1024)); + return (df.format(new Float(f).doubleValue()) + " MB"); + } - } + } - public static String getSizeText(int downLoadSize, int fileSize) { - return byteChange(downLoadSize) + "/" + byteChange(fileSize); - } + public static String getSizeText(int downLoadSize, int fileSize) { + return byteChange(downLoadSize) + "/" + byteChange(fileSize); + } - public static enum downLoadStatus { - /** - * Indicates that the task has not been executed yet. - */ - WAIT, - /** - * Indicates that the task is running. - */ - RUNNING, - PAUSED, - /** - * Indicates that {@link AsyncTask#onPostExecute} has finished. - */ - FINISHED, - } + public static enum downLoadStatus { + /** + * Indicates that the task has not been executed yet. + */ + WAIT, + /** + * Indicates that the task is running. + */ + RUNNING, + PAUSED, + /** + * Indicates that {@link AsyncTask#onPostExecute} has finished. + */ + FINISHED, + } } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowser.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowser.java index f0434c68..ff44316e 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowser.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowser.java @@ -127,11 +127,11 @@ protected void hiddenShelter() { mBrwWindPol.notifyHiddenShelter(); } - protected void pushNotify() { + protected void pushNotify(String appType) { if (null == mBrwWindPol) { return; } - mBrwWindPol.pushNotify(); + mBrwWindPol.pushNotify(appType); } public void uexOnAuthorize(String id) { diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java index 0562eab7..2fdb064c 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java @@ -21,7 +21,9 @@ import android.app.AlertDialog; import android.content.Context; import android.content.DialogInterface; +import android.content.SharedPreferences; import android.content.DialogInterface.OnClickListener; +import android.content.SharedPreferences.Editor; import android.content.Intent; import android.content.pm.ActivityInfo; import android.content.res.Configuration; @@ -54,7 +56,9 @@ import org.zywx.wbpalmstar.engine.universalex.EUExUtil; import org.zywx.wbpalmstar.engine.universalex.ThirdPluginMgr; import org.zywx.wbpalmstar.engine.universalex.ThirdPluginObject; +import org.zywx.wbpalmstar.platform.push.PushDataInfo; import org.zywx.wbpalmstar.platform.push.PushRecieveMsgReceiver; +import org.zywx.wbpalmstar.platform.push.report.PushReportConstants; import org.zywx.wbpalmstar.widgetone.WidgetOneApplication; import org.zywx.wbpalmstar.widgetone.dataservice.WWidgetData; @@ -71,6 +75,9 @@ public final class EBrowserActivity extends FragmentActivity { public static final int F_OAUTH_CODE = 100001; public final static int FILECHOOSER_RESULTCODE = 233; + public final static String APP_TYPE_NOT_START = "0"; + public final static String APP_TYPE_START_BACKGROUND = "1"; + public final static String APP_TYPE_START_FORGROUND= "2"; private EBrowser mBrowser; private boolean mKeyDown; @@ -427,33 +434,67 @@ public void handleIntent(Intent intent) { try { Intent firstIntent = getIntent(); int type = intent.getIntExtra("ntype", 0); - ; switch (type) { - case ENotification.F_TYPE_PUSH: - if (null != mBrowser) { - String data = intent.getStringExtra("data"); - String pushMessage = intent.getStringExtra("message"); - firstIntent.putExtra("data", data); - firstIntent.putExtra("message", pushMessage); - mBrowser.pushNotify(); - } - break; - case ENotification.F_TYPE_USER: - - break; - case ENotification.F_TYPE_SYS: - - break; - default: - getIntentData(intent); - firstIntent.putExtras(intent); - break; + case ENotification.F_TYPE_PUSH: + handlePushNotify(intent); + break; + case ENotification.F_TYPE_USER: + break; + case ENotification.F_TYPE_SYS: + break; + default: + getIntentData(intent); + firstIntent.putExtras(intent); + break; } } catch (Exception e) { e.printStackTrace(); } } + private void handlePushNotify(Intent intent) { + if (null != mBrowser) { + try { + String data = intent.getStringExtra("data"); + String pushMessage = intent.getStringExtra("message"); + SharedPreferences sp = getSharedPreferences( + PushReportConstants.PUSH_DATA_SHAREPRE, + Context.MODE_PRIVATE); + Editor editor = sp.edit(); + editor.putString( + PushReportConstants.PUSH_DATA_SHAREPRE_DATA, data); + editor.putString( + PushReportConstants.PUSH_DATA_SHAREPRE_MESSAGE, + pushMessage); + if (intent.hasExtra(PushReportConstants.PUSH_DATA_INFO_KEY)) { + PushDataInfo dataInfo = (PushDataInfo) intent.getExtras() + .get(PushReportConstants.PUSH_DATA_INFO_KEY); + String taskId = dataInfo.getTaskId(); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_TASKID, + taskId); + String tenantId = dataInfo.getTenantId(); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_TENANTID, + tenantId); + } + editor.commit(); + String appType = ""; + if (mVisable && isForground) { + //应用在前台 + appType = APP_TYPE_START_FORGROUND; + } else if (!mVisable && !isForground) { + //应用Home键退到后台再点通知进入 + appType = APP_TYPE_START_BACKGROUND; + } else if (mVisable && !isForground) { + //应用Back键退出再点通知进入 + appType = APP_TYPE_NOT_START; + } + mBrowser.pushNotify(appType); + } catch (Exception e) { + e.printStackTrace(); + } + } + } + public final void exitApp(boolean showDilog) { Message msg = mEHandler.obtainMessage(EHandler.F_MSG_EXIT_APP, showDilog); diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java index 7ffdf701..14509763 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java @@ -82,7 +82,7 @@ public EBrowserWidget(Context context, WWidgetData inWidget, setAlwaysDrawnWithCacheEnabled(false); EUtil.viewBaseSetting(this); mPres = mContext.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); mPushNotifyWindName = mPres.getString(BConstant.F_PUSH_WIN_NAME, ""); mPushNotifyFunctionName = mPres.getString(BConstant.F_PUSH_NOTI_FUN_NAME, ""); } @@ -302,7 +302,7 @@ public void notifyWindowFinish(EBrowserWindow window, EBrowserView view, mBrw.hiddenShelter(); if (mBrw.isFromPush()) { mBrw.setFromPush(false); - mBrw.pushNotify(); + mBrw.pushNotify(EBrowserActivity.APP_TYPE_START_FORGROUND); } } clearFlag(); @@ -581,10 +581,11 @@ public void evaluateMultiPopoverScript(WebView inWhich, String inWndName, } } - public void setPushNotify(String windName, String function) { + public void setPushNotify(String windName, String function, String appId) { mPushNotifyWindName = windName; mPushNotifyFunctionName = function; SharedPreferences.Editor editor = mPres.edit(); + editor.putString(BConstant.F_PUSH_APPID, appId); editor.putString(BConstant.F_PUSH_WIN_NAME, windName); editor.putString(BConstant.F_PUSH_NOTI_FUN_NAME, function); editor.commit(); @@ -593,7 +594,7 @@ public void setPushNotify(String windName, String function) { public void pushNotify(String info) { EBrowserWindow beNotify = mEWindowStack.get(mPushNotifyWindName); if (null != beNotify) { - beNotify.pushNotify(mPushNotifyFunctionName); + beNotify.pushNotify(mPushNotifyFunctionName, info); } } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidgetPool.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidgetPool.java index cb90d40c..c7da9667 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidgetPool.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidgetPool.java @@ -19,6 +19,7 @@ package org.zywx.wbpalmstar.engine; import org.json.JSONObject; +import org.zywx.wbpalmstar.base.BConstant; import org.zywx.wbpalmstar.base.BDebug; import org.zywx.wbpalmstar.engine.external.Compat; import org.zywx.wbpalmstar.engine.universalex.EUExWidget.SpaceClickListener; @@ -28,11 +29,13 @@ import android.annotation.SuppressLint; import android.content.Context; +import android.content.SharedPreferences; import android.content.res.Configuration; import android.os.Build; import android.os.Handler; import android.os.Looper; import android.os.Message; +import android.text.TextUtils; import android.view.View; import android.view.animation.Animation; import android.view.animation.Animation.AnimationListener; @@ -141,9 +144,20 @@ public EBrowserWidget getWidget(int index) { return mWgtStack.get(index); } - public void pushNotify() { - - mWgtStack.peek().pushNotify(null); + public void pushNotify(String appType) { + SharedPreferences pres = mContext.getSharedPreferences("saveData", + Context.MODE_MULTI_PROCESS); + String appId = pres.getString(BConstant.F_PUSH_APPID, ""); + if (TextUtils.isEmpty(appId)) { + mWgtStack.peek().pushNotify(appType); + } else { + EBrowserWidget widget = mWgtStack.get(appId); + if (null != widget) { + widget.pushNotify(appType); + } else { + mWgtStack.peek().pushNotify(appType); + } + } } public void uexOnAuthorize(String id) { diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java index 4a17ee92..908f24a6 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWindow.java @@ -918,11 +918,11 @@ protected void notifyScreenOrientationChange(Configuration newConfig) { } } - protected void pushNotify(String function) { + protected void pushNotify(String function, String appType) { if (null == mMainView) { return; } - String js = "javascript:" + function + "();"; + String js = "javascript:" + function + "('" + appType + "');"; mMainView.loadUrl(js); } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java index f69787a9..d3c0009f 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWidget.java @@ -656,7 +656,8 @@ public void getOpenerInfo(String[] parm) { public void setPushNotifyCallback(String[] parm) { mBrwView.getBrowserWindow().getEBrowserWidget() - .setPushNotify(mBrwView.getWindowName(), parm[0]); + .setPushNotify(mBrwView.getWindowName(), parm[0], + mBrwView.getCurrentWidget().m_appId); } public void checkUpdate(String[] parm) { diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportAgent.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportAgent.java index d8440501..4694a23b 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportAgent.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportAgent.java @@ -23,6 +23,7 @@ import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; +import android.text.TextUtils; import android.util.Log; import org.apache.http.NameValuePair; @@ -156,26 +157,46 @@ public static void reportPush(String pushInfo, String occuredAt, String eventType, String softToken, Context context) { PushReportUtility.log("reportPush===" + pushInfo + " eventType===" + eventType); - String msgId = parsePushInfo2MsgId(pushInfo); - if (msgId != null) { - List nameValuePairs = new ArrayList(); - nameValuePairs - .add(new BasicNameValuePair(KEY_PUSH_REPORT_MSGID, msgId)); - nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_SOFTTOKEN, - softToken)); - nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_EVENTTYPE, - eventType)); - nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_OCCUREDAT, - occuredAt)); - if (eventType.equals(PushReportConstants.EVENT_TYPE_OPEN)) { - PushReportThread.getPushReportThread(context, sAgent, - TYPE_PUSH_REPORT_OPEN, nameValuePairs).start(); - Log.i("push", "EVENT_TYPE_OPEN"); - } else if (eventType.equals(PushReportConstants.EVENT_TYPE_ARRIVED)) { - PushReportThread.getPushReportThread(context, sAgent, - TYPE_PUSH_REPORT_ARRIVED, nameValuePairs).start(); - Log.i("push", "EVENT_TYPE_ARRIVED"); + SharedPreferences sp = context.getSharedPreferences( + PushReportConstants.PUSH_DATA_SHAREPRE, Context.MODE_PRIVATE); + String taskId = sp.getString( + PushReportConstants.PUSH_DATA_SHAREPRE_TASKID, ""); + PushReportUtility.log("reportPush===taskId " + taskId); + if (TextUtils.isEmpty(taskId)) { + String msgId = parsePushInfo2MsgId(pushInfo); + if (msgId != null) { + List nameValuePairs = new ArrayList(); + nameValuePairs + .add(new BasicNameValuePair(KEY_PUSH_REPORT_MSGID, msgId)); + nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_SOFTTOKEN, + softToken)); + nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_EVENTTYPE, + eventType)); + nameValuePairs.add(new BasicNameValuePair(KEY_PUSH_REPORT_OCCUREDAT, + occuredAt)); + if (eventType.equals(PushReportConstants.EVENT_TYPE_OPEN)) { + PushReportThread.getPushReportThread(context, sAgent, + TYPE_PUSH_REPORT_OPEN, nameValuePairs).start(); + Log.i("push", "EVENT_TYPE_OPEN"); + } else if (eventType.equals(PushReportConstants.EVENT_TYPE_ARRIVED)) { + PushReportThread.getPushReportThread(context, sAgent, + TYPE_PUSH_REPORT_ARRIVED, nameValuePairs).start(); + Log.i("push", "EVENT_TYPE_ARRIVED"); + } } + } else { + String tenantId = sp.getString( + PushReportConstants.PUSH_DATA_SHAREPRE_TENANTID, ""); + PushReportUtility.log("reportPush===tenantId " + tenantId); + Editor editor = sp.edit(); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_DATA, ""); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_MESSAGE, ""); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_TASKID, ""); + editor.putString(PushReportConstants.PUSH_DATA_SHAREPRE_TENANTID, ""); + editor.commit(); + PushReportThread.getNewPushReportOpen(context, + TYPE_NEW_PUSH_REPORT_OPEN, taskId, tenantId, softToken).start(); + Log.i("push", "TYPE_NEW_PUSH_REPORT_OPEN"); } } @@ -204,7 +225,7 @@ private static String parsePushInfo2MsgId(String pushInfo) { public static void setPushState(Context context, int type) { PushReportUtility.log("setPushState--" + type); SharedPreferences sp = context.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); Editor editor = sp.edit(); editor.putString("localPushMes", String.valueOf(type)); editor.commit(); diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java index 36fc8c13..740f510f 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportConstants.java @@ -39,12 +39,29 @@ public interface PushReportConstants { public static final String PUSH_DATA_SHAREPRE = "pushData_sharePre"; public static final String PUSH_DATA_SHAREPRE_DATA = "pushData_data"; public static final String PUSH_DATA_SHAREPRE_MESSAGE = "pushData_message"; + public static final String PUSH_DATA_SHAREPRE_TASKID = "pushData_taskId"; + public static final String PUSH_DATA_SHAREPRE_TENANTID = "pushData_tenantId"; + + public static final String PUSH_DATA_INFO_KEY = "pushDataInfo"; + public static final String PUSH_DATA_JSON_KEY_APPID = "appId"; + public static final String PUSH_DATA_JSON_KEY_TASKID = "taskId"; + public static final String PUSH_DATA_JSON_KEY_TITLE = "title"; + public static final String PUSH_DATA_JSON_KEY_ALERT = "alert"; + public static final String PUSH_DATA_JSON_KEY_BADGE = "badge"; + public static final String PUSH_DATA_JSON_KEY_CONTENT_AVAILABLE = "content-available"; + public static final String PUSH_DATA_JSON_KEY_REMINDTYPE = "remindType"; + public static final String PUSH_DATA_JSON_KEY_STYLE = "style"; + public static final String PUSH_DATA_JSON_KEY_ICON = "icon"; + public static final String PUSH_DATA_JSON_KEY_RGB = "rgb"; + public static final String PUSH_DATA_JSON_KEY_BEHAVIOR = "behavior"; + public static final String PUSH_DATA_JSON_KEY_TENANTID = "tenantId"; public final static int TYPE_INIT_PUSH = 0; public final static int TYPE_PUSH_BINDUSER = 1; public final static int TYPE_PUSH_REPORT_OPEN = 2; public final static int TYPE_PUSH_REPORT_ARRIVED = 3; public final static int TYPE_PUSH_UNBINDUSER = 4; + public final static int TYPE_NEW_PUSH_REPORT_OPEN = 5; public static final int NETWORK_TYPE_UNKNOWN = 0; /** diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportHttpClient.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportHttpClient.java index 65241aa9..b470045f 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportHttpClient.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportHttpClient.java @@ -19,6 +19,8 @@ package org.zywx.wbpalmstar.platform.push.report; import android.content.Context; +import android.content.SharedPreferences; +import android.text.TextUtils; import org.apache.http.Header; import org.apache.http.HttpResponse; @@ -30,6 +32,7 @@ import org.apache.http.client.methods.HttpPost; import org.apache.http.conn.ssl.SSLSocketFactory; import org.apache.http.entity.ByteArrayEntity; +import org.apache.http.entity.StringEntity; import org.apache.http.entity.mime.HttpMultipartMode; import org.apache.http.entity.mime.MultipartEntity; import org.apache.http.entity.mime.content.FileBody; @@ -37,7 +40,9 @@ import org.apache.http.impl.client.DefaultHttpClient; import org.apache.http.protocol.HTTP; import org.apache.http.util.EntityUtils; +import org.json.JSONObject; import org.zywx.wbpalmstar.base.BDebug; +import org.zywx.wbpalmstar.engine.universalex.EUExUtil; import org.zywx.wbpalmstar.platform.certificates.Http; import javax.net.ssl.SSLContext; @@ -201,6 +206,62 @@ public static String sendPostWithFile(String url, return null; } + public static String newPushOpenByPostData(String url, Context mCtx, String tenantId, String softToken) { + PushReportUtility.log(url); + PushReportUtility.log("softToken ==" + softToken); + HttpPost post = new HttpPost(url); + HttpClient httpClient = getSSLHttpClient(mCtx); + HttpResponse httpResponse = null; + try { + SharedPreferences preferences = mCtx.getSharedPreferences( + "app", Context.MODE_PRIVATE); + String appid = preferences.getString("appid", null); + if (!TextUtils.isEmpty(tenantId)) { + appid = tenantId + ":" + appid; + } + String appkey = EUExUtil.getString("appkey"); + PushReportUtility.log("appid ==" + appid + " appkey ==" + appkey); + post.addHeader("Accept", "*/*"); + post.addHeader("Content-Type", "application/json"); + post.addHeader("x-mas-app-id", appid); + post.addHeader(PushReportUtility.KEY_APPVERIFY, + PushReportUtility.getAppVerifyValue(appid, appkey, + System.currentTimeMillis())); + + JSONObject jsonObject = new JSONObject(); + jsonObject.put("count", 1); + jsonObject.put("softToken", softToken); + StringEntity stringEntity = new StringEntity(jsonObject.toString()); + post.setEntity(stringEntity); + + // 取得HTTP response + httpResponse = httpClient.execute(post); + // 若状态码为200 ok + int responesCode = httpResponse.getStatusLine().getStatusCode(); + PushReportUtility.log("responesCode ==" + responesCode); + if (responesCode == 200) { + // 取出回应字串 + String res = EntityUtils.toString(httpResponse.getEntity()); + return res; + } + } catch (Exception e) { + PushReportUtility.oe("newPushOpenByNameValuePair: " + url, e); + } finally { + if (post != null) { + post.abort(); + post = null; + } + if (httpResponse != null) { + httpResponse = null; + } + if (httpClient != null) { + httpClient.getConnectionManager().shutdown(); + httpClient = null; + } + } + return null; + } + public static String sendPostDataByNameValuePair(String url, List nameValuePairs, Context mCtx) { PushReportUtility.log(url); diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportThread.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportThread.java index fd36910c..1fd83eff 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportThread.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportThread.java @@ -38,6 +38,9 @@ public class PushReportThread extends Thread implements PushReportConstants { private int mThreadType; private String host_pushReport = null; private String host_pushBindUser = null; + private String mTaskId = null; + private String mTenantId = null; + private String mSoftToken = null; // private PushReportAgent mPushAgent = null; private List mNameValuePairs = null; private boolean mIsRun; @@ -76,6 +79,15 @@ public static PushReportThread getPushReportThread(Context inActivity, return pushReportThread; } + public static PushReportThread getNewPushReportOpen(Context inActivity, + int threadType, String taskId, String tenantId, String softToken) { + PushReportThread pushReportThread = new PushReportThread(inActivity, threadType); + pushReportThread.mTaskId = taskId; + pushReportThread.mTenantId = tenantId; + pushReportThread.mSoftToken = softToken; + return pushReportThread; + } + @Override public void run() { Process.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND); @@ -114,6 +126,13 @@ public void run() { } pushReportArrive(); break; + case TYPE_NEW_PUSH_REPORT_OPEN: + if (TextUtils.isEmpty(host_pushBindUser)) { + Log.w("PushReportThread", "host_pushBindUser is empty"); + break; + } + newPushReportOpen(); + break; } mIsRun = false; } @@ -135,7 +154,7 @@ private void initPush() { String localPushMes = "0";// setPushState 可以改变 String pushMes = "1"; SharedPreferences sp = m_activity.getSharedPreferences("saveData", - Context.MODE_PRIVATE); + Context.MODE_MULTI_PROCESS); Editor editor = sp.edit(); if (!PushReportAgent.widgetPush) { pushMes = "0"; @@ -168,6 +187,16 @@ private void pushReportOpen() { Log.i("PushReportThread", "pushReportOpen result======" + result); } + private void newPushReportOpen() { + if (!host_pushBindUser.endsWith("/")) { + host_pushBindUser = host_pushBindUser + "/"; + } + host_pushBindUser = host_pushBindUser + "4.0/count/" + mTaskId; + String result = PushReportHttpClient.newPushOpenByPostData( + host_pushBindUser, m_activity, mTenantId, mSoftToken); + Log.i("PushReportThread", "newPushReportOpen result======" + result); + } + private void pushReportArrive() { String result = PushReportHttpClient.sendPostDataByNameValuePair( (host_pushReport + url_push_report), mNameValuePairs, diff --git a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportUtility.java b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportUtility.java index a7882170..eedd8479 100755 --- a/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportUtility.java +++ b/Engine/src/org/zywx/wbpalmstar/platform/push/report/PushReportUtility.java @@ -52,6 +52,7 @@ public class PushReportUtility { private static boolean isLog = true; + public final static String KEY_APPVERIFY = "appverify"; public static String getLocalIpAddress() { try { @@ -490,4 +491,43 @@ public static String getSerialNumber() { return serial; } + + /** + * 添加验证头 + * + * @param appid + * @param appkey + * @param timeStamp + * 当前时间戳 + * @return + */ + public static String getAppVerifyValue(String appid, String appkey, long timeStamp) { + String value = null; + String md5 = getMD5Code(appid + ":" + appkey + ":" + timeStamp); + value = "md5=" + md5 + ";ts=" + timeStamp; + return value; + } + + public static String getMD5Code(String value) { + if (value == null) { + value = ""; + } + try { + MessageDigest md = MessageDigest.getInstance("MD5"); + md.reset(); + md.update(value.getBytes()); + byte[] md5Bytes = md.digest(); + StringBuffer hexValue = new StringBuffer(); + for (int i = 0; i < md5Bytes.length; i++) { + int val = ((int) md5Bytes[i]) & 0xff; + if (val < 16) + hexValue.append("0"); + hexValue.append(Integer.toHexString(val)); + } + return hexValue.toString(); + } catch (NoSuchAlgorithmException e) { + e.printStackTrace(); + } + return null; + } } From 33c9064e5d1a4cf0c253e15553b39ac9da69434a Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Wed, 2 Mar 2016 13:47:40 +0800 Subject: [PATCH 14/25] =?UTF-8?q?BUtility=E6=B7=BB=E5=8A=A0getRealPathWith?= =?UTF-8?q?CopyRes()=E6=96=B9=E6=B3=95=EF=BC=8C=E5=A4=84=E7=90=86res://?= =?UTF-8?q?=E5=8D=8F=E8=AE=AE=E8=B7=AF=E5=BE=84=E9=97=AE=E9=A2=98=20?= =?UTF-8?q?=E5=88=86=E4=BA=AB=E6=94=AF=E6=8C=81res://=E5=8D=8F=E8=AE=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../widget/wintestNormal/uexWindowFunc.html | 2 +- .../org/zywx/wbpalmstar/base/BUtility.java | 69 ++++++++++++++++++- .../engine/universalex/EUExWindow.java | 4 +- 3 files changed, 71 insertions(+), 4 deletions(-) diff --git a/Engine/assets/widget/wintestNormal/uexWindowFunc.html b/Engine/assets/widget/wintestNormal/uexWindowFunc.html index 230b4b40..76ca8936 100755 --- a/Engine/assets/widget/wintestNormal/uexWindowFunc.html +++ b/Engine/assets/widget/wintestNormal/uexWindowFunc.html @@ -36,7 +36,7 @@ } function share() { - var imgs=new Array("/sdcard/DCIM/123.jpg","/sdcard/DCIM/119.jpg","/sdcard/DCIM/504.jpg"); + var imgs=new Array("res://1_1.jpg"); var params = { type:0, text:"test text...text", diff --git a/Engine/src/org/zywx/wbpalmstar/base/BUtility.java b/Engine/src/org/zywx/wbpalmstar/base/BUtility.java index 0e94cab1..621688a6 100755 --- a/Engine/src/org/zywx/wbpalmstar/base/BUtility.java +++ b/Engine/src/org/zywx/wbpalmstar/base/BUtility.java @@ -43,10 +43,11 @@ import java.io.File; import java.io.FileDescriptor; import java.io.FileInputStream; +import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.text.BreakIterator; +import java.io.OutputStream; import java.util.ArrayList; import java.util.List; import java.util.regex.Matcher; @@ -709,6 +710,72 @@ public static Bitmap getLocalImg(Context ctx, String imgUrl) { return bitmap; } + /** + * 获取真实的路径,同时拷贝res协议文件到sd卡缓存目录 + * @param mBrwView + * @param url AppCan协议路径 + * @return + */ + public static String getRealPathWithCopyRes(EBrowserView mBrwView,String url){ + String realPath=makeRealPath(url,mBrwView); + if (realPath.startsWith("/") && !realPath.startsWith ("/data")) { + return realPath; + } + return getResLocalPath(mBrwView.getContext(),realPath); + } + + /** + * 根据res协议获取本地路径(将文件拷贝到sd卡缓存目录) + * @param context + * @param url Android assets路径,或者开启增量更新时的/data 开头路径 + * @return + */ + public static String getResLocalPath(Context context,String url){ + String resPath = url;// 获取的为assets路径 + InputStream inputStream = null; + OutputStream out = null; + String tempPath = url; + try { + if(resPath.startsWith("/data")){ + inputStream = new FileInputStream(new File(resPath)); + }else{ + inputStream = context.getResources().getAssets() + .open(resPath); + } + File cacheDir=context.getExternalCacheDir(); + if (cacheDir==null){ + return null; + } + String cachePath =cacheDir.getAbsolutePath(); + tempPath = cachePath + File.separator + resPath; + File file = new File(tempPath); + if(!file.getParentFile().exists()){ + file.getParentFile().mkdirs(); + } + if(file.exists()){ + file.delete(); + } + out = new FileOutputStream(file); + int count = 0; + byte[] buff = new byte[1024]; + while ((count = inputStream.read(buff)) != -1) { + out.write(buff, 0, count); + } + out.flush(); + } catch (Exception e) { + e.printStackTrace(); + } finally { + try { + if(inputStream != null) inputStream.close(); + if(out != null) out.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + return tempPath; + + } + public static String getFileNameWithNoSuffix(String path) { String name = null; int index = path.lastIndexOf('/'); diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index 1db813c3..103b9785 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -3449,12 +3449,12 @@ public void share(String[] params){ String jsonStr=params[0]; ShareInputVO inputVO=DataHelper.gson.fromJson(jsonStr,ShareInputVO.class); if (!TextUtils.isEmpty(inputVO.getImgPath())){ - inputVO.setImgPath(BUtility.makeRealPath(inputVO.getImgPath(),mBrwView)); + inputVO.setImgPath(BUtility.getRealPathWithCopyRes(mBrwView,inputVO.getImgPath())); } if (inputVO.getImgPaths()!=null){ List realImagePaths=new ArrayList(); for (String path:inputVO.getImgPaths()){ - realImagePaths.add(BUtility.makeRealPath(path,mBrwView)); + realImagePaths.add(BUtility.getRealPathWithCopyRes(mBrwView,path)); } inputVO.setImgPaths(realImagePaths); } From 3f160bb2a93d15a3b6a514d943d2fbf8b16593d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=92=8B=E8=90=8D=E8=90=8D?= Date: Thu, 3 Mar 2016 18:17:01 +0800 Subject: [PATCH 15/25] =?UTF-8?q?=E4=BF=AE=E6=94=B9uexWindow.setOrientatio?= =?UTF-8?q?n=E6=8E=A5=E5=8F=A3=E5=8F=82=E6=95=B0=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/engine/EBrowserActivity.java | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java index 2fdb064c..49f81c34 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserActivity.java @@ -618,14 +618,17 @@ public void handleMessage(Message msg) { } public final int intoOrientation(int flag) { - /* - * 1,4,5 portrait 2,8,10 landscape 3,9,6,12,15 sensor - */ int or = ActivityInfo.SCREEN_ORIENTATION_USER; - if (flag == 1 || flag == 4 || flag == 5) { + if (flag == 1) {// portrait or = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT; - } else if (flag == 2 || flag == 8 || flag == 10) { + } else if (flag == 2) {// landscape or = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE; + } else if (flag == 4) {// reverse portrait + or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT; + } else if (flag == 8) {// reverse landscape + or = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE; + } else if (flag == 15) {// sensor + or = ActivityInfo.SCREEN_ORIENTATION_FULL_SENSOR; } else { ; } From 615590b5c8f6bdbeb30c966cc71bdf4d369132ab Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Fri, 4 Mar 2016 16:32:31 +0800 Subject: [PATCH 16/25] =?UTF-8?q?=E4=BF=AE=E5=A4=8DuexWindow.setWindowFram?= =?UTF-8?q?e=E8=B0=83=E7=94=A8=E4=B9=8B=E5=90=8E=E7=AC=AC=E4=BA=8C?= =?UTF-8?q?=E6=AC=A1=E8=BF=9B=E9=A1=B5=E9=9D=A2=E5=BC=82=E5=B8=B8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../wbpalmstar/engine/EBrowserWidget.java | 45 +++++++++---------- 1 file changed, 21 insertions(+), 24 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java index 14509763..8492f633 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserWidget.java @@ -18,6 +18,9 @@ package org.zywx.wbpalmstar.engine; +import android.animation.Animator; +import android.animation.AnimatorSet; +import android.animation.ObjectAnimator; import android.content.Context; import android.content.SharedPreferences; import android.content.res.Configuration; @@ -28,7 +31,6 @@ import android.view.View; import android.view.ViewParent; import android.view.animation.Animation; -import android.view.animation.Animation.AnimationListener; import android.view.animation.DecelerateInterpolator; import android.view.animation.TranslateAnimation; import android.webkit.WebView; @@ -942,38 +944,33 @@ public void handleMessage(Message msg) { final EBrowserWindow window = (EBrowserWindow) en.obj; AbsoluteLayout.LayoutParams oldLp = (LayoutParams) window .getLayoutParams(); - int oldX = oldLp.x; - int oldY = oldLp.y; - int sx = oldX - en.x; - int sy = oldY - en.y; - if (0 == sx && 0 == sy) { - return; - } - Animation amin = null; - amin = new TranslateAnimation(0, -sx, 0, -sy); - amin.setDuration(en.duration); - amin.setFillEnabled(true); - amin.setFillAfter(true); - amin.setAnimationListener(new AnimationListener() { + ObjectAnimator animatorX=ObjectAnimator.ofFloat(window,"translationX",oldLp.x,en.x); + ObjectAnimator animatorY=ObjectAnimator.ofFloat(window,"translationY",oldLp.y,en.y); + AnimatorSet animatorSet=new AnimatorSet(); + animatorSet.playTogether(animatorX,animatorY); + animatorSet.setDuration(en.duration); + animatorSet.addListener(new Animator.AnimatorListener() { @Override - public void onAnimationStart(Animation animation) { + public void onAnimationStart(Animator animation) { + } @Override - public void onAnimationRepeat(Animation animation) { + public void onAnimationEnd(Animator animation) { + window.onSetWindowFrameFinish(); } @Override - public void onAnimationEnd(Animation animation) { - AbsoluteLayout.LayoutParams newLp = new AbsoluteLayout.LayoutParams( - Compat.FILL, Compat.FILL, en.x, en.y); - window.setLayoutParams(newLp); - window.clearAnimation(); - window.onSetWindowFrameFinish(); + public void onAnimationCancel(Animator animation) { + + } + + @Override + public void onAnimationRepeat(Animator animation) { + } }); - window.startAnimation(amin); - invalidate(); + animatorSet.start(); break; // case F_WIDGET_HANDLER_WINDOW_CLOSE:// close window // closeWindow((EBrowserWindow) msg.obj); From 3638716debd2f834d65600b60029792f722b4f4a Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Mon, 7 Mar 2016 13:43:08 +0800 Subject: [PATCH 17/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=8E=B7=E5=8F=96windo?= =?UTF-8?q?w=E5=AE=BD=E9=AB=98=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/engine/universalex/EUExScript.java | 2 ++ .../zywx/wbpalmstar/engine/universalex/EUExWindow.java | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java index 24248ab8..ab48edaf 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java @@ -128,6 +128,8 @@ public class EUExScript { + // Window "window.uexWindow={" + + "getHeight:function(){return uexDispatcher.dispatch('uexWindow','getHeight',jo(arguments));}," + + "getWidth:function(){return uexDispatcher.dispatch('uexWindow','getWidth',jo(arguments));}," + "forward:function(){uexDispatcher.dispatch('uexWindow','forward',jo(arguments));}," + "back:function(){uexDispatcher.dispatch('uexWindow','back',jo(arguments));}," + "pageBack:function(){uexDispatcher.dispatch('uexWindow','pageBack',jo(arguments));}," diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index 103b9785..fac750f7 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -313,6 +313,14 @@ public void openMsg(String[] parm) { curWind.createWindow(mBrwView, windEntry); } + public int getHeight(String[] params){ + return mBrwView.getBrowserWindow().getHeight(); + } + + public int getWidth(String[] params){ + return mBrwView.getBrowserWindow().getWidth(); + } + private boolean checkWindPermission(String windName) { WWidgetData rootWgt = mBrwView.getRootWidget(); String[] winds = rootWgt.disableRootWindows; From c71d52002219acc6f478b4ea1ce22a9e78168ea0 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Mon, 7 Mar 2016 14:18:58 +0800 Subject: [PATCH 18/25] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/src/org/zywx/wbpalmstar/base/BConstant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java index ed5417f4..66770880 100755 --- a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java +++ b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java @@ -25,7 +25,7 @@ public class BConstant { - public static final String ENGINE_VERSION="3.2.2"; + public static final String ENGINE_VERSION="3.2.3"; public static final String F_URL = "url"; public static final String F_WIDGET = "widget"; From 7fd4427f13046972f9c9d945f7a098637f839e31 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Mon, 7 Mar 2016 16:57:45 +0800 Subject: [PATCH 19/25] =?UTF-8?q?=E6=8F=92=E4=BB=B6=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=94=E5=9B=9E=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/engine/universalex/ThirdPluginObject.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/ThirdPluginObject.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/ThirdPluginObject.java index 8f98472f..982392bd 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/ThirdPluginObject.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/ThirdPluginObject.java @@ -25,7 +25,7 @@ public class ThirdPluginObject { public static final String js_object_begin = "window."; public static final String js_arg_low = "jo(arguments)"; public static final String js_staves = "."; - public static final String js_function_begin = ":function(){"; + public static final String js_function_begin = ":function(){return "; public static final String js_symbol = "="; public static final String js_l_brackets = "("; public static final String js_function_end = ");},"; From 448b7f3a814d4e111f50b1bac7bc38797d6cfb1e Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 09:45:40 +0800 Subject: [PATCH 20/25] =?UTF-8?q?EUExBase=E6=B7=BB=E5=8A=A0=E5=9B=9E?= =?UTF-8?q?=E8=B0=83JS=E5=AF=B9=E8=B1=A1=E7=9A=84=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../engine/universalex/EUExBase.java | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExBase.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExBase.java index a58d3548..b2651757 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExBase.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExBase.java @@ -35,6 +35,7 @@ import android.widget.FrameLayout; import android.widget.RelativeLayout; +import org.zywx.wbpalmstar.base.BDebug; import org.zywx.wbpalmstar.base.view.BaseFragment; import org.zywx.wbpalmstar.engine.EBrowserActivity; import org.zywx.wbpalmstar.engine.EBrowserAnimation; @@ -123,6 +124,34 @@ public final void jsCallback(String inCallbackName, int inOpCode, callbackToJs(js); } + public void callBackJs(String methodName, String jsonData) { + callBackJs(mBrwView,methodName,jsonData); + } + + public void callBackJsObject(String methodName,Object object){ + callBackJsObject(mBrwView,methodName,object); + } + + public static void callBackJs(EBrowserView eBrowserView,String methodName, String jsonData){ + if (eBrowserView == null) { + BDebug.e("mBrwView is null..."); + return; + } + String js = SCRIPT_HEADER + "if(" + methodName + "){" + + methodName + "('" + jsonData + "');}else{console.log('function "+methodName +" not found.')}"; + eBrowserView.loadUrl(js); + } + + public static void callBackJsObject(EBrowserView eBrowserView,String methodName, Object value){ + if (eBrowserView == null) { + BDebug.e("mBrwView is null..."); + return; + } + String js = SCRIPT_HEADER + "if(" + methodName + "){" + + methodName + "(" + value + ");}else{console.log('function "+methodName +" not found.')}"; + eBrowserView.loadUrl(js); + } + public final void errorCallback(int inOpCode, int InErrorCode, String inErrorInfo) { String js = SCRIPT_ERROR_HEADER + inOpCode + "," + InErrorCode + ",'" From 8e20558373cd4b437ad78be92c01c419864622f3 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 09:52:29 +0800 Subject: [PATCH 21/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0SharedPreferences?= =?UTF-8?q?=E5=B7=A5=E5=85=B7=E7=B1=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/base/util/SpManager.java | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Engine/src/org/zywx/wbpalmstar/base/util/SpManager.java diff --git a/Engine/src/org/zywx/wbpalmstar/base/util/SpManager.java b/Engine/src/org/zywx/wbpalmstar/base/util/SpManager.java new file mode 100644 index 00000000..619d677e --- /dev/null +++ b/Engine/src/org/zywx/wbpalmstar/base/util/SpManager.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2016. The AppCan Open Source Project. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program. If not, see . + * + * + */ + +package org.zywx.wbpalmstar.base.util; + +import android.content.Context; +import android.content.SharedPreferences; + +import org.zywx.wbpalmstar.base.BConstant; + +/** + * Created by ylt on 16/2/26. + */ +public class SpManager { + + public static final String SP_NAME="appcan_data"; + + private static SpManager instance=null; + + private SharedPreferences mSharedPreferences; + + public SpManager(Context context) { + mSharedPreferences=context.getSharedPreferences(SP_NAME,Context.MODE_PRIVATE); + } + + public static SpManager getInstance(){ + if (instance==null){ + instance=new SpManager(BConstant.app); + } + return instance; + } + + + public SharedPreferences getSharedPreferences() { + return mSharedPreferences; + } + + public boolean putString(String key, String value){ + return mSharedPreferences.edit().putString(key,value).commit(); + } + + public String getString(String key, String defValue) { + return mSharedPreferences.getString(key, defValue); + } + + public boolean remove(String key) { + return mSharedPreferences.edit().remove(key).commit(); + } + +} From 4bdedcc4f64cea918f350dbe8813f7ff5fd9f11d Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 09:53:04 +0800 Subject: [PATCH 22/25] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=AF=BB=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E5=86=85=E5=AE=B9=E6=96=B9=E6=B3=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/zywx/wbpalmstar/base/FileHelper.java | 50 +++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/Engine/src/org/zywx/wbpalmstar/base/FileHelper.java b/Engine/src/org/zywx/wbpalmstar/base/FileHelper.java index 891c7336..5951f808 100755 --- a/Engine/src/org/zywx/wbpalmstar/base/FileHelper.java +++ b/Engine/src/org/zywx/wbpalmstar/base/FileHelper.java @@ -18,6 +18,7 @@ package org.zywx.wbpalmstar.base; +import android.content.Context; import android.os.Environment; import android.os.StatFs; @@ -242,4 +243,53 @@ public static int getBufferSizeByFileSize(long length) { return 4096;// 4K } + public static String loadAssetTextAsString(Context context, String name) { + BufferedReader in = null; + try { + StringBuilder buf = new StringBuilder(); + InputStream is = context.getAssets().open(name); + in = new BufferedReader(new InputStreamReader(is)); + + String str; + boolean isFirst = true; + while ( (str = in.readLine()) != null ) { + if (isFirst) + isFirst = false; + else + buf.append('\n'); + buf.append(str); + } + return buf.toString(); + } catch (IOException e) { + BDebug.e("Error opening asset " + name); + } finally { + if (in != null) { + try { + in.close(); + } catch (IOException e) { + BDebug.e("Error closing asset " + name); + } + } + } + + return null; + } + + public static String readFile(String fileName) throws IOException { + BufferedReader br = new BufferedReader(new FileReader(fileName)); + try { + StringBuilder sb = new StringBuilder(); + String line = br.readLine(); + + while (line != null) { + sb.append(line); + sb.append("\n"); + line = br.readLine(); + } + return sb.toString(); + } finally { + br.close(); + } + } + } From 0c739ea33110afc9d246a3ca2d3be68a966f2063 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 09:54:47 +0800 Subject: [PATCH 23/25] =?UTF-8?q?window=E6=B7=BB=E5=8A=A0putLocalData,getL?= =?UTF-8?q?ocalData=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../zywx/wbpalmstar/engine/universalex/EUExScript.java | 2 ++ .../zywx/wbpalmstar/engine/universalex/EUExWindow.java | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java index ab48edaf..81dd3779 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExScript.java @@ -208,6 +208,8 @@ public class EUExScript { + "setPopHardwareEnable:function(){uexDispatcher.dispatch('uexWindow','setPopHardwareEnable',jo(arguments));}," + "setSwipeCloseEnable:function(){uexDispatcher.dispatch('uexWindow','setSwipeCloseEnable',jo(arguments));}," + "share:function(){uexDispatcher.dispatch('uexWindow','share',jo(arguments));}," + + "putLocalData:function(){uexDispatcher.dispatch('uexWindow','putLocalData',jo(arguments));}," + + "getLocalData:function(){return uexDispatcher.dispatch('uexWindow','getLocalData',jo(arguments));}," + "setSlidingWindow:function(){uexDispatcher.dispatch('uexWindow','setSlidingWindow',jo(arguments));}," diff --git a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java index fac750f7..2c0eae89 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/universalex/EUExWindow.java @@ -52,6 +52,7 @@ import org.zywx.wbpalmstar.base.BDebug; import org.zywx.wbpalmstar.base.BUtility; import org.zywx.wbpalmstar.base.ResoureFinder; +import org.zywx.wbpalmstar.base.util.SpManager; import org.zywx.wbpalmstar.base.vo.CreateContainerVO; import org.zywx.wbpalmstar.base.vo.SetSwipeCloseEnableVO; import org.zywx.wbpalmstar.base.vo.ShareInputVO; @@ -2371,6 +2372,14 @@ public void windowBackMsg(String[] parm) { mBrwView.getBrowserWindow().windowGoBack(animId, duration); } + public void putLocalData(String[] params) { + SpManager.getInstance().putString(params[0],params[1]); + } + + public String getLocalData(String[] params) { + return SpManager.getInstance().getString(params[0], ""); + } + public void windowForward(String[] parm) { Message msg = new Message(); msg.obj = this; From e2851a44484fde01a6240d468e27492a4dc61332 Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 09:56:52 +0800 Subject: [PATCH 24/25] =?UTF-8?q?=E5=A4=84=E7=90=86EBrowserView=E5=9C=A8Se?= =?UTF-8?q?rvice=E4=B8=AD=E5=88=9B=E5=BB=BA=E7=9A=84=E6=83=85=E5=86=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/zywx/wbpalmstar/engine/CBrowserWindow7.java | 4 +++- .../src/org/zywx/wbpalmstar/engine/EBrowserView.java | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Engine/src/org/zywx/wbpalmstar/engine/CBrowserWindow7.java b/Engine/src/org/zywx/wbpalmstar/engine/CBrowserWindow7.java index 4b3cb998..5217b0b1 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/CBrowserWindow7.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/CBrowserWindow7.java @@ -224,7 +224,9 @@ public void onPageFinished(WebView view, String url) { if (!info.mFinished) { if (WWidgetData.m_remove_loading == 1) { - ((EBrowserActivity) target.getContext()).setContentViewVisible(200); + if (target.getContext()instanceof EBrowserActivity) { + ((EBrowserActivity) target.getContext()).setContentViewVisible(200); + } } } diff --git a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserView.java b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserView.java index 4d5d10c9..11c370e6 100755 --- a/Engine/src/org/zywx/wbpalmstar/engine/EBrowserView.java +++ b/Engine/src/org/zywx/wbpalmstar/engine/EBrowserView.java @@ -100,7 +100,7 @@ public class EBrowserView extends WebView implements View.OnLongClickListener, public static boolean sHardwareAccelerate = true;//配置全部WebView是否硬件加速,默认开启,config.xml 配置关闭 - protected EBrowserView(Context context, int inType, EBrowserWindow inParent) { + public EBrowserView(Context context, int inType, EBrowserWindow inParent) { super(context); mMyCountId = EBrowser.assignCountID(); mBroWind = inParent; @@ -120,7 +120,7 @@ public void setScrollCallBackContex(EUExWindow callback) { this.callback = callback; } - protected void init() { + public void init() { setInitialScale(100); setVerticalScrollbarOverlay(true); setHorizontalScrollbarOverlay(true); @@ -581,14 +581,18 @@ protected void onPageStarted(EBrowserView view, String url) { if (!checkType(EBrwViewEntry.VIEW_TYPE_MAIN)) { return; } - mBroWind.onPageStarted(view, url); + if (mBroWind!=null) { + mBroWind.onPageStarted(view, url); + } } protected void onPageFinished(EBrowserView view, String url) { if (mDestroyed) { return; } - mBroWind.onPageFinished(view, url); + if (mBroWind!=null){ + mBroWind.onPageFinished(view, url); + } if (mBrowserViewChangeListener != null) { mBrowserViewChangeListener.onPageFinish(); } From ff85a25662efb7bb1538f56c6a1b763a6cb5b30a Mon Sep 17 00:00:00 2001 From: yanlongtao Date: Thu, 10 Mar 2016 14:07:08 +0800 Subject: [PATCH 25/25] =?UTF-8?q?=E5=8D=87=E7=BA=A7=E7=89=88=E6=9C=AC?= =?UTF-8?q?=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Engine/src/org/zywx/wbpalmstar/base/BConstant.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java index 66770880..917ee043 100755 --- a/Engine/src/org/zywx/wbpalmstar/base/BConstant.java +++ b/Engine/src/org/zywx/wbpalmstar/base/BConstant.java @@ -25,7 +25,7 @@ public class BConstant { - public static final String ENGINE_VERSION="3.2.3"; + public static final String ENGINE_VERSION="3.3.0"; public static final String F_URL = "url"; public static final String F_WIDGET = "widget";