From c2d8613d2c5183211130a8922ce4f81b0f4eb7ff Mon Sep 17 00:00:00 2001 From: Azuma Kasumi Date: Wed, 31 Aug 2022 15:20:11 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=E3=82=BF=E3=83=96=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E6=99=82webview=E3=81=AE=E7=94=9F=E6=88=90=E3=82=92=E3=82=84?= =?UTF-8?q?=E3=82=81=E3=82=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/ui/documentweb/DocumentWebClient.kt | 4 ++++ .../view/ui/documentweb/DocumentWebFragment.kt | 17 ++++++++++++++++- .../view/ui/documentweb/DocumentWebPresenter.kt | 10 ++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) 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 a2926e02..e5681a5b 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 @@ -28,6 +28,10 @@ class DocumentWebViewClient(private val webShare: DocumentWebShare): WebViewClie super.onPageFinished(view, url) webShare.presenter.hideLoadingProgressBar() webShare.presenter.updateAutoReloadState(false) + if (webShare.presenter.getClearHistoryFlg()) { + webShare.presenter.setClearHistoryFlg(false) + view!!.clearHistory(); + } } override fun onReceivedClientCertRequest(view: WebView?, request: ClientCertRequest?) { 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 9b0e7da7..18e88e08 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 @@ -46,6 +46,8 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { private var getUrl: String? = null // webViewからのアラート表示用変数 private var dialog: AlertDialog? = null + //閲覧履歴削除フラグ + private var clearHistoryFlg = false // スワイプのジェスチャー。折に触れて状態設定をする必要があるのでメンバーとして持つ。 // 必要とされるタイミング次第で null のままのことがある恐れがあるので lateinit にはしていない。 @@ -310,7 +312,11 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { private fun getSessionAndSetupWebView(view: View, url: String, lasturl: String?, urlLoading: Boolean) { CookieManager.getInstance().apply { setAcceptCookie(true) - webview = WebView(requireActivity()) + if (webview == null) { //webview生成 + webview = WebView(requireActivity()) + } else { // タブ選択時 + setClearHistoryFlg(true) + } view.findViewById(R.id.webviewLelativeLayout)?.let { it.addView(webview, 0, RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)) } @@ -520,6 +526,15 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { } } + //閲覧履歴削除フラグの設定 + override fun setClearHistoryFlg(clearHistory: Boolean) { + clearHistoryFlg = clearHistory + } + //閲覧履歴削除フラグの取得 + override fun getClearHistoryFlg(): Boolean { + return clearHistoryFlg + } + companion object { private const val TAG = "DocumentWebFragmentHandler" 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 8ce8d0ee..fa105ba2 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 @@ -49,4 +49,14 @@ interface DocumentWebPresenter { * webViewからのアラートをダイアログ表示 */ fun showDialog(message: String, view: WebView) + + /** + * 閲覧履歴の削除フラグ設定 + */ + fun setClearHistoryFlg(clearHistory: Boolean) + + /** + * 閲覧履歴の削除フラグ取得 + */ + fun getClearHistoryFlg(): Boolean } -- GitLab From e990382bcd22895275683a7ac8c26c982ae29c0f Mon Sep 17 00:00:00 2001 From: YUDAI YAMAGUCHI Date: Tue, 20 Sep 2022 17:31:32 +0900 Subject: [PATCH 2/2] =?UTF-8?q?=E3=82=BF=E3=83=96=E5=88=87=E3=82=8A?= =?UTF-8?q?=E6=9B=BF=E3=81=88=E6=99=82=E3=81=AB=E5=88=9D=E6=9C=9FURL?= =?UTF-8?q?=E3=81=A7=E3=81=82=E3=81=A3=E3=81=A6=E3=82=82=E5=86=8D=E8=AA=AD?= =?UTF-8?q?=E3=81=BF=E8=BE=BC=E3=81=BF=E3=81=99=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E5=A4=89=E6=9B=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../view/ui/documentweb/DocumentWebFragment.kt | 16 ++++++++++++++++ .../main/res/navigation/nav_create_document.xml | 4 ++++ app/src/main/res/navigation/nav_home.xml | 4 ++++ app/src/main/res/navigation/nav_search.xml | 4 ++++ app/src/main/res/navigation/nav_work.xml | 4 ++++ 5 files changed, 32 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 18e88e08..809a0d5b 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 @@ -48,6 +48,8 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { private var dialog: AlertDialog? = null //閲覧履歴削除フラグ private var clearHistoryFlg = false + // タブ選択時初期URLリロードするかどうか + private var reloadTab = false // スワイプのジェスチャー。折に触れて状態設定をする必要があるのでメンバーとして持つ。 // 必要とされるタイミング次第で null のままのことがある恐れがあるので lateinit にはしていない。 @@ -73,6 +75,12 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { } if(getUrl != holdUrl){ applyCookieManager(holdUrl, true) + } else { + if (reloadTab) { + webview?.let { + it.reload() + } + } } } } @@ -83,6 +91,9 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { super.onViewCreated(view, savedInstanceState) webShare = DocumentWebShare(this, DocumentWebDownloader(this, RC_CHOOSE_FILE, RC_SAVE_FILE)) arguments?.let { + DocumentWebFragmentArgs.fromBundle(it).tabChengeReload?.let { + reloadTab = it + } connectUrl = DocumentWebFragmentArgs.fromBundle(it).url if (!connectUrl!!.contains(AwApp.Baseurl())) { connectUrl = AwApp.Baseurl() + connectUrl @@ -316,6 +327,11 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { webview = WebView(requireActivity()) } else { // タブ選択時 setClearHistoryFlg(true) + webview?.let { + if (reloadTab && it.url == url) { + it.reload() + } + } } view.findViewById(R.id.webviewLelativeLayout)?.let { it.addView(webview, 0, RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.FILL_PARENT)) diff --git a/app/src/main/res/navigation/nav_create_document.xml b/app/src/main/res/navigation/nav_create_document.xml index d6e6e28f..aad3c1ce 100644 --- a/app/src/main/res/navigation/nav_create_document.xml +++ b/app/src/main/res/navigation/nav_create_document.xml @@ -12,5 +12,9 @@ android:name="url" android:defaultValue="Broker/Mobile#formSelection" app:argType="string" /> + diff --git a/app/src/main/res/navigation/nav_home.xml b/app/src/main/res/navigation/nav_home.xml index 632085b8..ca29d6b9 100644 --- a/app/src/main/res/navigation/nav_home.xml +++ b/app/src/main/res/navigation/nav_home.xml @@ -12,5 +12,9 @@ android:name="url" android:defaultValue="Broker/Mobile#home" app:argType="string" /> + diff --git a/app/src/main/res/navigation/nav_search.xml b/app/src/main/res/navigation/nav_search.xml index b6490f8b..771a29dc 100644 --- a/app/src/main/res/navigation/nav_search.xml +++ b/app/src/main/res/navigation/nav_search.xml @@ -12,5 +12,9 @@ android:name="url" android:defaultValue="Broker/Mobile#agileWorksSearch" app:argType="string" /> + diff --git a/app/src/main/res/navigation/nav_work.xml b/app/src/main/res/navigation/nav_work.xml index 4a3d37f0..8d5cbda0 100644 --- a/app/src/main/res/navigation/nav_work.xml +++ b/app/src/main/res/navigation/nav_work.xml @@ -12,5 +12,9 @@ android:name="url" android:defaultValue="Broker/Mobile#work" app:argType="string" /> + -- GitLab