mirror of https://github.com/axmolengine/axmol.git
finish android version
This commit is contained in:
parent
631e1a70c4
commit
15815118a2
|
@ -349,7 +349,9 @@ LOCAL_SRC_FILES += ui/UIWidget.cpp \
|
||||||
ui/UIRelativeBox.cpp \
|
ui/UIRelativeBox.cpp \
|
||||||
ui/UIVideoPlayerAndroid.cpp \
|
ui/UIVideoPlayerAndroid.cpp \
|
||||||
ui/UIDeprecated.cpp \
|
ui/UIDeprecated.cpp \
|
||||||
ui/UIScale9Sprite.cpp
|
ui/UIScale9Sprite.cpp \
|
||||||
|
ui/WebView.cpp \
|
||||||
|
ui/WebViewImpl_android.cpp \
|
||||||
|
|
||||||
#extension
|
#extension
|
||||||
LOCAL_SRC_FILES += ../extensions/assets-manager/AssetsManager.cpp \
|
LOCAL_SRC_FILES += ../extensions/assets-manager/AssetsManager.cpp \
|
||||||
|
|
|
@ -33,11 +33,10 @@ import android.content.pm.PackageManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Message;
|
import android.os.Message;
|
||||||
import android.view.ViewGroup;
|
|
||||||
import android.view.WindowManager;
|
|
||||||
import android.util.Log;
|
|
||||||
import android.widget.FrameLayout;
|
|
||||||
import android.preference.PreferenceManager.OnActivityResultListener;
|
import android.preference.PreferenceManager.OnActivityResultListener;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
|
public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelperListener {
|
||||||
// ===========================================================
|
// ===========================================================
|
||||||
|
@ -55,6 +54,7 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
private Cocos2dxHandler mHandler;
|
private Cocos2dxHandler mHandler;
|
||||||
private static Cocos2dxActivity sContext = null;
|
private static Cocos2dxActivity sContext = null;
|
||||||
private Cocos2dxVideoHelper mVideoHelper = null;
|
private Cocos2dxVideoHelper mVideoHelper = null;
|
||||||
|
private Cocos2dxWebViewHelper mWebViewHelper = null;
|
||||||
|
|
||||||
public static Context getContext() {
|
public static Context getContext() {
|
||||||
return sContext;
|
return sContext;
|
||||||
|
@ -102,6 +102,10 @@ public abstract class Cocos2dxActivity extends Activity implements Cocos2dxHelpe
|
||||||
if (mVideoHelper == null) {
|
if (mVideoHelper == null) {
|
||||||
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
|
mVideoHelper = new Cocos2dxVideoHelper(this, mFrameLayout);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(mWebViewHelper == null){
|
||||||
|
mWebViewHelper = new Cocos2dxWebViewHelper(mFrameLayout);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//native method,call GLViewImpl::getGLContextAttrs() to get the OpenGL ES context attributions
|
//native method,call GLViewImpl::getGLContextAttrs() to get the OpenGL ES context attributions
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
package org.cocos2dx.lib;
|
package org.cocos2dx.lib;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.net.URI;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
@ -7,9 +10,6 @@ import android.webkit.WebView;
|
||||||
import android.webkit.WebViewClient;
|
import android.webkit.WebViewClient;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.net.URI;
|
|
||||||
|
|
||||||
public class Cocos2dxWebView extends WebView {
|
public class Cocos2dxWebView extends WebView {
|
||||||
private static final String TAG = Cocos2dxWebViewHelper.class.getSimpleName();
|
private static final String TAG = Cocos2dxWebViewHelper.class.getSimpleName();
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class Cocos2dxWebView extends WebView {
|
||||||
try {
|
try {
|
||||||
Method method = this.getClass().getMethod("removeJavascriptInterface", new Class[]{String.class});
|
Method method = this.getClass().getMethod("removeJavascriptInterface", new Class[]{String.class});
|
||||||
method.invoke(this, "searchBoxJavaBridge_");
|
method.invoke(this, "searchBoxJavaBridge_");
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (Exception e) {
|
||||||
Log.d(TAG, "This API level do not support `removeJavascriptInterface`");
|
Log.d(TAG, "This API level do not support `removeJavascriptInterface`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,19 +24,21 @@
|
||||||
|
|
||||||
#include "WebViewImpl_android.h"
|
#include "WebViewImpl_android.h"
|
||||||
|
|
||||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
|
#include <unordered_map>
|
||||||
#include "WebView.h"
|
#include <stdlib.h>
|
||||||
|
#include <string>
|
||||||
#include "jni/JniHelper.h"
|
#include "jni/JniHelper.h"
|
||||||
#include <jni.h>
|
#include <jni.h>
|
||||||
|
|
||||||
|
#include "WebView.h"
|
||||||
#include "platform/CCGLView.h"
|
#include "platform/CCGLView.h"
|
||||||
#include "base/CCDirector.h"
|
#include "base/CCDirector.h"
|
||||||
#include "platform/CCFileUtils.h"
|
#include "platform/CCFileUtils.h"
|
||||||
#include <unordered_map>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <jni.h>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxWebViewHelper"
|
#define CLASS_NAME "org/cocos2dx/lib/Cocos2dxWebViewHelper"
|
||||||
|
|
||||||
|
#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,"",__VA_ARGS__)
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
/*
|
/*
|
||||||
* Class: org_cocos2dx_lib_Cocos2dxWebViewHelper
|
* Class: org_cocos2dx_lib_Cocos2dxWebViewHelper
|
||||||
|
@ -56,6 +58,7 @@ extern "C"{
|
||||||
* Signature: (ILjava/lang/String;)V
|
* Signature: (ILjava/lang/String;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_didFinishLoading(JNIEnv *env, jclass, jint index, jstring jurl) {
|
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_didFinishLoading(JNIEnv *env, jclass, jint index, jstring jurl) {
|
||||||
|
// LOGD("didFinishLoading");
|
||||||
auto charUrl = env->GetStringUTFChars(jurl, NULL);
|
auto charUrl = env->GetStringUTFChars(jurl, NULL);
|
||||||
std::string url = charUrl;
|
std::string url = charUrl;
|
||||||
env->ReleaseStringUTFChars(jurl, charUrl);
|
env->ReleaseStringUTFChars(jurl, charUrl);
|
||||||
|
@ -68,6 +71,7 @@ extern "C"{
|
||||||
* Signature: (ILjava/lang/String;)V
|
* Signature: (ILjava/lang/String;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_didFailLoading(JNIEnv *env, jclass, jint index, jstring jurl) {
|
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_didFailLoading(JNIEnv *env, jclass, jint index, jstring jurl) {
|
||||||
|
// LOGD("didFailLoading");
|
||||||
auto charUrl = env->GetStringUTFChars(jurl, NULL);
|
auto charUrl = env->GetStringUTFChars(jurl, NULL);
|
||||||
std::string url = charUrl;
|
std::string url = charUrl;
|
||||||
env->ReleaseStringUTFChars(jurl, charUrl);
|
env->ReleaseStringUTFChars(jurl, charUrl);
|
||||||
|
@ -80,6 +84,7 @@ extern "C"{
|
||||||
* Signature: (ILjava/lang/String;)V
|
* Signature: (ILjava/lang/String;)V
|
||||||
*/
|
*/
|
||||||
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_onJsCallback(JNIEnv *env, jclass, jint index, jstring jmessage) {
|
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxWebViewHelper_onJsCallback(JNIEnv *env, jclass, jint index, jstring jmessage) {
|
||||||
|
// LOGD("jsCallback");
|
||||||
auto charMessage = env->GetStringUTFChars(jmessage, NULL);
|
auto charMessage = env->GetStringUTFChars(jmessage, NULL);
|
||||||
std::string message = charMessage;
|
std::string message = charMessage;
|
||||||
env->ReleaseStringUTFChars(jmessage, charMessage);
|
env->ReleaseStringUTFChars(jmessage, charMessage);
|
||||||
|
@ -92,6 +97,7 @@ namespace {
|
||||||
int createWebViewJNI() {
|
int createWebViewJNI() {
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "createWebView", "()I")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "createWebView", "()I")) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
jint viewTag = t.env->CallStaticIntMethod(t.classID, t.methodID);
|
jint viewTag = t.env->CallStaticIntMethod(t.classID, t.methodID);
|
||||||
t.env->DeleteLocalRef(t.classID);
|
t.env->DeleteLocalRef(t.classID);
|
||||||
return viewTag;
|
return viewTag;
|
||||||
|
@ -100,6 +106,7 @@ int createWebViewJNI() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void removeWebViewJNI(const int index) {
|
void removeWebViewJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "removeWebView", "(I)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "removeWebView", "(I)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
||||||
|
@ -108,6 +115,7 @@ void removeWebViewJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWebViewRectJNI(const int index, const int left, const int top, const int width, const int height) {
|
void setWebViewRectJNI(const int index, const int left, const int top, const int width, const int height) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setWebViewRect", "(IIIII)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setWebViewRect", "(IIIII)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, left, top, width, height);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, left, top, width, height);
|
||||||
|
@ -116,6 +124,7 @@ void setWebViewRectJNI(const int index, const int left, const int top, const int
|
||||||
}
|
}
|
||||||
|
|
||||||
void setJavascriptInterfaceSchemeJNI(const int index, const std::string &scheme) {
|
void setJavascriptInterfaceSchemeJNI(const int index, const std::string &scheme) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setJavascriptInterfaceScheme", "(ILjava/lang/String;)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setJavascriptInterfaceScheme", "(ILjava/lang/String;)V")) {
|
||||||
jstring jScheme = t.env->NewStringUTF(scheme.c_str());
|
jstring jScheme = t.env->NewStringUTF(scheme.c_str());
|
||||||
|
@ -127,6 +136,7 @@ void setJavascriptInterfaceSchemeJNI(const int index, const std::string &scheme)
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadDataJNI(const int index, const std::string &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) {
|
void loadDataJNI(const int index, const std::string &data, const std::string &MIMEType, const std::string &encoding, const std::string &baseURL) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadData", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadData", "(ILjava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V")) {
|
||||||
jstring jData = t.env->NewStringUTF(data.c_str());
|
jstring jData = t.env->NewStringUTF(data.c_str());
|
||||||
|
@ -144,6 +154,7 @@ void loadDataJNI(const int index, const std::string &data, const std::string &MI
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadHTMLStringJNI(const int index, const std::string &string, const std::string &baseURL) {
|
void loadHTMLStringJNI(const int index, const std::string &string, const std::string &baseURL) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadHTMLString", "(ILjava/lang/String;Ljava/lang/String;)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadHTMLString", "(ILjava/lang/String;Ljava/lang/String;)V")) {
|
||||||
jstring jString = t.env->NewStringUTF(string.c_str());
|
jstring jString = t.env->NewStringUTF(string.c_str());
|
||||||
|
@ -168,6 +179,7 @@ void loadUrlJNI(const int index, const std::string &url) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void loadFileJNI(const int index, const std::string &filePath) {
|
void loadFileJNI(const int index, const std::string &filePath) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadFile", "(ILjava/lang/String;)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "loadFile", "(ILjava/lang/String;)V")) {
|
||||||
jstring jFilePath = t.env->NewStringUTF(filePath.c_str());
|
jstring jFilePath = t.env->NewStringUTF(filePath.c_str());
|
||||||
|
@ -179,6 +191,7 @@ void loadFileJNI(const int index, const std::string &filePath) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void stopLoadingJNI(const int index) {
|
void stopLoadingJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "stopLoading", "(I)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "stopLoading", "(I)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
||||||
|
@ -187,6 +200,7 @@ void stopLoadingJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void reloadJNI(const int index) {
|
void reloadJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "reload", "(I)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "reload", "(I)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
||||||
|
@ -195,6 +209,7 @@ void reloadJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canGoBackJNI(const int index) {
|
bool canGoBackJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "canGoBack", "(I)Z")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "canGoBack", "(I)Z")) {
|
||||||
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, index);
|
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, index);
|
||||||
|
@ -205,6 +220,7 @@ bool canGoBackJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool canGoForwardJNI(const int index) {
|
bool canGoForwardJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "canGoForward", "(I)Z")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "canGoForward", "(I)Z")) {
|
||||||
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, index);
|
jboolean ret = t.env->CallStaticBooleanMethod(t.classID, t.methodID, index);
|
||||||
|
@ -215,6 +231,7 @@ bool canGoForwardJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void goBackJNI(const int index) {
|
void goBackJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "goBack", "(I)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "goBack", "(I)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
||||||
|
@ -223,6 +240,7 @@ void goBackJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void goForwardJNI(const int index) {
|
void goForwardJNI(const int index) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "goForward", "(I)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "goForward", "(I)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index);
|
||||||
|
@ -231,6 +249,7 @@ void goForwardJNI(const int index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void evaluateJSJNI(const int index, const std::string &js) {
|
void evaluateJSJNI(const int index, const std::string &js) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "evaluateJS", "(ILjava/lang/String;)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "evaluateJS", "(ILjava/lang/String;)V")) {
|
||||||
jstring jjs = t.env->NewStringUTF(js.c_str());
|
jstring jjs = t.env->NewStringUTF(js.c_str());
|
||||||
|
@ -242,6 +261,7 @@ void evaluateJSJNI(const int index, const std::string &js) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScalesPageToFitJNI(const int index, const bool scalesPageToFit) {
|
void setScalesPageToFitJNI(const int index, const bool scalesPageToFit) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setScalesPageToFit", "(IZ)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setScalesPageToFit", "(IZ)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, scalesPageToFit);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, scalesPageToFit);
|
||||||
|
@ -250,6 +270,7 @@ void setScalesPageToFitJNI(const int index, const bool scalesPageToFit) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void setWebViewVisibleJNI(const int index, const bool visible) {
|
void setWebViewVisibleJNI(const int index, const bool visible) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
cocos2d::JniMethodInfo t;
|
cocos2d::JniMethodInfo t;
|
||||||
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setVisible", "(IZ)V")) {
|
if (cocos2d::JniHelper::getStaticMethodInfo(t, CLASS_NAME, "setVisible", "(IZ)V")) {
|
||||||
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, visible);
|
t.env->CallStaticVoidMethod(t.classID, t.methodID, index, visible);
|
||||||
|
@ -258,6 +279,7 @@ void setWebViewVisibleJNI(const int index, const bool visible) {
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string getUrlStringByFileName(const std::string &fileName) {
|
std::string getUrlStringByFileName(const std::string &fileName) {
|
||||||
|
// LOGD("error: %s,%d",__func__,__LINE__);
|
||||||
const std::string basePath("file:///android_asset/");
|
const std::string basePath("file:///android_asset/");
|
||||||
std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
|
std::string fullPath = cocos2d::FileUtils::getInstance()->fullPathForFilename(fileName);
|
||||||
const std::string assetsPath("assets/");
|
const std::string assetsPath("assets/");
|
||||||
|
@ -407,8 +429,7 @@ namespace cocos2d {
|
||||||
void WebViewImpl::setVisible(bool visible) {
|
void WebViewImpl::setVisible(bool visible) {
|
||||||
setWebViewVisibleJNI(_viewTag, visible);
|
setWebViewVisibleJNI(_viewTag, visible);
|
||||||
}
|
}
|
||||||
} // namespace cocos2d
|
|
||||||
} // namespace experimental
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
|
} // namespace experimental
|
||||||
|
} //namespace cocos2d
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -135,7 +135,7 @@ namespace experimental{
|
||||||
Node::setVisible(visible);
|
Node::setVisible(visible);
|
||||||
_impl->setVisible(visible);
|
_impl->setVisible(visible);
|
||||||
}
|
}
|
||||||
} // namespace cocos2d
|
|
||||||
} // namespace ui
|
} // namespace ui
|
||||||
} // namespace experimental
|
} // namespace experimental
|
||||||
|
} //namespace cocos2d
|
||||||
|
|
||||||
|
|
|
@ -104,6 +104,7 @@ Classes/UITest/CocoStudioGUITest/UITextBMFontTest/UITextBMFontTest_Editor.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp \
|
Classes/UITest/CocoStudioGUITest/UITextFieldTest/UITextFieldTest_Editor.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \
|
Classes/UITest/CocoStudioGUITest/UIWidgetAddNodeTest/UIWidgetAddNodeTest_Editor.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp \
|
Classes/UITest/CocoStudioGUITest/UIVideoPlayerTest/UIVideoPlayerTest.cpp \
|
||||||
|
Classes/UITest/CocoStudioGUITest/UIWebViewTest/UIWebViewTest.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \
|
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageView.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp \
|
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomImageViewReader.cpp \
|
||||||
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp \
|
Classes/UITest/CocoStudioGUITest/CustomWidget/CustomParticleWidget.cpp \
|
||||||
|
|
|
@ -24,10 +24,20 @@
|
||||||
|
|
||||||
#include "UIWebViewTest.h"
|
#include "UIWebViewTest.h"
|
||||||
|
|
||||||
|
WebViewTest::WebViewTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
WebViewTest::~WebViewTest()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
bool WebViewTest::init()
|
bool WebViewTest::init()
|
||||||
{
|
{
|
||||||
if (UIScene::init()) {
|
if (UIScene::init()) {
|
||||||
_webView = experimental::ui::WebView::create();
|
_webView = cocos2d::experimental::ui::WebView::create();
|
||||||
_webView->setPosition(Director::getInstance()->getVisibleSize()/2);
|
_webView->setPosition(Director::getInstance()->getVisibleSize()/2);
|
||||||
_webView->setContentSize(Director::getInstance()->getVisibleSize() * 0.5);
|
_webView->setContentSize(Director::getInstance()->getVisibleSize() * 0.5);
|
||||||
_webView->loadUrl("http://www.baidu.com");
|
_webView->loadUrl("http://www.baidu.com");
|
||||||
|
|
|
@ -32,6 +32,8 @@ USING_NS_CC;
|
||||||
class WebViewTest : public UIScene
|
class WebViewTest : public UIScene
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
WebViewTest();
|
||||||
|
virtual ~WebViewTest();
|
||||||
UI_SCENE_CREATE_FUNC(WebViewTest);
|
UI_SCENE_CREATE_FUNC(WebViewTest);
|
||||||
|
|
||||||
virtual bool init();
|
virtual bool init();
|
||||||
|
|
Loading…
Reference in New Issue