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
4eaf430d
Commit
4eaf430d
authored
Sep 22, 2023
by
fallenstardust
Committed by
GitHub
Sep 22, 2023
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #113 from zhuhongbozhuhongbo/master
小修改
parents
2631359a
06d3c355
Changes
21
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
21 changed files
with
178 additions
and
66 deletions
+178
-66
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+44
-8
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+1
-0
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+12
-1
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
+9
-3
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
...ain/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
+5
-1
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
.../java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
+5
-14
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
...java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
.../src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
+1
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
...main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
+12
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+1
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+5
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+3
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+22
-8
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+6
-3
mobile/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
+2
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
+11
-1
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
...e/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
+10
-5
mobile/src/main/java/cn/garymb/ygomobile/utils/StringUtils.java
.../src/main/java/cn/garymb/ygomobile/utils/StringUtils.java
+6
-2
mobile/src/main/java/ocgcore/CardManager.java
mobile/src/main/java/ocgcore/CardManager.java
+5
-1
mobile/src/main/java/ocgcore/DataManager.java
mobile/src/main/java/ocgcore/DataManager.java
+8
-5
mobile/src/main/java/ocgcore/LimitManager.java
mobile/src/main/java/ocgcore/LimitManager.java
+8
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
4eaf430d
...
...
@@ -54,13 +54,15 @@ import java.util.Locale;
import
cn.garymb.ygomobile.core.IrrlichtBridge
;
import
cn.garymb.ygomobile.lite.BuildConfig
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.settings.PreferenceFragmentPlus
;
import
cn.garymb.ygomobile.ui.settings.SharedPreferencesPlus
;
import
cn.garymb.ygomobile.utils.DeckUtil
;
import
cn.garymb.ygomobile.utils.DensityUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
/**
* 静态类
*/
public
class
AppsSettings
{
private
static
final
String
TAG
=
"AppsSettings"
;
private
static
final
String
PREF_VERSION
=
"app_version"
;
...
...
@@ -231,7 +233,7 @@ public class AppsSettings {
return
options
;
}
public
File
getData
B
aseFile
()
{
public
File
getData
b
aseFile
()
{
return
new
File
(
getDataBasePath
(),
Constants
.
DATABASE_NAME
);
}
...
...
@@ -269,9 +271,14 @@ public class AppsSettings {
}
}
}
pathList
.
add
(
getData
B
aseFile
().
getAbsolutePath
());
pathList
.
add
(
getData
b
aseFile
().
getAbsolutePath
());
}
/**
* 返回扩展卡路径,在app-specific external storage下
*
* @return 扩展卡路径
*/
public
File
getExpansionsPath
()
{
return
new
File
(
getResourcePath
(),
CORE_EXPANSIONS
);
}
...
...
@@ -497,10 +504,24 @@ public class AppsSettings {
}
/***
* 游戏根目录
* 返回存储游戏资源的根目录,为app-specific external storage
* 优先返回sharedPreference中存储的设置值,该值为空时返回context.getExternalFilesDir()
*/
public
String
getResourcePath
()
{
String
defPath
;
/* 注意,调用的函数context.getExternalFilesDir()获取的是外部存储目录,只是安卓系统会将一部分内部存储模拟
外部存储,此时返回的/storage/emulated/0其实是指向内部存储的一部分的链接,但在语义上它是external storage。
context.getExternalFilesDir()的部分注释:If a shared storage device is emulated (as determined
by Environment.isExternalStorageEmulated(File)),
it's contents are backed by a private user data partition, which means there is little benefit
to storing data here instead of the private directories returned by getFilesDir(), etc.
可以用Environment.isExternalStorageEmulated()验证,nova10实测返回值为true
To put it simply, the Android storage/emulated/0 folder is the full name of the root
directory that you access all your files from in the file explorer on your Android device.
However, as its name suggets, this folder is emulated storage, which means that it is merely
a link to the actual internal storage of your device's operating system. This is done for security reasons.
*/
defPath
=
new
File
(
String
.
valueOf
(
context
.
getExternalFilesDir
(
Constants
.
PREF_DEF_GAME_DIR
))).
getAbsolutePath
();
return
mSharedPreferences
.
getString
(
Constants
.
PREF_GAME_PATH
,
defPath
);
}
...
...
@@ -718,6 +739,21 @@ public class AppsSettings {
mSharedPreferences
.
putString
(
Constants
.
PREF_LAST_ROOM_LIST
,
array
.
toString
());
}
public
enum
languageEnum
{
//todo 逐步将设置语言的代码都更改为languageEnum
Chinese
(
0
,
"zh"
),
Korean
(
1
,
"ko"
),
English
(
2
,
"en"
);
public
Integer
code
;
public
String
name
;
languageEnum
(
Integer
code
,
String
name
)
{
this
.
code
=
code
;
this
.
name
=
name
;
}
}
public
void
copyCnData
()
throws
IOException
{
//复制数据库
copyCdbFile
(
getDatapath
(
DATABASE_NAME
));
...
...
@@ -730,7 +766,7 @@ public class AppsSettings {
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
//设置语言为0=中文
setDataLanguage
(
0
);
setDataLanguage
(
languageEnum
.
Chinese
.
code
);
}
public
void
copyKorData
()
throws
IOException
{
...
...
@@ -747,8 +783,8 @@ public class AppsSettings {
String
botConfPath
=
new
File
(
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
//设置语言为1=
조선말
setDataLanguage
(
1
);
//设置语言为1=
???
setDataLanguage
(
languageEnum
.
Korean
.
code
);
}
public
void
copyEnData
()
throws
IOException
{
...
...
@@ -768,7 +804,7 @@ public class AppsSettings {
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
//设置语言为2=English
setDataLanguage
(
2
);
setDataLanguage
(
languageEnum
.
English
.
code
);
}
public
void
fixString
(
String
stringPath
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
4eaf430d
This diff is collapsed.
Click to expand it.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
4eaf430d
...
...
@@ -23,12 +23,15 @@ import android.widget.Toast;
import
com.ourygo.lib.duelassistant.util.YGODAUtil
;
import
org.greenrobot.eventbus.EventBus
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.util.Locale
;
import
cn.garymb.ygodata.YGOGameOptions
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.HomeActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
...
...
@@ -51,6 +54,12 @@ public class GameUriManager {
stringManager
=
new
StringManager
();
}
/**
* 根据intent的getData()和getXXXExtra()执行逻辑,
*
* @param intent
* @return false当传入的intent.getAction()不符合可处理的action时,不做处理,返回false
*/
public
boolean
doIntent
(
Intent
intent
)
{
Log
.
i
(
Constants
.
TAG
,
"doIntent"
);
if
(
ACTION_OPEN_DECK
.
equals
(
intent
.
getAction
()))
{
...
...
@@ -225,12 +234,14 @@ public class GameUriManager {
}
else
if
(
isYpk
)
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
startSetting
.
putExtra
(
"flag"
,
4
);
activity
.
startActivity
(
startSetting
);
activity
.
startActivity
(
startSetting
);
//todo ??再次打开MainActivity?
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_go_setting
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
activity
,
R
.
string
.
ypk_installed
,
Toast
.
LENGTH_LONG
).
show
();
loadServerInfoFromZipOrYpk
(
getActivity
(),
file
);
//ypk不与excard机制相干涉
}
}
else
if
(
isYrp
)
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
()))
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/YGOStarter.java
View file @
4eaf430d
...
...
@@ -107,6 +107,12 @@ public class YGOStarter {
quitFullScreen
(
activity
,
activityShowInfo
);
}
/**
* 对添加用于展示的相关信息
*
* @param activity
* @return
*/
public
static
ActivityShowInfo
onCreated
(
Activity
activity
)
{
ActivityShowInfo
activityShowInfo
=
Infos
.
get
(
activity
);
if
(
activityShowInfo
==
null
)
{
...
...
@@ -157,7 +163,6 @@ public class YGOStarter {
private
static
long
lasttime
=
0
;
/**
*
* @param activity
* @param options
* @param args 例如(播放完退出游戏):-r 1111.yrp
...
...
@@ -184,6 +189,7 @@ public class YGOStarter {
Log
.
e
(
TAG
,
"跳转后"
+
System
.
currentTimeMillis
());
}
/* 维护activity的用于展示的相关信息 */
private
static
final
HashMap
<
Activity
,
ActivityShowInfo
>
Infos
=
new
HashMap
<>();
private
static
class
ActivityShowInfo
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/events/ExCardEvent.java
View file @
4eaf430d
package
cn.garymb.ygomobile.bean.events
;
/**
* 用于EventBus发布的时间类型。
*/
public
class
ExCardEvent
{
public
enum
EventType
{
exCardPackageChange
,
exCardPrefChange
exCardPackageChange
,
//扩展卡包变化
exCardPrefChange
//扩展卡设置变化
}
private
EventType
eventType
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExCardListFragment.java
View file @
4eaf430d
package
cn.garymb.ygomobile.ex_card
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_ADVANCE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_FILE_ALT
;
...
...
@@ -30,31 +29,18 @@ import org.greenrobot.eventbus.Subscribe;
import
org.greenrobot.eventbus.ThreadMode
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.util.ArrayList
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.ServerInfo
;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.activities.WebActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.ServerUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.UnzipUtils
;
import
cn.garymb.ygomobile.utils.XmlUtils
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
ocgcore.DataManager
;
...
...
@@ -145,6 +131,10 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_LONG
).
show
();
WebActivity
.
open
(
getActivity
(),
getString
(
R
.
string
.
ex_card_list_title
),
URL_YGO233_ADVANCE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
//状态UNCHECKED仅在app启动后调用哦你Create()之前短暂存在,所以该情况进行处理
//the UNCHECKED state only exists temporarily before the check action, so we need not handle it.
}
}
//TODO eventbus receive event
...
...
@@ -233,6 +223,7 @@ public class ExCardListFragment extends Fragment implements View.OnClickListener
changeDownloadText
();
}
}
private
void
downloadfromWeb
(
String
fileUrl
)
{
textDownload
.
setText
(
"0%"
);
//点击下载后,距离onDownloading触发要等几秒,这一延迟会造成软件响应慢的错觉,因此在下载函数开始就设置文本
File
file
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
"-preRlease.zip"
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ex_card/ExPackageTabAdapter.java
View file @
4eaf430d
...
...
@@ -11,11 +11,11 @@ import com.google.android.material.tabs.TabLayout;
import
cn.garymb.ygomobile.lite.R
;
/**
*
先行卡相关Fragment的Tab的适配器,用来实现页面切换
*
先行卡相关Fragment的Tab的适配器,用来实现页面切换
*/
public
class
ExPackageTabAdapter
extends
FragmentStatePagerAdapter
{
TabLayout
tabLayout
;
/*
仅用于获取strings.xml中的字符串。I
t's used just for getting strings from strings.xml */
/*
仅用于获取strings.xml中的字符串。It's
used just for getting strings from strings.xml */
Context
context
;
public
ExPackageTabAdapter
(
FragmentManager
fm
,
TabLayout
_tabLayout
,
Context
context
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/loader/CardLoader.java
View file @
4eaf430d
...
...
@@ -28,8 +28,7 @@ import ocgcore.enums.LimitType;
/**
* 包括LimitManager、CardManager、LimitList
* LimitList负责判断禁止卡等
*
*
* field包括LimitManager、CardManager
*/
public
class
CardLoader
implements
ICardSearcher
{
private
final
LimitManager
mLimitManager
;
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/CardFavorites.java
View file @
4eaf430d
...
...
@@ -14,6 +14,9 @@ import cn.garymb.ygomobile.loader.ICardSearcher;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
ocgcore.data.Card
;
/**
* 静态类,
*/
public
class
CardFavorites
{
private
final
List
<
Integer
>
mList
=
new
ArrayList
<>();
private
static
final
String
TAG
=
"CardFavorites"
;
...
...
@@ -55,6 +58,12 @@ public class CardFavorites {
return
mList
;
}
/**
* 从cardLoader查询收藏的卡片
*
* @param cardLoader
* @return 排序后的列表
*/
public
List
<
Card
>
getCards
(
ICardSearcher
cardLoader
)
{
SparseArray
<
Card
>
id
=
cardLoader
.
readCards
(
mList
,
false
);
List
<
Card
>
list
=
new
ArrayList
<>();
...
...
@@ -89,6 +98,9 @@ public class CardFavorites {
Log
.
d
(
TAG
,
"load favorites success:"
+
mList
.
size
());
}
/**
* 将卡片收藏保存到sharedStorage中
*/
public
void
save
()
{
List
<
String
>
ret
=
new
ArrayList
<>();
if
(!
mList
.
isEmpty
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
4eaf430d
...
...
@@ -26,13 +26,8 @@ import com.tencent.smtt.export.external.TbsCoreSettings;
import
com.tencent.smtt.sdk.QbSdk
;
import
java.io.BufferedReader
;
import
java.io.ByteArrayOutputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.OutputStreamWriter
;
import
java.io.StringReader
;
import
java.nio.charset.StandardCharsets
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
...
...
@@ -141,7 +136,7 @@ public abstract class HomeActivity extends BaseActivity implements BottomNavigat
//showNewbieGuide("homePage");
initBottomNavigationBar
();
onNewIntent
(
getIntent
());
ServerUtil
.
initExCardState
();
//检查扩展卡版本
ServerUtil
.
initExCardState
();
//检查扩展卡版本
todo 移动到LogoActivity中
}
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
4eaf430d
...
...
@@ -289,6 +289,10 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
ERROR
)
{
Toast
.
makeText
(
getActivity
(),
R
.
string
.
ex_card_check_toast_message_iii
,
Toast
.
LENGTH_SHORT
).
show
();
ll_new_notice
.
setVisibility
(
View
.
GONE
);
}
else
if
(
ServerUtil
.
exCardState
==
ServerUtil
.
ExCardState
.
UNCHECKED
)
{
//do nothing
//由于UNCHECKED状态仅在app刚启动时短暂存在,因此不需要对其进行处理
//the UNCHECKED state only exists temporarily before the check action, so we need not handle it.
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
4eaf430d
...
...
@@ -69,6 +69,9 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
}
/**
* 资源复制
*/
private
void
checkRes
()
{
checkResourceDownload
((
error
,
isNew
)
->
{
//加载收藏夹
...
...
@@ -210,7 +213,6 @@ public class MainActivity extends HomeActivity implements BottomNavigationBar.On
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
Intent
data
)
{
if
(
requestCode
==
Constants
.
REQUEST_SETTINGS_CODE
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
4eaf430d
...
...
@@ -30,11 +30,13 @@ import java.io.IOException;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings.languageEnum
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
libwindbot.windbot.WindBot
;
import
ocgcore.CardManager
;
...
...
@@ -151,12 +153,15 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
mContext
.
unregisterReceiver
(
mReceiver
);
}
/**
* 查询sharedPreference中的版本号和package的版本号,比较后得出是否需要更新,将结果存入isNewVersion。
*/
@Override
protected
void
onPreExecute
()
{
super
.
onPreExecute
();
dialog
=
DialogPlus
.
show
(
mContext
,
null
,
mContext
.
getString
(
R
.
string
.
check_res
));
int
vercode
=
SystemUtils
.
getVersion
(
mContext
);
if
(
mSettings
.
getAppVersion
()
<
vercode
)
{
if
(
mSettings
.
getAppVersion
()
<
vercode
)
{
//刚安装app时,mSettings.getAppVersion()返回值为0
mSettings
.
setAppVersion
(
vercode
);
isNewVersion
=
true
;
}
else
{
...
...
@@ -186,6 +191,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
});
}
/**
* 清除下载缓存
* 如果是新安装ygomobile,则将资源文件从assets拷贝到游戏目录中。游戏目录为app-specific external storage
*
* @param params The parameters of the task.
* @return
*/
@Override
protected
Integer
doInBackground
(
Void
...
params
)
{
Log
.
d
(
TAG
,
"check start"
);
...
...
@@ -214,12 +226,13 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
checkDirs
();
if
(
mSettings
.
isUseExtraCards
())
{
//自定义数据库无效,则用默认的
if
(!
CardManager
.
checkDataBase
(
mSettings
.
getData
B
aseFile
()))
{
if
(!
CardManager
.
checkDataBase
(
mSettings
.
getData
b
aseFile
()))
{
mSettings
.
setUseExtraCards
(
false
);
}
}
//如果是新版本
if
(
needsUpdate
)
{
LogUtil
.
i
(
TAG
,
"needsUpdate"
);
//复制卡组
File
deckFiles
=
new
File
(
mSettings
.
getDeckDir
());
if
(
deckFiles
.
list
().
length
==
0
)
{
...
...
@@ -277,17 +290,18 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
String
language
=
mContext
.
getResources
().
getConfiguration
().
locale
.
getLanguage
();
if
(!
language
.
isEmpty
())
{
if
(
mSettings
.
getDataLanguage
()
==
-
1
)
{
if
(
language
.
equals
(
"zh"
))
{
if
(
language
.
equals
(
languageEnum
.
Chinese
.
name
))
{
copyCnData
(
true
);
}
else
if
(
language
.
equals
(
"ko"
))
{
}
else
if
(
language
.
equals
(
languageEnum
.
Korean
.
name
))
{
copyKorData
(
true
);
}
else
{
copyEnData
(
true
);
}
}
else
{
if
(
mSettings
.
getDataLanguage
()
==
0
)
copyCnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
1
)
copyKorData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
2
)
copyEnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
Chinese
.
code
)
copyCnData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
Korean
.
code
)
copyKorData
(
true
);
if
(
mSettings
.
getDataLanguage
()
==
languageEnum
.
English
.
code
)
copyEnData
(
true
);
}
}
han
.
sendEmptyMessage
(
0
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
4eaf430d
...
...
@@ -342,10 +342,12 @@ public class SettingFragment extends PreferenceFragmentPlus {
FileUtils
.
delFile
(
mSettings
.
getExpansionsPath
().
getAbsolutePath
()
+
"/"
+
name
);
DataManager
.
get
().
load
(
true
);
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_LONG
).
show
();
if
(
name
.
equals
(
Constants
.
officialExCardPackageName
))
{
//如果删除的是官方先行卡ypk,则更新其相关UI状态
SharedPreferenceUtil
.
setExpansionDataVer
(
null
);
//删除先行卡后,更新版本状态
ServerUtil
.
exCardState
=
ServerUtil
.
ExCardState
.
NEED_UPDATE
;
EventBus
.
getDefault
().
postSticky
(
new
ExCardEvent
(
ExCardEvent
.
EventType
.
exCardPackageChange
));
//删除后,通知UI做更新
}
}
return
true
;
});
/*
...
...
@@ -672,6 +674,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
return
false
;
}
}
private
void
arrangeCodeList
(
String
code
)
{
BufferedReader
br
=
new
BufferedReader
(
new
StringReader
(
code
));
try
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/BitmapUtil.java
View file @
4eaf430d
...
...
@@ -226,7 +226,7 @@ public class BitmapUtil {
return
bitmap
;
}
public
static
Paint
getPaint
(
int
saturation
){
public
static
Paint
getPaint
(
int
saturation
)
{
Paint
mPaint
=
new
Paint
();
ColorMatrix
cm
=
new
ColorMatrix
();
cm
.
setSaturation
(
saturation
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
View file @
4eaf430d
...
...
@@ -103,6 +103,9 @@ public class IOUtils {
return
new
File
(
path
).
getName
();
}
/**
* 将文件从工程的assets文件夹拷贝到目录中
*/
public
static
int
copyFilesFromAssets
(
Context
context
,
String
assets
,
String
toPath
,
boolean
update
)
throws
IOException
{
AssetManager
am
=
context
.
getAssets
();
String
[]
files
=
am
.
list
(
assets
);
...
...
@@ -162,8 +165,15 @@ public class IOUtils {
createFolder
(
file
.
getParentFile
());
}
/**
* 根据file创建目录,如果file指向的目录已存在,则直接返回true。
* 创建失败时返回false。
* 创建成功时返回true
* @param file
* @return
*/
public
static
boolean
createFolder
(
@Nullable
File
file
)
{
if
(
file
==
null
)
{
if
(
file
==
null
)
{
return
false
;
}
if
(!
file
.
exists
())
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/ServerUtil.java
View file @
4eaf430d
...
...
@@ -37,8 +37,14 @@ import okhttp3.Response;
public
class
ServerUtil
{
private
static
final
String
TAG
=
ServerUtil
.
class
.
getSimpleName
();
public
enum
ExCardState
{
/* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */
UNCHECKED
,
UPDATED
,
NEED_UPDATE
,
ERROR
}
/* 存储了当前先行卡是否需要更新的状态,UI逻辑直接读取该变量就能获知是否已安装先行卡 */
public
volatile
static
ExCardState
exCardState
=
ExCardState
.
ERROR
;
//TODO 可能有并发问题
public
volatile
static
ExCardState
exCardState
=
ExCardState
.
UNCHECKED
;
//TODO 可能有并发问题
public
volatile
static
String
serverExCardVersion
=
""
;
private
volatile
static
int
failCounter
=
0
;
...
...
@@ -122,9 +128,12 @@ public class ServerUtil {
}
if
(
serverName
!=
null
&&
(
isHost
(
serverHost
)
||
isValidIP
(
serverHost
))
&&
isNumeric
(
serverPort
))
{
AddServer
(
context
,
serverName
,
serverHost
,
Integer
.
valueOf
(
serverPort
),
"Knight of Hanoi"
);
}
else
{
YGOUtil
.
showTextToast
(
"can't parse ex-server properly"
);
}
LogUtil
.
w
(
"看看"
,
serverName
+
isHost
(
serverHost
)
+
serverHost
+
isNumeric
(
serverPort
)
+
serverPort
);
zipFile
.
close
();
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -202,8 +211,4 @@ public class ServerUtil {
}
public
enum
ExCardState
{
/* 已安装最新版扩展卡,扩展卡不是最新版本,无法查询到服务器版本 */
UPDATED
,
NEED_UPDATE
,
ERROR
}
}
mobile/src/main/java/cn/garymb/ygomobile/utils/StringUtils.java
View file @
4eaf430d
package
cn.garymb.ygomobile.utils
;
import
org.apache.commons.lang3.math.Number
Utils
;
import
android.text.Text
Utils
;
import
java.util.regex.Matcher
;
import
java.util.regex.Pattern
;
...
...
@@ -65,6 +65,10 @@ public class StringUtils {
* 检查字符串是否是域名
*/
public
static
boolean
isHost
(
String
hostStr
)
{
if
(
TextUtils
.
isEmpty
(
hostStr
))
{
return
false
;
}
boolean
isurl
=
false
;
String
regex
=
"(((https|http)?://)?([a-z0-9]+[.])|(www.))"
+
"\\w+[.|\\/]([a-z0-9]{0,})?[[.]([a-z0-9]{0,})]+((/[\\S&&[^,;\u4E00-\u9FA5]]+)+)?([.][a-z0-9]{0,}+|/?)"
;
//设置正则表达式
...
...
@@ -82,7 +86,7 @@ public class StringUtils {
* 检查字符串是否是IPv4
*/
public
static
boolean
isValidIP
(
String
s
)
{
if
(
s
==
null
||
s
.
length
()
==
0
)
{
if
(
TextUtils
.
isEmpty
(
s
)
)
{
return
false
;
}
String
[]
arr
=
s
.
split
(
"\\."
);
...
...
mobile/src/main/java/ocgcore/CardManager.java
View file @
4eaf430d
...
...
@@ -134,10 +134,14 @@ public class CardManager {
return
cardDataHashMap
;
}
/**
* 清空cardDataHashMap,之后从cdb文件读取卡牌,到cardDataHashMap
* 如果开启了先行卡,
*/
@WorkerThread
public
void
loadCards
()
{
cardDataHashMap
.
clear
();
int
count
=
readAllCards
(
AppsSettings
.
get
().
getData
B
aseFile
(),
cardDataHashMap
);
int
count
=
readAllCards
(
AppsSettings
.
get
().
getData
b
aseFile
(),
cardDataHashMap
);
Log
.
i
(
TAG
,
"load defualt cdb:"
+
count
);
if
(!
TextUtils
.
isEmpty
(
exDbPath
))
{
if
(
AppsSettings
.
get
().
isReadExpansions
())
{
...
...
mobile/src/main/java/ocgcore/DataManager.java
View file @
4eaf430d
package
ocgcore
;
import
org.greenrobot.eventbus.EventBus
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.
ex_card.ExCardListAdapter
;
import
cn.garymb.ygomobile.
bean.events.ExCardEvent
;
import
cn.garymb.ygomobile.loader.CardLoader
;
/**
* 单例模式,使用get()方式自动获取单例
* 单例模式,使用get()方式自动获取单例
* 其field包括StringManager、LimitManager、CardManager
*/
public
class
DataManager
{
private
static
DataManager
sLoader
=
null
;
private
static
final
String
TAG
=
String
.
valueOf
(
DataManager
.
class
);
public
static
DataManager
get
()
{
if
(
sLoader
!=
null
)
{
return
sLoader
;
...
...
@@ -50,8 +54,7 @@ public class DataManager {
private
boolean
mInit
;
public
void
load
(
boolean
force
)
{
//Log.i("webCrawler", "DataManager load data");
//LogUtil.i("webCrawler", "DataManager load data");
boolean
needLoad
=
false
;
synchronized
(
this
)
{
if
(!
mInit
||
force
)
{
...
...
@@ -59,7 +62,7 @@ public class DataManager {
}
mInit
=
true
;
}
if
(
needLoad
)
{
if
(
needLoad
)
{
mStringManager
.
load
();
mLimitManager
.
load
();
mCardManager
.
loadCards
();
...
...
mobile/src/main/java/ocgcore/LimitManager.java
View file @
4eaf430d
...
...
@@ -22,7 +22,9 @@ import cn.garymb.ygomobile.utils.IOUtils;
import
ocgcore.data.LimitList
;
public
class
LimitManager
implements
Closeable
{
/* key为时间,如“2023.7” ,value为禁止卡、限制卡、准限制卡的列表 */
private
final
Map
<
String
,
LimitList
>
mLimitLists
=
new
HashMap
<>();
/* 只存储key的列表,其元素形如“2023.7” */
private
final
List
<
String
>
mLimitNames
=
new
ArrayList
<>();
private
int
mCount
;
...
...
@@ -74,6 +76,12 @@ public class LimitManager implements Closeable {
return
rs1
&&
rs2
;
}
/**
* 解析限制卡配置文件lflist.conf的内容
*
* @param file
* @return
*/
public
boolean
loadFile
(
File
file
)
{
if
(
file
.
isDirectory
()
||
!
file
.
exists
())
{
return
false
;
...
...
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