From 6775246d4c40600c5ad619964c311e8f96e9abb2 Mon Sep 17 00:00:00 2001 From: seven332 Date: Thu, 21 Mar 2019 19:16:14 +0800 Subject: [PATCH] Add login tip for EHentai Setting and My Tags --- .../SignInRequiredActivityPreference.java | 72 +++++++++++++++++++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + app/src/main/res/xml/eh_settings.xml | 4 +- 6 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/hippo/ehviewer/preference/SignInRequiredActivityPreference.java diff --git a/app/src/main/java/com/hippo/ehviewer/preference/SignInRequiredActivityPreference.java b/app/src/main/java/com/hippo/ehviewer/preference/SignInRequiredActivityPreference.java new file mode 100644 index 000000000..0160b1bd6 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/preference/SignInRequiredActivityPreference.java @@ -0,0 +1,72 @@ +/* + * Copyright 2019 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.content.Context; +import android.util.AttributeSet; +import android.view.View; +import android.view.ViewGroup; +import android.widget.Toast; +import com.google.android.material.snackbar.Snackbar; +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.preference.ActivityPreference; +import okhttp3.HttpUrl; + +public class SignInRequiredActivityPreference extends ActivityPreference { + + private View view; + + public SignInRequiredActivityPreference(Context context) { + super(context); + } + + public SignInRequiredActivityPreference(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public SignInRequiredActivityPreference(Context context, AttributeSet attrs, int defStyleAttr) { + super(context, attrs, defStyleAttr); + } + + @Override + protected View onCreateView(ViewGroup parent) { + return view = super.onCreateView(parent); + } + + @Override + protected void onClick() { + EhCookieStore store = EhApplication.getEhCookieStore(getContext()); + HttpUrl e = HttpUrl.get(EhUrl.HOST_E); + HttpUrl ex = HttpUrl.get(EhUrl.HOST_EX); + + if (store.contains(e, EhCookieStore.KEY_IPD_MEMBER_ID) || + store.contains(e, EhCookieStore.KEY_IPD_PASS_HASH) || + store.contains(ex, EhCookieStore.KEY_IPD_MEMBER_ID) || + store.contains(ex, EhCookieStore.KEY_IPD_PASS_HASH)) { + super.onClick(); + } else { + if (view != null) { + Snackbar.make(view, R.string.error_please_login_first, 3000).show(); + } else { + Toast.makeText(getContext(), R.string.error_please_login_first, Toast.LENGTH_LONG).show(); + } + } + } +} diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 20eeba860..5a866b393 100755 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -90,6 +90,7 @@ 无法创建临时文件 无法保存图片 非法数字 + 请先登陆 本应用中内容来自互联网,部分内容可能对您的生理及心理造成难以恢复的伤害。本应用作者不会对由本应用造成的任何后果负责。\n\n未成年人应在监护人指导下使用本应用。 用户名不可为空 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index aa7007151..a5e5c7b0e 100755 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -90,6 +90,7 @@ 無法創建臨時文件 無法保存圖片 非法數字 + 請先登陸 本應用中內容來自互聯網,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用作者不會對由本應用造成的任何後果負責。\n\n未成年人應在監護人指導下使用本應用。 用户名不可為空 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 052e3c671..02e4fd197 100755 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -90,6 +90,7 @@ 無法建立暫存檔案 無法儲存圖片 無效的數字 + 請先登陸 本應用程式中內容來自網際網路,部分內容可能對您的生理及心理造成難以恢復的傷害。本應用程式的作者不會對由其所造成的任何影響負責。\n\n未成年人應在監護人指導下使用本應用程式。 使用者名稱欄位不能為空 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6d5bfcec5..3860f6f6b 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -132,6 +132,7 @@ Couldn\'t create temp file Can\'t save image Invalid number + Please login first The content of this application is from the Internet. Some of it may do physical or mental harm to you. You have learnt the risks above and would like to undertake them. Username cannot be an empty string diff --git a/app/src/main/res/xml/eh_settings.xml b/app/src/main/res/xml/eh_settings.xml index 44f3947df..a8ae33ae9 100644 --- a/app/src/main/res/xml/eh_settings.xml +++ b/app/src/main/res/xml/eh_settings.xml @@ -37,13 +37,13 @@ app:entryValues="@array/gallery_site_entry_values" android:defaultValue="1"/> - -