Skip to content

Commit

Permalink
Merge pull request #90 from AppCanOpenSource/develop
Browse files Browse the repository at this point in the history
merge develop
  • Loading branch information
yltwust committed Mar 11, 2016
2 parents 473fc5c + ff85a25 commit c476c6b
Show file tree
Hide file tree
Showing 38 changed files with 1,779 additions and 338 deletions.
11 changes: 5 additions & 6 deletions Engine/assets/widget/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -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){
Expand Down Expand Up @@ -122,7 +120,8 @@
<!-- <div onclick="openTest('media/media')" class="testbtn">多媒体插件</div><br>-->
<!-- <div onclick="openTest('other/other')" class="testbtn">第三方插件</div><br>-->
<div onclick="openTest1('wintestNormal/uexWindow')" class="testbtn">打开普通窗口</div><br>
<div onclick="openLeftSlidingWin()" class="testbtn">打开侧边栏窗口</div><br>
<div onclick="openTest1('wintestNormal/uexWindowFunc')" class="testbtn">window接口测试</div><br>
<div onclick="openLeftSlidingWin()" class="testbtn">打开侧边栏窗口</div><br>
<div onclick="openTest('wintestNav/uexWindow')" class="testbtn">打开导航视图窗口(iOS)</div><br>
<div onclick="openTest('uexWidget')" class="testbtn">uexWidget</div><br>

Expand Down
102 changes: 102 additions & 0 deletions Engine/assets/widget/wintestNormal/uexWindowFunc.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
<!DOCTYPE html>
<html class="um landscape min-width-240px min-width-320px min-width-480px min-width-768px min-width-1024px">
<head>
<title>
</title>
<meta charset="utf-8">
<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">
<link rel="stylesheet" href="../css/ui-base.css">
<link rel="stylesheet" href="../css/ui-box.css">
<link rel="stylesheet" href="../css/ui-color.css">
<link rel="stylesheet" href="../css/ui-res.css">
<link rel="stylesheet" href="../css/ui-btn.css">
<link rel="stylesheet" href="../css/index.css">
<script src="../js/zy_control.js">
</script>
<script src="../js/zy_click.js">
</script>
<script type="text/javascript">
function showConfirm(){
var value = document.getElementById('confirmbutton').value;
if(value == null || value.length == 0){
alert("参数不能为空");
return;
}
var mycars=value.split(";");
uexWindow.confirm(document.getElementById('confirmTitle').value,document.getElementById('confirmMsg').value,mycars);
}
window.uexOnload = function(type){
if(type == 0){

}
}

function winBack(){
uexWindow.evaluateScript("uexWindow","0", "winBack()");
}

function share() {
var imgs=new Array("res://1_1.jpg");
var params = {
type:0,
text:"test text...text",
title:"title",
desc:"desc",
imgPaths:imgs
};

var paramStr = JSON.stringify(params);
uexWindow.share(paramStr);
}


function testForwardWin() {

//打开一个窗口

var name = "uexWindow_Forward";

uexWindow.open(name, '0', name+".html", '2', '', '', 0);
}


function winOpenPop2() {
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winPopOpen2()");
}

function closeOpenPop2() {
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "closeOpenPop2()");
}

function winOpenMultiPop() {
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winOpenMultiPop()");
}

function winCloseMultiPop() {
uexWindow.evaluateScript("wintestNormal/uexWindow","0", "winCloseMultiPop()");
}

</script>
</head>
<body class="um-vp" ontouchstart bgcolor="#03A9F4">
<div class="conbor">
<div class="consj">

<span>1.分享(share)</span>
<input class="btn" type="button" value="分享" onclick="share()"><br>


<span>2.窗口前进后退(windowForward, windowBack forward, back, pageForward, pageBack)</span>
<input class="btn" type="button" value="窗口前进后退" onclick="testForwardWin()"><br>

<span>5.打开浮动窗口2(测试closePopover)</span>
<input class="btn" type="button" value="打开浮动窗2" onclick="winOpenPop2()"><br>
<input class="btn" type="button" value="关闭浮动窗2" onclick="closeOpenPop2()"><br>

<span>6.打开多页面浮动窗口(openMultiPopover)</span>
<input class="btn" type="button" value="打开多页面浮动窗口" onclick="winOpenMultiPop()"><br>
<input class="btn" type="button" value="关闭多页面浮动窗口" onclick="winCloseMultiPop()"><br>
</div>
</div>
</body>
</html>
2 changes: 1 addition & 1 deletion Engine/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
39 changes: 37 additions & 2 deletions Engine/src/org/zywx/wbpalmstar/base/ACEImageLoader.java
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*
*
*/

package org.zywx.wbpalmstar.base;

import android.widget.ImageView;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -65,8 +85,23 @@ public <T extends ImageView> void displayImage(T imageView, String imgUrl) {
} else {
realImgUrl = imgUrl;
}
ImageLoader.getInstance().displayImage(realImgUrl, imageView);
displayImageWithOptions(realImgUrl,imageView,true);
}

public <T extends ImageView> 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);
}

}



}
89 changes: 45 additions & 44 deletions Engine/src/org/zywx/wbpalmstar/base/BConstant.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,56 +25,57 @@

public class BConstant {

public static final String ENGINE_VERSION="3.2.2";
public static final String ENGINE_VERSION="3.3.0";

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,
}


}
69 changes: 68 additions & 1 deletion Engine/src/org/zywx/wbpalmstar/base/BUtility.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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('/');
Expand Down
Loading

0 comments on commit c476c6b

Please sign in to comment.