From 9115294793cf4c2012a933995a171f0b8478bbae Mon Sep 17 00:00:00 2001 From: S-6203-ATLED Date: Mon, 6 Jun 2022 15:13:03 +0900 Subject: [PATCH] =?UTF-8?q?#89=20=E3=83=84=E3=83=BC=E3=83=AB=E3=83=90?= =?UTF-8?q?=E3=83=BC=E3=81=AE=E3=82=BF=E3=82=A4=E3=83=88=E3=83=AB=E3=82=92?= =?UTF-8?q?URL=E4=BE=9D=E5=AD=98=E3=81=8B=E3=82=89=E9=81=B8=E6=8A=9E?= =?UTF-8?q?=E3=81=97=E3=81=A6=E3=81=84=E3=82=8B=E3=82=BF=E3=83=96=E4=BE=9D?= =?UTF-8?q?=E5=AD=98=E3=81=AB=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 | 2 +- .../ui/documentweb/DocumentWebFragment.kt | 24 +++++-------------- .../ui/documentweb/DocumentWebPresenter.kt | 2 +- .../res/navigation/nav_create_document.xml | 6 +---- app/src/main/res/navigation/nav_home.xml | 6 +---- app/src/main/res/navigation/nav_search.xml | 6 +---- app/src/main/res/navigation/nav_work.xml | 6 +---- 7 files changed, 12 insertions(+), 40 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 3e3ad9d2..f8cac2e1 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 @@ -18,7 +18,7 @@ class DocumentWebViewClient(private val webShare: DocumentWebShare): WebViewClie super.onPageStarted(view, url, favicon) webShare.presenter.showLoadingProgressBar() url?.let { - webShare.presenter.updateTitle(it) + webShare.presenter.saveLastUrl(it) } webShare.presenter.updateAutoReloadState(true) // 更新途中に読み込み失敗した場合、ネットワーク復帰時に自動リロードする } 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 ac69bed7..6fe82477 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 @@ -216,7 +216,7 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { setAcceptThirdPartyCookies(it, true) } lasturl?.let { - updateTitle(lasturl) + saveLastUrl(lasturl) } applyCookieManager(url, urlLoading) } @@ -371,23 +371,22 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { } // ツールバー部分のタイトルを更新する関数 - override fun updateTitle(url: String) { + override fun saveLastUrl(url: String) { try { if (!isAdded) { return } - // Titleを設定する URL を定義 - val urlToTitle: Map = hashMapOf( + // 保存する LastURL を定義 + val setLastUrl: Map = hashMapOf( "Mobile#home" to requireActivity().baseContext.getString(R.string.main_label_home), "Mobile#work" to requireActivity().baseContext.getString(R.string.main_label_work), "Mobile#formSelection" to requireActivity().baseContext.getString(R.string.main_label_create_document), "Mobile#agileWorksSearch" to requireActivity().baseContext.getString(R.string.main_label_search) ) requireActivity().runOnUiThread { - urlToTitle.forEach { (k, v) -> + setLastUrl.forEach { (k, v) -> if (url.contains(k)) { lastUrl = url - setTitle(v) } } } @@ -395,18 +394,7 @@ class DocumentWebFragment : Fragment(), DocumentWebPresenter { // WebView が表示しているページによっては普通に起こり得るため単に握り潰す。 } } - private fun setTitle(title: String) { - val activity = requireActivity() - val titleView = activity.findViewById(R.id.toolbar_title) - if (titleView == null) { - // メイン表示: ツールバーのタイトルとして設定 - val toolbar = activity.findViewById(R.id.toolbar) - toolbar?.title = title - } else { - // 通知からの表示: 得られた TextView に設定 - titleView.text = title - } - } + override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) when (requestCode) { 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 daaf6faa..71468c2d 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 @@ -25,7 +25,7 @@ interface DocumentWebPresenter { /** * 現在開かれているページのタイトルを必要に応じて更新する。 */ - fun updateTitle(url: String) + fun saveLastUrl(url: String) // ネットワーク接続/切断関連 /** diff --git a/app/src/main/res/navigation/nav_create_document.xml b/app/src/main/res/navigation/nav_create_document.xml index 6a397e55..d6e6e28f 100644 --- a/app/src/main/res/navigation/nav_create_document.xml +++ b/app/src/main/res/navigation/nav_create_document.xml @@ -7,11 +7,7 @@ - + android:label="@string/main_label_create_document"> - + android:label="@string/main_label_home"> - + android:label="@string/main_label_search"> - + android:label="@string/main_label_work">