Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
YGOMobile-Cn-Ko-En
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-Cn-Ko-En
Commits
c0751e14
Commit
c0751e14
authored
Dec 21, 2018
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复资源文件不复制的问题
parent
97c88374
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
47 deletions
+63
-47
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
+6
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
+17
-6
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
...c/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
+40
-35
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
...mb/ygomobile/ui/preference/fragments/SettingFragment.java
+0
-2
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
+0
-4
No files found.
mobile/src/main/java/cn/garymb/ygomobile/AppsSettings.java
View file @
c0751e14
...
...
@@ -450,10 +450,16 @@ public class AppsSettings {
mSharedPreferences
.
putString
(
Constants
.
PREF_GAME_PATH
,
path
);
}
//获取卡组文件夹
public
String
getDeckDir
()
{
return
new
File
(
getResourcePath
(),
Constants
.
CORE_DECK_PATH
).
getAbsolutePath
();
}
//获取残局文件夹
public
String
getSingleDir
()
{
return
new
File
(
getResourcePath
(),
Constants
.
CORE_SINGLE_PATH
).
getAbsolutePath
();
}
/**
* 隐藏底部导航栏
*/
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/MainActivity.java
View file @
c0751e14
...
...
@@ -15,6 +15,7 @@ import android.provider.Settings;
import
android.support.annotation.NonNull
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.app.NotificationManagerCompat
;
import
android.util.Log
;
import
java.io.IOException
;
...
...
@@ -176,24 +177,34 @@ public class MainActivity extends HomeActivity{
@Override
public
void
updateImages
()
{
Log
.
e
(
"MainActivity"
,
"重置资源"
);
DialogPlus
dialog
=
DialogPlus
.
show
(
this
,
null
,
getString
(
R
.
string
.
message
));
dialog
.
show
();
VUiKit
.
defer
().
when
(()
->
{
if
(
IOUtils
.
hasAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
Log
.
e
(
"MainActivity"
,
"开始复制"
);
try
{
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
IOUtils
.
createNoMedia
(
AppsSettings
.
get
().
getResourcePath
());
if
(
IOUtils
.
hasAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
}
if
(
IOUtils
.
hasAssets
(
this
,
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
)))
{
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
}
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
DATABASE_NAME
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_STRING_PATH
),
AppsSettings
.
get
().
getResourcePath
(),
true
);
IOUtils
.
copyFilesFromAssets
(
this
,
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
AppsSettings
.
get
().
getCoreSkinPath
(),
true
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
Log
.
e
(
"MainActivity"
,
"错误"
+
e
);
}
}
}).
done
((
rs
)
->
{
Log
.
e
(
"MainActivity"
,
"复制完毕"
);
dialog
.
dismiss
();
});
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/ResCheckTask.java
View file @
c0751e14
...
...
@@ -21,6 +21,7 @@ import cn.garymb.ygomobile.AppsSettings;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.utils.FileLogUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.IOUtils
;
import
cn.garymb.ygomobile.utils.SystemUtils
;
...
...
@@ -114,8 +115,11 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
//res
try
{
String
resPath
=
mSettings
.
getResourcePath
();
//创建游戏目录
IOUtils
.
createNoMedia
(
resPath
);
//检查文件夹
checkDirs
();
//复制游戏配置文件
copyCoreConfig
(
resPath
,
needsUpdate
);
if
(
AppsSettings
.
get
().
isUseExtraCards
())
{
//自定义数据库无效,则用默认的
...
...
@@ -123,61 +127,49 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
AppsSettings
.
get
().
setUseExtraCards
(
false
);
}
}
/* if (needsUpdate) {
* if(AppsSettings.get().resetGameVersion() == 0){
* VUiKit.show(mContext, mContext.getString(R.string.reset_game_ver_fail));
* }
* }*/
//设置字体
ConfigManager
systemConf
=
DataManager
.
openConfig
(
mSettings
.
getSystemConfig
());
systemConf
.
setFontSize
(
mSettings
.
getFontSize
());
systemConf
.
close
();
// copyCoreConfig(new File(mSettings.getResourcePath(), GameSettings.CORE_CONFIG_PATH).getAbsolutePath());
//如果是新版本
if
(
needsUpdate
)
{
//复制卡组
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
tip_new_deck
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_DECK_PATH
),
new
File
(
resPath
,
Constants
.
CORE_DECK_PATH
).
getAbsolutePath
(),
needsUpdate
);
}
if
(
needsUpdate
)
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
game_skins
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
mSettings
.
getCoreSkinPath
(),
false
,
mSettings
.
isPendulumScale
());
}
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
font_files
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
FONT_DIRECTORY
),
mSettings
.
getFontDirPath
(),
false
);
if
(
needsUpdate
)
{
mSettings
.
getDeckDir
(),
needsUpdate
);
//复制残局
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
single_lua
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SINGLE_PATH
),
new
File
(
resPath
,
Constants
.
CORE_SINGLE_PATH
).
getAbsolutePath
(),
needsUpdate
);
mSettings
.
getSingleDir
(),
needsUpdate
);
}
//复制资源
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
game_skins
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SKIN_PATH
),
mSettings
.
getCoreSkinPath
(),
needsUpdate
);
//复制字体
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
font_files
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
FONT_DIRECTORY
),
mSettings
.
getFontDirPath
(),
needsUpdate
);
//复制脚本压缩包
if
(
IOUtils
.
hasAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
)))
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
scripts
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_SCRIPTS_ZIP
),
resPath
,
needsUpdate
);
}
//复制数据库
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
cards_cdb
)));
copyCdbFile
(
needsUpdate
);
//复制卡图压缩包
if
(
IOUtils
.
hasAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
)))
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
images
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_PICS_ZIP
),
resPath
,
needsUpdate
);
}
//if (needsUpdate) {
File
filesDir
=
mContext
.
getFilesDir
();
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
WINDBOT_PATH
),
filesDir
.
getPath
(),
needsUpdate
);
// }
if
(
needsUpdate
)
{
setMessage
(
mContext
.
getString
(
R
.
string
.
check_things
,
mContext
.
getString
(
R
.
string
.
ex_pack
)));
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
CORE_EXPANSIONS
),
mSettings
.
getExpansionsPath
().
getAbsolutePath
(),
true
,
needsUpdate
);
}
//checkWindbot();
IOUtils
.
copyFilesFromAssets
(
mContext
,
getDatapath
(
Constants
.
WINDBOT_PATH
),
mContext
.
getFilesDir
().
getPath
(),
needsUpdate
);
han
.
sendEmptyMessage
(
0
);
loadData
();
...
...
@@ -189,7 +181,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
return
ERROR_NONE
;
}
private
void
loadData
(){
private
void
loadData
()
{
setMessage
(
mContext
.
getString
(
R
.
string
.
loading
));
DataManager
.
get
().
load
(
false
);
}
...
...
@@ -197,7 +189,7 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
void
copyCdbFile
(
boolean
needsUpdate
)
throws
IOException
{
File
dbFile
=
new
File
(
mSettings
.
getDataBasePath
(),
DATABASE_NAME
);
boolean
copyDb
=
true
;
if
(
dbFile
.
exists
())
{
if
(
dbFile
.
exists
()
&&
dbFile
.
length
()<
1024
*
1024
)
{
copyDb
=
false
;
if
(
needsUpdate
)
{
copyDb
=
true
;
...
...
@@ -269,14 +261,27 @@ public class ResCheckTask extends AsyncTask<Void, Integer, Integer> {
}
private
void
checkDirs
()
{
String
[]
dirs
=
{
Constants
.
CORE_SCRIPT_PATH
,
String
[]
dirs
=
{
//脚本文件夹
Constants
.
CORE_SCRIPT_PATH
,
//残局文件夹
Constants
.
CORE_SINGLE_PATH
,
//卡组文件夹
Constants
.
CORE_DECK_PATH
,
//录像文件夹
Constants
.
CORE_REPLAY_PATH
,
//字体文件夹
Constants
.
FONT_DIRECTORY
,
//资源文件夹
Constants
.
CORE_SKIN_PATH
,
//卡图文件夹
Constants
.
CORE_IMAGE_PATH
,
//log文件夹
Constants
.
MOBILE_LOG
,
Constants
.
MOBILE_DECK_SHARE
//卡组分享截图文件夹
Constants
.
MOBILE_DECK_SHARE
,
//额外卡库文件夹
Constants
.
CORE_EXPANSIONS
};
File
dirFile
=
null
;
for
(
String
dir
:
dirs
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/preference/fragments/SettingFragment.java
View file @
c0751e14
...
...
@@ -384,8 +384,6 @@ public class SettingFragment extends PreferenceFragmentPlus {
process
.
waitFor
();
IOUtils
.
delete
(
soFile
);
Log
.
e
(
"SettingFragment"
,
"file: "
+
file
);
Log
.
e
(
"SettingFragment"
,
"path: "
+
soFile
.
getAbsolutePath
());
IOUtils
.
copyFile
(
file
,
soFile
.
getAbsolutePath
(),
true
);
me
.
what
=
COPY_SO_OK
;
}
catch
(
Exception
e
)
{
...
...
mobile/src/main/java/cn/garymb/ygomobile/utils/IOUtils.java
View file @
c0751e14
...
...
@@ -107,10 +107,6 @@ public class IOUtils {
}
public
static
int
copyFilesFromAssets
(
Context
context
,
String
assets
,
String
toPath
,
boolean
update
)
throws
IOException
{
return
copyFilesFromAssets
(
context
,
assets
,
toPath
,
update
,
true
);
}
public
static
int
copyFilesFromAssets
(
Context
context
,
String
assets
,
String
toPath
,
boolean
update
,
boolean
sub
)
throws
IOException
{
AssetManager
am
=
context
.
getAssets
();
String
[]
files
=
am
.
list
(
assets
);
if
(
files
==
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