Compare commits

...

8 Commits

Author SHA1 Message Date
zhl
3ed8671c61 update version code of meizu 2021-02-25 12:56:14 +08:00
zhl
8b74ffe041 修改魅族的版本号 2021-01-18 12:55:28 +08:00
zhl
9aaf50d237 修正热更无法正常运行的bug 2020-12-23 20:05:49 +08:00
zhl
b37c0bfff0 修改icon 2020-12-01 11:19:18 +08:00
zhl
c1d5b2bcf7 更新readme 2020-12-01 10:07:09 +08:00
zhl
4a6801185c 完善魅族必接功能 2020-11-27 12:01:57 +08:00
zhl
936267cc85 更新配置 2020-11-27 10:54:57 +08:00
zhl
f5b35506b2 添加魅族的接入代码 2020-11-26 16:06:14 +08:00
29 changed files with 706 additions and 107 deletions

View File

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

View File

@ -3,19 +3,29 @@ apply plugin: 'com.android.application'
android { android {
compileSdkVersion 28 compileSdkVersion 28
defaultConfig { defaultConfig {
applicationId "com.hnjc.wjtx.mi" applicationId "com.hnjc.wjtx.mz"
minSdkVersion 18 minSdkVersion 18
targetSdkVersion 28 targetSdkVersion 28
versionCode 1 versionCode 4
versionName "1.0.0" versionName "1.0.4"
ndk { ndk {
abiFilters 'armeabi-v7a' abiFilters 'armeabi-v7a'
} }
} }
signingConfigs {
release {
storeFile file("../key/publish_key")
storePassword "7654321Kingsome_"
keyAlias "meizu"
keyPassword "7654321Kingsome_"
v2SigningEnabled false
}
}
buildTypes { buildTypes {
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
} }
} }
sourceSets { sourceSets {
@ -36,7 +46,6 @@ android {
dependencies { dependencies {
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs') implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.volley:volley:1.1.1' implementation 'com.android.volley:volley:1.1.1'
implementation 'org.greenrobot:eventbus:3.2.0' implementation 'org.greenrobot:eventbus:3.2.0'
} }

Binary file not shown.

Binary file not shown.

View File

@ -1,57 +1,64 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <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.mz">
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.GET_TASKS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.VIBRATE" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
<application <application
android:allowBackup="false"
android:icon="@mipmap/ic_launcher"
android:name=".JCApplication" android:name=".JCApplication"
android:allowBackup="false"
android:icon="@drawable/icon"
android:label="@string/app_name" android:label="@string/app_name"
android:usesCleartextTraffic="true" android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.Light.NoTitleBar.Fullscreen" > tools:replace="name,label"
android:usesCleartextTraffic="true">
<meta-data android:name="android.max_aspect" android:value="2.2" /> <activity
<activity android:name=".LaunchActivity" android:name=".LaunchActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:launchMode="singleTask" android:launchMode="singleTask"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout" android:theme="@style/SplashTheme">
android:theme="@style/SplashTheme"
>
<intent-filter> <intent-filter>
<action android:name="android.intent.action.MAIN" /> <action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity android:name=".MainActivity"
<activity
android:name=".MainActivity"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:launchMode="singleTask" android:launchMode="singleTask"
android:screenOrientation="portrait" android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"> android:theme="@android:style/Theme.NoTitleBar.Fullscreen">
</activity> </activity>
<meta-data
<!-- <activity android:name=".MainActivity"--> android:name="android.max_aspect"
<!-- android:launchMode="singleTask"--> android:value="2.2" />
<!-- android:screenOrientation="portrait"--> <provider
<!-- android:windowSoftInputMode="adjustPan|stateAlwaysVisible"--> android:name="androidx.core.content.FileProvider"
<!-- android:configChanges="orientation|keyboardHidden|screenSize|screenLayout"--> android:authorities="com.hnjc.wjtx.mz.fileprovider"
<!-- android:theme="@android:style/Theme.NoTitleBar.Fullscreen">--> android:exported="false"
<!-- <intent-filter>--> android:grantUriPermissions="true">
<!-- <action android:name="android.intent.action.MAIN" />--> <meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
<!-- <category android:name="android.intent.category.LAUNCHER" />--> android:resource="@xml/file_paths" />
<!-- </intent-filter>--> </provider>
<!-- </activity>-->
</application> </application>
</manifest> </manifest>

View File

@ -1,12 +1,17 @@
package com.hnjc.wjtx; package com.hnjc.wjtx.mz;
import android.app.Application; import android.app.Application;
import android.util.Log; import android.util.Log;
import com.meizu.gamesdk.online.core.MzGameCenterPlatform;
public class JCApplication extends Application { public class JCApplication extends Application {
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();
Log.i("JCApplication", "JCApplication onCreate"); Log.i("JCApplication", "JCApplication onCreate");
String appId = "3345357";
String appKey = "8ece854e1f9c4e50844bb14b8e0a29c8";
MzGameCenterPlatform.init(this, appId, appKey);
} }
} }

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx; package com.hnjc.wjtx.mz;
import android.Manifest; import android.Manifest;
import android.app.Activity; import android.app.Activity;
@ -12,12 +12,12 @@ import android.util.Log;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import com.hnjc.wjtx.net.DownloadRunnable; import com.hnjc.wjtx.mz.net.DownloadRunnable;
import com.hnjc.wjtx.net.TaskInfo; import com.hnjc.wjtx.mz.net.TaskInfo;
import com.hnjc.wjtx.net.WebApi; import com.hnjc.wjtx.mz.net.WebApi;
import com.hnjc.wjtx.util.AssetsUtil; import com.hnjc.wjtx.mz.util.AssetsUtil;
import com.hnjc.wjtx.util.StringUtil; import com.hnjc.wjtx.mz.util.StringUtil;
import com.hnjc.wjtx.util.UnzipRunnable; import com.hnjc.wjtx.mz.util.UnzipRunnable;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -143,7 +143,7 @@ public class LaunchActivity extends Activity {
*/ */
private void getLocalVersionInfo() { private void getLocalVersionInfo() {
String fileName = gameUrl.replace("index.html", "version.json"); String fileName = gameUrl.replace("index.html", "version.json");
String realPath = getFileDirByUrl(fileName); String realPath = preloadPath + "/" + getFileDirByUrl(fileName) + "version.json" ;
File versionFile = new File(realPath); File versionFile = new File(realPath);
if (versionFile.exists()) { if (versionFile.exists()) {
JSONObject data = AssetsUtil.readJsonFromFile(this, realPath); JSONObject data = AssetsUtil.readJsonFromFile(this, realPath);
@ -211,7 +211,7 @@ public class LaunchActivity extends Activity {
} }
// 更新远程资源 // 更新远程资源
private void preloadGame() { private void preloadGame() {
String dir = preloadPath + getFileDirByUrl(gameUrl); String dir = preloadPath + "/" + getFileDirByUrl(gameUrl);
File dirFile = new File(dir); File dirFile = new File(dir);
if (!dirFile.exists()) { if (!dirFile.exists()) {
dirFile.mkdirs(); dirFile.mkdirs();

View File

@ -1,7 +1,6 @@
package com.hnjc.wjtx; package com.hnjc.wjtx.mz;
import android.app.Activity; import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context; import android.content.Context;
import android.content.SharedPreferences; import android.content.SharedPreferences;
import android.content.res.Resources; import android.content.res.Resources;
@ -16,10 +15,18 @@ import android.widget.FrameLayout;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.Toast; import android.widget.Toast;
import com.hnjc.wjtx.util.AssetsUtil; import com.hnjc.wjtx.mz.util.AssetsUtil;
import com.hnjc.wjtx.util.IdUtil; import com.hnjc.wjtx.mz.util.StorageUtil;
import com.hnjc.wjtx.util.StorageUtil; import com.hnjc.wjtx.mz.util.StringUtil;
import com.hnjc.wjtx.util.StringUtil; import com.meizu.gamesdk.model.callback.MzExitListener;
import com.meizu.gamesdk.model.callback.MzLoginListener;
import com.meizu.gamesdk.model.callback.MzPayListener;
import com.meizu.gamesdk.model.model.LoginResultCode;
import com.meizu.gamesdk.model.model.MzAccountInfo;
import com.meizu.gamesdk.model.model.MzBuyInfo;
import com.meizu.gamesdk.model.model.PayResultCode;
import com.meizu.gamesdk.online.core.MzGameBarPlatform;
import com.meizu.gamesdk.online.core.MzGameCenterPlatform;
import org.egret.egretnativeandroid.EgretNativeAndroid; import org.egret.egretnativeandroid.EgretNativeAndroid;
import org.json.JSONException; import org.json.JSONException;
@ -27,12 +34,14 @@ import org.json.JSONObject;
//Android项目发布设置详见doc目录下的README_ANDROID.md //Android项目发布设置详见doc目录下的README_ANDROID.md
public class MainActivity extends Activity { public class MainActivity extends Activity implements MzLoginListener, MzPayListener {
private final String TAG = "MainActivity"; private final String TAG = "MainActivity";
private EgretNativeAndroid nativeAndroid; private EgretNativeAndroid nativeAndroid;
private ImageView launchScreenImageView = null; private ImageView launchScreenImageView = null;
private FrameLayout rootLayout = null; private FrameLayout rootLayout = null;
private Vibrator vibrator; private Vibrator vibrator;
private MzAccountInfo accountInfo;
private MzGameBarPlatform mzGameBarPlatform;
@Override @Override
@ -69,36 +78,44 @@ public class MainActivity extends Activity {
rootLayout = nativeAndroid.getRootFrameLayout(); rootLayout = nativeAndroid.getRootFrameLayout();
showLoadingView(); showLoadingView();
vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE); vibrator = (Vibrator) this.getSystemService(Context.VIBRATOR_SERVICE);
//初始化可以指定gamebar第一次显示的位置在游戏退出时会记住用户操作的最后一次位置再次启动时使用上一次的位置
//第一次显示的位置可以指定四个方向左上左下右上右下
// public static final int GRAVITY_LEFT_TOP = 1;
// public static final int GRAVITY_LEFT_BOTTOM = 2;
// public static final int GRAVITY_RIGHT_TOP = 3;
// public static final int GRAVITY_RIGHT_BOTTOM = 4;
mzGameBarPlatform = new MzGameBarPlatform(this, MzGameBarPlatform.GRAVITY_LEFT_TOP);
mzGameBarPlatform.onActivityCreate();
mzGameBarPlatform.showGameBar();
} }
@Override @Override
protected void onPause() { protected void onPause() {
super.onPause(); super.onPause();
nativeAndroid.pause(); nativeAndroid.pause();
mzGameBarPlatform.onActivityPause();
} }
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
nativeAndroid.resume(); nativeAndroid.resume();
mzGameBarPlatform.onActivityResume();
} }
@Override @Override
public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) { public boolean onKeyDown(final int keyCode, final KeyEvent keyEvent) {
if (keyCode == KeyEvent.KEYCODE_BACK) { if (keyCode == KeyEvent.KEYCODE_BACK) {
//声明并初始化弹出对象 //声明并初始化弹出对象
AlertDialog.Builder builder=new AlertDialog.Builder(this); MzGameCenterPlatform.exitSDK(this, new MzExitListener() {
builder.setTitle("提示:"); @Override
builder.setMessage("是否退出"); public void callback(int i, String s) {
//设置确认按钮 if (i == MzExitListener.CODE_SDK_EXIT) {
builder.setNegativeButton("确定", (dialog, which) -> {
nativeAndroid.exitGame(); nativeAndroid.exitGame();
finish();//退出程序 finish();//退出程序
}
}
}); });
//设置取消按钮
builder.setPositiveButton("取消",null);
//显示弹框
builder.show();
return true; return true;
} else { } else {
return super.onKeyDown(keyCode, keyEvent); return super.onKeyDown(keyCode, keyEvent);
@ -163,18 +180,7 @@ public class MainActivity extends Activity {
Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show();
}); });
nativeAndroid.setExternalInterface("getUid", message -> { nativeAndroid.setExternalInterface("getUid", message -> {
//TODO: 平台的登陆 MzGameCenterPlatform.login(this, this);
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", "");
}
}); });
nativeAndroid.setExternalInterface("@onState", message -> { nativeAndroid.setExternalInterface("@onState", message -> {
@ -195,18 +201,25 @@ public class MainActivity extends Activity {
try { try {
JSONObject jsonObject = new JSONObject(message); JSONObject jsonObject = new JSONObject(message);
String cpOrderId = jsonObject.getString("orderId"); Log.i(TAG, "pay info: " + jsonObject.toString());
String productCode = jsonObject.getString("productCode"); Bundle buyBundle = new MzBuyInfo()
int count = jsonObject.getInt("count"); .setBuyCount(jsonObject.getInt("buy_amount"))
//TODO: 平台的支付 .setCpUserInfo(jsonObject.getString("user_info"))
JSONObject obj = new JSONObject(); .setOrderAmount(jsonObject.getString("total_price"))
try { .setOrderId(jsonObject.getString("cp_order_id"))
obj.put("errcode", 0); .setPerPrice(jsonObject.getString("product_per_price"))
obj.put("errmsg", ""); .setProductBody(jsonObject.getString("product_body"))
nativeAndroid.callExternalInterface("payResult", obj.toString()); .setProductId(jsonObject.getString("product_id"))
} catch (JSONException e) { .setProductSubject(jsonObject.getString("product_subject"))
e.printStackTrace(); .setProductUnit(jsonObject.getString("product_unit"))
} .setSign(jsonObject.getString("sign"))
.setSignType(jsonObject.getString("sign_type"))
.setCreateTime(jsonObject.getLong("create_time"))
.setAppid(jsonObject.getString("app_id"))
.setUserUid(jsonObject.getString("uid"))
.setPayType(jsonObject.getInt("pay_type"))
.toBundle();
MzGameCenterPlatform.payOnline(MainActivity.this, buyBundle, MainActivity.this);
} catch (JSONException e) { } catch (JSONException e) {
e.printStackTrace(); e.printStackTrace();
} catch ( Exception e ) { } catch ( Exception e ) {
@ -236,6 +249,8 @@ public class MainActivity extends Activity {
@Override @Override
protected void onDestroy() { protected void onDestroy() {
super.onDestroy(); super.onDestroy();
//调一下onActivityDestroy
mzGameBarPlatform.onActivityDestroy();
} }
private void showLoadingView() { private void showLoadingView() {
@ -266,4 +281,84 @@ public class MainActivity extends Activity {
launchScreenImageView = null; launchScreenImageView = null;
} }
/**
* 登录回调
* 请处理相关回调事件
*
* @param code 错误码
* @message 错误信息
* @MzAccountInfo 账号信息
*/
@Override
public void onLoginResult(int code, final MzAccountInfo accountInfo, final String message) {
switch (code) {
case LoginResultCode.LOGIN_SUCCESS:
this.accountInfo = accountInfo; //保存登录信息用于查询实名认证信息
JSONObject obj = new JSONObject();
try {
obj.put("openid", accountInfo.getUid());
obj.put("token", accountInfo.getSession());
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
nativeAndroid.callExternalInterface("sendUidToJS", obj.toString());
} catch (JSONException e) {
e.printStackTrace();
nativeAndroid.callExternalInterface("loginCancel", "");
}
break;
case LoginResultCode.LOGIN_LOGOUT:
nativeAndroid.callExternalInterface("loginOut", "");
break;
default:
JSONObject obj1 = new JSONObject();
try {
obj1.put("errcode", code);
// 如果其他登陆过程中的错误, 则传入一个大于0的errorcode
nativeAndroid.callExternalInterface("sendUidToJS", message);
} catch (JSONException e) {
e.printStackTrace();
nativeAndroid.callExternalInterface("loginCancel", "");
}
// runOnUiThread(new Runnable() {
// @Override
// public void run() {
// showMsg(message);
// }
// });
break;
}
}
/**
* 支付录回调
* 请处理相关回调事件
*
* @param code 错误码
* @message 错误信息
* @bundle 支付信息
*/
@Override
public void onPayResult(int code, final Bundle bundle, final String message) {
JSONObject obj = new JSONObject();
try {
obj.put("errcode", code);
obj.put("errmsg", message);
} catch (JSONException e) {
e.printStackTrace();
}
switch (code) {
case PayResultCode.PAY_SUCCESS: //支付成功
MzBuyInfo payInfo = MzBuyInfo.fromBundle(bundle);
Log.i(TAG, "支付成功: " + payInfo.getOrderId() + " | " + payInfo.getPerPrice());
case PayResultCode.PAY_ERROR_CANCEL: //支付取消
Log.i(TAG, "支付取消: ");
break;
default:
Log.i(TAG, "支付错误: code: " + code + " | " + message);
break;
}
nativeAndroid.callExternalInterface("payResult", obj.toString());
}
} }

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.net; package com.hnjc.wjtx.mz.net;
import android.content.Context; import android.content.Context;
@ -14,7 +14,7 @@ public class WebApi {
public void getVersionInfo(BaseInterface iFace) { public void getVersionInfo(BaseInterface iFace) {
this.mInterface = 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"; String versionUrl = "https://h5games-al.kingsome.cn/wjtx/config/version_native.json";
AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() { AppRequestUtil.getInstance().getRequest(context, versionUrl, new RequestListener() {

View File

@ -1,4 +1,4 @@
package com.hnjc.wjtx.util; package com.hnjc.wjtx.mz.util;
import android.content.Context; import android.content.Context;
import android.content.res.AssetManager; import android.content.res.AssetManager;
@ -12,6 +12,7 @@ import org.json.JSONObject;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
@ -187,7 +188,8 @@ public class AssetsUtil {
*/ */
public static String readFromFile(Context context, String path) { public static String readFromFile(Context context, String path) {
try { 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); BufferedReader bufReader = new BufferedReader(inputReader);
String line=""; String line="";
StringBuilder result= new StringBuilder(); StringBuilder result= new StringBuilder();

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 145 KiB

After

Width:  |  Height:  |  Size: 195 KiB

View File

@ -3,7 +3,7 @@
<string name="load_game">下载游戏资源</string> <string name="load_game">下载游戏资源</string>
<string name="start_game">进入游戏</string> <string name="start_game">进入游戏</string>
<string name="preload_path">preload</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=7108</string>
<string name="local_version">1.0.0</string> <string name="local_version">1.0.0</string>
<string name="load_back">load_back</string> <string name="load_back">load_back</string>
<string name="launch_version">获取游戏版本</string> <string name="launch_version">获取游戏版本</string>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<paths>
<external-path name="external_files" path="."/>
</paths>

Binary file not shown.

Binary file not shown.

476
platform.js Normal file
View File

@ -0,0 +1,476 @@
function getQueryString(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
return r ? decodeURIComponent(r[2]) : '';
}
class GamePlatform {
constructor() {
this.name = 'native';
this.version = "1.0.7";
this.jcGameId = 1009;
this.jcChannelId = getQueryString('channel') ? Number(getQueryString('channel')) : 7103;
console.log('jcchannelid: ' + this.jcChannelId);
this.isDev = true;
this.orderIdUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=Pay&a=preOrder`;
this.checkRegRewardUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=GoProxy&a=checkRegisterReward`;
this.regRewardUrl = `https://game1009proxy${this.isDev ? '-test':''}.kingsome.cn/webapp/index.php?c=GoProxy&a=registerReward`;
this.svrListUrl = `https://game1009gate${this.isDev ? '-test':''}.kingsome.cn/wjtxgate/common/login.aspx?pid=${this.jcChannelId}`;
this.wssHost = `game1009game${this.isDev ? '-test' : ''}.kingsome.cn`;
this.other = new GamePlatformOther();
}
login() {
return new Promise((resolve, reject) => {
jc.init({
channelid: this.jcChannelId,
gameid: this.jcGameId,
isoffical: !this.isDev,
});
console.log('jcfw init finished 2');
jc.loginUser({
success: function(res) {
console.log('登录成功', JSON.stringify(res));
wxUserData.open_id = res.openid;
wxUserData.nick_name = res.nickname;
wxUserData.avatar_url = res.avatar_url;
wxUserData.gender = res.sex;
platform.code = res.openid;
//res.session_key
platform.session = res.session_id;
resolve(res);
},
fail: function(neterr, logicerr, errmsg) {
console.log('登录错误');
console.log(neterr, logicerr, errmsg);
reject(errmsg);
}
});
});
}
getUserInfo() {
return new Promise((resolve, reject) => {
platform.login().then(res => {
console.log("登录成功");
resolve();
}).catch(err => {
reject(err);
});
})
}
// obj { data, success, fail }
_getOrderId(pid, uid, sid, callback) {
var url = jc.gg.extcfg['prePayUrl'] || this.orderIdUrl;
var reqData = {
openid: platform.code,
produce: pid,
gameid: platform.jcGameId,
session: platform.session,
uid: uid,
server: sid,
platform: platform.jcChannelId,
role_name: giant.Core.hero.name,
role_level: giant.Core.hero.level,
server_name: giant.Core.serverVO.name
};
var loginCount = 0;
var loginMaxCount = 1;
console.log('pre order with url: ' + url);
var request = function () {
platform.urlRequest({
url: url,
method: 'GET',
data: reqData,
success: function (res) {
console.log("_getOrderId success", JSON.stringify(res));
if (res && res.data) {
// session检测失败需要登录
if (res.data.sessionCheck != null) {
if (loginCount >= loginMaxCount) {
callback && callback(false, "session失效请重新登录");
return;
}
loginCount++;
platform.login().then(res => {
request();
}).catch(err => {
callback && callback(false, "session失效login失败请重新登录");
});
}
else {
callback && callback(true, res.data.prepayId);
}
}
else {
callback && callback(false, "接口返回有误,请重试");
}
},
fail: function (err) {
console.log('pay with err: ' + JSON.stringify(err));
callback && callback(false, "接口访问失败,请重试");
}
})
}
request();
}
pay(obj) {
var orderInfo = null;
console.warn("pay obj", JSON.stringify(obj));
var onOrderIdResult = function (isOk, data) {
if (isOk) {
try {
var payData = JSON.parse(data);
Object.assign(payData, {count: 1});
orderInfo = payData;
realPay();
} catch (err) {
obj.fail && obj.fail({ tipMessage: '解析接口数据失败' });
}
}
else {
obj.fail && obj.fail({ tipMessage: data });
}
}
var realPay = function () {
console.log("pay orderInfo", orderInfo);
if (!orderInfo) return;
jc.plat.pay(orderInfo)
.then(data => {
if (data.errcode === 0) {
console.log("[quick]pay success", JSON.stringify(data));
obj.success && obj.success();
} else {
console.warn("pay fail", JSON.stringify(data));
obj.fail && obj.fail({ tipMessage: "充值失败" , err: data.errmsg });
}
})
.catch(err => {
console.warn("pay fail", JSON.stringify(err));
obj.fail && obj.fail({ tipMessage: "充值失败" , err: err.errmsg });
})
}
platform._getOrderId(obj.data.goodsId, obj.data.uid, obj.data.sid, onOrderIdResult);
}
concatServerList(res0, res1) {
res0.data.lastWorldIds = res1.data.lastWorldIds.concat(res0.data.lastWorldIds);
if (res1 && res1.data) {
if (res1.data.servers) {
for (let data of res1.data.servers) {
data.comp = 'jc';
res0.data.servers.push(data);
}
}
}
if (res1 && res1.data && res1.data.notice) {
res0.data.notice = res1.data.notice;
}
return res0;
}
requestServerList() {
var url = this.svrListUrl;
return this.getServerList(url);
}
getServerList(url) {
return new Promise((resolve, reject) => {
let data = {
openId: wxUserData.open_id
}
platform.urlRequest({
url: url,
method: 'GET',
data: data,
success: function (res) {
resolve(res);
},
fail: function (err) {
console.log('getServerList fail with url:', url);
resolve({data: {
lastWorldIds: [],
servers: [],
}});
}
})
})
}
getWxWebResRoot(configUrl) {
return new Promise((resolve, reject) => {
platform.urlRequest({
url: configUrl,
method: "GET",
success: function (res) {
let newObj = res.data;
constantRes.wxWebResRoot = constantRes.root + newObj.version + "/";
resolve();
}
});
});
}
urlRequest(obj) {
var url = obj.url;
var method = obj.method.toUpperCase();
var data = obj.data;
var postDataRaw = obj.postDataRaw === true;
var success = obj.success;
var fail = obj.fail;
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
if (xhr.status >= 200 && xhr.status < 400) {
var retData = xhr.responseText;
try {
retData = JSON.parse(retData);
success && success({
data: retData
});
} catch (err) {
fail && fail();
}
} else if (xhr.status >= 400) {
fail && fail();
}
}
};
xhr.onerror = function (e) {
fail && fail();
};
if (method === "POST") {
var dataStr = null;
if (postDataRaw) {
dataStr = data;
}
else {
if (data) {
dataStr = "";
for (var key in data) {
if (dataStr != "") {
dataStr += "&";
}
dataStr += key + "=" + data[key];
}
}
}
xhr.open(method, url);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send(dataStr);
} else {
var paramStr = "";
if (data) {
for (var key in data) {
if (paramStr != "") {
paramStr += "&";
}
paramStr += key + "=" + encodeURIComponent(data[key]);
}
if (paramStr != "") {
paramStr = (url.indexOf("?") == -1 ? "?" : "&") + paramStr;
}
}
url += paramStr;
url += `&_d=${Date.now()}`
console.log(url);
xhr.open(method, url);
xhr.send();
}
}
}
class GamePlatformOther {
constructor() {
this.localFileName = 'userData_';
}
checkRegisterReward(uid, sid) {
return new Promise((resolve, reject) => {
var url = jc.gg.extcfg['checkRegRewardUrl'] || platform.checkRegRewardUrl;
console.log('checkRegisterReward req', uid, sid, url);
platform.urlRequest({
url: url,
method: 'GET',
data: {
uid: uid,
server: sid,
},
success: function (res) {
console.log("checkRegisterReward res", res);
if (res && res.data) {
if (res.data.code == 1) {
resolve && resolve(true);
}
else {
resolve && resolve(false, "code = " + res.data.code + ", error = " + res.data.error);
}
}
else {
reject && reject("接口返回有误,请重试");
}
},
fail: function (err) {
reject && reject("接口访问失败,请重试");
}
});
});
}
getRegisterReward(uid, sid, name) {
return new Promise((resolve, reject) => {
var url = jc.gg.extcfg['RegRewardUrl'] || platform.regRewardUrl;
console.log('getRegisterReward req', uid, sid, name, url);
var count = 0;
var maxCount = 20;
var interval = 3;
var doRequest = function () {
platform.urlRequest({
url: url,
method: 'GET',
data: {
uid: uid,
server: sid,
name: name
},
success: function (res) {
console.log("getRegisterReward res", res);
if (res && res.data) {
if (res.data.code == 1) {
resolve && resolve(true);
}
else {
count++;
if (count <= maxCount) {
setTimeout(doRequest, interval * 1000);
}
else {
resolve && resolve(false, "code = " + res.data.code + ", error = " + res.data.error);
}
}
}
else {
reject && reject("接口返回有误,请重试");
}
},
fail: function (err) {
reject && reject("接口访问失败,请重试");
}
});
}
doRequest();
});
}
reportRoleCreate(isNew) {
let data = {
isCreateRole: isNew,
roleCreateTime: Date.now(),
serverId: giant.Core.serverVO.id,
serverName: giant.Core.serverVO.name,
userRoleId: giant.Core.hero.id,
userRoleName: giant.Core.hero.name,
userRoleBalance: giant.Core.hero.coin,
vipLevel: giant.Core.hero.vipLevel,
userRoleLevel: giant.Core.hero.level,
partyId: 0,
partyName: giant.Core.hero.camp,
gameRoleGender: giant.Core.hero.gender,
gameRolePower: giant.Core.hero.power,
};
jc.plat.reportRoleInfo(data)
.then(res => {})
.catch(err=> {})
}
setLocalStorage(key, value) {
let self = this;
if (key === 'lastSvr') {
giant.Core.externalParams.lastWordId = value;
}
if (typeof localStorage != "undefined") {
localStorage.setItem(self.localFileName + key, value);
}
else {
console.warn("localStorage is null, on set");
}
}
getLocalStorage(key) {
let self = this;
if (key === 'lastSvr' && giant.Core.externalParams.lastWordId) {
return giant.Core.externalParams.lastWordId;
}
if (typeof localStorage != "undefined") {
var dataStr = localStorage.getItem(self.localFileName + key);
if (key === 'lastSvr') {
giant.Core.externalParams.lastWordId = dataStr;
}
return dataStr;
}
else {
console.warn("localStorage is null, on get");
return null;
}
}
getLiuHaiHeight() {
var ratioScreen = egret.Capabilities.boundingClientHeight / egret.Capabilities.boundingClientWidth;
var ratioGameDesign = 1136 / 640;
console.log("getLiuHaiHeight", ratioScreen, ratioGameDesign);
// 跟游戏分辨率相比,相等没有刘海
if (Math.abs(ratioScreen - ratioGameDesign) < 0.01) {
return 0;
}
else {
// 默认刘海值50
return 50;
}
}
}
class PlatUserData {
constructor() {
this.open_id = null;
this.nick_name = null;
this.avatar_url = null;
this.gender = null;
}
getOpenId() {
return this.open_id;
}
}
class GameConstant {
constructor() {
this.root = "";
this.wxWebResRoot = "";
}
}
window.platform = new GamePlatform();
window.wxUserData = new PlatUserData();
window.constantRes = new GameConstant();