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
caf4146b
Commit
caf4146b
authored
May 07, 2019
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
卡组分享时同时分享卡组url
决斗助手识别卡组url
parent
3c0f01d5
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
80 additions
and
41 deletions
+80
-41
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
+7
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
...cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
+8
-4
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
...ain/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
+3
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
+1
-11
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
.../java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
+20
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
...ava/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
+41
-24
No files found.
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
View file @
caf4146b
...
...
@@ -4,6 +4,7 @@ import android.net.Uri;
import
android.os.Parcel
;
import
android.os.Parcelable
;
import
android.text.TextUtils
;
import
android.util.Log
;
import
java.io.File
;
import
java.util.ArrayList
;
...
...
@@ -30,8 +31,8 @@ public class Deck implements Parcelable {
sideList
=
new
ArrayList
<>();
}
public
Deck
(
Uri
uri
)
{
this
(
uri
.
getQueryParameter
(
QUERY_YDK
)
);
public
Deck
(
String
name
,
Uri
uri
)
{
this
(
name
);
String
main
=
uri
.
getQueryParameter
(
QUERY_MAIN
);
String
extra
=
uri
.
getQueryParameter
(
QUERY_EXTRA
);
String
side
=
uri
.
getQueryParameter
(
QUERY_SIDE
);
...
...
@@ -64,6 +65,10 @@ public class Deck implements Parcelable {
}
}
public
Deck
(
Uri
uri
)
{
this
(
uri
.
getQueryParameter
(
QUERY_YDK
),
uri
);
}
public
Uri
toAppUri
()
{
return
toUri
(
Constants
.
SCHEME_APP
);
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/DeckManagerActivityImpl.java
View file @
caf4146b
...
...
@@ -7,7 +7,6 @@ import android.graphics.Bitmap;
import
android.graphics.Color
;
import
android.os.Build
;
import
android.os.Bundle
;
import
android.support.annotation.Keep
;
import
android.support.annotation.Nullable
;
import
android.support.v7.widget.AppCompatSpinner
;
import
android.support.v7.widget.RecyclerView
;
...
...
@@ -37,7 +36,6 @@ import org.greenrobot.eventbus.ThreadMode;
import
java.io.File
;
import
java.io.IOException
;
import
java.text.Collator
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Collections
;
...
...
@@ -59,9 +57,11 @@ import cn.garymb.ygomobile.ui.cards.deck.DeckItem;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemTouchHelper
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckItemType
;
import
cn.garymb.ygomobile.ui.cards.deck.DeckLayoutManager
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.Util
;
import
cn.garymb.ygomobile.ui.plus.AOnGestureListener
;
import
cn.garymb.ygomobile.ui.plus.DefaultOnBoomListener
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.utils.BitmapUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
...
...
@@ -706,8 +706,12 @@ class DeckManagerActivityImpl extends BaseCardsAcitivity implements RecyclerView
String
savePath
=
new
File
(
AppsSettings
.
get
().
getDeckSharePath
(),
deckName
+
".jpg"
).
getAbsolutePath
();
BitmapUtil
.
saveBitmap
(
bitmap
,
savePath
,
50
);
ShareUtil
.
shareImage
(
DeckManagerActivityImpl
.
this
,
"卡组分享"
,
savePath
,
null
);
//复制前关闭决斗助手
stopService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
Util
.
fzMessage
(
this
,
mDeckAdapater
.
getDeckInfo
().
toDeck
().
toAppUri
().
toString
());
showToast
(
"已复制卡组代码到剪贴板"
);
//复制完毕开启决斗助手
Util
.
startDuelService
(
this
);
// String label = TextUtils.isEmpty(deck.getName()) ? getString(R.string.share_deck) : deck.getName();
// final String uriString = deck.toAppUri().toString();
// final String httpUri = deck.toHttpUri().toString();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/cards/deck/DeckUtils.java
View file @
caf4146b
package
cn.garymb.ygomobile.ui.cards.deck
;
import
android.util.Log
;
import
java.io.ByteArrayOutputStream
;
import
java.io.File
;
import
java.io.FileOutputStream
;
...
...
@@ -123,6 +125,7 @@ public class DeckUtils {
outputStream
=
new
FileOutputStream
(
file
);
save
(
deck
,
outputStream
);
}
catch
(
Exception
e
)
{
Log
.
e
(
"DeckUtil"
,
"保存出错"
+
e
);
//ignore
}
finally
{
IOUtils
.
close
(
outputStream
);
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeActivity.java
View file @
caf4146b
...
...
@@ -225,17 +225,7 @@ public abstract class HomeActivity extends BaseActivity implements NavigationVie
//autoupadte checking
checkPgyerUpdateSilent
(
getContext
(),
false
,
false
,
false
);
//ServiceDuelAssistant
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
this
);
if
(
dialogPlus
==
null
)
this
.
startForegroundService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
else
dialogPlus
.
show
();
}
else
{
startService
(
new
Intent
(
this
,
ServiceDuelAssistant
.
class
));
}
}
//萌卡
StartMycard
();
checkNotch
();
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/mycard/mcchat/util/Util.java
View file @
caf4146b
...
...
@@ -3,9 +3,16 @@ package cn.garymb.ygomobile.ui.mycard.mcchat.util;
import
android.app.Activity
;
import
android.content.ClipboardManager
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Build
;
import
android.view.inputmethod.InputMethodManager
;
import
android.widget.Toast
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.ServiceDuelAssistant
;
import
cn.garymb.ygomobile.utils.PermissionUtil
;
public
class
Util
{
//提示
public
static
void
show
(
Context
context
,
String
message
)
{
...
...
@@ -26,5 +33,18 @@ public class Util {
cmb
.
setText
(
message
);
//复制命令
}
public
static
void
startDuelService
(
Context
context
){
if
(
AppsSettings
.
get
().
isServiceDuelAssistant
())
{
if
(
Build
.
VERSION
.
SDK_INT
>=
Build
.
VERSION_CODES
.
O
)
{
DialogPlus
dialogPlus
=
PermissionUtil
.
isNotificationPermission
(
context
);
if
(
dialogPlus
==
null
)
context
.
startForegroundService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
else
dialogPlus
.
show
();
}
else
{
context
.
startService
(
new
Intent
(
context
,
ServiceDuelAssistant
.
class
));
}
}
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/ServiceDuelAssistant.java
View file @
caf4146b
...
...
@@ -11,6 +11,7 @@ import android.content.ClipboardManager;
import
android.content.Context
;
import
android.content.Intent
;
import
android.graphics.PixelFormat
;
import
android.net.Uri
;
import
android.os.Build
;
import
android.os.Handler
;
import
android.os.IBinder
;
...
...
@@ -22,7 +23,6 @@ import android.view.View;
import
android.view.View.OnClickListener
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.LinearLayout
;
import
android.widget.RemoteViews
;
import
android.widget.TextView
;
import
android.widget.Toast
;
...
...
@@ -30,10 +30,11 @@ 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
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.bean.Deck
;
import
cn.garymb.ygomobile.bean.ServerInfo
;
import
cn.garymb.ygomobile.bean.ServerList
;
import
cn.garymb.ygomobile.lite.R
;
...
...
@@ -43,9 +44,7 @@ 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
;
import
cn.garymb.ygomobile.utils.PermissionUtil
;
import
cn.garymb.ygomobile.utils.XmlUtils
;
import
static
cn
.
garymb
.
ygomobile
.
Constants
.
ASSET_SERVER_LIST
;
...
...
@@ -59,6 +58,7 @@ public class ServiceDuelAssistant extends Service {
private
final
static
String
CMD_NAME
=
"CMD"
;
private
final
static
String
CMD_START_GAME
=
"CMD : START GAME"
;
private
final
static
String
CMD_STOP_SERVICE
=
"CMD : STOP SERVICE"
;
private
final
static
String
DECK_URL_PREFIX
=
"ygomobile://m.ygomobile.com/"
;
//悬浮窗显示的时间
private
static
final
int
TIME_DIS_WINDOW
=
3000
;
...
...
@@ -84,7 +84,7 @@ public class ServiceDuelAssistant extends Service {
//卡查内容
public
static
String
cardSearchMessage
=
""
;
//卡组复制
public
static
final
String
[]
DeckTextKey
=
new
String
[]{
"#main"
};
public
static
final
String
[]
DeckTextKey
=
new
String
[]{
"#main"
};
public
static
String
DeckText
=
""
;
//悬浮窗布局View
...
...
@@ -133,7 +133,7 @@ public class ServiceDuelAssistant extends Service {
cm
.
addPrimaryClipChangedListener
(
onPrimaryClipChangedListener
);
}
ClipboardManager
.
OnPrimaryClipChangedListener
onPrimaryClipChangedListener
=
new
ClipboardManager
.
OnPrimaryClipChangedListener
()
{
ClipboardManager
.
OnPrimaryClipChangedListener
onPrimaryClipChangedListener
=
new
ClipboardManager
.
OnPrimaryClipChangedListener
()
{
@Override
public
void
onPrimaryClipChanged
()
{
...
...
@@ -157,19 +157,26 @@ public class ServiceDuelAssistant extends Service {
for
(
String
s
:
DeckTextKey
)
{
//只要包含其中一个关键字就视为卡组
if
(
clipMessage
.
contains
(
s
))
{
saveDeck
(
clipMessag
e
);
return
;
saveDeck
(
clipMessage
,
fals
e
);
return
;
}
}
return
;
}
//如果是卡组url
int
deckStart
=
clipMessage
.
indexOf
(
DECK_URL_PREFIX
);
if
(
deckStart
!=-
1
){
saveDeck
(
clipMessage
.
substring
(
deckStart
+
DECK_URL_PREFIX
.
length
(),
clipMessage
.
length
()),
true
);
return
;
}
int
start
=
-
1
;
int
end
=
-
1
;
String
passwordPrefixKey
=
null
;
for
(
String
s
:
passwordPrefix
)
{
start
=
clipMessage
.
indexOf
(
s
);
passwordPrefixKey
=
s
;
if
(
start
!=
-
1
)
{
if
(
start
!=
-
1
)
{
break
;
}
}
...
...
@@ -180,9 +187,9 @@ public class ServiceDuelAssistant extends Service {
//如果不含有空格则取片尾所有
if
(
end
==
-
1
)
{
end
=
clipMessage
.
length
();
}
else
{
}
else
{
//如果只有密码前缀而没有密码内容则不跳转
if
(
end
-
start
==
passwordPrefixKey
.
length
())
if
(
end
-
start
==
passwordPrefixKey
.
length
())
return
;
}
//如果有悬浮窗权限再显示
...
...
@@ -199,7 +206,7 @@ public class ServiceDuelAssistant extends Service {
return
;
}
//如果卡查内容包含“=”并且复制的内容包含“.”不卡查
if
(
cardSearchMessage
.
contains
(
"="
)
&&
clipMessage
.
contains
(
"."
))
{
if
(
cardSearchMessage
.
contains
(
"="
)
&&
clipMessage
.
contains
(
"."
))
{
return
;
}
Intent
intent
=
new
Intent
(
ServiceDuelAssistant
.
this
,
CardSearchAcitivity
.
class
);
...
...
@@ -243,20 +250,19 @@ public class ServiceDuelAssistant extends Service {
builder
.
setSound
(
null
);
builder
.
setCustomContentView
(
remoteViews
);
startForeground
(
1
,
builder
.
build
());
}
else
{
}
else
{
//如果没有通知权限则关闭服务
stopForeground
(
true
);
stopService
(
new
Intent
(
ServiceDuelAssistant
.
this
,
ServiceDuelAssistant
.
class
));
stopService
(
new
Intent
(
ServiceDuelAssistant
.
this
,
ServiceDuelAssistant
.
class
));
}
}
}
@Override
public
int
onStartCommand
(
Intent
intent
,
int
flags
,
int
startId
)
{
if
(
intent
==
null
)
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
if
(
intent
==
null
)
return
super
.
onStartCommand
(
intent
,
flags
,
startId
);
String
action
=
intent
.
getAction
();
Log
.
d
(
TAG
,
"rev action:"
+
action
);
if
(
DUEL_ASSISTANT_SERVICE_ACTION
.
equals
(
action
))
{
...
...
@@ -316,7 +322,7 @@ public class ServiceDuelAssistant extends Service {
}
}
private
void
saveDeck
(
String
deckMessage
)
{
private
void
saveDeck
(
String
deckMessage
,
boolean
isUrl
)
{
tv_message
.
setText
(
"检测到卡组文本,是否保存?"
);
bt_close
.
setText
(
R
.
string
.
search_close
);
bt_join
.
setText
(
"保存并打开"
);
...
...
@@ -338,16 +344,27 @@ public class ServiceDuelAssistant extends Service {
@Override
public
void
onClick
(
View
v
)
{
disJoinDialog
();
try
{
//以当前时间戳作为卡组名保存卡组
File
file
=
DeckUtils
.
save
(
"助手保存:"
+
System
.
currentTimeMillis
(),
deckMessage
);
//如果是卡组url
if
(
isUrl
)
{
Deck
deckInfo
=
new
Deck
(
"助手保存:"
+
System
.
currentTimeMillis
(),
Uri
.
parse
(
deckMessage
));
File
file
=
deckInfo
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
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
();
}
else
{
//如果是卡组文本
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
();
}
}
}
});
...
...
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