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
7253dcd1
Commit
7253dcd1
authored
Jan 07, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
重置资源时也按照设定语言进行复制资料
parent
b9294916
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
65 additions
and
61 deletions
+65
-61
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+9
-11
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
+2
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+10
-11
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
...java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
+40
-33
mobile/src/main/java/cn/garymb/ygomobile/utils/SharedPreferenceUtil.java
.../java/cn/garymb/ygomobile/utils/SharedPreferenceUtil.java
+4
-2
No files found.
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
7253dcd1
...
@@ -6,10 +6,8 @@ import static cn.garymb.ygomobile.Constants.BOT_CONF;
...
@@ -6,10 +6,8 @@ import static cn.garymb.ygomobile.Constants.BOT_CONF;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_BOT_CONF_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_BOT_CONF_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_DECK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_DECK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_EXPANSIONS
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_LIMIT_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_PACK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_PACK_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_REPLAY_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_REPLAY_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SINGLE_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_STRING_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_STRING_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DATABASE_NAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DATABASE_NAME
;
...
@@ -238,7 +236,7 @@ public class AppsSettings {
...
@@ -238,7 +236,7 @@ public class AppsSettings {
public
File
[]
getExpansionFiles
()
{
public
File
[]
getExpansionFiles
()
{
return
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
Constants
.
CORE_EXPANSIONS
)
return
new
File
(
getResourcePath
(),
Constants
.
CORE_EXPANSIONS
)
.
listFiles
((
file
)
->
{
.
listFiles
((
file
)
->
{
if
(!
file
.
isFile
())
{
if
(!
file
.
isFile
())
{
return
false
;
return
false
;
...
@@ -726,8 +724,8 @@ public class AppsSettings {
...
@@ -726,8 +724,8 @@ public class AppsSettings {
IOUtils
.
copyFilesFromAssets
(
context
,
getDatapath
(
"conf"
)
+
"/"
+
CORE_STRING_PATH
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
getDatapath
(
"conf"
)
+
"/"
+
CORE_STRING_PATH
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
getDatapath
(
"conf"
)
+
"/"
+
BOT_CONF
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
getDatapath
(
"conf"
)
+
"/"
+
BOT_CONF
,
getResourcePath
(),
true
);
//替换换行符
//替换换行符
String
stringConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
stringConfPath
=
new
File
(
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
fixString
(
stringConfPath
);
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
fixString
(
botConfPath
);
//设置语言为0=中文
//设置语言为0=中文
...
@@ -744,8 +742,8 @@ public class AppsSettings {
...
@@ -744,8 +742,8 @@ public class AppsSettings {
IOUtils
.
copyFilesFromAssets
(
context
,
korStringConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
korStringConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
korBotConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
korBotConf
,
getResourcePath
(),
true
);
//替换换行符
//替换换行符
String
stringConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
stringConfPath
=
new
File
(
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
fixString
(
stringConfPath
);
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
fixString
(
botConfPath
);
//设置语言为1=조선말
//设置语言为1=조선말
...
@@ -764,20 +762,20 @@ public class AppsSettings {
...
@@ -764,20 +762,20 @@ public class AppsSettings {
IOUtils
.
copyFilesFromAssets
(
context
,
enStringConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
enStringConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
enBotConf
,
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
enBotConf
,
getResourcePath
(),
true
);
//替换换行符
//替换换行符
String
stringConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
stringConfPath
=
new
File
(
getResourcePath
(),
CORE_STRING_PATH
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
AppsSettings
.
get
().
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
String
botConfPath
=
new
File
(
getResourcePath
(),
BOT_CONF
).
getAbsolutePath
();
fixString
(
stringConfPath
);
fixString
(
stringConfPath
);
fixString
(
botConfPath
);
fixString
(
botConfPath
);
//设置语言为2=English
//设置语言为2=English
setDataLanguage
(
2
);
setDataLanguage
(
2
);
}
}
p
rivate
void
fixString
(
String
stringPath
)
{
p
ublic
void
fixString
(
String
stringPath
)
{
List
<
String
>
lines
=
FileUtils
.
readLines
(
stringPath
,
Constants
.
DEF_ENCODING
);
List
<
String
>
lines
=
FileUtils
.
readLines
(
stringPath
,
Constants
.
DEF_ENCODING
);
FileUtils
.
writeLines
(
stringPath
,
lines
,
Constants
.
DEF_ENCODING
,
"\n"
);
FileUtils
.
writeLines
(
stringPath
,
lines
,
Constants
.
DEF_ENCODING
,
"\n"
);
}
}
p
rivate
void
copyCdbFile
(
String
cdbPath
)
throws
IOException
{
p
ublic
void
copyCdbFile
(
String
cdbPath
)
throws
IOException
{
File
dbFile
=
new
File
(
getDataBasePath
(),
DATABASE_NAME
);
File
dbFile
=
new
File
(
getDataBasePath
(),
DATABASE_NAME
);
if
(
dbFile
.
exists
())
dbFile
.
delete
();
//如果数据库存在先删除
if
(
dbFile
.
exists
())
dbFile
.
delete
();
//如果数据库存在先删除
IOUtils
.
copyFilesFromAssets
(
context
,
cdbPath
,
getDataBasePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
context
,
cdbPath
,
getDataBasePath
(),
true
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/Constants.java
View file @
7253dcd1
This diff is collapsed.
Click to expand it.
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
7253dcd1
...
@@ -10,7 +10,6 @@ import static cn.garymb.ygomobile.Constants.CORE_SINGLE_PATH;
...
@@ -10,7 +10,6 @@ import static cn.garymb.ygomobile.Constants.CORE_SINGLE_PATH;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_STRING_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_STRING_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
CORE_SYSTEM_PATH
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DATABASE_NAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
DATABASE_NAME
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
WINDBOT_PATH
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
...
@@ -194,7 +193,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -194,7 +193,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
Log
.
d
(
TAG
,
"check start"
);
Log
.
d
(
TAG
,
"check start"
);
boolean
needsUpdate
=
isNewVersion
;
boolean
needsUpdate
=
isNewVersion
;
//清空下载缓存
//清空下载缓存
File
imgDir
=
new
File
(
AppsSettings
.
get
()
.
getCardImagePath
());
File
imgDir
=
new
File
(
mSettings
.
getCardImagePath
());
File
[]
files
=
imgDir
.
listFiles
(
new
FilenameFilter
()
{
File
[]
files
=
imgDir
.
listFiles
(
new
FilenameFilter
()
{
@Override
@Override
public
boolean
accept
(
File
dir
,
String
name
)
{
public
boolean
accept
(
File
dir
,
String
name
)
{
...
@@ -215,10 +214,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -215,10 +214,10 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils
.
createNoMedia
(
resPath
);
IOUtils
.
createNoMedia
(
resPath
);
//检查文件夹
//检查文件夹
checkDirs
();
checkDirs
();
if
(
AppsSettings
.
get
()
.
isUseExtraCards
())
{
if
(
mSettings
.
isUseExtraCards
())
{
//自定义数据库无效,则用默认的
//自定义数据库无效,则用默认的
if
(!
CardManager
.
checkDataBase
(
AppsSettings
.
get
()
.
getDataBaseFile
()))
{
if
(!
CardManager
.
checkDataBase
(
mSettings
.
getDataBaseFile
()))
{
AppsSettings
.
get
()
.
setUseExtraCards
(
false
);
mSettings
.
setUseExtraCards
(
false
);
}
}
}
}
//如果是新版本
//如果是新版本
...
@@ -316,7 +315,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -316,7 +315,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
copyCoreConfig
(
getDatapath
(
"conf"
)
+
"/"
+
CORE_STRING_PATH
,
copyCoreConfig
(
getDatapath
(
"conf"
)
+
"/"
+
CORE_STRING_PATH
,
getDatapath
(
"conf"
)
+
"/"
+
BOT_CONF
,
getDatapath
(
"conf"
)
+
"/"
+
BOT_CONF
,
mSettings
.
getResourcePath
(),
needsUpdate
);
mSettings
.
getResourcePath
(),
needsUpdate
);
AppsSettings
.
get
()
.
setDataLanguage
(
0
);
mSettings
.
setDataLanguage
(
0
);
return
ERROR_NONE
;
return
ERROR_NONE
;
}
}
...
@@ -332,7 +331,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -332,7 +331,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils
.
copyFilesFromAssets
(
mContext
,
enSingle
,
mSettings
.
getSingleDir
(),
needsUpdate
);
IOUtils
.
copyFilesFromAssets
(
mContext
,
enSingle
,
mSettings
.
getSingleDir
(),
needsUpdate
);
//复制游戏配置文件
//复制游戏配置文件
copyCoreConfig
(
enStringConf
,
enBotConf
,
mSettings
.
getResourcePath
(),
needsUpdate
);
copyCoreConfig
(
enStringConf
,
enBotConf
,
mSettings
.
getResourcePath
(),
needsUpdate
);
AppsSettings
.
get
()
.
setDataLanguage
(
2
);
mSettings
.
setDataLanguage
(
2
);
return
ERROR_NONE
;
return
ERROR_NONE
;
}
}
...
@@ -348,7 +347,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -348,7 +347,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
IOUtils
.
copyFilesFromAssets
(
mContext
,
korSingle
,
mSettings
.
getSingleDir
(),
needsUpdate
);
IOUtils
.
copyFilesFromAssets
(
mContext
,
korSingle
,
mSettings
.
getSingleDir
(),
needsUpdate
);
//复制游戏配置文件
//复制游戏配置文件
copyCoreConfig
(
korStringConf
,
korBotConf
,
mSettings
.
getResourcePath
(),
needsUpdate
);
copyCoreConfig
(
korStringConf
,
korBotConf
,
mSettings
.
getResourcePath
(),
needsUpdate
);
//AppsSettings.get()
.setDataLanguage(1);
mSettings
.
setDataLanguage
(
1
);
return
ERROR_NONE
;
return
ERROR_NONE
;
}
}
...
@@ -426,9 +425,9 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
...
@@ -426,9 +425,9 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
}
}
private
int
copyCoreConfig
(
String
assetStringPath
,
String
assetBotPath
,
String
toPath
,
boolean
needsUpdate
)
throws
IOException
{
private
int
copyCoreConfig
(
String
assetStringPath
,
String
assetBotPath
,
String
toPath
,
boolean
needsUpdate
)
throws
IOException
{
File
systemfile
=
new
File
(
AppsSettings
.
get
()
.
getResourcePath
(),
CORE_SYSTEM_PATH
);
File
systemfile
=
new
File
(
mSettings
.
getResourcePath
(),
CORE_SYSTEM_PATH
);
File
stringfile
=
new
File
(
AppsSettings
.
get
()
.
getResourcePath
(),
CORE_STRING_PATH
);
File
stringfile
=
new
File
(
mSettings
.
getResourcePath
(),
CORE_STRING_PATH
);
File
botfile
=
new
File
(
AppsSettings
.
get
()
.
getResourcePath
(),
BOT_CONF
);
File
botfile
=
new
File
(
mSettings
.
getResourcePath
(),
BOT_CONF
);
if
(!
systemfile
.
exists
())
{
if
(!
systemfile
.
exists
())
{
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
"conf"
)
+
"/"
+
CORE_SYSTEM_PATH
,
toPath
,
false
);
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
"conf"
)
+
"/"
+
CORE_SYSTEM_PATH
,
toPath
,
false
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/settings/SettingFragment.java
View file @
7253dcd1
...
@@ -35,12 +35,10 @@ import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
...
@@ -35,12 +35,10 @@ import static cn.garymb.ygomobile.Constants.SETTINGS_AVATAR;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_CARD_BG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_CARD_BG
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_COVER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
SETTINGS_COVER
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_HOME_VERSION
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
URL_YGO233_DOWNLOAD_LINK
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
ResCheckTask
.
getDatapath
;
import
static
cn
.
garymb
.
ygomobile
.
ui
.
home
.
ResCheckTask
.
getDatapath
;
import
android.annotation.SuppressLint
;
import
android.annotation.SuppressLint
;
import
android.app.Dialog
;
import
android.app.Dialog
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.content.SharedPreferences
;
import
android.content.SharedPreferences
;
import
android.graphics.Color
;
import
android.graphics.Color
;
...
@@ -65,8 +63,6 @@ import android.widget.Toast;
...
@@ -65,8 +63,6 @@ import android.widget.Toast;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.load.engine.DiskCacheStrategy
;
import
com.bumptech.glide.signature.MediaStoreSignature
;
import
com.bumptech.glide.signature.MediaStoreSignature
;
import
org.apache.commons.lang3.StringUtils
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -80,16 +76,13 @@ import cn.garymb.ygomobile.lite.BuildConfig;
...
@@ -80,16 +76,13 @@ import cn.garymb.ygomobile.lite.BuildConfig;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.adapters.SimpleListAdapter
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.ResCheckTask
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.OkhttpUtil
;
import
cn.garymb.ygomobile.utils.SharedPreferenceUtil
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
kotlin.collections.IndexedValue
;
import
ocgcore.DataManager
;
import
ocgcore.DataManager
;
import
okhttp3.Call
;
import
okhttp3.Call
;
import
okhttp3.Callback
;
import
okhttp3.Callback
;
...
@@ -141,7 +134,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -141,7 +134,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
@Override
@Override
protected
SharedPreferences
getSharedPreferences
()
{
protected
SharedPreferences
getSharedPreferences
()
{
return
AppsSettings
.
get
()
.
getSharedPreferences
();
return
mSettings
.
getSharedPreferences
();
}
}
@Override
@Override
...
@@ -191,10 +184,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -191,10 +184,10 @@ public class SettingFragment extends PreferenceFragmentPlus {
super
.
onPreferenceChange
(
preference
,
value
);
super
.
onPreferenceChange
(
preference
,
value
);
if
(!
isInit
)
{
if
(!
isInit
)
{
/*if (PREF_GAME_VERSION.equals(preference.getKey())) {
/*if (PREF_GAME_VERSION.equals(preference.getKey())) {
int v =
AppsSettings.get()
.getVersionValue(value.toString());
int v =
mSettings
.getVersionValue(value.toString());
if (v > 0 && v <=
AppsSettings.get()
.getVersionValue("0xF99F")) {
if (v > 0 && v <=
mSettings
.getVersionValue("0xF99F")) {
mSettings.setGameVersion(v);
mSettings.setGameVersion(v);
super.onPreferenceChange(preference,
AppsSettings.get()
.getVersionString(v));
super.onPreferenceChange(preference,
mSettings
.getVersionString(v));
return true;
return true;
} else {
} else {
if (BuildConfig.DEBUG) {
if (BuildConfig.DEBUG) {
...
@@ -308,7 +301,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -308,7 +301,7 @@ public class SettingFragment extends PreferenceFragmentPlus {
});
});
}
}
if
(
PREF_DEL_EX
.
equals
(
key
))
{
if
(
PREF_DEL_EX
.
equals
(
key
))
{
File
[]
ypks
=
new
File
(
AppsSettings
.
get
()
.
getExpansionsPath
().
getAbsolutePath
()).
listFiles
();
File
[]
ypks
=
new
File
(
mSettings
.
getExpansionsPath
().
getAbsolutePath
()).
listFiles
();
List
<
String
>
list
=
new
ArrayList
<>();
List
<
String
>
list
=
new
ArrayList
<>();
for
(
int
i
=
0
;
i
<
ypks
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
ypks
.
length
;
i
++)
{
list
.
add
(
ypks
[
i
].
getName
());
list
.
add
(
ypks
[
i
].
getName
());
...
@@ -585,46 +578,60 @@ public class SettingFragment extends PreferenceFragmentPlus {
...
@@ -585,46 +578,60 @@ public class SettingFragment extends PreferenceFragmentPlus {
}
}
public
void
updateImages
()
{
public
void
updateImages
()
{
Log
.
e
(
"MainActivity"
,
"重置资源"
);
DialogPlus
dialog
=
DialogPlus
.
show
(
getContext
(),
null
,
getString
(
R
.
string
.
message
));
DialogPlus
dialog
=
DialogPlus
.
show
(
getContext
(),
null
,
getString
(
R
.
string
.
message
));
dialog
.
show
();
dialog
.
show
();
VUiKit
.
defer
().
when
(()
->
{
VUiKit
.
defer
().
when
(()
->
{
Log
.
e
(
"MainActivity"
,
"开始复制"
);
try
{
try
{
IOUtils
.
createNoMedia
(
AppsSettings
.
get
().
getResourcePath
());
//.nomedia
IOUtils
.
createNoMedia
(
mSettings
.
getResourcePath
());
FileUtils
.
delFile
(
AppsSettings
.
get
().
getResourcePath
()
+
"/"
+
Constants
.
CORE_SCRIPT_PATH
);
//删除script文件夹,因为已经直接从scripts.zip读取script
FileUtils
.
delFile
(
mSettings
.
getResourcePath
()
+
"/"
+
Constants
.
CORE_SCRIPT_PATH
);
//复制卡图包
if
(
IOUtils
.
hasAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
if
(
IOUtils
.
hasAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
mSettings
.
getResourcePath
(),
true
);
AppsSettings
.
get
().
getResourcePath
(),
true
);
}
}
//复制脚本包
if
(
IOUtils
.
hasAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
)))
{
if
(
IOUtils
.
hasAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
)))
{
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
),
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
),
mSettings
.
getResourcePath
(),
true
);
AppsSettings
.
get
().
getResourcePath
(),
true
);
}
}
//复制textures下的贴图文件
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
mSettings
.
getCoreSkinPath
(),
false
);
AppsSettings
.
get
().
getCoreSkinPath
(),
false
);
//先删除已存在的字体再复制字体
String
fonts
=
AppsSettings
.
get
()
.
getResourcePath
()
+
"/"
+
Constants
.
FONT_DIRECTORY
;
String
fonts
=
mSettings
.
getResourcePath
()
+
"/"
+
Constants
.
FONT_DIRECTORY
;
if
(
new
File
(
fonts
).
list
()
!=
null
)
if
(
new
File
(
fonts
).
list
()
!=
null
)
FileUtils
.
delFile
(
fonts
);
FileUtils
.
delFile
(
fonts
);
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
FONT_DIRECTORY
),
IOUtils
.
copyFilesFromAssets
(
getContext
(),
getDatapath
(
Constants
.
FONT_DIRECTORY
),
mSettings
.
getFontDirPath
(),
true
);
AppsSettings
.
get
().
getFontDirPath
(),
true
);
//根据系统语言复制特定资料文件
String
language
=
getContext
().
getResources
().
getConfiguration
().
locale
.
getLanguage
();
if
(!
language
.
isEmpty
())
{
if
(
mSettings
.
getDataLanguage
()
==
-
1
)
{
if
(
language
.
equals
(
"zh"
))
{
mSettings
.
copyCnData
();
}
else
if
(
language
.
equals
(
"ko"
))
{
mSettings
.
copyKorData
();
}
else
{
mSettings
.
copyEnData
();
}
}
else
{
if
(
mSettings
.
getDataLanguage
()
==
0
)
mSettings
.
copyCnData
();
if
(
mSettings
.
getDataLanguage
()
==
1
)
mSettings
.
copyKorData
();
if
(
mSettings
.
getDataLanguage
()
==
2
)
mSettings
.
copyEnData
();
}
}
/*
/*
IOUtils.copyFilesFromAssets(this, getDatapath(Constants.CORE_SOUND_PATH),
IOUtils.copyFilesFromAssets(this, getDatapath(Constants.CORE_SOUND_PATH),
AppsSettings.get()
.getSoundPath(), false);*/
mSettings
.getSoundPath(), false);*/
//复制原目录文件
//复制原目录文件
if
(
new
File
(
ORI_DECK
).
list
()
!=
null
)
if
(
new
File
(
ORI_DECK
).
list
()
!=
null
)
FileUtils
.
copyDir
(
ORI_DECK
,
AppsSettings
.
get
()
.
getDeckDir
(),
false
);
FileUtils
.
copyDir
(
ORI_DECK
,
mSettings
.
getDeckDir
(),
false
);
if
(
new
File
(
ORI_REPLAY
).
list
()
!=
null
)
if
(
new
File
(
ORI_REPLAY
).
list
()
!=
null
)
FileUtils
.
copyDir
(
ORI_REPLAY
,
AppsSettings
.
get
()
.
getResourcePath
()
+
"/"
+
Constants
.
CORE_REPLAY_PATH
,
false
);
FileUtils
.
copyDir
(
ORI_REPLAY
,
mSettings
.
getResourcePath
()
+
"/"
+
Constants
.
CORE_REPLAY_PATH
,
false
);
if
(
new
File
(
ORI_PICS
).
list
()
!=
null
)
if
(
new
File
(
ORI_PICS
).
list
()
!=
null
)
FileUtils
.
copyDir
(
ORI_PICS
,
AppsSettings
.
get
()
.
getCardImagePath
(),
false
);
FileUtils
.
copyDir
(
ORI_PICS
,
mSettings
.
getCardImagePath
(),
false
);
}
catch
(
IOException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
Log
.
e
(
"
MainActivity
"
,
"错误"
+
e
);
Log
.
e
(
"
SettingFragment
"
,
"错误"
+
e
);
}
}
}).
done
((
rs
)
->
{
}).
done
((
rs
)
->
{
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
Toast
.
makeText
(
getContext
(),
R
.
string
.
done
,
Toast
.
LENGTH_SHORT
).
show
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/SharedPreferenceUtil.java
View file @
7253dcd1
...
@@ -50,9 +50,11 @@ public class SharedPreferenceUtil {
...
@@ -50,9 +50,11 @@ public class SharedPreferenceUtil {
return
getShareRecord
().
getInt
(
"StartTimes"
,
0
);
return
getShareRecord
().
getInt
(
"StartTimes"
,
0
);
}
}
public
static
void
setExpansionDataVer
(
String
json
){
public
static
void
setExpansionDataVer
(
String
json
)
{
getShareRecord
().
edit
().
putString
(
"ExpansionsDataVer"
,
json
).
commit
();
getShareRecord
().
edit
().
putString
(
"ExpansionsDataVer"
,
json
).
commit
();
};
}
;
public
static
String
getExpansionDataVer
()
{
public
static
String
getExpansionDataVer
()
{
return
getShareRecord
().
getString
(
"ExpansionsDataVer"
,
null
);
return
getShareRecord
().
getString
(
"ExpansionsDataVer"
,
null
);
...
...
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