This commit is contained in:
zhuguoqing 2022-05-26 15:34:24 +08:00
parent 8fe3f41663
commit ae43cdef4c
3 changed files with 141 additions and 140 deletions

View File

@ -14,11 +14,11 @@ android {
applicationId "com.shjc.cebg"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
versionName "1.0"
versionCode 3
versionName "1.0.2"
ndk{
abiFilters 'armeabi-v7a','x86','arm64-v8a'
abiFilters 'armeabi-v7a','arm64-v8a'
}
externalNativeBuild {

View File

@ -1,27 +1,27 @@
/****************************************************************************
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2015-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
****************************************************************************/
package org.cocos2dx.javascript;
import org.cocos2dx.lib.Cocos2dxActivity;
@ -182,45 +182,45 @@ public class AppActivity extends Cocos2dxActivity implements YouMeCallBackInterf
switch (eventType) {
case YouMeConst.YouMeEvent.YOUME_EVENT_INIT_OK: //YOUME_EVENT_INIT_OK:
System.out.println("Talk 初始化成功");
break;
System.out.println("Talk 初始化成功");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_INIT_FAILED://YOUME_EVENT_INIT_FAILED:
System.out.println("Talk 初始化失败");
break;
System.out.println("Talk 初始化失败");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_JOIN_OK://YOUME_EVENT_JOIN_OK:
System.out.println("Talk 进入频道成功,频道:" + channelID + " 用户id:" + param);
break;
System.out.println("Talk 进入频道成功,频道:" + channelID + " 用户id:" + param);
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_JOIN_FAILED://YOUME_EVENT_JOIN_FAILED:
System.out.println("Talk 进入频道:" + channelID + "失败,code:" + errorCode);
break;
System.out.println("Talk 进入频道:" + channelID + "失败,code:" + errorCode);
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_LEAVED_ONE://YOUME_EVENT_LEAVED_ONE:
System.out.println("Talk 离开单个频道:" + channelID);
break;
System.out.println("Talk 离开单个频道:" + channelID);
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_LEAVED_ALL://YOUME_EVENT_LEAVED_ALL:
System.out.println("Talk 离开所有频道这个回调channel参数为空字符串");
break;
System.out.println("Talk 离开所有频道这个回调channel参数为空字符串");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_PAUSED://YOUME_EVENT_PAUSED:
System.out.println("Talk 暂停");
break;
System.out.println("Talk 暂停");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_RESUMED://YOUME_EVENT_RESUMED:
System.out.println("Talk 恢复");
break;
System.out.println("Talk 恢复");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_SPEAK_SUCCESS://YOUME_EVENT_SPEAK_SUCCESS:///< 切换对指定频道讲话成功适用于多频道模式
break;
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_SPEAK_FAILED://YOUME_EVENT_SPEAK_FAILED:///< 切换对指定频道讲话失败适用于多频道模式
break;
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_RECONNECTING://YOUME_EVENT_RECONNECTING:///< 断网了正在重连
System.out.println("Talk 正在重连");
break;
System.out.println("Talk 正在重连");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_RECONNECTED://YOUME_EVENT_RECONNECTED:///< 断网重连成功
System.out.println("Talk 重连成功");
break;
System.out.println("Talk 重连成功");
break;
case YouMeConst.YouMeEvent.YOUME_EVENT_REC_PERMISSION_STATUS://YOUME_EVENT_REC_FAILED:///< 通知录音启动失败此时不管麦克风mute状态如何都没有声音输出
System.out.println("录音启动失败code" + errorCode);
break;
System.out.println("录音启动失败code" + errorCode);
break;
default:
break;
break;
}
}
@ -251,6 +251,7 @@ public class AppActivity extends Cocos2dxActivity implements YouMeCallBackInterf
ExampleApplication.session.addCallback(appActivity);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.parse(ExampleApplication.config.toWCUri()));
System.out.println(ExampleApplication.config.toWCUri());
try {
appActivity.startActivity(intent);
} catch (ActivityNotFoundException e) {
@ -263,10 +264,10 @@ public class AppActivity extends Cocos2dxActivity implements YouMeCallBackInterf
// private boolean hasSign = false;
public static void signApp(String nonce){
ExampleApplication.Companion.ethSign(nonce,ExampleApplication.session.approvedAccounts().get(0));
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("wc://"));
appActivity.startActivity(i);
ExampleApplication.Companion.ethSign(nonce,ExampleApplication.session.approvedAccounts().get(0));
Intent i = new Intent(Intent.ACTION_VIEW);
i.setData(Uri.parse("wc://"));
appActivity.startActivity(i);
}
@ -275,21 +276,21 @@ public class AppActivity extends Cocos2dxActivity implements YouMeCallBackInterf
System.out.println("change area"+area);
switch (area){
case "0":
// japan
api.init(appKey,appSecret,9,"");
break;
// japan
api.init(appKey,appSecret,9,"");
break;
case "1":
//singapore
api.init(appKey,appSecret,3,"");
break;
//singapore
api.init(appKey,appSecret,3,"");
break;
case "2":
// turkey
api.init(appKey,appSecret,8,"");
break;
// turkey
api.init(appKey,appSecret,8,"");
break;
case "3":
// usa
api.init(appKey,appSecret,12,"");
break;
// usa
api.init(appKey,appSecret,12,"");
break;
}
}
@ -300,49 +301,49 @@ public class AppActivity extends Cocos2dxActivity implements YouMeCallBackInterf
if(ExampleApplication.session.approvedAccounts()!=null){
if(methodCall.id()==999999999){
//签名
appActivity.runOnGLThread(new Runnable() {
@Override
public void run() {
String tmp = ExampleApplication.Companion.getSignRes().substring(2);
System.out.println("签名无前缀"+tmp);
Cocos2dxJavascriptJavaBridge.evalString("window.signApp(\""+tmp+"\")");
}
});
}else{
//连接钱包
appActivity.runOnGLThread(new Runnable() {
@Override
public void run() {
String result = methodCall.toString();
String[] allRes = result.split(",");
for(int i=0;i<allRes.length;i++){
//删除所有空格
String tt = allRes[i].replaceAll("\\s+", "");
if(tt.startsWith("chainId")){
String[] fi = tt.split("=");
int chainid = Double.valueOf(fi[1]).intValue();
System.out.println("chainid---"+chainid);
if(chainid==321){
// 链正确
String tmp = ExampleApplication.session.approvedAccounts().get(0).substring(2);
Cocos2dxJavascriptJavaBridge.evalString("window.connectOK(\""+tmp+"\")");
}else{
appActivity.runOnGLThread(new Runnable() {
@Override
public void run() {
String tmp = ExampleApplication.Companion.getSignRes().substring(2);
System.out.println("签名无前缀"+tmp);
Cocos2dxJavascriptJavaBridge.evalString("window.signApp(\""+tmp+"\")");
}
});
}else{
//连接钱包
appActivity.runOnGLThread(new Runnable() {
@Override
public void run() {
String result = methodCall.toString();
String[] allRes = result.split(",");
for(int i=0;i<allRes.length;i++){
//删除所有空格
String tt = allRes[i].replaceAll("\\s+", "");
if(tt.startsWith("chainId")){
String[] fi = tt.split("=");
int chainid = Double.valueOf(fi[1]).intValue();
System.out.println("chainid---"+chainid);
if(chainid==321){
// 链正确
String tmp = ExampleApplication.session.approvedAccounts().get(0).substring(2);
Cocos2dxJavascriptJavaBridge.evalString("window.connectOK(\""+tmp+"\")");
}else{
// 链不正确
runOnUiThread(new Runnable() {
public void run() {
final Toast toast = Toast.makeText(appActivity, "Your wallet should support KCC chain" , Toast.LENGTH_SHORT);
toast.show();
}
});
}
}
}
runOnUiThread(new Runnable() {
public void run() {
final Toast toast = Toast.makeText(appActivity, "Your wallet should support KCC chain" , Toast.LENGTH_SHORT);
toast.show();
}
});
}
}
}
}
});
}
}
});
}
}
}

View File

@ -62,8 +62,8 @@ class ExampleApplication : MultiDexApplication() {
session.performMethodCall(Session.MethodCall.Custom(999999999,"eth_signTypedData",parmList),::handleResponse)
}
fun handleResponse(resp: Session.MethodCall.Response) {
signRes = resp.result as String;
fun handleResponse(resp: Session.MethodCall.Response) {
signRes = resp.result as String;
}