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
013927d2
Commit
013927d2
authored
Jan 12, 2025
by
Dark Zane
Committed by
GitHub
Jan 12, 2025
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'fallenstardust:master' into master
parents
bb31231c
f6ae818f
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
117 additions
and
2 deletions
+117
-2
mobile/build.gradle
mobile/build.gradle
+1
-1
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
+6
-1
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+103
-0
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
...in/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
+7
-0
No files found.
mobile/build.gradle
View file @
013927d2
...
@@ -105,7 +105,7 @@ dependencies {
...
@@ -105,7 +105,7 @@ dependencies {
implementation
'com.nightonke:boommenu:2.1.0'
implementation
'com.nightonke:boommenu:2.1.0'
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
implementation
fileTree
(
dir:
'libs'
,
include:
[
'*.jar'
])
//dialog库
//dialog库
implementation
'com.github.feihuaduo:DialogUtils:1.8.9.
23
'
implementation
'com.github.feihuaduo:DialogUtils:1.8.9.
31
'
//recyclerview的adapter库
//recyclerview的adapter库
implementation
'io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.14'
implementation
'io.github.cymchad:BaseRecyclerViewAdapterHelper:3.0.14'
implementation
'androidx.appcompat:appcompat:1.7.0'
implementation
'androidx.appcompat:appcompat:1.7.0'
...
...
mobile/src/main/java/cn/garymb/ygomobile/bean/Deck.java
View file @
013927d2
...
@@ -79,7 +79,12 @@ public class Deck implements Parcelable {
...
@@ -79,7 +79,12 @@ public class Deck implements Parcelable {
public
Uri
toUri
()
{
public
Uri
toUri
()
{
Map
<
String
,
String
>
map
=
new
HashMap
<>();
Map
<
String
,
String
>
map
=
new
HashMap
<>();
map
.
put
(
Constants
.
QUERY_NAME
,
name
);
String
deckName
=
name
;
int
ydkIndex
=
deckName
.
indexOf
(
YDK_FILE_EX
);
if
(
ydkIndex
!=
-
1
)
{
deckName
=
deckName
.
substring
(
0
,
ydkIndex
);
}
map
.
put
(
Constants
.
QUERY_NAME
,
deckName
);
return
YGODAUtil
.
toUri
(
mainlist
,
extraList
,
sideList
,
map
);
return
YGODAUtil
.
toUri
(
mainlist
,
extraList
,
sideList
,
map
);
}
}
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
013927d2
package
cn.garymb.ygomobile.ui.activities
;
package
cn.garymb.ygomobile.ui.activities
;
import
static
cn
.
garymb
.
ygomobile
.
utils
.
DownloadUtil
.
TYPE_DOWNLOAD_EXCEPTION
;
import
android.annotation.SuppressLint
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Bundle
;
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.MenuItem
;
import
android.view.View
;
import
android.view.View
;
import
android.view.inputmethod.EditorInfo
;
import
android.view.inputmethod.EditorInfo
;
...
@@ -12,23 +19,36 @@ import android.widget.EditText;
...
@@ -12,23 +19,36 @@ import android.widget.EditText;
import
android.widget.ImageButton
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.LinearLayout
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
androidx.annotation.NonNull
;
import
androidx.annotation.Nullable
;
import
androidx.annotation.Nullable
;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.appcompat.widget.Toolbar
;
import
com.tencent.smtt.sdk.DownloadListener
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
java.io.File
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.AppsSettings
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.Constants
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.file.FileActivity
;
import
cn.garymb.ygomobile.ui.file.FileActivity
;
import
cn.garymb.ygomobile.ui.file.FileOpenType
;
import
cn.garymb.ygomobile.ui.file.FileOpenType
;
import
cn.garymb.ygomobile.ui.mycard.MyCard
;
import
cn.garymb.ygomobile.ui.mycard.MyCard
;
import
cn.garymb.ygomobile.ui.mycard.bean.McUser
;
import
cn.garymb.ygomobile.ui.plus.DefWebChromeClient
;
import
cn.garymb.ygomobile.ui.plus.DefWebChromeClient
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.ui.widget.WebViewPlus
;
import
cn.garymb.ygomobile.utils.DownloadUtil
;
import
cn.garymb.ygomobile.utils.FileUtils
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.LogUtil
;
import
cn.garymb.ygomobile.utils.YGOUtil
;
import
cn.garymb.ygomobile.utils.glide.GlideCompat
;
import
ocgcore.DataManager
;
import
ocgcore.data.Card
;
import
ocgcore.data.Card
;
public
class
WebActivity
extends
BaseActivity
implements
View
.
OnClickListener
{
public
class
WebActivity
extends
BaseActivity
implements
View
.
OnClickListener
{
...
@@ -45,6 +65,35 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
...
@@ -45,6 +65,35 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
private
EditText
et_context_keyword
;
private
EditText
et_context_keyword
;
private
ImageButton
btn_context_search_close
,
btn_context_search_last
,
btn_context_search_next
;
private
ImageButton
btn_context_search_close
,
btn_context_search_last
,
btn_context_search_next
;
@SuppressLint
(
"HandlerLeak"
)
Handler
handler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
@NonNull
Message
msg
)
{
super
.
handleMessage
(
msg
);
switch
(
msg
.
what
)
{
case
DownloadUtil
.
TYPE_DOWNLOAD_ING
:
break
;
case
DownloadUtil
.
TYPE_DOWNLOAD_EXCEPTION
:
YGOUtil
.
showTextToast
(
getString
(
R
.
string
.
tip_download_failed
));
break
;
case
DownloadUtil
.
TYPE_DOWNLOAD_OK
:
if
(
msg
.
obj
.
toString
().
endsWith
(
Constants
.
YDK_FILE_EX
))
{
YGOUtil
.
showTextToast
(
Gravity
.
TOP
,
getString
(
R
.
string
.
tip_download_OK
)
+
getString
(
R
.
string
.
deck_list
),
Toast
.
LENGTH_SHORT
);
}
else
if
(
msg
.
obj
.
toString
().
endsWith
(
Constants
.
YRP_FILE_EX
))
{
YGOUtil
.
showTextToast
(
Gravity
.
TOP
,
getString
(
R
.
string
.
tip_download_OK
)
+
getString
(
R
.
string
.
replay_list
),
Toast
.
LENGTH_SHORT
);
}
else
if
(
msg
.
obj
.
toString
().
endsWith
(
Constants
.
YPK_FILE_EX
)
||
msg
.
obj
.
toString
().
endsWith
(
Constants
.
CORE_LIMIT_PATH
))
{
YGOUtil
.
showTextToast
(
Gravity
.
TOP
,
getString
(
R
.
string
.
ypk_installed
)
+
getString
(
R
.
string
.
restart_app
),
Toast
.
LENGTH_SHORT
);
DataManager
.
get
().
load
(
true
);
}
else
{
YGOUtil
.
showTextToast
(
Gravity
.
TOP
,
getString
(
R
.
string
.
tip_download_OK
)
+
AppsSettings
.
get
().
getResourcePath
(),
Toast
.
LENGTH_LONG
);
}
break
;
}
}
};
@Override
@Override
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
protected
void
onCreate
(
@Nullable
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
super
.
onCreate
(
savedInstanceState
);
...
@@ -79,6 +128,60 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
...
@@ -79,6 +128,60 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
return
false
;
return
false
;
};
};
et_context_keyword
.
setOnEditorActionListener
(
searchListener
);
et_context_keyword
.
setOnEditorActionListener
(
searchListener
);
//设置网页下载监听
mWebViewPlus
.
setDownloadListener
(
new
DownloadListener
()
{
@Override
public
void
onDownloadStart
(
String
url
,
String
userAgent
,
String
contentDisposition
,
String
mimetype
,
long
contentLength
)
{
String
fileName
=
""
;
try
{
//从contentDisposition获取文件名并转换urlcode为UTF-8
fileName
=
URLDecoder
.
decode
(
contentDisposition
.
substring
(
contentDisposition
.
lastIndexOf
(
"''"
)
+
2
),
"UTF-8"
);
}
catch
(
UnsupportedEncodingException
e
)
{
throw
new
RuntimeException
(
e
);
}
String
destFileDir
=
""
;
if
(
fileName
.
endsWith
(
Constants
.
YDK_FILE_EX
))
{
destFileDir
=
AppsSettings
.
get
().
getDeckDir
();
}
else
if
(
fileName
.
endsWith
(
Constants
.
YRP_FILE_EX
))
{
destFileDir
=
AppsSettings
.
get
().
getReplayDir
();
}
else
if
(
fileName
.
endsWith
(
Constants
.
CORE_LIMIT_PATH
)
||
fileName
.
endsWith
(
Constants
.
YPK_FILE_EX
))
{
destFileDir
=
AppsSettings
.
get
().
getExpansionsPath
().
getPath
();
}
else
if
(
fileName
.
endsWith
(
Constants
.
LUA_FILE_EX
))
{
destFileDir
=
AppsSettings
.
get
().
getSingleDir
();
}
else
{
//萌卡还有些什么文件格式后续可以添加
destFileDir
=
AppsSettings
.
get
().
getResourcePath
();
}
File
file
=
new
File
(
destFileDir
+
"/"
+
fileName
);
DownloadUtil
.
get
().
download
(
url
,
destFileDir
,
file
.
getName
(),
new
DownloadUtil
.
OnDownloadListener
()
{
@Override
public
void
onDownloadSuccess
(
File
file
)
{
Message
message
=
new
Message
();
message
.
what
=
DownloadUtil
.
TYPE_DOWNLOAD_OK
;
message
.
obj
=
file
.
getName
();
handler
.
sendMessage
(
message
);
}
@Override
public
void
onDownloading
(
int
progress
)
{
Message
message
=
new
Message
();
message
.
what
=
DownloadUtil
.
TYPE_DOWNLOAD_ING
;
message
.
arg1
=
progress
;
handler
.
sendMessage
(
message
);
}
@Override
public
void
onDownloadFailed
(
Exception
e
)
{
//下载失败后删除下载的文件
FileUtils
.
deleteFile
(
file
);
Message
message
=
new
Message
();
message
.
what
=
TYPE_DOWNLOAD_EXCEPTION
;
handler
.
sendMessage
(
message
);
}
});
}
});
}
}
@Override
@Override
...
...
mobile/src/main/java/cn/garymb/ygomobile/ui/plus/DefWebViewClient.java
View file @
013927d2
package
cn.garymb.ygomobile.ui.plus
;
package
cn.garymb.ygomobile.ui.plus
;
import
com.ourygo.lib.duelassistant.util.DARecord
;
import
com.ourygo.lib.duelassistant.util.DuelAssistantManagement
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebViewClient
;
import
com.tencent.smtt.sdk.WebViewClient
;
public
class
DefWebViewClient
extends
WebViewClient
{
public
class
DefWebViewClient
extends
WebViewClient
{
private
static
final
int
CHECK_ID_WEB_VIEW
=
100
;
@Override
@Override
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
public
boolean
shouldOverrideUrlLoading
(
WebView
view
,
String
url
)
{
if
(
url
.
startsWith
(
DARecord
.
DECK_URL_PREFIX
))
{
DuelAssistantManagement
.
getInstance
().
deckCheck
(
url
,
CHECK_ID_WEB_VIEW
);
return
true
;
}
return
false
;
return
false
;
}
}
}
}
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