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
bdc86ae0
Commit
bdc86ae0
authored
Sep 10, 2021
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
arrange code
parent
953529a3
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
38 additions
and
34 deletions
+38
-34
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
+21
-21
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
...c/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
...rc/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
+6
-6
mobile/src/main/java/ocgcore/StringManager.java
mobile/src/main/java/ocgcore/StringManager.java
+3
-3
mobile/src/main/java/ocgcore/data/Card.java
mobile/src/main/java/ocgcore/data/Card.java
+3
-0
mobile/src/main/java/ocgcore/data/CardData.java
mobile/src/main/java/ocgcore/data/CardData.java
+4
-3
No files found.
mobile/src/main/java/cn/garymb/ygomobile/GameUriManager.java
View file @
bdc86ae0
package
cn.garymb.ygomobile
;
import
android.app.Activity
;
import
android.content.ContentUris
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Environment
;
import
android.os.ParcelFileDescriptor
;
import
android.provider.DocumentsContract
;
import
android.provider.MediaStore
;
import
android.provider.Settings
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
android.widget.Toast
;
import
androidx.documentfile.provider.DocumentFile
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.util.Locale
;
...
...
@@ -41,7 +47,7 @@ public class GameUriManager {
}
public
boolean
doIntent
(
Intent
intent
)
{
Log
.
i
(
"ygo"
,
"doIntent"
);
Log
.
i
(
Constants
.
TAG
,
"doIntent"
);
if
(
ACTION_OPEN_DECK
.
equals
(
intent
.
getAction
()))
{
if
(
intent
.
getData
()
!=
null
)
{
doUri
(
intent
.
getData
());
...
...
@@ -79,7 +85,7 @@ public class GameUriManager {
private
String
getPathName
(
String
path
,
boolean
withOutEx
)
{
Log
.
d
(
"ygo"
,
"path="
+
path
);
Log
.
d
(
Constants
.
TAG
,
"path="
+
path
);
if
(
path
!=
null
)
{
int
index
=
path
.
lastIndexOf
(
"/"
);
if
(
index
>
0
)
{
...
...
@@ -98,7 +104,7 @@ public class GameUriManager {
}
private
File
getDeckFile
(
File
dir
,
String
name
)
{
File
file
=
new
File
(
dir
,
name
+
".ydk"
);
File
file
=
new
File
(
dir
,
name
);
if
(
file
.
exists
())
{
for
(
int
i
=
2
;
i
<
10
;
i
++)
{
file
=
new
File
(
dir
,
name
+
"("
+
i
+
").ydk"
);
...
...
@@ -140,11 +146,11 @@ public class GameUriManager {
}
try
{
if
(!
remoteFile
.
canRead
())
{
Log
.
w
(
"ygo"
,
"don't read file "
+
remoteFile
.
getAbsolutePath
());
Log
.
w
(
Constants
.
TAG
,
"don't read file "
+
remoteFile
.
getAbsolutePath
());
return
null
;
}
}
catch
(
Throwable
e
)
{
Log
.
e
(
"ygo"
,
"don't read file "
+
remoteFile
.
getAbsolutePath
(),
e
);
Log
.
e
(
Constants
.
TAG
,
"don't read file "
+
remoteFile
.
getAbsolutePath
(),
e
);
return
null
;
}
}
...
...
@@ -152,7 +158,7 @@ public class GameUriManager {
File
local
;
if
(
name
.
toLowerCase
(
Locale
.
US
).
endsWith
(
".ydk"
))
{
File
dir
=
Constants
.
COPY_YDK_FILE
?
new
File
(
AppsSettings
.
get
().
getDeckDir
())
:
new
File
(
getActivity
().
getApplicationInfo
().
dataDir
,
"cache"
);
local
=
getDeckFile
(
dir
,
name
);
local
=
getDeckFile
(
dir
,
getPathName
(
path
,
true
)
);
}
else
if
(
name
.
toLowerCase
(
Locale
.
US
).
endsWith
(
".ypk"
))
{
local
=
new
File
(
AppsSettings
.
get
().
getExpansionsPath
(),
name
);
}
else
if
(
name
.
toLowerCase
(
Locale
.
US
).
endsWith
(
".yrp"
))
{
...
...
@@ -163,11 +169,11 @@ public class GameUriManager {
local
=
new
File
(
AppsSettings
.
get
().
getResourcePath
()
+
"/temp"
,
name
);
}
if
(
local
.
exists
())
{
Log
.
w
(
"ygo"
,
"Overwrite file "
+
local
.
getAbsolutePath
());
Log
.
w
(
Constants
.
TAG
,
"Overwrite file "
+
local
.
getAbsolutePath
());
}
if
(
remoteFile
!=
null
&&
TextUtils
.
equals
(
remoteFile
.
getAbsolutePath
(),
local
.
getAbsolutePath
()))
{
//is same path
Log
.
i
(
"ygo"
,
"is same file "
+
remoteFile
.
getAbsolutePath
()
+
"=="
+
local
.
getAbsolutePath
());
Log
.
i
(
Constants
.
TAG
,
"is same file "
+
remoteFile
.
getAbsolutePath
()
+
"=="
+
local
.
getAbsolutePath
());
return
local
;
}
//copy
...
...
@@ -186,7 +192,7 @@ public class GameUriManager {
FileUtils
.
copyFile
(
input
,
local
);
}
}
catch
(
Throwable
e
)
{
Log
.
w
(
"ygo"
,
"copy file "
+
path
+
"->"
+
local
.
getAbsolutePath
(),
e
);
Log
.
w
(
Constants
.
TAG
,
"copy file "
+
path
+
"->"
+
local
.
getAbsolutePath
(),
e
);
return
null
;
}
finally
{
IOUtils
.
close
(
input
);
...
...
@@ -207,11 +213,9 @@ public class GameUriManager {
boolean
isYpk
=
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".ypk"
);
boolean
isYrp
=
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".yrp"
);
boolean
isLua
=
file
.
getName
().
toLowerCase
(
Locale
.
US
).
endsWith
(
".lua"
);
Log
.
i
(
"ygo"
,
"open file:"
+
uri
+
"->"
+
file
.
getAbsolutePath
());
Log
.
i
(
Constants
.
TAG
,
"open file:"
+
uri
+
"->"
+
file
.
getAbsolutePath
());
if
(
isYdk
)
{
Intent
intent
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
intent
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
activity
.
startActivity
(
intent
);
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
}
else
if
(
isYpk
)
{
if
(!
AppsSettings
.
get
().
isReadExpansions
())
{
activity
.
startActivity
(
startSeting
);
...
...
@@ -225,14 +229,14 @@ public class GameUriManager {
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-r"
,
file
.
getName
());
Toast
.
makeText
(
activity
,
activity
.
getString
(
R
.
string
.
file_installed
),
Toast
.
LENGTH_LONG
).
show
();
}
else
{
Log
.
w
(
"ygo"
,
"game is running"
);
Log
.
w
(
Constants
.
TAG
,
"game is running"
);
}
}
else
if
(
isLua
)
{
if
(!
YGOStarter
.
isGameRunning
(
getActivity
()))
{
YGOStarter
.
startGame
(
getActivity
(),
null
,
"-s"
,
file
.
getName
());
Toast
.
makeText
(
activity
,
"load single lua file"
,
Toast
.
LENGTH_LONG
).
show
();
}
else
{
Log
.
w
(
"ygo"
,
"game is running"
);
Log
.
w
(
Constants
.
TAG
,
"game is running"
);
}
}
}
else
{
...
...
@@ -247,9 +251,7 @@ public class GameUriManager {
}
else
{
Deck
deckInfo
=
new
Deck
(
uri
);
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
Intent
startdeck
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
activity
.
startActivity
(
startdeck
);
DeckManagerActivity
.
start
(
activity
,
file
.
getAbsolutePath
());
}
}
// else if (PATH_ROOM.equals(path)) {
...
...
@@ -277,9 +279,7 @@ public class GameUriManager {
}
}
if
(
deck
!=
null
&&
deck
.
exists
())
{
Intent
startdeck
=
new
Intent
(
getActivity
(),
DeckManagerActivity
.
getDeckManager
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
deck
.
getAbsolutePath
());
activity
.
startActivity
(
startdeck
);
DeckManagerActivity
.
start
(
activity
,
deck
.
getAbsolutePath
());
}
else
{
Log
.
w
(
"kk"
,
"no find "
+
name
);
activity
.
finish
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileActivity.java
View file @
bdc86ae0
...
...
@@ -244,7 +244,7 @@ public class FileActivity extends BaseActivity implements AdapterView.OnItemClic
}
else
{
mFileAdapter
.
setPath
(
mFileOpenInfo
.
getDefPath
());
}
mFileAdapter
.
setFile
f
ilter
(
mFileOpenInfo
.
getFileFilter
());
mFileAdapter
.
setFile
F
ilter
(
mFileOpenInfo
.
getFileFilter
());
mFileAdapter
.
setOnlyFolder
(
mFileOpenInfo
.
getType
()
==
FileOpenType
.
SelectFolder
);
mFileAdapter
.
loadFiles
();
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/file/FileAdapter.java
View file @
bdc86ae0
...
...
@@ -42,17 +42,17 @@ class FileAdapter extends BaseAdapterPlus<File> {
public
FileAdapter
(
Context
context
)
{
super
(
context
);
rootPath
=
getRootPath
();
try
{
rootPath
=
Environment
.
getExternalStorageDirectory
().
getAbsolutePath
();
}
catch
(
Exception
e
)
{
rootPath
=
"/"
;
}
}
public
void
setOnPathChangedListener
(
OnPathChangedListener
onPathChangedListener
)
{
mOnPathChangedListener
=
onPathChangedListener
;
}
private
String
getRootPath
()
{
return
"/"
;
}
public
File
getCurPath
()
{
return
mCurPath
;
}
...
...
@@ -101,7 +101,7 @@ class FileAdapter extends BaseAdapterPlus<File> {
mShowHide
=
showHide
;
}
public
void
setFile
f
ilter
(
String
filefilter
)
{
public
void
setFile
F
ilter
(
String
filefilter
)
{
mFilefilter
=
filefilter
;
}
...
...
mobile/src/main/java/ocgcore/StringManager.java
View file @
bdc86ae0
...
...
@@ -82,9 +82,9 @@ public class StringManager implements Closeable {
InputStreamReader
in
=
null
;
try
{
in
=
new
InputStreamReader
(
inputStream
,
"utf-8"
);
in
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
String
line
=
null
;
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"#"
)
||
(!
line
.
startsWith
(
PRE_SYSTEM
)
&&
!
line
.
startsWith
(
PRE_SETNAME
)))
{
continue
;
...
...
@@ -133,7 +133,7 @@ public class StringManager implements Closeable {
inputStream
=
new
FileInputStream
(
file
);
in
=
new
InputStreamReader
(
inputStream
,
StandardCharsets
.
UTF_8
);
BufferedReader
reader
=
new
BufferedReader
(
in
);
String
line
=
null
;
String
line
;
while
((
line
=
reader
.
readLine
())
!=
null
)
{
if
(
line
.
startsWith
(
"#"
)
||
(!
line
.
startsWith
(
PRE_SYSTEM
)
&&
!
line
.
startsWith
(
PRE_SETNAME
)))
{
continue
;
...
...
mobile/src/main/java/ocgcore/data/Card.java
View file @
bdc86ae0
...
...
@@ -4,6 +4,8 @@ package ocgcore.data;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
androidx.annotation.NonNull
;
import
ocgcore.enums.CardType
;
public
class
Card
extends
CardData
implements
Parcelable
{
...
...
@@ -137,6 +139,7 @@ public class Card extends CardData implements Parcelable {
return
c
.
Code
==
this
.
Code
||
c
.
Alias
==
this
.
Code
||
c
.
Code
==
this
.
Alias
;
}
@NonNull
@Override
public
String
toString
()
{
return
"Card{"
+
...
...
mobile/src/main/java/ocgcore/data/CardData.java
View file @
bdc86ae0
...
...
@@ -3,10 +3,9 @@ package ocgcore.data;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
ocgcore.enums.CardAttribute
;
import
ocgcore.enums.CardOt
;
import
androidx.annotation.NonNull
;
public
class
CardData
implements
Parcelable
{
public
class
CardData
implements
Parcelable
{
public
CardData
()
{
}
...
...
@@ -14,6 +13,7 @@ public class CardData implements Parcelable{
public
CardData
(
int
code
)
{
Code
=
code
;
}
public
int
Code
;
public
int
Ot
;
public
int
Alias
;
...
...
@@ -28,6 +28,7 @@ public class CardData implements Parcelable{
public
int
RightScale
;
public
long
Category
;
@NonNull
@Override
public
String
toString
()
{
return
"CardData{"
+
...
...
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