Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
abook_check
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abook_android
abook_check
Commits
1c959ce9
Commit
1c959ce9
authored
Aug 24, 2020
by
yuichiro ogawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#39283 ファイルダウンロード処理
parent
57d0dce7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
32 additions
and
8 deletions
+32
-8
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
+1
-2
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ChatWebviewActivity.java
+31
-6
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
View file @
1c959ce9
...
...
@@ -42,10 +42,9 @@ public class OnAppDownloadReceiver extends BroadcastReceiver {
cursor
.
getColumnIndex
(
DownloadManager
.
COLUMN_LOCAL_URI
));
Log
.
d
(
TAG
,
"The file has been downloaded to: "
+
downloadedTo
);
if
(
downloadedTo
!=
null
&&
downloadedTo
.
endsWith
(
".pdf
"
))
{
if
(
downloadedTo
!=
null
&&
!
downloadedTo
.
endsWith
(
".apk
"
))
{
Toast
.
makeText
(
context
,
context
.
getResources
().
getString
(
R
.
string
.
download_success
),
//To notify the Client that the file is being downloaded
Toast
.
LENGTH_LONG
).
show
();
// PDFファイルの場合はAPK用の処理は通過させない
return
;
}
}
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/ChatWebviewActivity.java
View file @
1c959ce9
...
...
@@ -20,11 +20,14 @@ import android.security.NetworkSecurityPolicy;
import
android.view.KeyEvent
;
import
android.view.View
;
import
android.view.Window
;
import
android.webkit.CookieManager
;
import
android.webkit.DownloadListener
;
import
android.webkit.JavascriptInterface
;
import
android.webkit.JsResult
;
import
android.webkit.URLUtil
;
import
android.webkit.ValueCallback
;
import
android.webkit.WebChromeClient
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.ImageButton
;
...
...
@@ -35,6 +38,8 @@ import android.widget.Toast;
import
java.io.File
;
import
java.io.FileOutputStream
;
import
java.io.OutputStream
;
import
java.net.MalformedURLException
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Objects
;
...
...
@@ -112,8 +117,11 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
mChatWebView
.
setOverScrollMode
(
View
.
OVER_SCROLL_NEVER
);
//オーバースクロールしない。
mChatWebView
.
setVerticalScrollBarEnabled
(
false
);
//スクロールバーを消す。
mChatWebView
.
getSettings
().
setJavaScriptEnabled
(
true
);
//Javascriptを有効にする。
// mChatWebView.setWebContentsDebuggingEnabled(true);
WebSettings
settings
=
mChatWebView
.
getSettings
();
settings
.
setJavaScriptEnabled
(
true
);
//Javascriptを有効にする。
settings
.
setAppCacheEnabled
(
false
);
settings
.
setCacheMode
(
WebSettings
.
LOAD_NO_CACHE
);
if
(
Logger
.
isDebugEnabled
())
{
mChatWebView
.
setWebContentsDebuggingEnabled
(
true
);
//デバッグモード(chromeからinspect可)
}
...
...
@@ -268,9 +276,26 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
public
void
onDownloadStart
(
String
url
,
String
userAgent
,
String
contentDisposition
,
String
mimetype
,
long
contentLength
)
{
Intent
i
=
new
Intent
(
Intent
.
ACTION_VIEW
);
i
.
setData
(
Uri
.
parse
(
url
));
startActivity
(
i
);
Uri
uri
=
Uri
.
parse
(
url
);
DownloadManager
.
Request
request
=
new
DownloadManager
.
Request
(
uri
);
final
String
fileName
=
uri
.
getQueryParameter
(
"fileName"
);
//------------------------COOKIE!!------------------------
String
cookies
=
CookieManager
.
getInstance
().
getCookie
(
url
);
request
.
addRequestHeader
(
"cookie"
,
cookies
);
//------------------------COOKIE!!------------------------
request
.
addRequestHeader
(
"User-Agent"
,
userAgent
);
request
.
setTitle
(
fileName
);
request
.
allowScanningByMediaScanner
();
request
.
setNotificationVisibility
(
DownloadManager
.
Request
.
VISIBILITY_VISIBLE_NOTIFY_COMPLETED
);
//Notify client once download is completed!
request
.
setDestinationInExternalPublicDir
(
Environment
.
DIRECTORY_DOWNLOADS
,
fileName
);
DownloadManager
dm
=
(
DownloadManager
)
getSystemService
(
DOWNLOAD_SERVICE
);
if
(
dm
!=
null
)
{
dm
.
enqueue
(
request
);
}
Toast
.
makeText
(
getApplicationContext
(),
getString
(
R
.
string
.
download_start
),
//To notify the Client that the file is being downloaded
Toast
.
LENGTH_LONG
).
show
();
}
});
...
...
@@ -317,7 +342,7 @@ public class ChatWebviewActivity extends ParentWebViewActivity {
}
else
{
// その他のファイルはurlのみ確認
Logger
.
d
(
"download "
,
"download URL :"
+
url
);
}
return
tru
e
;
return
fals
e
;
}
// @Override
...
...
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