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
a8377931
Commit
a8377931
authored
Jun 25, 2020
by
yuichiro ogawa
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#38370 PDFダウンロード処理の実装
parent
288b8b71
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
6 deletions
+75
-6
ABVJE_Res_Default_Android/res/drawable-xhdpi/home_print_white.png
+0
-0
ABVJE_Res_Default_Android/res/drawable/btn_operation_print_white.xml
+9
-0
ABVJE_UI_Android/res/layout/ac_html_webview.xml
+1
-1
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
+28
-5
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/viewer/activity/OnlineHTMLWebViewActivity.java
+37
-0
No files found.
ABVJE_Res_Default_Android/res/drawable-xhdpi/home_print_white.png
0 → 100644
View file @
a8377931
816 Bytes
ABVJE_Res_Default_Android/res/drawable/btn_operation_print_white.xml
0 → 100644
View file @
a8377931
<?xml version="1.0" encoding="utf-8"?>
<selector
xmlns:android=
"http://schemas.android.com/apk/res/android"
>
<item
android:state_enabled=
"false"
android:drawable=
"@drawable/home_print_off"
/>
<item
android:drawable=
"@drawable/home_print_white"
/>
</selector>
\ No newline at end of file
ABVJE_UI_Android/res/layout/ac_html_webview.xml
View file @
a8377931
...
@@ -133,7 +133,7 @@
...
@@ -133,7 +133,7 @@
android:layout_height=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"10dp"
android:layout_marginRight=
"10dp"
android:layout_weight=
"1"
android:layout_weight=
"1"
android:background=
"@drawable/btn_operation_print"
android:background=
"@drawable/btn_operation_print
_white
"
android:contentDescription=
"@string/print"
android:contentDescription=
"@string/print"
android:visibility=
"gone"
/>
android:visibility=
"gone"
/>
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/launcher/android/OnAppDownloadReceiver.java
View file @
a8377931
package
jp
.
agentec
.
abook
.
abv
.
launcher
.
android
;
package
jp
.
agentec
.
abook
.
abv
.
launcher
.
android
;
import
java.io.File
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
android.app.DownloadManager
;
import
android.app.DownloadManager
;
import
android.content.BroadcastReceiver
;
import
android.content.BroadcastReceiver
;
import
android.content.Context
;
import
android.content.Context
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.database.Cursor
;
import
android.net.Uri
;
import
android.net.Uri
;
import
android.os.Environment
;
import
android.os.Environment
;
import
android.util.Log
;
import
android.widget.Toast
;
import
android.widget.Toast
;
import
java.io.File
;
import
jp.agentec.abook.abv.bl.common.ABVEnvironment
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
static
android
.
content
.
ContentValues
.
TAG
;
/**
/**
* 新しいAPKのダウンロードが完了したときの通知を受け取る
* 新しいAPKのダウンロードが完了したときの通知を受け取る
* @author jang
* @author jang
...
@@ -26,6 +30,25 @@ public class OnAppDownloadReceiver extends BroadcastReceiver {
...
@@ -26,6 +30,25 @@ public class OnAppDownloadReceiver extends BroadcastReceiver {
long
id
=
intent
.
getLongExtra
(
DownloadManager
.
EXTRA_DOWNLOAD_ID
,
-
1
);
long
id
=
intent
.
getLongExtra
(
DownloadManager
.
EXTRA_DOWNLOAD_ID
,
-
1
);
Logger
.
d
(
"Download Complete ID : "
+
id
);
Logger
.
d
(
"Download Complete ID : "
+
id
);
DownloadManager
dm
=
(
DownloadManager
)
context
.
getSystemService
(
context
.
DOWNLOAD_SERVICE
);
final
Cursor
cursor
;
if
(
dm
!=
null
)
{
cursor
=
dm
.
query
(
new
DownloadManager
.
Query
().
setFilterById
(
id
));
if
(
cursor
.
moveToFirst
())
{
final
String
downloadedTo
=
cursor
.
getString
(
cursor
.
getColumnIndex
(
DownloadManager
.
COLUMN_LOCAL_URI
));
Log
.
d
(
TAG
,
"The file has been downloaded to: "
+
downloadedTo
);
if
(
downloadedTo
!=
null
&&
downloadedTo
.
endsWith
(
".pdf"
))
{
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
;
}
}
}
if
(
id
==
-
1
)
{
if
(
id
==
-
1
)
{
// ダウンロードマネージャの通知領域をクリックした場合はメッセージ表示のみ
// ダウンロードマネージャの通知領域をクリックした場合はメッセージ表示のみ
Toast
.
makeText
(
context
,
intent
.
getAction
(),
Toast
.
LENGTH_LONG
).
show
();
Toast
.
makeText
(
context
,
intent
.
getAction
(),
Toast
.
LENGTH_LONG
).
show
();
...
...
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/viewer/activity/OnlineHTMLWebViewActivity.java
View file @
a8377931
package
jp
.
agentec
.
abook
.
abv
.
ui
.
viewer
.
activity
;
package
jp
.
agentec
.
abook
.
abv
.
ui
.
viewer
.
activity
;
import
android.app.DownloadManager
;
import
android.content.Intent
;
import
android.content.Intent
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.os.Bundle
;
import
android.os.Environment
;
import
android.view.View
;
import
android.view.View
;
import
android.view.Window
;
import
android.view.Window
;
import
android.webkit.CookieManager
;
import
android.webkit.DownloadListener
;
import
android.webkit.URLUtil
;
import
android.webkit.WebSettings
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.webkit.WebViewClient
;
import
android.widget.Button
;
import
android.widget.Button
;
import
android.widget.TextView
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
java.util.HashMap
;
import
java.util.HashMap
;
import
java.util.Map
;
import
java.util.Map
;
...
@@ -92,6 +99,36 @@ public class OnlineHTMLWebViewActivity extends ABVContentViewActivity {
...
@@ -92,6 +99,36 @@ public class OnlineHTMLWebViewActivity extends ABVContentViewActivity {
return
false
;
return
false
;
}
}
});
});
webView
.
setDownloadListener
(
new
DownloadListener
()
{
@Override
public
void
onDownloadStart
(
String
url
,
String
userAgent
,
String
contentDisposition
,
String
mimetype
,
long
contentLength
)
{
DownloadManager
.
Request
request
=
new
DownloadManager
.
Request
(
Uri
.
parse
(
url
));
final
String
fileName
=
URLUtil
.
guessFileName
(
url
,
contentDisposition
,
mimetype
);
request
.
setMimeType
(
mimetype
);
//------------------------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
();
}
});
}
}
@Override
@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