Commit 52392bce authored by fallenstardust's avatar fallenstardust

加入多语言超先行更新检测下载

parent d38e50bf
...@@ -165,12 +165,8 @@ public interface Constants { ...@@ -165,12 +165,8 @@ public interface Constants {
String ID3 = "#pre_release_code"; String ID3 = "#pre_release_code";
//String URL_YGO233_DOWNLOAD_LINK = "https://ygo233.com/download/ygomobile"; //String URL_YGO233_DOWNLOAD_LINK = "https://ygo233.com/download/ygomobile";
String URL_YGO233_ADVANCE = "";//"https://ygo233.com/pre#pre_release_cards";//关闭233先行卡服务器,但不要删除该字段,许多未调用的遗留代码使用该contant String URL_YGO233_ADVANCE = "";//"https://ygo233.com/pre#pre_release_cards";//关闭233先行卡服务器,但不要删除该字段,许多未调用的遗留代码使用该contant
String URL_YGO233_DATAVER = "https://cdn02.moecube.com:444/ygopro-super-pre/data/version.txt"; String URL_CN_DATAVER = "https://cdn02.moecube.com:444/ygopro-super-pre/data/version.txt";
String URL_PRE_CARD = "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release.json"; String URL_PRE_CARD = "https://cdn02.moecube.com:444/ygopro-super-pre/data/test-release.json";
// String URL_YGO233_DATAVER = "http://192.168.0.103:8006/ygo/version.txt";
// String URL_PRE_CARD = "http://192.168.0.103:8006/ygo/test-release.json";
String URL_YGO233_FILE = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk"; String URL_YGO233_FILE = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk";
String URL_YGO233_FILE_ALT = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk"; String URL_YGO233_FILE_ALT = "https://cdn02.moecube.com:444/ygopro-super-pre/archive/ygopro-super-pre.ypk";
String URL_YGO233_BUG_REPORT = "https://ygo233.com/pre#faq"; String URL_YGO233_BUG_REPORT = "https://ygo233.com/pre#faq";
......
package cn.garymb.ygomobile.ex_card; package cn.garymb.ygomobile.ex_card;
import static cn.garymb.ygomobile.Constants.URL_CN_DATAVER;
import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE; import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE;
import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE_ALT; import static cn.garymb.ygomobile.Constants.URL_YGO233_FILE_ALT;
import static cn.garymb.ygomobile.utils.DownloadUtil.TYPE_DOWNLOAD_EXCEPTION; import static cn.garymb.ygomobile.utils.DownloadUtil.TYPE_DOWNLOAD_EXCEPTION;
...@@ -92,7 +93,7 @@ public class ExCardListFragment extends Fragment { ...@@ -92,7 +93,7 @@ public class ExCardListFragment extends Fragment {
LogUtil.i(TAG, "start download"); LogUtil.i(TAG, "start download");
if (downloadState != DownloadState.DOWNLOAD_ING) { if (downloadState != DownloadState.DOWNLOAD_ING) {
downloadState = DownloadState.DOWNLOAD_ING; downloadState = DownloadState.DOWNLOAD_ING;
downloadfromWeb(URL_YGO233_FILE); downloadfromWeb(URL_FILE);
} }
} }
}); });
......
...@@ -105,7 +105,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -105,7 +105,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
//showNewbieGuide("homePage"); //showNewbieGuide("homePage");
initBottomNavigationBar(); initBottomNavigationBar();
onNewIntent(getIntent()); onNewIntent(getIntent());
ServerUtil.initExCardState();//检查扩展卡版本 ServerUtil.initExCardState(this);//检查扩展卡版本
} }
@Override @Override
...@@ -318,7 +318,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat ...@@ -318,7 +318,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
@Override @Override
protected void onResume() { protected void onResume() {
super.onResume(); super.onResume();
ServerUtil.initExCardState();//检查扩展卡版本 ServerUtil.initExCardState(this);//检查扩展卡版本
} }
@Override @Override
......
...@@ -149,7 +149,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene ...@@ -149,7 +149,7 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
if (!EventBus.getDefault().isRegistered(this)) {//加上判断 if (!EventBus.getDefault().isRegistered(this)) {//加上判断
EventBus.getDefault().register(this); EventBus.getDefault().register(this);
} }
ServerUtil.initExCardState();//LogoActivity中会调用一次本函数,此处再次调用的原因:有时HomeFragment的onCreateView()函数执行较慢,导致initExCardState()中eventbus事件发布完毕后仍未注册,因此在此处再调用一次检查,再次发布 ServerUtil.initExCardState(getActivity());//LogoActivity中会调用一次本函数,此处再次调用的原因:有时HomeFragment的onCreateView()函数执行较慢,导致initExCardState()中eventbus事件发布完毕后仍未注册,因此在此处再调用一次检查,再次发布
changeColor(); changeColor();
try { try {
ServerUtil.refreshServer(activity); ServerUtil.refreshServer(activity);
......
package cn.garymb.ygomobile.utils; package cn.garymb.ygomobile.utils;
import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST; import static cn.garymb.ygomobile.Constants.ASSET_SERVER_LIST;
import static cn.garymb.ygomobile.Constants.URL_YGO233_DATAVER; import static cn.garymb.ygomobile.Constants.URL_CN_DATAVER;
import static cn.garymb.ygomobile.utils.StringUtils.isHost; import static cn.garymb.ygomobile.utils.StringUtils.isHost;
import static cn.garymb.ygomobile.utils.StringUtils.isNumeric; import static cn.garymb.ygomobile.utils.StringUtils.isNumeric;
import static cn.garymb.ygomobile.utils.WebParseUtil.isValidIP; import static cn.garymb.ygomobile.utils.WebParseUtil.isValidIP;
...@@ -27,6 +27,7 @@ import java.util.ArrayList; ...@@ -27,6 +27,7 @@ import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.List; import java.util.List;
import cn.garymb.ygomobile.AppsSettings;
import cn.garymb.ygomobile.Constants; import cn.garymb.ygomobile.Constants;
import cn.garymb.ygomobile.bean.ServerInfo; import cn.garymb.ygomobile.bean.ServerInfo;
import cn.garymb.ygomobile.bean.ServerList; import cn.garymb.ygomobile.bean.ServerList;
...@@ -56,10 +57,27 @@ public class ServerUtil { ...@@ -56,10 +57,27 @@ public class ServerUtil {
* 比对服务器的先行卡版本号与本地先行卡版本号, * 比对服务器的先行卡版本号与本地先行卡版本号,
* 更新全局变量exCardVersion(如删除先行卡、重新安装先行卡等) * 更新全局变量exCardVersion(如删除先行卡、重新安装先行卡等)
*/ */
public static void initExCardState() { public static void initExCardState(Context context) {
String oldVer = SharedPreferenceUtil.getExpansionDataVer(); String oldVer = SharedPreferenceUtil.getExpansionDataVer();
LogUtil.i(TAG, "server util, old pre-card version:" + oldVer); LogUtil.i(TAG, "server util, old pre-card version:" + oldVer);
OkhttpUtil.get(URL_YGO233_DATAVER, new Callback() { String language = context.getResources().getConfiguration().locale.getLanguage();
String id = "";
String URL_DATAVER = URL_CN_DATAVER;
if (!language.isEmpty()) {
if (AppsSettings.get().getDataLanguage() == -1) {
if (language.equals(AppsSettings.languageEnum.English.name)) id = "EN";
if (language.equals(AppsSettings.languageEnum.Korean.name)) id = "KR";
if (language.equals(AppsSettings.languageEnum.Spanish.name)) id = "ES";
if (language.equals(AppsSettings.languageEnum.Japanese)) id = "JP";
} else {
if (AppsSettings.get().getDataLanguage() == AppsSettings.languageEnum.Korean.code) id = "KR";
if (AppsSettings.get().getDataLanguage() == AppsSettings.languageEnum.English.code) id = "EN";
if (AppsSettings.get().getDataLanguage() == AppsSettings.languageEnum.Spanish.code) id = "ES";
if (AppsSettings.get().getDataLanguage() == AppsSettings.languageEnum.Japanese.code) id = "JP";
}
URL_DATAVER = (AppsSettings.get().getDataLanguage() == AppsSettings.languageEnum.Chinese.code) ? URL_CN_DATAVER : "https://github.com/DaruKani/TransSuperpre/blob/main/" + id + "/version.txt";
}
OkhttpUtil.get(URL_DATAVER, new Callback() {
@Override @Override
public void onFailure(Call call, IOException e) { public void onFailure(Call call, IOException e) {
exCardState = ExCardState.ERROR; exCardState = ExCardState.ERROR;
...@@ -69,7 +87,7 @@ public class ServerUtil { ...@@ -69,7 +87,7 @@ public class ServerUtil {
if (failCounter < 10) { if (failCounter < 10) {
LogUtil.i(TAG, "network failed, retry fetch pre-card version:"); LogUtil.i(TAG, "network failed, retry fetch pre-card version:");
failCounter++; failCounter++;
initExCardState(); initExCardState(context);
} }
} }
...@@ -161,7 +179,7 @@ public class ServerUtil { ...@@ -161,7 +179,7 @@ public class ServerUtil {
if (serverName != null && (isHost(serverHost) || isValidIP(serverHost)) && isNumeric(serverPort)) { if (serverName != null && (isHost(serverHost) || isValidIP(serverHost)) && isNumeric(serverPort)) {
AddServer(context, serverName, serverDesc, serverHost, Integer.valueOf(serverPort), Constants.PlayerName); AddServer(context, serverName, serverDesc, serverHost, Integer.valueOf(serverPort), Constants.PlayerName);
} else { } else {
Log.w(TAG,"can't parse ex-server properly"); Log.w(TAG, "can't parse ex-server properly");
} }
} }
} }
...@@ -210,7 +228,7 @@ public class ServerUtil { ...@@ -210,7 +228,7 @@ public class ServerUtil {
if (fileList == null) { if (fileList == null) {
return; return;
} }
for (int i=0; i<assetList.getServerInfoList().size();i++) { for (int i = 0; i < assetList.getServerInfoList().size(); i++) {
String assetName = assetList.getServerInfoList().get(i).getName(); String assetName = assetList.getServerInfoList().get(i).getName();
String assetDesc = assetList.getServerInfoList().get(i).getDesc(); String assetDesc = assetList.getServerInfoList().get(i).getDesc();
...@@ -218,7 +236,7 @@ public class ServerUtil { ...@@ -218,7 +236,7 @@ public class ServerUtil {
int assetPort = assetList.getServerInfoList().get(i).getPort(); int assetPort = assetList.getServerInfoList().get(i).getPort();
/*考虑到fileList的serverinfo其他信息被用户修改过,专门只比较域名地址和端口来视为相同的server来补充备注*/ /*考虑到fileList的serverinfo其他信息被用户修改过,专门只比较域名地址和端口来视为相同的server来补充备注*/
for (int j=0; j<fileList.getServerInfoList().size();j++){ for (int j = 0; j < fileList.getServerInfoList().size(); j++) {
String fileAddr = fileList.getServerInfoList().get(j).getServerAddr(); String fileAddr = fileList.getServerInfoList().get(j).getServerAddr();
int filePort = fileList.getServerInfoList().get(j).getPort(); int filePort = fileList.getServerInfoList().get(j).getPort();
String fileDesc = fileList.getServerInfoList().get(j).getDesc(); String fileDesc = fileList.getServerInfoList().get(j).getDesc();
...@@ -236,8 +254,9 @@ public class ServerUtil { ...@@ -236,8 +254,9 @@ public class ServerUtil {
} }
} }
saveItems(context,xmlFile,fileList.getServerInfoList()); saveItems(context, xmlFile, fileList.getServerInfoList());
} }
/** /**
* 从资源文件serverlist.xml(或本地文件server_list.xml)解析服务器列表,并将新添加的服务器信息(name,addr,port)合并到服务器列表中。 * 从资源文件serverlist.xml(或本地文件server_list.xml)解析服务器列表,并将新添加的服务器信息(name,addr,port)合并到服务器列表中。
* *
......
...@@ -227,7 +227,7 @@ ...@@ -227,7 +227,7 @@
<string name="failed_reason">登录失败,原因是</string> <string name="failed_reason">登录失败,原因是</string>
<string name="notice_verify_email">请验证账号邮箱后重登方可进入聊天室</string> <string name="notice_verify_email">请验证账号邮箱后重登方可进入聊天室</string>
<string name="send">发送</string> <string name="send">发送</string>
<string name="mc_home">大厅</string> <string name="mc_home">直连大厅</string>
<string name="bbs">社区</string> <string name="bbs">社区</string>
<string name="McNews">公告</string> <string name="McNews">公告</string>
<string name="settings_pref_settings_only_game">直接启动游戏</string> <string name="settings_pref_settings_only_game">直接启动游戏</string>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment