Compare commits

...

10 Commits
master ... uc

Author SHA1 Message Date
zhl
b899ede62a update gradle version code 2021-10-19 12:03:27 +08:00
zhl
26154b3c57 更新版本号 2021-07-28 13:35:24 +08:00
zhl
068a80cb83 更新uc的版本号 2021-01-18 13:01:51 +08:00
zhl
7ec2cacaac 修正热更无法正常运行的bug 2020-12-23 20:08:35 +08:00
zhl
0b4a20b506 更新uc的版本号 2020-12-01 14:57:26 +08:00
zhl
10027cdcac 修改uc PullupActivity相关配置 2020-12-01 13:44:38 +08:00
zhl
86e7543a00 更新uc的releasekey 2020-12-01 10:10:24 +08:00
zhl
a5eed53e33 游戏icon增加角标 2020-11-30 16:48:24 +08:00
zhl
970b4e8ad8 完善uc的代码 2020-11-27 20:16:01 +08:00
zhl
f8c016c722 添加uc接入代码 2020-11-27 16:19:07 +08:00
32 changed files with 394 additions and 200 deletions

View File

@ -10,5 +10,5 @@ key pass: 7654321Kingsome_
vivo key alias: vivo
oppo key alias: oppo
xiaomi key alias: release
uc key alias: uc
```

View File

@ -1,13 +1,13 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
compileSdkVersion 26
defaultConfig {
applicationId "com.hnjc.wjtx.mi"
minSdkVersion 18
targetSdkVersion 28
versionCode 1
versionName "1.0.0"
applicationId "com.hnjc.wjtx.aligames"
minSdkVersion 19
targetSdkVersion 26
versionCode 8
versionName "1.0.8"
ndk {
abiFilters 'armeabi-v7a'
}
@ -27,16 +27,19 @@ android {
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
buildToolsVersion '28.0.3'
buildToolsVersion '26.0.3'
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
useLibrary 'org.apache.http.legacy'
}
dependencies {
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.volley:volley:1.1.1'
implementation 'org.greenrobot:eventbus:3.2.0'
implementation 'com.jakewharton:butterknife:8.2.1'
annotationProcessor('com.jakewharton:butterknife-compiler:8.2.1')
}

Binary file not shown.

Binary file not shown.

Binary file not shown.

114
app/proguard-rules.pro vendored
View File

@ -1,90 +1,34 @@
-keepattributes InnerClasses,Signature,Exceptions,Deprecated,*Annotation*
-printmapping 'mapping.txt'
# this is very dangerous that cause bug
-ignorewarnings
-dontskipnonpubliclibraryclassmembers
-dontshrink
-dontoptimize
-keepattributes Exceptions,InnerClasses,Signature,Deprecated,SourceFile,LineNumberTable,LocalVariable*Table,*Annotation*,Synthetic,EnclosingMethod
-keepclasseswithmembers class * extends cn.gundam.sdk.shell.even.SDKEventReceiver
-keep class cn.uc.**{
<methods>;
<fields>;
}
-keep class cn.gundam.**{
<methods>;
<fields>;
}
-keep class android.**{
<methods>;
<fields>;
}
-keep class org.json.**{
<methods>;
<fields>;
}
-dontwarn android.**
-dontwarn com.google.**
-keep class android.** {*;}
-keep class com.google.** {*;}
-keep class com.android.** {*;}
-dontwarn org.apache.**
-keep class org.apache.** { *; }
-keep class sun.misc.Unsafe { *; }
-keep class com.google.** {*;}
-keep public class android.arch.core.internal.FastSafeIterableMap
-keep public class android.arch.core.util.Function
-keep public class android.arch.lifecycle.Lifecycle
-keep public class android.arch.lifecycle.Observer
-keep public class android.arch.lifecycle.ReportFragment
-keep public class android.arch.lifecycle.ViewModel
-keep public class android.support.v4.app.Fragment
-keep public class android.support.annotation.AnimatorRes
-keep public class android.support.v4.app.ActivityCompat
-keep public class android.support.design.widget.CoordinatorLayout
-keep public class android.support.v4.app.AppLaunchChecker
-keep public class android.support.v4.app.BackStackState
#-libraryjars libs/alipaySdk.jar
-dontwarn com.alipay.**
-keep class com.alipay.** {*;}
-keep class com.ut.device.** {*;}
-keep class com.ta.utdid2.** {*;}
#-libraryjars libs/eventbus-3.jar
-keep class org.greenrobot.eventbus.** { *; }
-keep class de.greenrobot.event.** { *; }
-keep class de.greenrobot.dao.** {*;}
-keepclassmembers class ** {
public void onEvent*(**);
void onEvent*(**);
}
-keepclassmembers class ** {
@org.greenrobot.eventbus.Subscribe <methods>;
}
-keep enum org.greenrobot.eventbus.ThreadMode { *; }
# Only required if you use AsyncExecutor
-keepclassmembers class * extends org.greenrobot.eventbus.util.ThrowableFailureEvent {
<init>(java.lang.Throwable);
}
#-libraryjars libs/wechat.jar
-keep class com.tencent.** {*;}
#-libraryjars libs/glide.jar
-keep class com.bumptech.glide.** {*;}
-dontwarn com.xiaomi.**
-keep class com.xiaomi.** {*;}
-keep class com.mi.** {*;}
-keep class com.wali.** {*;}
-keep class cn.com.wali.** {*;}
-keep class miui.net.**{*;}
-keep class org.xiaomi.** {*;}
#保留位于View类中的get和set方法
-keepclassmembers public class * extends android.view.View{
void set*(***);
*** get*();
}
#保留在Activity中以View为参数的方法不变
-keepclassmembers class * extends android.app.Activity{
public void *(android.view.View);
}
#保留实现了Parcelable的类名不变
-keep class * implements android.os.Parcelable{
public static final android.os.Parcelable$Creator *;
}
#保留R$*类中静态成员的变量名
-keep class **.R$* {*;}
-dontwarn android.support.**
-keep class **.R$styleable{*;}
-keep class com.hnjc.wjtx.mi.** { *; }
-dontwarn com.hnjc.wjtx.mi.**
-keep class com.hnjc.wjtx.aligames.** { *; }
-dontwarn com.hnjc.wjtx.aligams.**
-keep class org.egret.** { *; }

View File

@ -1,6 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.hnjc.wjtx">
xmlns:tools="http://schemas.android.com/tools"
package="com.hnjc.wjtx.aligames">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
@ -10,9 +12,17 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.VIBRATE" />
<supports-screens
android:anyDensity="true"
android:largeScreens="true"
android:normalScreens="true"
android:resizeable="true"
android:smallScreens="true" />
<application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
tools:replace="android:allowBackup"
android:icon="@drawable/icon"
android:name=".JCApplication"
android:label="@string/app_name"
android:usesCleartextTraffic="true"
@ -38,19 +48,45 @@
android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity>
<!-- 增加app拉起相关cn.uc.gamesdk.activity.PullupActivity的声明 -->
<activity
android:name="cn.uc.gamesdk.activity.PullupActivity"
android:theme="@android:style/Theme.Translucent"
android:taskAffinity="com.hnjc.wjtx.aligames.diff"
android:excludeFromRecents="true"
android:label="PullupActivity"
android:launchMode="singleTop"
android:exported="true"
tools:node="replace">
<!-- <activity android:name=".MainActivity"-->
<!-- android:launchMode="singleTask"-->
<!-- android:screenOrientation="portrait"-->
<!-- android:windowSoftInputMode="adjustPan|stateAlwaysVisible"-->
<!-- android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"-->
<!-- android:theme="@android:style/Theme.NoTitleBar.Fullscreen">-->
<!-- <intent-filter>-->
<!-- <action android:name="android.intent.action.MAIN" />-->
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE"/>
<data android:scheme="ng1179479" />
</intent-filter>
</activity>
<activity
android:name="cn.gundam.sdk.shell.activity.ProxyActivity"
android:configChanges="keyboardHidden|orientation|screenSize"
android:label="@string/app_name"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:windowSoftInputMode="adjustResize" >
<intent-filter>
<action android:name="cn.uc.gamesdk.sdkweb" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<!-- sdk service -->
<service
android:name="cn.gundam.sdk.shell.service.ProxyService"
android:exported="true"
android:process=":bgservice" />
<!-- sdk service end -->
<!-- <category android:name="android.intent.category.LAUNCHER" />-->
<!-- </intent-filter>-->
<!-- </activity>-->
</application>

View File

@ -1,12 +0,0 @@
package com.hnjc.wjtx;
import android.app.Application;
import android.util.Log;
public class JCApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Log.i("JCApplication", "JCApplication onCreate");
}
}

View File

@ -0,0 +1,18 @@
package com.hnjc.wjtx.aligames;
import android.app.Application;
import android.util.Log;
import cn.uc.gamesdk.SDKHelper;
public class JCApplication extends Application {
@Override
public void onCreate() {
Log.i("JCApplication", "JCApplication onCreate");
if(!SDKHelper.isBackground(this)){
//调用super方法
super.onCreate();
//表示当前为SDK所属的子进程不应该再执行其他游戏相关的初始化
}
}
}

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx;
package com.hnjc.wjtx.aligames;
import android.Manifest;
import android.app.Activity;
@ -11,19 +11,30 @@ import android.os.Message;
import android.util.Log;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import com.hnjc.wjtx.net.DownloadRunnable;
import com.hnjc.wjtx.net.TaskInfo;
import com.hnjc.wjtx.net.WebApi;
import com.hnjc.wjtx.util.AssetsUtil;
import com.hnjc.wjtx.util.StringUtil;
import com.hnjc.wjtx.util.UnzipRunnable;
import com.hnjc.wjtx.aligames.net.DownloadRunnable;
import com.hnjc.wjtx.aligames.net.TaskInfo;
import com.hnjc.wjtx.aligames.net.WebApi;
import com.hnjc.wjtx.aligames.util.AssetsUtil;
import com.hnjc.wjtx.aligames.util.StringUtil;
import com.hnjc.wjtx.aligames.util.UnzipRunnable;
import org.json.JSONException;
import org.json.JSONObject;
import java.io.File;
import cn.gundam.sdk.shell.even.SDKEventKey;
import cn.gundam.sdk.shell.even.SDKEventReceiver;
import cn.gundam.sdk.shell.even.Subscribe;
import cn.gundam.sdk.shell.exception.AliLackActivityException;
import cn.gundam.sdk.shell.open.ParamInfo;
import cn.gundam.sdk.shell.open.UCOrientation;
import cn.gundam.sdk.shell.param.SDKParamKey;
import cn.gundam.sdk.shell.param.SDKParams;
import cn.uc.gamesdk.UCGameSdk;
public class LaunchActivity extends Activity {
private final String TAG = "LaunchActivity";
private final String ZERO_VERSION = "0";
@ -100,7 +111,35 @@ public class LaunchActivity extends Activity {
requestPermissions(permissions, 111);
}
}
compareVersions();
ucNetworkAndInitUCGameSDK();
UCGameSdk.defaultSdk().registerSDKEventReceiver(receiver);
}
public void ucNetworkAndInitUCGameSDK() {
//!!!在调用SDK初始化前进行网络检查
//当前没有拥有网络
ucSdkInit();//执行UCGameSDK初始化
}
private void ucSdkInit() {
ParamInfo gameParamInfo = new ParamInfo();
gameParamInfo.setGameId(UCSdkConfig.gameId);
gameParamInfo.setOrientation(UCOrientation.PORTRAIT);
SDKParams sdkParams = new SDKParams();
sdkParams.put(SDKParamKey.GAME_PARAMS, gameParamInfo);
try {
UCGameSdk.defaultSdk().initSdk(this, sdkParams);
} catch (AliLackActivityException e) {
e.printStackTrace();
}
}
/**
@ -143,7 +182,7 @@ public class LaunchActivity extends Activity {
*/
private void getLocalVersionInfo() {
String fileName = gameUrl.replace("index.html", "version.json");
String realPath = getFileDirByUrl(fileName);
String realPath = preloadPath + "/" + getFileDirByUrl(fileName) + "version.json" ;
File versionFile = new File(realPath);
if (versionFile.exists()) {
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
@ -211,7 +250,7 @@ public class LaunchActivity extends Activity {
}
// 更新远程资源
private void preloadGame() {
String dir = preloadPath + getFileDirByUrl(gameUrl);
String dir = preloadPath + "/" + getFileDirByUrl(gameUrl);
File dirFile = new File(dir);
if (!dirFile.exists()) {
dirFile.mkdirs();
@ -301,6 +340,7 @@ public class LaunchActivity extends Activity {
handler.removeCallbacksAndMessages(null);
handler = null;
}
UCGameSdk.defaultSdk().unregisterSDKEventReceiver(receiver);
super.onDestroy();
}
@Override
@ -309,5 +349,22 @@ public class LaunchActivity extends Activity {
// 移除activity的移出场动画
overridePendingTransition(0, 0);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
ucNetworkAndInitUCGameSDK();
}
SDKEventReceiver receiver = new SDKEventReceiver() {
@Subscribe(event = SDKEventKey.ON_INIT_SUCC)
private void onInitSucc() {
compareVersions();
}
@Subscribe(event = SDKEventKey.ON_INIT_FAILED)
private void onInitFailed(String data) {
//初始化失败
Toast.makeText(LaunchActivity.this, "init failed", Toast.LENGTH_SHORT).show();
Log.i(TAG, "UC SDK init failed");
ucNetworkAndInitUCGameSDK();
}
};
}

View File

@ -1,7 +1,6 @@
package com.hnjc.wjtx;
package com.hnjc.wjtx.aligames;
import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.SharedPreferences;
import android.content.res.Resources;
@ -16,15 +15,27 @@ import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.Toast;
import com.hnjc.wjtx.util.AssetsUtil;
import com.hnjc.wjtx.util.IdUtil;
import com.hnjc.wjtx.util.StorageUtil;
import com.hnjc.wjtx.util.StringUtil;
import com.hnjc.wjtx.aligames.util.AssetsUtil;
import com.hnjc.wjtx.aligames.util.StorageUtil;
import com.hnjc.wjtx.aligames.util.StringUtil;
import org.egret.egretnativeandroid.EgretNativeAndroid;
import org.json.JSONException;
import org.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
import cn.gundam.sdk.shell.even.SDKEventKey;
import cn.gundam.sdk.shell.even.SDKEventReceiver;
import cn.gundam.sdk.shell.even.Subscribe;
import cn.gundam.sdk.shell.exception.AliLackActivityException;
import cn.gundam.sdk.shell.exception.AliNotInitException;
import cn.gundam.sdk.shell.open.OrderInfo;
import cn.gundam.sdk.shell.param.SDKParamKey;
import cn.gundam.sdk.shell.param.SDKParams;
import cn.uc.gamesdk.UCGameSdk;
//Android项目发布设置详见doc目录下的README_ANDROID.md
public class MainActivity extends Activity {
@ -40,7 +51,7 @@ public class MainActivity extends Activity {
super.onCreate(savedInstanceState);
String preloadPath = AssetsUtil.getDiskFileDir(this, this.getString(R.string.preload_path));
String gameUrl = this.getString(R.string.game_url);
nativeAndroid = new EgretNativeAndroid(this);
if (!nativeAndroid.checkGlEsVersion()) {
@ -59,7 +70,7 @@ public class MainActivity extends Activity {
nativeAndroid.config.preloadPath = preloadPath;
setExternalInterfaces();
String gameUrl = this.getString(R.string.game_url);
if (!nativeAndroid.initialize(gameUrl)) {
Toast.makeText(this, "Initialize native failed.",
Toast.LENGTH_LONG).show();
@ -67,8 +78,13 @@ public class MainActivity extends Activity {
}
setContentView(nativeAndroid.getRootFrameLayout());
rootLayout = nativeAndroid.getRootFrameLayout();
nativeAndroid.pause();
showLoadingView();
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
UCGameSdk.defaultSdk().registerSDKEventReceiver(receiver);
}
public void startGame() {
nativeAndroid.resume();
}
@Override
@ -86,19 +102,11 @@ public class MainActivity extends Activity {
@Override
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
//声明并初始化弹出对象
AlertDialog.Builder builder=new AlertDialog.Builder(this);
builder.setTitle("提示:");
builder.setMessage("是否退出");
//设置确认按钮
builder.setNegativeButton("确定", (dialog, which) -> {
nativeAndroid.exitGame();
finish();//退出程序
});
//设置取消按钮
builder.setPositiveButton("取消",null);
//显示弹框
builder.show();
try {
UCGameSdk.defaultSdk().exit(this, null);
} catch (Exception e) {
e.printStackTrace();
}
return true;
} else {
return super.onKeyDown(keyCode, keyEvent);
@ -163,18 +171,7 @@ public class MainActivity extends Activity {
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
});
nativeAndroid.setExternalInterface("getUid", message -> {
//TODO: 平台的登陆
JSONObject obj = new JSONObject();
try {
obj.put("openid", IdUtil.getUid(this));
obj.put("token", "");
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
obj.put("errorcode", 1);
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
nativeAndroid.callExternalInterface("loginCancel", "");
}
ucSdkLogin();
});
nativeAndroid.setExternalInterface("@onState", message -> {
@ -192,21 +189,18 @@ public class MainActivity extends Activity {
nativeAndroid.setExternalInterface("@onError", message -> Log.e(TAG, "Get @onError: " + message));
// 支付
nativeAndroid.setExternalInterface("pay", message -> {
Log.i(TAG, "client pay: " + message);
try {
JSONObject jsonObject = new JSONObject(message);
String cpOrderId = jsonObject.getString("orderId");
String productCode = jsonObject.getString("productCode");
int count = jsonObject.getInt("count");
//TODO: 平台的支付
JSONObject obj = new JSONObject();
try {
obj.put("errcode", 0);
obj.put("errmsg", "");
nativeAndroid.callExternalInterface("payResult", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
Map<String, Object> paramMap = new HashMap<>();
paramMap.put(SDKParamKey.CALLBACK_INFO, jsonObject.getString("callbackInfo"));
paramMap.put(SDKParamKey.NOTIFY_URL, jsonObject.getString("notifyUrl"));
paramMap.put(SDKParamKey.AMOUNT, jsonObject.getString("amount"));
paramMap.put(SDKParamKey.CP_ORDER_ID, jsonObject.getString("cpOrderId"));
paramMap.put(SDKParamKey.ACCOUNT_ID, jsonObject.getString("accountId"));
paramMap.put(SDKParamKey.SIGN, jsonObject.getString("sign"));
paramMap.put(SDKParamKey.SIGN_TYPE, jsonObject.getString("signType"));
ucSdkPay(paramMap);
} catch (JSONException e) {
e.printStackTrace();
} catch ( Exception e ) {
@ -230,11 +224,30 @@ public class MainActivity extends Activity {
*/
nativeAndroid.setExternalInterface("reportRoleInfo", message -> {
Log.i(TAG, "Get reportRoleInfo: " + message);
try {
JSONObject data = new JSONObject(message);
SDKParams sdkParams = new SDKParams();
sdkParams.put(SDKParamKey.STRING_ROLE_ID, data.getString("userRoleId"));
sdkParams.put(SDKParamKey.STRING_ROLE_NAME, data.getString("userRoleName"));
sdkParams.put(SDKParamKey.LONG_ROLE_LEVEL, (long) data.getInt("userRoleLevel"));
/**
*角色创建时间需要传递当前服务器时间不可传递设备本地时间值生成后保持唯一且角色创建升级退出重登三个时机均需传递此参数
**/
sdkParams.put(SDKParamKey.LONG_ROLE_CTIME, data.getLong("roleCreateTime"));
sdkParams.put(SDKParamKey.STRING_ZONE_ID, data.getString("serverId"));
sdkParams.put(SDKParamKey.STRING_ZONE_NAME, data.getString("serverName"));
UCGameSdk.defaultSdk().submitRoleData(this, sdkParams);
// Toast.makeText(MainActivity.this,"submitData = "+sdkParams, Toast.LENGTH_SHORT).show();
} catch (AliNotInitException | AliLackActivityException | JSONException e) {
e.printStackTrace();
}
});
}
@Override
protected void onDestroy() {
UCGameSdk.defaultSdk().unregisterSDKEventReceiver(receiver);
receiver = null;
super.onDestroy();
}
@ -266,4 +279,118 @@ public class MainActivity extends Activity {
launchScreenImageView = null;
}
private void ucSdkLogin() {
try {
UCGameSdk.defaultSdk().login(this, null);
} catch (AliLackActivityException e) {
e.printStackTrace();
} catch (AliNotInitException e) {
e.printStackTrace();
}
}
private void ucSdkPay(Map<String, Object> paramMap) {
try {
SDKParams sdkParams = new SDKParams();
sdkParams.putAll(paramMap);
UCGameSdk.defaultSdk().pay(this, sdkParams);
} catch (Exception e) {
e.printStackTrace();
// addOutputResult("charge failed - Exception: " + e.toString() + "\n");
}
}
SDKEventReceiver receiver = new SDKEventReceiver() {
@Subscribe(event = SDKEventKey.ON_LOGIN_SUCC)
private void onLoginSucc(String sid) {
Log.i(TAG, "UC onLoaginSucc: " + sid);
JSONObject obj = new JSONObject();
try {
obj.put("openid", sid);
obj.put("token", sid);
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
nativeAndroid.callExternalInterface("loginCancel", "");
}
}
@Subscribe(event = SDKEventKey.ON_LOGIN_FAILED)
private void onLoginFailed(String desc) {
nativeAndroid.callExternalInterface("loginCancel", desc);
}
@Subscribe(event = SDKEventKey.ON_LOGOUT_SUCC)
private void onLogoutSucc() {
nativeAndroid.callExternalInterface("loginOut", "");
// AccountInfo.instance().setSid("");
ucSdkLogin();
}
@Subscribe(event = SDKEventKey.ON_LOGOUT_FAILED)
private void onLogoutFailed() {
Toast.makeText(MainActivity.this, "logout failed", Toast.LENGTH_SHORT).show();
// printMsg("注销失败");
}
@Subscribe(event = SDKEventKey.ON_EXIT_SUCC)
private void onExit(String desc) {
nativeAndroid.exitGame();
finish();//退出程序
// // 退出程序
// Intent intent = new Intent(Intent.ACTION_MAIN);
// intent.addCategory(Intent.CATEGORY_HOME);
// intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
// startActivity(intent);
// android.os.Process.killProcess(android.os.Process.myPid());
// printMsg(desc);
}
@Subscribe(event = SDKEventKey.ON_EXIT_CANCELED)
private void onExitCanceled(String desc) {
// Toast.makeText(MainActivity.this, desc, Toast.LENGTH_SHORT).show();
}
@Subscribe(event = SDKEventKey.ON_CREATE_ORDER_SUCC)
private void onCreateOrderSucc(OrderInfo orderInfo) {
if (orderInfo != null) {
String txt = orderInfo.getOrderAmount() + "," + orderInfo.getOrderId() + "," + orderInfo.getPayWay();
Log.i(TAG, "下单成功: " + txt + "\n");
}
JSONObject obj = new JSONObject();
try {
obj.put("errcode", 0);
obj.put("errmsg", "");
nativeAndroid.callExternalInterface("payResult", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
Log.i(TAG, "pay succ");
}
@Subscribe(event = SDKEventKey.ON_PAY_USER_EXIT)
private void onPayUserExit(OrderInfo orderInfo) {
if (orderInfo != null) {
String txt = orderInfo.getOrderAmount() + "," + orderInfo.getOrderId() + "," + orderInfo.getPayWay();
// addOutputResult("页面关闭,订单信息: " + txt + "\n");
}
Log.i(TAG, "pay cancel");
JSONObject obj = new JSONObject();
try {
obj.put("errcode", 1);
obj.put("errmsg", "user cancel");
nativeAndroid.callExternalInterface("payResult", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
}
}
};
}

View File

@ -0,0 +1,14 @@
package com.hnjc.wjtx.aligames;
public class UCSdkConfig {
// 以下参数仅供测试在正式集成SDK时需要使用正式的id数据
// 游戏开发人员需要跟自己的商务或运营人员联系获取
public static final int gameId = 1179479;
public static final String sign_key = "bf4dcf740ca7cd6f0980e4d8fa7f77b0";
}

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import android.content.Context;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import org.json.JSONObject;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
public class BaseMode {
private boolean status;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import android.util.Log;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
public class RequestErrorEvent {
private int type;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import org.json.JSONObject;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
public class TaskInfo {
private String name;//文件名

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import android.content.Context;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net;
package com.hnjc.wjtx.aligames.net;
import android.content.Context;
@ -14,7 +14,7 @@ public class WebApi {
public void getVersionInfo(BaseInterface iFace) {
this.mInterface = iFace;
// String versionUrl = "http://10.0.1.3:7021/game/zip/version.json";
// String versionUrl = "https://test.kingsome.cn/wjtx/config/version_native.json";
String versionUrl = "https://h5games-al.kingsome.cn/wjtx/config/version_native.json";
AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() {

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.util;
package com.hnjc.wjtx.aligames.util;
import android.content.Context;
import android.content.res.AssetManager;
@ -12,6 +12,7 @@ import org.json.JSONObject;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
@ -187,12 +188,15 @@ public class AssetsUtil {
*/
public static String readFromFile(Context context, String path) {
try {
InputStreamReader inputReader = new InputStreamReader(context.openFileInput(path));
FileInputStream fileInputStream = new FileInputStream(new File(path));
InputStreamReader inputReader = new InputStreamReader(fileInputStream);
BufferedReader bufReader = new BufferedReader(inputReader);
String line="";
StringBuilder result= new StringBuilder();
while((line = bufReader.readLine()) != null)
result.append(line);
fileInputStream.close();
inputReader.close();
bufReader.close();
return result.toString();

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.util;
package com.hnjc.wjtx.aligames.util;
import android.content.ContentResolver;
import android.content.Context;
@ -20,7 +20,7 @@ public class IdUtil {
while (enumeration.hasMoreElements()) {
NetworkInterface netInterface = enumeration.nextElement();
if (netInterface.getName().equals("wlan0")) {
return com.hnjc.wjtx.util.StringUtil.getMD5(netInterface.getHardwareAddress().toString(), false);
return com.hnjc.wjtx.aligames.util.StringUtil.getMD5(netInterface.getHardwareAddress().toString(), false);
}
}
} catch (Exception e) {
@ -59,9 +59,9 @@ public class IdUtil {
ContentResolver resolver = context.getContentResolver();
String wifiMac = getWifiMac();
String androidId = getAndroidId(resolver);
if (com.hnjc.wjtx.util.StringUtil.notBlank(androidId)) {
if (com.hnjc.wjtx.aligames.util.StringUtil.notBlank(androidId)) {
return androidId;
} else if (com.hnjc.wjtx.util.StringUtil.notBlank(wifiMac)) {
} else if (com.hnjc.wjtx.aligames.util.StringUtil.notBlank(wifiMac)) {
return wifiMac;
} else {
return getUniquePsuedoID();

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.util;
package com.hnjc.wjtx.aligames.util;
import android.content.SharedPreferences;

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.util;
package com.hnjc.wjtx.aligames.util;
import java.security.MessageDigest;

View File

@ -1,8 +1,8 @@
package com.hnjc.wjtx.util;
package com.hnjc.wjtx.aligames.util;
import android.util.Log;
import com.hnjc.wjtx.net.TaskInfo;
import com.hnjc.wjtx.aligames.net.TaskInfo;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 1.1 MiB

View File

@ -3,7 +3,7 @@
<string name="load_game">下载游戏资源</string>
<string name="start_game">进入游戏</string>
<string name="preload_path">preload</string>
<string name="game_url">http://local/index.html?channel=7103</string>
<string name="game_url">http://local/index.html?channel=7110</string>
<string name="local_version">1.0.0</string>
<string name="load_back">load_back</string>
<string name="launch_version">获取游戏版本</string>

View File

@ -15,6 +15,9 @@ buildscript {
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
classpath 'com.jakewharton:butterknife-gradle-plugin:8.4.0'
classpath "gradle.plugin.com.dorongold.plugins:task-tree:1.3"
}
}

View File

@ -16,6 +16,6 @@ org.gradle.jvmargs=-Xmx1536m
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
android.injected.testOnly=false
android.useAndroidX=true
android.enableJetifier=true
#android.injected.testOnly=false
#android.useAndroidX=true
#android.enableJetifier=true

Binary file not shown.