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
633dde66
Commit
633dde66
authored
Jan 28, 2025
by
feihuaduo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebActivity支持打开卡组
parent
d1780756
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
142 additions
and
35 deletions
+142
-35
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+47
-2
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
...c/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
+70
-31
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
...in/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
+15
-2
mobile/src/main/res/values-es/strings.xml
mobile/src/main/res/values-es/strings.xml
+2
-0
mobile/src/main/res/values-jp/strings.xml
mobile/src/main/res/values-jp/strings.xml
+2
-0
mobile/src/main/res/values-ko/strings.xml
mobile/src/main/res/values-ko/strings.xml
+2
-0
mobile/src/main/res/values-zh/strings.xml
mobile/src/main/res/values-zh/strings.xml
+2
-0
mobile/src/main/res/values/strings.xml
mobile/src/main/res/values/strings.xml
+2
-0
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
633dde66
...
...
@@ -9,6 +9,7 @@ import android.net.Uri;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.text.TextUtils
;
import
android.view.Gravity
;
import
android.view.MenuItem
;
import
android.view.View
;
...
...
@@ -24,6 +25,9 @@ import androidx.annotation.NonNull;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.Toolbar
;
import
com.ourygo.lib.duelassistant.listener.OnDuelAssistantListener
;
import
com.ourygo.lib.duelassistant.util.DuelAssistantManagement
;
import
com.ourygo.lib.duelassistant.util.Util
;
import
com.tencent.smtt.sdk.DownloadListener
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.WebChromeClient
;
...
...
@@ -32,6 +36,7 @@ import com.tencent.smtt.sdk.WebView;
import
java.io.File
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.util.List
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
...
...
@@ -41,6 +46,7 @@ import cn.garymb.ygomobile.ui.file.FileOpenType;
import
cn.garymb.ygomobile.ui.mycard.MyCard
;
import
cn.garymb.ygomobile.ui.plus.DefWebChromeClient
;
import
cn.garymb.ygomobile.ui.plus.DefWebViewClient
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
...
...
@@ -49,7 +55,7 @@ import cn.garymb.ygomobile.utils.YGOUtil;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
public
class
WebActivity
extends
BaseActivity
implements
View
.
OnClickListener
{
public
class
WebActivity
extends
BaseActivity
implements
View
.
OnClickListener
,
OnDuelAssistantListener
{
private
static
String
TAG
=
"WebActivity"
;
private
static
final
int
FILE_CHOOSER_REQUEST
=
100
;
private
ValueCallback
<
Uri
[]>
mFilePathCallback
;
...
...
@@ -113,7 +119,7 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
return
true
;
}
});
mWebViewPlus
.
setWebViewClient
(
new
DefWebViewClient
()
{
mWebViewPlus
.
setWebViewClient
(
new
DefWebViewClient
(
DefWebViewClient
.
CHECK_ID_WEB_VIEW_NEW_ACTIVITY
)
{
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
return
super
.
shouldOverrideUrlLoading
(
view
,
url
);
...
...
@@ -186,6 +192,7 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
});
}
});
DuelAssistantManagement
.
getInstance
().
addDuelAssistantListener
(
this
);
}
@Override
...
...
@@ -284,6 +291,7 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
mWebViewPlus
.
stopLoading
();
mWebViewPlus
.
setWebChromeClient
(
null
);
mWebViewPlus
.
setWebViewClient
(
null
);
DuelAssistantManagement
.
getInstance
().
removeDuelAssistantListener
(
this
);
//mWebViewPlus.onDestroy();
super
.
onDestroy
();
}
...
...
@@ -355,4 +363,41 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
String
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
getCode
())
+
"#faq"
;
WebActivity
.
open
(
context
,
cardInfo
.
Name
,
uri
);
}
@Override
public
void
onJoinRoom
(
String
host
,
int
port
,
String
password
,
int
id
)
{
}
@Override
public
void
onCardQuery
(
String
key
,
int
id
)
{
}
@Override
public
boolean
isListenerEffective
()
{
return
Util
.
isContextExisted
(
getActivity
());
}
@Override
public
void
onSaveDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
,
String
exception
,
int
id
)
{
if
(!
TextUtils
.
isEmpty
(
exception
))
{
YGOUtil
.
showTextToast
(
"卡组解析失败,原因为:"
+
exception
);
return
;
}
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
dialog
.
setTitle
(
R
.
string
.
question
);
dialog
.
setMessage
(
getString
(
R
.
string
.
web_warn_save_deck
));
dialog
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
dialog
.
setLeftButtonText
(
R
.
string
.
Cancel
);
dialog
.
setRightButtonText
(
R
.
string
.
open
);
dialog
.
show
();
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
});
dialog
.
setRightButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
finish
();
});
}
}
mobile/src/main/java/cn/garymb/ygomobile/ui/home/HomeFragment.java
View file @
633dde66
...
...
@@ -72,6 +72,7 @@ import cn.garymb.ygomobile.ui.cards.CardDetailRandom;
import
cn.garymb.ygomobile.ui.mycard.McNews
;
import
cn.garymb.ygomobile.ui.mycard.MyCard
;
import
cn.garymb.ygomobile.ui.mycard.mcchat.util.ImageUtil
;
import
cn.garymb.ygomobile.ui.plus.DefWebViewClient
;
import
cn.garymb.ygomobile.ui.plus.DialogPlus
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.widget.Shimmer
;
...
...
@@ -131,6 +132,13 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
private
Bundle
mBundle
;
private
View
layoutView
;
private
boolean
isShouldSaveAndOpenDeck
=
false
;
private
Uri
pendingUri
;
private
List
<
Integer
>
pendingMainList
;
private
List
<
Integer
>
pendingExList
;
private
List
<
Integer
>
pendingSideList
;
private
boolean
pendingIsCompleteDeck
;
@Nullable
@Override
public
View
onCreateView
(
@NonNull
LayoutInflater
inflater
,
@Nullable
ViewGroup
container
,
@Nullable
Bundle
savedInstanceState
)
{
...
...
@@ -565,11 +573,11 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
@Override
public
void
onSaveDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
,
String
exception
,
int
id
)
{
saveDeck
(
uri
,
mainList
,
exList
,
sideList
,
isCompleteDeck
,
exception
);
saveDeck
(
uri
,
mainList
,
exList
,
sideList
,
isCompleteDeck
,
exception
,
id
!=
DefWebViewClient
.
CHECK_ID_WEB_VIEW_NEW_ACTIVITY
);
}
public
void
saveDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
,
String
exception
)
{
if
(!
TextUtils
.
isEmpty
(
exception
))
{
public
void
saveDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
,
String
exception
,
boolean
isShowDialog
)
{
if
(
isShowDialog
&&
!
TextUtils
.
isEmpty
(
exception
))
{
YGOUtil
.
showTextToast
(
"卡组解析失败,原因为:"
+
exception
);
return
;
}
...
...
@@ -598,36 +606,54 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
sideList
.
set
(
sideList
.
indexOf
(
id
),
ArrayUtil
.
get
(
newIDsArray
,
ArrayUtil
.
indexOf
(
oldIDsArray
,
id
)));
}
}
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
dialog
.
setTitle
(
R
.
string
.
question
);
dialog
.
setMessage
(
R
.
string
.
find_deck_text
);
dialog
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
dialog
.
setLeftButtonText
(
R
.
string
.
Cancel
);
dialog
.
setRightButtonText
(
R
.
string
.
save_n_open
);
dialog
.
show
();
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
});
dialog
.
setRightButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
Deck
deck
;
//如果是卡组url
if
(
uri
!=
null
)
{
deck
=
new
Deck
(
uri
,
mainList
,
exList
,
sideList
);
if
(
isShowDialog
)
{
DialogPlus
dialog
=
new
DialogPlus
(
getContext
());
dialog
.
setTitle
(
R
.
string
.
question
);
dialog
.
setMessage
(
R
.
string
.
find_deck_text
);
dialog
.
setMessageGravity
(
Gravity
.
CENTER_HORIZONTAL
);
dialog
.
setLeftButtonText
(
R
.
string
.
Cancel
);
dialog
.
setRightButtonText
(
R
.
string
.
save_n_open
);
dialog
.
show
();
dialog
.
setLeftButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
});
dialog
.
setRightButtonListener
((
dlg
,
s
)
->
{
dialog
.
dismiss
();
saveAndOpenDeck
(
uri
,
mainList
,
exList
,
sideList
,
isCompleteDeck
);
});
}
else
{
if
(
isAdded
()
&&
isResumed
())
{
saveAndOpenDeck
(
uri
,
mainList
,
exList
,
sideList
,
isCompleteDeck
);
}
else
{
deck
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
mainList
,
exList
,
sideList
)
;
}
deck
.
setCompleteDeck
(
isCompleteDeck
)
;
File
file
=
deck
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
())
;
if
(!
deck
.
isCompleteDeck
())
{
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
tip_deckInfo_isNot_completeDeck
))
;
isShouldSaveAndOpenDeck
=
true
;
pendingUri
=
uri
;
pendingMainList
=
mainList
;
pendingExList
=
exList
;
pendingSideList
=
sideList
;
pendingIsCompleteDeck
=
isCompleteDeck
;
}
if
(!
file
.
getAbsolutePath
().
isEmpty
())
{
mBundle
.
putString
(
"setDeck"
,
file
.
getAbsolutePath
());
activity
.
fragment_deck_cards
.
setArguments
(
mBundle
);
}
activity
.
switchFragment
(
activity
.
fragment_deck_cards
,
2
,
true
);
});
}
}
private
void
saveAndOpenDeck
(
Uri
uri
,
List
<
Integer
>
mainList
,
List
<
Integer
>
exList
,
List
<
Integer
>
sideList
,
boolean
isCompleteDeck
)
{
Deck
deck
;
//如果是卡组url
if
(
uri
!=
null
)
{
deck
=
new
Deck
(
uri
,
mainList
,
exList
,
sideList
);
}
else
{
deck
=
new
Deck
(
getString
(
R
.
string
.
rename_deck
)
+
System
.
currentTimeMillis
(),
mainList
,
exList
,
sideList
);
}
deck
.
setCompleteDeck
(
isCompleteDeck
);
File
file
=
deck
.
saveTemp
(
AppsSettings
.
get
().
getDeckDir
());
if
(!
deck
.
isCompleteDeck
())
{
YGOUtil
.
showTextToast
(
activity
.
getString
(
R
.
string
.
tip_deckInfo_isNot_completeDeck
));
}
if
(!
file
.
getAbsolutePath
().
isEmpty
())
{
mBundle
.
putString
(
"setDeck"
,
file
.
getAbsolutePath
());
activity
.
fragment_deck_cards
.
setArguments
(
mBundle
);
}
activity
.
switchFragment
(
activity
.
fragment_deck_cards
,
2
,
true
);
}
@Override
...
...
@@ -725,6 +751,19 @@ public class HomeFragment extends BaseFragemnt implements OnDuelAssistantListene
BacktoDuel
();
//server list
mServerListManager
.
syncLoadData
();
if
(
isShouldSaveAndOpenDeck
&&
pendingMainList
!=
null
&&
pendingExList
!=
null
&&
pendingSideList
!=
null
)
{
saveAndOpenDeck
(
pendingUri
,
pendingMainList
,
pendingExList
,
pendingSideList
,
pendingIsCompleteDeck
);
isShouldSaveAndOpenDeck
=
false
;
pendingUri
=
null
;
pendingMainList
=
null
;
pendingExList
=
null
;
pendingSideList
=
null
;
pendingIsCompleteDeck
=
false
;
}
}
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
View file @
633dde66
...
...
@@ -6,11 +6,24 @@ import com.tencent.smtt.sdk.WebView;
import
com.tencent.smtt.sdk.WebViewClient
;
public
class
DefWebViewClient
extends
WebViewClient
{
private
static
final
int
CHECK_ID_WEB_VIEW
=
100
;
public
static
final
int
CHECK_ID_WEB_VIEW
=
100
;
public
static
final
int
CHECK_ID_WEB_VIEW_NEW_ACTIVITY
=
101
;
private
final
int
daCheckId
;
public
DefWebViewClient
()
{
this
(
CHECK_ID_WEB_VIEW
);
}
public
DefWebViewClient
(
int
daCheckId
)
{
super
();
this
.
daCheckId
=
daCheckId
;
}
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
if
(
url
.
startsWith
(
DARecord
.
DECK_URL_PREFIX
))
{
DuelAssistantManagement
.
getInstance
().
deckCheck
(
url
,
CHECK_ID_WEB_VIEW
);
DuelAssistantManagement
.
getInstance
().
deckCheck
(
url
,
daCheckId
);
return
true
;
}
return
false
;
...
...
mobile/src/main/res/values-es/strings.xml
View file @
633dde66
...
...
@@ -375,5 +375,7 @@
<string
name=
"replay_list"
>
lista de reproducción
</string>
<string
name=
"user_privacy_policy"
>
Política de Privacidad del Usuario
</string>
<string
name=
"about_user_privacy_policy"
>
Explicación de los permisos utilizados por YGOMobile
</string>
<string
name=
"open"
>
打开
</string>
<string
name=
"web_warn_save_deck"
>
打开卡组将关闭正在浏览的网页,是否关闭网页并打开卡组
</string>
</resources>
mobile/src/main/res/values-jp/strings.xml
View file @
633dde66
...
...
@@ -369,4 +369,6 @@
<string
name=
"replay_list"
>
リプレイ
</string>
<string
name=
"user_privacy_policy"
>
ユーザーのプライバシーポリシー
</string>
<string
name=
"about_user_privacy_policy"
>
このアプリが使用する権限についての説明
</string>
<string
name=
"open"
>
打开
</string>
<string
name=
"web_warn_save_deck"
>
打开卡组将关闭正在浏览的网页,是否关闭网页并打开卡组
</string>
</resources>
mobile/src/main/res/values-ko/strings.xml
View file @
633dde66
...
...
@@ -370,4 +370,6 @@
<string
name=
"replay_list"
>
재생 목록
</string>
<string
name=
"user_privacy_policy"
>
사용자 개인정보 보호정책
</string>
<string
name=
"about_user_privacy_policy"
>
이 앱에서 사용하는 권한에 대한 설명
</string>
<string
name=
"open"
>
打开
</string>
<string
name=
"web_warn_save_deck"
>
打开卡组将关闭正在浏览的网页,是否关闭网页并打开卡组
</string>
</resources>
mobile/src/main/res/values-zh/strings.xml
View file @
633dde66
...
...
@@ -369,4 +369,6 @@
<string
name=
"tip_download_OK"
>
已保存至
</string>
<string
name=
"user_privacy_policy"
>
用户隐私政策
</string>
<string
name=
"about_user_privacy_policy"
>
关于本应用使用的权限进行说明
</string>
<string
name=
"open"
>
打开
</string>
<string
name=
"web_warn_save_deck"
>
打开卡组将关闭正在浏览的网页,是否关闭网页并打开卡组
</string>
</resources>
mobile/src/main/res/values/strings.xml
View file @
633dde66
...
...
@@ -379,4 +379,6 @@
<string
name=
"card_related"
>
Related
</string>
<string
name=
"user_privacy_policy"
>
User Privacy Policy
</string>
<string
name=
"about_user_privacy_policy"
>
Explanation of the permissions used by YGOMObile
</string>
<string
name=
"open"
>
打开
</string>
<string
name=
"web_warn_save_deck"
>
打开卡组将关闭正在浏览的网页,是否关闭网页并打开卡组
</string>
</resources>
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