Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
32096e8d74 | ||
![]() |
b2e58d4462 | ||
![]() |
c0e90edc9e | ||
![]() |
e29648f328 | ||
![]() |
36e83cdd26 | ||
![]() |
77dad4165f | ||
![]() |
74f0323ebe | ||
![]() |
3e27e9cba7 | ||
![]() |
5ae3e1d729 | ||
![]() |
93c149afb6 |
2
.gitignore
vendored
2
.gitignore
vendored
@ -10,4 +10,4 @@
|
|||||||
/app/build/
|
/app/build/
|
||||||
/sdk/build/
|
/sdk/build/
|
||||||
/.idea/
|
/.idea/
|
||||||
/assets
|
/assets/game
|
||||||
|
@ -6,4 +6,9 @@ key/publish_key
|
|||||||
key store pass: 7654321Kingsome_
|
key store pass: 7654321Kingsome_
|
||||||
key alias: release
|
key alias: release
|
||||||
key pass: 7654321Kingsome_
|
key pass: 7654321Kingsome_
|
||||||
|
|
||||||
|
vivo key alias: vivo
|
||||||
|
oppo key alias: oppo
|
||||||
|
xiaomi key alias: release
|
||||||
|
|
||||||
```
|
```
|
||||||
|
@ -35,8 +35,8 @@ android {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation fileTree(include: '*.jar', dir: 'libs')
|
implementation fileTree(include: ['*.jar','*.aar'], dir: 'libs')
|
||||||
implementation(name: 'egret', ext: 'aar')
|
|
||||||
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
|
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'
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,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);
|
||||||
@ -198,7 +198,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();
|
||||||
@ -257,8 +257,10 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
private void startMain() {
|
private void startMain() {
|
||||||
Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
|
Intent intent = new Intent(LaunchActivity.this, MainActivity.class);
|
||||||
|
intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
|
||||||
intent.putExtra("preloadPath", preloadPath);
|
intent.putExtra("preloadPath", preloadPath);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
finish();
|
finish();
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -270,5 +272,10 @@ public class LaunchActivity extends Activity {
|
|||||||
}
|
}
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
|
@Override
|
||||||
|
public void finish() {
|
||||||
|
super.finish();
|
||||||
|
overridePendingTransition(0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.hnjc.wjtx;
|
package com.hnjc.wjtx;
|
||||||
|
|
||||||
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,6 +17,7 @@ import android.widget.ImageView;
|
|||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import com.hnjc.wjtx.util.AssetsUtil;
|
import com.hnjc.wjtx.util.AssetsUtil;
|
||||||
|
import com.hnjc.wjtx.util.IdUtil;
|
||||||
import com.hnjc.wjtx.util.StorageUtil;
|
import com.hnjc.wjtx.util.StorageUtil;
|
||||||
import com.hnjc.wjtx.util.StringUtil;
|
import com.hnjc.wjtx.util.StringUtil;
|
||||||
|
|
||||||
@ -84,10 +86,24 @@ public class MainActivity extends Activity {
|
|||||||
@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) {
|
||||||
nativeAndroid.exitGame();
|
//声明并初始化弹出对象
|
||||||
|
AlertDialog.Builder builder=new AlertDialog.Builder(this);
|
||||||
|
builder.setTitle("提示:");
|
||||||
|
builder.setMessage("是否退出");
|
||||||
|
//设置确认按钮
|
||||||
|
builder.setNegativeButton("确定", (dialog, which) -> {
|
||||||
|
nativeAndroid.exitGame();
|
||||||
|
finish();//退出程序
|
||||||
|
});
|
||||||
|
//设置取消按钮
|
||||||
|
builder.setPositiveButton("取消",null);
|
||||||
|
//显示弹框
|
||||||
|
builder.show();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return super.onKeyDown(keyCode, keyEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return super.onKeyDown(keyCode, keyEvent);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setExternalInterfaces() {
|
private void setExternalInterfaces() {
|
||||||
@ -148,6 +164,18 @@ public class MainActivity extends Activity {
|
|||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("getUid", message -> {
|
nativeAndroid.setExternalInterface("getUid", message -> {
|
||||||
//TODO: 平台的登陆
|
//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", "");
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
||||||
nativeAndroid.setExternalInterface("@onState", message -> {
|
nativeAndroid.setExternalInterface("@onState", message -> {
|
||||||
Log.e(TAG, "Get @onState: " + message);
|
Log.e(TAG, "Get @onState: " + message);
|
||||||
@ -171,12 +199,38 @@ public class MainActivity extends Activity {
|
|||||||
String productCode = jsonObject.getString("productCode");
|
String productCode = jsonObject.getString("productCode");
|
||||||
int count = jsonObject.getInt("count");
|
int count = jsonObject.getInt("count");
|
||||||
//TODO: 平台的支付
|
//TODO: 平台的支付
|
||||||
|
JSONObject obj = new JSONObject();
|
||||||
|
try {
|
||||||
|
obj.put("errcode", 0);
|
||||||
|
obj.put("errmsg", "");
|
||||||
|
nativeAndroid.callExternalInterface("payResult", obj.toString());
|
||||||
|
} catch (JSONException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
} catch (JSONException e) {
|
} catch (JSONException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} catch ( Exception e ) {
|
} catch ( Exception e ) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
/**
|
||||||
|
* 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,
|
||||||
|
*/
|
||||||
|
nativeAndroid.setExternalInterface("reportRoleInfo", message -> {
|
||||||
|
Log.i(TAG, "Get reportRoleInfo: " + message);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -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,12 +188,15 @@ 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();
|
||||||
while((line = bufReader.readLine()) != null)
|
while((line = bufReader.readLine()) != null)
|
||||||
result.append(line);
|
result.append(line);
|
||||||
|
fileInputStream.close();
|
||||||
inputReader.close();
|
inputReader.close();
|
||||||
bufReader.close();
|
bufReader.close();
|
||||||
return result.toString();
|
return result.toString();
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:opacity="opaque">
|
android:opacity="opaque">
|
||||||
<item android:drawable="@color/color_black"/>
|
<item android:drawable="@color/colorBlack"/>
|
||||||
<item>
|
<item>
|
||||||
<bitmap
|
<bitmap
|
||||||
android:gravity="center"
|
android:gravity="center"
|
||||||
|
@ -3,5 +3,6 @@
|
|||||||
<color name="colorPrimary">#3F51B5</color>
|
<color name="colorPrimary">#3F51B5</color>
|
||||||
<color name="colorPrimaryDark">#303F9F</color>
|
<color name="colorPrimaryDark">#303F9F</color>
|
||||||
<color name="colorAccent">#FF4081</color>
|
<color name="colorAccent">#FF4081</color>
|
||||||
|
<color name="colorBlack">#000000</color>
|
||||||
<color name="colorProgressBg">#32000000</color>
|
<color name="colorProgressBg">#32000000</color>
|
||||||
</resources>
|
</resources>
|
||||||
|
@ -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</string>
|
<string name="game_url">http://local/index.html?channel=7103</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>
|
||||||
|
@ -11,7 +11,7 @@ buildscript {
|
|||||||
jcenter()
|
jcenter()
|
||||||
}
|
}
|
||||||
dependencies {
|
dependencies {
|
||||||
classpath 'com.android.tools.build:gradle:3.3.1'
|
classpath 'com.android.tools.build:gradle:4.1.1'
|
||||||
|
|
||||||
// NOTE: Do not place your application dependencies here; they belong
|
// NOTE: Do not place your application dependencies here; they belong
|
||||||
// in the individual module build.gradle files
|
// in the individual module build.gradle files
|
||||||
|
4
gradle/wrapper/gradle-wrapper.properties
vendored
4
gradle/wrapper/gradle-wrapper.properties
vendored
@ -1,6 +1,6 @@
|
|||||||
#Mon Nov 16 13:55:33 CST 2020
|
#Thu Nov 19 11:09:11 CST 2020
|
||||||
distributionBase=GRADLE_USER_HOME
|
distributionBase=GRADLE_USER_HOME
|
||||||
distributionPath=wrapper/dists
|
distributionPath=wrapper/dists
|
||||||
zipStoreBase=GRADLE_USER_HOME
|
zipStoreBase=GRADLE_USER_HOME
|
||||||
zipStorePath=wrapper/dists
|
zipStorePath=wrapper/dists
|
||||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
|
distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip
|
||||||
|
Loading…
x
Reference in New Issue
Block a user