From beadc7b1856d6ea65f2b62140d221783d385733a Mon Sep 17 00:00:00 2001 From: tarsin Date: Fri, 16 Sep 2022 10:46:47 +0800 Subject: [PATCH] Merge Account and Signout --- .../ehviewer/preference/AccountPreference.kt | 10 ++- .../preference/SignOutPreference.java | 73 ------------------- app/src/main/res/values-zh-rCN/strings.xml | 6 +- app/src/main/res/values/strings.xml | 4 +- app/src/main/res/xml/eh_settings.xml | 6 -- 5 files changed, 11 insertions(+), 88 deletions(-) delete mode 100644 app/src/main/java/com/hippo/ehviewer/preference/SignOutPreference.java diff --git a/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt b/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt index ceedc419c..865fb284a 100644 --- a/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt +++ b/app/src/main/java/com/hippo/ehviewer/preference/AccountPreference.kt @@ -25,6 +25,7 @@ import com.hippo.ehviewer.EhApplication import com.hippo.ehviewer.R import com.hippo.ehviewer.client.EhCookieStore import com.hippo.ehviewer.client.EhUrl +import com.hippo.ehviewer.client.EhUtils import com.hippo.ehviewer.ui.SettingsActivity import com.hippo.ehviewer.ui.scene.BaseScene import com.hippo.preference.MessagePreference @@ -79,7 +80,7 @@ class AccountPreference @JvmOverloads constructor( override fun onPrepareDialogBuilder(builder: AlertDialog.Builder) { super.onPrepareDialogBuilder(builder) if (message != null) { - builder.setPositiveButton(R.string.settings_eh_identity_cookies_copy) { dialog: DialogInterface?, which: Int -> + builder.setNeutralButton(R.string.settings_eh_identity_cookies_copy) { dialog: DialogInterface?, which: Int -> val clipboardManager = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager? val clipData = ClipData.newPlainText(null, message) @@ -96,9 +97,10 @@ class AccountPreference @JvmOverloads constructor( mActivity.showTip(R.string.copied_to_clipboard, BaseScene.LENGTH_SHORT) this@AccountPreference.onClick(dialog, which) } - builder.setNegativeButton(android.R.string.cancel, null) - } else { - builder.setPositiveButton(android.R.string.ok, null) + } + builder.setPositiveButton(R.string.settings_eh_sign_out) { _: DialogInterface?, _: Int -> + EhUtils.signOut(context) + mActivity.showTip(R.string.settings_eh_sign_out_tip, BaseScene.LENGTH_SHORT) } } } \ No newline at end of file diff --git a/app/src/main/java/com/hippo/ehviewer/preference/SignOutPreference.java b/app/src/main/java/com/hippo/ehviewer/preference/SignOutPreference.java deleted file mode 100644 index aaa2bc795..000000000 --- a/app/src/main/java/com/hippo/ehviewer/preference/SignOutPreference.java +++ /dev/null @@ -1,73 +0,0 @@ -/* - * Copyright 2016 Hippo Seven - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.hippo.ehviewer.preference; - -import android.annotation.SuppressLint; -import android.content.Context; -import android.util.AttributeSet; - -import androidx.appcompat.app.AlertDialog; - -import com.hippo.ehviewer.R; -import com.hippo.ehviewer.client.EhUtils; -import com.hippo.ehviewer.ui.SettingsActivity; -import com.hippo.ehviewer.ui.scene.BaseScene; -import com.hippo.preference.MessagePreference; - -public class SignOutPreference extends MessagePreference { - - @SuppressLint("StaticFieldLeak") - private final SettingsActivity mActivity; - - public SignOutPreference(Context context) { - super(context); - init(); - mActivity = (SettingsActivity) context; - } - - public SignOutPreference(Context context, AttributeSet attrs) { - super(context, attrs); - init(); - mActivity = (SettingsActivity) context; - } - - public SignOutPreference(Context context, AttributeSet attrs, int defStyleAttr) { - super(context, attrs, defStyleAttr); - init(); - mActivity = (SettingsActivity) context; - } - - private void init() { - setDialogMessage(getContext().getString(R.string.settings_eh_sign_out_warning)); - } - - @Override - protected void onPrepareDialogBuilder(AlertDialog.Builder builder) { - super.onPrepareDialogBuilder(builder); - builder.setPositiveButton(R.string.settings_eh_sign_out_yes, this); - builder.setNegativeButton(android.R.string.cancel, null); - } - - @Override - protected void onDialogClosed(boolean positiveResult) { - super.onDialogClosed(positiveResult); - if (positiveResult) { - EhUtils.signOut(getContext()); - mActivity.showTip(R.string.settings_eh_sign_out_tip, BaseScene.LENGTH_SHORT); - } - } -} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 11ef53a90..bd9f1dcdd 100755 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -391,7 +391,7 @@ 自定义 hosts.txt hosts.txt Host - IP1(+IP2+IP3...) + IP1(+IP2+IP3…) 添加 host 添加 编辑 host @@ -421,8 +421,8 @@ 身份 Cookie 可用于登录 身份 Cookie 可用于登录该账号。<br><b>注意数据安全</b><br><br>%s - 未登录 - 复制 + 游客模式 + 复制 Cookies EHentai 设置 EHentai 网站上的设置 我的标签 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 221e2ad2b..4b46116c9 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -466,8 +466,8 @@ Identity cookies Cookies can be used to sign in Identity cookies can be used to sign in to this account.<br><b>KEEP IT SAFE</b><br><br>%s - Not signed in. - Copy + Tourist mode + Copy Cookies EHentai settings Settings on EHentai website My tags diff --git a/app/src/main/res/xml/eh_settings.xml b/app/src/main/res/xml/eh_settings.xml index 8cb1e18c4..6188aa694 100644 --- a/app/src/main/res/xml/eh_settings.xml +++ b/app/src/main/res/xml/eh_settings.xml @@ -23,12 +23,6 @@ android:title="@string/account_name" app:iconSpaceReserved="false" /> - -