From 2f309fe9bb7113453eb6c525790db81a685dd304 Mon Sep 17 00:00:00 2001 From: tarsin Date: Tue, 6 Jun 2023 01:16:34 +0800 Subject: [PATCH] [DO NOT USE] Cleanup AccountPreference --- .../hippo/ehviewer/ui/settings/EhScreen.kt | 32 ++++++++----------- 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/app/src/main/java/com/hippo/ehviewer/ui/settings/EhScreen.kt b/app/src/main/java/com/hippo/ehviewer/ui/settings/EhScreen.kt index abde1b8d1..9841eb220 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/settings/EhScreen.kt +++ b/app/src/main/java/com/hippo/ehviewer/ui/settings/EhScreen.kt @@ -65,7 +65,6 @@ fun EhScreen() { title = stringResource(id = R.string.account_name), summary = Settings.displayName ?: stringResource(id = R.string.settings_eh_identity_cookies_tourist), ) { - val builder = BaseDialogBuilder(context) val eCookies = EhCookieStore.getCookies(EhUrl.HOST_E.toHttpUrl()) val exCookies = EhCookieStore.getCookies(EhUrl.HOST_EX.toHttpUrl()) var ipbMemberId: String? = null @@ -78,23 +77,20 @@ fun EhScreen() { EhCookieStore.KEY_IGNEOUS -> igneous = it.value } } - val message = if (ipbMemberId != null || ipbPassHash != null || igneous != null) { - val str = EhCookieStore.KEY_IPB_MEMBER_ID + ": " + ipbMemberId + "
" + EhCookieStore.KEY_IPB_PASS_HASH + ": " + ipbPassHash + "
" + EhCookieStore.KEY_IGNEOUS + ": " + igneous - val spanned = Html.fromHtml(context.getString(R.string.settings_eh_identity_cookies_signed, str), Html.FROM_HTML_MODE_LEGACY) - builder.setMessage(spanned) - str.replace("
", "\n") - } else { - builder.setMessage(context.getString(R.string.settings_eh_identity_cookies_tourist)) - null - } - if (message != null) { - builder.setNeutralButton(R.string.settings_eh_identity_cookies_copy) { _, _ -> context whisperClipboard message } - } - builder.setPositiveButton(R.string.settings_eh_sign_out) { _, _ -> - EhUtils.signOut() - launchSnackBar(signOutMessage) - } - builder.show() + BaseDialogBuilder(context).apply { + if (ipbMemberId != null || ipbPassHash != null || igneous != null) { + val str = EhCookieStore.KEY_IPB_MEMBER_ID + ": " + ipbMemberId + "
" + EhCookieStore.KEY_IPB_PASS_HASH + ": " + ipbPassHash + "
" + EhCookieStore.KEY_IGNEOUS + ": " + igneous + val spanned = Html.fromHtml(context.getString(R.string.settings_eh_identity_cookies_signed, str), Html.FROM_HTML_MODE_LEGACY) + setMessage(spanned) + setNeutralButton(R.string.settings_eh_identity_cookies_copy) { _, _ -> context whisperClipboard str.replace("
", "\n") } + } else { + setMessage(context.getString(R.string.settings_eh_identity_cookies_tourist)) + } + setPositiveButton(R.string.settings_eh_sign_out) { _, _ -> + EhUtils.signOut() + launchSnackBar(signOutMessage) + } + }.show() } Preference( title = stringResource(id = R.string.image_limits),