mirror of
https://github.com/seven332/EhViewer
synced 2026-11-27 17:48:06 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ba6d41b91f | ||
|
|
6a9e0198a2 | ||
|
|
92f716170c | ||
|
|
d72f686d5a | ||
|
|
28eade9451 | ||
|
|
7b95bc804a | ||
|
|
47c9d48787 | ||
|
|
8a7adbe838 | ||
|
|
0248fd4e02 | ||
|
|
1cd5f7bbf7 | ||
|
|
db893b899d | ||
|
|
d86dd3bc06 | ||
|
|
49f420c1eb | ||
|
|
c9103caad8 | ||
|
|
ee0ffc48d2 | ||
|
|
ed7eba7ef4 | ||
|
|
b6a16d1d58 | ||
|
|
04521dfeb6 | ||
|
|
d00f6e6cc6 | ||
|
|
7a47b2504d | ||
|
|
2da10a5855 | ||
|
|
323b36c58a | ||
|
|
9834d45ca9 | ||
|
|
c058bb01f0 | ||
|
|
f578c6cb8b | ||
|
|
2c43589c1c | ||
|
|
6e73f03c19 | ||
|
|
b7e2c5bce1 | ||
|
|
9707ac470a | ||
|
|
06fd28290c | ||
|
|
21ef5897ef | ||
|
|
bdd45b5f10 | ||
|
|
e68d4ad2c4 | ||
|
|
2e56ba4ed0 | ||
|
|
54b6dd99a9 | ||
|
|
6389b09d64 | ||
|
|
998d87b206 | ||
|
|
0b6a9da664 | ||
|
|
6086175ef6 | ||
|
|
5e690c6983 | ||
|
|
a898f289fe | ||
|
|
a215389b98 | ||
|
|
60af7937c7 | ||
|
|
4064510b14 | ||
|
|
c9146324f8 | ||
|
|
bd7c806ad9 | ||
|
|
efe7d4757a | ||
|
|
3554fe1188 | ||
|
|
06357b37d6 | ||
|
|
ae2443fbf0 | ||
|
|
19403975ba | ||
|
|
5087311b26 | ||
|
|
de854ac7ac | ||
|
|
40c0506f6e | ||
|
|
7beb49e599 | ||
|
|
7c5486aa08 | ||
|
|
120124101a | ||
|
|
c286d2c543 | ||
|
|
5f411661e9 | ||
|
|
981a7c7851 | ||
|
|
43b169371d | ||
|
|
311dabba17 | ||
|
|
c7d7ce8225 | ||
|
|
4b1c6ac917 | ||
|
|
24612b7d14 | ||
|
|
3530faabf1 | ||
|
|
0f3a95575c | ||
|
|
0334833bf8 | ||
|
|
1b1d94a98d | ||
|
|
dfa1de9745 | ||
|
|
84fe397c18 | ||
|
|
07b1b5034d | ||
|
|
7f73eb0bd4 | ||
|
|
f129ac649d | ||
|
|
e9d5569e81 | ||
|
|
db31e5c740 | ||
|
|
c83fcee21a | ||
|
|
6270e1695d | ||
|
|
a8b11c8e21 | ||
|
|
a12b2c4eac | ||
|
|
31412b78cf | ||
|
|
4a986a8428 | ||
|
|
d58b2ba03e | ||
|
|
176c64330f | ||
|
|
342ed0c709 | ||
|
|
d8ee689db7 | ||
|
|
229e429809 | ||
|
|
f5128cd17a | ||
|
|
5e5a736f1c | ||
|
|
1ec3681b7c | ||
|
|
67f9b6cb83 | ||
|
|
58ac39cf2c | ||
|
|
3cd4fc7ce9 | ||
|
|
d731719f1c | ||
|
|
be0c394de1 | ||
|
|
a739300260 | ||
|
|
da9940d581 | ||
|
|
a2523aae75 | ||
|
|
3ae3602671 | ||
|
|
6350fc1ece | ||
|
|
29a27cbe00 | ||
|
|
5fc0fb997a | ||
|
|
aa01ddd594 | ||
|
|
8774268adf | ||
|
|
265cbd0df5 | ||
|
|
82cdfeb1b2 | ||
|
|
71dd9d3693 | ||
|
|
fd9f1bd219 | ||
|
|
956b7455a3 | ||
|
|
b3c855a5dc | ||
|
|
06e624a1e3 | ||
|
|
871c0a43ca | ||
|
|
6775246d4c | ||
|
|
a0b0109424 | ||
|
|
c5566aa5e8 | ||
|
|
1d70572d92 | ||
|
|
5dc6446d64 | ||
|
|
13eb9e2f16 | ||
|
|
7e1e4a0f57 | ||
|
|
c0933eb8f0 | ||
|
|
a0e6a847ab | ||
|
|
23a7053597 | ||
|
|
d463cf2295 | ||
|
|
94db37c899 | ||
|
|
94f6eecbc7 | ||
|
|
c0f20ca975 | ||
|
|
749f2610af | ||
|
|
a2a6422917 | ||
|
|
df72243bb6 | ||
|
|
50c7a23566 | ||
|
|
1cbb725920 | ||
|
|
8b76eaa740 | ||
|
|
65f320f8f7 | ||
|
|
a7e4a2cd61 | ||
|
|
88baeeb335 | ||
|
|
00289d106d | ||
|
|
08d1ef87d4 | ||
|
|
388d507257 | ||
|
|
89209a3c44 | ||
|
|
9208c53d4f | ||
|
|
defa670a26 | ||
|
|
2ec229c8ef | ||
|
|
e5df5714de | ||
|
|
5b8e031e50 | ||
|
|
b0ccfe4793 | ||
|
|
b101ae142d | ||
|
|
c165c9071d | ||
|
|
7fc9ef9e1f | ||
|
|
c4514589c0 | ||
|
|
0305c541aa | ||
|
|
7631e3b4f9 | ||
|
|
350d846a39 | ||
|
|
c119562c16 | ||
|
|
37de170729 | ||
|
|
8d992d737e | ||
|
|
81434a682f | ||
|
|
b3a446ffcd | ||
|
|
e659ba91b4 | ||
|
|
7866722ec4 | ||
|
|
2a944f5e0a | ||
|
|
34eccad8be | ||
|
|
57a18b7215 | ||
|
|
6c253238ad | ||
|
|
c08068eeea | ||
|
|
303c51f93d |
No files matched your search
@@ -1,30 +0,0 @@
|
||||
感谢您提交 Issue,请在提交前仔细阅读以下信息。
|
||||
|
||||
请在阅读完毕后,删除这些文字,并写下对该 Issue 的描述。
|
||||
|
||||
若您能熟练使用现代标准汉语,请务必使用该语言描述 Issue。
|
||||
|
||||
Issue 的内容仅可为
|
||||
* Bug 反馈
|
||||
* 功能申请
|
||||
|
||||
若您希望得到使用指导(譬如如何删除快速搜索),请至 [G+ 社区](https://plus.google.com/u/1/communities/103823982034655188459) 发贴。若有其他问题,可在应用内找到开发者的邮箱地址,使用电子邮件与开发者交流。
|
||||
|
||||
若内容为 Bug 反馈,请先查看 [release 页面](https://github.com/seven332/EhViewer/releases),以帮助确认该 bug 是否存在于最新版中;同时应详细描述 bug 内容与重现方法,必要时可附加截图,但请确定截图符合风序良俗。
|
||||
|
||||
功能申请包括添加新功能与改进现有功能。
|
||||
|
||||
一个 Issue 只包含一个 Bug 反馈或者功能申请。若有多个需求,请提交多个 Issue。
|
||||
|
||||
尽量不提交重复的 Issue,可先进行搜索。对于重复的 Issue,开发者可能会直接关闭并添加 Duplicate 标签。
|
||||
|
||||
|
||||
Thank you for taking the time to submit an issue. Before you proceed, please consider the following.
|
||||
|
||||
An issue can only be about:
|
||||
* Bug Report
|
||||
* Feature Request
|
||||
|
||||
If you need application instructions, please post your question in [G+ community](https://plus.google.com/u/1/communities/103823982034655188459). If you have other questions, please get the developer's email address in the application, and send him/her an email.
|
||||
|
||||
One issue one bug report or feature request.
|
||||
@@ -0,0 +1,20 @@
|
||||
---
|
||||
name: 功能申请 / Feature request
|
||||
about: 有个想法 / Suggest an idea for this project
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**这个功能是用来解决问题的吗? / Is your feature request related to a problem? Please describe.**
|
||||
描述这个问题。
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**描述你想要的解决方法 / Describe the solution you'd like**
|
||||
描述应通过何种行为来解决这个问题。
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**备注 / Additional context**
|
||||
还有别的想说的吗?
|
||||
Add any other context or screenshots about the feature request here.
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
name: Bug 反馈 / Bug report
|
||||
about: 出问题了 / Create a report to help us improve
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**简略描述 / Describe the bug**
|
||||
大概说下是什么问题。
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**如何重现 / To Reproduce**
|
||||
重现的步骤:
|
||||
1. 打开什么什么
|
||||
2. 点击什么什么
|
||||
3. 出现什么什么问题
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**预期行为 / Expected behavior**
|
||||
应该是什么样子的?
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**截图 / Screenshots**
|
||||
能截图的话就发截图,请注意风序良俗。
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**设备型号与 Android 版本 / Device model and Android version**
|
||||
- 设备型号:【比如 Pixel 6 XXXL】
|
||||
- Android 版本:【比如 Android 12.1】
|
||||
- Device model: [e.g. Pixel 6 XXXL]
|
||||
- Android version: [e.g. Android 12.1]
|
||||
|
||||
**备注 / Additional context**
|
||||
还有什么想说的?
|
||||
Add any other context about the problem here.
|
||||
@@ -0,0 +1,11 @@
|
||||
---
|
||||
name: Sad Panda / 下载太慢 / Slow download speed
|
||||
about: 所有其他问题 / All other questions
|
||||
title: ''
|
||||
labels: ''
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
加入我们的 Telegram 群组,[https://t.me/ehviewer](https://t.me/ehviewer)。温柔[大小]姐姐手把手帮你解决问题。
|
||||
Join our Telegram group, [https://t.me/ehviewer](https://t.me/ehviewer). Administrators will help you solve the problem.
|
||||
@@ -1,3 +1,5 @@
|
||||
# DEPRECATED
|
||||
|
||||
[](https://t.me/ehviewer)
|
||||
|
||||
# EhViewer
|
||||
@@ -33,6 +35,13 @@ Linux
|
||||
The apk is in app\build\outputs\apk
|
||||
|
||||
|
||||
# Download
|
||||
|
||||
[下载](https://github.com/seven332/EhViewer/releases)
|
||||
|
||||
[Download](https://github.com/seven332/EhViewer/releases)
|
||||
|
||||
|
||||
# Thanks
|
||||
|
||||
本项目受到了诸多开源项目的帮助
|
||||
|
||||
+10
-8
@@ -12,11 +12,12 @@ android {
|
||||
applicationId "com.hippo.ehviewer"
|
||||
minSdkVersion 14
|
||||
targetSdkVersion 28
|
||||
versionCode 95
|
||||
versionName "1.4.2"
|
||||
versionCode 104
|
||||
versionName "1.7.3"
|
||||
vectorDrawables.useSupportLibrary = true
|
||||
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
|
||||
"es", "ja", "ko", "fr", "de"
|
||||
"es", "ja", "ko", "fr", "de", "th"
|
||||
testOptions.unitTests.includeAndroidResources = true
|
||||
ndk {
|
||||
abiFilters "armeabi-v7a", "x86"
|
||||
}
|
||||
@@ -71,8 +72,9 @@ dependencies {
|
||||
implementation 'androidx.appcompat:appcompat:1.0.2'
|
||||
implementation 'androidx.cardview:cardview:1.0.0'
|
||||
implementation 'com.google.android.material:material:1.0.0'
|
||||
implementation 'com.google.firebase:firebase-core:16.0.7'
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.9.9'
|
||||
implementation 'com.google.firebase:firebase-core:16.0.9'
|
||||
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
|
||||
implementation 'com.getkeepsafe.relinker:relinker:1.3.1'
|
||||
implementation 'com.github.amlcurran.showcaseview:library:5.4.3'
|
||||
implementation 'com.github.seven332.a7zip:extract-lite:d4ddec5793'
|
||||
implementation 'com.github.seven332:android-recaptcha:2bbb3459a8'
|
||||
@@ -96,12 +98,12 @@ dependencies {
|
||||
implementation 'com.github.seven332:yorozuya-thread:0.1.1'
|
||||
implementation 'com.github.seven332:yorozuya-collect:0.1.4'
|
||||
implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.1'
|
||||
implementation 'com.squareup.okhttp3:okhttp:3.12.3'
|
||||
implementation 'org.ccil.cowan.tagsoup:tagsoup:1.2.1'
|
||||
implementation 'org.greenrobot:greendao:2.2.1'
|
||||
implementation 'org.jsoup:jsoup:1.11.3'
|
||||
implementation 'org.jsoup:jsoup:1.12.1'
|
||||
testImplementation 'junit:junit:4.12'
|
||||
testImplementation 'org.robolectric:robolectric:3.8'
|
||||
testImplementation 'org.robolectric:robolectric:4.2.1'
|
||||
testImplementation 'org.jooq:joor:0.9.6'
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,8 @@
|
||||
android:largeHeap="true"
|
||||
android:networkSecurityConfig="@xml/network_security_config">
|
||||
|
||||
<uses-library android:name="org.apache.http.legacy" android:required="false"/>
|
||||
|
||||
<meta-data android:name="android.max_aspect" android:value="2.1"/>
|
||||
|
||||
<activity
|
||||
@@ -170,6 +172,12 @@
|
||||
android:theme="@style/AppTheme.Toolbar"
|
||||
android:label="@string/u_config"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.MyTagsActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
android:theme="@style/AppTheme.Toolbar"
|
||||
android:label="@string/my_tags"/>
|
||||
|
||||
<activity
|
||||
android:name="com.hippo.ehviewer.ui.HostsActivity"
|
||||
android:configChanges="screenSize|uiMode"
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 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.drawable;
|
||||
|
||||
/*
|
||||
* Created by Hippo on 2017/9/6.
|
||||
*/
|
||||
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.ColorFilter;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PixelFormat;
|
||||
import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.IntRange;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class TextDrawable extends Drawable {
|
||||
|
||||
private static final float STANDARD_TEXT_SIZE = 1000.0f;
|
||||
private static final Paint STANDARD_PAINT = new Paint();
|
||||
|
||||
static {
|
||||
STANDARD_PAINT.setTextSize(STANDARD_TEXT_SIZE);
|
||||
}
|
||||
|
||||
private String text;
|
||||
private float contentPercent;
|
||||
|
||||
private Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
private Paint textPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
|
||||
|
||||
private int textColor = Color.BLACK;
|
||||
private int backgroundColor = Color.BLACK;
|
||||
|
||||
private float x = 0.0f;
|
||||
private float y = 0.0f;
|
||||
private boolean textSizeDirty = false;
|
||||
private Rect textBounds = new Rect();
|
||||
|
||||
public TextDrawable(String text, float contentPercent) {
|
||||
this.text = text;
|
||||
this.contentPercent = contentPercent;
|
||||
STANDARD_PAINT.getTextBounds(text, 0, text.length(), textBounds);
|
||||
}
|
||||
|
||||
public int getTextColor() {
|
||||
return textColor;
|
||||
}
|
||||
|
||||
public void setTextColor(int textColor) {
|
||||
if (this.textColor != textColor) {
|
||||
this.textColor = textColor;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
public int getBackgroundColor() {
|
||||
return backgroundColor;
|
||||
}
|
||||
|
||||
public void setBackgroundColor(int backgroundColor) {
|
||||
if (this.backgroundColor != backgroundColor) {
|
||||
this.backgroundColor = backgroundColor;
|
||||
invalidateSelf();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onBoundsChange(Rect bounds) {
|
||||
super.onBoundsChange(bounds);
|
||||
textSizeDirty = true;
|
||||
}
|
||||
|
||||
private void updateTextSizeIfDirty(Rect bounds) {
|
||||
if (!textSizeDirty) {
|
||||
return;
|
||||
}
|
||||
textSizeDirty = false;
|
||||
|
||||
int contentWidth = (int) (bounds.width() * contentPercent);
|
||||
int contentHeight = (int) (bounds.height() * contentPercent);
|
||||
float widthRatio = (float) contentWidth / (float) textBounds.width();
|
||||
float heightRatio = (float) contentHeight / (float) textBounds.height();
|
||||
float ratio = Math.min(widthRatio, heightRatio);
|
||||
float textSize = STANDARD_TEXT_SIZE * ratio;
|
||||
textPaint.setTextSize(textSize);
|
||||
x = (bounds.width() - textBounds.width() * ratio) / 2 - textBounds.left * ratio;
|
||||
y = (bounds.height() - textBounds.height() * ratio) / 2 - textBounds.top * ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(@NonNull Canvas canvas) {
|
||||
Rect bounds = getBounds();
|
||||
if (!bounds.isEmpty()) {
|
||||
// Draw background
|
||||
backgroundPaint.setColor(backgroundColor);
|
||||
canvas.drawRect(bounds, backgroundPaint);
|
||||
|
||||
if (!TextUtils.isEmpty(text)) {
|
||||
// Draw text
|
||||
updateTextSizeIfDirty(bounds);
|
||||
textPaint.setColor(textColor);
|
||||
canvas.drawText(text, x, y, textPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(@IntRange(from = 0, to = 255) int alpha) {}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(@Nullable ColorFilter colorFilter) {
|
||||
backgroundPaint.setColorFilter(colorFilter);
|
||||
textPaint.setColorFilter(colorFilter);
|
||||
invalidateSelf();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return PixelFormat.TRANSLUCENT;
|
||||
}
|
||||
}
|
||||
@@ -18,26 +18,34 @@ package com.hippo.ehviewer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.text.TextUtils;
|
||||
import com.google.firebase.analytics.FirebaseAnalytics;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.IoThreadPoolExecutor;
|
||||
import okhttp3.OkHttpClient;
|
||||
import okhttp3.Request;
|
||||
import java.util.Locale;
|
||||
|
||||
public final class Analytics {
|
||||
|
||||
private static final String DEVICE_LANGUAGE = "device_language";
|
||||
|
||||
private static FirebaseAnalytics analytics;
|
||||
private static String userId;
|
||||
private static OkHttpClient client;
|
||||
|
||||
private Analytics() {}
|
||||
|
||||
public static void start(Context context) {
|
||||
analytics = FirebaseAnalytics.getInstance(context);
|
||||
userId = Settings.getUserID();
|
||||
analytics.setUserId(userId);
|
||||
client = EhApplication.getOkHttpClient(context);
|
||||
analytics.setUserId(Settings.getUserID());
|
||||
|
||||
Locale locale = Locale.getDefault();
|
||||
String language = locale.getLanguage();
|
||||
if (TextUtils.isEmpty(language)) {
|
||||
language = "none";
|
||||
}
|
||||
String country = locale.getCountry();
|
||||
if (!TextUtils.isEmpty(country)) {
|
||||
language = language + "-" + country;
|
||||
}
|
||||
language = language.toLowerCase();
|
||||
analytics.setUserProperty(DEVICE_LANGUAGE, language);
|
||||
}
|
||||
|
||||
public static boolean isEnabled() {
|
||||
@@ -52,89 +60,4 @@ public final class Analytics {
|
||||
analytics.logEvent("scene_view", bundle);
|
||||
}
|
||||
}
|
||||
|
||||
public static void signIn() {
|
||||
addRecord("sign_in", null, null, null);
|
||||
}
|
||||
|
||||
public static void viewGalleryList() {
|
||||
addRecord("view_gallery_list", null, null, null);
|
||||
}
|
||||
|
||||
public static void imageSearch() {
|
||||
addRecord("image_search", null, null, null);
|
||||
}
|
||||
|
||||
public static void viewWhatsHot() {
|
||||
addRecord("view_whats_hot", null, null, null);
|
||||
}
|
||||
|
||||
public static void viewHistory() {
|
||||
addRecord("view_history", null, null, null);
|
||||
}
|
||||
|
||||
public static void viewFavourite() {
|
||||
addRecord("view_favourite", null, null, null);
|
||||
}
|
||||
|
||||
public static void viewGallery(long gid, String token) {
|
||||
addRecord("view_gallery", gid, token, null);
|
||||
}
|
||||
|
||||
public static void readGallery(long gid, String token) {
|
||||
addRecord("read_gallery", gid, token, null);
|
||||
}
|
||||
|
||||
public static void downloadGallery(long gid, String token) {
|
||||
addRecord("download_gallery", gid, token, null);
|
||||
}
|
||||
|
||||
public static void rateGallery(long gid, String token) {
|
||||
addRecord("rate_gallery", gid, token, null);
|
||||
}
|
||||
|
||||
public static void commentGallery(long gid, String token) {
|
||||
addRecord("comment_gallery", gid, token, null);
|
||||
}
|
||||
|
||||
public static void voteComment(long gid, String token) {
|
||||
addRecord("vote_comment", gid, token, null);
|
||||
}
|
||||
|
||||
public static void addGalleryToFavourite(long gid, String token) {
|
||||
addRecord("add_gallery_to_favourite", gid, token, null);
|
||||
}
|
||||
|
||||
public static void downloadArchive(long gid, String token) {
|
||||
addRecord("download_archive", gid, token, null);
|
||||
}
|
||||
|
||||
private static void addRecord(String action, Long gid, String token, Integer page) {
|
||||
if (isEnabled()) {
|
||||
IoThreadPoolExecutor.getInstance().execute(() -> {
|
||||
try {
|
||||
StringBuilder sb = new StringBuilder(150)
|
||||
.append("http://155.138.199.206:8080/addRecord?userId=")
|
||||
.append(userId)
|
||||
.append("&action=")
|
||||
.append(action);
|
||||
if (gid != null) {
|
||||
sb.append("&gid=").append(gid);
|
||||
}
|
||||
if (token != null) {
|
||||
sb.append("&token=").append(token);
|
||||
}
|
||||
if (page != null) {
|
||||
sb.append("&page=").append(page);
|
||||
}
|
||||
String url = sb.toString();
|
||||
|
||||
Request request = new Request.Builder().url(url).build();
|
||||
client.newCall(request).execute().close();
|
||||
} catch (Throwable t) {
|
||||
ExceptionUtils.throwIfFatal(t);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,9 +92,12 @@ public class EhApplication extends RecordingApplication {
|
||||
private SimpleDiskCache mSpiderInfoCache;
|
||||
private DownloadManager mDownloadManager;
|
||||
private Hosts mHosts;
|
||||
private FavouriteStatusRouter mFavouriteStatusRouter;
|
||||
|
||||
private final List<Activity> mActivityList = new ArrayList<>();
|
||||
|
||||
private boolean initialized = false;
|
||||
|
||||
public static EhApplication getInstance() {
|
||||
return instance;
|
||||
}
|
||||
@@ -107,7 +110,8 @@ public class EhApplication extends RecordingApplication {
|
||||
Thread.UncaughtExceptionHandler handler = Thread.getDefaultUncaughtExceptionHandler();
|
||||
Thread.setDefaultUncaughtExceptionHandler((t, e) -> {
|
||||
try {
|
||||
if (Settings.getSaveCrashLog()) {
|
||||
// Always save crash file if onCreate() is not done
|
||||
if (!initialized || Settings.getSaveCrashLog()) {
|
||||
Crash.saveCrashLog(instance, e);
|
||||
}
|
||||
} catch (Throwable ignored) { }
|
||||
@@ -183,6 +187,8 @@ public class EhApplication extends RecordingApplication {
|
||||
if (DEBUG_PRINT_NATIVE_MEMORY || DEBUG_PRINT_IMAGE_COUNT) {
|
||||
debugPrint();
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
private void clearTempDir() {
|
||||
@@ -342,6 +348,12 @@ public class EhApplication extends RecordingApplication {
|
||||
if (application.mGalleryDetailCache == null) {
|
||||
// Max size 25, 3 min timeout
|
||||
application.mGalleryDetailCache = new LruCache<>(25);
|
||||
getFavouriteStatusRouter().addListener((gid, slot) -> {
|
||||
GalleryDetail gd = application.mGalleryDetailCache.get(gid);
|
||||
if (gd != null) {
|
||||
gd.favoriteSlot = slot;
|
||||
}
|
||||
});
|
||||
}
|
||||
return application.mGalleryDetailCache;
|
||||
}
|
||||
@@ -356,6 +368,11 @@ public class EhApplication extends RecordingApplication {
|
||||
return application.mSpiderInfoCache;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static DownloadManager getDownloadManager() {
|
||||
return getDownloadManager(instance);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static DownloadManager getDownloadManager(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
@@ -374,6 +391,20 @@ public class EhApplication extends RecordingApplication {
|
||||
return application.mHosts;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static FavouriteStatusRouter getFavouriteStatusRouter() {
|
||||
return getFavouriteStatusRouter(getInstance());
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static FavouriteStatusRouter getFavouriteStatusRouter(@NonNull Context context) {
|
||||
EhApplication application = ((EhApplication) context.getApplicationContext());
|
||||
if (application.mFavouriteStatusRouter == null) {
|
||||
application.mFavouriteStatusRouter = new FavouriteStatusRouter();
|
||||
}
|
||||
return application.mFavouriteStatusRouter;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getDeveloperEmail() {
|
||||
return "ehviewersu$gmail.com".replace('$', '@');
|
||||
|
||||
@@ -44,10 +44,11 @@ import com.hippo.ehviewer.dao.QuickSearchDao;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.SqlUtils;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.IOUtils;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
import com.hippo.yorozuya.collect.SparseJLArray;
|
||||
import de.greenrobot.dao.AbstractDao;
|
||||
import de.greenrobot.dao.query.CloseableListIterator;
|
||||
import de.greenrobot.dao.query.LazyList;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
@@ -89,10 +90,9 @@ public class EhDB {
|
||||
|
||||
private static void upgradeDB(SQLiteDatabase db, int oldVersion) {
|
||||
switch (oldVersion) {
|
||||
case 1: // 1 to 2
|
||||
case 1: // 1 to 2, add FILTER
|
||||
FilterDao.createTable(db, true);
|
||||
break;
|
||||
case 2: // add ENABLE column to table FILTER
|
||||
case 2: // 2 to 3, add ENABLE column to table FILTER
|
||||
db.execSQL("CREATE TABLE " + "\"FILTER2\" (" +
|
||||
"\"_id\" INTEGER PRIMARY KEY ," +
|
||||
"\"MODE\" INTEGER NOT NULL ," +
|
||||
@@ -102,8 +102,24 @@ public class EhDB {
|
||||
"_id, MODE, TEXT, ENABLE)" +
|
||||
"SELECT _id, MODE, TEXT, 1 FROM FILTER;");
|
||||
db.execSQL("DROP TABLE FILTER");
|
||||
db.execSQL("ALTER TABLE FILTER2 RENAME TO FILTER");
|
||||
break;
|
||||
db.execSQL("ALTER TABLE FILTER2 RENAME TO FILTER");
|
||||
case 3: // 3 to 4, add PAGE_FROM and PAGE_TO column to QUICK_SEARCH
|
||||
db.execSQL("CREATE TABLE " + "\"QUICK_SEARCH2\" (" +
|
||||
"\"_id\" INTEGER PRIMARY KEY ," +
|
||||
"\"NAME\" TEXT," +
|
||||
"\"MODE\" INTEGER NOT NULL ," +
|
||||
"\"CATEGORY\" INTEGER NOT NULL ," +
|
||||
"\"KEYWORD\" TEXT," +
|
||||
"\"ADVANCE_SEARCH\" INTEGER NOT NULL ," +
|
||||
"\"MIN_RATING\" INTEGER NOT NULL ," +
|
||||
"\"PAGE_FROM\" INTEGER NOT NULL ," +
|
||||
"\"PAGE_TO\" INTEGER NOT NULL ," +
|
||||
"\"TIME\" INTEGER NOT NULL );");
|
||||
db.execSQL("INSERT INTO \"QUICK_SEARCH2\" (" +
|
||||
"_id, NAME, MODE, CATEGORY, KEYWORD, ADVANCE_SEARCH, MIN_RATING, PAGE_FROM, PAGE_TO, TIME)" +
|
||||
"SELECT _id, NAME, MODE, CATEGORY, KEYWORD, ADVANCE_SEARCH, MIN_RATING, -1, -1, TIME FROM QUICK_SEARCH;");
|
||||
db.execSQL("DROP TABLE QUICK_SEARCH");
|
||||
db.execSQL("ALTER TABLE QUICK_SEARCH2 RENAME TO QUICK_SEARCH");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,30 +646,64 @@ public class EhDB {
|
||||
sDaoSession.getFilterDao().update(filter);
|
||||
}
|
||||
|
||||
public static synchronized boolean exportDB(Context context, File file) {
|
||||
File dbFile = context.getDatabasePath("eh.db");
|
||||
if (null == dbFile || !dbFile.isFile()) {
|
||||
return false;
|
||||
}
|
||||
if (null == file || !FileUtils.ensureFile(file)) {
|
||||
return false;
|
||||
}
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(dbFile);
|
||||
os = new FileOutputStream(file);
|
||||
IOUtils.copy(is, os);
|
||||
return true;
|
||||
private static <T> boolean copyDao(AbstractDao<T, ?> from, AbstractDao<T, ?> to) {
|
||||
try (CloseableListIterator<T> iterator = from.queryBuilder().listIterator()) {
|
||||
while (iterator.hasNext()) {
|
||||
to.insert(iterator.next());
|
||||
}
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static synchronized boolean exportDB(Context context, File file) {
|
||||
final String ehExportName = "eh.export.db";
|
||||
|
||||
// Delete old export db
|
||||
context.deleteDatabase(ehExportName);
|
||||
|
||||
DBOpenHelper helper = new DBOpenHelper(context.getApplicationContext(), ehExportName, null);
|
||||
|
||||
try {
|
||||
// Copy data to a export db
|
||||
try (SQLiteDatabase db = helper.getWritableDatabase()) {
|
||||
DaoMaster daoMaster = new DaoMaster(db);
|
||||
DaoSession exportSession = daoMaster.newSession();
|
||||
if (!copyDao(sDaoSession.getDownloadsDao(), exportSession.getDownloadsDao())) return false;
|
||||
if (!copyDao(sDaoSession.getDownloadLabelDao(), exportSession.getDownloadLabelDao())) return false;
|
||||
if (!copyDao(sDaoSession.getDownloadDirnameDao(), exportSession.getDownloadDirnameDao())) return false;
|
||||
if (!copyDao(sDaoSession.getHistoryDao(), exportSession.getHistoryDao())) return false;
|
||||
if (!copyDao(sDaoSession.getQuickSearchDao(), exportSession.getQuickSearchDao())) return false;
|
||||
if (!copyDao(sDaoSession.getLocalFavoritesDao(), exportSession.getLocalFavoritesDao())) return false;
|
||||
if (!copyDao(sDaoSession.getBookmarksBao(), exportSession.getBookmarksBao())) return false;
|
||||
if (!copyDao(sDaoSession.getFilterDao(), exportSession.getFilterDao())) return false;
|
||||
}
|
||||
|
||||
// Copy export db to data dir
|
||||
File dbFile = context.getDatabasePath(ehExportName);
|
||||
if (dbFile == null || !dbFile.isFile()) {
|
||||
return false;
|
||||
}
|
||||
InputStream is = null;
|
||||
OutputStream os = null;
|
||||
try {
|
||||
is = new FileInputStream(dbFile);
|
||||
os = new FileOutputStream(file);
|
||||
IOUtils.copy(is, os);
|
||||
return true;
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(os);
|
||||
}
|
||||
// Delete failed file
|
||||
file.delete();
|
||||
return false;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
IOUtils.closeQuietly(os);
|
||||
context.deleteDatabase(ehExportName);
|
||||
}
|
||||
// Delete failed file
|
||||
file.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class FavouriteStatusRouter {
|
||||
|
||||
private static final String KEY_DATA_MAP_NEXT_ID = "data_map_next_id";
|
||||
|
||||
private final IntIdGenerator idGenerator = new IntIdGenerator(Settings.getInt(KEY_DATA_MAP_NEXT_ID, 0));
|
||||
@SuppressLint("UseSparseArrays")
|
||||
private final HashMap<Integer, Map<Long, GalleryInfo>> maps = new HashMap<>();
|
||||
|
||||
private List<Listener> listeners = new ArrayList<>();
|
||||
|
||||
public int saveDataMap(Map<Long, GalleryInfo> map) {
|
||||
int id = idGenerator.nextId();
|
||||
maps.put(id, map);
|
||||
Settings.putInt(KEY_DATA_MAP_NEXT_ID, idGenerator.nextId());
|
||||
return id;
|
||||
}
|
||||
|
||||
public Map<Long, GalleryInfo> restoreDataMap(int id) {
|
||||
return maps.remove(id);
|
||||
}
|
||||
|
||||
public void modifyFavourites(long gid, int slot) {
|
||||
for (Map<Long, GalleryInfo> map : maps.values()) {
|
||||
GalleryInfo info = map.get(gid);
|
||||
if (info != null) {
|
||||
info.favoriteSlot = slot;
|
||||
}
|
||||
}
|
||||
|
||||
for (Listener listener : listeners) {
|
||||
listener.onModifyFavourites(gid, slot);
|
||||
}
|
||||
}
|
||||
|
||||
public void addListener(Listener listener) {
|
||||
listeners.add(listener);
|
||||
}
|
||||
|
||||
public void removeListener(Listener listener) {
|
||||
listeners.remove(listener);
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
void onModifyFavourites(long gid, int slot);
|
||||
}
|
||||
}
|
||||
@@ -28,6 +28,7 @@ import com.hippo.ehviewer.client.EhConfig;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.FavListUrlBuilder;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.scene.GalleryListScene;
|
||||
import com.hippo.glgallery.GalleryView;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
@@ -36,6 +37,7 @@ import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import java.io.File;
|
||||
import java.util.Locale;
|
||||
|
||||
public class Settings {
|
||||
|
||||
@@ -49,6 +51,16 @@ public class Settings {
|
||||
sContext = context.getApplicationContext();
|
||||
sSettingsPre = PreferenceManager.getDefaultSharedPreferences(sContext);
|
||||
sEhConfig = loadEhConfig();
|
||||
fixDefaultValue(context);
|
||||
}
|
||||
|
||||
private static void fixDefaultValue(Context context) {
|
||||
// Enable builtin hosts if the country is CN
|
||||
if (!sSettingsPre.contains(KEY_BUILT_IN_HOSTS)) {
|
||||
if ("CN".equals(Locale.getDefault().getCountry())) {
|
||||
putBuiltInHosts(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static EhConfig loadEhConfig() {
|
||||
@@ -250,7 +262,7 @@ public class Settings {
|
||||
}
|
||||
|
||||
public static final String KEY_APPLY_NAV_BAR_THEME_COLOR = "apply_nav_bar_theme_color";
|
||||
private static final boolean DEFAULT_APPLY_NAV_BAR_THEME_COLOR = false;
|
||||
private static final boolean DEFAULT_APPLY_NAV_BAR_THEME_COLOR = true;
|
||||
|
||||
public static boolean getApplyNavBarThemeColor() {
|
||||
return getBoolean(KEY_APPLY_NAV_BAR_THEME_COLOR, DEFAULT_APPLY_NAV_BAR_THEME_COLOR);
|
||||
@@ -267,6 +279,22 @@ public class Settings {
|
||||
putIntToStr(KEY_GALLERY_SITE, value);
|
||||
}
|
||||
|
||||
private static final String KEY_LAUNCH_PAGE = "launch_page";
|
||||
private static final int DEFAULT_LAUNCH_PAGE = 0;
|
||||
|
||||
public static String getLaunchPageGalleryListSceneAction() {
|
||||
int value = getIntFromStr(KEY_LAUNCH_PAGE, DEFAULT_LAUNCH_PAGE);
|
||||
switch (value) {
|
||||
default:
|
||||
case 0:
|
||||
return GalleryListScene.ACTION_HOMEPAGE;
|
||||
case 1:
|
||||
return GalleryListScene.ACTION_SUBSCRIPTION;
|
||||
case 2:
|
||||
return GalleryListScene.ACTION_WHATS_HOT;
|
||||
}
|
||||
}
|
||||
|
||||
public static final String KEY_LIST_MODE = "list_mode";
|
||||
private static final int DEFAULT_LIST_MODE = 0;
|
||||
|
||||
|
||||
@@ -46,7 +46,6 @@ public class EhClient {
|
||||
public static final int METHOD_ADD_FAVORITES_RANGE = 10;
|
||||
public static final int METHOD_MODIFY_FAVORITES = 11;
|
||||
public static final int METHOD_GET_TORRENT_LIST = 12;
|
||||
public static final int METHOD_GET_WHATS_HOT = 13;
|
||||
public static final int METHOD_GET_PROFILE = 14;
|
||||
public static final int METHOD_VOTE_COMMENT = 15;
|
||||
public static final int METHOD_IMAGE_SEARCH = 16;
|
||||
@@ -139,7 +138,7 @@ public class EhClient {
|
||||
try {
|
||||
switch (mMethod) {
|
||||
case METHOD_SIGN_IN:
|
||||
return EhEngine.signIn(this, mOkHttpClient, (String) params[0], (String) params[1], (String) params[2], (String) params[3]);
|
||||
return EhEngine.signIn(this, mOkHttpClient, (String) params[0], (String) params[1]);
|
||||
case METHOD_GET_GALLERY_LIST:
|
||||
return EhEngine.getGalleryList(this, mOkHttpClient, (String) params[0]);
|
||||
case METHOD_GET_GALLERY_DETAIL:
|
||||
@@ -149,7 +148,7 @@ public class EhClient {
|
||||
case METHOD_GET_RATE_GALLERY:
|
||||
return EhEngine.rateGallery(this, mOkHttpClient, (Long) params[0], (String) params[1], (Long) params[2], (String) params[3], (Float) params[4]);
|
||||
case METHOD_GET_COMMENT_GALLERY:
|
||||
return EhEngine.commentGallery(this, mOkHttpClient, (String) params[0], (String) params[1]);
|
||||
return EhEngine.commentGallery(this, mOkHttpClient, (String) params[0], (String) params[1], (String) params[2]);
|
||||
case METHOD_GET_GALLERY_TOKEN:
|
||||
return EhEngine.getGalleryToken(this, mOkHttpClient, (Long) params[0], (String) params[1], (Integer) params[2]);
|
||||
case METHOD_GET_FAVORITES:
|
||||
@@ -162,8 +161,6 @@ public class EhClient {
|
||||
return EhEngine.modifyFavorites(this, mOkHttpClient, (String) params[0], (long[]) params[1], (Integer) params[2], (Boolean) params[3]);
|
||||
case METHOD_GET_TORRENT_LIST:
|
||||
return EhEngine.getTorrentList(this, mOkHttpClient, (String) params[0], (Long) params[1], (String) params[2]);
|
||||
case METHOD_GET_WHATS_HOT:
|
||||
return EhEngine.getWhatsHot(this, mOkHttpClient);
|
||||
case METHOD_GET_PROFILE:
|
||||
return EhEngine.getProfile(this, mOkHttpClient);
|
||||
case METHOD_VOTE_COMMENT:
|
||||
|
||||
@@ -289,6 +289,7 @@ public class EhConfig implements Cloneable {
|
||||
public static final int ASIAN_PORN = 0x80;
|
||||
public static final int NON_H = 0x100;
|
||||
public static final int WESTERN = 0x200;
|
||||
public static final int ALL_CATEGORY = 0x3ff;
|
||||
|
||||
public static final int NAMESPACES_RECLASS = 0x1;
|
||||
public static final int NAMESPACES_LANGUAGE = 0x2;
|
||||
|
||||
@@ -39,11 +39,13 @@ public class EhDns implements Dns {
|
||||
|
||||
static {
|
||||
Map<String, InetAddress> map = new HashMap<>();
|
||||
put(map, "e-hentai.org", "104.24.255.11");
|
||||
put(map, "e-hentai.org", "104.20.26.25");
|
||||
put(map, "repo.e-hentai.org", "94.100.29.73");
|
||||
put(map, "forums.e-hentai.org", "94.100.18.243");
|
||||
put(map, "ehgt.org", "81.171.14.118");
|
||||
put(map, "ul.ehgt.org", "94.100.24.82");
|
||||
put(map, "github.com", "192.30.255.112");
|
||||
put(map, "raw.githubusercontent.com", "151.101.0.133");
|
||||
builtInHosts = map;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.PreviewSet;
|
||||
@@ -46,7 +46,6 @@ import com.hippo.ehviewer.client.parser.RateGalleryParser;
|
||||
import com.hippo.ehviewer.client.parser.SignInParser;
|
||||
import com.hippo.ehviewer.client.parser.TorrentParser;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.client.parser.WhatsHotParser;
|
||||
import com.hippo.network.StatusCodeException;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.yorozuya.AssertUtils;
|
||||
@@ -78,6 +77,8 @@ public class EhEngine {
|
||||
private static final String SAD_PANDA_TYPE = "image/gif";
|
||||
private static final String SAD_PANDA_LENGTH = "9615";
|
||||
|
||||
private static final String KOKOMADE_URL = "https://exhentai.org/img/kokomade.jpg";
|
||||
|
||||
public static final MediaType MEDIA_TYPE_JSON = MediaType.parse("application/json; charset=utf-8");
|
||||
private static final MediaType MEDIA_TYPE_JPEG = MediaType.parse("image/jpeg");
|
||||
|
||||
@@ -102,9 +103,16 @@ public class EhEngine {
|
||||
throw new EhException("Sad Panda");
|
||||
}
|
||||
|
||||
// Check kokomade
|
||||
if (body != null && body.contains(KOKOMADE_URL)) {
|
||||
throw new EhException("今回はここまで\n\n" + GetText.getString(R.string.kokomade_tip));
|
||||
}
|
||||
|
||||
if (e instanceof ParseException) {
|
||||
if (body != null && !body.contains("<")){
|
||||
if (body != null && !body.contains("<")) {
|
||||
throw new EhException(body);
|
||||
} else if (TextUtils.isEmpty(body)) {
|
||||
throw new EhException(GetText.getString(R.string.error_empty_html));
|
||||
} else {
|
||||
if (Settings.getSaveParseErrorBody()) {
|
||||
AppConfig.saveParseErrorBody((ParseException) e);
|
||||
@@ -133,17 +141,13 @@ public class EhEngine {
|
||||
}
|
||||
|
||||
public static String signIn(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String username, String password, String recaptchaChallenge, String recaptchaResponse) throws Throwable {
|
||||
String username, String password) throws Throwable {
|
||||
FormBody.Builder builder = new FormBody.Builder()
|
||||
.add("UserName", username)
|
||||
.add("PassWord", password)
|
||||
.add("submit", "Log me in")
|
||||
.add("CookieDate", "1")
|
||||
.add("temporary_https", "off");
|
||||
if (!TextUtils.isEmpty(recaptchaChallenge) && !TextUtils.isEmpty(recaptchaResponse)) {
|
||||
builder.add("recaptcha_challenge_field", recaptchaChallenge);
|
||||
builder.add("recaptcha_response_field", recaptchaResponse);
|
||||
}
|
||||
String url = EhUrl.API_SIGN_IN;
|
||||
String referer = "https://forums.e-hentai.org/index.php?act=Login&CODE=00";
|
||||
String origin = "https://forums.e-hentai.org";
|
||||
@@ -174,6 +178,59 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
private static void fillGalleryList(@Nullable EhClient.Task task, OkHttpClient okHttpClient, List<GalleryInfo> list, String url, boolean filter) throws Throwable {
|
||||
// Filter title and uploader
|
||||
if (filter) {
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
boolean hasTags = false;
|
||||
boolean hasPages = false;
|
||||
boolean hasRated = false;
|
||||
for (GalleryInfo gi : list) {
|
||||
if (gi.simpleTags != null) {
|
||||
hasTags = true;
|
||||
}
|
||||
if (gi.pages != 0) {
|
||||
hasPages = true;
|
||||
}
|
||||
if (gi.rated) {
|
||||
hasRated = true;
|
||||
}
|
||||
}
|
||||
|
||||
boolean needApi = (filter && sEhFilter.needTags() && !hasTags) ||
|
||||
(Settings.getShowGalleryPages() && !hasPages) ||
|
||||
hasRated;
|
||||
if (needApi) {
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
}
|
||||
|
||||
// Filter tag
|
||||
if (filter) {
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
// Thumbnail mode need filter uploader again
|
||||
if (!sEhFilter.filterUploader(info) || !sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
}
|
||||
|
||||
public static GalleryListParser.Result getGalleryList(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
|
||||
String url) throws Throwable {
|
||||
String referer = EhUrl.getReferer();
|
||||
@@ -202,50 +259,7 @@ public class EhEngine {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Filter title and uploader
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
boolean anyRated = false;
|
||||
for (GalleryInfo info : list) {
|
||||
if (info.rated) {
|
||||
anyRated = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
boolean needFillByApi = list.size() > 0
|
||||
&& (TextUtils.isEmpty(list.get(0).uploader)
|
||||
|| anyRated
|
||||
|| Settings.getShowJpnTitle()
|
||||
|| Settings.getShowGalleryPages()
|
||||
|| sEhFilter.needCallApi());
|
||||
|
||||
if (needFillByApi) {
|
||||
// Fill by api
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
|
||||
// Filter tag
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
fillGalleryList(task, okHttpClient, result.galleryInfoList, url, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -408,10 +422,15 @@ public class EhEngine {
|
||||
}
|
||||
}
|
||||
|
||||
public static GalleryComment[] commentGallery(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url, String comment) throws Throwable {
|
||||
FormBody.Builder builder = new FormBody.Builder()
|
||||
.add("commenttext_new", comment);
|
||||
public static GalleryCommentList commentGallery(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url, String comment, String id) throws Throwable {
|
||||
FormBody.Builder builder = new FormBody.Builder();
|
||||
if (id == null) {
|
||||
builder.add("commenttext_new", comment);
|
||||
} else {
|
||||
builder.add("commenttext_edit", comment);
|
||||
builder.add("edit_comment", id);
|
||||
}
|
||||
String origin = EhUrl.getOrigin();
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, url, origin)
|
||||
@@ -512,15 +531,7 @@ public class EhEngine {
|
||||
throw e;
|
||||
}
|
||||
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
|
||||
if (list.size() > 0 && (TextUtils.isEmpty(list.get(0).uploader) || Settings.getShowJpnTitle() || Settings.getShowGalleryPages())) {
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
fillGalleryList(task, okHttpClient, result.galleryInfoList, url, false);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -629,14 +640,7 @@ public class EhEngine {
|
||||
throw e;
|
||||
}
|
||||
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
if (list.size() > 0 && (TextUtils.isEmpty(list.get(0).uploader) || Settings.getShowJpnTitle() || Settings.getShowGalleryPages())) {
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
fillGalleryList(task, okHttpClient, result.galleryInfoList, url, false);
|
||||
|
||||
return result;
|
||||
}
|
||||
@@ -750,46 +754,6 @@ public class EhEngine {
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<GalleryInfo> getWhatsHot(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient) throws Throwable {
|
||||
String url = EhUrl.HOST_E;
|
||||
Log.d(TAG, url);
|
||||
Request request = new EhRequestBuilder(url, null).build();
|
||||
Call call = okHttpClient.newCall(request);
|
||||
|
||||
// Put call
|
||||
if (null != task) {
|
||||
task.setCall(call);
|
||||
}
|
||||
|
||||
String body = null;
|
||||
Headers headers = null;
|
||||
List<GalleryInfo> list;
|
||||
int code = -1;
|
||||
try {
|
||||
Response response = call.execute();
|
||||
code = response.code();
|
||||
headers = response.headers();
|
||||
body = response.body().string();
|
||||
list = WhatsHotParser.parse(body);
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
throwException(call, code, headers, body, e);
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (list.size() > 0) {
|
||||
// Fill by api
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
private static ProfileParser.Result getProfileInternal(@Nullable EhClient.Task task,
|
||||
OkHttpClient okHttpClient, String url, String referer) throws Throwable {
|
||||
Log.d(TAG, url);
|
||||
@@ -952,35 +916,7 @@ public class EhEngine {
|
||||
throw e;
|
||||
}
|
||||
|
||||
// Filter title and uploader
|
||||
List<GalleryInfo> list = result.galleryInfoList;
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTitle(info) || !sEhFilter.filterUploader(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
|
||||
if (list.size() > 0 && (TextUtils.isEmpty(list.get(0).uploader) || Settings.getShowJpnTitle() || Settings.getShowGalleryPages() || sEhFilter.needCallApi())) {
|
||||
// Fill by api
|
||||
fillGalleryListByApi(task, okHttpClient, list, url);
|
||||
|
||||
// Filter tag
|
||||
for (int i = 0, n = list.size(); i < n; i++) {
|
||||
GalleryInfo info = list.get(i);
|
||||
if (!sEhFilter.filterTag(info) || !sEhFilter.filterTagNamespace(info)) {
|
||||
list.remove(i);
|
||||
i--;
|
||||
n--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (GalleryInfo info : list) {
|
||||
info.thumb = EhUrl.getFixedPreviewThumbUrl(info.thumb);
|
||||
}
|
||||
fillGalleryList(task, okHttpClient, result.galleryInfoList, url, true);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ public final class EhFilter {
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized boolean needCallApi() {
|
||||
public synchronized boolean needTags() {
|
||||
return 0 != mTagFilterList.size() || 0 != mTagNamespaceFilterList.size();
|
||||
}
|
||||
|
||||
@@ -157,9 +157,8 @@ public final class EhFilter {
|
||||
String title = info.title;
|
||||
List<Filter> filters = mTitleFilterList;
|
||||
if (null != title && filters.size() > 0) {
|
||||
title = title.toLowerCase();
|
||||
for (int i = 0, n = filters.size(); i < n; i++) {
|
||||
if (filters.get(i).enable && title.contains(filters.get(i).text)) {
|
||||
if (filters.get(i).enable && title.toLowerCase().contains(filters.get(i).text)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,6 +40,9 @@ public class EhUrl {
|
||||
public static final String API_E = HOST_E + "api.php";
|
||||
public static final String API_EX = HOST_EX + "api.php";
|
||||
|
||||
public static final String URL_POPULAR_E = "https://e-hentai.org/popular";
|
||||
public static final String URL_POPULAR_EX = "https://exhentai.org/popular";
|
||||
|
||||
public static final String URL_IMAGE_SEARCH_E = "https://upload.e-hentai.org/image_lookup.php";
|
||||
public static final String URL_IMAGE_SEARCH_EX = "https://exhentai.org/upload/image_lookup.php";
|
||||
|
||||
@@ -55,10 +58,16 @@ public class EhUrl {
|
||||
public static final String ORIGIN_EX = REFERER_EX;
|
||||
public static final String ORIGIN_E = REFERER_E;
|
||||
|
||||
public static final String UCONFIG_E = HOST_E + "uconfig.php";
|
||||
public static final String UCONFIG_EX = HOST_EX + "uconfig.php";
|
||||
public static final String URL_UCONFIG_E = HOST_E + "uconfig.php";
|
||||
public static final String URL_UCONFIG_EX = HOST_EX + "uconfig.php";
|
||||
|
||||
private static final String URL_PREFIX_THUMB_E = "https://ul.ehgt.org/";
|
||||
public static final String URL_MY_TAGS_E = HOST_E + "mytags";
|
||||
public static final String URL_MY_TAGS_EX = HOST_EX + "mytags";
|
||||
|
||||
public static final String URL_WATCHED_E = HOST_E + "watched";
|
||||
public static final String URL_WATCHED_EX = HOST_EX + "watched";
|
||||
|
||||
private static final String URL_PREFIX_THUMB_E = "https://ehgt.org/";
|
||||
private static final String URL_PREFIX_THUMB_EX = "https://exhentai.org/t/";
|
||||
|
||||
public static String getGalleryDetailUrl(long gid, String token) {
|
||||
@@ -119,9 +128,19 @@ public class EhUrl {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
case SITE_E:
|
||||
return UCONFIG_E;
|
||||
return URL_UCONFIG_E;
|
||||
case SITE_EX:
|
||||
return UCONFIG_EX;
|
||||
return URL_UCONFIG_EX;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getMyTagsUrl() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
case SITE_E:
|
||||
return URL_MY_TAGS_E;
|
||||
case SITE_EX:
|
||||
return URL_MY_TAGS_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,6 +171,17 @@ public class EhUrl {
|
||||
return "https://ehwiki.org/wiki/" + tag.replace(' ', '_');
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getPopularUrl() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
case SITE_E:
|
||||
return URL_POPULAR_E;
|
||||
case SITE_EX:
|
||||
return URL_POPULAR_EX;
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getImageSearchUrl() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
@@ -163,6 +193,17 @@ public class EhUrl {
|
||||
}
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static String getWatchedUrl() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
case SITE_E:
|
||||
return URL_WATCHED_E;
|
||||
case SITE_EX:
|
||||
return URL_WATCHED_EX;
|
||||
}
|
||||
}
|
||||
|
||||
public static String getThumbUrlPrefix() {
|
||||
switch (Settings.getGallerySite()) {
|
||||
default:
|
||||
|
||||
@@ -70,9 +70,9 @@ public class EhUtils {
|
||||
new String[] { "misc" },
|
||||
new String[] { "doujinshi" },
|
||||
new String[] { "manga" },
|
||||
new String[] { "artistcg", "Artist CG Sets" },
|
||||
new String[] { "gamecg", "Game CG Sets" },
|
||||
new String[] { "imageset", "Image Sets" },
|
||||
new String[] { "artistcg", "Artist CG Sets", "Artist CG" },
|
||||
new String[] { "gamecg", "Game CG Sets", "Game CG" },
|
||||
new String[] { "imageset", "Image Sets", "Image Set" },
|
||||
new String[] { "cosplay" },
|
||||
new String[] { "asianporn", "Asian Porn" },
|
||||
new String[] { "non-h" },
|
||||
|
||||
@@ -69,11 +69,18 @@ public class FavListUrlBuilder implements Parcelable {
|
||||
UrlBuilder ub = new UrlBuilder(EhUrl.getFavoritesUrl());
|
||||
if (isValidFavCat(mFavCat)) {
|
||||
ub.addQuery("favcat", Integer.toString(mFavCat));
|
||||
} else if (mFavCat == FAV_CAT_ALL) {
|
||||
ub.addQuery("favcat", "all");
|
||||
}
|
||||
if (!TextUtils.isEmpty(mKeyword)) {
|
||||
try {
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
ub.addQuery("f_apply", "Search+Favorites");
|
||||
// Name
|
||||
ub.addQuery("sn", "on");
|
||||
// Tags
|
||||
ub.addQuery("st", "on");
|
||||
// Note
|
||||
ub.addQuery("sf", "on");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
Log.e(TAG, "Can't URLEncoder.encode " + mKeyword);
|
||||
}
|
||||
|
||||
@@ -24,12 +24,16 @@ public class GalleryComment implements Parcelable {
|
||||
// 0 for uploader comment. can't vote
|
||||
public long id;
|
||||
public int score;
|
||||
public boolean voteUp;
|
||||
public boolean voteDown;
|
||||
public boolean editable;
|
||||
public boolean voteUpAble;
|
||||
public boolean voteUpEd;
|
||||
public boolean voteDownAble;
|
||||
public boolean voteDownEd;
|
||||
public String voteState;
|
||||
public long time;
|
||||
public String user;
|
||||
public String comment;
|
||||
public long lastEdited;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -40,12 +44,16 @@ public class GalleryComment implements Parcelable {
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeLong(this.id);
|
||||
dest.writeInt(this.score);
|
||||
dest.writeByte(voteUp ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteDown ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(editable ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteUpAble ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteUpEd ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteDownAble ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(voteDownEd ? (byte) 1 : (byte) 0);
|
||||
dest.writeString(this.voteState);
|
||||
dest.writeLong(this.time);
|
||||
dest.writeString(this.user);
|
||||
dest.writeString(this.comment);
|
||||
dest.writeLong(this.lastEdited);
|
||||
}
|
||||
|
||||
public GalleryComment() {
|
||||
@@ -54,12 +62,16 @@ public class GalleryComment implements Parcelable {
|
||||
protected GalleryComment(Parcel in) {
|
||||
this.id = in.readLong();
|
||||
this.score = in.readInt();
|
||||
this.voteUp = in.readByte() != 0;
|
||||
this.voteDown = in.readByte() != 0;
|
||||
this.editable = in.readByte() != 0;
|
||||
this.voteUpAble = in.readByte() != 0;
|
||||
this.voteUpEd = in.readByte() != 0;
|
||||
this.voteDownAble = in.readByte() != 0;
|
||||
this.voteDownEd = in.readByte() != 0;
|
||||
this.voteState = in.readString();
|
||||
this.time = in.readLong();
|
||||
this.user = in.readString();
|
||||
this.comment = in.readString();
|
||||
this.lastEdited = in.readLong();
|
||||
}
|
||||
|
||||
public static final Creator<GalleryComment> CREATOR = new Creator<GalleryComment>() {
|
||||
|
||||
@@ -0,0 +1,65 @@
|
||||
/*
|
||||
* 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.client.data;
|
||||
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import java.util.Arrays;
|
||||
|
||||
public class GalleryCommentList implements Parcelable {
|
||||
|
||||
public GalleryComment[] comments;
|
||||
public boolean hasMore;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel dest, int flags) {
|
||||
dest.writeParcelableArray(comments, flags);
|
||||
dest.writeByte(hasMore ? (byte) 1 : (byte) 0);
|
||||
}
|
||||
|
||||
public GalleryCommentList(GalleryComment[] comments, boolean hasMore) {
|
||||
this.comments = comments;
|
||||
this.hasMore = hasMore;
|
||||
}
|
||||
|
||||
protected GalleryCommentList(Parcel in) {
|
||||
Parcelable[] array = in.readParcelableArray(getClass().getClassLoader());
|
||||
if (array != null) {
|
||||
comments = Arrays.copyOf(array, array.length, GalleryComment[].class);
|
||||
} else {
|
||||
comments = null;
|
||||
}
|
||||
hasMore = in.readByte() != 0;
|
||||
}
|
||||
|
||||
public static final Creator<GalleryCommentList> CREATOR = new Creator<GalleryCommentList>() {
|
||||
@Override
|
||||
public GalleryCommentList createFromParcel(Parcel in) {
|
||||
return new GalleryCommentList(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GalleryCommentList[] newArray(int size) {
|
||||
return new GalleryCommentList[size];
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -37,10 +37,9 @@ public class GalleryDetail extends GalleryInfo {
|
||||
public boolean isFavorited;
|
||||
public int ratingCount;
|
||||
public GalleryTagGroup[] tags;
|
||||
public GalleryComment[] comments;
|
||||
public GalleryCommentList comments;
|
||||
public int previewPages;
|
||||
public PreviewSet previewSet;
|
||||
public String favoriteName;
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
@@ -61,11 +60,10 @@ public class GalleryDetail extends GalleryInfo {
|
||||
dest.writeInt(this.favoriteCount);
|
||||
dest.writeByte(isFavorited ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.ratingCount);
|
||||
dest.writeParcelableArray(this.tags, 0);
|
||||
dest.writeParcelableArray(this.comments, 0);
|
||||
dest.writeParcelableArray(this.tags, flags);
|
||||
dest.writeParcelable(this.comments, flags);
|
||||
dest.writeInt(this.previewPages);
|
||||
dest.writeParcelable(previewSet, flags);
|
||||
dest.writeString(this.favoriteName);
|
||||
}
|
||||
|
||||
public GalleryDetail() {
|
||||
@@ -90,15 +88,9 @@ public class GalleryDetail extends GalleryInfo {
|
||||
} else {
|
||||
this.tags = null;
|
||||
}
|
||||
array = in.readParcelableArray(GalleryComment.class.getClassLoader());
|
||||
if (array != null) {
|
||||
this.comments = Arrays.copyOf(array, array.length, GalleryComment[].class);
|
||||
} else {
|
||||
this.comments = null;
|
||||
}
|
||||
this.comments = in.readParcelable(getClass().getClassLoader());
|
||||
this.previewPages = in.readInt();
|
||||
this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader());
|
||||
this.favoriteName = in.readString();
|
||||
}
|
||||
|
||||
public static final Creator<GalleryDetail> CREATOR = new Creator<GalleryDetail>() {
|
||||
|
||||
@@ -61,21 +61,21 @@ public class GalleryInfo implements Parcelable {
|
||||
};
|
||||
|
||||
public static final Pattern[] S_LANG_PATTERNS = {
|
||||
Pattern.compile("[(\\[]eng(?:lish)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]eng(?:lish)?[)\\]]|英訳", Pattern.CASE_INSENSITIVE),
|
||||
// [((\[]ch(?:inese)?[))\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳
|
||||
Pattern.compile("[(\uFF08\\[]ch(?:inese)?[)\uFF09\\]]|[汉漢]化|中[国國][语語]|中文|中国翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]korean?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]rus(?:sian)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]fr(?:ench)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]portuguese", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]thai(?: ภาษาไทย)?[)\\]]|แปลไทย", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]german[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]italiano?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]vietnamese(?: Tiếng Việt)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]polish[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]hun(?:garian)?[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]dutch[)\\]]", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]spanish[)\\]]|[(\\[]Español[)\\]]|スペイン翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]korean?[)\\]]|韓国翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]rus(?:sian)?[)\\]]|ロシア翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]fr(?:ench)?[)\\]]|フランス翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]portuguese|ポルトガル翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]thai(?: ภาษาไทย)?[)\\]]|แปลไทย|タイ翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]german[)\\]]|ドイツ翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]italiano?[)\\]]|イタリア翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]vietnamese(?: Tiếng Việt)?[)\\]]|ベトナム翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]polish[)\\]]|ポーランド翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]hun(?:garian)?[)\\]]|ハンガリー翻訳", Pattern.CASE_INSENSITIVE),
|
||||
Pattern.compile("[(\\[]dutch[)\\]]|オランダ翻訳", Pattern.CASE_INSENSITIVE),
|
||||
};
|
||||
|
||||
public static final String[] S_LANG_TAGS = {
|
||||
@@ -104,6 +104,7 @@ public class GalleryInfo implements Parcelable {
|
||||
public String posted;
|
||||
public String uploader;
|
||||
public float rating;
|
||||
public boolean rated;
|
||||
@Nullable
|
||||
public String[] simpleTags;
|
||||
public int pages;
|
||||
@@ -120,7 +121,8 @@ public class GalleryInfo implements Parcelable {
|
||||
*/
|
||||
public String simpleLanguage;
|
||||
|
||||
public boolean rated;
|
||||
public int favoriteSlot = -2;
|
||||
public String favoriteName;
|
||||
|
||||
public final void generateSLang() {
|
||||
if (simpleTags != null) {
|
||||
@@ -168,6 +170,7 @@ public class GalleryInfo implements Parcelable {
|
||||
dest.writeString(this.posted);
|
||||
dest.writeString(this.uploader);
|
||||
dest.writeFloat(this.rating);
|
||||
dest.writeByte(this.rated ? (byte) 1 : (byte) 0);
|
||||
dest.writeString(this.simpleLanguage);
|
||||
dest.writeStringArray(this.simpleTags);
|
||||
dest.writeInt(this.thumbWidth);
|
||||
@@ -175,6 +178,8 @@ public class GalleryInfo implements Parcelable {
|
||||
dest.writeInt(this.spanSize);
|
||||
dest.writeInt(this.spanIndex);
|
||||
dest.writeInt(this.spanGroupIndex);
|
||||
dest.writeInt(this.favoriteSlot);
|
||||
dest.writeString(this.favoriteName);
|
||||
}
|
||||
|
||||
public GalleryInfo() {}
|
||||
@@ -189,6 +194,7 @@ public class GalleryInfo implements Parcelable {
|
||||
this.posted = in.readString();
|
||||
this.uploader = in.readString();
|
||||
this.rating = in.readFloat();
|
||||
this.rated = in.readByte() != 0;
|
||||
this.simpleLanguage = in.readString();
|
||||
this.simpleTags = in.createStringArray();
|
||||
this.thumbWidth = in.readInt();
|
||||
@@ -196,6 +202,8 @@ public class GalleryInfo implements Parcelable {
|
||||
this.spanSize = in.readInt();
|
||||
this.spanIndex = in.readInt();
|
||||
this.spanGroupIndex = in.readInt();
|
||||
this.favoriteSlot = in.readInt();
|
||||
this.favoriteName = in.readString();
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<GalleryInfo> CREATOR = new Parcelable.Creator<GalleryInfo>() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.widget.AdvanceSearchTable;
|
||||
import com.hippo.network.UrlBuilder;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -36,7 +37,7 @@ import java.net.URLEncoder;
|
||||
|
||||
public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
|
||||
@IntDef({MODE_NORMAL, MODE_UPLOADER, MODE_TAG, MODE_WHATS_HOT, MODE_IMAGE_SEARCH})
|
||||
@IntDef({MODE_NORMAL, MODE_UPLOADER, MODE_TAG, MODE_WHATS_HOT, MODE_IMAGE_SEARCH, MODE_SUBSCRIPTION})
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
private @interface Mode {}
|
||||
|
||||
@@ -46,6 +47,7 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
public static final int MODE_TAG = 0x2;
|
||||
public static final int MODE_WHATS_HOT = 0x3;
|
||||
public static final int MODE_IMAGE_SEARCH = 0x4;
|
||||
public static final int MODE_SUBSCRIPTION = 0x5;
|
||||
|
||||
public static final int DEFAULT_ADVANCE = AdvanceSearchTable.SNAME | AdvanceSearchTable.STAGS;
|
||||
public static final int DEFAULT_MIN_RATING = 2;
|
||||
@@ -60,6 +62,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
|
||||
private int mAdvanceSearch = -1;
|
||||
private int mMinRating = -1;
|
||||
private int mPageFrom = -1;
|
||||
private int mPageTo = -1;
|
||||
|
||||
private String mImagePath;
|
||||
private boolean mUseSimilarityScan;
|
||||
@@ -76,6 +80,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = null;
|
||||
mAdvanceSearch = -1;
|
||||
mMinRating = -1;
|
||||
mPageFrom = -1;
|
||||
mPageTo = -1;
|
||||
mImagePath = null;
|
||||
mUseSimilarityScan = false;
|
||||
mOnlySearchCovers = false;
|
||||
@@ -140,6 +146,22 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mMinRating = minRating;
|
||||
}
|
||||
|
||||
public int getPageFrom() {
|
||||
return mPageFrom;
|
||||
}
|
||||
|
||||
public void setPageFrom(int pageFrom) {
|
||||
mPageFrom = pageFrom;
|
||||
}
|
||||
|
||||
public int getPageTo() {
|
||||
return mPageTo;
|
||||
}
|
||||
|
||||
public void setPageTo(int pageTo) {
|
||||
mPageTo = pageTo;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getImagePath() {
|
||||
return mImagePath;
|
||||
@@ -184,6 +206,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = lub.mKeyword;
|
||||
mAdvanceSearch = lub.mAdvanceSearch;
|
||||
mMinRating = lub.mMinRating;
|
||||
mPageFrom = lub.mPageFrom;
|
||||
mPageTo = lub.mPageTo;
|
||||
mImagePath = lub.mImagePath;
|
||||
mUseSimilarityScan = lub.mUseSimilarityScan;
|
||||
mOnlySearchCovers = lub.mOnlySearchCovers;
|
||||
@@ -196,6 +220,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
mKeyword = q.keyword;
|
||||
mAdvanceSearch = q.advanceSearch;
|
||||
mMinRating = q.minRating;
|
||||
mPageFrom = q.pageFrom;
|
||||
mPageTo = q.pageTo;
|
||||
mImagePath = null;
|
||||
mUseSimilarityScan = false;
|
||||
mOnlySearchCovers = false;
|
||||
@@ -209,6 +235,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
q.keyword = mKeyword;
|
||||
q.advanceSearch = mAdvanceSearch;
|
||||
q.minRating = mMinRating;
|
||||
q.pageFrom = mPageFrom;
|
||||
q.pageTo = mPageTo;
|
||||
return q;
|
||||
}
|
||||
|
||||
@@ -232,6 +260,12 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
if (q.minRating != mMinRating) {
|
||||
return false;
|
||||
}
|
||||
if (q.pageFrom != mPageFrom) {
|
||||
return false;
|
||||
}
|
||||
if (q.pageTo != mPageTo) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -248,124 +282,166 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
}
|
||||
|
||||
String[] querys = StringUtils.split(query, '&');
|
||||
boolean apply = false;
|
||||
int category = 0;
|
||||
String keyword = null;
|
||||
boolean enableAdvanceSearch = false;
|
||||
int advanceSearch = 0;
|
||||
boolean enableMinRating = false;
|
||||
int minRating = 0;
|
||||
for (int i = 0, size = querys.length; i < size; i++) {
|
||||
String str = querys[i];
|
||||
int minRating = -1;
|
||||
boolean enablePage = false;
|
||||
int pageFrom = -1;
|
||||
int pageTo = -1;
|
||||
for (String str : querys) {
|
||||
int index = str.indexOf('=');
|
||||
if (index < 0) {
|
||||
continue;
|
||||
}
|
||||
String key = str.substring(0, index);
|
||||
String value = str.substring(index + 1);
|
||||
if ("f_doujinshi".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.DOUJINSHI;
|
||||
}
|
||||
} else if ("f_manga".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.MANGA;
|
||||
}
|
||||
} else if ("f_artistcg".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.ARTIST_CG;
|
||||
}
|
||||
} else if ("f_gamecg".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.GAME_CG;
|
||||
}
|
||||
} else if ("f_western".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.WESTERN;
|
||||
}
|
||||
} else if ("f_non-h".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.NON_H;
|
||||
}
|
||||
} else if ("f_imageset".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.IMAGE_SET;
|
||||
}
|
||||
} else if ("f_cosplay".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.COSPLAY;
|
||||
}
|
||||
} else if ("f_asianporn".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.ASIAN_PORN;
|
||||
}
|
||||
} else if ("f_misc".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.MISC;
|
||||
}
|
||||
} else if ("f_search".equals(key)) {
|
||||
try {
|
||||
keyword = URLDecoder.decode(value, "utf-8");
|
||||
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
|
||||
// Ignore
|
||||
}
|
||||
} else if ("advsearch".equals(key)) {
|
||||
if ("1".equals(value)) {
|
||||
enableAdvanceSearch = true;
|
||||
}
|
||||
} else if ("f_sname".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SNAME;
|
||||
}
|
||||
} else if ("f_stags".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STAGS;
|
||||
}
|
||||
} else if ("f_sdesc".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDESC;
|
||||
}
|
||||
} else if ("f_storr".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STORR;
|
||||
}
|
||||
} else if ("f_sto".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STO;
|
||||
}
|
||||
} else if ("f_sdt1".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDT1;
|
||||
}
|
||||
} else if ("f_sdt2".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDT2;
|
||||
}
|
||||
} else if ("f_sh".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SH;
|
||||
}
|
||||
} else if ("f_sr".equals(key)) {
|
||||
if ("on".equals(value)) {
|
||||
enableMinRating = true;
|
||||
}
|
||||
} else if ("f_srdd".equals(key)) {
|
||||
try {
|
||||
minRating = Integer.parseInt(value);
|
||||
} catch (NumberFormatException e) {
|
||||
// Ignore
|
||||
}
|
||||
} else if ("f_apply".equals(key)) {
|
||||
if ("Apply+Filter".equals(value)) {
|
||||
apply = true;
|
||||
}
|
||||
switch (key) {
|
||||
case "f_cats":
|
||||
int cats = NumberUtils.parseIntSafely(value, EhConfig.ALL_CATEGORY);
|
||||
category |= (~cats) & EhConfig.ALL_CATEGORY;
|
||||
break;
|
||||
case "f_doujinshi":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.DOUJINSHI;
|
||||
}
|
||||
break;
|
||||
case "f_manga":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.MANGA;
|
||||
}
|
||||
break;
|
||||
case "f_artistcg":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.ARTIST_CG;
|
||||
}
|
||||
break;
|
||||
case "f_gamecg":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.GAME_CG;
|
||||
}
|
||||
break;
|
||||
case "f_western":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.WESTERN;
|
||||
}
|
||||
break;
|
||||
case "f_non-h":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.NON_H;
|
||||
}
|
||||
break;
|
||||
case "f_imageset":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.IMAGE_SET;
|
||||
}
|
||||
break;
|
||||
case "f_cosplay":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.COSPLAY;
|
||||
}
|
||||
break;
|
||||
case "f_asianporn":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.ASIAN_PORN;
|
||||
}
|
||||
break;
|
||||
case "f_misc":
|
||||
if ("1".equals(value)) {
|
||||
category |= EhConfig.MISC;
|
||||
}
|
||||
break;
|
||||
case "f_search":
|
||||
try {
|
||||
keyword = URLDecoder.decode(value, "utf-8");
|
||||
} catch (UnsupportedEncodingException | IllegalArgumentException e) {
|
||||
// Ignore
|
||||
}
|
||||
break;
|
||||
case "advsearch":
|
||||
if ("1".equals(value)) {
|
||||
enableAdvanceSearch = true;
|
||||
}
|
||||
break;
|
||||
case "f_sname":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SNAME;
|
||||
}
|
||||
break;
|
||||
case "f_stags":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STAGS;
|
||||
}
|
||||
break;
|
||||
case "f_sdesc":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDESC;
|
||||
}
|
||||
break;
|
||||
case "f_storr":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STORR;
|
||||
}
|
||||
break;
|
||||
case "f_sto":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.STO;
|
||||
}
|
||||
break;
|
||||
case "f_sdt1":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDT1;
|
||||
}
|
||||
break;
|
||||
case "f_sdt2":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SDT2;
|
||||
}
|
||||
break;
|
||||
case "f_sh":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SH;
|
||||
}
|
||||
break;
|
||||
case "f_sfl":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SFL;
|
||||
}
|
||||
break;
|
||||
case "f_sfu":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SFU;
|
||||
}
|
||||
break;
|
||||
case "f_sft":
|
||||
if ("on".equals(value)) {
|
||||
advanceSearch |= AdvanceSearchTable.SFT;
|
||||
}
|
||||
break;
|
||||
case "f_sr":
|
||||
if ("on".equals(value)) {
|
||||
enableMinRating = true;
|
||||
}
|
||||
break;
|
||||
case "f_srdd":
|
||||
minRating = NumberUtils.parseIntSafely(value, -1);
|
||||
break;
|
||||
case "f_sp":
|
||||
if ("on".equals(value)) {
|
||||
enablePage = true;
|
||||
}
|
||||
break;
|
||||
case "f_spf":
|
||||
pageFrom = NumberUtils.parseIntSafely(value, -1);
|
||||
break;
|
||||
case "f_spt":
|
||||
pageTo = NumberUtils.parseIntSafely(value, -1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!apply) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCategory = category;
|
||||
mKeyword = keyword;
|
||||
if (enableAdvanceSearch) {
|
||||
@@ -375,6 +451,13 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
} else {
|
||||
mMinRating = -1;
|
||||
}
|
||||
if (enablePage) {
|
||||
mPageFrom = pageFrom;
|
||||
mPageTo = pageTo;
|
||||
} else {
|
||||
mPageFrom = -1;
|
||||
mPageTo = -1;
|
||||
}
|
||||
} else {
|
||||
mAdvanceSearch = -1;
|
||||
}
|
||||
@@ -383,29 +466,28 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
public String build() {
|
||||
switch (mMode) {
|
||||
default:
|
||||
case MODE_NORMAL: {
|
||||
boolean filter = false;
|
||||
UrlBuilder ub = new UrlBuilder(EhUrl.getHost());
|
||||
case MODE_NORMAL:
|
||||
case MODE_SUBSCRIPTION: {
|
||||
String url;
|
||||
if (mMode == MODE_NORMAL) {
|
||||
url = EhUrl.getHost();
|
||||
} else {
|
||||
url = EhUrl.getWatchedUrl();
|
||||
}
|
||||
|
||||
UrlBuilder ub = new UrlBuilder(url);
|
||||
if (mCategory != EhUtils.NONE) {
|
||||
ub.addQuery("f_doujinshi", ((mCategory & EhConfig.DOUJINSHI) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_manga", ((mCategory & EhConfig.MANGA) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_artistcg", ((mCategory & EhConfig.ARTIST_CG) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_gamecg", ((mCategory & EhConfig.GAME_CG) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_western", ((mCategory & EhConfig.WESTERN) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_non-h", ((mCategory & EhConfig.NON_H) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_imageset", ((mCategory & EhConfig.IMAGE_SET) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_cosplay", ((mCategory & EhConfig.COSPLAY) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_asianporn", ((mCategory & EhConfig.ASIAN_PORN) == 0) ? "0" : "1");
|
||||
ub.addQuery("f_misc", ((mCategory & EhConfig.MISC) == 0) ? "0" : "1");
|
||||
filter = true;
|
||||
ub.addQuery("f_cats", (~mCategory) & EhConfig.ALL_CATEGORY);
|
||||
}
|
||||
// Search key
|
||||
if (mKeyword != null) {
|
||||
try {
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
filter = true;
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
String keyword = mKeyword.trim();
|
||||
if (!keyword.isEmpty()) {
|
||||
try {
|
||||
ub.addQuery("f_search", URLEncoder.encode(mKeyword, "UTF-8"));
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// Empty
|
||||
}
|
||||
}
|
||||
}
|
||||
// Page index
|
||||
@@ -423,16 +505,20 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SDT1) != 0) ub.addQuery("f_sdt1", "on");
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SDT2) != 0) ub.addQuery("f_sdt2", "on");
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SH) != 0) ub.addQuery("f_sh", "on");
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SFL) != 0) ub.addQuery("f_sfl", "on");
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SFU) != 0) ub.addQuery("f_sfu", "on");
|
||||
if((mAdvanceSearch & AdvanceSearchTable.SFT) != 0) ub.addQuery("f_sft", "on");
|
||||
// Set min star
|
||||
if (mMinRating != -1) {
|
||||
ub.addQuery("f_sr", "on");
|
||||
ub.addQuery("f_srdd", mMinRating);
|
||||
}
|
||||
filter = true;
|
||||
}
|
||||
// Add filter foot
|
||||
if (filter) {
|
||||
ub.addQuery("f_apply", "Apply+Filter");
|
||||
// Pages
|
||||
if (mPageFrom != -1 || mPageTo != -1) {
|
||||
ub.addQuery("f_sp", "on");
|
||||
ub.addQuery("f_spf", mPageFrom != -1 ? Integer.toString(mPageFrom) : "");
|
||||
ub.addQuery("f_spt", mPageTo != -1 ? Integer.toString(mPageTo) : "");
|
||||
}
|
||||
}
|
||||
return ub.build();
|
||||
}
|
||||
@@ -462,6 +548,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
case MODE_WHATS_HOT:
|
||||
return EhUrl.getPopularUrl();
|
||||
case MODE_IMAGE_SEARCH:
|
||||
return EhUrl.getImageSearchUrl();
|
||||
}
|
||||
@@ -480,6 +568,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
dest.writeString(this.mKeyword);
|
||||
dest.writeInt(this.mAdvanceSearch);
|
||||
dest.writeInt(this.mMinRating);
|
||||
dest.writeInt(this.mPageFrom);
|
||||
dest.writeInt(this.mPageTo);
|
||||
dest.writeString(this.mImagePath);
|
||||
dest.writeByte(mUseSimilarityScan ? (byte) 1 : (byte) 0);
|
||||
dest.writeByte(mOnlySearchCovers ? (byte) 1 : (byte) 0);
|
||||
@@ -497,6 +587,8 @@ public class ListUrlBuilder implements Cloneable, Parcelable {
|
||||
this.mKeyword = in.readString();
|
||||
this.mAdvanceSearch = in.readInt();
|
||||
this.mMinRating = in.readInt();
|
||||
this.mPageFrom = in.readInt();
|
||||
this.mPageTo = in.readInt();
|
||||
this.mImagePath = in.readString();
|
||||
this.mUseSimilarityScan = in.readByte() != 0;
|
||||
this.mOnlySearchCovers = in.readByte() != 0;
|
||||
|
||||
@@ -36,6 +36,7 @@ public class FavoritesParser {
|
||||
public String[] catArray; // Size 10
|
||||
public int[] countArray; // Size 10
|
||||
public int pages;
|
||||
public int nextPage;
|
||||
public List<GalleryInfo> galleryInfoList;
|
||||
}
|
||||
|
||||
@@ -71,6 +72,7 @@ public class FavoritesParser {
|
||||
re.catArray = catArray;
|
||||
re.countArray = countArray;
|
||||
re.pages = result.pages;
|
||||
re.nextPage = result.nextPage;
|
||||
re.galleryInfoList = result.galleryInfoList;
|
||||
|
||||
return re;
|
||||
|
||||
@@ -16,13 +16,13 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
import com.hippo.ehviewer.client.data.LargePreviewSet;
|
||||
@@ -34,6 +34,7 @@ import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.ehviewer.client.exception.PiningException;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
import com.hippo.util.MutableBoolean;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
import java.text.DateFormat;
|
||||
@@ -49,7 +50,10 @@ import java.util.regex.Pattern;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.nodes.Node;
|
||||
import org.jsoup.select.Elements;
|
||||
import org.jsoup.select.NodeTraversor;
|
||||
import org.jsoup.select.NodeVisitor;
|
||||
|
||||
public class GalleryDetailParser {
|
||||
|
||||
@@ -67,7 +71,7 @@ public class GalleryDetailParser {
|
||||
private static final Pattern PATTERN_LARGE_PREVIEW = Pattern.compile("<div class=\"gdtl\".+?<a href=\"(.+?)\"><img alt=\"([\\d,]+)\".+?src=\"(.+?)\"");
|
||||
|
||||
private static final GalleryTagGroup[] EMPTY_GALLERY_TAG_GROUP_ARRAY = new GalleryTagGroup[0];
|
||||
private static final GalleryComment[] EMPTY_GALLERY_COMMENT_ARRAY = new GalleryComment[0];
|
||||
private static final GalleryCommentList EMPTY_GALLERY_COMMENT_ARRAY = new GalleryCommentList(new GalleryComment[0], false);
|
||||
|
||||
private static final DateFormat WEB_COMMENT_DATE_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm z", Locale.US);
|
||||
|
||||
@@ -167,9 +171,11 @@ public class GalleryDetailParser {
|
||||
// Category
|
||||
Element gdc = gm.getElementById("gdc");
|
||||
try {
|
||||
String href = gdc.child(0).attr("href");
|
||||
String category = href.substring(href.lastIndexOf('/') + 1);
|
||||
gd.category = EhUtils.getCategory(category);
|
||||
Element ce = JsoupUtils.getElementByClass(gdc, "cn");
|
||||
if (ce == null) {
|
||||
ce = JsoupUtils.getElementByClass(gdc, "cs");
|
||||
}
|
||||
gd.category = EhUtils.getCategory(ce.text());
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
gd.category = EhUtils.UNKNOWN;
|
||||
@@ -266,7 +272,10 @@ public class GalleryDetailParser {
|
||||
if (key.startsWith("Posted")) {
|
||||
gd.posted = value;
|
||||
} else if (key.startsWith("Parent")) {
|
||||
gd.parent = value;
|
||||
Element a = es.get(1).children().first();
|
||||
if (a != null) {
|
||||
gd.parent = a.attr("href");
|
||||
}
|
||||
} else if (key.startsWith("Visible")) {
|
||||
gd.visible = value;
|
||||
} else if (key.startsWith("Language")) {
|
||||
@@ -337,10 +346,20 @@ public class GalleryDetailParser {
|
||||
try {
|
||||
Element taglist = document.getElementById("taglist");
|
||||
Elements tagGroups = taglist.child(0).child(0).children();
|
||||
return parseTagGroups(tagGroups);
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
e.printStackTrace();
|
||||
return EMPTY_GALLERY_TAG_GROUP_ARRAY;
|
||||
}
|
||||
}
|
||||
|
||||
List<GalleryTagGroup> list = new ArrayList<>(tagGroups.size());
|
||||
for (int i = 0, n = tagGroups.size(); i < n; i++) {
|
||||
GalleryTagGroup group = parseTagGroup(tagGroups.get(i));
|
||||
@NonNull
|
||||
public static GalleryTagGroup[] parseTagGroups(Elements trs) {
|
||||
try {
|
||||
List<GalleryTagGroup> list = new ArrayList<>(trs.size());
|
||||
for (int i = 0, n = trs.size(); i < n; i++) {
|
||||
GalleryTagGroup group = parseTagGroup(trs.get(i));
|
||||
if (null != group) {
|
||||
list.add(group);
|
||||
}
|
||||
@@ -387,13 +406,23 @@ public class GalleryDetailParser {
|
||||
Element a = element.previousElementSibling();
|
||||
String name = a.attr("name");
|
||||
comment.id = Integer.parseInt(StringUtils.trim(name).substring(1));
|
||||
// Vote up and vote down
|
||||
// Editable, vote up and vote down
|
||||
Element c4 = JsoupUtils.getElementByClass(element, "c4");
|
||||
if (null != c4) {
|
||||
Elements es = c4.children();
|
||||
if (2 == es.size()) {
|
||||
comment.voteUp = !TextUtils.isEmpty(StringUtils.trim(es.get(0).attr("style")));
|
||||
comment.voteDown = !TextUtils.isEmpty(StringUtils.trim(es.get(1).attr("style")));
|
||||
for (Element e : c4.children()) {
|
||||
switch (e.text()) {
|
||||
case "Vote+":
|
||||
comment.voteUpAble = true;
|
||||
comment.voteUpEd = !StringUtils.trim(e.attr("style")).isEmpty();
|
||||
break;
|
||||
case "Vote-":
|
||||
comment.voteDownAble = true;
|
||||
comment.voteDownEd = !StringUtils.trim(e.attr("style")).isEmpty();
|
||||
break;
|
||||
case "Edit":
|
||||
comment.editable = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Vote state
|
||||
@@ -418,6 +447,14 @@ public class GalleryDetailParser {
|
||||
comment.user = c3.child(0).text();
|
||||
// comment
|
||||
comment.comment = JsoupUtils.getElementByClass(element, "c6").html();
|
||||
// last edited
|
||||
Element c8 = JsoupUtils.getElementByClass(element, "c8");
|
||||
if (c8 != null) {
|
||||
Element e = c8.children().first();
|
||||
if (e != null) {
|
||||
comment.lastEdited = WEB_COMMENT_DATE_FORMAT.parse(temp).getTime();
|
||||
}
|
||||
}
|
||||
return comment;
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
@@ -430,7 +467,7 @@ public class GalleryDetailParser {
|
||||
* Parse comments with html parser
|
||||
*/
|
||||
@NonNull
|
||||
public static GalleryComment[] parseComments(Document document) {
|
||||
public static GalleryCommentList parseComments(Document document) {
|
||||
try {
|
||||
Element cdiv = document.getElementById("cdiv");
|
||||
Elements c1s = cdiv.getElementsByClass("c1");
|
||||
@@ -442,7 +479,22 @@ public class GalleryDetailParser {
|
||||
list.add(comment);
|
||||
}
|
||||
}
|
||||
return list.toArray(new GalleryComment[list.size()]);
|
||||
|
||||
Element chd = cdiv.getElementById("chd");
|
||||
MutableBoolean hasMore = new MutableBoolean(false);
|
||||
NodeTraversor.traverse(new NodeVisitor() {
|
||||
@Override
|
||||
public void head(Node node, int depth) {
|
||||
if (node instanceof Element && ((Element) node).text().equals("click to show all")) {
|
||||
hasMore.value = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void tail(Node node, int depth) { }
|
||||
}, chd);
|
||||
|
||||
return new GalleryCommentList(list.toArray(new GalleryComment[list.size()]), hasMore.value);
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
e.printStackTrace();
|
||||
|
||||
@@ -16,16 +16,17 @@
|
||||
|
||||
package com.hippo.ehviewer.client.parser;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
import com.hippo.yorozuya.StringUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
@@ -41,10 +42,28 @@ public class GalleryListParser {
|
||||
private static final String TAG = GalleryListParser.class.getSimpleName();
|
||||
|
||||
private static final Pattern PATTERN_RATING = Pattern.compile("\\d+px");
|
||||
private static final Pattern PATTERN_THUMB_SIZE = Pattern.compile("height:(\\d+)px; width:(\\d+)px");
|
||||
private static final Pattern PATTERN_THUMB_SIZE = Pattern.compile("height:(\\d+)px;width:(\\d+)px");
|
||||
private static final Pattern PATTERN_FAVORITE_SLOT = Pattern.compile("background-color:rgba\\((\\d+),(\\d+),(\\d+),");
|
||||
private static final Pattern PATTERN_PAGES = Pattern.compile("(\\d+) page");
|
||||
private static final Pattern PATTERN_NEXT_PAGE = Pattern.compile("page=(\\d+)");
|
||||
|
||||
private static final String[][] FAVORITE_SLOT_RGB = new String[][] {
|
||||
new String[] { "0", "0", "0"},
|
||||
new String[] { "240", "0", "0"},
|
||||
new String[] { "240", "160", "0"},
|
||||
new String[] { "208", "208", "0"},
|
||||
new String[] { "0", "128", "0"},
|
||||
new String[] { "144", "240", "64"},
|
||||
new String[] { "64", "176", "240"},
|
||||
new String[] { "0", "0", "240"},
|
||||
new String[] { "80", "0", "128"},
|
||||
new String[] { "224", "128", "224"},
|
||||
};
|
||||
|
||||
public static class Result {
|
||||
public int pages;
|
||||
public int nextPage;
|
||||
public boolean noWatchedTags;
|
||||
public List<GalleryInfo> galleryInfoList;
|
||||
}
|
||||
|
||||
@@ -83,154 +102,191 @@ public class GalleryListParser {
|
||||
return re;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GalleryInfo parseGalleryInfo(Element e) {
|
||||
GalleryInfo gi = new GalleryInfo();
|
||||
// Get category
|
||||
Element ic = JsoupUtils.getElementByClass(e, "ic");
|
||||
if (null != ic) {
|
||||
gi.category = EhUtils.getCategory(ic.attr("alt").trim());
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info category");
|
||||
gi.category = EhUtils.UNKNOWN;
|
||||
}
|
||||
// Posted
|
||||
Element itd = JsoupUtils.getElementByClass(e, "itd");
|
||||
if (null != itd) {
|
||||
gi.posted = itd.text().trim();
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info posted");
|
||||
gi.posted = "";
|
||||
}
|
||||
// Thumb
|
||||
Element it2 = JsoupUtils.getElementByClass(e, "it2");
|
||||
if (null != it2) {
|
||||
// Thumb size
|
||||
Matcher m = PATTERN_THUMB_SIZE.matcher(it2.attr("style"));
|
||||
if (m.find()) {
|
||||
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
|
||||
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb size");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
}
|
||||
|
||||
// Thumb url
|
||||
Elements es = it2.children();
|
||||
if (null != es && es.size() >= 1) {
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(es.get(0).attr("src"));
|
||||
} else {
|
||||
String html = it2.html();
|
||||
int index1 = html.indexOf('~');
|
||||
int index2 = StringUtils.ordinalIndexOf(html, '~', 2);
|
||||
if (index1 < index2) {
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(
|
||||
"http://" +StringUtils.replace(html.substring(index1 + 1, index2), "~", "/"));
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb url");
|
||||
gi.thumb = "";
|
||||
private static int parseFavoriteSlot(String style) {
|
||||
Matcher m = PATTERN_FAVORITE_SLOT.matcher(style);
|
||||
if (m.find()) {
|
||||
String r = m.group(1);
|
||||
String g = m.group(2);
|
||||
String b = m.group(3);
|
||||
int slot = 0;
|
||||
for (String[] rgb : FAVORITE_SLOT_RGB) {
|
||||
if (r.equals(rgb[0]) && g.equals(rgb[1]) && b.equals(rgb[2])) {
|
||||
return slot;
|
||||
}
|
||||
slot++;
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
gi.thumb = "";
|
||||
}
|
||||
// Title (required)
|
||||
Element it5 = JsoupUtils.getElementByClass(e, "it5");
|
||||
if (null == it5) {
|
||||
Log.e(TAG, "Can't parse gallery info title, step 1");
|
||||
return null;
|
||||
}
|
||||
Elements es = it5.children();
|
||||
if (null == es || es.size() <= 0) {
|
||||
Log.e(TAG, "Can't parse gallery info title, step 2");
|
||||
return null;
|
||||
}
|
||||
Element a = es.get(0);
|
||||
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
|
||||
if (null == result) {
|
||||
Log.e(TAG, "Can't parse gallery info title, step 3");
|
||||
return null;
|
||||
}
|
||||
gi.gid = result.gid;
|
||||
gi.token = result.token;
|
||||
gi.title = a.text().trim();
|
||||
// Rating
|
||||
Element it4r = JsoupUtils.getElementByClass(e, "it4r");
|
||||
if (null != it4r) {
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(it4r.attr("style")), -1.0f);
|
||||
// TODO The gallery may be rated even if it has one of these classes
|
||||
gi.rated = it4r.hasClass("irr") || it4r.hasClass("irg") || it4r.hasClass("irb");
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info rating");
|
||||
gi.rating = -1.0f;
|
||||
}
|
||||
// Uploader
|
||||
Element itu = JsoupUtils.getElementByClass(e, "itu");
|
||||
if (null != itu) {
|
||||
gi.uploader = itu.text().trim();
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info uploader");
|
||||
gi.uploader = "";
|
||||
}
|
||||
|
||||
gi.generateSLang();
|
||||
|
||||
return gi;
|
||||
return -2;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static GalleryInfo parseGalleryInfoThumbVersion(Element e) {
|
||||
private static GalleryInfo parseGalleryInfo(Element e) {
|
||||
GalleryInfo gi = new GalleryInfo();
|
||||
|
||||
// Title (required)
|
||||
Element id2 = JsoupUtils.getElementByClass(e, "id2");
|
||||
if (id2 == null) {
|
||||
return null;
|
||||
}
|
||||
gi.title = id2.text().trim();
|
||||
|
||||
// gid, token (required)
|
||||
Element a = id2.children().first();
|
||||
if (a == null) {
|
||||
return null;
|
||||
}
|
||||
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
|
||||
if (result == null) {
|
||||
return null;
|
||||
}
|
||||
gi.gid = result.gid;
|
||||
gi.token = result.token;
|
||||
|
||||
// Thumbnail
|
||||
Element id3 = JsoupUtils.getElementByClass(e, "id3");
|
||||
if (id3 != null) {
|
||||
a = id3.children().first();
|
||||
// Title, gid, token (required), tags
|
||||
Element glname = JsoupUtils.getElementByClass(e, "glname");
|
||||
if (glname != null) {
|
||||
Element a = JsoupUtils.getElementByTag(glname, "a");
|
||||
if (a == null) {
|
||||
Element parent = glname.parent();
|
||||
if (parent != null && "a".equals(parent.tagName())) {
|
||||
a = parent;
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
Element img = a.children().first();
|
||||
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(a.attr("href"));
|
||||
if (result != null) {
|
||||
gi.gid = result.gid;
|
||||
gi.token = result.token;
|
||||
}
|
||||
}
|
||||
|
||||
Element child = glname;
|
||||
Elements children = glname.children();
|
||||
while (children.size() != 0) {
|
||||
child = children.get(0);
|
||||
children = child.children();
|
||||
}
|
||||
gi.title = child.text().trim();
|
||||
|
||||
Element tbody = JsoupUtils.getElementByTag(glname, "tbody");
|
||||
if (tbody != null) {
|
||||
ArrayList<String> tags = new ArrayList<>();
|
||||
GalleryTagGroup[] groups = GalleryDetailParser.parseTagGroups(tbody.children());
|
||||
for (GalleryTagGroup group : groups) {
|
||||
for (int j = 0; j < group.size(); j++) {
|
||||
tags.add(group.groupName + ":" + group.getTagAt(j));
|
||||
}
|
||||
}
|
||||
gi.simpleTags = tags.toArray(new String[tags.size()]);
|
||||
}
|
||||
}
|
||||
if (gi.title == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// Category
|
||||
gi.category = EhUtils.UNKNOWN;
|
||||
Element ce = JsoupUtils.getElementByClass(e, "cn");
|
||||
if (ce == null) {
|
||||
ce = JsoupUtils.getElementByClass(e, "cs");
|
||||
}
|
||||
if (ce != null) {
|
||||
gi.category = EhUtils.getCategory(ce.text());
|
||||
}
|
||||
|
||||
// Thumb
|
||||
Element glthumb = JsoupUtils.getElementByClass(e, "glthumb");
|
||||
if (glthumb != null) {
|
||||
Element img = glthumb.select("div:nth-child(1)>img").first();
|
||||
if (img != null) {
|
||||
// Thumb size
|
||||
Matcher m = PATTERN_THUMB_SIZE.matcher(img.attr("style"));
|
||||
if (m.find()) {
|
||||
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
|
||||
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb size");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
}
|
||||
// Thumb url
|
||||
String url = img.attr("data-src");
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
url = img.attr("src");
|
||||
}
|
||||
if (TextUtils.isEmpty(url)) {
|
||||
url = null;
|
||||
}
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(url);
|
||||
}
|
||||
|
||||
// Pages
|
||||
Element div = glthumb.select("div:nth-child(2)>div:nth-child(2)>div:nth-child(2)").first();
|
||||
if (div != null) {
|
||||
Matcher matcher = PATTERN_PAGES.matcher(div.text());
|
||||
if (matcher.find()) {
|
||||
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Try extended and thumbnail version
|
||||
if (gi.thumb == null) {
|
||||
Element gl = JsoupUtils.getElementByClass(e, "gl1e");
|
||||
if (gl == null) {
|
||||
gl = JsoupUtils.getElementByClass(e, "gl3t");
|
||||
}
|
||||
if (gl != null) {
|
||||
Element img = JsoupUtils.getElementByTag(gl, "img");
|
||||
if (img != null) {
|
||||
// Thumb size
|
||||
Matcher m = PATTERN_THUMB_SIZE.matcher(img.attr("style"));
|
||||
if (m.find()) {
|
||||
gi.thumbWidth = NumberUtils.parseIntSafely(m.group(2), 0);
|
||||
gi.thumbHeight = NumberUtils.parseIntSafely(m.group(1), 0);
|
||||
} else {
|
||||
Log.w(TAG, "Can't parse gallery info thumb size");
|
||||
gi.thumbWidth = 0;
|
||||
gi.thumbHeight = 0;
|
||||
}
|
||||
gi.thumb = EhUtils.handleThumbUrlResolution(img.attr("src"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Category
|
||||
Element id41 = JsoupUtils.getElementByClass(e, "id41");
|
||||
if (id41 != null) {
|
||||
gi.category = EhUtils.getCategory(id41.attr("title").trim());
|
||||
} else {
|
||||
gi.category = EhUtils.UNKNOWN;
|
||||
// Posted
|
||||
gi.favoriteSlot = -2;
|
||||
Element posted = e.getElementById("posted_" + gi.gid);
|
||||
if (posted != null) {
|
||||
gi.posted = posted.text().trim();
|
||||
gi.favoriteSlot = parseFavoriteSlot(posted.attr("style"));
|
||||
}
|
||||
if (gi.favoriteSlot == -2) {
|
||||
gi.favoriteSlot = EhDB.containLocalFavorites(gi.gid) ? -1 : -2;
|
||||
}
|
||||
|
||||
// Rating
|
||||
Element id43 = JsoupUtils.getElementByClass(e, "id43");
|
||||
if (id43 != null) {
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(id43.attr("style")), -1.0f);
|
||||
} else {
|
||||
gi.rating = -1.0f;
|
||||
Element ir = JsoupUtils.getElementByClass(e, "ir");
|
||||
if (ir != null) {
|
||||
gi.rating = NumberUtils.parseFloatSafely(parseRating(ir.attr("style")), -1.0f);
|
||||
// TODO The gallery may be rated even if it doesn't has one of these classes
|
||||
gi.rated = ir.hasClass("irr") || ir.hasClass("irg") || ir.hasClass("irb");
|
||||
}
|
||||
|
||||
// Uploader and pages
|
||||
Element gl = JsoupUtils.getElementByClass(e, "glhide");
|
||||
int uploaderIndex = 0;
|
||||
int pagesIndex = 1;
|
||||
if (gl == null) {
|
||||
// For extended
|
||||
gl = JsoupUtils.getElementByClass(e, "gl3e");
|
||||
uploaderIndex = 3;
|
||||
pagesIndex = 4;
|
||||
}
|
||||
if (gl != null) {
|
||||
Elements children = gl.children();
|
||||
if (children.size() > uploaderIndex) {
|
||||
Element a = children.get(uploaderIndex).children().first();
|
||||
if (a != null) {
|
||||
gi.uploader = a.text().trim();
|
||||
}
|
||||
}
|
||||
if (children.size() > pagesIndex) {
|
||||
Matcher matcher = PATTERN_PAGES.matcher(children.get(pagesIndex).text());
|
||||
if (matcher.find()) {
|
||||
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
// For thumbnail
|
||||
Element gl5t = JsoupUtils.getElementByClass(e, "gl5t");
|
||||
if (gl5t != null) {
|
||||
Element div = gl5t.select("div:nth-child(2)>div:nth-child(2)").first();
|
||||
if (div != null) {
|
||||
Matcher matcher = PATTERN_PAGES.matcher(div.text());
|
||||
if (matcher.find()) {
|
||||
gi.pages = NumberUtils.parseIntSafely(matcher.group(1), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gi.generateSLang();
|
||||
@@ -243,51 +299,62 @@ public class GalleryListParser {
|
||||
Document d = Jsoup.parse(body);
|
||||
|
||||
try {
|
||||
result.pages = parsePages(d, body);
|
||||
} catch (ParseException e) {
|
||||
Element ptt = d.getElementsByClass("ptt").first();
|
||||
Elements es = ptt.child(0).child(0).children();
|
||||
result.pages = Integer.parseInt(es.get(es.size() - 2).text().trim());
|
||||
|
||||
Element e = es.get(es.size() - 1);
|
||||
if (e != null) {
|
||||
e = e.children().first();
|
||||
if (e != null) {
|
||||
String href = e.attr("href");
|
||||
Matcher matcher = PATTERN_NEXT_PAGE.matcher(href);
|
||||
if (matcher.find()) {
|
||||
result.nextPage = NumberUtils.parseIntSafely(matcher.group(1), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
result.noWatchedTags = body.contains("<p>You do not have any watched tags");
|
||||
if (body.contains("No hits found</p>")) {
|
||||
result.pages = 0;
|
||||
//noinspection unchecked
|
||||
result.galleryInfoList = Collections.EMPTY_LIST;
|
||||
return result;
|
||||
} else if (d.getElementsByClass("ptt").isEmpty()) {
|
||||
result.pages = 1;
|
||||
} else {
|
||||
throw e;
|
||||
result.pages = Integer.MAX_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Elements es = d.getElementsByClass("itg").first().child(0).children();
|
||||
List<GalleryInfo> list = new ArrayList<>(es.size() - 1);
|
||||
for (int i = 1; i < es.size(); i++) { // First one is table header, skip it
|
||||
Element itg = d.getElementsByClass("itg").first();
|
||||
Elements es;
|
||||
if ("table".equalsIgnoreCase(itg.tagName())) {
|
||||
es = itg.child(0).children();
|
||||
} else {
|
||||
es = itg.children();
|
||||
}
|
||||
List<GalleryInfo> list = new ArrayList<>(es.size());
|
||||
// First one is table header, skip it
|
||||
for (int i = 0; i < es.size(); i++) {
|
||||
GalleryInfo gi = parseGalleryInfo(es.get(i));
|
||||
if (null != gi) {
|
||||
list.add(gi);
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
throw new ParseException("No gallery", body);
|
||||
}
|
||||
result.galleryInfoList = list;
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
e.printStackTrace();
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
}
|
||||
|
||||
// Maybe it's thumbnail version
|
||||
if (result.galleryInfoList.isEmpty()) {
|
||||
try {
|
||||
Elements es = d.getElementsByClass("itg").first().children();
|
||||
List<GalleryInfo> list = new ArrayList<>(es.size() - 1);
|
||||
for (int i = 0; i < es.size(); i++) {
|
||||
GalleryInfo gi = parseGalleryInfoThumbVersion(es.get(i));
|
||||
if (null != gi) {
|
||||
list.add(gi);
|
||||
}
|
||||
}
|
||||
result.galleryInfoList = list;
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
throw new ParseException("Can't parse gallery list", body);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -1,61 +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.client.parser;
|
||||
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.exception.ParseException;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
import com.hippo.util.JsoupUtils;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.jsoup.nodes.Element;
|
||||
import org.jsoup.select.Elements;
|
||||
|
||||
public class WhatsHotParser {
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
public static List<GalleryInfo> parse(String body) throws ParseException {
|
||||
try {
|
||||
List<GalleryInfo> galleryInfoList = new ArrayList<>(15);
|
||||
Document d = Jsoup.parse(body);
|
||||
Element pp = d.getElementById("pp");
|
||||
Elements id1List = pp.getElementsByClass("id1");
|
||||
for (int i = 0, n = id1List.size(); i < n; i++) {
|
||||
GalleryInfo galleryInfo = new GalleryInfo();
|
||||
Element id1 = id1List.get(i);
|
||||
Element id3 = JsoupUtils.getElementByClass(id1, "id3");
|
||||
Element temp = JsoupUtils.getElementByTag(id3, "a");
|
||||
String url = temp.attr("href");
|
||||
GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(url);
|
||||
galleryInfo.gid = result.gid;
|
||||
galleryInfo.token = result.token;
|
||||
temp = JsoupUtils.getElementByTag(temp, "img");
|
||||
galleryInfo.thumb = EhUtils.handleThumbUrlResolution(temp.attr("src"));
|
||||
galleryInfo.title = temp.attr("title");
|
||||
galleryInfo.generateSLang();
|
||||
galleryInfoList.add(galleryInfo);
|
||||
}
|
||||
return galleryInfoList;
|
||||
} catch (Throwable e) {
|
||||
ExceptionUtils.throwIfFatal(e);
|
||||
throw new ParseException("Parse whats hot error", body);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@ import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.dao.DownloadInfo;
|
||||
@@ -448,8 +447,6 @@ public class DownloadManager implements SpiderQueen.OnSpiderListener {
|
||||
for (DownloadInfoListener l: mDownloadInfoListeners) {
|
||||
l.onAdd(info, list, list.size() - 1);
|
||||
}
|
||||
|
||||
Analytics.downloadGallery(galleryInfo.gid, galleryInfo.token);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.GetText;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.util.ReadableTime;
|
||||
import java.io.File;
|
||||
|
||||
public class ExportDataPreference extends TaskPreference {
|
||||
|
||||
public ExportDataPreference(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public ExportDataPreference(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
public ExportDataPreference(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
protected Task onCreateTask() {
|
||||
return new ExportDataTask(getContext());
|
||||
}
|
||||
|
||||
private static class ExportDataTask extends Task {
|
||||
|
||||
public ExportDataTask(@NonNull Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object doInBackground(Void... voids) {
|
||||
File dir = AppConfig.getExternalDataDir();
|
||||
if (dir != null) {
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".db");
|
||||
if (EhDB.exportDB(getApplication(), file)) {
|
||||
return file;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Object o) {
|
||||
Toast.makeText(getApplication(),
|
||||
(o instanceof File)
|
||||
? GetText.getString(R.string.settings_advanced_export_data_to, ((File) o).getPath())
|
||||
: GetText.getString(R.string.settings_advanced_export_data_failed),
|
||||
Toast.LENGTH_SHORT).show();
|
||||
super.onPostExecute(o);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -166,6 +166,10 @@ public abstract class TaskPreference extends DialogPreference {
|
||||
mApplication = (EhApplication) context.getApplicationContext();
|
||||
}
|
||||
|
||||
public EhApplication getApplication() {
|
||||
return mApplication;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public TaskPreference getPreference() {
|
||||
return mPreference;
|
||||
|
||||
@@ -61,6 +61,7 @@ import com.hippo.yorozuya.Utilities;
|
||||
import com.hippo.yorozuya.collect.SparseJLArray;
|
||||
import com.hippo.yorozuya.thread.PriorityThread;
|
||||
import com.hippo.yorozuya.thread.PriorityThreadFactory;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
@@ -1078,7 +1079,6 @@ public final class SpiderQueen implements Runnable {
|
||||
localShowKey = showKey.get();
|
||||
if (localShowKey == null || forceHtml) {
|
||||
if (leakSkipHathKey) {
|
||||
error = "No more new SkipHathKey";
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1173,7 +1173,6 @@ public final class SpiderQueen implements Runnable {
|
||||
}
|
||||
|
||||
// Download image
|
||||
OutputStreamPipe pipe = null;
|
||||
InputStream is = null;
|
||||
try {
|
||||
if (DEBUG_LOG) {
|
||||
@@ -1209,49 +1208,93 @@ public final class SpiderQueen implements Runnable {
|
||||
extension = GalleryProvider2.SUPPORT_IMAGE_EXTENSIONS[0];
|
||||
}
|
||||
|
||||
// Get out put pipe
|
||||
pipe = mSpiderDen.openOutputStreamPipe(index, extension);
|
||||
if (null == pipe) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_write_failed);
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
|
||||
long contentLength = responseBody.contentLength();
|
||||
is = responseBody.byteStream();
|
||||
pipe.obtain();
|
||||
OutputStream os = pipe.open();
|
||||
|
||||
final byte data[] = new byte[1024 * 4];
|
||||
long receivedSize = 0;
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
int bytesRead = is.read(data);
|
||||
if (bytesRead == -1) {
|
||||
OutputStreamPipe osPipe = null;
|
||||
try {
|
||||
// Get out put pipe
|
||||
osPipe = mSpiderDen.openOutputStreamPipe(index, extension);
|
||||
if (osPipe == null) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_write_failed);
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
os.write(data, 0, bytesRead);
|
||||
receivedSize += bytesRead;
|
||||
// Update page percent
|
||||
if (contentLength > 0) {
|
||||
mPagePercentMap.put(index, (float) receivedSize / contentLength);
|
||||
}
|
||||
// Notify listener
|
||||
notifyPageDownload(index, contentLength, receivedSize, bytesRead);
|
||||
}
|
||||
os.flush();
|
||||
|
||||
// check download size
|
||||
if (contentLength >= 0) {
|
||||
if (receivedSize < contentLength) {
|
||||
Log.e(TAG, "Can't download all of image data");
|
||||
error = "Incomplete";
|
||||
long contentLength = responseBody.contentLength();
|
||||
is = responseBody.byteStream();
|
||||
osPipe.obtain();
|
||||
OutputStream os = osPipe.open();
|
||||
|
||||
final byte[] data = new byte[1024 * 4];
|
||||
long receivedSize = 0;
|
||||
|
||||
while (!Thread.currentThread().isInterrupted()) {
|
||||
int bytesRead = is.read(data);
|
||||
if (bytesRead == -1) {
|
||||
response.close();
|
||||
break;
|
||||
}
|
||||
os.write(data, 0, bytesRead);
|
||||
receivedSize += bytesRead;
|
||||
// Update page percent
|
||||
if (contentLength > 0) {
|
||||
mPagePercentMap.put(index, (float) receivedSize / contentLength);
|
||||
}
|
||||
// Notify listener
|
||||
notifyPageDownload(index, contentLength, receivedSize, bytesRead);
|
||||
}
|
||||
os.flush();
|
||||
|
||||
// check download size
|
||||
if (contentLength >= 0) {
|
||||
if (receivedSize < contentLength) {
|
||||
Log.e(TAG, "Can't download all of image data");
|
||||
error = "Incomplete";
|
||||
forceHtml = true;
|
||||
continue;
|
||||
} else if (receivedSize > contentLength) {
|
||||
Log.w(TAG, "Received data is more than contentLength");
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
if (osPipe != null) {
|
||||
osPipe.close();
|
||||
osPipe.release();
|
||||
}
|
||||
}
|
||||
|
||||
InputStreamPipe isPipe = null;
|
||||
try {
|
||||
// Get InputStreamPipe
|
||||
isPipe = mSpiderDen.openInputStreamPipe(index);
|
||||
if (isPipe == null) {
|
||||
// Can't get pipe
|
||||
error = GetText.getString(R.string.error_reading_failed);
|
||||
break;
|
||||
}
|
||||
|
||||
// Check plain txt
|
||||
isPipe.obtain();
|
||||
InputStream inputStream = new BufferedInputStream(isPipe.open());
|
||||
boolean isPlainTxt = true;
|
||||
for (;;) {
|
||||
int b = inputStream.read();
|
||||
if (b == -1) {
|
||||
break;
|
||||
}
|
||||
if (b > 126) {
|
||||
isPlainTxt = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (isPlainTxt) {
|
||||
error = GetText.getString(R.string.error_reading_failed);
|
||||
forceHtml = true;
|
||||
continue;
|
||||
} else if (receivedSize > contentLength) {
|
||||
Log.w(TAG, "Received data is more than contentLength");
|
||||
}
|
||||
} finally {
|
||||
if (isPipe != null) {
|
||||
isPipe.close();
|
||||
isPipe.release();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1275,10 +1318,6 @@ public final class SpiderQueen implements Runnable {
|
||||
forceHtml = true;
|
||||
} finally {
|
||||
IOUtils.closeQuietly(is);
|
||||
if (null != pipe) {
|
||||
pipe.close();
|
||||
pipe.release();
|
||||
}
|
||||
|
||||
if (DEBUG_LOG) {
|
||||
Log.d(TAG, "End download image " + index);
|
||||
|
||||
@@ -25,7 +25,6 @@ import android.os.AsyncTask;
|
||||
import android.util.Log;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import com.hippo.app.ListCheckBoxDialogBuilder;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -33,7 +32,6 @@ import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.dao.DownloadLabel;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
@@ -196,7 +194,6 @@ public final class CommonOperations {
|
||||
if (slot == -1) {
|
||||
EhDB.putLocalFavorites(galleryInfo);
|
||||
listener.onSuccess(null);
|
||||
Analytics.addGalleryToFavourite(galleryInfo.gid, galleryInfo.token);
|
||||
} else if (slot >= 0 && slot <= 9) {
|
||||
EhClient client = EhApplication.getEhClient(activity);
|
||||
EhRequest request = new EhRequest();
|
||||
@@ -204,7 +201,6 @@ public final class CommonOperations {
|
||||
request.setArgs(galleryInfo.gid, galleryInfo.token, slot, "");
|
||||
request.setCallback(listener);
|
||||
client.execute(request);
|
||||
Analytics.addGalleryToFavourite(galleryInfo.gid, galleryInfo.token);
|
||||
} else {
|
||||
listener.onFailure(new Exception()); // TODO Add text
|
||||
}
|
||||
@@ -219,17 +215,13 @@ public final class CommonOperations {
|
||||
System.arraycopy(favCat, 0, items, 1, 10);
|
||||
if (slot >= -1 && slot <= 9) {
|
||||
String newFavoriteName = slot >= 0 ? items[slot + 1] : null;
|
||||
doAddToFavorites(activity, galleryInfo, slot, galleryInfo instanceof GalleryDetail
|
||||
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, newFavoriteName)
|
||||
: listener);
|
||||
doAddToFavorites(activity, galleryInfo, slot, new DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot));
|
||||
} else {
|
||||
new ListCheckBoxDialogBuilder(activity, items,
|
||||
(builder, dialog, position) -> {
|
||||
int slot1 = position - 1;
|
||||
String newFavoriteName = (slot1 >= 0 && slot1 <= 9) ? items[slot1+1] : null;
|
||||
doAddToFavorites(activity, galleryInfo, slot1, galleryInfo instanceof GalleryDetail
|
||||
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, newFavoriteName)
|
||||
: listener);
|
||||
doAddToFavorites(activity, galleryInfo, slot1, new DelegateFavoriteCallback(listener, galleryInfo, newFavoriteName, slot1));
|
||||
if (builder.isChecked()) {
|
||||
Settings.putDefaultFavSlot(slot1);
|
||||
} else {
|
||||
@@ -244,33 +236,36 @@ public final class CommonOperations {
|
||||
|
||||
public static void removeFromFavorites(Activity activity, GalleryInfo galleryInfo,
|
||||
final EhClient.Callback<Void> listener) {
|
||||
EhDB.removeLocalFavorites(galleryInfo.gid);
|
||||
EhClient client = EhApplication.getEhClient(activity);
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_ADD_FAVORITES);
|
||||
request.setArgs(galleryInfo.gid, galleryInfo.token, -1, "");
|
||||
request.setCallback(galleryInfo instanceof GalleryDetail
|
||||
? new UpdateFavoriteNameCallback(listener, (GalleryDetail) galleryInfo, null)
|
||||
: listener);
|
||||
request.setCallback(new DelegateFavoriteCallback(listener, galleryInfo, null, -2));
|
||||
client.execute(request);
|
||||
}
|
||||
|
||||
private static class UpdateFavoriteNameCallback implements EhClient.Callback<Void> {
|
||||
private static class DelegateFavoriteCallback implements EhClient.Callback<Void> {
|
||||
|
||||
private final EhClient.Callback<Void> delegate;
|
||||
private final GalleryDetail detail;
|
||||
private final GalleryInfo info;
|
||||
private final String newFavoriteName;
|
||||
private final int slot;
|
||||
|
||||
UpdateFavoriteNameCallback(EhClient.Callback<Void> delegate, GalleryDetail detail,
|
||||
String newFavoriteName) {
|
||||
DelegateFavoriteCallback(EhClient.Callback<Void> delegate, GalleryInfo info,
|
||||
String newFavoriteName, int slot) {
|
||||
this.delegate = delegate;
|
||||
this.detail = detail;
|
||||
this.info = info;
|
||||
this.newFavoriteName = newFavoriteName;
|
||||
this.slot = slot;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
detail.favoriteName = newFavoriteName;
|
||||
info.favoriteName = newFavoriteName;
|
||||
info.favoriteSlot = slot;
|
||||
delegate.onSuccess(result);
|
||||
EhApplication.getFavouriteStatusRouter().modifyFavourites(info.gid, slot);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -25,11 +25,14 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.content.ContextCompat;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.widget.DirExplorer;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import java.io.File;
|
||||
|
||||
public class DirPickerActivity extends ToolbarActivity
|
||||
@@ -46,6 +49,7 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
private TextView mPath;
|
||||
@Nullable
|
||||
private DirExplorer mDirExplorer;
|
||||
private View mDefault;
|
||||
@Nullable
|
||||
private View mOk;
|
||||
|
||||
@@ -55,9 +59,10 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
setContentView(R.layout.activity_dir_picker);
|
||||
setNavigationIcon(R.drawable.v_arrow_left_dark_x24);
|
||||
|
||||
mPath = (TextView) ViewUtils.$$(this, R.id.path);
|
||||
mDirExplorer = (DirExplorer) ViewUtils.$$(this, R.id.dir_explorer);
|
||||
mOk = ViewUtils.$$(this, R.id.ok);
|
||||
mPath = findViewById(R.id.path);
|
||||
mDirExplorer = findViewById(R.id.dir_explorer);
|
||||
mDefault = findViewById(R.id.preset);
|
||||
mOk = findViewById(R.id.ok);
|
||||
|
||||
File file;
|
||||
if (null == savedInstanceState) {
|
||||
@@ -71,6 +76,7 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
|
||||
Ripple.addRipple(mOk, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme));
|
||||
|
||||
mDefault.setOnClickListener(this);
|
||||
mOk.setOnClickListener(this);
|
||||
|
||||
mPath.setText(mDirExplorer.getCurrentFile().getPath());
|
||||
@@ -126,7 +132,31 @@ public class DirPickerActivity extends ToolbarActivity
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View v) {
|
||||
if (mOk == v) {
|
||||
if (mDefault == v) {
|
||||
File[] externalFilesDirs = ContextCompat.getExternalFilesDirs(this, null);
|
||||
File[] dirs = new File[externalFilesDirs.length + 1];
|
||||
dirs[0] = AppConfig.getDefaultDownloadDir();
|
||||
for (int i = 0; i < externalFilesDirs.length; i++) {
|
||||
dirs[i + 1] = new File(externalFilesDirs[i], "download");
|
||||
}
|
||||
|
||||
CharSequence[] items = new CharSequence[dirs.length];
|
||||
items[0] = getString(R.string.default_directory);
|
||||
for (int i = 1; i < items.length; i++) {
|
||||
items[i] = getString(R.string.application_file_directory, i);
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(this).setItems(items, (dialog, which) -> {
|
||||
File dir = dirs[which];
|
||||
if (!FileUtils.ensureDirectory(dir)) {
|
||||
Toast.makeText(DirPickerActivity.this, R.string.directory_not_writable, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
if (mDirExplorer != null) {
|
||||
mDirExplorer.setCurrentFile(dir);
|
||||
}
|
||||
}).show();
|
||||
} else if (mOk == v) {
|
||||
if (null == mDirExplorer) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -145,36 +145,18 @@ public class FilterActivity extends ToolbarActivity {
|
||||
}
|
||||
|
||||
private void showDeleteFilterDialog(final Filter filter) {
|
||||
int messageId;
|
||||
switch (filter.mode) {
|
||||
case EhFilter.MODE_TITLE:
|
||||
messageId = R.string.delete_title_filter;
|
||||
break;
|
||||
case EhFilter.MODE_UPLOADER:
|
||||
messageId = R.string.delete_uploader_filter;
|
||||
break;
|
||||
case EhFilter.MODE_TAG:
|
||||
messageId = R.string.delete_tag_filter;
|
||||
break;
|
||||
default:
|
||||
messageId = R.string.delete_filter;
|
||||
}
|
||||
String message = getString(messageId, filter.text);
|
||||
|
||||
String message = getString(R.string.delete_filter, filter.text);
|
||||
new AlertDialog.Builder(this)
|
||||
.setMessage(message)
|
||||
.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (DialogInterface.BUTTON_POSITIVE != which || null == mFilterList) {
|
||||
return;
|
||||
}
|
||||
mFilterList.delete(filter);
|
||||
if (null != mAdapter) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateView(true);
|
||||
.setPositiveButton(R.string.delete, (dialog, which) -> {
|
||||
if (DialogInterface.BUTTON_POSITIVE != which || null == mFilterList) {
|
||||
return;
|
||||
}
|
||||
mFilterList.delete(filter);
|
||||
if (null != mAdapter) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
updateView(true);
|
||||
}).show();
|
||||
}
|
||||
|
||||
@@ -242,7 +224,7 @@ public class FilterActivity extends ToolbarActivity {
|
||||
public FilterHolder(View itemView) {
|
||||
super(itemView);
|
||||
text = (TextView) ViewUtils.$$(itemView, R.id.text);
|
||||
icon = (ImageView) itemView.findViewById(R.id.icon);
|
||||
icon = itemView.findViewById(R.id.icon);
|
||||
|
||||
if (null != icon) {
|
||||
icon.setOnClickListener(this);
|
||||
|
||||
@@ -49,7 +49,6 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.SwitchCompat;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.BuildConfig;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -60,6 +59,7 @@ import com.hippo.ehviewer.gallery.DirGalleryProvider;
|
||||
import com.hippo.ehviewer.gallery.EhGalleryProvider;
|
||||
import com.hippo.ehviewer.gallery.GalleryProvider2;
|
||||
import com.hippo.ehviewer.widget.GalleryGuideView;
|
||||
import com.hippo.ehviewer.widget.GalleryHeader;
|
||||
import com.hippo.ehviewer.widget.ReversibleSeekBar;
|
||||
import com.hippo.glgallery.GalleryPageView;
|
||||
import com.hippo.glgallery.GalleryProvider;
|
||||
@@ -207,7 +207,6 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
} else if (ACTION_EH.equals(mAction)) {
|
||||
if (mGalleryInfo != null) {
|
||||
mGalleryProvider = new EhGalleryProvider(this, mGalleryInfo);
|
||||
Analytics.readGallery(mGalleryInfo.gid, mGalleryInfo.token);
|
||||
}
|
||||
} else if (Intent.ACTION_VIEW.equals(mAction)) {
|
||||
if (mUri != null) {
|
||||
@@ -371,12 +370,26 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
case 2:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||
break;
|
||||
case 3:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
|
||||
break;
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
|
||||
// Screen lightness
|
||||
setScreenLightness(Settings.getCustomScreenLightness(), Settings.getScreenLightness());
|
||||
|
||||
// Cutout
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
getWindow().getAttributes().layoutInDisplayCutoutMode = WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_SHORT_EDGES;
|
||||
|
||||
GalleryHeader galleryHeader = findViewById(R.id.gallery_header);
|
||||
galleryHeader.setOnApplyWindowInsetsListener((v, insets) -> {
|
||||
galleryHeader.setDisplayCutout(insets.getDisplayCutout());
|
||||
return insets;
|
||||
});
|
||||
}
|
||||
|
||||
if (Settings.getGuideGallery()) {
|
||||
FrameLayout mainLayout = (FrameLayout) ViewUtils.$$(this, R.id.main);
|
||||
mainLayout.addView(new GalleryGuideView(this));
|
||||
@@ -831,6 +844,9 @@ public class GalleryActivity extends EhActivity implements SeekBar.OnSeekBarChan
|
||||
case 2:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE;
|
||||
break;
|
||||
case 3:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_SENSOR;
|
||||
break;
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
mGalleryView.setLayoutMode(layoutMode);
|
||||
|
||||
@@ -22,6 +22,8 @@ package com.hippo.ehviewer.ui;
|
||||
|
||||
import android.app.Dialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.util.Pair;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -86,7 +88,7 @@ public class HostsActivity extends ToolbarActivity
|
||||
LayoutUtils.dp2pix(this, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
recyclerView.addItemDecoration(decoration);
|
||||
recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme)));
|
||||
recyclerView.setSelector(Ripple.generateRippleDrawable(this, !AttrResources.getAttrBoolean(this, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
recyclerView.setHasFixedSize(true);
|
||||
recyclerView.setOnItemClickListener(this);
|
||||
recyclerView.setPadding(
|
||||
|
||||
@@ -175,7 +175,7 @@ public final class MainActivity extends StageActivity
|
||||
return new Announcer(SelectSiteScene.class);
|
||||
} else {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE);
|
||||
args.putString(GalleryListScene.KEY_ACTION, Settings.getLaunchPageGalleryListSceneAction());
|
||||
return new Announcer(GalleryListScene.class).setArgs(args);
|
||||
}
|
||||
}
|
||||
@@ -309,7 +309,7 @@ public final class MainActivity extends StageActivity
|
||||
finish();
|
||||
} else {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE);
|
||||
args.putString(GalleryListScene.KEY_ACTION, Settings.getLaunchPageGalleryListSceneAction());
|
||||
startScene(processAnnouncer(new Announcer(GalleryListScene.class).setArgs(args)));
|
||||
}
|
||||
}
|
||||
@@ -695,6 +695,11 @@ public final class MainActivity extends StageActivity
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE);
|
||||
startSceneFirstly(new Announcer(GalleryListScene.class)
|
||||
.setArgs(args));
|
||||
} else if (id == R.id.nav_subscription) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_SUBSCRIPTION);
|
||||
startSceneFirstly(new Announcer(GalleryListScene.class)
|
||||
.setArgs(args));
|
||||
} else if (id == R.id.nav_whats_hot) {
|
||||
Bundle args = new Bundle();
|
||||
args.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_WHATS_HOT);
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.graphics.Bitmap;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.View;
|
||||
import android.webkit.CookieManager;
|
||||
import android.webkit.CookieSyncManager;
|
||||
import android.webkit.WebView;
|
||||
import android.webkit.WebViewClient;
|
||||
import androidx.annotation.Nullable;
|
||||
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;
|
||||
|
||||
public class MyTagsActivity extends ToolbarActivity {
|
||||
|
||||
private WebView webView;
|
||||
private ProgressView progress;
|
||||
private String url;
|
||||
|
||||
@SuppressLint("SetJavaScriptEnabled")
|
||||
@Override
|
||||
protected void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
// http://stackoverflow.com/questions/32284642/how-to-handle-an-uncatched-exception
|
||||
CookieManager cookieManager = CookieManager.getInstance();
|
||||
if (Build.VERSION.SDK_INT >= 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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
switch (item.getItemId()) {
|
||||
case android.R.id.home:
|
||||
finish();
|
||||
return true;
|
||||
default:
|
||||
return super.onOptionsItemSelected(item);
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,78 @@
|
||||
/*
|
||||
* 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.ui.dialog;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.content.res.AppCompatResources;
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
public class SelectItemWithIconAdapter extends BaseAdapter {
|
||||
|
||||
private Context context;
|
||||
private LayoutInflater inflater;
|
||||
|
||||
private CharSequence[] texts;
|
||||
private int[] icons;
|
||||
|
||||
public SelectItemWithIconAdapter(Context context, CharSequence[] texts, int[] icons) {
|
||||
int count = texts.length;
|
||||
if (count != icons.length) {
|
||||
throw new IllegalArgumentException("Length conflict");
|
||||
}
|
||||
this.context = context;
|
||||
this.inflater = LayoutInflater.from(context);
|
||||
this.texts = texts;
|
||||
this.icons = icons;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return texts.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getItem(int position) {
|
||||
return texts[position];
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getItemId(int position) {
|
||||
return position;
|
||||
}
|
||||
|
||||
@Override
|
||||
public View getView(int position, View convertView, ViewGroup parent) {
|
||||
if (convertView == null) {
|
||||
convertView = inflater.inflate(R.layout.dialog_item_select_with_icon, parent, false);
|
||||
}
|
||||
TextView view = (TextView) convertView;
|
||||
|
||||
view.setText(texts[position]);
|
||||
|
||||
Drawable icon = AppCompatResources.getDrawable(context, icons[position]);
|
||||
icon.setBounds(0, 0, icon.getIntrinsicWidth(), icon.getIntrinsicHeight());
|
||||
view.setCompoundDrawables(icon, null, null, null);
|
||||
|
||||
return view;
|
||||
}
|
||||
}
|
||||
@@ -40,7 +40,6 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
private static final String KEY_DUMP_LOGCAT = "dump_logcat";
|
||||
private static final String KEY_CLEAR_MEMORY_CACHE = "clear_memory_cache";
|
||||
private static final String KEY_APP_LANGUAGE = "app_language";
|
||||
private static final String KEY_EXPORT_DATA = "export_data";
|
||||
private static final String KEY_IMPORT_DATA = "import_data";
|
||||
|
||||
@Override
|
||||
@@ -51,12 +50,10 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
Preference dumpLogcat = findPreference(KEY_DUMP_LOGCAT);
|
||||
Preference clearMemoryCache = findPreference(KEY_CLEAR_MEMORY_CACHE);
|
||||
Preference appLanguage = findPreference(KEY_APP_LANGUAGE);
|
||||
Preference exportData = findPreference(KEY_EXPORT_DATA);
|
||||
Preference importData = findPreference(KEY_IMPORT_DATA);
|
||||
|
||||
dumpLogcat.setOnPreferenceClickListener(this);
|
||||
clearMemoryCache.setOnPreferenceClickListener(this);
|
||||
exportData.setOnPreferenceClickListener(this);
|
||||
importData.setOnPreferenceClickListener(this);
|
||||
|
||||
appLanguage.setOnPreferenceChangeListener(this);
|
||||
@@ -88,18 +85,6 @@ public class AdvancedFragment extends PreferenceFragment
|
||||
} else if (KEY_CLEAR_MEMORY_CACHE.equals(key)) {
|
||||
((EhApplication) getActivity().getApplication()).clearMemoryCache();
|
||||
Runtime.getRuntime().gc();
|
||||
} else if (KEY_EXPORT_DATA.equals(key)) {
|
||||
File dir = AppConfig.getExternalDataDir();
|
||||
if (dir != null) {
|
||||
File file = new File(dir, ReadableTime.getFilenamableTime(System.currentTimeMillis()) + ".db");
|
||||
if (EhDB.exportDB(getActivity(), file)) {
|
||||
Toast.makeText(getActivity(),
|
||||
getString(R.string.settings_advanced_export_data_to, file.getPath()), Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Toast.makeText(getActivity(),R.string.settings_advanced_export_data_failed, Toast.LENGTH_SHORT).show();
|
||||
return true;
|
||||
} else if (KEY_IMPORT_DATA.equals(key)) {
|
||||
importData(getActivity());
|
||||
getActivity().setResult(Activity.RESULT_OK);
|
||||
|
||||
@@ -37,7 +37,6 @@ import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimat
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
|
||||
import com.hippo.app.EditTextDialogBuilder;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
@@ -98,25 +97,21 @@ public class DownloadLabelsScene extends ToolbarScene {
|
||||
tip.setCompoundDrawables(null, drawable, null, null);
|
||||
tip.setText(R.string.no_download_label);
|
||||
|
||||
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
|
||||
RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
|
||||
guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
|
||||
guardManager.setEnabled(true);
|
||||
// drag & drop manager
|
||||
RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
|
||||
dragDropManager.setDraggingItemShadowDrawable(
|
||||
(NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp));
|
||||
|
||||
RecyclerView.Adapter adapter = new LabelAdapter();
|
||||
adapter.setHasStableIds(true);
|
||||
adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging
|
||||
mAdapter = adapter;
|
||||
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
|
||||
animator.setSupportsChangeAnimations(false);
|
||||
mRecyclerView.hasFixedSize();
|
||||
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
mRecyclerView.setItemAnimator(animator);
|
||||
guardManager.attachRecyclerView(mRecyclerView);
|
||||
|
||||
dragDropManager.attachRecyclerView(mRecyclerView);
|
||||
|
||||
updateView();
|
||||
@@ -382,9 +377,6 @@ public class DownloadLabelsScene extends ToolbarScene {
|
||||
}
|
||||
|
||||
EhApplication.getDownloadManager(context).moveLabel(fromPosition, toPosition);
|
||||
if (mAdapter != null && mList != null) {
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -22,7 +22,9 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
@@ -45,6 +47,7 @@ import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.appcompat.widget.Toolbar;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.SimpleItemAnimator;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
@@ -82,7 +85,6 @@ import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.streampipe.InputStreamPipe;
|
||||
import com.hippo.unifile.UniFile;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.IoThreadPoolExecutor;
|
||||
import com.hippo.view.ViewTransition;
|
||||
@@ -299,9 +301,8 @@ public class DownloadsScene extends ToolbarScene
|
||||
mLayoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
|
||||
mLayoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
@@ -1114,9 +1115,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GALLERY_INFO);
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, list.get(index));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
if (ApiHelper.SUPPORT_TRANSITION) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
startScene(announcer);
|
||||
} else if (start == v) {
|
||||
Intent intent = new Intent(activity, DownloadService.class);
|
||||
@@ -1188,8 +1187,7 @@ public class DownloadsScene extends ToolbarScene
|
||||
|
||||
// Update transition name
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = info.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(info.gid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.view.View;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.transition.TransitionInflater;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
|
||||
@@ -40,16 +40,17 @@ class EnterGalleryDetailTransaction implements TransitionHelper {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
String transitionName = ViewCompat.getTransitionName(mThumb);
|
||||
if (transitionName != null) {
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mThumb, mThumb.getTransitionName());
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
transaction.addSharedElement(mThumb, transitionName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -21,9 +21,12 @@ import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableStringBuilder;
|
||||
import android.text.TextUtils;
|
||||
@@ -50,10 +53,11 @@ import com.github.amlcurran.showcaseview.targets.PointTarget;
|
||||
import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.annotation.Implemented;
|
||||
import com.hippo.app.EditTextDialogBuilder;
|
||||
import com.hippo.drawable.AddDeleteDrawable;
|
||||
import com.hippo.drawable.DrawerArrowDrawable;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -70,12 +74,13 @@ import com.hippo.ehviewer.ui.annotation.DrawerLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.ViewLifeCircle;
|
||||
import com.hippo.ehviewer.ui.annotation.WholeLifeCircle;
|
||||
import com.hippo.ehviewer.widget.EhDrawerLayout;
|
||||
import com.hippo.ehviewer.widget.GalleryInfoContentHelper;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
import com.hippo.refreshlayout.RefreshLayout;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.widget.FabLayout;
|
||||
@@ -92,7 +97,8 @@ import java.util.List;
|
||||
public class FavoritesScene extends BaseScene implements
|
||||
EasyRecyclerView.OnItemClickListener, EasyRecyclerView.OnItemLongClickListener,
|
||||
FastScroller.OnDragHandlerListener, SearchBarMover.Helper, SearchBar.Helper,
|
||||
FabLayout.OnClickFabListener, EasyRecyclerView.CustomChoiceListener {
|
||||
FabLayout.OnClickFabListener, FabLayout.OnExpandListener,
|
||||
EasyRecyclerView.CustomChoiceListener {
|
||||
|
||||
private static final long ANIMATE_TIME = 300L;
|
||||
|
||||
@@ -123,6 +129,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Nullable
|
||||
@ViewLifeCircle
|
||||
private DrawerArrowDrawable mLeftDrawable;
|
||||
private AddDeleteDrawable mActionFabDrawable;
|
||||
|
||||
@Nullable
|
||||
private EhDrawerLayout mDrawerLayout;
|
||||
@@ -259,9 +266,8 @@ public class FavoritesScene extends BaseScene implements
|
||||
contentLayout.getFastScroller().setOnDragHandlerListener(this);
|
||||
|
||||
mAdapter = new FavoritesAdapter(inflater, resources, mRecyclerView, Settings.getListMode());
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
@@ -281,10 +287,13 @@ public class FavoritesScene extends BaseScene implements
|
||||
updateSearchBar();
|
||||
mSearchBarMover = new SearchBarMover(this, mSearchBar, mRecyclerView);
|
||||
|
||||
mActionFabDrawable = new AddDeleteDrawable(context, resources.getColor(R.color.primary_drawable_dark));
|
||||
mFabLayout.getPrimaryFab().setImageDrawable(mActionFabDrawable);
|
||||
mFabLayout.setExpanded(false, false);
|
||||
mFabLayout.setAutoCancel(false);
|
||||
mFabLayout.setHidePrimaryFab(true);
|
||||
mFabLayout.setAutoCancel(true);
|
||||
mFabLayout.setHidePrimaryFab(false);
|
||||
mFabLayout.setOnClickFabListener(this);
|
||||
mFabLayout.setOnExpandListener(this);
|
||||
addAboveSnackView(mFabLayout);
|
||||
|
||||
// Restore search mode
|
||||
@@ -301,8 +310,6 @@ public class FavoritesScene extends BaseScene implements
|
||||
|
||||
guideCollections();
|
||||
|
||||
Analytics.viewFavourite();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -394,6 +401,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
|
||||
if (null != mHelper) {
|
||||
mHelper.destroy();
|
||||
if (1 == mHelper.getShownViewIndex()) {
|
||||
mHasFirstRefresh = false;
|
||||
}
|
||||
@@ -543,6 +551,8 @@ public class FavoritesScene extends BaseScene implements
|
||||
|
||||
if (mRecyclerView != null && mRecyclerView.isInCustomChoice()) {
|
||||
mRecyclerView.outOfCustomChoiceMode();
|
||||
} else if (mFabLayout != null && mFabLayout.isExpanded()) {
|
||||
mFabLayout.toggle();
|
||||
} else if (mSearchMode) {
|
||||
exitSearchMode(true);
|
||||
} else {
|
||||
@@ -618,7 +628,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
@@ -738,19 +748,86 @@ public class FavoritesScene extends BaseScene implements
|
||||
onBackPressed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExpand(boolean expanded) {
|
||||
if (expanded) {
|
||||
mActionFabDrawable.setDelete(ANIMATE_TIME);
|
||||
} else {
|
||||
mActionFabDrawable.setAdd(ANIMATE_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Implemented(FabLayout.OnClickFabListener.class)
|
||||
public void onClickPrimaryFab(FabLayout view, FloatingActionButton fab) {
|
||||
if (mRecyclerView != null) {
|
||||
mRecyclerView.outOfCustomChoiceMode();
|
||||
if (mRecyclerView != null && mFabLayout != null) {
|
||||
if (mRecyclerView.isInCustomChoice()) {
|
||||
mRecyclerView.outOfCustomChoiceMode();
|
||||
} else {
|
||||
mFabLayout.toggle();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void showGoToDialog() {
|
||||
Context context = getContext2();
|
||||
if (null == context || null == mHelper) {
|
||||
return;
|
||||
}
|
||||
|
||||
final int page = mHelper.getPageForTop();
|
||||
final int pages = mHelper.getPages();
|
||||
String hint = getString(R.string.go_to_hint, page + 1, pages);
|
||||
final EditTextDialogBuilder builder = new EditTextDialogBuilder(context, null, hint);
|
||||
builder.getEditText().setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);
|
||||
final AlertDialog dialog = builder.setTitle(R.string.go_to)
|
||||
.setPositiveButton(android.R.string.ok, null)
|
||||
.show();
|
||||
dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
|
||||
if (null == mHelper) {
|
||||
dialog.dismiss();
|
||||
return;
|
||||
}
|
||||
|
||||
String text = builder.getText().trim();
|
||||
int goTo;
|
||||
try {
|
||||
goTo = Integer.parseInt(text) - 1;
|
||||
} catch (NumberFormatException e){
|
||||
builder.setError(getString(R.string.error_invalid_number));
|
||||
return;
|
||||
}
|
||||
if (goTo < 0 || goTo >= pages) {
|
||||
builder.setError(getString(R.string.error_out_of_range));
|
||||
return;
|
||||
}
|
||||
builder.setError(null);
|
||||
mHelper.goTo(goTo);
|
||||
AppHelper.hideSoftInput(dialog);
|
||||
dialog.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@Implemented(FabLayout.OnClickFabListener.class)
|
||||
public void onClickSecondaryFab(FabLayout view, FloatingActionButton fab, int position) {
|
||||
Context context = getContext2();
|
||||
if (null == context || null == mRecyclerView || null == mHelper || !mRecyclerView.isInCustomChoice()) {
|
||||
if (null == context || null == mRecyclerView || null == mHelper) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!mRecyclerView.isInCustomChoice()) {
|
||||
switch (position) {
|
||||
case 0: // Go to
|
||||
if (mHelper.canGoTo()) {
|
||||
showGoToDialog();
|
||||
}
|
||||
break;
|
||||
case 1: // Refresh
|
||||
mHelper.refresh();
|
||||
break;
|
||||
}
|
||||
view.setExpanded(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -766,7 +843,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
|
||||
switch (position) {
|
||||
case 0: { // Download
|
||||
case 2: { // Download
|
||||
Activity activity = getActivity2();
|
||||
if (activity != null) {
|
||||
CommonOperations.startDownload(getActivity2(), mModifyGiList, false);
|
||||
@@ -777,7 +854,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: { // Delete
|
||||
case 3: { // Delete
|
||||
DeleteDialogHelper helper = new DeleteDialogHelper();
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.delete_favorites_dialog_title)
|
||||
@@ -787,7 +864,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
.show();
|
||||
break;
|
||||
}
|
||||
case 2: { // Move
|
||||
case 4: { // Move
|
||||
MoveDialogHelper helper = new MoveDialogHelper();
|
||||
// First is local favorite, the other 10 is cloud favorite
|
||||
String[] array = new String[11];
|
||||
@@ -803,11 +880,45 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
}
|
||||
|
||||
private Runnable showNormalFabsRunnable = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (mFabLayout != null) {
|
||||
mFabLayout.setSecondaryFabVisibilityAt(0, true);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(1, true);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(2, false);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(3, false);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(4, false);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private void showNormalFabs() {
|
||||
// Delay showing normal fabs to avoid mutation
|
||||
SimpleHandler.getInstance().removeCallbacks(showNormalFabsRunnable);
|
||||
SimpleHandler.getInstance().postDelayed(showNormalFabsRunnable, 300);
|
||||
}
|
||||
|
||||
private void showSelectionFabs() {
|
||||
SimpleHandler.getInstance().removeCallbacks(showNormalFabsRunnable);
|
||||
|
||||
if (mFabLayout != null) {
|
||||
mFabLayout.setSecondaryFabVisibilityAt(0, false);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(1, false);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(2, true);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(3, true);
|
||||
mFabLayout.setSecondaryFabVisibilityAt(4, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Implemented(EasyRecyclerView.CustomChoiceListener.class)
|
||||
public void onIntoCustomChoice(EasyRecyclerView view) {
|
||||
if (mFabLayout != null) {
|
||||
mFabLayout.setExpanded(true);
|
||||
showSelectionFabs();
|
||||
mFabLayout.setAutoCancel(false);
|
||||
// Delay expanding action to make layout work fine
|
||||
SimpleHandler.getInstance().post(() -> mFabLayout.setExpanded(true));
|
||||
}
|
||||
if (mHelper != null) {
|
||||
mHelper.setRefreshLayoutEnable(false);
|
||||
@@ -821,6 +932,8 @@ public class FavoritesScene extends BaseScene implements
|
||||
@Implemented(EasyRecyclerView.CustomChoiceListener.class)
|
||||
public void onOutOfCustomChoice(EasyRecyclerView view) {
|
||||
if (mFabLayout != null) {
|
||||
showNormalFabs();
|
||||
mFabLayout.setAutoCancel(true);
|
||||
mFabLayout.setExpanded(false);
|
||||
}
|
||||
if (mHelper != null) {
|
||||
@@ -877,8 +990,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
|
||||
updateSearchBar();
|
||||
mHelper.setPages(taskId, result.pages);
|
||||
mHelper.onGetPageData(taskId, result.galleryInfoList);
|
||||
mHelper.onGetPageData(taskId, result.pages, result.nextPage, result.galleryInfoList);
|
||||
|
||||
if (mDrawerAdapter != null) {
|
||||
mDrawerAdapter.notifyDataSetChanged();
|
||||
@@ -904,11 +1016,9 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
|
||||
if (list.size() == 0) {
|
||||
mHelper.setPages(taskId, 0);
|
||||
mHelper.onGetPageData(taskId, Collections.EMPTY_LIST);
|
||||
mHelper.onGetPageData(taskId, 0, 0, Collections.EMPTY_LIST);
|
||||
} else {
|
||||
mHelper.setPages(taskId, 1);
|
||||
mHelper.onGetPageData(taskId, list);
|
||||
mHelper.onGetPageData(taskId, 1, 0, list);
|
||||
}
|
||||
|
||||
if (TextUtils.isEmpty(keyword)) {
|
||||
@@ -1012,7 +1122,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
|
||||
public FavoritesAdapter(@NonNull LayoutInflater inflater, @NonNull Resources resources,
|
||||
@NonNull RecyclerView recyclerView, int type) {
|
||||
super(inflater, resources, recyclerView, type);
|
||||
super(inflater, resources, recyclerView, type, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1027,7 +1137,7 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
}
|
||||
|
||||
private class FavoritesHelper extends ContentLayout.ContentHelper<GalleryInfo> {
|
||||
private class FavoritesHelper extends GalleryInfoContentHelper {
|
||||
|
||||
@Override
|
||||
protected void getPageData(final int taskId, int type, int page) {
|
||||
@@ -1142,6 +1252,11 @@ public class FavoritesScene extends BaseScene implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDuplicate(GalleryInfo d1, GalleryInfo d2) {
|
||||
return d1.gid == d2.gid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollToPosition(int postion) {
|
||||
if (0 == postion) {
|
||||
|
||||
@@ -18,24 +18,26 @@ package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
import com.hippo.drawable.TriangleDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhCacheKeyFactory;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.widget.TileThumb;
|
||||
import com.hippo.widget.recyclerview.AutoStaggeredGridLayoutManager;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
@@ -62,14 +64,18 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
private final int mListThumbWidth;
|
||||
private final int mListThumbHeight;
|
||||
private int mType = TYPE_INVALID;
|
||||
private boolean mShowFavourited;
|
||||
|
||||
private DownloadManager mDownloadManager;
|
||||
|
||||
public GalleryAdapter(@NonNull LayoutInflater inflater, @NonNull Resources resources,
|
||||
@NonNull RecyclerView recyclerView, int type) {
|
||||
@NonNull RecyclerView recyclerView, int type, boolean showFavourited) {
|
||||
mInflater = inflater;
|
||||
mResources = resources;
|
||||
mRecyclerView = recyclerView;
|
||||
mLayoutManager = new AutoStaggeredGridLayoutManager(0, StaggeredGridLayoutManager.VERTICAL);
|
||||
mPaddingTopSB = resources.getDimensionPixelOffset(R.dimen.gallery_padding_top_search_bar);
|
||||
mShowFavourited = showFavourited;
|
||||
|
||||
mRecyclerView.setAdapter(this);
|
||||
mRecyclerView.setLayoutManager(mLayoutManager);
|
||||
@@ -80,6 +86,8 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
mListThumbWidth = mListThumbHeight * 2 / 3;
|
||||
|
||||
setType(type);
|
||||
|
||||
mDownloadManager = EhApplication.getDownloadManager(inflater.getContext());
|
||||
}
|
||||
|
||||
private void adjustPaddings() {
|
||||
@@ -191,23 +199,27 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
holder.rating.setRating(gi.rating);
|
||||
TextView category = holder.category;
|
||||
String newCategoryText = EhUtils.getCategory(gi.category);
|
||||
if (!newCategoryText.equals(category.getText())) {
|
||||
if (!newCategoryText.equals(category.getText().toString())) {
|
||||
category.setText(newCategoryText);
|
||||
category.setBackgroundColor(EhUtils.getCategoryColor(gi.category));
|
||||
}
|
||||
holder.posted.setText(gi.posted);
|
||||
if (gi.pages == 0 || !Settings.getShowGalleryPages()) {
|
||||
holder.pages.setText(null);
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.simpleLanguage.getLayoutParams();
|
||||
lp.addRule(RelativeLayout.LEFT_OF, 0);
|
||||
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT);
|
||||
holder.pages.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.pages.setText(Integer.toString(gi.pages) + "P");
|
||||
RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.simpleLanguage.getLayoutParams();
|
||||
lp.addRule(RelativeLayout.LEFT_OF, R.id.pages);
|
||||
lp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 0);
|
||||
holder.pages.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
if (TextUtils.isEmpty(gi.simpleLanguage)) {
|
||||
holder.simpleLanguage.setText(null);
|
||||
holder.simpleLanguage.setVisibility(View.GONE);
|
||||
} else {
|
||||
holder.simpleLanguage.setText(gi.simpleLanguage);
|
||||
holder.simpleLanguage.setVisibility(View.VISIBLE);
|
||||
}
|
||||
holder.favourited.setVisibility((mShowFavourited && gi.favoriteSlot >= -1 && gi.favoriteSlot <= 10) ? View.VISIBLE : View.GONE);
|
||||
holder.downloaded.setVisibility(mDownloadManager.containDownloadInfo(gi.gid) ? View.VISIBLE : View.GONE);
|
||||
break;
|
||||
}
|
||||
case TYPE_GRID: {
|
||||
@@ -228,9 +240,6 @@ abstract class GalleryAdapter extends RecyclerView.Adapter<GalleryHolder> {
|
||||
}
|
||||
|
||||
// Update transition name
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gi.gid));
|
||||
}
|
||||
}
|
||||
@@ -18,17 +18,17 @@ package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.animation.Animator;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Typeface;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Looper;
|
||||
import android.os.Parcelable;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.SpannableStringBuilder;
|
||||
@@ -55,7 +55,6 @@ import com.google.android.material.floatingactionbutton.FloatingActionButton;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
@@ -63,6 +62,8 @@ import com.hippo.ehviewer.client.EhClient;
|
||||
import com.hippo.ehviewer.client.EhRequest;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.parser.VoteCommentParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.reveal.ViewAnimationUtils;
|
||||
@@ -99,14 +100,14 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
public static final String KEY_API_KEY = "api_key";
|
||||
public static final String KEY_GID = "gid";
|
||||
public static final String KEY_TOKEN = "token";
|
||||
public static final String KEY_COMMENTS = "comments";
|
||||
public static final String KEY_COMMENT_LIST = "comment_list";
|
||||
|
||||
private long mApiUid;
|
||||
private String mApiKey;
|
||||
private long mGid;
|
||||
private String mToken;
|
||||
@Nullable
|
||||
private GalleryComment[] mComments;
|
||||
private GalleryCommentList mCommentList;
|
||||
|
||||
@Nullable
|
||||
private EasyRecyclerView mRecyclerView;
|
||||
@@ -125,8 +126,15 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Nullable
|
||||
private ViewTransition mViewTransition;
|
||||
|
||||
private Drawable mSendDrawable;
|
||||
private Drawable mPencilDrawable;
|
||||
private long mCommentId;
|
||||
|
||||
private boolean mInAnimation = false;
|
||||
|
||||
private boolean mShowAllComments = false;
|
||||
private boolean mRefreshingComments = false;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
@@ -147,10 +155,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mApiKey = args.getString(KEY_API_KEY);
|
||||
mGid = args.getLong(KEY_GID, -1L);
|
||||
mToken = args.getString(KEY_TOKEN, null);
|
||||
Parcelable[] parcelables = args.getParcelableArray(KEY_COMMENTS);
|
||||
if (parcelables instanceof GalleryComment[]) {
|
||||
mComments = (GalleryComment[]) parcelables;
|
||||
}
|
||||
mCommentList = args.getParcelable(KEY_COMMENT_LIST);
|
||||
mShowAllComments = mCommentList != null && !mCommentList.hasMore;
|
||||
}
|
||||
|
||||
private void onInit() {
|
||||
@@ -162,10 +168,8 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
mApiKey = savedInstanceState.getString(KEY_API_KEY);
|
||||
mGid = savedInstanceState.getLong(KEY_GID, -1L);
|
||||
mToken = savedInstanceState.getString(KEY_TOKEN, null);
|
||||
Parcelable[] parcelables = savedInstanceState.getParcelableArray(KEY_COMMENTS);
|
||||
if (parcelables instanceof GalleryComment[]) {
|
||||
mComments = (GalleryComment[]) parcelables;
|
||||
}
|
||||
mCommentList = savedInstanceState.getParcelable(KEY_COMMENT_LIST);
|
||||
mShowAllComments = mCommentList != null && !mCommentList.hasMore;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -175,7 +179,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
outState.putString(KEY_API_KEY, mApiKey);
|
||||
outState.putLong(KEY_GID, mGid);
|
||||
outState.putString(KEY_TOKEN, mToken);
|
||||
outState.putParcelableArray(KEY_COMMENTS, mComments);
|
||||
outState.putParcelable(KEY_COMMENT_LIST, mCommentList);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -200,6 +204,9 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
drawable.setBounds(0, 0, drawable.getIntrinsicWidth(), drawable.getIntrinsicHeight());
|
||||
tip.setCompoundDrawables(null, drawable, null, null);
|
||||
|
||||
mSendDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_send_dark_x24);
|
||||
mPencilDrawable = DrawableManager.getVectorDrawable(context, R.drawable.v_pencil_dark_x24);
|
||||
|
||||
mAdapter = new CommentAdapter();
|
||||
mRecyclerView.setAdapter(mAdapter);
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(context,
|
||||
@@ -209,7 +216,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setPadding(mRecyclerView.getPaddingLeft(), mRecyclerView.getPaddingTop(),
|
||||
@@ -282,8 +289,6 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
.setCallback(new VoteCommentListener(context,
|
||||
activity.getStageId(), getTag()));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
|
||||
Analytics.voteComment(mGid, mToken);
|
||||
}
|
||||
|
||||
private class InfoHolder extends RecyclerView.ViewHolder {
|
||||
@@ -344,32 +349,34 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(ResourcesUtils.getAttrDimensionPixelOffset(context, R.attr.dialogPreferredPadding));
|
||||
rv.addItemDecoration(decoration);
|
||||
rv.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
rv.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
rv.setClipToPadding(false);
|
||||
builder.setView(rv).show();
|
||||
}
|
||||
|
||||
private void showCommentDialog(int position) {
|
||||
final Context context = getContext2();
|
||||
if (null == context || null == mComments || position >= mComments.length || position < 0) {
|
||||
if (context == null || mCommentList == null || mCommentList.comments == null || position >= mCommentList.comments.length || position < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
final GalleryComment comment = mComments[position];
|
||||
final GalleryComment comment = mCommentList.comments[position];
|
||||
List<String> menu = new ArrayList<>();
|
||||
final IntList menuId = new IntList();
|
||||
Resources resources = context.getResources();
|
||||
if (0 == comment.id || mApiUid < 0) {
|
||||
// 0 id is uploader comment, can't vote
|
||||
// Not sign in, can't vote
|
||||
menu.add(resources.getString(R.string.copy_comment_text));
|
||||
menuId.add(R.id.copy);
|
||||
} else {
|
||||
menu.add(resources.getString(R.string.copy_comment_text));
|
||||
menuId.add(R.id.copy);
|
||||
menu.add(resources.getString(comment.voteUp ? R.string.cancel_vote_up : R.string.vote_up));
|
||||
|
||||
menu.add(resources.getString(R.string.copy_comment_text));
|
||||
menuId.add(R.id.copy);
|
||||
if (comment.editable) {
|
||||
menu.add(resources.getString(R.string.edit_comment));
|
||||
menuId.add(R.id.edit_comment);
|
||||
}
|
||||
if (comment.voteUpAble) {
|
||||
menu.add(resources.getString(comment.voteUpEd ? R.string.cancel_vote_up : R.string.vote_up));
|
||||
menuId.add(R.id.vote_up);
|
||||
menu.add(resources.getString(comment.voteDown ? R.string.cancel_vote_down : R.string.vote_down));
|
||||
}
|
||||
if (comment.voteDownAble) {
|
||||
menu.add(resources.getString(comment.voteDownEd ? R.string.cancel_vote_down : R.string.vote_down));
|
||||
menuId.add(R.id.vote_down);
|
||||
}
|
||||
if (!TextUtils.isEmpty(comment.voteState)) {
|
||||
@@ -400,6 +407,12 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
case R.id.check_vote_status:
|
||||
showVoteStatusDialog(context, comment.voteState);
|
||||
break;
|
||||
case R.id.edit_comment:
|
||||
prepareEditComment(comment.id);
|
||||
if (!mInAnimation && mEditPanel != null && mEditPanel.getVisibility() != View.VISIBLE) {
|
||||
showEditPanel(true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}).show();
|
||||
@@ -407,25 +420,38 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
@Override
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
Activity activity = getActivity2();
|
||||
MainActivity activity = getActivity2();
|
||||
if (null == activity) {
|
||||
return false;
|
||||
}
|
||||
|
||||
RecyclerView.ViewHolder holder = parent.getChildViewHolder(view);
|
||||
if (holder instanceof CommentHolder) {
|
||||
CommentHolder commentHolder = (CommentHolder) holder;
|
||||
if (holder instanceof ActualCommentHolder) {
|
||||
ActualCommentHolder commentHolder = (ActualCommentHolder) holder;
|
||||
ClickableSpan span = commentHolder.comment.getCurrentSpan();
|
||||
commentHolder.comment.clearCurrentSpan();
|
||||
|
||||
if (span instanceof URLSpan) {
|
||||
UrlOpener.openUrl(activity, ((URLSpan) span).getURL(), true);
|
||||
return true;
|
||||
} else {
|
||||
showCommentDialog(position);
|
||||
}
|
||||
} else if (holder instanceof MoreCommentHolder && !mRefreshingComments && mAdapter != null) {
|
||||
mRefreshingComments = true;
|
||||
mShowAllComments = true;
|
||||
mAdapter.notifyItemChanged(position);
|
||||
|
||||
String url = getGalleryDetailUrl();
|
||||
if (url != null) {
|
||||
// Request
|
||||
EhRequest request = new EhRequest()
|
||||
.setMethod(EhClient.METHOD_GET_GALLERY_DETAIL)
|
||||
.setArgs(url)
|
||||
.setCallback(new RefreshCommentListener(activity, activity.getStageId(), getTag()));
|
||||
EhApplication.getEhClient(activity).execute(request);
|
||||
}
|
||||
}
|
||||
|
||||
showCommentDialog(position);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -434,13 +460,27 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
return;
|
||||
}
|
||||
|
||||
if (mComments == null || mComments.length <= 0) {
|
||||
if (mCommentList == null || mCommentList.comments == null || mCommentList.comments.length <= 0) {
|
||||
mViewTransition.showView(1, animation);
|
||||
} else {
|
||||
mViewTransition.showView(0, animation);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareNewComment() {
|
||||
mCommentId = 0;
|
||||
if (mSendImage != null) {
|
||||
mSendImage.setImageDrawable(mSendDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
private void prepareEditComment(long commentId) {
|
||||
mCommentId = commentId;
|
||||
if (mSendImage != null) {
|
||||
mSendImage.setImageDrawable(mPencilDrawable);
|
||||
}
|
||||
}
|
||||
|
||||
private void showEditPanelWithAnimation() {
|
||||
if (null == mFab || null == mEditPanel) {
|
||||
return;
|
||||
@@ -554,7 +594,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
@Nullable
|
||||
private String getGalleryDetailUrl() {
|
||||
if (mGid != -1 && mToken != null) {
|
||||
return EhUrl.getGalleryDetailUrl(mGid, mToken, 0, false);
|
||||
return EhUrl.getGalleryDetailUrl(mGid, mToken, 0, mShowAllComments);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
@@ -570,6 +610,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
if (mFab == v) {
|
||||
if (!mInAnimation) {
|
||||
prepareNewComment();
|
||||
showEditPanel(true);
|
||||
}
|
||||
} else if (mSendImage == v) {
|
||||
@@ -586,14 +627,12 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
// Request
|
||||
EhRequest request = new EhRequest()
|
||||
.setMethod(EhClient.METHOD_GET_COMMENT_GALLERY)
|
||||
.setArgs(url, comment)
|
||||
.setArgs(url, comment, mCommentId != 0 ? Long.toString(mCommentId) : null)
|
||||
.setCallback(new CommentGalleryListener(context,
|
||||
activity.getStageId(), getTag()));
|
||||
activity.getStageId(), getTag(), mCommentId));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
hideSoftInput();
|
||||
hideEditPanel(true);
|
||||
|
||||
Analytics.commentGallery(mGid, mToken);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -610,17 +649,73 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
}
|
||||
|
||||
private class CommentHolder extends RecyclerView.ViewHolder {
|
||||
private static final int TYPE_COMMENT = 0;
|
||||
private static final int TYPE_MORE = 1;
|
||||
private static final int TYPE_PROGRESS = 2;
|
||||
|
||||
public final TextView user;
|
||||
public final TextView time;
|
||||
public final LinkifyTextView comment;
|
||||
private abstract class CommentHolder extends RecyclerView.ViewHolder {
|
||||
public CommentHolder(LayoutInflater inflater, int resId, ViewGroup parent) {
|
||||
super(inflater.inflate(resId, parent, false));
|
||||
}
|
||||
}
|
||||
|
||||
public CommentHolder(View itemView) {
|
||||
super(itemView);
|
||||
user = (TextView) itemView.findViewById(R.id.user);
|
||||
time = (TextView) itemView.findViewById(R.id.time);
|
||||
comment = (LinkifyTextView) itemView.findViewById(R.id.comment);
|
||||
private class ActualCommentHolder extends CommentHolder {
|
||||
|
||||
private final TextView user;
|
||||
private final TextView time;
|
||||
private final LinkifyTextView comment;
|
||||
|
||||
public ActualCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment, parent);
|
||||
user = itemView.findViewById(R.id.user);
|
||||
time = itemView.findViewById(R.id.time);
|
||||
comment = itemView.findViewById(R.id.comment);
|
||||
}
|
||||
|
||||
private CharSequence generateComment(Context context, ObservedTextView textView, GalleryComment comment) {
|
||||
SpannableStringBuilder ssb = Html.fromHtml(comment.comment, new URLImageGetter(textView,
|
||||
EhApplication.getConaco(context)), null);
|
||||
|
||||
if (0 != comment.id && 0 != comment.score) {
|
||||
int score = comment.score;
|
||||
String scoreString = score > 0 ? "+" + score : Integer.toString(score);
|
||||
SpannableString ss = new SpannableString(scoreString);
|
||||
ss.setSpan(new RelativeSizeSpan(0.8f), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(AttrResources.getAttrColor(context, android.R.attr.textColorSecondary))
|
||||
, 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.append(" ").append(ss);
|
||||
}
|
||||
|
||||
if (comment.lastEdited != 0) {
|
||||
String str = context.getString(R.string.last_edited, ReadableTime.getTimeAgo(comment.lastEdited));
|
||||
SpannableString ss = new SpannableString(str);
|
||||
ss.setSpan(new RelativeSizeSpan(0.8f), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(AttrResources.getAttrColor(context, android.R.attr.textColorSecondary)),
|
||||
0, str.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.append("\n\n").append(ss);
|
||||
}
|
||||
|
||||
return TextUrl.handleTextUrl(ssb);
|
||||
}
|
||||
|
||||
public void bind(GalleryComment value) {
|
||||
user.setText(value.user);
|
||||
time.setText(ReadableTime.getTimeAgo(value.time));
|
||||
comment.setText(generateComment(comment.getContext(), comment, value));
|
||||
}
|
||||
}
|
||||
|
||||
private class MoreCommentHolder extends CommentHolder {
|
||||
public MoreCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_more, parent);
|
||||
}
|
||||
}
|
||||
|
||||
private class ProgressCommentHolder extends CommentHolder {
|
||||
public ProgressCommentHolder(LayoutInflater inflater, ViewGroup parent) {
|
||||
super(inflater, R.layout.item_gallery_comment_progress, parent);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -634,56 +729,89 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommentHolder onCreateViewHolder(ViewGroup parent, int viewType) {
|
||||
return new CommentHolder(mInflater.inflate(R.layout.item_gallery_comment, parent, false));
|
||||
}
|
||||
|
||||
public CharSequence generateComment(Context context, ObservedTextView textView, GalleryComment comment) {
|
||||
SpannableStringBuilder ssb = Html.fromHtml(comment.comment, new URLImageGetter(textView,
|
||||
EhApplication.getConaco(context)), null);
|
||||
|
||||
if (0 != comment.id && 0 != comment.score) {
|
||||
int score = comment.score;
|
||||
String scoreString = score > 0 ? "+" + score : Integer.toString(score);
|
||||
SpannableString ss = new SpannableString(scoreString);
|
||||
ss.setSpan(new RelativeSizeSpan(0.8f), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new StyleSpan(Typeface.BOLD), 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ss.setSpan(new ForegroundColorSpan(AttrResources.getAttrColor(context, android.R.attr.textColorSecondary))
|
||||
, 0, scoreString.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
|
||||
ssb.append(" ").append(ss);
|
||||
public CommentHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
switch (viewType) {
|
||||
case TYPE_COMMENT:
|
||||
return new ActualCommentHolder(mInflater, parent);
|
||||
case TYPE_MORE:
|
||||
return new MoreCommentHolder(mInflater, parent);
|
||||
case TYPE_PROGRESS:
|
||||
return new ProgressCommentHolder(mInflater, parent);
|
||||
default:
|
||||
throw new IllegalStateException("Invalid view type: " + viewType);
|
||||
}
|
||||
|
||||
return TextUrl.handleTextUrl(ssb);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(CommentHolder holder, int position) {
|
||||
public void onBindViewHolder(@NonNull CommentHolder holder, int position) {
|
||||
Context context = getContext2();
|
||||
if (null == context || null == mComments) {
|
||||
if (context == null || mCommentList == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GalleryComment comment = mComments[position];
|
||||
holder.user.setText(comment.user);
|
||||
holder.time.setText(ReadableTime.getTimeAgo(comment.time));
|
||||
holder.comment.setText(generateComment(context, holder.comment, comment));
|
||||
if (holder instanceof ActualCommentHolder) {
|
||||
((ActualCommentHolder) holder).bind(mCommentList.comments[position]);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return mComments == null ? 0 : mComments.length;
|
||||
if (mCommentList == null || mCommentList.comments == null) {
|
||||
return 0;
|
||||
} else if (mCommentList.hasMore) {
|
||||
return mCommentList.comments.length + 1;
|
||||
} else {
|
||||
return mCommentList.comments.length;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
if (position >= mCommentList.comments.length) {
|
||||
return mRefreshingComments ? TYPE_PROGRESS : TYPE_MORE;
|
||||
} else {
|
||||
return TYPE_COMMENT;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommentGallerySuccess(GalleryComment[] result) {
|
||||
if (null == mAdapter) {
|
||||
private void onRefreshGallerySuccess(GalleryCommentList result) {
|
||||
if (mAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mComments = result;
|
||||
mRefreshingComments = false;
|
||||
mCommentList = result;
|
||||
mAdapter.notifyDataSetChanged();
|
||||
|
||||
updateView(true);
|
||||
|
||||
Bundle re = new Bundle();
|
||||
re.putParcelable(KEY_COMMENT_LIST, result);
|
||||
setResult(SceneFragment.RESULT_OK, re);
|
||||
}
|
||||
|
||||
private void onRefreshGalleryFailure() {
|
||||
if (mAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mRefreshingComments = false;
|
||||
int position = mAdapter.getItemCount() - 1;
|
||||
if (position >= 0) {
|
||||
mAdapter.notifyItemChanged(position);
|
||||
}
|
||||
}
|
||||
|
||||
private void onCommentGallerySuccess(GalleryCommentList result) {
|
||||
if (mAdapter == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
mCommentList = result;
|
||||
mAdapter.notifyDataSetChanged();
|
||||
Bundle re = new Bundle();
|
||||
re.putParcelableArray(KEY_COMMENTS, result);
|
||||
re.putParcelable(KEY_COMMENT_LIST, result);
|
||||
setResult(SceneFragment.RESULT_OK, re);
|
||||
|
||||
// Remove text
|
||||
@@ -695,13 +823,13 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
private void onVoteCommentSuccess(VoteCommentParser.Result result) {
|
||||
if (null == mAdapter || null == mComments) {
|
||||
if (mAdapter == null || mCommentList == null || mCommentList.comments == null ) {
|
||||
return;
|
||||
}
|
||||
|
||||
int position = -1;
|
||||
for (int i = 0, n = mComments.length; i < n; i++) {
|
||||
GalleryComment comment = mComments[i];
|
||||
for (int i = 0, n = mCommentList.comments.length; i < n; i++) {
|
||||
GalleryComment comment = mCommentList.comments[i];
|
||||
if (comment.id == result.id) {
|
||||
position = i;
|
||||
break;
|
||||
@@ -714,32 +842,66 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
}
|
||||
|
||||
// Update comment
|
||||
GalleryComment comment = mComments[position];
|
||||
GalleryComment comment = mCommentList.comments[position];
|
||||
comment.score = result.score;
|
||||
if (result.expectVote > 0) {
|
||||
comment.voteUp = 0 != result.vote;
|
||||
comment.voteDown = false;
|
||||
comment.voteUpEd = 0 != result.vote;
|
||||
comment.voteDownEd = false;
|
||||
} else {
|
||||
comment.voteDown = 0 != result.vote;
|
||||
comment.voteUp = false;
|
||||
comment.voteDownEd = 0 != result.vote;
|
||||
comment.voteUpEd = false;
|
||||
}
|
||||
|
||||
mAdapter.notifyItemChanged(position);
|
||||
|
||||
Bundle re = new Bundle();
|
||||
re.putParcelableArray(KEY_COMMENTS, mComments);
|
||||
re.putParcelable(KEY_COMMENT_LIST, mCommentList);
|
||||
setResult(SceneFragment.RESULT_OK, re);
|
||||
}
|
||||
|
||||
private static class CommentGalleryListener extends EhCallback<GalleryCommentsScene, GalleryComment[]> {
|
||||
private static class RefreshCommentListener extends EhCallback<GalleryCommentsScene, GalleryDetail> {
|
||||
|
||||
public CommentGalleryListener(Context context, int stageId, String sceneTag) {
|
||||
public RefreshCommentListener(Context context, int stageId, String sceneTag) {
|
||||
super(context, stageId, sceneTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GalleryComment[] result) {
|
||||
showTip(R.string.comment_successfully, LENGTH_SHORT);
|
||||
public void onSuccess(GalleryDetail result) {
|
||||
GalleryCommentsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onRefreshGallerySuccess(result.comments);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
GalleryCommentsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onRefreshGalleryFailure();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() { }
|
||||
|
||||
@Override
|
||||
public boolean isInstance(SceneFragment scene) {
|
||||
return scene instanceof GalleryCommentsScene;
|
||||
}
|
||||
}
|
||||
|
||||
private static class CommentGalleryListener extends EhCallback<GalleryCommentsScene, GalleryCommentList> {
|
||||
|
||||
private long mCommentId;
|
||||
|
||||
public CommentGalleryListener(Context context, int stageId, String sceneTag, long commentId) {
|
||||
super(context, stageId, sceneTag);
|
||||
mCommentId = commentId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(GalleryCommentList result) {
|
||||
showTip(mCommentId != 0 ? R.string.edit_comment_successfully : R.string.comment_successfully, LENGTH_SHORT);
|
||||
|
||||
GalleryCommentsScene scene = getScene();
|
||||
if (scene != null) {
|
||||
@@ -749,7 +911,7 @@ public final class GalleryCommentsScene extends ToolbarScene
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(getContent().getString(R.string.comment_failed) + "\n" + ExceptionUtils.getReadableString(e), LENGTH_LONG);
|
||||
showTip(getContent().getString(mCommentId != 0 ? R.string.edit_comment_failed : R.string.comment_failed) + "\n" + ExceptionUtils.getReadableString(e), LENGTH_LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -26,12 +26,9 @@ import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.transition.TransitionInflater;
|
||||
import android.util.Pair;
|
||||
import android.view.Gravity;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -55,11 +52,11 @@ import androidx.appcompat.widget.PopupMenu;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentTransaction;
|
||||
import androidx.transition.TransitionInflater;
|
||||
import com.hippo.android.resource.AttrResources;
|
||||
import com.hippo.beerbelly.BeerBelly;
|
||||
import com.hippo.drawable.RoundSideRectDrawable;
|
||||
import com.hippo.drawerlayout.DrawerLayout;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.AppConfig;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
@@ -74,6 +71,7 @@ import com.hippo.ehviewer.client.EhTagDatabase;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryComment;
|
||||
import com.hippo.ehviewer.client.data.GalleryCommentList;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.ehviewer.client.data.GalleryTagGroup;
|
||||
@@ -95,7 +93,6 @@ import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.scene.TransitionHelper;
|
||||
import com.hippo.text.Html;
|
||||
import com.hippo.text.URLImageGetter;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
@@ -119,6 +116,7 @@ import java.io.OutputStream;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.List;
|
||||
import okhttp3.HttpUrl;
|
||||
|
||||
public class GalleryDetailScene extends BaseScene implements View.OnClickListener,
|
||||
com.hippo.ehviewer.download.DownloadManager.DownloadInfoListener,
|
||||
@@ -148,6 +146,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private static final String KEY_GALLERY_DETAIL = "gallery_detail";
|
||||
private static final String KEY_REQUEST_ID = "request_id";
|
||||
|
||||
private static final boolean TRANSITION_ANIMATION_DISABLED = true;
|
||||
|
||||
/*---------------
|
||||
View life cycle
|
||||
---------------*/
|
||||
@@ -679,14 +679,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
.setCallback(callback);
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
|
||||
if (mGalleryDetail != null) {
|
||||
Analytics.viewGallery(mGalleryDetail.gid, mGalleryDetail.token);
|
||||
} else if (mGalleryInfo != null) {
|
||||
Analytics.viewGallery(mGalleryInfo.gid, mGalleryInfo.token);
|
||||
} else {
|
||||
Analytics.viewGallery(mGid, mToken);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -722,8 +714,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
int w = mColorBg.getWidth();
|
||||
int h = mColorBg.getHeight();
|
||||
if (ViewCompat.isAttachedToWindow(mColorBg) && w != 0 && h != 0) {
|
||||
ViewAnimationUtils.createCircularReveal(mColorBg, w / 2, h / 2, 0,
|
||||
(float) Math.hypot(w / 2, h / 2)).setDuration(300).start();
|
||||
Resources resources = getContext2().getResources();
|
||||
int keylineMargin = resources.getDimensionPixelSize(R.dimen.keyline_margin);
|
||||
int thumbWidth = resources.getDimensionPixelSize(R.dimen.gallery_detail_thumb_width);
|
||||
int thumbHeight = resources.getDimensionPixelSize(R.dimen.gallery_detail_thumb_height);
|
||||
|
||||
int x = thumbWidth / 2 + keylineMargin;
|
||||
int y = thumbHeight / 2 + keylineMargin;
|
||||
|
||||
int radiusX = Math.max(Math.abs(x), Math.abs(w - x));
|
||||
int radiusY = Math.max(Math.abs(y), Math.abs(h - y));
|
||||
float radius = (float) Math.hypot(radiusX, radiusY);
|
||||
|
||||
ViewAnimationUtils.createCircularReveal(mColorBg, x, y, 0, radius).setDuration(300).start();
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
@@ -741,6 +744,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
int oldState = mState;
|
||||
mState = state;
|
||||
|
||||
animation = !TRANSITION_ANIMATION_DISABLED && animation;
|
||||
|
||||
switch (state) {
|
||||
case STATE_NORMAL:
|
||||
// Show mMainView
|
||||
@@ -769,12 +774,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
if ((oldState == STATE_INIT || oldState == STATE_FAILED || oldState == STATE_REFRESH) &&
|
||||
(state == STATE_NORMAL || state == STATE_REFRESH_HEADER) && AttrResources.getAttrBoolean(getContext2(), R.attr.isLightTheme)) {
|
||||
if (!createCircularReveal()) {
|
||||
SimpleHandler.getInstance().post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
createCircularReveal();
|
||||
}
|
||||
});
|
||||
SimpleHandler.getInstance().post(this::createCircularReveal);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -857,7 +857,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
mTorrent.setText(resources.getString(R.string.torrent_count, gd.torrentCount));
|
||||
|
||||
bindTags(gd.tags);
|
||||
bindComments(gd.comments);
|
||||
bindComments(gd.comments.comments);
|
||||
bindPreviews(gd);
|
||||
}
|
||||
|
||||
@@ -1033,13 +1033,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
private void setTransitionName() {
|
||||
long gid = getGid();
|
||||
|
||||
if (gid != -1 && ApiHelper.SUPPORT_TRANSITION && mThumb != null &&
|
||||
mTitle != null && mUploader != null && mCategory != null &&
|
||||
Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
mThumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
mTitle.setTransitionName(TransitionNameFactory.getTitleTransitionName(gid));
|
||||
mUploader.setTransitionName(TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
mCategory.setTransitionName(TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
if (gid != -1 && mThumb != null &&
|
||||
mTitle != null && mUploader != null && mCategory != null) {
|
||||
ViewCompat.setTransitionName(mThumb, TransitionNameFactory.getThumbTransitionName(gid));
|
||||
ViewCompat.setTransitionName(mTitle, TransitionNameFactory.getTitleTransitionName(gid));
|
||||
ViewCompat.setTransitionName(mUploader, TransitionNameFactory.getUploaderTransitionName(gid));
|
||||
ViewCompat.setTransitionName(mCategory, TransitionNameFactory.getCategoryTransitionName(gid));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1098,7 +1097,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
if (null != keyword) {
|
||||
ListUrlBuilder lub = new ListUrlBuilder();
|
||||
lub.setMode(ListUrlBuilder.MODE_NORMAL);
|
||||
lub.setKeyword(keyword);
|
||||
lub.setKeyword("\"" + keyword + "\"");
|
||||
GalleryListScene.startScene(this, lub);
|
||||
return;
|
||||
}
|
||||
@@ -1188,7 +1187,15 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
} else if (mDownload == v) {
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
CommonOperations.startDownload(activity, galleryInfo, false);
|
||||
if (EhApplication.getDownloadManager(context).getDownloadState(galleryInfo.gid) == DownloadInfo.STATE_INVALID) {
|
||||
CommonOperations.startDownload(activity, galleryInfo, false);
|
||||
} else {
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.download_remove_dialog_title)
|
||||
.setMessage(getString(R.string.download_remove_dialog_message, galleryInfo.title))
|
||||
.setPositiveButton(android.R.string.ok, (dialog1, which1) -> EhApplication.getDownloadManager(context).deleteDownload(galleryInfo.gid))
|
||||
.show();
|
||||
}
|
||||
}
|
||||
} else if (mRead == v) {
|
||||
GalleryInfo galleryInfo = null;
|
||||
@@ -1210,11 +1217,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
} else if (mHeartGroup == v) {
|
||||
if (mGalleryDetail != null && !mModifingFavorites) {
|
||||
boolean remove = false;
|
||||
if (EhDB.containLocalFavorites(mGalleryDetail.gid)) {
|
||||
EhDB.removeLocalFavorites(mGalleryDetail.gid);
|
||||
remove = true;
|
||||
}
|
||||
if (mGalleryDetail.isFavorited) {
|
||||
if (EhDB.containLocalFavorites(mGalleryDetail.gid) || mGalleryDetail.isFavorited) {
|
||||
mModifingFavorites = true;
|
||||
CommonOperations.removeFromFavorites(activity, mGalleryDetail,
|
||||
new ModifyFavoritesListener(context,
|
||||
@@ -1289,7 +1292,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
args.putString(GalleryCommentsScene.KEY_API_KEY, mGalleryDetail.apiKey);
|
||||
args.putLong(GalleryCommentsScene.KEY_GID, mGalleryDetail.gid);
|
||||
args.putString(GalleryCommentsScene.KEY_TOKEN, mGalleryDetail.token);
|
||||
args.putParcelableArray(GalleryCommentsScene.KEY_COMMENTS, mGalleryDetail.comments);
|
||||
args.putParcelable(GalleryCommentsScene.KEY_COMMENT_LIST, mGalleryDetail.comments);
|
||||
startScene(new Announcer(GalleryCommentsScene.class)
|
||||
.setArgs(args)
|
||||
.setRequestCode(this, REQUEST_CODE_COMMENT_GALLERY));
|
||||
@@ -1324,41 +1327,49 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
}
|
||||
|
||||
private void showBlockUploaderDialog() {
|
||||
private void showFilterUploaderDialog() {
|
||||
Context context = getContext2();
|
||||
if (null == context) {
|
||||
return;
|
||||
}
|
||||
final String uploader = getUploader();
|
||||
if (null == uploader) {
|
||||
String uploader = getUploader();
|
||||
if (context == null || uploader == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(getString(R.string.block_the_uploader, uploader))
|
||||
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
if (DialogInterface.BUTTON_POSITIVE != which) {
|
||||
return;
|
||||
}
|
||||
|
||||
Filter filter = new Filter();
|
||||
filter.mode = EhFilter.MODE_UPLOADER;
|
||||
filter.text = uploader;
|
||||
EhFilter.getInstance().addFilter(filter);
|
||||
|
||||
showTip(R.string.filter_added, LENGTH_SHORT);
|
||||
.setMessage(getString(R.string.filter_the_uploader, uploader))
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
if (which != DialogInterface.BUTTON_POSITIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Filter filter = new Filter();
|
||||
filter.mode = EhFilter.MODE_UPLOADER;
|
||||
filter.text = uploader;
|
||||
EhFilter.getInstance().addFilter(filter);
|
||||
|
||||
showTip(R.string.filter_added, LENGTH_SHORT);
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void addTagFilter(String tag) {
|
||||
Filter filter = new Filter();
|
||||
filter.mode = EhFilter.MODE_TAG;
|
||||
filter.text = tag;
|
||||
EhFilter.getInstance().addFilter(filter);
|
||||
showTip(R.string.filter_added, LENGTH_SHORT);
|
||||
private void showFilterTagDialog(String tag) {
|
||||
Context context = getContext2();
|
||||
if (context == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setMessage(getString(R.string.filter_the_tag, tag))
|
||||
.setPositiveButton(android.R.string.ok, (dialog, which) -> {
|
||||
if (which != DialogInterface.BUTTON_POSITIVE) {
|
||||
return;
|
||||
}
|
||||
|
||||
Filter filter = new Filter();
|
||||
filter.mode = EhFilter.MODE_TAG;
|
||||
filter.text = tag;
|
||||
EhFilter.getInstance().addFilter(filter);
|
||||
|
||||
showTip(R.string.filter_added, LENGTH_SHORT);
|
||||
}).show();
|
||||
}
|
||||
|
||||
private void showTagDialog(final String tag) {
|
||||
@@ -1377,17 +1388,14 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(tag)
|
||||
.setItems(R.array.tag_menu_entries, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0:
|
||||
UrlOpener.openUrl(context, EhUrl.getTagDefinitionUrl(tag2), false);
|
||||
break;
|
||||
case 1:
|
||||
addTagFilter(tag);
|
||||
break;
|
||||
}
|
||||
.setItems(R.array.tag_menu_entries, (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0:
|
||||
UrlOpener.openUrl(context, EhUrl.getTagDefinitionUrl(tag2), false);
|
||||
break;
|
||||
case 1:
|
||||
showFilterTagDialog(tag);
|
||||
break;
|
||||
}
|
||||
}).show();
|
||||
}
|
||||
@@ -1400,7 +1408,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
}
|
||||
|
||||
if (mUploader == v) {
|
||||
showBlockUploaderDialog();
|
||||
showFilterUploaderDialog();
|
||||
} else if (mDownload == v) {
|
||||
GalleryInfo galleryInfo = getGalleryInfo();
|
||||
if (galleryInfo != null) {
|
||||
@@ -1419,7 +1427,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (ApiHelper.SUPPORT_TRANSITION && mViewTransition != null && mThumb != null &&
|
||||
if (mViewTransition != null && mThumb != null &&
|
||||
mViewTransition.getShownViewIndex() == 0 && mThumb.isShown()) {
|
||||
int[] location = new int[2];
|
||||
mThumb.getLocationInWindow(location);
|
||||
@@ -1440,16 +1448,12 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
if (resultCode != RESULT_OK || data == null){
|
||||
break;
|
||||
}
|
||||
Parcelable[] array = data.getParcelableArray(GalleryCommentsScene.KEY_COMMENTS);
|
||||
if (!(array instanceof GalleryComment[])) {
|
||||
break;
|
||||
}
|
||||
GalleryComment[] comments = (GalleryComment[]) array;
|
||||
if (mGalleryDetail == null) {
|
||||
GalleryCommentList comments = data.getParcelable(GalleryCommentsScene.KEY_COMMENT_LIST);
|
||||
if (mGalleryDetail == null && comments == null) {
|
||||
break;
|
||||
}
|
||||
mGalleryDetail.comments = comments;
|
||||
bindComments(comments);
|
||||
bindComments(comments.comments);
|
||||
break;
|
||||
default:
|
||||
super.onSceneResult(requestCode, resultCode, data);
|
||||
@@ -1550,16 +1554,17 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
return false;
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
String transitionName = ViewCompat.getTransitionName(mThumb);
|
||||
if (transitionName != null) {
|
||||
exit.setSharedElementReturnTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
exit.setExitTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
enter.setSharedElementEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_move));
|
||||
enter.setEnterTransition(
|
||||
TransitionInflater.from(context).inflateTransition(android.R.transition.fade));
|
||||
transaction.addSharedElement(mThumb, mThumb.getTransitionName());
|
||||
TransitionInflater.from(context).inflateTransition(R.transition.trans_fade));
|
||||
transaction.addSharedElement(mThumb, transitionName);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -1755,7 +1760,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
request.setArgs(mGalleryDetail.gid, mGalleryDetail.token, mArchiveFormParamOr, res);
|
||||
request.setCallback(new DownloadArchiveListener(context, activity.getStageId(), getTag()));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
Analytics.downloadArchive(mGalleryDetail.gid, mGalleryDetail.token);
|
||||
}
|
||||
|
||||
if (mDialog != null) {
|
||||
@@ -1872,6 +1876,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
FileUtils.sanitizeFilename(name + ".torrent"));
|
||||
r.allowScanningByMediaScanner();
|
||||
r.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
|
||||
r.addRequestHeader("Cookie", EhApplication.getEhCookieStore(context).getCookieHeader(HttpUrl.get(url)));
|
||||
DownloadManager dm = (DownloadManager) context.getSystemService(Context.DOWNLOAD_SERVICE);
|
||||
if (dm != null) {
|
||||
try {
|
||||
@@ -2009,8 +2014,6 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
|
||||
.setCallback(new RateGalleryListener(context,
|
||||
activity.getStageId(), getTag(), mGalleryDetail.gid));
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
|
||||
Analytics.rateGallery(mGalleryDetail.gid, mGalleryDetail.token);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.hippo.ehviewer.ui.scene;
|
||||
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -33,17 +34,21 @@ class GalleryHolder extends RecyclerView.ViewHolder {
|
||||
public final TextView posted;
|
||||
public final TextView pages;
|
||||
public final TextView simpleLanguage;
|
||||
public final ImageView favourited;
|
||||
public final ImageView downloaded;
|
||||
|
||||
public GalleryHolder(View itemView) {
|
||||
super(itemView);
|
||||
|
||||
thumb = (LoadImageView) itemView.findViewById(R.id.thumb);
|
||||
title = (TextView) itemView.findViewById(R.id.title);
|
||||
uploader = (TextView) itemView.findViewById(R.id.uploader);
|
||||
rating = (SimpleRatingView) itemView.findViewById(R.id.rating);
|
||||
category = (TextView) itemView.findViewById(R.id.category);
|
||||
posted = (TextView) itemView.findViewById(R.id.posted);
|
||||
pages = (TextView) itemView.findViewById(R.id.pages);
|
||||
simpleLanguage = (TextView) itemView.findViewById(R.id.simple_language);
|
||||
thumb = itemView.findViewById(R.id.thumb);
|
||||
title = itemView.findViewById(R.id.title);
|
||||
uploader = itemView.findViewById(R.id.uploader);
|
||||
rating = itemView.findViewById(R.id.rating);
|
||||
category = itemView.findViewById(R.id.category);
|
||||
posted = itemView.findViewById(R.id.posted);
|
||||
pages = itemView.findViewById(R.id.pages);
|
||||
simpleLanguage = itemView.findViewById(R.id.simple_language);
|
||||
favourited = itemView.findViewById(R.id.favourited);
|
||||
downloaded = itemView.findViewById(R.id.downloaded);
|
||||
}
|
||||
}
|
||||
@@ -20,6 +20,8 @@ import android.content.ClipData;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -34,6 +36,7 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.LinearDividerItemDecoration;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.UrlOpener;
|
||||
import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.data.GalleryDetail;
|
||||
@@ -49,6 +52,9 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
public static final String KEY_KEYS = "keys";
|
||||
public static final String KEY_VALUES = "values";
|
||||
|
||||
private static final int INDEX_URL = 3;
|
||||
private static final int INDEX_PARENT = 10;
|
||||
|
||||
/*---------------
|
||||
Whole life cycle
|
||||
---------------*/
|
||||
@@ -169,7 +175,7 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setPadding(context.getResources().getDimensionPixelOffset(R.dimen.keyline_margin));
|
||||
mRecyclerView.addItemDecoration(decoration);
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setHasFixedSize(true);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
@@ -197,15 +203,19 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler
|
||||
public boolean onItemClick(EasyRecyclerView parent, View view, int position, long id) {
|
||||
Context context = getContext2();
|
||||
if (null != context && 0 != position && null != mValues) {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
|
||||
if (position == INDEX_PARENT) {
|
||||
UrlOpener.openUrl(context, mValues.get(position), true);
|
||||
} else {
|
||||
ClipboardManager cmb = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
|
||||
cmb.setPrimaryClip(ClipData.newPlainText(null, mValues.get(position)));
|
||||
|
||||
if (position == 3) {
|
||||
// Save it to avoid detect the gallery
|
||||
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
|
||||
if (position == INDEX_URL) {
|
||||
// Save it to avoid detect the gallery
|
||||
Settings.putClipboardTextHashCode(mValues.get(position).hashCode());
|
||||
}
|
||||
|
||||
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
|
||||
}
|
||||
|
||||
showTip(R.string.copied_to_clipboard, LENGTH_SHORT);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
||||
@@ -22,7 +22,9 @@ import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.Point;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.text.InputType;
|
||||
@@ -59,9 +61,9 @@ import com.hippo.drawable.DrawerArrowDrawable;
|
||||
import com.hippo.drawerlayout.DrawerLayout;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.FavouriteStatusRouter;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
import com.hippo.ehviewer.client.EhClient;
|
||||
@@ -74,16 +76,20 @@ import com.hippo.ehviewer.client.exception.EhException;
|
||||
import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryListParser;
|
||||
import com.hippo.ehviewer.client.parser.GalleryPageUrlParser;
|
||||
import com.hippo.ehviewer.dao.DownloadInfo;
|
||||
import com.hippo.ehviewer.dao.QuickSearch;
|
||||
import com.hippo.ehviewer.download.DownloadManager;
|
||||
import com.hippo.ehviewer.ui.CommonOperations;
|
||||
import com.hippo.ehviewer.ui.GalleryActivity;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.ui.dialog.SelectItemWithIconAdapter;
|
||||
import com.hippo.ehviewer.widget.GalleryInfoContentHelper;
|
||||
import com.hippo.ehviewer.widget.SearchBar;
|
||||
import com.hippo.ehviewer.widget.SearchLayout;
|
||||
import com.hippo.refreshlayout.RefreshLayout;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.AppHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
@@ -118,6 +124,7 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
public final static String KEY_ACTION = "action";
|
||||
public final static String ACTION_HOMEPAGE = "action_homepage";
|
||||
public final static String ACTION_SUBSCRIPTION = "action_subscription";
|
||||
public final static String ACTION_WHATS_HOT = "action_whats_hot";
|
||||
public final static String ACTION_LIST_URL_BUILDER = "action_list_url_builder";
|
||||
|
||||
@@ -218,6 +225,11 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
private ShowcaseView mShowcaseView;
|
||||
|
||||
private DownloadManager mDownloadManager;
|
||||
private DownloadManager.DownloadInfoListener mDownloadInfoListener;
|
||||
private FavouriteStatusRouter mFavouriteStatusRouter;
|
||||
private FavouriteStatusRouter.Listener mFavouriteStatusRouterListener;
|
||||
|
||||
@Override
|
||||
public int getNavCheckedItem() {
|
||||
return mNavCheckedId;
|
||||
@@ -231,7 +243,11 @@ public final class GalleryListScene extends BaseScene
|
||||
String action = args.getString(KEY_ACTION);
|
||||
if (ACTION_HOMEPAGE.equals(action)) {
|
||||
mUrlBuilder.reset();
|
||||
} else if (ACTION_SUBSCRIPTION.equals(action)) {
|
||||
mUrlBuilder.reset();
|
||||
mUrlBuilder.setMode(ListUrlBuilder.MODE_SUBSCRIPTION);
|
||||
} else if (ACTION_WHATS_HOT.equals(action)) {
|
||||
mUrlBuilder.reset();
|
||||
mUrlBuilder.setMode(ListUrlBuilder.MODE_WHATS_HOT);
|
||||
} else if (ACTION_LIST_URL_BUILDER.equals(action)) {
|
||||
ListUrlBuilder builder = args.getParcelable(KEY_LIST_URL_BUILDER);
|
||||
@@ -261,6 +277,51 @@ public final class GalleryListScene extends BaseScene
|
||||
Context context = getContext2();
|
||||
AssertUtils.assertNotNull(context);
|
||||
mClient = EhApplication.getEhClient(context);
|
||||
mDownloadManager = EhApplication.getDownloadManager(context);
|
||||
mFavouriteStatusRouter = EhApplication.getFavouriteStatusRouter(context);
|
||||
|
||||
mDownloadInfoListener = new DownloadManager.DownloadInfoListener() {
|
||||
@Override
|
||||
public void onAdd(@NonNull DownloadInfo info, @NonNull List<DownloadInfo> list, int position) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(@NonNull DownloadInfo info, @NonNull List<DownloadInfo> list) { }
|
||||
@Override
|
||||
public void onUpdateAll() { }
|
||||
@Override
|
||||
public void onReload() {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onChange() {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onRenameLabel(String from, String to) { }
|
||||
@Override
|
||||
public void onRemove(@NonNull DownloadInfo info, @NonNull List<DownloadInfo> list, int position) {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void onUpdateLabels() { }
|
||||
};
|
||||
mDownloadManager.addDownloadInfoListener(mDownloadInfoListener);
|
||||
|
||||
mFavouriteStatusRouterListener = (gid, slot) -> {
|
||||
if (mAdapter != null) {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
};
|
||||
mFavouriteStatusRouter.addListener(mFavouriteStatusRouterListener);
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
onInit();
|
||||
@@ -302,6 +363,8 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
mClient = null;
|
||||
mUrlBuilder = null;
|
||||
mDownloadManager.removeDownloadInfoListener(mDownloadInfoListener);
|
||||
mFavouriteStatusRouter.removeListener(mFavouriteStatusRouterListener);
|
||||
}
|
||||
|
||||
private void setSearchBarHint(Context context, SearchBar searchBar) {
|
||||
@@ -413,8 +476,20 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
if (ListUrlBuilder.MODE_NORMAL == urlBuilder.getMode() &&
|
||||
EhUtils.NONE == category &&
|
||||
TextUtils.isEmpty(keyword)) {
|
||||
TextUtils.isEmpty(keyword) &&
|
||||
urlBuilder.getAdvanceSearch() == -1 &&
|
||||
urlBuilder.getMinRating() == -1 &&
|
||||
urlBuilder.getPageFrom() == -1 &&
|
||||
urlBuilder.getPageTo() == -1) {
|
||||
return resources.getString(appName ? R.string.app_name : R.string.homepage);
|
||||
} else if (ListUrlBuilder.MODE_SUBSCRIPTION == urlBuilder.getMode() &&
|
||||
EhUtils.NONE == category &&
|
||||
TextUtils.isEmpty(keyword) &&
|
||||
urlBuilder.getAdvanceSearch() == -1 &&
|
||||
urlBuilder.getMinRating() == -1 &&
|
||||
urlBuilder.getPageFrom() == -1 &&
|
||||
urlBuilder.getPageTo() == -1) {
|
||||
return resources.getString(R.string.subscription);
|
||||
} else if (ListUrlBuilder.MODE_WHATS_HOT == urlBuilder.getMode()) {
|
||||
return resources.getString(R.string.whats_hot);
|
||||
} else if (!TextUtils.isEmpty(keyword)) {
|
||||
@@ -426,19 +501,48 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
private String wrapTagKeyword(String keyword) {
|
||||
keyword = keyword.trim();
|
||||
|
||||
int index1 = keyword.indexOf(':');
|
||||
if (index1 == -1 || index1 >= keyword.length() - 1) {
|
||||
// Can't find :, or : is the last char
|
||||
return keyword;
|
||||
}
|
||||
if (keyword.charAt(index1 + 1) == '"') {
|
||||
// The char after : is ", the word must be quoted
|
||||
return keyword;
|
||||
}
|
||||
int index2 = keyword.indexOf(' ');
|
||||
if (index2 <= index1) {
|
||||
// Can't find space, or space is before :
|
||||
return keyword;
|
||||
}
|
||||
|
||||
return keyword.substring(0, index1 + 1) + "\"" + keyword.substring(index1 + 1) + "$\"";
|
||||
}
|
||||
|
||||
// Update search bar title, drawer checked item
|
||||
private void onUpdateUrlBuilder() {
|
||||
ListUrlBuilder builder = mUrlBuilder;
|
||||
Resources resources = getResources2();
|
||||
if (null == resources || null == builder) {
|
||||
if (resources == null || builder == null || mSearchLayout == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String keyword = builder.getKeyword();
|
||||
int category = builder.getCategory();
|
||||
|
||||
// Update normal search mode
|
||||
mSearchLayout.setNormalSearchMode(builder.getMode() == ListUrlBuilder.MODE_SUBSCRIPTION
|
||||
? R.id.search_subscription_search
|
||||
: R.id.search_normal_search);
|
||||
|
||||
// Update search edit text
|
||||
if (!TextUtils.isEmpty(keyword) && null != mSearchBar) {
|
||||
if (builder.getMode() == ListUrlBuilder.MODE_TAG) {
|
||||
keyword = wrapTagKeyword(keyword);
|
||||
}
|
||||
mSearchBar.setText(keyword);
|
||||
mSearchBar.cursorToEnd();
|
||||
}
|
||||
@@ -458,6 +562,8 @@ public final class GalleryListScene extends BaseScene
|
||||
EhUtils.NONE == category &&
|
||||
TextUtils.isEmpty(keyword)) {
|
||||
checkedItemId = R.id.nav_homepage;
|
||||
} else if (ListUrlBuilder.MODE_SUBSCRIPTION == builder.getMode()) {
|
||||
checkedItemId = R.id.nav_subscription;
|
||||
} else if (ListUrlBuilder.MODE_WHATS_HOT == builder.getMode()) {
|
||||
checkedItemId = R.id.nav_whats_hot;
|
||||
} else {
|
||||
@@ -496,15 +602,13 @@ public final class GalleryListScene extends BaseScene
|
||||
mViewTransition = new ViewTransition(contentLayout, mSearchLayout);
|
||||
|
||||
mHelper = new GalleryListHelper();
|
||||
mHelper.setEmptyString(resources.getString(R.string.gallery_list_empty_hit));
|
||||
contentLayout.setHelper(mHelper);
|
||||
contentLayout.getFastScroller().setOnDragHandlerListener(this);
|
||||
|
||||
mAdapter = new GalleryListAdapter(inflater, resources,
|
||||
mRecyclerView, Settings.getListMode());
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
@@ -603,6 +707,7 @@ public final class GalleryListScene extends BaseScene
|
||||
mSearchBarMover = null;
|
||||
}
|
||||
if (null != mHelper) {
|
||||
mHelper.destroy();
|
||||
if (1 == mHelper.getShownViewIndex()) {
|
||||
mHasFirstRefresh = false;
|
||||
}
|
||||
@@ -843,7 +948,7 @@ public final class GalleryListScene extends BaseScene
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, gi);
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
@@ -854,6 +959,7 @@ public final class GalleryListScene extends BaseScene
|
||||
public void onClick(View v) {
|
||||
if (STATE_NORMAL != mState && null != mSearchBar) {
|
||||
mSearchBar.applySearch();
|
||||
hideSoftInput();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -956,21 +1062,49 @@ public final class GalleryListScene extends BaseScene
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean downloaded = mDownloadManager.getDownloadState(gi.gid) != DownloadInfo.STATE_INVALID;
|
||||
boolean favourited = gi.favoriteSlot != -2;
|
||||
|
||||
CharSequence[] items = new CharSequence[] {
|
||||
context.getString(R.string.read),
|
||||
context.getString(downloaded ? R.string.delete_downloads : R.string.download),
|
||||
context.getString(favourited ? R.string.remove_from_favourites : R.string.add_to_favourites),
|
||||
};
|
||||
|
||||
int[] icons = new int[] {
|
||||
R.drawable.v_book_open_x24,
|
||||
downloaded ? R.drawable.v_delete_x24 : R.drawable.v_download_x24,
|
||||
favourited ? R.drawable.v_heart_broken_x24 : R.drawable.v_heart_x24,
|
||||
};
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(EhUtils.getSuitableTitle(gi))
|
||||
.setItems(R.array.gallery_list_menu_entries, new DialogInterface.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
switch (which) {
|
||||
case 0: // Download
|
||||
.setAdapter(new SelectItemWithIconAdapter(context, items, icons), (dialog, which) -> {
|
||||
switch (which) {
|
||||
case 0: // Read
|
||||
Intent intent = new Intent(activity, GalleryActivity.class);
|
||||
intent.setAction(GalleryActivity.ACTION_EH);
|
||||
intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, gi);
|
||||
startActivity(intent);
|
||||
break;
|
||||
case 1: // Download
|
||||
if (downloaded) {
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.download_remove_dialog_title)
|
||||
.setMessage(getString(R.string.download_remove_dialog_message, gi.title))
|
||||
.setPositiveButton(android.R.string.ok, (dialog1, which1) -> mDownloadManager.deleteDownload(gi.gid))
|
||||
.show();
|
||||
} else {
|
||||
CommonOperations.startDownload(activity, gi, false);
|
||||
break;
|
||||
case 1: // Favorites
|
||||
CommonOperations.addToFavorites(activity, gi,
|
||||
new addToFavoriteListener(context,
|
||||
activity.getStageId(), getTag()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case 2: // Favorites
|
||||
if (favourited) {
|
||||
CommonOperations.removeFromFavorites(activity, gi, new RemoveFromFavoriteListener(context, activity.getStageId(), getTag()));
|
||||
} else {
|
||||
CommonOperations.addToFavorites(activity, gi, new AddToFavoriteListener(context, activity.getStageId(), getTag()));
|
||||
}
|
||||
break;
|
||||
}
|
||||
}).show();
|
||||
return true;
|
||||
@@ -1209,7 +1343,13 @@ public final class GalleryListScene extends BaseScene
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
int oldMode = mUrlBuilder.getMode();
|
||||
// If it's MODE_SUBSCRIPTION, keep it
|
||||
int newMode = oldMode == ListUrlBuilder.MODE_SUBSCRIPTION
|
||||
? ListUrlBuilder.MODE_SUBSCRIPTION
|
||||
: ListUrlBuilder.MODE_NORMAL;
|
||||
mUrlBuilder.reset();
|
||||
mUrlBuilder.setMode(newMode);
|
||||
mUrlBuilder.setKeyword(query);
|
||||
}
|
||||
onUpdateUrlBuilder();
|
||||
@@ -1338,7 +1478,7 @@ public final class GalleryListScene extends BaseScene
|
||||
|
||||
public GalleryListAdapter(@NonNull LayoutInflater inflater,
|
||||
@NonNull Resources resources, @NonNull RecyclerView recyclerView, int type) {
|
||||
super(inflater, resources, recyclerView, type);
|
||||
super(inflater, resources, recyclerView, type, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1353,7 +1493,7 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
private class GalleryListHelper extends ContentLayout.ContentHelper<GalleryInfo> {
|
||||
private class GalleryListHelper extends GalleryInfoContentHelper {
|
||||
|
||||
@Override
|
||||
protected void getPageData(int taskId, int type, int page) {
|
||||
@@ -1363,15 +1503,7 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
|
||||
mUrlBuilder.setPageIndex(page);
|
||||
if (ListUrlBuilder.MODE_WHATS_HOT == mUrlBuilder.getMode()) {
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_GET_WHATS_HOT);
|
||||
request.setCallback(new GetWhatsHotListener(getContext(),
|
||||
activity.getStageId(), getTag(), taskId));
|
||||
request.setArgs();
|
||||
mClient.execute(request);
|
||||
Analytics.viewWhatsHot();
|
||||
} else if (ListUrlBuilder.MODE_IMAGE_SEARCH == mUrlBuilder.getMode()) {
|
||||
if (ListUrlBuilder.MODE_IMAGE_SEARCH == mUrlBuilder.getMode()) {
|
||||
EhRequest request = new EhRequest();
|
||||
request.setMethod(EhClient.METHOD_IMAGE_SEARCH);
|
||||
request.setCallback(new GetGalleryListListener(getContext(),
|
||||
@@ -1380,7 +1512,6 @@ public final class GalleryListScene extends BaseScene
|
||||
mUrlBuilder.isUseSimilarityScan(),
|
||||
mUrlBuilder.isOnlySearchCovers(), mUrlBuilder.isShowExpunged());
|
||||
mClient.execute(request);
|
||||
Analytics.imageSearch();
|
||||
} else {
|
||||
String url = mUrlBuilder.build();
|
||||
EhRequest request = new EhRequest();
|
||||
@@ -1389,7 +1520,6 @@ public final class GalleryListScene extends BaseScene
|
||||
activity.getStageId(), getTag(), taskId));
|
||||
request.setArgs(url);
|
||||
mClient.execute(request);
|
||||
Analytics.viewGalleryList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1427,6 +1557,11 @@ public final class GalleryListScene extends BaseScene
|
||||
showActionFab();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDuplicate(GalleryInfo d1, GalleryInfo d2) {
|
||||
return d1.gid == d2.gid;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onScrollToPosition(int postion) {
|
||||
if (0 == postion) {
|
||||
@@ -1441,8 +1576,11 @@ public final class GalleryListScene extends BaseScene
|
||||
private void onGetGalleryListSuccess(GalleryListParser.Result result, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId)) {
|
||||
mHelper.setPages(taskId, result.pages);
|
||||
mHelper.onGetPageData(taskId, result.galleryInfoList);
|
||||
String emptyString = getResources2().getString(mUrlBuilder.getMode() == ListUrlBuilder.MODE_SUBSCRIPTION && result.noWatchedTags
|
||||
? R.string.gallery_list_empty_hit_subscription
|
||||
: R.string.gallery_list_empty_hit);
|
||||
mHelper.setEmptyString(emptyString);
|
||||
mHelper.onGetPageData(taskId, result.pages, result.nextPage, result.galleryInfoList);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,55 +1591,6 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
private void onGetWhatsHotSuccess(List<GalleryInfo> result, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId)) {
|
||||
mHelper.setPages(taskId, 1);
|
||||
mHelper.onGetPageData(taskId, result);
|
||||
}
|
||||
}
|
||||
|
||||
private void onGetWhatsHotFailure(Exception e, int taskId) {
|
||||
if (mHelper != null && mSearchBarMover != null &&
|
||||
mHelper.isCurrentTask(taskId)) {
|
||||
mHelper.onGetException(taskId, e);
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetWhatsHotListener extends EhCallback<GalleryListScene, List<GalleryInfo>> {
|
||||
|
||||
private final int mTaskId;
|
||||
|
||||
public GetWhatsHotListener(Context context, int stageId, String sceneTag, int taskId) {
|
||||
super(context, stageId, sceneTag);
|
||||
mTaskId = taskId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(List<GalleryInfo> result) {
|
||||
GalleryListScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetWhatsHotSuccess(result, mTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
GalleryListScene scene = getScene();
|
||||
if (scene != null) {
|
||||
scene.onGetWhatsHotFailure(e, mTaskId);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(SceneFragment scene) {
|
||||
return scene instanceof GalleryListScene;
|
||||
}
|
||||
}
|
||||
|
||||
private static class GetGalleryListListener extends EhCallback<GalleryListScene, GalleryListParser.Result> {
|
||||
|
||||
private final int mTaskId;
|
||||
@@ -1536,9 +1625,9 @@ public final class GalleryListScene extends BaseScene
|
||||
}
|
||||
}
|
||||
|
||||
private static class addToFavoriteListener extends EhCallback<GalleryListScene, Void> {
|
||||
private static class AddToFavoriteListener extends EhCallback<GalleryListScene, Void> {
|
||||
|
||||
public addToFavoriteListener(Context context, int stageId, String sceneTag) {
|
||||
public AddToFavoriteListener(Context context, int stageId, String sceneTag) {
|
||||
super(context, stageId, sceneTag);
|
||||
}
|
||||
|
||||
@@ -1560,4 +1649,29 @@ public final class GalleryListScene extends BaseScene
|
||||
return scene instanceof GalleryListScene;
|
||||
}
|
||||
}
|
||||
|
||||
private static class RemoveFromFavoriteListener extends EhCallback<GalleryListScene, Void> {
|
||||
|
||||
public RemoveFromFavoriteListener(Context context, int stageId, String sceneTag) {
|
||||
super(context, stageId, sceneTag);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void result) {
|
||||
showTip(R.string.remove_from_favorite_success, LENGTH_SHORT);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Exception e) {
|
||||
showTip(R.string.remove_from_favorite_failure, LENGTH_LONG);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCancel() {}
|
||||
|
||||
@Override
|
||||
public boolean isInstance(SceneFragment scene) {
|
||||
return scene instanceof GalleryListScene;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -330,6 +330,11 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
mAdapter.notifyItemRangeInserted(positionStart, itemCount);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isDuplicate(GalleryPreview d1, GalleryPreview d2) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private void onGetPreviewSetSuccess(Pair<PreviewSet, Integer> result, int taskId) {
|
||||
@@ -341,8 +346,7 @@ public class GalleryPreviewsScene extends ToolbarScene implements EasyRecyclerVi
|
||||
list.add(previewSet.getGalleryPreview(mGalleryInfo.gid, i));
|
||||
}
|
||||
|
||||
mHelper.setPages(taskId, result.second);
|
||||
mHelper.onGetPageData(taskId, list);
|
||||
mHelper.onGetPageData(taskId, result.second, 0, list);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ package com.hippo.ehviewer.ui.scene;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.res.Resources;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
@@ -29,6 +31,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.core.view.ViewCompat;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import androidx.recyclerview.widget.StaggeredGridLayoutManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
||||
@@ -46,7 +49,6 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.easyrecyclerview.FastScroller;
|
||||
import com.hippo.easyrecyclerview.HandlerDrawable;
|
||||
import com.hippo.easyrecyclerview.MarginItemDecoration;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
@@ -60,7 +62,6 @@ import com.hippo.ehviewer.widget.SimpleRatingView;
|
||||
import com.hippo.ripple.Ripple;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ApiHelper;
|
||||
import com.hippo.util.DrawableManager;
|
||||
import com.hippo.view.ViewTransition;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
@@ -125,9 +126,8 @@ public class HistoryScene extends ToolbarScene
|
||||
layoutManager.setColumnSize(resources.getDimensionPixelOffset(Settings.getDetailSizeResId()));
|
||||
layoutManager.setStrategy(AutoStaggeredGridLayoutManager.STRATEGY_MIN_SIZE);
|
||||
mRecyclerView.setLayoutManager(layoutManager);
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
mRecyclerView.setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
mRecyclerView.setDrawSelectorOnTop(true);
|
||||
mRecyclerView.hasFixedSize();
|
||||
mRecyclerView.setClipToPadding(false);
|
||||
mRecyclerView.setOnItemClickListener(this);
|
||||
mRecyclerView.setOnItemLongClickListener(this);
|
||||
@@ -148,8 +148,6 @@ public class HistoryScene extends ToolbarScene
|
||||
updateLazyList();
|
||||
updateView(false);
|
||||
|
||||
Analytics.viewHistory();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
@@ -258,7 +256,7 @@ public class HistoryScene extends ToolbarScene
|
||||
args.putParcelable(GalleryDetailScene.KEY_GALLERY_INFO, mLazyList.get(position));
|
||||
Announcer announcer = new Announcer(GalleryDetailScene.class).setArgs(args);
|
||||
View thumb;
|
||||
if (ApiHelper.SUPPORT_TRANSITION && null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
if (null != (thumb = view.findViewById(R.id.thumb))) {
|
||||
announcer.setTranHelper(new EnterGalleryDetailTransaction(thumb));
|
||||
}
|
||||
startScene(announcer);
|
||||
@@ -384,7 +382,7 @@ public class HistoryScene extends ToolbarScene
|
||||
// Update transition name
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
|
||||
long gid = gi.gid;
|
||||
holder.thumb.setTransitionName(TransitionNameFactory.getThumbTransitionName(gid));
|
||||
ViewCompat.setTransitionName(holder.thumb, TransitionNameFactory.getThumbTransitionName(gid));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -29,12 +29,11 @@ import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.DraggableItemAnimator;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.GeneralItemAnimator;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.animator.SwipeDismissItemAnimator;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.DraggableItemAdapter;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.ItemDraggableRange;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.draggable.RecyclerViewDragDropManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.touchguard.RecyclerViewTouchActionGuardManager;
|
||||
import com.h6ah4i.android.widget.advrecyclerview.utils.AbstractDraggableItemViewHolder;
|
||||
import com.hippo.easyrecyclerview.EasyRecyclerView;
|
||||
import com.hippo.ehviewer.EhDB;
|
||||
@@ -95,26 +94,21 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
tip.setCompoundDrawables(null, drawable, null, null);
|
||||
tip.setText(R.string.no_quick_search);
|
||||
|
||||
// touch guard manager (this class is required to suppress scrolling while swipe-dismiss animation is running)
|
||||
RecyclerViewTouchActionGuardManager guardManager = new RecyclerViewTouchActionGuardManager();
|
||||
guardManager.setInterceptVerticalScrollingWhileAnimationRunning(true);
|
||||
guardManager.setEnabled(true);
|
||||
// drag & drop manager
|
||||
RecyclerViewDragDropManager dragDropManager = new RecyclerViewDragDropManager();
|
||||
dragDropManager.setDraggingItemShadowDrawable(
|
||||
(NinePatchDrawable) context.getResources().getDrawable(R.drawable.shadow_8dp));
|
||||
// swipe manager
|
||||
|
||||
RecyclerView.Adapter adapter = new QuickSearchAdapter();
|
||||
adapter.setHasStableIds(true);
|
||||
adapter = dragDropManager.createWrappedAdapter(adapter); // wrap for dragging
|
||||
mAdapter = adapter;
|
||||
final GeneralItemAnimator animator = new SwipeDismissItemAnimator();
|
||||
animator.setSupportsChangeAnimations(false);
|
||||
mRecyclerView.hasFixedSize();
|
||||
|
||||
final GeneralItemAnimator animator = new DraggableItemAnimator();
|
||||
mRecyclerView.setLayoutManager(new LinearLayoutManager(context));
|
||||
mRecyclerView.setAdapter(adapter);
|
||||
mRecyclerView.setItemAnimator(animator);
|
||||
guardManager.attachRecyclerView(mRecyclerView);
|
||||
|
||||
dragDropManager.attachRecyclerView(mRecyclerView);
|
||||
|
||||
updateView();
|
||||
@@ -257,7 +251,6 @@ public final class QuickSearchScene extends ToolbarScene {
|
||||
EhDB.moveQuickSearch(fromPosition, toPosition);
|
||||
final QuickSearch item = mQuickSearchList.remove(fromPosition);
|
||||
mQuickSearchList.add(toPosition, item);
|
||||
notifyItemMoved(fromPosition, toPosition);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -29,7 +29,6 @@ import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.appcompat.app.AlertDialog;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.hippo.ehviewer.Analytics;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.Settings;
|
||||
@@ -40,7 +39,6 @@ import com.hippo.ehviewer.client.EhUrl;
|
||||
import com.hippo.ehviewer.client.EhUtils;
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser;
|
||||
import com.hippo.ehviewer.ui.MainActivity;
|
||||
import com.hippo.ehviewer.widget.RecaptchaView;
|
||||
import com.hippo.scene.Announcer;
|
||||
import com.hippo.scene.SceneFragment;
|
||||
import com.hippo.util.ExceptionUtils;
|
||||
@@ -69,8 +67,6 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
private EditText mUsername;
|
||||
@Nullable
|
||||
private EditText mPassword;
|
||||
private EditText mRecaptcha;
|
||||
private RecaptchaView mRecaptchaView;
|
||||
@Nullable
|
||||
private View mRegister;
|
||||
@Nullable
|
||||
@@ -128,8 +124,6 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
mPasswordLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.password_layout);
|
||||
mPassword = mPasswordLayout.getEditText();
|
||||
AssertUtils.assertNotNull(mPassword);
|
||||
mRecaptcha = (EditText) ViewUtils.$$(loginForm, R.id.recaptcha);
|
||||
mRecaptchaView = (RecaptchaView) ViewUtils.$$(loginForm, R.id.recaptcha_image);
|
||||
mRegister = ViewUtils.$$(loginForm, R.id.register);
|
||||
mSignIn = ViewUtils.$$(loginForm, R.id.sign_in);
|
||||
mSignInViaWebView = (TextView) ViewUtils.$$(loginForm, R.id.sign_in_via_webview);
|
||||
@@ -285,18 +279,14 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
// Clean up for sign in
|
||||
EhUtils.signOut(context);
|
||||
|
||||
String challenge = mRecaptchaView.getChallenge();
|
||||
String response = mRecaptcha.getText().toString();
|
||||
|
||||
EhCallback callback = new SignInListener(context,
|
||||
activity.getStageId(), getTag());
|
||||
mRequestId = ((EhApplication) context.getApplicationContext()).putGlobalStuff(callback);
|
||||
EhRequest request = new EhRequest()
|
||||
.setMethod(EhClient.METHOD_SIGN_IN)
|
||||
.setArgs(username, password, challenge, response)
|
||||
.setArgs(username, password)
|
||||
.setCallback(callback);
|
||||
EhApplication.getEhClient(context).execute(request);
|
||||
Analytics.signIn();
|
||||
|
||||
mSigningIn = true;
|
||||
}
|
||||
@@ -337,7 +327,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
|
||||
|
||||
new AlertDialog.Builder(context)
|
||||
.setTitle(R.string.sign_in_failed)
|
||||
.setMessage(ExceptionUtils.getReadableString(e))
|
||||
.setMessage(ExceptionUtils.getReadableString(e) + "\n\n" + getString(R.string.sign_in_failed_tip))
|
||||
.setPositiveButton(R.string.get_it, null)
|
||||
.show();
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ public class SolidScene extends BaseScene {
|
||||
startScene(new Announcer(clazz).setArgs(targetArgs));
|
||||
} else {
|
||||
Bundle newArgs = new Bundle();
|
||||
newArgs.putString(GalleryListScene.KEY_ACTION, GalleryListScene.ACTION_HOMEPAGE);
|
||||
newArgs.putString(GalleryListScene.KEY_ACTION, Settings.getLaunchPageGalleryListSceneAction());
|
||||
startScene(new Announcer(GalleryListScene.class).setArgs(newArgs));
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -132,23 +132,18 @@ public class WebViewSignInScene extends SolidScene {
|
||||
return;
|
||||
}
|
||||
|
||||
String cookieString = CookieManager.getInstance().getCookie(url);
|
||||
String cookieString = CookieManager.getInstance().getCookie(EhUrl.HOST_E);
|
||||
List<Cookie> cookies = parseCookies(httpUrl, cookieString);
|
||||
boolean getId = false;
|
||||
boolean getHash = false;
|
||||
for (Cookie cookie: cookies) {
|
||||
if (EhCookieStore.KEY_IPD_MEMBER_ID.equals(cookie.name())) {
|
||||
getId = true;
|
||||
addCookie(context, EhUrl.DOMAIN_EX, cookie);
|
||||
addCookie(context, EhUrl.DOMAIN_E, cookie);
|
||||
} else if (EhCookieStore.KEY_IPD_PASS_HASH.equals(cookie.name())) {
|
||||
getHash = true;
|
||||
addCookie(context, EhUrl.DOMAIN_EX, cookie);
|
||||
addCookie(context, EhUrl.DOMAIN_E, cookie);
|
||||
} else if (EhCookieStore.KEY_IGNEOUS.equals(cookie.name())) {
|
||||
addCookie(context, EhUrl.DOMAIN_EX, cookie);
|
||||
addCookie(context, EhUrl.DOMAIN_E, cookie);
|
||||
}
|
||||
addCookie(context, EhUrl.DOMAIN_EX, cookie);
|
||||
addCookie(context, EhUrl.DOMAIN_E, cookie);
|
||||
}
|
||||
|
||||
if (getId && getHash) {
|
||||
|
||||
@@ -21,19 +21,22 @@ import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TableLayout;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.NumberUtils;
|
||||
|
||||
public class AdvanceSearchTable extends TableLayout {
|
||||
public class AdvanceSearchTable extends LinearLayout {
|
||||
|
||||
private static final String STATE_KEY_SUPER = "super";
|
||||
private static final String STATE_KEY_ADVANCE_SEARCH = "advance_search";
|
||||
private static final String STATE_KEY_MIN_RATING = "min_rating";
|
||||
private static final String STATE_KEY_PAGE_FROM = "page_from";
|
||||
private static final String STATE_KEY_PAGE_TO = "page_to";
|
||||
|
||||
public static final int SNAME = 0x1;
|
||||
public static final int STAGS = 0x2;
|
||||
@@ -43,6 +46,9 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
public static final int SDT1 = 0x20;
|
||||
public static final int SDT2 = 0x40;
|
||||
public static final int SH = 0x80;
|
||||
public static final int SFL = 0x100;
|
||||
public static final int SFU = 0x200;
|
||||
public static final int SFT = 0x400;
|
||||
|
||||
private CheckBox mSname;
|
||||
private CheckBox mStags;
|
||||
@@ -54,6 +60,12 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
private CheckBox mSh;
|
||||
private CheckBox mSr;
|
||||
private Spinner mMinRating;
|
||||
private CheckBox mSp;
|
||||
private EditText mSpf;
|
||||
private EditText mSpt;
|
||||
private CheckBox mSfl;
|
||||
private CheckBox mSfu;
|
||||
private CheckBox mSft;
|
||||
|
||||
public AdvanceSearchTable(Context context) {
|
||||
super(context);
|
||||
@@ -66,6 +78,8 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
}
|
||||
|
||||
public void init(Context context) {
|
||||
setOrientation(LinearLayout.VERTICAL);
|
||||
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
inflater.inflate(R.layout.widget_advance_search_table, this);
|
||||
|
||||
@@ -88,6 +102,25 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
ViewGroup row4 = (ViewGroup) getChildAt(4);
|
||||
mSr = (CheckBox) row4.getChildAt(0);
|
||||
mMinRating = (Spinner) row4.getChildAt(1);
|
||||
|
||||
ViewGroup row5 = (ViewGroup) getChildAt(5);
|
||||
mSp = (CheckBox) row5.getChildAt(0);
|
||||
mSpf = (EditText) row5.getChildAt(1);
|
||||
mSpt = (EditText) row5.getChildAt(3);
|
||||
|
||||
ViewGroup row7 = (ViewGroup) getChildAt(7);
|
||||
mSfl = (CheckBox) row7.getChildAt(0);
|
||||
mSfu = (CheckBox) row7.getChildAt(1);
|
||||
mSft = (CheckBox) row7.getChildAt(2);
|
||||
|
||||
// Avoid java.lang.IllegalStateException: focus search returned a view that wasn't able to take focus!
|
||||
mSpt.setOnEditorActionListener((v, actionId, event) -> {
|
||||
View nextView = v.focusSearch(View.FOCUS_DOWN);
|
||||
if (nextView != null) {
|
||||
nextView.requestFocus(View.FOCUS_DOWN);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
public int getAdvanceSearch() {
|
||||
@@ -100,6 +133,9 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
if (mSdt1.isChecked()) advanceSearch |= SDT1;
|
||||
if (mSdt2.isChecked()) advanceSearch |= SDT2;
|
||||
if (mSh.isChecked()) advanceSearch |= SH;
|
||||
if (mSfl.isChecked()) advanceSearch |= SFL;
|
||||
if (mSfu.isChecked()) advanceSearch |= SFU;
|
||||
if (mSft.isChecked()) advanceSearch |= SFT;
|
||||
return advanceSearch;
|
||||
}
|
||||
|
||||
@@ -112,6 +148,20 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public int getPageFrom() {
|
||||
if (mSp.isChecked()) {
|
||||
return NumberUtils.parseIntSafely(mSpf.getText().toString(), -1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public int getPageTo() {
|
||||
if (mSp.isChecked()) {
|
||||
return NumberUtils.parseIntSafely(mSpt.getText().toString(), -1);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public void setAdvanceSearch(int advanceSearch) {
|
||||
mSname.setChecked(NumberUtils.int2boolean(advanceSearch & SNAME));
|
||||
mStags.setChecked(NumberUtils.int2boolean(advanceSearch & STAGS));
|
||||
@@ -121,6 +171,9 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
mSdt1.setChecked(NumberUtils.int2boolean(advanceSearch & SDT1));
|
||||
mSdt2.setChecked(NumberUtils.int2boolean(advanceSearch & SDT2));
|
||||
mSh.setChecked(NumberUtils.int2boolean(advanceSearch & SH));
|
||||
mSfl.setChecked(NumberUtils.int2boolean(advanceSearch & SFL));
|
||||
mSfu.setChecked(NumberUtils.int2boolean(advanceSearch & SFU));
|
||||
mSft.setChecked(NumberUtils.int2boolean(advanceSearch & SFT));
|
||||
}
|
||||
|
||||
public void setMinRating(int minRating) {
|
||||
@@ -132,12 +185,34 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
}
|
||||
}
|
||||
|
||||
public void setPageFrom(int pageFrom) {
|
||||
if (pageFrom > 0) {
|
||||
mSpf.setText(Integer.toString(pageFrom));
|
||||
mSp.setChecked(true);
|
||||
} else {
|
||||
mSp.setChecked(false);
|
||||
mSpf.setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void setPageTo(int pageTo) {
|
||||
if (pageTo > 0) {
|
||||
mSpt.setText(Integer.toString(pageTo));
|
||||
mSp.setChecked(true);
|
||||
} else {
|
||||
mSp.setChecked(false);
|
||||
mSpt.setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Parcelable onSaveInstanceState() {
|
||||
final Bundle state = new Bundle();
|
||||
state.putParcelable(STATE_KEY_SUPER, super.onSaveInstanceState());
|
||||
state.putInt(STATE_KEY_ADVANCE_SEARCH, getAdvanceSearch());
|
||||
state.putInt(STATE_KEY_MIN_RATING, getMinRating());
|
||||
state.putInt(STATE_KEY_PAGE_FROM, getPageFrom());
|
||||
state.putInt(STATE_KEY_PAGE_TO, getPageTo());
|
||||
return state;
|
||||
}
|
||||
|
||||
@@ -148,6 +223,8 @@ public class AdvanceSearchTable extends TableLayout {
|
||||
super.onRestoreInstanceState(savedState.getParcelable(STATE_KEY_SUPER));
|
||||
setAdvanceSearch(savedState.getInt(STATE_KEY_ADVANCE_SEARCH));
|
||||
setMinRating(savedState.getInt(STATE_KEY_MIN_RATING));
|
||||
setPageFrom(savedState.getInt(STATE_KEY_PAGE_FROM));
|
||||
setPageTo(savedState.getInt(STATE_KEY_PAGE_TO));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,205 @@
|
||||
/*
|
||||
* 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.graphics.Rect;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.DisplayCutout;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.annotation.RequiresApi;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.ObjectUtils;
|
||||
|
||||
public class GalleryHeader extends ViewGroup {
|
||||
|
||||
private DisplayCutout displayCutout;
|
||||
|
||||
private View battery;
|
||||
private View progress;
|
||||
private View clock;
|
||||
|
||||
private Rect batteryRect = new Rect();
|
||||
private Rect progressRect = new Rect();
|
||||
private Rect clockRect = new Rect();
|
||||
|
||||
private int[] location = new int[2];
|
||||
|
||||
private int lastX = 0;
|
||||
private int lastY = 0;
|
||||
|
||||
public GalleryHeader(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
public void setDisplayCutout(@Nullable DisplayCutout displayCutout) {
|
||||
if (!ObjectUtils.equal(this.displayCutout, displayCutout)) {
|
||||
this.displayCutout = displayCutout;
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onFinishInflate() {
|
||||
super.onFinishInflate();
|
||||
|
||||
battery = findViewById(R.id.battery);
|
||||
progress = findViewById(R.id.progress);
|
||||
clock = findViewById(R.id.clock);
|
||||
}
|
||||
|
||||
private void measureChild(Rect rect, View view, int width, int paddingLeft, int paddingRight) {
|
||||
int left;
|
||||
MarginLayoutParams lp = (MarginLayoutParams) view.getLayoutParams();
|
||||
if (view == battery) {
|
||||
left = paddingLeft + lp.leftMargin;
|
||||
} else if (view == progress) {
|
||||
left = paddingLeft + (width - paddingLeft - paddingRight) / 2 - view.getMeasuredWidth() / 2;
|
||||
} else {
|
||||
left = width - paddingRight - lp.rightMargin - view.getMeasuredWidth();
|
||||
}
|
||||
rect.set(left, lp.topMargin, left + view.getMeasuredWidth(), lp.topMargin + view.getMeasuredHeight());
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private boolean offsetVertically(Rect rect, View view, int width) {
|
||||
int offset = 0;
|
||||
|
||||
measureChild(rect, view, width, 0, 0);
|
||||
rect.offset(lastX, lastY);
|
||||
|
||||
for (Rect notch : displayCutout.getBoundingRects()) {
|
||||
if (Rect.intersects(notch, rect)) {
|
||||
offset = Math.max(offset, notch.bottom - lastY);
|
||||
}
|
||||
}
|
||||
|
||||
if (offset != 0) {
|
||||
rect.offset(-lastX, -lastY);
|
||||
rect.offset(0, offset);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private int getOffsetLeft(Rect rect, View view, int width) {
|
||||
int offset = 0;
|
||||
|
||||
measureChild(rect, view, width, 0, 0);
|
||||
rect.offset(lastX, lastY);
|
||||
|
||||
for (Rect notch : displayCutout.getBoundingRects()) {
|
||||
if (Rect.intersects(notch, rect)) {
|
||||
offset = Math.max(offset, notch.right - lastX);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
@RequiresApi(api = Build.VERSION_CODES.P)
|
||||
private int getOffsetRight(Rect rect, View view, int width) {
|
||||
int offset = 0;
|
||||
|
||||
measureChild(rect, view, width, 0, 0);
|
||||
rect.offset(lastX, lastY);
|
||||
|
||||
for (Rect notch : displayCutout.getBoundingRects()) {
|
||||
if (Rect.intersects(notch, rect)) {
|
||||
offset = Math.max(offset, lastX + width - notch.left);
|
||||
}
|
||||
}
|
||||
|
||||
return offset;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
if (MeasureSpec.getMode(widthMeasureSpec) != MeasureSpec.EXACTLY) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
int width = MeasureSpec.getSize(widthMeasureSpec);
|
||||
|
||||
int height = 0;
|
||||
for (int i = 0; i < getChildCount(); i++) {
|
||||
View child = getChildAt(i);
|
||||
measureChild(child, widthMeasureSpec, heightMeasureSpec);
|
||||
MarginLayoutParams lp = (MarginLayoutParams) child.getLayoutParams();
|
||||
height = Math.max(height, child.getMeasuredHeight() + lp.topMargin);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P && displayCutout != null) {
|
||||
// Check progress covered
|
||||
if (offsetVertically(progressRect, progress, width)) {
|
||||
offsetVertically(batteryRect, battery, width);
|
||||
offsetVertically(clockRect, clock, width);
|
||||
height = Math.max(progressRect.bottom, Math.max(batteryRect.bottom, clockRect.bottom));
|
||||
} else {
|
||||
// Clamp left and right
|
||||
int paddingLeft = getOffsetLeft(batteryRect, battery, width);
|
||||
int paddingRight = getOffsetRight(clockRect, clock, width);
|
||||
measureChild(batteryRect, battery, width, paddingLeft, paddingRight);
|
||||
measureChild(progressRect, progress, width, paddingLeft, paddingRight);
|
||||
measureChild(clockRect, clock, width, paddingLeft, paddingRight);
|
||||
}
|
||||
} else {
|
||||
measureChild(batteryRect, battery, width, 0, 0);
|
||||
measureChild(progressRect, progress, width, 0, 0);
|
||||
measureChild(clockRect, clock, width, 0, 0);
|
||||
}
|
||||
|
||||
setMeasuredDimension(width, height);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onLayout(boolean changed, int l, int t, int r, int b) {
|
||||
battery.layout(batteryRect.left, batteryRect.top, batteryRect.right, batteryRect.bottom);
|
||||
progress.layout(progressRect.left, progressRect.top, progressRect.right, progressRect.bottom);
|
||||
clock.layout(clockRect.left, clockRect.top, clockRect.right, clockRect.bottom);
|
||||
|
||||
getLocationOnScreen(location);
|
||||
if (lastX != location[0] || lastY != location[1]) {
|
||||
lastX = location[0];
|
||||
lastY = location[1];
|
||||
requestLayout();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public MarginLayoutParams generateLayoutParams(AttributeSet attrs) {
|
||||
return new MarginLayoutParams(getContext(), attrs);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean checkLayoutParams(ViewGroup.LayoutParams p) {
|
||||
return p instanceof MarginLayoutParams;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MarginLayoutParams generateLayoutParams(ViewGroup.LayoutParams lp) {
|
||||
if (lp instanceof MarginLayoutParams) {
|
||||
return new MarginLayoutParams((MarginLayoutParams) lp);
|
||||
}
|
||||
return new MarginLayoutParams(lp);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* 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.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import com.hippo.ehviewer.EhApplication;
|
||||
import com.hippo.ehviewer.FavouriteStatusRouter;
|
||||
import com.hippo.ehviewer.client.data.GalleryInfo;
|
||||
import com.hippo.widget.ContentLayout;
|
||||
import com.hippo.yorozuya.IntIdGenerator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public abstract class GalleryInfoContentHelper extends ContentLayout.ContentHelper<GalleryInfo> {
|
||||
|
||||
private static final String KEY_DATA_MAP = "data_map";
|
||||
|
||||
@SuppressLint("UseSparseArrays")
|
||||
private Map<Long, GalleryInfo> map = new HashMap<>();
|
||||
private FavouriteStatusRouter.Listener listener;
|
||||
|
||||
public GalleryInfoContentHelper() {
|
||||
listener = (gid, slot) -> {
|
||||
GalleryInfo info = map.get(gid);
|
||||
if (info != null) {
|
||||
info.favoriteSlot = slot;
|
||||
}
|
||||
};
|
||||
EhApplication.getFavouriteStatusRouter().addListener(listener);
|
||||
}
|
||||
|
||||
public void destroy() {
|
||||
EhApplication.getFavouriteStatusRouter().removeListener(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAddData(GalleryInfo data) {
|
||||
map.put(data.gid, data);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onAddData(List<GalleryInfo> data) {
|
||||
for (GalleryInfo info : data) {
|
||||
map.put(info.gid, info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemoveData(GalleryInfo data) {
|
||||
map.remove(data.gid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRemoveData(List<GalleryInfo> data) {
|
||||
for (GalleryInfo info : data) {
|
||||
map.remove(info.gid);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onClearData() {
|
||||
map.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable saveInstanceState(Parcelable superState) {
|
||||
Bundle bundle = (Bundle) super.saveInstanceState(superState);
|
||||
|
||||
// TODO It's a bad design
|
||||
FavouriteStatusRouter router = EhApplication.getFavouriteStatusRouter();
|
||||
int id = router.saveDataMap(map);
|
||||
bundle.putInt(KEY_DATA_MAP, id);
|
||||
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable restoreInstanceState(Parcelable state) {
|
||||
Bundle bundle = (Bundle) state;
|
||||
|
||||
int id = bundle.getInt(KEY_DATA_MAP, IntIdGenerator.INVALID_ID);
|
||||
if (id != IntIdGenerator.INVALID_ID) {
|
||||
FavouriteStatusRouter router = EhApplication.getFavouriteStatusRouter();
|
||||
Map<Long, GalleryInfo> map = router.restoreDataMap(id);
|
||||
if (map != null) {
|
||||
this.map = map;
|
||||
}
|
||||
}
|
||||
|
||||
return super.restoreInstanceState(state);
|
||||
}
|
||||
}
|
||||
@@ -1,183 +0,0 @@
|
||||
/*
|
||||
* Copyright 2017 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;
|
||||
|
||||
/*
|
||||
* Created by Hippo on 2017/8/20.
|
||||
*/
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import androidx.annotation.NonNull;
|
||||
import com.hippo.android.recaptcha.RecaptchaV1;
|
||||
import com.hippo.drawable.TextDrawable;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.widget.LoadImageView;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
|
||||
public class RecaptchaView extends LoadImageView implements RecaptchaV1.RecaptchaCallback, View.OnClickListener {
|
||||
|
||||
private static final String CHALLENGE = "6LdtfgYAAAAAALjIPPiCgPJJah8MhAUpnHcKF8u_";
|
||||
|
||||
private boolean loading = false;
|
||||
private String challenge;
|
||||
private String image;
|
||||
|
||||
private TextDrawable waitingDrawable;
|
||||
private TextDrawable loadingDrawable;
|
||||
private TextDrawable failureDrawable;
|
||||
|
||||
public RecaptchaView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public RecaptchaView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
private void init() {
|
||||
setOnClickListener(this);
|
||||
if (waitingDrawable == null) {
|
||||
waitingDrawable = new TextDrawable(getContext().getString(R.string.recaptcha_none), 0.6f);
|
||||
waitingDrawable.setBackgroundColor(Color.GRAY);
|
||||
waitingDrawable.setTextColor(Color.WHITE);
|
||||
}
|
||||
load(waitingDrawable);
|
||||
}
|
||||
|
||||
public String getChallenge() {
|
||||
return challenge;
|
||||
}
|
||||
|
||||
public void load() {
|
||||
if (loading) {
|
||||
return;
|
||||
}
|
||||
loading = false;
|
||||
challenge = null;
|
||||
image = null;
|
||||
|
||||
if (loadingDrawable == null) {
|
||||
loadingDrawable = new TextDrawable(getContext().getString(R.string.recaptcha_loading), 0.6f);
|
||||
loadingDrawable.setBackgroundColor(Color.GRAY);
|
||||
loadingDrawable.setTextColor(Color.WHITE);
|
||||
}
|
||||
load(loadingDrawable);
|
||||
|
||||
RecaptchaV1.recaptcha(getContext(), CHALLENGE, SimpleHandler.getInstance(), this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(@NonNull View v) {
|
||||
load();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(@NonNull String challenge, @NonNull String image) {
|
||||
this.loading = false;
|
||||
this.challenge = challenge;
|
||||
this.image = image;
|
||||
|
||||
load(image, image);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure() {
|
||||
this.loading = false;
|
||||
this.challenge = null;
|
||||
this.image = null;
|
||||
|
||||
if (failureDrawable == null) {
|
||||
failureDrawable = new TextDrawable(getContext().getString(R.string.recaptcha_failure), 0.6f);
|
||||
failureDrawable.setBackgroundColor(Color.GRAY);
|
||||
failureDrawable.setTextColor(Color.WHITE);
|
||||
}
|
||||
load(failureDrawable);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
SavedState ss = new SavedState(super.onSaveInstanceState());
|
||||
ss.loading = loading;
|
||||
ss.challenge = challenge;
|
||||
ss.image = image;
|
||||
return ss;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (!(state instanceof SavedState)) {
|
||||
super.onRestoreInstanceState(state);
|
||||
return;
|
||||
}
|
||||
|
||||
SavedState ss = (SavedState) state;
|
||||
super.onRestoreInstanceState(ss.getSuperState());
|
||||
|
||||
if (ss.loading) {
|
||||
load();
|
||||
} else if (!TextUtils.isEmpty(ss.challenge) && !TextUtils.isEmpty(ss.image)) {
|
||||
onSuccess(ss.challenge, ss.image);
|
||||
}
|
||||
}
|
||||
|
||||
private static class SavedState extends BaseSavedState {
|
||||
|
||||
private boolean loading;
|
||||
private String challenge;
|
||||
private String image;
|
||||
|
||||
public SavedState(Parcelable superState) {
|
||||
super(superState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeByte(loading ? (byte) 1 : (byte) 0);
|
||||
out.writeString(challenge);
|
||||
out.writeString(image);
|
||||
}
|
||||
|
||||
public static final Parcelable.Creator<SavedState> CREATOR
|
||||
= new Parcelable.Creator<SavedState>() {
|
||||
@Override
|
||||
public SavedState createFromParcel(Parcel in) {
|
||||
return new SavedState(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SavedState[] newArray(int size) {
|
||||
return new SavedState[size];
|
||||
}
|
||||
};
|
||||
|
||||
public SavedState(Parcel source) {
|
||||
super(source);
|
||||
loading = source.readByte() != 0;
|
||||
challenge = source.readString();
|
||||
image = source.readString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -168,6 +168,10 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
mImageView.setImageUri(imageUri);
|
||||
}
|
||||
|
||||
public void setNormalSearchMode(int id) {
|
||||
mNormalSearchMode.check(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSelectImage() {
|
||||
if (mHelper != null) {
|
||||
@@ -243,6 +247,9 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
case R.id.search_normal_search:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_NORMAL);
|
||||
break;
|
||||
case R.id.search_subscription_search:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_SUBSCRIPTION);
|
||||
break;
|
||||
case R.id.search_specify_uploader:
|
||||
urlBuilder.setMode(ListUrlBuilder.MODE_UPLOADER);
|
||||
break;
|
||||
@@ -255,6 +262,8 @@ public class SearchLayout extends EasyRecyclerView implements CompoundButton.OnC
|
||||
if (mEnableAdvance) {
|
||||
urlBuilder.setAdvanceSearch(mTableAdvanceSearch.getAdvanceSearch());
|
||||
urlBuilder.setMinRating(mTableAdvanceSearch.getMinRating());
|
||||
urlBuilder.setPageFrom(mTableAdvanceSearch.getPageFrom());
|
||||
urlBuilder.setPageTo(mTableAdvanceSearch.getPageTo());
|
||||
}
|
||||
break;
|
||||
case SEARCH_MODE_IMAGE:
|
||||
|
||||
@@ -85,6 +85,19 @@ public class CookieRepository implements CookieJar {
|
||||
}
|
||||
}
|
||||
|
||||
public String getCookieHeader(HttpUrl url) {
|
||||
List<Cookie> cookies = getCookies(url);
|
||||
StringBuilder cookieHeader = new StringBuilder();
|
||||
for (int i = 0, size = cookies.size(); i < size; i++) {
|
||||
if (i > 0) {
|
||||
cookieHeader.append("; ");
|
||||
}
|
||||
Cookie cookie = cookies.get(i);
|
||||
cookieHeader.append(cookie.name()).append('=').append(cookie.value());
|
||||
}
|
||||
return cookieHeader.toString();
|
||||
}
|
||||
|
||||
public synchronized List<Cookie> getCookies(HttpUrl url) {
|
||||
List<Cookie> accepted = new ArrayList<>();
|
||||
List<Cookie> expired = new ArrayList<>();
|
||||
|
||||
+6
-4
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016 Hippo Seven
|
||||
* 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.
|
||||
@@ -16,9 +16,11 @@
|
||||
|
||||
package com.hippo.util;
|
||||
|
||||
import android.os.Build;
|
||||
public class MutableBoolean {
|
||||
|
||||
public final class ApiHelper {
|
||||
public boolean value;
|
||||
|
||||
public static final boolean SUPPORT_TRANSITION = Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
|
||||
public MutableBoolean(boolean value) {
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -16,17 +16,16 @@
|
||||
|
||||
package com.hippo.util;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.content.res.Resources;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
|
||||
@SuppressLint("SimpleDateFormat")
|
||||
public final class ReadableTime {
|
||||
|
||||
private static Resources sResources;
|
||||
@@ -56,30 +55,21 @@ public final class ReadableTime {
|
||||
R.plurals.second
|
||||
};
|
||||
|
||||
private static final Calendar sCalendar = Calendar.getInstance(TimeZone.getTimeZone("GMT+08:00"));
|
||||
private static final Calendar sCalendar = Calendar.getInstance();
|
||||
private static final Object sCalendarLock = new Object();
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT_WITHOUT_YEAR =
|
||||
new SimpleDateFormat("MMM d", Locale.getDefault());
|
||||
private static final SimpleDateFormat DATE_FORMAT_WITHOUT_YEAR = new SimpleDateFormat("MMM d");
|
||||
private static final SimpleDateFormat DATE_FORMAT_WITH_YEAR = new SimpleDateFormat("MMM d, yyyy");
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT_WIT_YEAR =
|
||||
new SimpleDateFormat("yyy MMM d", Locale.getDefault());
|
||||
private static final SimpleDateFormat DATE_FORMAT_WITHOUT_YEAR_ZH = new SimpleDateFormat("M月d日");
|
||||
private static final SimpleDateFormat DATE_FORMAT_WITH_YEAR_ZH = new SimpleDateFormat("yyyy年M月d日");
|
||||
|
||||
private static final SimpleDateFormat DATE_FORMAT =
|
||||
new SimpleDateFormat("yy-MM-dd HH:mm", Locale.getDefault());
|
||||
private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yy-MM-dd HH:mm");
|
||||
private static final Object sDateFormatLock1 = new Object();
|
||||
|
||||
private static final SimpleDateFormat FILENAMABLE_DATE_FORMAT =
|
||||
new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS", Locale.getDefault());
|
||||
private static final SimpleDateFormat FILENAMABLE_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd-HH-mm-ss-SSS");
|
||||
private static final Object sDateFormatLock2 = new Object();
|
||||
|
||||
static {
|
||||
// The website use GMT+08:00, so tell user the same
|
||||
DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("GMT+08:00"));
|
||||
|
||||
DATE_FORMAT_WITHOUT_YEAR.setTimeZone(TimeZone.getTimeZone("GMT+08:00"));
|
||||
}
|
||||
|
||||
public static void initialize(Context context) {
|
||||
sResources = context.getApplicationContext().getResources();
|
||||
}
|
||||
@@ -134,11 +124,12 @@ public final class ReadableTime {
|
||||
int nowYear = sCalendar.get(Calendar.YEAR);
|
||||
sCalendar.setTime(timeDate);
|
||||
int timeYear = sCalendar.get(Calendar.YEAR);
|
||||
boolean isZh = Locale.getDefault().getLanguage().equals("zh");
|
||||
|
||||
if (nowYear == timeYear) {
|
||||
return DATE_FORMAT_WITHOUT_YEAR.format(timeDate);
|
||||
return (isZh ? DATE_FORMAT_WITHOUT_YEAR_ZH : DATE_FORMAT_WITHOUT_YEAR).format(timeDate);
|
||||
} else {
|
||||
return DATE_FORMAT_WIT_YEAR.format(timeDate);
|
||||
return (isZh ? DATE_FORMAT_WITH_YEAR_ZH : DATE_FORMAT_WITH_YEAR).format(timeDate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ import com.hippo.yorozuya.IntIdGenerator;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
import com.hippo.yorozuya.collect.IntList;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public class ContentLayout extends FrameLayout {
|
||||
@@ -167,6 +169,8 @@ public class ContentLayout extends FrameLayout {
|
||||
|
||||
private static final String TAG = ContentHelper.class.getSimpleName();
|
||||
|
||||
private static final int CHECK_DUPLICATE_RANGE = 50;
|
||||
|
||||
private static final String KEY_SUPER = "super";
|
||||
private static final String KEY_SHOWN_VIEW = "shown_view";
|
||||
private static final String KEY_TIP = "tip";
|
||||
@@ -232,6 +236,8 @@ public class ContentLayout extends FrameLayout {
|
||||
*/
|
||||
private int mPages;
|
||||
|
||||
private int mNextPage;
|
||||
|
||||
private int mCurrentTaskId;
|
||||
private int mCurrentTaskType;
|
||||
private int mCurrentTaskPage;
|
||||
@@ -268,6 +274,13 @@ public class ContentLayout extends FrameLayout {
|
||||
public void onFooterRefresh() {
|
||||
if (mEndPage < mPages) {
|
||||
// Get next page
|
||||
// Fill pages before NextPage with empty list
|
||||
while (mNextPage > mEndPage && mEndPage < mPages) {
|
||||
mCurrentTaskId = mIdGenerator.nextId();
|
||||
mCurrentTaskType = TYPE_NEXT_PAGE_KEEP_POS;
|
||||
mCurrentTaskPage = mEndPage;
|
||||
onGetPageData(mCurrentTaskId, mPages, mNextPage, Collections.emptyList());
|
||||
}
|
||||
mCurrentTaskId = mIdGenerator.nextId();
|
||||
mCurrentTaskType = TYPE_NEXT_PAGE_KEEP_POS;
|
||||
mCurrentTaskPage = mEndPage;
|
||||
@@ -280,6 +293,7 @@ public class ContentLayout extends FrameLayout {
|
||||
getPageData(mCurrentTaskId, mCurrentTaskType, mCurrentTaskPage);
|
||||
} else {
|
||||
Log.e(TAG, "Try to footer refresh, but mEndPage = " + mEndPage + ", mPages = " + mPages);
|
||||
mRefreshLayout.setFooterRefreshing(false);
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -321,7 +335,7 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
/**
|
||||
* Call {@link #onGetPageData(int, List)} when get data
|
||||
* Call {@link #onGetPageData(int, int, int, List)} when get data
|
||||
*
|
||||
* @param taskId task id
|
||||
* @param page the page to get
|
||||
@@ -386,19 +400,13 @@ public class ContentLayout extends FrameLayout {
|
||||
return mCurrentTaskId == taskId;
|
||||
}
|
||||
|
||||
public void setPages(int taskId, int pages) {
|
||||
// TODO what it pages > mEndPage
|
||||
if (mCurrentTaskId == taskId) {
|
||||
mPages = pages;
|
||||
}
|
||||
}
|
||||
|
||||
public int getPages() {
|
||||
return mPages;
|
||||
}
|
||||
|
||||
public void addAt(int index, E data) {
|
||||
mData.add(index, data);
|
||||
onAddData(data);
|
||||
|
||||
for (int i = 0, n = mPageDivider.size(); i < n; i++) {
|
||||
int divider = mPageDivider.get(i);
|
||||
@@ -411,7 +419,8 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
public void removeAt(int index) {
|
||||
mData.remove(index);
|
||||
E data = mData.remove(index);
|
||||
onRemoveData(data);
|
||||
|
||||
for (int i = 0, n = mPageDivider.size(); i < n; i++) {
|
||||
int divider = mPageDivider.get(i);
|
||||
@@ -423,7 +432,33 @@ public class ContentLayout extends FrameLayout {
|
||||
notifyItemRangeRemoved(index, 1);
|
||||
}
|
||||
|
||||
public void onGetPageData(int taskId, List<E> data) {
|
||||
protected abstract boolean isDuplicate(E d1, E d2);
|
||||
|
||||
private void removeDuplicateData(List<E> data, int start, int end) {
|
||||
start = Math.max(0, start);
|
||||
end = Math.min(mData.size(), end);
|
||||
for (Iterator<E> iterator = data.iterator(); iterator.hasNext();) {
|
||||
E d = iterator.next();
|
||||
for (int i = start; i < end; i++) {
|
||||
if (isDuplicate(d, mData.get(i))) {
|
||||
iterator.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void onAddData(E data) { }
|
||||
|
||||
protected void onAddData(List<E> data) { }
|
||||
|
||||
protected void onRemoveData(E data) { }
|
||||
|
||||
protected void onRemoveData(List<E> data) { }
|
||||
|
||||
protected void onClearData() { }
|
||||
|
||||
public void onGetPageData(int taskId, int pages, int nextPage, List<E> data) {
|
||||
if (mCurrentTaskId == taskId) {
|
||||
int dataSize;
|
||||
|
||||
@@ -431,11 +466,14 @@ public class ContentLayout extends FrameLayout {
|
||||
case TYPE_REFRESH:
|
||||
mStartPage = 0;
|
||||
mEndPage = 1;
|
||||
mPages = pages;
|
||||
mNextPage = nextPage;
|
||||
mPageDivider.clear();
|
||||
mPageDivider.add(data.size());
|
||||
|
||||
if (data.isEmpty()) {
|
||||
mData.clear();
|
||||
onClearData();
|
||||
notifyDataSetChanged();
|
||||
|
||||
if (true || mEndPage >= mPages) { // Not found
|
||||
@@ -457,7 +495,9 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
} else {
|
||||
mData.clear();
|
||||
onClearData();
|
||||
mData.addAll(data);
|
||||
onAddData(data);
|
||||
notifyDataSetChanged();
|
||||
|
||||
// Ui change, show content
|
||||
@@ -475,12 +515,14 @@ public class ContentLayout extends FrameLayout {
|
||||
break;
|
||||
case TYPE_PRE_PAGE:
|
||||
case TYPE_PRE_PAGE_KEEP_POS:
|
||||
removeDuplicateData(data, 0, CHECK_DUPLICATE_RANGE);
|
||||
dataSize = data.size();
|
||||
for (int i = 0, n = mPageDivider.size(); i < n; i++) {
|
||||
mPageDivider.set(i, mPageDivider.get(i) + dataSize);
|
||||
}
|
||||
mPageDivider.add(0, dataSize);
|
||||
mStartPage--;
|
||||
mPages = Math.max(mEndPage, pages);
|
||||
// assert mStartPage >= 0
|
||||
|
||||
if (data.isEmpty()) {
|
||||
@@ -514,6 +556,7 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
} else {
|
||||
mData.addAll(0, data);
|
||||
onAddData(data);
|
||||
notifyItemRangeInserted(0, data.size());
|
||||
|
||||
// Ui change, show content
|
||||
@@ -537,10 +580,13 @@ public class ContentLayout extends FrameLayout {
|
||||
break;
|
||||
case TYPE_NEXT_PAGE:
|
||||
case TYPE_NEXT_PAGE_KEEP_POS:
|
||||
removeDuplicateData(data, mData.size() - CHECK_DUPLICATE_RANGE, mData.size());
|
||||
dataSize = data.size();
|
||||
int oldDataSize = mData.size();
|
||||
mPageDivider.add(oldDataSize + dataSize);
|
||||
mEndPage++;
|
||||
mNextPage = nextPage;
|
||||
mPages = Math.max(mEndPage, pages);
|
||||
|
||||
if (data.isEmpty()) {
|
||||
if (true || mEndPage >= mPages) { // OK, that's all
|
||||
@@ -573,6 +619,7 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
} else {
|
||||
mData.addAll(data);
|
||||
onAddData(data);
|
||||
notifyItemRangeInserted(oldDataSize, dataSize);
|
||||
|
||||
// Ui change, show content
|
||||
@@ -595,11 +642,14 @@ public class ContentLayout extends FrameLayout {
|
||||
case TYPE_SOMEWHERE:
|
||||
mStartPage = mCurrentTaskPage;
|
||||
mEndPage = mCurrentTaskPage + 1;
|
||||
mNextPage = nextPage;
|
||||
mPages = pages;
|
||||
mPageDivider.clear();
|
||||
mPageDivider.add(data.size());
|
||||
|
||||
if (data.isEmpty()) {
|
||||
mData.clear();
|
||||
onClearData();
|
||||
notifyDataSetChanged();
|
||||
|
||||
if (true || mEndPage >= mPages) { // Not found
|
||||
@@ -621,7 +671,9 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
} else {
|
||||
mData.clear();
|
||||
onClearData();
|
||||
mData.addAll(data);
|
||||
onAddData(data);
|
||||
notifyDataSetChanged();
|
||||
|
||||
// Ui change, show content
|
||||
@@ -644,12 +696,22 @@ public class ContentLayout extends FrameLayout {
|
||||
break;
|
||||
}
|
||||
|
||||
if (mCurrentTaskPage == mEndPage - 1) {
|
||||
mNextPage = nextPage;
|
||||
}
|
||||
|
||||
mPages = Math.max(mEndPage, pages);
|
||||
|
||||
int oldIndexStart = mCurrentTaskPage == mStartPage ? 0 : mPageDivider.get(mCurrentTaskPage - mStartPage - 1);
|
||||
int oldIndexEnd = mPageDivider.get(mCurrentTaskPage - mStartPage);
|
||||
mData.subList(oldIndexStart, oldIndexEnd).clear();
|
||||
List<E> toRemove = mData.subList(oldIndexStart, oldIndexEnd);
|
||||
onRemoveData(toRemove);
|
||||
toRemove.clear();
|
||||
removeDuplicateData(data, oldIndexStart - CHECK_DUPLICATE_RANGE, oldIndexStart + CHECK_DUPLICATE_RANGE);
|
||||
int newIndexStart = oldIndexStart;
|
||||
int newIndexEnd = newIndexStart + data.size();
|
||||
mData.addAll(oldIndexStart, data);
|
||||
onAddData(data);
|
||||
notifyDataSetChanged();
|
||||
|
||||
for (int i = mCurrentTaskPage - mStartPage, n = mPageDivider.size(); i < n; i++) {
|
||||
@@ -717,7 +779,7 @@ public class ContentLayout extends FrameLayout {
|
||||
}
|
||||
|
||||
public void showText(CharSequence text) {
|
||||
mTipView.setText(text + "\n\n" + getContext().getString(R.string.help_route));
|
||||
mTipView.setText(text);
|
||||
mViewTransition.showView(2);
|
||||
}
|
||||
|
||||
@@ -867,7 +929,7 @@ public class ContentLayout extends FrameLayout {
|
||||
|
||||
private int mSavedDataId = IntIdGenerator.INVALID_ID;
|
||||
|
||||
private Parcelable saveInstanceState(Parcelable superState) {
|
||||
protected Parcelable saveInstanceState(Parcelable superState) {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable(KEY_SUPER, superState);
|
||||
int shownView = mViewTransition.getShownViewIndex();
|
||||
@@ -891,7 +953,7 @@ public class ContentLayout extends FrameLayout {
|
||||
return bundle;
|
||||
}
|
||||
|
||||
private Parcelable restoreInstanceState(Parcelable state) {
|
||||
protected Parcelable restoreInstanceState(Parcelable state) {
|
||||
if (state instanceof Bundle) {
|
||||
Bundle bundle = (Bundle) state;
|
||||
mViewTransition.showView(bundle.getInt(KEY_SHOWN_VIEW), false);
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package com.hippo.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Color;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.os.Environment;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -76,7 +78,7 @@ public class DirExplorer extends EasyRecyclerView implements EasyRecyclerView.On
|
||||
LayoutUtils.dp2pix(context, 1));
|
||||
decoration.setShowLastDivider(true);
|
||||
addItemDecoration(decoration);
|
||||
setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme)));
|
||||
setSelector(Ripple.generateRippleDrawable(context, !AttrResources.getAttrBoolean(context, R.attr.isLightTheme), new ColorDrawable(Color.TRANSPARENT)));
|
||||
setOnItemClickListener(this);
|
||||
|
||||
mCurrentFile = Environment.getExternalStorageDirectory();
|
||||
|
||||
@@ -105,6 +105,19 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
|
||||
return (FloatingActionButton) getChildAt(index);
|
||||
}
|
||||
|
||||
public void setSecondaryFabVisibilityAt(int index, boolean visible) {
|
||||
View fab = getSecondaryFabAt(index);
|
||||
if (fab != null) {
|
||||
if (visible && fab.getVisibility() == View.GONE) {
|
||||
fab.animate().cancel();
|
||||
fab.setVisibility(mExpanded ? View.VISIBLE : View.INVISIBLE);
|
||||
} else if (!visible && fab.getVisibility() != View.GONE) {
|
||||
fab.animate().cancel();
|
||||
fab.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
AssertUtils.assertEquals("Measure mode must be MeasureSpec.EXACTLY",
|
||||
@@ -230,6 +243,9 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
|
||||
int checkCount = mHidePrimaryFab ? count : count - 1;
|
||||
for (int i = 0; i < checkCount; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
child.setVisibility(expanded ? View.VISIBLE : View.INVISIBLE);
|
||||
if (expanded) {
|
||||
child.setAlpha(1f);
|
||||
@@ -242,6 +258,9 @@ public class FabLayout extends ViewGroup implements View.OnClickListener {
|
||||
|
||||
for (int i = 0; i < count - 1; i++) {
|
||||
View child = getChildAt(i);
|
||||
if (child.getVisibility() == GONE) {
|
||||
continue;
|
||||
}
|
||||
setSecondaryFabAnimation(child, expanded, expanded);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<shape
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shape="rectangle">
|
||||
|
||||
<size
|
||||
android:width="6dp"
|
||||
android:height="6dp"/>
|
||||
|
||||
<solid android:color="@android:color/transparent"/>
|
||||
|
||||
</shape>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/drawableColorPrimary"
|
||||
android:pathData="@string/pd_copy"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="16dp"
|
||||
android:width="16dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?android:attr/textColorSecondary"
|
||||
android:pathData="@string/pd_download"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/drawableColorPrimary"
|
||||
android:pathData="@string/pd_download"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@android:color/black"
|
||||
android:pathData="@string/pd_eh_subscription"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/drawableColorPrimary"
|
||||
android:pathData="@string/pd_heart_broken"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="16dp"
|
||||
android:width="16dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?android:attr/textColorSecondary"
|
||||
android:pathData="@string/pd_heart"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="?attr/drawableColorPrimary"
|
||||
android:pathData="@string/pd_heart"/>
|
||||
|
||||
</vector>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:height="24dp"
|
||||
android:width="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
android:fillColor="@color/primary_drawable_dark"
|
||||
android:pathData="@string/pd_pencil"/>
|
||||
|
||||
</vector>
|
||||
@@ -38,13 +38,27 @@
|
||||
android:layout_height="0dp"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@android:string/ok"
|
||||
android:textColor="?attr/colorPrimary"/>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/preset"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:text="@string/preset"
|
||||
android:textColor="?attr/colorAccent"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/ok"
|
||||
style="?attr/buttonBarButtonStyle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:text="@android:string/ok"
|
||||
android:textColor="?attr/colorPrimary"/>
|
||||
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
@@ -26,34 +26,42 @@
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<com.hippo.widget.TextClock
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="wrap_content"
|
||||
<com.hippo.ehviewer.widget.GalleryHeader
|
||||
android:id="@+id/gallery_header"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:layout_marginRight="@dimen/gallery_widget_margin_h"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
android:layout_gravity="top">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
<com.hippo.widget.TextClock
|
||||
android:id="@+id/clock"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:layout_marginRight="@dimen/gallery_widget_margin_h"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
<com.hippo.widget.BatteryView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/battery"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:layout_marginLeft="@dimen/gallery_widget_margin_h"
|
||||
android:drawablePadding="4dp"
|
||||
app:color="?android:attr/textColorSecondary"
|
||||
app:warningColor="@color/red_500"/>
|
||||
<TextView
|
||||
android:id="@+id/progress"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:textColor="?android:attr/textColorSecondary"/>
|
||||
|
||||
<com.hippo.widget.BatteryView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/battery"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left"
|
||||
android:layout_marginTop="@dimen/gallery_widget_margin_v"
|
||||
android:layout_marginLeft="@dimen/gallery_widget_margin_h"
|
||||
android:drawablePadding="4dp"
|
||||
app:color="?android:attr/textColorSecondary"
|
||||
app:warningColor="@color/red_500"/>
|
||||
|
||||
</com.hippo.ehviewer.widget.GalleryHeader>
|
||||
|
||||
<com.hippo.ehviewer.widget.SeekBarPanel
|
||||
android:id="@+id/seek_bar_panel"
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2018 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.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:animateLayoutChanges="true">
|
||||
|
||||
<WebView
|
||||
android:id="@+id/webview"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"/>
|
||||
|
||||
<com.hippo.widget.ProgressView
|
||||
android:id="@+id/progress"
|
||||
style="@style/ProgressView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:visibility="gone"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,34 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2014 The Android Open Source Project
|
||||
|
||||
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.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This layout file is used by the AlertDialog when displaying a list of items.
|
||||
This layout file is inflated and used as the TextView to display individual
|
||||
items.
|
||||
-->
|
||||
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:id="@android:id/text1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="?android:attr/listPreferredItemHeightSmall"
|
||||
android:textAppearance="?android:attr/textAppearanceListItemSmall"
|
||||
android:textColor="?android:attr/textColorAlertDialogListItem"
|
||||
android:gravity="center_vertical"
|
||||
android:paddingLeft="?attr/listPreferredItemPaddingLeft"
|
||||
android:paddingRight="?attr/listPreferredItemPaddingRight"
|
||||
android:drawablePadding="@dimen/keyline_margin"
|
||||
android:ellipsize="marquee"/>
|
||||
@@ -45,7 +45,6 @@
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical">
|
||||
|
||||
@@ -33,10 +33,12 @@
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:id="@+id/icon"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:padding="12dp"/>
|
||||
android:padding="12dp"
|
||||
app:srcCompat="@drawable/v_copy_x24"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/text"
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/keyline_margin">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/click_more_comments"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"
|
||||
android:text="@string/click_more_comments"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<FrameLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:padding="@dimen/keyline_margin">
|
||||
|
||||
<com.hippo.widget.ProgressView
|
||||
android:id="@+id/progress"
|
||||
style="@style/ProgressView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -87,23 +87,44 @@
|
||||
android:layout_marginRight="6dp"
|
||||
android:layout_marginBottom="4dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pages"
|
||||
style="@style/CardMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/posted"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="6dp"/>
|
||||
<LinearLayout
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/posted"
|
||||
android:layout_alignParentRight="true"
|
||||
android:layout_marginRight="6dp"
|
||||
android:orientation="horizontal"
|
||||
android:divider="@drawable/spacer_x6"
|
||||
android:showDividers="middle"
|
||||
android:gravity="center_vertical">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/simple_language"
|
||||
style="@style/CardMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_above="@id/posted"
|
||||
android:layout_toLeftOf="@+id/pages"
|
||||
android:layout_marginRight="6dp"/>
|
||||
<ImageView
|
||||
android:id="@+id/downloaded"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/v_download_x16"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/favourited"
|
||||
android:layout_width="16dp"
|
||||
android:layout_height="16dp"
|
||||
android:visibility="gone"
|
||||
app:srcCompat="@drawable/v_heart_x16"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/simple_language"
|
||||
style="@style/CardMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/pages"
|
||||
style="@style/CardMessage"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
</RelativeLayout>
|
||||
</androidx.cardview.widget.CardView>
|
||||
@@ -47,28 +47,44 @@
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_download_dark_x24"
|
||||
app:srcCompat="@drawable/v_go_to_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemeAccent"
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_refresh_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemeAccent"
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_download_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemeAccent"
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_delete_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemeAccent"
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"/>
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_folder_move_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemeAccent"
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"/>
|
||||
style="@style/Widget.Design.FloatingActionButton.Mini"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.FloatingActionButton
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/v_close_dark_x24"
|
||||
app:backgroundTint="?attr/widgetColorThemePrimary"
|
||||
style="@style/Widget.Design.FloatingActionButton"/>
|
||||
|
||||
|
||||
@@ -75,8 +75,7 @@
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="bottom"
|
||||
android:padding="16dp"
|
||||
app:srcCompat="@drawable/v_send_dark_x24"/>
|
||||
android:padding="16dp"/>
|
||||
|
||||
</LinearLayout>
|
||||
</com.hippo.reveal.RevealLinearLayout>
|
||||
|
||||
@@ -47,7 +47,6 @@
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center_horizontal"
|
||||
android:drawablePadding="8dp"
|
||||
android:text="@string/no_one_comments_gallery"
|
||||
style="@style/TextAppearance.AppCompat.Medium"/>
|
||||
|
||||
</FrameLayout>
|
||||
@@ -73,40 +73,13 @@
|
||||
android:id="@+id/password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="actionNext"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="textPassword"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/recaptcha_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:minWidth="@dimen/single_max_width"
|
||||
android:hint="@string/recaptcha">
|
||||
|
||||
<com.hippo.widget.HackyTextInputEditText
|
||||
android:id="@+id/recaptcha"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:imeOptions="actionDone"
|
||||
android:inputType="text"
|
||||
android:maxLines="1"
|
||||
android:singleLine="true"/>
|
||||
|
||||
</com.google.android.material.textfield.TextInputLayout>
|
||||
|
||||
<com.hippo.ehviewer.widget.RecaptchaView
|
||||
android:id="@+id/recaptcha_image"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="48dp"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:minWidth="@dimen/single_max_width"
|
||||
android:scaleType="fitCenter"/>
|
||||
|
||||
<Space
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="0dp"
|
||||
|
||||
@@ -42,6 +42,12 @@
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_normal_search"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatRadioButton
|
||||
android:id="@+id/search_subscription_search"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="@string/search_subscription_search"/>
|
||||
|
||||
<androidx.appcompat.widget.AppCompatRadioButton
|
||||
android:id="@+id/search_specify_uploader"
|
||||
android:layout_width="wrap_content"
|
||||
|
||||
@@ -16,13 +16,17 @@
|
||||
<merge
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<TableRow>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true"
|
||||
android:text="@string/search_sname"/>
|
||||
|
||||
@@ -30,88 +34,199 @@
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:checked="true"
|
||||
android:text="@string/search_stags"/>
|
||||
</TableRow>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sdesc"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_storr"/>
|
||||
</TableRow>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sto"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sdt1"/>
|
||||
</TableRow>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sdt2"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sh"/>
|
||||
</TableRow>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<TableRow>
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sr"/>
|
||||
|
||||
<Spinner
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:entries="@array/search_min_rating"/>
|
||||
</TableRow>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sp"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/spf"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:inputType="number"
|
||||
android:maxLines="1"
|
||||
android:imeOptions="actionNext"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sp_to"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
|
||||
<EditText
|
||||
android:id="@+id/spt"
|
||||
android:layout_width="64dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:inputType="number"
|
||||
android:maxLines="1"
|
||||
android:imeOptions="actionNone"/>
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sp_suffix"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginBottom="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sf"
|
||||
android:textColor="?android:attr/textColorPrimary"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="@dimen/advance_search_table_item_margin">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sfl"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_marginRight="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sfu"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:layout_marginLeft="@dimen/advance_search_table_item_margin"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:text="@string/search_sft"/>
|
||||
</LinearLayout>
|
||||
</merge>
|
||||
@@ -23,6 +23,11 @@
|
||||
android:title="@string/homepage"
|
||||
android:icon="@drawable/v_homepage_black_x24"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_subscription"
|
||||
android:title="@string/subscription"
|
||||
android:icon="@drawable/v_eh_subscription_black_x24"/>
|
||||
|
||||
<item
|
||||
android:id="@+id/nav_whats_hot"
|
||||
android:title="@string/whats_hot"
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<transitionSet>
|
||||
<changeTransform/>
|
||||
<changeBounds/>
|
||||
</transitionSet>
|
||||
@@ -0,0 +1,22 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
|
||||
<transitionSet>
|
||||
<changeTransform/>
|
||||
<changeBounds/>
|
||||
<changeImageTransform/>
|
||||
</transitionSet>
|
||||
Loaded 100 of 132 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user