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
3fdc59b2
Commit
3fdc59b2
authored
Dec 28, 2022
by
Kazuyuki Hida
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WebViewの埋め込み
parent
897426a5
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
156 additions
and
2 deletions
+156
-2
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/DashboardActivity.java
+156
-2
No files found.
ABVJE_UI_Android/src/jp/agentec/abook/abv/ui/home/activity/DashboardActivity.java
View file @
3fdc59b2
package
jp
.
agentec
.
abook
.
abv
.
ui
.
home
.
activity
;
import
android.annotation.SuppressLint
;
import
android.net.Uri
;
import
android.os.Bundle
;
import
android.view.View
;
import
android.view.inputmethod.EditorInfo
;
import
android.webkit.ValueCallback
;
import
android.webkit.WebChromeClient
;
import
android.webkit.WebSettings
;
import
android.webkit.WebView
;
import
android.webkit.WebViewClient
;
import
android.widget.FrameLayout
;
import
android.widget.ImageButton
;
import
android.widget.LinearLayout
;
import
android.widget.ProgressBar
;
import
jp.agentec.abook.abv.bl.common.log.Logger
;
import
jp.agentec.abook.abv.launcher.android.R
;
import
jp.agentec.abook.abv.ui.viewer.view.CheckFormWebview
;
public
class
DashboardActivity
extends
OperationActivity
{
@SuppressWarnings
(
"unused"
)
private
static
final
String
TAG
=
"DashboardActivity"
;
private
WebView
webView
;
private
String
url
=
"https://abook188-1.abook.bz/acms/asp/login/"
;
private
ProgressBar
progress
;
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
super
.
onCreate
(
savedInstanceState
);
setContentView
(
R
.
layout
.
ac_operation_dashboard
);
createCommonToolber
();
ImageButton
reloadButton
=
findViewById
(
R
.
id
.
btn_reload
);
reloadButton
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
Logger
.
d
(
TAG
,
"ReloadUrl"
);
webView
.
loadUrl
(
url
+
"&reload=true"
);
}
});
progress
=
findViewById
(
R
.
id
.
refresh_prog
);
createWebView
();
FrameLayout
frameLayout
=
findViewById
(
R
.
id
.
frameWebView
);
frameLayout
.
addView
(
webView
,
new
LinearLayout
.
LayoutParams
(
FP
,
FP
));
// 読み込み
webView
.
loadUrl
(
url
);
}
@Override
protected
void
onStop
()
{
super
.
onStop
();
if
(
webView
!=
null
)
{
webView
.
stopLoading
();
}
}
@Override
protected
void
createCommonToolber
()
{
super
.
createCommonToolber
();
// ダッシュボード
mDashboardButton
.
setEnabled
(
false
);
}
private
void
createWebView
()
{
webView
=
new
CheckFormWebview
(
this
,
new
CheckFormWebview
.
KeyActionCallback
()
{
@Override
public
void
keyActionCallback
(
int
editorInfoAction
)
{
if
(
editorInfoAction
==
EditorInfo
.
IME_ACTION_GO
||
editorInfoAction
==
EditorInfo
.
IME_ACTION_NEXT
)
{
// キーボードの次ボタン検知
runOnUiThread
(
new
Runnable
()
{
@Override
public
void
run
()
{
Logger
.
i
(
TAG
,
"javascript:CHK.notifyMoveForcus()"
);
webView
.
loadUrl
(
"javascript:CHK.notifyMoveForcus()"
);
}
});
}
}
});
webView
.
setVisibility
(
View
.
VISIBLE
);
if
(
Logger
.
isDebugEnabled
())
{
WebView
.
setWebContentsDebuggingEnabled
(
true
);
//デバッグモード(chromeからinspect可)
}
initSettings
(
webView
.
getSettings
());
webView
.
setWebChromeClient
(
new
ChromeClient
());
webView
.
setWebViewClient
(
new
WebViewClient
());
// webView.addJavascriptInterface(jsInf, "android");
Logger
.
d
(
TAG
,
"loadUrl: "
+
url
);
}
@SuppressLint
(
"SetJavaScriptEnabled"
)
private
void
initSettings
(
WebSettings
settings
)
{
settings
.
setSupportMultipleWindows
(
true
);
// 新しいウィンドウを開くイベントを取得する
settings
.
setLoadsImagesAutomatically
(
true
);
// イメージを自動的にロードする
settings
.
setBuiltInZoomControls
(
true
);
// ズーム機能を有効にする
settings
.
setSupportZoom
(
true
);
// ズーム機能を有効にする
settings
.
setJavaScriptEnabled
(
true
);
// JavaScriptを有効にする
settings
.
setLoadWithOverviewMode
(
true
);
// 画面の横幅にページの横幅を合わせる
settings
.
setUseWideViewPort
(
true
);
// 画面の横幅にページの横幅を合わせる
//noinspection deprecation(API18から非推奨になった。無視)
settings
.
setPluginState
(
WebSettings
.
PluginState
.
ON
);
// 「EventHub.removeMessages(int what = 107) is not supported before the WebViewCore is set up.」のエラー対応(あまり効果ない?)
settings
.
setDomStorageEnabled
(
true
);
// WebStorage有効化
settings
.
setAppCacheEnabled
(
false
);
settings
.
setCacheMode
(
WebSettings
.
LOAD_NO_CACHE
);
settings
.
setAllowFileAccessFromFileURLs
(
true
);
//Android7利用で警告ダイヤログ表示問題対応
//ターゲットバージョン30以上からデフォルトがfalseに設定されている問題対応
settings
.
setAllowFileAccess
(
true
);
}
private
class
ChromeClient
extends
WebChromeClient
{
@Override
public
void
onProgressChanged
(
WebView
view
,
int
newProgress
)
{
if
(
progress
!=
null
)
{
progress
.
setVisibility
(
View
.
VISIBLE
);
if
(
newProgress
>=
100
)
{
progress
.
setVisibility
(
View
.
GONE
);
}
}
}
@Override
public
boolean
onShowFileChooser
(
WebView
webView
,
ValueCallback
<
Uri
[]>
filePathCallback
,
FileChooserParams
fileChooserParams
)
{
Logger
.
i
(
TAG
,
"oepnFile acceptType : %s"
,
fileChooserParams
.
getAcceptTypes
()[
0
]);
return
false
;
}
}
// private class JsInf {
//
// @JavascriptInterface
// public void existSetLocation(String ret) {
// Logger.d(TAG, "existSetLocation=%s", ret);
// if (ret != null && ret.equals("true")) { // setLocationメソッドが存在する場合、ページ読み込み完了とみなす
// isPageFinished = true;
// } else { // 存在しない場合、ページ読み込み未完了とみなし1秒後に再度呼出しを繰り返す
// handler.postDelayed(new Runnable() {
// @Override
// public void run() {
// callExistsSetLocation();
// }
// }, 1000);
// }
// }
//
// @JavascriptInterface
// public void existSendLog(String ret) {
// Logger.d(TAG, "existSendLog=%s", ret);
// if (ret != null && ret.equals("true")) {
// runOnUiThread(new Runnable() { // sendLogメソッドが存在する場合、呼び出す
// @Override
// public void run() {
// try {
// webView.loadUrl("javascript:sendLog()");
// } catch (Exception e) {
// Logger.e(TAG, "javascript:sendLog error. " + e.toString());
// }
// }
// });
// } else {
// finishActivity();
// }
// }
//
// @JavascriptInterface
// public void getAttachedDataUrl(String taskKey, String data) {
// commonAttachedDataUrl(taskKey, data);
// }
// }
}
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