diff --git a/app/src/main/assets/supplierconfig.json b/app/src/main/assets/supplierconfig.json deleted file mode 100644 index a6ecba4..0000000 --- a/app/src/main/assets/supplierconfig.json +++ /dev/null @@ -1,17 +0,0 @@ -{ - "supplier":{ - "vivo":{ - "appid":"104485272" - }, - "xiaomi":{ - - }, - "huawei":{ - - }, - "oppo":{ - - } - } - -} diff --git a/app/src/main/assets/vivounionsdk/vivounionapk.vua b/app/src/main/assets/vivounionsdk/vivounionapk.vua deleted file mode 100644 index 0110bab..0000000 Binary files a/app/src/main/assets/vivounionsdk/vivounionapk.vua and /dev/null differ diff --git a/app/src/main/assets/vivounionsdk/vivounionchecklist.xml b/app/src/main/assets/vivounionsdk/vivounionchecklist.xml deleted file mode 100644 index 5ad9d3a..0000000 --- a/app/src/main/assets/vivounionsdk/vivounionchecklist.xml +++ /dev/null @@ -1,244 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/app/src/main/java/com/hnjc/wjtx/LaunchActivity.java b/app/src/main/java/com/hnjc/wjtx/LaunchActivity.java index 48dfa98..2d79faf 100644 --- a/app/src/main/java/com/hnjc/wjtx/LaunchActivity.java +++ b/app/src/main/java/com/hnjc/wjtx/LaunchActivity.java @@ -25,12 +25,12 @@ import org.json.JSONObject; import java.io.File; public class LaunchActivity extends Activity { + private static final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; private final String TAG = "LaunchActivity"; private final String ZERO_VERSION = "0"; private ProgressBar progressBar = null; private TextView progressLabel = null; private WebApi webApi; - private String zipUrl; private String gameUrl; private String preloadPath; @@ -43,13 +43,9 @@ public class LaunchActivity extends Activity { private String versionStr; private String downloadStr; private String unzipStr; - private TaskInfo info;//任务信息 private DownloadRunnable runnable;//下载任务 private UnzipRunnable unzipRunnable; // 解压任务 - - private static final String[] permissions = {Manifest.permission.WRITE_EXTERNAL_STORAGE}; - private Handler handler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { @@ -59,7 +55,7 @@ public class LaunchActivity extends Activity { int l = (int) ((float) info.getCompletedLen() / (float) info.getContentLen() * 100); //设置进度条进度 updateProgress(l); - if (l>=100) {//当进度>=100时,取消Handler循环 + if (l >= 100) {//当进度>=100时,取消Handler循环 handler.removeCallbacksAndMessages(null); if (info.getType() == 0) { File file = new File(info.getPath() + info.getName()); @@ -74,6 +70,12 @@ public class LaunchActivity extends Activity { } }); + private static String getFileDirByUrl(String urlString) { + int lastSlash = urlString.lastIndexOf('/'); + String server = urlString.substring(0, lastSlash + 1); + return server.replaceFirst("://", "/").replace(":", "#0A"); + } + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -101,9 +103,11 @@ public class LaunchActivity extends Activity { private void updateProgress(int val) { progressBar.setProgress(val); } + private void changeLoadTxt(String title) { progressLabel.setText(title); } + private void compareVersions() { changeLoadTxt(versionStr); updateProgress(10); @@ -123,6 +127,7 @@ public class LaunchActivity extends Activity { updateProgress(60); getRemoteVersionInfo(); } + /** * 获取位于预加载目录version.json中的版本号 */ @@ -139,6 +144,7 @@ public class LaunchActivity extends Activity { } } } + /** * 获取位于assets目录version.json中的版本号 */ @@ -152,6 +158,7 @@ public class LaunchActivity extends Activity { } } } + /** * 获取远程资源的版本号 */ @@ -197,6 +204,7 @@ public class LaunchActivity extends Activity { } }); } + private void preloadGame() { String dir = preloadPath + getFileDirByUrl(gameUrl); File dirFile = new File(dir); @@ -229,12 +237,6 @@ public class LaunchActivity extends Activity { handler.sendEmptyMessageDelayed(1, 200); } - - private static String getFileDirByUrl(String urlString) { - int lastSlash = urlString.lastIndexOf('/'); - String server = urlString.substring(0, lastSlash + 1); - return server.replaceFirst("://", "/").replace(":", "#0A"); - } private void emptyPreload() { File dirFile = new File(preloadPath); if (dirFile.exists() && dirFile.isDirectory()) { @@ -244,6 +246,7 @@ public class LaunchActivity extends Activity { } } } + private void deletePreloadFile(File file) { if (file.isDirectory()) { File[] files = file.listFiles(); @@ -255,20 +258,30 @@ public class LaunchActivity extends Activity { file.delete(); } } + private void startMain() { Intent intent = new Intent(LaunchActivity.this, MainActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION); intent.putExtra("preloadPath", preloadPath); startActivity(intent); + overridePendingTransition(0, 0); finish(); } + @Override protected void onDestroy() { //在Activity销毁时移除回调和msg,并置空,防止内存泄露 - if(handler != null){ + if (handler != null) { handler.removeCallbacksAndMessages(null); handler = null; } super.onDestroy(); } + @Override + public void finish() { + super.finish(); + overridePendingTransition(0, 0); + } + } diff --git a/app/src/main/java/com/hnjc/wjtx/MainActivity.java b/app/src/main/java/com/hnjc/wjtx/MainActivity.java index 47e3ba7..9caace9 100755 --- a/app/src/main/java/com/hnjc/wjtx/MainActivity.java +++ b/app/src/main/java/com/hnjc/wjtx/MainActivity.java @@ -42,33 +42,31 @@ public class MainActivity extends Activity { private Vibrator vibrator; //用户uid private String mUid = ""; + private String mAuthToken = ""; //游戏订单号 private String cpPayOrderNumber; //订单金额 private String cpOrderAmount; - private VivoAccountCallback mAcccountCallback = new VivoAccountCallback() { + private final VivoAccountCallback mAcccountCallback = new VivoAccountCallback() { @Override public void onVivoAccountLogin(String userName, String uid, String authToken) { // 1. 收到登录成功回调后,调用服务端接口校验登录有效性。arg2返回值为authtoken。服务端接口详见文档。校验登录代码略。 mUid = uid; - // 2. 登录成功后上报角色信息 - VivoUnionHelper.reportRoleInfo(new VivoRoleInfo("角色ID", "角色等级", "角色名称", "区服ID", "区服名称")); - // 3. 处理自己的登录成功逻辑 - Toast.makeText(MainActivity.this, "登录成功", Toast.LENGTH_SHORT).show(); - + mAuthToken = authToken; + sendUidToGame(mUid, mAuthToken); //登录成功 VivoUnionHelper.queryMissOrderResult(uid); } @Override public void onVivoAccountLogout(int i) { - + nativeAndroid.callExternalInterface("loginOut", ""); } @Override public void onVivoAccountLoginCancel() { - + nativeAndroid.callExternalInterface("loginCancel", ""); } }; @@ -251,7 +249,7 @@ public class MainActivity extends Activity { Toast.makeText(MainActivity.this, message, Toast.LENGTH_LONG).show(); }); nativeAndroid.setExternalInterface("getUid", message -> { - //TODO: 平台的登陆 + loginVivoAccount(); }); nativeAndroid.setExternalInterface("@onState", message -> { Log.e(TAG, "Get @onState: " + message); @@ -351,7 +349,7 @@ public class MainActivity extends Activity { */ public void loginVivoAccount() { if (!TextUtils.isEmpty(mUid)) { - Toast.makeText(this, "已登录成功,禁止重复登录", Toast.LENGTH_SHORT).show(); + sendUidToGame(mUid, mAuthToken); return; } @@ -406,4 +404,15 @@ public class MainActivity extends Activity { // VivoUnionHelper.payNowV2(this, vivoPayInfo, mVivoPayCallback, code); } + private void sendUidToGame(String uid, String token) { + JSONObject obj = new JSONObject(); + try { + obj.put("openid", uid); + obj.put("token", token); + nativeAndroid.callExternalInterface("sendUidToJS", obj.toString()); + } catch (JSONException e) { + e.printStackTrace(); + } + } + } diff --git a/platform.js b/platform.js index c2c7513..d92628f 100644 --- a/platform.js +++ b/platform.js @@ -12,7 +12,7 @@ class GamePlatform { this.jcGameId = 1009; this.jcChannelId = getQueryString('channel') ? Number(getQueryString('channel')) : 7103; console.log('jcchannelid: ' + this.jcChannelId); - this.isDev = false; + 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`;