Skip to content

Commit c476c6b

Browse files
author
yltwust
committed
Merge pull request #90 from AppCanOpenSource/develop
merge develop
2 parents 473fc5c + ff85a25 commit c476c6b

38 files changed

Lines changed: 1779 additions & 338 deletions

Engine/assets/widget/index.html

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,11 +59,9 @@
5959
}
6060

6161
function openTest(name){
62-
if(name == "uexWindow"){
63-
openNewWin("uexWindow", "uexWindow.html?index=1&page=wind");
64-
}else{
65-
openNewWin(name, name+".html");
66-
}
62+
var optInfo = "{'key1':'value1'},{'key2':'value1'}";
63+
var extra='{data:"http://www.cnblogs.com"}';
64+
uexWidget.startApp(0, "com.tencent.mtt","com.tencent.mtt.MainActivity",optInfo,extra);
6765
}
6866

6967
function openTestController(name){
@@ -122,7 +120,8 @@
122120
<!-- <div onclick="openTest('media/media')" class="testbtn">多媒体插件</div><br>-->
123121
<!-- <div onclick="openTest('other/other')" class="testbtn">第三方插件</div><br>-->
124122
<div onclick="openTest1('wintestNormal/uexWindow')" class="testbtn">打开普通窗口</div><br>
125-
<div onclick="openLeftSlidingWin()" class="testbtn">打开侧边栏窗口</div><br>
123+
<div onclick="openTest1('wintestNormal/uexWindowFunc')" class="testbtn">window接口测试</div><br>
124+
<div onclick="openLeftSlidingWin()" class="testbtn">打开侧边栏窗口</div><br>
126125
<div onclick="openTest('wintestNav/uexWindow')" class="testbtn">打开导航视图窗口(iOS)</div><br>
127126
<div onclick="openTest('uexWidget')" class="testbtn">uexWidget</div><br>
128127

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
<!DOCTYPE html>
2+
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
3+
<head>
4+
<title>
5+
</title>
6+
<meta charset="utf-8">
7+
<meta name="viewport" content="target-densitydpi=device-dpi, width=device-width, initial-scale=1, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0">
8+
<link rel="stylesheet" href="../css/ui-base.css">
9+
<link rel="stylesheet" href="../css/ui-box.css">
10+
<link rel="stylesheet" href="../css/ui-color.css">
11+
<link rel="stylesheet" href="../css/ui-res.css">
12+
<link rel="stylesheet" href="../css/ui-btn.css">
13+
<link rel="stylesheet" href="../css/index.css">
14+
<script src="../js/zy_control.js">
15+
</script>
16+
<script src="../js/zy_click.js">
17+
</script>
18+
<script type="text/javascript">
19+
function showConfirm(){
20+
var value = document.getElementById('confirmbutton').value;
21+
if(value == null || value.length == 0){
22+
alert("参数不能为空");
23+
return;
24+
}
25+
var mycars=value.split(";");
26+
uexWindow.confirm(document.getElementById('confirmTitle').value,document.getElementById('confirmMsg').value,mycars);
27+
}
28+
window.uexOnload = function(type){
29+
if(type == 0){
30+
31+
}
32+
}
33+
34+
function winBack(){
35+
uexWindow.evaluateScript("uexWindow","0", "winBack()");
36+
}
37+
38+
function share() {
39+
var imgs=new Array("res://1_1.jpg");
40+
var params = {
41+
type:0,
42+
text:"test text...text",
43+
title:"title",
44+
desc:"desc",
45+
imgPaths:imgs
46+
};
47+
48+
var paramStr = JSON.stringify(params);
49+
uexWindow.share(paramStr);
50+
}
51+
52+
53+
function testForwardWin() {
54+
55+
//打开一个窗口
56+
57+
var name = "uexWindow_Forward";
58+
59+
uexWindow.open(name, '0', name+".html", '2', '', '', 0);
60+
}
61+
62+
63+
function winOpenPop2() {
64+
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winPopOpen2()");
65+
}
66+
67+
function closeOpenPop2() {
68+
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "closeOpenPop2()");
69+
}
70+
71+
function winOpenMultiPop() {
72+
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winOpenMultiPop()");
73+
}
74+
75+
function winCloseMultiPop() {
76+
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winCloseMultiPop()");
77+
}
78+
79+
</script>
80+
</head>
81+
<body class="um-vp" ontouchstart bgcolor="#03A9F4">
82+
<div class="conbor">
83+
<div class="consj">
84+
85+
<span>1.分享(share)</span>
86+
<input class="btn" type="button" value="分享" onclick="share()"><br>
87+
88+
89+
<span>2.窗口前进后退(windowForward, windowBack forward, back, pageForward, pageBack)</span>
90+
<input class="btn" type="button" value="窗口前进后退" onclick="testForwardWin()"><br>
91+
92+
<span>5.打开浮动窗口2(测试closePopover)</span>
93+
<input class="btn" type="button" value="打开浮动窗2" onclick="winOpenPop2()"><br>
94+
<input class="btn" type="button" value="关闭浮动窗2" onclick="closeOpenPop2()"><br>
95+
96+
<span>6.打开多页面浮动窗口(openMultiPopover)</span>
97+
<input class="btn" type="button" value="打开多页面浮动窗口" onclick="winOpenMultiPop()"><br>
98+
<input class="btn" type="button" value="关闭多页面浮动窗口" onclick="winCloseMultiPop()"><br>
99+
</div>
100+
</div>
101+
</body>
102+
</html>

Engine/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ dependencies {
99

1010
android {
1111
compileSdkVersion 22
12-
buildToolsVersion '23.0.0'
12+
buildToolsVersion '23.0.2'
1313
packagingOptions {
1414
exclude 'META-INF/MANIFEST.MF'
1515
exclude 'META-INF/LICENSE.txt'

Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
/*
2+
* Copyright (c) 2016. The AppCan Open Source Project.
3+
*
4+
* This program is free software: you can redistribute it and/or modify
5+
* it under the terms of the GNU Lesser General Public License as published by
6+
* the Free Software Foundation, either version 3 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful,
10+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
* GNU Lesser General Public License for more details.
13+
*
14+
* You should have received a copy of the GNU Lesser General Public License
15+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16+
*
17+
*
18+
*/
19+
120
package org.zywx.wbpalmstar.base;
221

322
import android.widget.ImageView;
@@ -35,9 +54,10 @@ private ACEImageLoader() {
3554
.diskCache(new UnlimitedDiskCache(DiskCache.cacheFolder))//自定义缓存路径
3655
.diskCacheFileNameGenerator(new Md5FileNameGenerator())
3756
.diskCacheSize(200 * 1024 * 1024)
57+
.diskCacheFileCount(100)
3858
.defaultDisplayImageOptions(DisplayImageOptions.createSimple())
3959
.imageDownloader(new BaseImageDownloader(BConstant.app, 5 * 1000, 30 * 1000)) // connectTimeout (5 s),
40-
// readTimeout (30 s)超时时间
60+
// readTimeout (30 s)超时时间
4161
.writeDebugLogs() // Remove for release app
4262
.build();//开始构建
4363
ImageLoader.getInstance().init(config);
@@ -65,8 +85,23 @@ public <T extends ImageView> void displayImage(T imageView, String imgUrl) {
6585
} else {
6686
realImgUrl = imgUrl;
6787
}
68-
ImageLoader.getInstance().displayImage(realImgUrl, imageView);
88+
displayImageWithOptions(realImgUrl,imageView,true);
6989
}
7090

91+
public <T extends ImageView> void displayImageWithOptions(String imgUrl, T imageView,boolean cacheOnDisk)
92+
{
93+
if (cacheOnDisk){
94+
DisplayImageOptions options;
95+
options=new DisplayImageOptions.Builder()
96+
.cacheOnDisk(true)
97+
.build();
98+
ImageLoader.getInstance().displayImage(imgUrl, imageView,options);
99+
}else{
100+
ImageLoader.getInstance().displayImage(imgUrl, imageView);
101+
}
102+
103+
}
104+
105+
71106

72107
}

Engine/src/org/zywx/wbpalmstar/base/BConstant.java

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -25,56 +25,57 @@
2525

2626
public class BConstant {
2727

28-
public static final String ENGINE_VERSION="3.2.2";
28+
public static final String ENGINE_VERSION="3.3.0";
2929

30-
public static final String F_URL = "url";
31-
public static final String F_WIDGET = "widget";
32-
public static final String F_MULTIPLEWINDOW = "MultipleWindow";
33-
public static final String F_WIDGETONE = "widgetone";
34-
public static final String F_USER_AGENT = "userAgent";
35-
public static final String F_CONTENT_DISPOSITION = "contentDisposition";
36-
public static final String F_MIMETYPE = "mimeType";
37-
public static final String F_CONTENTLENGTH = "contentLength";
38-
public static final String F_DIALOG_TYPE = "dialogType";
39-
public static final String F_ASSETS_ROOT = "android_asset/";
40-
public static final String F_SDCARD_ROOT = "file:///sdcard/";
41-
public static final String F_PUSH_WIN_NAME = "winName";
42-
public static final String F_PUSH_NOTI_FUN_NAME = "funName";
30+
public static final String F_URL = "url";
31+
public static final String F_WIDGET = "widget";
32+
public static final String F_MULTIPLEWINDOW = "MultipleWindow";
33+
public static final String F_WIDGETONE = "widgetone";
34+
public static final String F_USER_AGENT = "userAgent";
35+
public static final String F_CONTENT_DISPOSITION = "contentDisposition";
36+
public static final String F_MIMETYPE = "mimeType";
37+
public static final String F_CONTENTLENGTH = "contentLength";
38+
public static final String F_DIALOG_TYPE = "dialogType";
39+
public static final String F_ASSETS_ROOT = "android_asset/";
40+
public static final String F_SDCARD_ROOT = "file:///sdcard/";
41+
public static final String F_PUSH_APPID = "appId";
42+
public static final String F_PUSH_WIN_NAME = "winName";
43+
public static final String F_PUSH_NOTI_FUN_NAME = "funName";
4344

44-
public static Application app=null;
45+
public static Application app = null;
4546

46-
public static String byteChange(int size) {
47-
DecimalFormat df = new DecimalFormat("0.00");
48-
float f;
49-
if (size < 1024 * 1024) {
50-
f = (float) ((float) size / (float) 1024);
51-
return (df.format(new Float(f).doubleValue()) + " KB");
52-
} else {
53-
f = (float) ((float) size / (float) (1024 * 1024));
54-
return (df.format(new Float(f).doubleValue()) + " MB");
55-
}
47+
public static String byteChange(int size) {
48+
DecimalFormat df = new DecimalFormat("0.00");
49+
float f;
50+
if (size < 1024 * 1024) {
51+
f = (float) ((float) size / (float) 1024);
52+
return (df.format(new Float(f).doubleValue()) + " KB");
53+
} else {
54+
f = (float) ((float) size / (float) (1024 * 1024));
55+
return (df.format(new Float(f).doubleValue()) + " MB");
56+
}
5657

57-
}
58+
}
5859

59-
public static String getSizeText(int downLoadSize, int fileSize) {
60-
return byteChange(downLoadSize) + "/" + byteChange(fileSize);
61-
}
60+
public static String getSizeText(int downLoadSize, int fileSize) {
61+
return byteChange(downLoadSize) + "/" + byteChange(fileSize);
62+
}
6263

63-
public static enum downLoadStatus {
64-
/**
65-
* Indicates that the task has not been executed yet.
66-
*/
67-
WAIT,
68-
/**
69-
* Indicates that the task is running.
70-
*/
71-
RUNNING,
72-
PAUSED,
73-
/**
74-
* Indicates that {@link AsyncTask#onPostExecute} has finished.
75-
*/
76-
FINISHED,
77-
}
64+
public static enum downLoadStatus {
65+
/**
66+
* Indicates that the task has not been executed yet.
67+
*/
68+
WAIT,
69+
/**
70+
* Indicates that the task is running.
71+
*/
72+
RUNNING,
73+
PAUSED,
74+
/**
75+
* Indicates that {@link AsyncTask#onPostExecute} has finished.
76+
*/
77+
FINISHED,
78+
}
7879

7980

8081
}

Engine/src/org/zywx/wbpalmstar/base/BUtility.java

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,11 @@
4343
import java.io.File;
4444
import java.io.FileDescriptor;
4545
import java.io.FileInputStream;
46+
import java.io.FileOutputStream;
4647
import java.io.IOException;
4748
import java.io.InputStream;
4849
import java.io.InputStreamReader;
49-
import java.text.BreakIterator;
50+
import java.io.OutputStream;
5051
import java.util.ArrayList;
5152
import java.util.List;
5253
import java.util.regex.Matcher;
@@ -709,6 +710,72 @@ public static Bitmap getLocalImg(Context ctx, String imgUrl) {
709710
return bitmap;
710711
}
711712

713+
/**
714+
* 获取真实的路径,同时拷贝res协议文件到sd卡缓存目录
715+
* @param mBrwView
716+
* @param url AppCan协议路径
717+
* @return
718+
*/
719+
public static String getRealPathWithCopyRes(EBrowserView mBrwView,String url){
720+
String realPath=makeRealPath(url,mBrwView);
721+
if (realPath.startsWith("/") && !realPath.startsWith ("/data")) {
722+
return realPath;
723+
}
724+
return getResLocalPath(mBrwView.getContext(),realPath);
725+
}
726+
727+
/**
728+
* 根据res协议获取本地路径(将文件拷贝到sd卡缓存目录)
729+
* @param context
730+
* @param url Android assets路径,或者开启增量更新时的/data 开头路径
731+
* @return
732+
*/
733+
public static String getResLocalPath(Context context,String url){
734+
String resPath = url;// 获取的为assets路径
735+
InputStream inputStream = null;
736+
OutputStream out = null;
737+
String tempPath = url;
738+
try {
739+
if(resPath.startsWith("/data")){
740+
inputStream = new FileInputStream(new File(resPath));
741+
}else{
742+
inputStream = context.getResources().getAssets()
743+
.open(resPath);
744+
}
745+
File cacheDir=context.getExternalCacheDir();
746+
if (cacheDir==null){
747+
return null;
748+
}
749+
String cachePath =cacheDir.getAbsolutePath();
750+
tempPath = cachePath + File.separator + resPath;
751+
File file = new File(tempPath);
752+
if(!file.getParentFile().exists()){
753+
file.getParentFile().mkdirs();
754+
}
755+
if(file.exists()){
756+
file.delete();
757+
}
758+
out = new FileOutputStream(file);
759+
int count = 0;
760+
byte[] buff = new byte[1024];
761+
while ((count = inputStream.read(buff)) != -1) {
762+
out.write(buff, 0, count);
763+
}
764+
out.flush();
765+
} catch (Exception e) {
766+
e.printStackTrace();
767+
} finally {
768+
try {
769+
if(inputStream != null) inputStream.close();
770+
if(out != null) out.close();
771+
} catch (Exception e) {
772+
e.printStackTrace();
773+
}
774+
}
775+
return tempPath;
776+
777+
}
778+
712779
public static String getFileNameWithNoSuffix(String path) {
713780
String name = null;
714781
int index = path.lastIndexOf('/');

0 commit comments

Comments
 (0)