From 5bf2c1d6bd9806a3ec877cc6163f7aee0a900fd6 Mon Sep 17 00:00:00 2001 From: S-6203-ATLED Date: Mon, 4 Jul 2022 18:25:26 +0900 Subject: [PATCH 1/4] =?UTF-8?q?#96=20=E3=82=A2=E3=83=A9=E3=83=BC=E3=83=88?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E4=B8=AD=E3=81=AB=E3=82=A6=E3=82=A3=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=83=88=E3=81=8B=E3=82=89=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=8C?= =?UTF-8?q?=E7=9C=9F=E3=81=A3=E7=99=BD=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D?= =?UTF-8?q?=E5=85=B7=E5=90=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/ui/documentweb/DocumentWebClient.kt | 9 +++++++++ .../view/ui/documentweb/DocumentWebFragment.kt | 16 ++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt index f60f8729..70cd2f61 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt @@ -95,4 +95,13 @@ class DocumentWebChromeClient(private val webShare: DocumentWebShare) : WebChrom false } } + // webViewからのアラートを取得、表示 + override fun onJsAlert(view: WebView?, url: String?, message: String?, result: JsResult?): Boolean { + if (message != null && view != null) { + DocumentWebFragment().showDialog(message, view) + } + result?.confirm() + // webViewでは表示せずアプリ標準の方で表示する + return true + } } \ No newline at end of file diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt index b6515602..b302f726 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt @@ -1,6 +1,7 @@ package jp.atled.agileworks.view.ui.documentweb import android.annotation.SuppressLint +import android.app.AlertDialog import android.content.Context import android.content.Intent import android.net.ConnectivityManager @@ -40,6 +41,8 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { private var lastUrl: String? = null private var connectUrl: String? = null private var getUrl: String? = null + // webViewからのアラート表示用変数 + private var dialog: AlertDialog? = null // スワイプのジェスチャー。折に触れて状態設定をする必要があるのでメンバーとして持つ。 // 必要とされるタイミング次第で null のままのことがある恐れがあるので lateinit にはしていない。 @@ -425,6 +428,19 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { else -> {} } } + // webviewのアラートを表示 + fun showDialog(message: String, view: WebView) { + if (message != null && view != null) { + val builder = AlertDialog.Builder(view.getContext()) + builder.setTitle(R.string.login_alert_title) + .setMessage(message) + .setPositiveButton(R.string.login_alert_button_label) { _, _ -> } + .setCancelable(false) + // onStopでdismissするために変数へ保存 + dialog = builder.create() + dialog?.show() + } + } companion object { private const val TAG = "DocumentWebFragmentHandler" -- GitLab From 1316a70179ce9a9593940050d0b16dbd3be45087 Mon Sep 17 00:00:00 2001 From: S-6203-ATLED Date: Tue, 5 Jul 2022 11:21:05 +0900 Subject: [PATCH 2/4] =?UTF-8?q?#96=20=E3=82=A2=E3=83=A9=E3=83=BC=E3=83=88?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E4=B8=AD=E3=81=AB=E3=82=A6=E3=82=A3=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=83=88=E3=81=8B=E3=82=89=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=8C?= =?UTF-8?q?=E7=9C=9F=E3=81=A3=E7=99=BD=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D?= =?UTF-8?q?=E5=85=B7=E5=90=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agileworks/view/ui/documentweb/DocumentWebFragment.kt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt index b302f726..4b27c411 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt @@ -142,6 +142,14 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { // バックグラウンドかの情報 viewDataBinding?.viewModel?.setAppBackGroundStatus(true) } + // 画面を閉じた際にアラートが表示されていたら閉じる + override fun onDestroy() { + super.onDestroy() + dialog?.dismiss() + if (dialog != null) { + dialog = null + } + } @SuppressLint("ClickableViewAccessibility") private fun setClickListeners() { -- GitLab From 8da25b426572686fc97e2ec18a3c6e6cd1b559b6 Mon Sep 17 00:00:00 2001 From: S-6203-ATLED Date: Tue, 5 Jul 2022 11:49:37 +0900 Subject: [PATCH 3/4] =?UTF-8?q?#96=20=E3=82=A2=E3=83=A9=E3=83=BC=E3=83=88?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E4=B8=AD=E3=81=AB=E3=82=A6=E3=82=A3=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=83=88=E3=81=8B=E3=82=89=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=8C?= =?UTF-8?q?=E7=9C=9F=E3=81=A3=E7=99=BD=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D?= =?UTF-8?q?=E5=85=B7=E5=90=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../agileworks/view/ui/documentweb/DocumentWebClient.kt | 2 +- .../agileworks/view/ui/documentweb/DocumentWebFragment.kt | 4 ++-- .../agileworks/view/ui/documentweb/DocumentWebPresenter.kt | 7 +++++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt index 70cd2f61..75566769 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebClient.kt @@ -98,7 +98,7 @@ class DocumentWebChromeClient(private val webShare: DocumentWebShare) : WebChrom // webViewからのアラートを取得、表示 override fun onJsAlert(view: WebView?, url: String?, message: String?, result: JsResult?): Boolean { if (message != null && view != null) { - DocumentWebFragment().showDialog(message, view) + webShare.presenter.showDialog(message, view) } result?.confirm() // webViewでは表示せずアプリ標準の方で表示する diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt index 4b27c411..bce954aa 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt @@ -436,8 +436,8 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { else -> {} } } - // webviewのアラートを表示 - fun showDialog(message: String, view: WebView) { + // webviewのアラートを表示、WebPresenterで宣言 + override fun showDialog(message: String, view: WebView) { if (message != null && view != null) { val builder = AlertDialog.Builder(view.getContext()) builder.setTitle(R.string.login_alert_title) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt index 71468c2d..8ce8d0ee 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebPresenter.kt @@ -1,5 +1,7 @@ package jp.atled.agileworks.view.ui.documentweb +import android.webkit.WebView + /** * 書類ビューにて見た目を反映させるインターフェース。 * 書類ビュー関連の各クラスはこれを通して表示の変更をリクエストする。 @@ -42,4 +44,9 @@ interface DocumentWebPresenter { * ネットワーク切断時View表示フラグ更新 */ fun updateDisconnectViewDisplayState(url: String) + + /** + * webViewからのアラートをダイアログ表示 + */ + fun showDialog(message: String, view: WebView) } -- GitLab From 4a803bf5151ab9437fc58b39e1702a220cb96ec8 Mon Sep 17 00:00:00 2001 From: S-6203-ATLED Date: Tue, 5 Jul 2022 11:57:31 +0900 Subject: [PATCH 4/4] =?UTF-8?q?#96=20=E3=82=A2=E3=83=A9=E3=83=BC=E3=83=88?= =?UTF-8?q?=E8=A1=A8=E7=A4=BA=E4=B8=AD=E3=81=AB=E3=82=A6=E3=82=A3=E3=82=B8?= =?UTF-8?q?=E3=82=A7=E3=83=83=E3=83=88=E3=81=8B=E3=82=89=E8=B5=B7=E5=8B=95?= =?UTF-8?q?=E3=81=97=E3=81=9F=E9=9A=9B=E3=81=AB=E7=94=BB=E9=9D=A2=E3=81=8C?= =?UTF-8?q?=E7=9C=9F=E3=81=A3=E7=99=BD=E3=81=AB=E3=81=AA=E3=82=8B=E4=B8=8D?= =?UTF-8?q?=E5=85=B7=E5=90=88=E4=BF=AE=E6=AD=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt index bce954aa..66dac2ba 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/documentweb/DocumentWebFragment.kt @@ -444,7 +444,7 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { .setMessage(message) .setPositiveButton(R.string.login_alert_button_label) { _, _ -> } .setCancelable(false) - // onStopでdismissするために変数へ保存 + // onDestroyでdismissするために変数へ保存 dialog = builder.create() dialog?.show() } -- GitLab