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
4452a6b8
Commit
4452a6b8
authored
May 06, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
决斗助手快速保存复制的卡组文本
parent
a457c6c7
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
12 deletions
+70
-12
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
...ain/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
+20
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
...ava/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
+49
-12
mobile/src/main/res/xml/preference_game.xml
mobile/src/main/res/xml/preference_game.xml
+1
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
View file @
4452a6b8
...
...
@@ -3,10 +3,13 @@ package cn.garymb.ygomobile.ui.cards.deck;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.OutputStreamWriter
;
import
java.io.PrintWriter
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.DeckInfo
;
import
cn.garymb.ygomobile.utils.IOUtils
;
...
...
@@ -126,4 +129,21 @@ public class DeckUtils {
}
return
true
;
}
public
static
File
save
(
String
name
,
String
deckMessage
)
throws
IOException
{
FileWriter
fw
=
null
;
//如果文件存在,则重写内容;如果文件不存在,则创建文件
File
f
=
new
File
(
AppsSettings
.
get
().
getDeckDir
(),
name
+
".ydk"
);
fw
=
new
FileWriter
(
f
,
false
);
PrintWriter
pw
=
new
PrintWriter
(
fw
);
pw
.
println
(
deckMessage
);
pw
.
flush
();
fw
.
flush
();
pw
.
close
();
fw
.
close
();
return
f
;
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
View file @
4452a6b8
...
...
@@ -25,9 +25,11 @@ import android.widget.Button;
import
android.widget.LinearLayout
;
import
android.widget.RemoteViews
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.lang.reflect.Method
;
...
...
@@ -37,6 +39,8 @@ import cn.garymb.ygomobile.bean.ServerList;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.adapters.ServerListAdapter
;
import
cn.garymb.ygomobile.ui.cards.CardSearchAcitivity
;
import
cn.garymb.ygomobile.ui.cards.DeckManagerActivity
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckUtils
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
import
cn.garymb.ygomobile.utils.IOUtils
;
...
...
@@ -80,7 +84,7 @@ public class ServiceDuelAssistant extends Service {
//卡查内容
public
static
String
cardSearchMessage
=
""
;
//卡组复制
public
static
final
String
[]
DeckTextKey
=
new
String
[]{
"#Created by"
,
"#main"
};
public
static
final
String
[]
DeckTextKey
=
new
String
[]{
"#main"
};
public
static
String
DeckText
=
""
;
//悬浮窗布局View
...
...
@@ -148,21 +152,16 @@ public class ServiceDuelAssistant extends Service {
if
(
TextUtils
.
isEmpty
(
clipMessage
))
{
return
;
}
//如果复制的内容是多行
则视为卡组
//如果复制的内容是多行
作为卡组去判断
if
(
clipMessage
.
contains
(
"\n"
))
{
for
(
String
s
:
DeckTextKey
)
{
int
DeckTextStart
=
clipMessage
.
indexOf
(
s
);
if
(
DeckTextStart
!=
-
1
)
{
DeckText
=
clipMessage
.
substring
(
DeckTextStart
+
s
.
length
(),
clipMessage
.
length
());
if
(
TextUtils
.
isEmpty
(
DeckText
))
{
//只要包含其中一个关键字就视为卡组
if
(
clipMessage
.
contains
(
s
))
{
saveDeck
(
clipMessage
);
return
;
}
//如果卡组文本包含“#extra”并且复制的内容包含“!side”则作为卡组打开
if
(
DeckText
.
contains
(
"#extra"
)&&
clipMessage
.
contains
(
"!side"
))
{
}
}
}
return
;
}
int
start
=
-
1
;
int
end
=
-
1
;
...
...
@@ -317,6 +316,44 @@ public class ServiceDuelAssistant extends Service {
}
}
private
void
saveDeck
(
String
deckMessage
){
tv_message
.
setText
(
"检测到卡组文本,是否保存?"
);
bt_close
.
setText
(
R
.
string
.
search_close
);
bt_join
.
setText
(
"保存并打开"
);
disJoinDialog
();
showJoinDialog
();
new
Handler
().
postDelayed
(()
->
{
if
(
isdis
)
{
isdis
=
false
;
mWindowManager
.
removeView
(
mFloatLayout
);
}
},
TIME_DIS_WINDOW
);
bt_close
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
disJoinDialog
();
}
});
bt_join
.
setOnClickListener
(
new
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
disJoinDialog
();
try
{
//以当前时间戳作为卡组名保存卡组
File
file
=
DeckUtils
.
save
(
"助手保存:"
+
System
.
currentTimeMillis
(),
deckMessage
);
Intent
startdeck
=
new
Intent
(
ServiceDuelAssistant
.
this
,
DeckManagerActivity
.
getDeckManager
());
startdeck
.
putExtra
(
Intent
.
EXTRA_TEXT
,
file
.
getAbsolutePath
());
startdeck
.
addFlags
(
Intent
.
FLAG_ACTIVITY_NEW_TASK
);
startActivity
(
startdeck
);
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
Toast
.
makeText
(
ServiceDuelAssistant
.
this
,
"保存失败,原因为"
+
e
,
Toast
.
LENGTH_SHORT
).
show
();
}
}
});
}
private
void
joinRoom
(
String
ss
,
int
start
,
int
end
)
{
final
String
password
=
ss
.
substring
(
start
,
ss
.
length
());
tv_message
.
setText
(
getString
(
R
.
string
.
quick_join
)
+
password
+
"\""
);
...
...
mobile/src/main/res/xml/preference_game.xml
View file @
4452a6b8
...
...
@@ -37,6 +37,7 @@
<CheckBoxPreference
android:key=
"pref_key_start_serviceduelassistant"
android:persistent=
"true"
android:summary=
"快速卡查,加入决斗等"
android:title=
"@string/Start_ServiceDuelAssistant"
/>
<CheckBoxPreference
android:key=
"pref_key_game_sound_effect"
...
...
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