Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
fallenstardust
YGOMobile
Commits
dcc89779
Commit
dcc89779
authored
Nov 19, 2023
by
fallenstardust
Committed by
GitHub
Nov 19, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #123 from zhuhongbozhuhongbo/master
修复上版本在添加先行卡服务器时存在的问题
parents
0f418747
2cd758ed
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
82 additions
and
67 deletions
+82
-67
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+4
-4
mobile/src/main/java/cn/garymb/ygomobile/bean/ServerList.java
...le/src/main/java/cn/garymb/ygomobile/bean/ServerList.java
+4
-1
mobile/src/main/java/cn/garymb/ygomobile/bean/events/CardInfoEvent.java
...n/java/cn/garymb/ygomobile/bean/events/CardInfoEvent.java
+3
-0
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
...ain/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ServerInfoEvent.java
...java/cn/garymb/ygomobile/bean/events/ServerInfoEvent.java
+3
-1
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardActivity.java
...main/java/cn/garymb/ygomobile/ex_card/ExCardActivity.java
+10
-8
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
.../java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
+13
-29
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
+40
-21
mobile/src/main/res/values-zh/strings.xml
mobile/src/main/res/values-zh/strings.xml
+2
-1
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+2
-1
No files found.
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
dcc89779
...
...
@@ -162,16 +162,16 @@ public interface Constants {
String
ID1
=
"[versionname]"
;
String
ID2
=
"[download_link]"
;
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_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_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_BUG_REPORT
=
"https://ygo233.com/pre#faq"
;
int
PORT_
YGO233
=
23333
;
String
URL_
YGO233_1
=
"s1.ygo233.com
"
;
String
URL_YGO233_2
=
"s2.ygo233.com"
;
int
PORT_
Mycard_Super_Pre_Server
=
888
;
String
URL_
Mycard_Super_Pre_Server
=
"mygo.superpre.pro
"
;
//
String URL_YGO233_2 = "s2.ygo233.com";
String
SERVER_FILE
=
"server_list.xml"
;
String
SHARE_FILE
=
".share_deck.png"
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/ServerList.java
View file @
dcc89779
...
...
@@ -4,6 +4,9 @@ import net.kk.xml.annotations.XmlElement;
import
java.util.List
;
/**
* 将服务器列表写入xml文件时利用的PO类
*/
@XmlElement
(
"servers"
)
public
class
ServerList
{
@XmlElement
(
"version"
)
...
...
@@ -20,7 +23,7 @@ public class ServerList {
}
public
ServerList
(
int
version
,
List
<
ServerInfo
>
serverInfoList
)
{
mServerInfoList
=
serverInfoList
;
this
.
mServerInfoList
=
serverInfoList
;
this
.
vercode
=
version
;
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/CardInfoEvent.java
View file @
dcc89779
package
cn.garymb.ygomobile.bean.events
;
/**
* 用于EventBus的事件类型。
*/
public
class
CardInfoEvent
{
public
int
position
;
public
boolean
toMain
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
View file @
dcc89779
package
cn.garymb.ygomobile.bean.events
;
/**
* 用于EventBus
发布的时间
类型。
* 用于EventBus
的事件
类型。
*/
public
class
ExCardEvent
{
public
enum
EventType
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ServerInfoEvent.java
View file @
dcc89779
package
cn.garymb.ygomobile.bean.events
;
import
cn.garymb.ygomobile.bean.ServerInfo
;
/**
* 用于EventBus的事件类型。
*/
public
class
ServerInfoEvent
{
public
int
position
;
public
ServerInfo
serverInfo
;
//为了让接受event的HomeFragment能获取到当前server的端口号等信息,加入该属性
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardActivity.java
View file @
dcc89779
...
...
@@ -9,6 +9,7 @@ import com.google.android.material.tabs.TabLayout;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.BaseActivity
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
public
class
ExCardActivity
extends
BaseActivity
{
private
static
final
String
TAG
=
String
.
valueOf
(
ExCardActivity
.
class
);
...
...
@@ -47,18 +48,19 @@ public class ExCardActivity extends BaseActivity {
return
true
;
}
private
int
backCounter
=
0
;
//todo 当未下载完先行卡就退出页面时,会导致软件错误退出。未来通过监听返回事件,判断下载状态,若正在下载则阻拦返回键。
//若发生错误或已完成,则不阻拦返回。
@Override
public
void
onBackPressed
()
{
// 完全由自己控制返回键逻辑,系统不再控制,但是有个前提是:
// 不要在Activity的onKeyDown或者OnKeyUp中拦截掉返回键
// 拦截:就是在OnKeyDown或者OnKeyUp中自己处理了返回键
//(这里处理之后return true.或者return false都会导致onBackPressed不会执行)
// 不拦截:在OnKeyDown和OnKeyUp中返回super对应的方法
//(如果两个方法都被覆写就分别都要返回super.onKeyDown,super.onKeyUp)
if
(
ExCardListFragment
.
downloadState
==
ExCardListFragment
.
DownloadState
.
DOWNLOAD_ING
)
{
if
(
backCounter
<
1
)
{
backCounter
++;
YGOUtil
.
showTextToast
(
"下载中,建议不要退出页面,再次按返回键可以退出页面"
);
return
;
}
}
super
.
onBackPressed
();
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
View file @
dcc89779
...
...
@@ -16,7 +16,6 @@ import android.view.View;
import
android.view.ViewGroup
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.fragment.app.Fragment
;
...
...
@@ -62,7 +61,7 @@ public class ExCardListFragment extends Fragment {
NO_DOWNLOAD
}
p
rivate
DownloadState
downloadState
;
p
ublic
static
DownloadState
downloadState
;
@Override
...
...
@@ -126,7 +125,7 @@ public class ExCardListFragment extends Fragment {
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
/* 查询不到版本号时,提示toast */
textDownload
.
setText
(
R
.
string
.
Download
);
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
"error"
+
getString
(
R
.
string
.
ex_card_check_toast_message_iii
)
);
//WebActivity.open(getActivity(), getString(R.string.ex_card_list_title), URL_YGO233_ADVANCE);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
...
...
@@ -149,10 +148,10 @@ public class ExCardListFragment extends Fragment {
downloadState
=
DownloadState
.
NO_DOWNLOAD
;
++
FailedCount
;
if
(
FailedCount
<=
2
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
Ask_to_Change_Other_Way
,
Toast
.
LENGTH_SHORT
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
Ask_to_Change_Other_Way
)
);
downloadfromWeb
(
URL_YGO233_FILE_ALT
);
}
YGOUtil
.
showTextToast
(
"error
"
+
getString
(
R
.
string
.
Download_precard_f
ailed
));
YGOUtil
.
showTextToast
(
"error
:"
+
getString
(
R
.
string
.
Download_Precard_F
ailed
));
break
;
// case UnzipUtils.ZIP_READY:
// textDownload.setText(R.string.title_use_ex);
...
...
@@ -161,15 +160,16 @@ public class ExCardListFragment extends Fragment {
downloadState
=
DownloadState
.
NO_DOWNLOAD
;
/* 将先行服务器信息添加到服务器列表中 */
String
servername
=
""
;
//todo 改成用安卓的localization机制strings.xml
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Chinese
.
code
)
servername
=
"
23333先行服务器
"
;
servername
=
"
萌卡超先行服
"
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Korean
.
code
)
servername
=
"
YGOPRO ?? ?? ????
"
;
servername
=
"
Mycard Super-pre Server
"
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
English
.
code
)
servername
=
"M
ercury23333 OCG/TCG Pre-release
"
;
servername
=
"M
ycard Super-pre Server
"
;
if
(
AppsSettings
.
get
().
getDataLanguage
()
==
AppsSettings
.
languageEnum
.
Spanish
.
code
)
servername
=
"M
ercury23333 OCG/TCG Pre-release
"
;
AddServer
(
getActivity
(),
servername
,
"s1.ygo233.com"
,
23333
,
"Knight of Hanoi"
);
servername
=
"M
ycard Super-pre Server
"
;
AddServer
(
getActivity
(),
servername
,
Constants
.
URL_Mycard_Super_Pre_Server
,
Constants
.
PORT_Mycard_Super_Pre_Server
,
"Knight of Hanoi"
);
//changeDownloadButton();在下载完成后,通过EventBus通知下载完成(加入用户点击下载后临时切出本fragment,又在下载完成后切回,通过eventbus能保证按钮样式正确更新
/* 注意,要先更新版本号 */
...
...
@@ -179,8 +179,7 @@ public class ExCardListFragment extends Fragment {
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
context
,
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
();
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
ypk_installed
));
LogUtil
.
i
(
"webCrawler"
,
"Ex-card package is installed"
);
/* 如果未开启先行卡设置,则跳转到设置页面 */
...
...
@@ -189,26 +188,11 @@ public class ExCardListFragment extends Fragment {
Intent
startSetting
=
new
Intent
(
context
,
MainActivity
.
class
);
startSetting
.
putExtra
(
"flag"
,
4
);
startActivity
(
startSetting
);
Toast
.
makeText
(
context
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
(
);
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
ypk_go_setting
)
);
}
break
;
// case UnzipUtils.ZIP_UNZIP_EXCEPTION:
// Toast.makeText(context, getString(R.string.install_failed_bcos) + msg.obj,
// Toast.LENGTH_SHORT).show();
// break;
// case HomeFragment.TYPE_GET_DATA_VER_OK:
// WebActivity.exCardVer = msg.obj.toString();
// String oldVer = SharedPreferenceUtil.getExpansionDataVer();
// if (!TextUtils.isEmpty(WebActivity.exCardVer)) {
// if (!WebActivity.exCardVer.equals(oldVer)) {
// //btn_download展示默认视图
// } else {
// btnDownload.setText(R.string.tip_redownload);
// }
// } else {
// showExNew();
// }
}
}
};
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
View file @
dcc89779
...
...
@@ -169,6 +169,32 @@ public class ServerUtil {
}
}
/**
* 读取xmlFile指定的本地文件server_list.xml和apk资源文件(assets)下的serverlist.xml,返回其中版本最新的
*
* @param context
* @param xmlFile 指定的本地文件server_list.xml
* @return
* @throws IOException
*/
private
static
ServerList
mergeServerList
(
Context
context
,
File
xmlFile
)
throws
IOException
{
/* 读取apk中assets文件夹下的serverlist.xml文件 */
ServerList
assetList
=
ServerListManager
.
readList
(
context
.
getAssets
().
open
(
ASSET_SERVER_LIST
));
ServerList
fileList
=
xmlFile
.
exists
()
?
ServerListManager
.
readList
(
new
FileInputStream
(
xmlFile
))
:
null
;
if
(
fileList
==
null
)
{
return
assetList
;
}
/* 如果apk下assets中的版本号更大,则返回assets下的server列表 */
if
(
fileList
.
getVercode
()
<
assetList
.
getVercode
())
{
xmlFile
.
delete
();
return
assetList
;
}
return
fileList
;
}
/**
* 从资源文件serverlist.xml(或本地文件server_list.xml)解析服务器列表,并将新添加的服务器信息(name,addr,port)合并到服务器列表中。
*
...
...
@@ -178,26 +204,21 @@ public class ServerUtil {
* @param playerName
*/
public
static
void
AddServer
(
Context
context
,
String
name
,
String
Addr
,
int
port
,
String
playerName
)
{
/* 读取本地文件server_list.xml */
File
xmlFile
=
new
File
(
context
.
getFilesDir
(),
Constants
.
SERVER_FILE
);
//读取文件路径下的server_list.xml
VUiKit
.
defer
().
when
(()
->
{
return
mergeServerList
(
context
,
xmlFile
);
}).
done
((
list
)
->
{
List
<
ServerInfo
>
serverInfos
=
new
ArrayList
<>();
ServerInfo
mServerInfo
=
new
ServerInfo
();
mServerInfo
.
setName
(
name
);
mServerInfo
.
setServerAddr
(
Addr
);
mServerInfo
.
setPort
(
port
);
mServerInfo
.
setPlayerName
(
playerName
);
VUiKit
.
defer
().
when
(()
->
{
/* 读取本地文件server_list.xml和资源文件(assets)下的serverlist.xml,返回其中版本最新的 */
ServerList
assetList
=
ServerListManager
.
readList
(
context
.
getAssets
().
open
(
ASSET_SERVER_LIST
));
//读取serverlist.xml文件
ServerList
fileList
=
xmlFile
.
exists
()
?
ServerListManager
.
readList
(
new
FileInputStream
(
xmlFile
))
:
null
;
if
(
fileList
==
null
)
{
return
assetList
;
}
if
(
fileList
.
getVercode
()
<
assetList
.
getVercode
())
{
xmlFile
.
delete
();
return
assetList
;
}
return
fileList
;
}).
done
((
list
)
->
{
boolean
hasServer
=
false
;
if
(
list
!=
null
)
{
serverInfos
.
clear
();
...
...
@@ -210,7 +231,7 @@ public class ServerUtil {
hasServer
=
false
;
}
}
if
(!
hasServer
&&
!
serverInfos
.
contains
(
mServerInfo
))
{
if
(!
hasServer
&&
!
serverInfos
.
contains
(
mServerInfo
))
{
//todo serverInfos.contains(mServerInfo)好像没必要
serverInfos
.
add
(
mServerInfo
);
}
}
...
...
@@ -234,9 +255,7 @@ public class ServerUtil {
}
public
static
boolean
isPreServer
(
int
port
,
String
addr
)
{
return
(
port
==
Constants
.
PORT_YGO233
&&
addr
.
equals
(
Constants
.
URL_YGO233_1
))
||
(
port
==
Constants
.
PORT_YGO233
&&
addr
.
equals
(
Constants
.
URL_YGO233_2
));
return
(
port
==
Constants
.
PORT_Mycard_Super_Pre_Server
&&
addr
.
equals
(
Constants
.
URL_Mycard_Super_Pre_Server
));
}
}
mobile/src/main/res/values-zh/strings.xml
View file @
dcc89779
...
...
@@ -269,7 +269,8 @@
<string
name=
"Checking_Update"
>
检查更新中,请稍候
</string>
<string
name=
"Found_Update"
>
发现新版本,前往下载?
</string>
<string
name=
"Checking_Update_Failed"
>
检查更新失败
</string>
<string
name=
"Download_precard_failed"
>
先行卡下载失败
</string>
<string
name=
"Download_Precard_Failed"
>
先行卡下载失败
</string>
<string
name=
"Pre_Server_Name"
>
萌卡超先行服
</string>
<string
name=
"Ask_to_Change_Other_Way"
>
主线获取失败,尝试备选线路中...
</string>
<string
name=
"DuelAssistant"
>
决斗助手启用中
</string>
<string
name=
"masterrule"
>
学习大师规则
</string>
...
...
mobile/src/main/res/values/strings.xml
View file @
dcc89779
...
...
@@ -266,7 +266,8 @@
<string
name=
"Checking_Update"
>
Now Checking Update
</string>
<string
name=
"Found_Update"
>
New upGrade is Founded, Download?
</string>
<string
name=
"Checking_Update_Failed"
>
Checking Update Failed
</string>
<string
name=
"Download_precard_failed"
>
Download pre-cards failed
</string>
<string
name=
"Download_Precard_Failed"
>
Download pre-cards failed
</string>
<string
name=
"Pre_Server_Name"
>
Mycard Super-pre Server
</string>
<string
name=
"Ask_to_Change_Other_Way"
>
trying other way...
</string>
<string
name=
"DuelAssistant"
>
DuelAssiatant is On
</string>
<string
name=
"masterrule"
>
Master Rule
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment