diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 7ebd6b4bb..82b3bae19 100755
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -170,6 +170,12 @@
android:theme="@style/AppTheme.Toolbar"
android:label="@string/u_config"/>
+
+
= Build.VERSION_CODES.LOLLIPOP) {
+ cookieManager.flush();
+ cookieManager.removeAllCookies(null);
+ cookieManager.removeSessionCookies(null);
+ } else {
+ CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this);
+ cookieSyncManager.startSync();
+ cookieManager.removeAllCookie();
+ cookieManager.removeSessionCookie();
+ cookieSyncManager.stopSync();
+ }
+
+ // Copy cookies from okhttp cookie store to CookieManager
+ url = EhUrl.getMyTagsUrl();
+ EhCookieStore store = EhApplication.getEhCookieStore(this);
+ for (Cookie cookie : store.getCookies(HttpUrl.parse(url))) {
+ cookieManager.setCookie(url, cookie.toString());
+ }
+
+ setContentView(R.layout.activity_my_tags);
+ setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
+ webView = findViewById(R.id.webview);
+ webView.getSettings().setJavaScriptEnabled(true);
+ webView.setWebViewClient(new MyTagsWebViewClient());
+ webView.setWebChromeClient(new DialogWebChromeClient(this));
+ webView.loadUrl(url);
+ progress = findViewById(R.id.progress);
+ }
+
+ private class MyTagsWebViewClient extends WebViewClient {
+ @Override
+ public boolean shouldOverrideUrlLoading(WebView view, String url) {
+ // Never load other urls
+ return !url.equals(MyTagsActivity.this.url);
+ }
+
+ @Override
+ public void onPageStarted(WebView view, String url, Bitmap favicon) {
+ progress.setVisibility(View.VISIBLE);
+ }
+
+ @Override
+ public void onPageFinished(WebView view, String url) {
+ progress.setVisibility(View.GONE);
+ }
+ }
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java
index f011b9c87..6a51aefed 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/UConfigActivity.java
@@ -21,8 +21,6 @@ package com.hippo.ehviewer.ui;
*/
import android.annotation.SuppressLint;
-import android.content.Context;
-import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Build;
import android.os.Bundle;
@@ -31,20 +29,15 @@ import android.view.MenuItem;
import android.view.View;
import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
-import android.webkit.JsPromptResult;
-import android.webkit.JsResult;
-import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
-import android.widget.EditText;
-import android.widget.TextView;
import androidx.annotation.Nullable;
-import androidx.appcompat.app.AlertDialog;
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.ehviewer.widget.DialogWebChromeClient;
import com.hippo.widget.ProgressView;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
@@ -87,7 +80,7 @@ public class UConfigActivity extends ToolbarActivity {
webView = (WebView) findViewById(R.id.webview);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new UConfigWebViewClient());
- webView.setWebChromeClient(new UConfigWebChromeClient());
+ webView.setWebChromeClient(new DialogWebChromeClient(this));
webView.loadUrl(url);
progress = (ProgressView) findViewById(R.id.progress);
@@ -183,69 +176,4 @@ public class UConfigActivity extends ToolbarActivity {
loaded = true;
}
}
-
- private class UConfigWebChromeClient extends WebChromeClient {
-
- private Context context = UConfigActivity.this;
-
- @Override
- public boolean onJsPrompt(WebView view, String url, String message, String defaultValue,
- final JsPromptResult result) {
-
- View promptView = UConfigActivity.this.getLayoutInflater()
- .inflate(R.layout.dialog_js_prompt, null, false);
- TextView messageView = (TextView) promptView.findViewById(R.id.message);
- messageView.setText(message);
- final EditText valueView = (EditText) promptView.findViewById(R.id.value);
- valueView.setText(defaultValue);
-
- new AlertDialog.Builder(context)
- .setView(promptView)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- result.confirm(valueView.getText().toString());
- }
- })
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- result.cancel();
- }
- })
- .show();
-
- return true;
- }
-
- private void showMessageDialog(String message, final JsResult result) {
- new AlertDialog.Builder(context)
- .setMessage(message)
- .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
- result.confirm();
- }
- })
- .setOnCancelListener(new DialogInterface.OnCancelListener() {
- @Override
- public void onCancel(DialogInterface dialog) {
- result.cancel();
- }
- })
- .show();
- }
-
- @Override
- public boolean onJsAlert(WebView view, String url, String message, final JsResult result) {
- showMessageDialog(message, result);
- return true;
- }
-
- @Override
- public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
- showMessageDialog(message, result);
- return true;
- }
- }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/widget/DialogWebChromeClient.java b/app/src/main/java/com/hippo/ehviewer/widget/DialogWebChromeClient.java
new file mode 100644
index 000000000..41dcb092f
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/widget/DialogWebChromeClient.java
@@ -0,0 +1,77 @@
+/*
+ * 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.widget;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.webkit.JsPromptResult;
+import android.webkit.JsResult;
+import android.webkit.WebChromeClient;
+import android.webkit.WebView;
+import android.widget.EditText;
+import android.widget.TextView;
+import androidx.appcompat.app.AlertDialog;
+import com.hippo.ehviewer.R;
+
+public class DialogWebChromeClient extends WebChromeClient {
+
+ private Context context;
+
+ public DialogWebChromeClient(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public boolean onJsAlert(WebView view, String url, String message, JsResult result) {
+ new AlertDialog.Builder(view.getContext())
+ .setMessage(message)
+ .setPositiveButton(android.R.string.ok, (dialog, which) -> result.confirm())
+ .setOnCancelListener(dialog -> result.cancel())
+ .show();
+ return true;
+ }
+
+ @Override
+ public boolean onJsConfirm(WebView view, String url, String message, JsResult result) {
+ new AlertDialog.Builder(view.getContext())
+ .setMessage(message)
+ .setPositiveButton(android.R.string.ok, (dialog, which) -> result.confirm())
+ .setNegativeButton(android.R.string.cancel, (dialog, which) -> result.cancel())
+ .setOnCancelListener(dialog -> result.cancel())
+ .show();
+ return true;
+ }
+
+ @Override
+ public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, JsPromptResult result) {
+ LayoutInflater inflater = LayoutInflater.from(context);
+ View promptView = inflater.inflate(R.layout.dialog_js_prompt, null, false);
+ TextView messageView = promptView.findViewById(R.id.message);
+ messageView.setText(message);
+ final EditText valueView = promptView.findViewById(R.id.value);
+ valueView.setText(defaultValue);
+
+ new AlertDialog.Builder(context)
+ .setView(promptView)
+ .setPositiveButton(android.R.string.ok, (dialog, which) -> result.confirm(valueView.getText().toString()))
+ .setOnCancelListener(dialog -> result.cancel())
+ .show();
+
+ return true;
+ }
+}
diff --git a/app/src/main/res/layout/activity_my_tags.xml b/app/src/main/res/layout/activity_my_tags.xml
new file mode 100644
index 000000000..841181f7f
--- /dev/null
+++ b/app/src/main/res/layout/activity_my_tags.xml
@@ -0,0 +1,38 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 1c7f29c1e..6971aa64a 100755
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -363,6 +363,9 @@
应用
点击右上角的对勾来保存设置
+
+ 我的标签
+
自定义 hosts.txt
hosts.txt
@@ -401,6 +404,8 @@
复制
EHentai 设置
EHentai 网站上的设置
+ 我的标签
+ EHentai 网站上的我的标签
主题
亮色
暗色
diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml
index 048715f84..f3a5c33ac 100755
--- a/app/src/main/res/values-zh-rHK/strings.xml
+++ b/app/src/main/res/values-zh-rHK/strings.xml
@@ -363,6 +363,9 @@
應用
點擊右上角的對勾來保存設置
+
+ 我的標籤
+
自定義 hosts.txt
hosts.txt
@@ -400,6 +403,8 @@
複製
EHentai 設置
EHentai 網站上的設置
+ 我的標籤
+ EHentai 網站上的我的標籤
主題
亮色
暗色
diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml
index d635af3ac..f3c705284 100755
--- a/app/src/main/res/values-zh-rTW/strings.xml
+++ b/app/src/main/res/values-zh-rTW/strings.xml
@@ -363,6 +363,9 @@
套用
點選右上角的勾勾以儲存設定
+
+ 我的標籤
+
自訂hosts.txt
hosts.txt
@@ -400,6 +403,8 @@
複製
EHentai 設定
EHentai 網站上的設定
+ 我的標籤
+ EHentai 網站上的我的標籤
主題
亮色
暗色
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index dd1d48268..db777006d 100755
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -407,6 +407,9 @@
Apply
Tap the check mark to save the settings
+
+ My tags
+
Custom hosts.txt
hosts.txt
@@ -444,6 +447,8 @@
Copy
EHentai settings
Settings on EHentai website
+ My tags
+ My tags on EHentai website
Theme
Light
Dark
diff --git a/app/src/main/res/xml/eh_settings.xml b/app/src/main/res/xml/eh_settings.xml
index bb58a1695..f5c23b304 100644
--- a/app/src/main/res/xml/eh_settings.xml
+++ b/app/src/main/res/xml/eh_settings.xml
@@ -43,6 +43,12 @@
android:summary="@string/settings_u_config_summary"
app:activity="com.hippo.ehviewer.ui.UConfigActivity"/>
+
+