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
b02ca6b3
Commit
b02ca6b3
authored
Aug 09, 2023
by
fallenstardust
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
网页文件上传
打开文件选择并回调
parent
bee4c504
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
10 deletions
+56
-10
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
...n/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
+56
-10
No files found.
mobile/src/main/java/cn/garymb/ygomobile/ui/activities/WebActivity.java
View file @
b02ca6b3
...
@@ -9,6 +9,7 @@ import static cn.garymb.ygomobile.utils.DownloadUtil.TYPE_DOWNLOAD_EXCEPTION;
...
@@ -9,6 +9,7 @@ import static cn.garymb.ygomobile.utils.DownloadUtil.TYPE_DOWNLOAD_EXCEPTION;
import
android.annotation.SuppressLint
;
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.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.os.Message
;
...
@@ -29,6 +30,10 @@ import androidx.annotation.Nullable;
...
@@ -29,6 +30,10 @@ import androidx.annotation.Nullable;
import
androidx.appcompat.widget.Toolbar
;
import
androidx.appcompat.widget.Toolbar
;
import
com.tencent.smtt.export.external.interfaces.IX5WebViewBase
;
import
com.tencent.smtt.export.external.interfaces.IX5WebViewBase
;
import
com.tencent.smtt.sdk.ValueCallback
;
import
com.tencent.smtt.sdk.WebChromeClient
;
import
com.tencent.smtt.sdk.WebView
;
import
com.tencent.smtt.sdk.WebViewClient
;
import
java.io.File
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.FileInputStream
;
...
@@ -44,6 +49,7 @@ import cn.garymb.ygomobile.bean.ServerList;
...
@@ -44,6 +49,7 @@ import cn.garymb.ygomobile.bean.ServerList;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.lite.R
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.MainActivity
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
import
cn.garymb.ygomobile.ui.home.ServerListManager
;
import
cn.garymb.ygomobile.ui.plus.DefWebChromeClient
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
import
cn.garymb.ygomobile.ui.plus.VUiKit
;
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.DownloadUtil
;
...
@@ -57,8 +63,10 @@ import cn.garymb.ygomobile.utils.YGOUtil;
...
@@ -57,8 +63,10 @@ import cn.garymb.ygomobile.utils.YGOUtil;
import
ocgcore.DataManager
;
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
{
private
static
String
TAG
=
"WebActivity"
;
private
static
String
TAG
=
"WebActivity"
;
private
static
final
int
FILE_CHOOSER_REQUEST
=
100
;
private
ValueCallback
<
Uri
[]>
mFilePathCallback
;
/* 全局存储了扩展卡版本号,会被其他activity使用 */
/* 全局存储了扩展卡版本号,会被其他activity使用 */
private
static
String
exCardVer
;
private
static
String
exCardVer
;
private
WebViewPlus
mWebViewPlus
;
private
WebViewPlus
mWebViewPlus
;
...
@@ -136,18 +144,16 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
...
@@ -136,18 +144,16 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
serverInfos
=
new
ArrayList
<>();
serverInfos
=
new
ArrayList
<>();
xmlFile
=
new
File
(
this
.
getFilesDir
(),
Constants
.
SERVER_FILE
);
xmlFile
=
new
File
(
this
.
getFilesDir
(),
Constants
.
SERVER_FILE
);
initButton
();
initButton
();
/
*
mWebViewPlus.enableHtml5();
/
/
mWebViewPlus.enableHtml5();
mWebViewPlus
.
setWebChromeClient
(
new
DefWebChromeClient
()
{
mWebViewPlus
.
setWebChromeClient
(
new
DefWebChromeClient
()
{
@Override
@Override
public void onReceivedTitle(WebView view, String title) {
public
boolean
onShowFileChooser
(
WebView
webView
,
ValueCallback
<
Uri
[]>
filePathCallback
,
WebChromeClient
.
FileChooserParams
fileChooserParams
)
{
super.onReceivedTitle(view, title);
Log
.
i
(
TAG
,
"openFileChooser: "
+
fileChooserParams
.
getMode
());
if (toolbar != null) {
mFilePathCallback
=
filePathCallback
;
toolbar.setSubtitle(title);
openFileChooseProcess
(
fileChooserParams
.
getMode
()
==
FileChooserParams
.
MODE_OPEN_MULTIPLE
);
} else {
return
true
;
setTitle(title);
}
}
}
});
*/
});
if
(
doIntent
(
getIntent
()))
{
if
(
doIntent
(
getIntent
()))
{
mWebViewPlus
.
loadUrl
(
mUrl
);
mWebViewPlus
.
loadUrl
(
mUrl
);
if
(
mUrl
.
startsWith
(
URL_YGO233_ADVANCE
))
{
if
(
mUrl
.
startsWith
(
URL_YGO233_ADVANCE
))
{
...
@@ -168,6 +174,35 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
...
@@ -168,6 +174,35 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
et_context_keyword
.
setOnEditorActionListener
(
searchListener
);
et_context_keyword
.
setOnEditorActionListener
(
searchListener
);
}
}
@Override
protected
void
onActivityResult
(
int
requestCode
,
int
resultCode
,
@Nullable
Intent
data
)
{
super
.
onActivityResult
(
requestCode
,
resultCode
,
data
);
if
(
requestCode
==
FILE_CHOOSER_REQUEST
)
{
if
(
resultCode
==
RESULT_OK
)
{
if
(
mFilePathCallback
!=
null
)
{
if
(
data
!=
null
&&
data
.
getClipData
()
!=
null
)
{
//有选择多个文件
int
count
=
data
.
getClipData
().
getItemCount
();
Log
.
i
(
TAG
,
"url count : "
+
count
);
Uri
[]
uris
=
new
Uri
[
count
];
int
currentItem
=
0
;
while
(
currentItem
<
count
)
{
Uri
fileUri
=
data
.
getClipData
().
getItemAt
(
currentItem
).
getUri
();
uris
[
currentItem
]
=
fileUri
;
currentItem
=
currentItem
+
1
;
}
mFilePathCallback
.
onReceiveValue
(
uris
);
}
else
{
Uri
result
=
data
==
null
?
null
:
data
.
getData
();
Log
.
e
(
TAG
,
""
+
result
);
mFilePathCallback
.
onReceiveValue
(
new
Uri
[]{
result
});
}
mFilePathCallback
=
null
;
}
}
}
}
@Override
@Override
protected
void
onNewIntent
(
Intent
intent
)
{
protected
void
onNewIntent
(
Intent
intent
)
{
super
.
onNewIntent
(
intent
);
super
.
onNewIntent
(
intent
);
...
@@ -287,6 +322,17 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
...
@@ -287,6 +322,17 @@ public class WebActivity extends BaseActivity implements View.OnClickListener {
context
.
startActivity
(
intent
);
context
.
startActivity
(
intent
);
}
}
private
void
openFileChooseProcess
(
boolean
isMulti
)
{
Intent
intent
=
new
Intent
(
Intent
.
ACTION_GET_CONTENT
);
intent
.
addCategory
(
Intent
.
CATEGORY_DEFAULT
);
intent
.
setType
(
"*/*"
);
if
(
isMulti
)
{
Log
.
e
(
TAG
,
"putExtra"
);
intent
.
putExtra
(
Intent
.
EXTRA_ALLOW_MULTIPLE
,
true
);
}
startActivityForResult
(
Intent
.
createChooser
(
intent
,
"FileChooser"
),
FILE_CHOOSER_REQUEST
);
}
public
static
void
openFAQ
(
Context
context
,
Card
cardInfo
)
{
public
static
void
openFAQ
(
Context
context
,
Card
cardInfo
)
{
String
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
getCode
())
+
"#faq"
;
String
uri
=
Constants
.
WIKI_SEARCH_URL
+
String
.
format
(
"%08d"
,
cardInfo
.
getCode
())
+
"#faq"
;
WebActivity
.
open
(
context
,
cardInfo
.
Name
,
uri
);
WebActivity
.
open
(
context
,
cardInfo
.
Name
,
uri
);
...
...
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