From 04c0e1474a79ee19950d2ab1cfe379c84cd5b3e8 Mon Sep 17 00:00:00 2001 From: sitou Date: Mon, 18 Aug 2025 16:07:50 +0900 Subject: [PATCH] =?UTF-8?q?=E3=82=BB=E3=83=83=E3=82=B7=E3=83=A7=E3=83=B3AP?= =?UTF-8?q?I=E3=81=8C=E5=AE=8C=E4=BA=86=E3=81=97=E3=81=A6=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=83=AD=E3=82=B0=E3=82=A2=E3=82=A6=E3=83=88=E5=87=A6?= =?UTF-8?q?=E7=90=86=E3=82=92=E9=80=B2=E3=82=81=E3=82=8B=E3=82=88=E3=81=86?= =?UTF-8?q?=E3=81=AB=E3=81=99=E3=82=8B=E3=80=82=E9=80=9A=E7=9F=A5=E3=81=8B?= =?UTF-8?q?=E3=82=89=E9=96=8B=E3=81=84=E3=81=9F=E7=94=BB=E9=9D=A2=E3=81=8B?= =?UTF-8?q?=E3=82=89=E3=83=A1=E3=83=8B=E3=83=A5=E3=83=BC=E3=82=92=E5=89=8A?= =?UTF-8?q?=E9=99=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../model/NotificationRepository.kt | 49 ++++++++++---- .../view/ui/DirectOpenDocumentActivity.kt | 1 - .../jp/atled/agileworks/view/ui/DrawerMenu.kt | 67 +++++++++++++++++-- .../atled/agileworks/view/ui/MainActivity.kt | 11 +++ .../ui/documentweb/DocumentWebFragment.kt | 21 +++++- app/src/main/res/layout/activity_main.xml | 15 +++++ 6 files changed, 142 insertions(+), 22 deletions(-) diff --git a/app/src/main/java/jp/atled/agileworks/model/NotificationRepository.kt b/app/src/main/java/jp/atled/agileworks/model/NotificationRepository.kt index c8890aca..7bca3c86 100644 --- a/app/src/main/java/jp/atled/agileworks/model/NotificationRepository.kt +++ b/app/src/main/java/jp/atled/agileworks/model/NotificationRepository.kt @@ -6,6 +6,12 @@ import android.content.SharedPreferences import android.util.Log import jp.atled.agileworks.AwApp import jp.atled.agileworks.model.api.ApiClient +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.GlobalScope +import kotlinx.coroutines.launch +import kotlinx.coroutines.suspendCancellableCoroutine +import kotlinx.coroutines.withTimeoutOrNull +import kotlin.coroutines.resume /** * 通知全般を扱うリポジトリ @@ -39,21 +45,40 @@ class NotificationRepository(_serverNumber: Int? = null) { fun clearToken(onResult: (Boolean) -> Unit) { Log.d("AgileWorks", "firebase token clean") ApiClient.reCreateLogout(serverNumber) - LogoutRepository.getInstance().getLogout { - /* - FcmRepository().removeFcmToken { - Log.d("AgileWorks", "firebase token clean -> ${successOrFailured(it)}") - onResult(it) + // 30秒でタイムアウト + GlobalScope.launch(Dispatchers.Main) { + val timeoutMillis = 30000L + val result = withTimeoutOrNull(timeoutMillis) { + suspendCancellableCoroutine { continuation -> + LogoutRepository.getInstance().getLogout { success -> + if (continuation.isActive) { + continuation.resume(success) + } + } + } } - */ - // 全サーバログアウト状態で FcmToken の削除 - val serverList = ServerRepository().loadServerList() - if (serverList.isEmpty()) { - FcmRepository().removeFcmToken { - Log.d("AgileWorks", "firebase token clean -> ${successOrFailured(it)}") + + if (result == null) { + // タイムアウトした場合 + // 全サーバログアウト状態で FcmToken の削除 + val serverList = ServerRepository().loadServerList() + if (serverList.isEmpty()) { + FcmRepository().removeFcmToken { + Log.d("AgileWorks", "firebase token clean (timeout path)") + } + } + onResult(true) // 成功として扱う + } else { + // タイムアウトしなかった場合 + // 全サーバログアウト状態で FcmToken の削除 + val serverList = ServerRepository().loadServerList() + if (serverList.isEmpty()) { + FcmRepository().removeFcmToken { + Log.d("AgileWorks", "firebase token clean -> ${successOrFailured(result)}") + } } + onResult(result) } - onResult(it) } } diff --git a/app/src/main/java/jp/atled/agileworks/view/ui/DirectOpenDocumentActivity.kt b/app/src/main/java/jp/atled/agileworks/view/ui/DirectOpenDocumentActivity.kt index 036635ee..0c0df764 100644 --- a/app/src/main/java/jp/atled/agileworks/view/ui/DirectOpenDocumentActivity.kt +++ b/app/src/main/java/jp/atled/agileworks/view/ui/DirectOpenDocumentActivity.kt @@ -52,7 +52,6 @@ class DirectOpenDocumentActivity : BaseActivity(), View.OnClickListener { setContentView(binding.root) binding.toolbar.title = title() setSupportActionBar(binding.toolbar) - setupDrawerMenu() findViewById