Compare commits

...
36 Commits
Author SHA1 Message Date
seven332 185ab00431 1.0.25 2017-12-28 22:00:51 +08:00
LackOfDream b48b38e8c4 remove redundant trailing whitespace of tags when parsing gallery detail 2017-12-24 18:12:44 +08:00
LackOfDream 34632342fc Notify change of single item instead of the whole data set, disable item animation 2017-12-19 15:46:42 +08:00
LackOfDream c7bf9509e3 Add enable/disable feature on Filter 2017-12-19 15:46:42 +08:00
seven332 877c354f84 Add the Telegram link 2017-11-14 21:42:58 +08:00
seven332 6c7b33e86f Add community links 2017-11-14 21:35:02 +08:00
seven332 2c3fa31e91 Add recaptcha 2017-09-06 16:49:48 +08:00
scese250 550d3735c7 Fixed typos, incorrect capital and added accents
Thanks for add spanish translation, I'll help for correct errors.
2017-07-24 12:48:05 +08:00
Jabasukuriputo Wang 71f654635c Add textbox for cookie:igneous.
Fix #208 #274
It seems that login via other ways is impossible to get correct igneous atm.
(DAMN, SAVE IT ELSEWHERE NOW)
2017-07-14 21:08:12 +08:00
seven332 e9c7695367 1.0.24 2017-06-04 23:03:28 +08:00
seven332 b2e34e622c Set default request id to invalid one 2017-06-04 23:02:13 +08:00
seven332 78db7ecbc5 1.0.23 2017-06-01 22:31:41 +08:00
seven332 4896a1edbc Use HashMap instead of WeakHashMap for GlobalStuffMap 2017-06-01 22:30:02 +08:00
seven332 61b2075302 Add e-hentai.org to intent-filter
Close #249
2017-05-25 01:04:35 +08:00
seven332 b21fe89ea1 1.0.22 2017-05-23 16:35:42 +08:00
seven332 4af054a9cd Update gradle tools 2017-05-23 16:35:19 +08:00
seven332 3f579060b5 Fix GalleryDetailParser parsing gallery cover 2017-05-23 16:31:26 +08:00
seven332 1e87279310 Avoid saving large data in ContentLayout 2017-05-23 16:21:05 +08:00
seven332 5fae1df78c Update libraries 2017-04-22 20:48:26 +08:00
seven332 84949442ee Add ISSUE_TEMPLATE English translate 2017-04-07 19:48:21 +08:00
seven332 3b395380c7 Merge remote-tracking branch 'origin/master' 2017-04-05 20:26:00 +08:00
seven332 3e3de0ff2a Update gradle library 2017-04-05 20:24:45 +08:00
seven332 da802c5371 Update ISSUE_TEMPLATE 2017-04-05 20:23:20 +08:00
seven332 24405f7c44 Merge pull request #251 from danthe100/mycommits
Fixed Spanish translation
2017-03-30 22:09:41 -05:00
Dante Garcia 9ed826a87e Fixed certain errors 2017-03-30 12:01:03 -05:00
seven332 9c5c9dfa95 Add ISSUE_TEMPLATE 2017-03-27 23:26:21 +08:00
seven332 6eb29c783a 1.0.21 2017-03-20 22:36:05 +08:00
seven332 cb11ecc9f0 Fix category parsing 2017-03-20 22:34:05 +08:00
seven332 bf5feaacd1 Merge pull request #242 from sorz/master
Add fingerprint unlock
2017-03-18 01:41:53 -05:00
seven332 0ef4088b88 Update gradle 2017-03-17 23:12:11 +08:00
sorz 1e87d34806 Add translations for fingerprint setting
Spanish by Google Translate
2017-03-16 01:52:54 +11:00
sorz 0b35fb01ee Add fingerprint on SecurityScene 2017-03-16 01:11:19 +11:00
sorz 7f1d590fbd Add fingerprint protection switch 2017-03-15 22:38:47 +11:00
seven332 97ce2bbe54 Apply Spanish strings.xml to all countries 2017-02-23 16:54:06 +08:00
seven332 d8a6424ecc Merge pull request #235 from danthe100/mycommits
Added translation into Spanish
2017-02-23 13:10:04 +08:00
Dante Garcia fdc199cc49 Added translation into Spanish 2017-02-22 20:18:17 -05:00
55 changed files with 2641 additions and 556 deletions

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
感谢您提交 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.
+2
View File
@@ -1,3 +1,5 @@
[![Telegram](https://img.shields.io/badge/chat-Telegram-blue.svg)](https://t.me/ehviewer) [![G+](https://img.shields.io/badge/chat-G%2B-red.svg)](https://plus.google.com/communities/103823982034655188459)
# EhViewer
![Icon](art/launcher_icon-web.png)
+11 -7
View File
@@ -5,16 +5,17 @@ apply plugin: 'android-chinese-string'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.hippo.ehviewer"
minSdkVersion 14
targetSdkVersion 25
versionCode 73
versionName "1.0.20"
versionCode 78
versionName "1.0.25"
vectorDrawables.useSupportLibrary = true
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW"
resConfigs "zh", "zh-rCN", "zh-rHK", "zh-rTW",
"es"
}
lintOptions {
@@ -51,13 +52,14 @@ clean {
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.1.0'
compile 'com.android.support:design:25.1.0'
compile "com.android.support:appcompat-v7:$supportLibrary"
compile "com.android.support:design:$supportLibrary"
compile 'com.github.amlcurran.showcaseview:library:5.4.3'
compile 'com.github.seven332:android-recaptcha:2bbb3459a8'
compile 'com.github.seven332:animator:0.1.0'
compile 'com.github.seven332:beerbelly:0.1.4'
compile 'com.github.seven332:conaco:0.1.5-eh'
compile 'com.github.seven332:drawerlayout:0.1.0'
compile 'com.github.seven332:drawerlayout:0.2.1'
compile 'com.github.seven332:easyrecyclerview:0.1.1'
compile 'com.github.seven332:glgallery:0.1.2'
compile 'com.github.seven332:glview:0.1.0'
@@ -78,4 +80,6 @@ dependencies {
compile 'org.greenrobot:greendao:2.2.0'
compile 'org.jsoup:jsoup:1.9.2'
testCompile 'junit:junit:4.12'
testCompile 'org.robolectric:robolectric:3.4'
testCompile 'org.jooq:joor:0.9.6'
}
Regular → Executable
+2
View File
@@ -22,6 +22,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.USE_FINGERPRINT" />
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
@@ -54,6 +55,7 @@
<data android:scheme="http"/>
<data android:scheme="https"/>
<data android:host="exhentai.org"/>
<data android:host="e-hentai.org"/>
<data android:host="g.e-hentai.org"/>
<data android:host="lofi.e-hentai.org"/>
</intent-filter>
@@ -0,0 +1,130 @@
/*
* 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.database;
/*
* Created by Hippo on 2017/9/3.
*/
import android.content.Context;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.SparseArray;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class MSQLiteBuilder {
public static final String COLUMN_ID = "_id";
private static final Map<Class, String> JAVA_TYPE_TO_SQLITE_TYPE = new HashMap<>();
static {
JAVA_TYPE_TO_SQLITE_TYPE.put(boolean.class, "INTEGER NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(byte.class, "INTEGER NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(short.class, "INTEGER NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(int.class, "INTEGER NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(long.class, "INTEGER NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(float.class, "REAL NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(double.class, "REAL NOT NULL DEFAULT 0");
JAVA_TYPE_TO_SQLITE_TYPE.put(String.class, "TEXT");
}
private static String javaTypeToSQLiteType(Class clazz) {
String type = JAVA_TYPE_TO_SQLITE_TYPE.get(clazz);
if (type == null) {
throw new IllegalStateException("Unknown type: " + clazz);
}
return type;
}
private int version = 0;
private List<String> statements;
private SparseArray<List<String>> statementsMap = new SparseArray<>();
/**
* Bump database version.
*/
public MSQLiteBuilder version(int version) {
if (version <= this.version) {
throw new IllegalStateException("New version must be bigger than current version. "
+ "current version: " + this.version + ", new version: " + version + ".");
}
this.version = version;
this.statements = new ArrayList<>();
this.statementsMap.put(version, this.statements);
return this;
}
/**
* Creates a table with int {@link #COLUMN_ID} primary key.
*/
public MSQLiteBuilder createTable(String table) {
return createTable(table, COLUMN_ID, int.class);
}
/**
* Creates a table.
*/
public MSQLiteBuilder createTable(String table, String column, Class clazz) {
return statement("CREATE TABLE " + table + " (" + column + " " + javaTypeToSQLiteType(clazz) + " PRIMARY KEY);");
}
/**
* Drops a table.
*/
public MSQLiteBuilder dropTable(String table) {
return statement("DROP TABLE " + table + ";");
}
/**
* Inserts a column to the table.
*/
public MSQLiteBuilder insertColumn(String table, String column, Class clazz) {
return statement("ALTER TABLE " + table + " ADD COLUMN " + column + " " + javaTypeToSQLiteType(clazz) + ";");
}
/**
* Add a statement.
*/
public MSQLiteBuilder statement(String statement) {
if (version == 0 || statements == null) {
throw new IllegalStateException("Call version() first!");
}
statements.add(statement);
return this;
}
/**
* Build a SQLiteOpenHelper from it.
*/
public SQLiteOpenHelper build(Context context, String name, int version) {
return new MSQLiteOpenHelper(context, name, version, this);
}
List<String> getStatements(int oldVersion, int newVersion) {
List<String> result = new ArrayList<>();
for (int i = oldVersion + 1; i <= newVersion; ++i) {
List<String> list = statementsMap.get(i);
if (list != null) {
result.addAll(list);
}
}
return result;
}
}
@@ -0,0 +1,56 @@
/*
* 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.database;
/*
* Created by Hippo on 2017/9/4.
*/
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import com.hippo.util.SqlUtils;
class MSQLiteOpenHelper extends SQLiteOpenHelper {
private final int version;
private final MSQLiteBuilder builder;
public MSQLiteOpenHelper(Context context, String name, int version, MSQLiteBuilder builder) {
super(context, name, null, version);
this.version = version;
this.builder = builder;
}
@Override
public void onCreate(SQLiteDatabase db) {
onUpgrade(db, 0, version);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
for (String command : builder.getStatements(oldVersion, newVersion)) {
db.execSQL(command);
}
}
@Override
public void onDowngrade(SQLiteDatabase db, int oldVersion, int newVersion) {
SqlUtils.dropAllTable(db);
onCreate(db);
}
}
@@ -0,0 +1,140 @@
/*
* 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.support.annotation.IntRange;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.text.TextUtils;
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;
}
}
@@ -32,7 +32,6 @@ import com.hippo.conaco.Conaco;
import com.hippo.ehviewer.client.EhClient;
import com.hippo.ehviewer.client.EhCookieStore;
import com.hippo.ehviewer.client.EhEngine;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ehviewer.download.DownloadManager;
import com.hippo.ehviewer.spider.SpiderDen;
@@ -40,7 +39,6 @@ import com.hippo.ehviewer.ui.CommonOperations;
import com.hippo.image.Image;
import com.hippo.image.ImageBitmap;
import com.hippo.network.StatusCodeException;
import com.hippo.okhttp.CookieDB;
import com.hippo.scene.SceneApplication;
import com.hippo.text.Html;
import com.hippo.unifile.UniFile;
@@ -54,12 +52,10 @@ import com.hippo.yorozuya.SimpleHandler;
import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.WeakHashMap;
import java.util.concurrent.TimeUnit;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
import okhttp3.OkHttpClient;
public class EhApplication extends SceneApplication implements Thread.UncaughtExceptionHandler {
@@ -76,7 +72,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
private Thread.UncaughtExceptionHandler mDefaultHandler;
private final IntIdGenerator mIdGenerator = new IntIdGenerator();
private final WeakHashMap<Integer, Object> mGlobalStuffMap = new WeakHashMap<>();
private final HashMap<Integer, Object> mGlobalStuffMap = new HashMap<>();
private EhCookieStore mEhCookieStore;
private EhClient mEhClient;
private OkHttpClient mOkHttpClient;
@@ -97,7 +93,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
super.onCreate();
GetText.initialize(this);
CookieDB.initialize(this);
StatusCodeException.initialize(this);
Settings.initialize(this);
ReadableTime.initialize(this);
@@ -159,29 +154,6 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
if (version < 52) {
Settings.putGuideGallery(true);
}
if (version < 56) { // Make cookie long live
HttpUrl eUrl = HttpUrl.parse(EhUrl.HOST_E);
HttpUrl exUrl = HttpUrl.parse(EhUrl.HOST_EX);
EhCookieStore cookieStore = getEhCookieStore(this);
Cookie c;
c = cookieStore.get(eUrl, EhCookieStore.KEY_IPD_MEMBER_ID);
if (null != c) {
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
}
c = cookieStore.get(eUrl, EhCookieStore.KEY_IPD_PASS_HASH);
if (null != c) {
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
}
c = cookieStore.get(exUrl, EhCookieStore.KEY_IPD_MEMBER_ID);
if (null != c) {
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
}
c = cookieStore.get(exUrl, EhCookieStore.KEY_IPD_PASS_HASH);
if (null != c) {
cookieStore.add(EhCookieStore.newCookie(c, c.domain(), true, true, true));
}
}
}
public void clearMemoryCache() {
@@ -243,7 +215,7 @@ public class EhApplication extends SceneApplication implements Thread.UncaughtEx
public static EhCookieStore getEhCookieStore(@NonNull Context context) {
EhApplication application = ((EhApplication) context.getApplicationContext());
if (application.mEhCookieStore == null) {
application.mEhCookieStore = new EhCookieStore();
application.mEhCookieStore = new EhCookieStore(context);
}
return application.mEhCookieStore;
}
@@ -93,6 +93,19 @@ public class EhDB {
switch (oldVersion) {
case 1: // 1 to 2
FilterDao.createTable(db, true);
break;
case 2: // add ENABLE column to table FILTER
db.execSQL("CREATE TABLE " + "\"FILTER2\" (" +
"\"_id\" INTEGER PRIMARY KEY ," +
"\"MODE\" INTEGER NOT NULL ," +
"\"TEXT\" TEXT," +
"\"ENABLE\" INTEGER);");
db.execSQL("INSERT INTO \"FILTER2\" (" +
"_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;
}
}
@@ -606,6 +619,11 @@ public class EhDB {
sDaoSession.getFilterDao().delete(filter);
}
public static synchronized void triggerFilter(Filter filter) {
filter.setEnable(!filter.enable);
sDaoSession.getFilterDao().update(filter);
}
public static synchronized boolean exportDB(Context context, File file) {
File dbFile = context.getDatabasePath("eh.db");
if (null == dbFile || !dbFile.isFile()) {
+10
View File
@@ -911,6 +911,16 @@ public class Settings {
putString(KEY_SECURITY, value);
}
public static final String KEY_ENABLE_FINGERPRINT = "enable_fingerprint";
public static boolean getEnableFingerprint() {
return getBoolean(KEY_ENABLE_FINGERPRINT, false);
}
public static void putEnableFingerprint(boolean value) {
putBoolean(KEY_ENABLE_FINGERPRINT, value);
}
public static final String KEY_READ_CACHE_SIZE = "read_cache_size";
public static final int DEFAULT_READ_CACHE_SIZE = 160;
@@ -153,7 +153,7 @@ public class EhClient {
try {
switch (mMethod) {
case METHOD_SIGN_IN:
return EhEngine.signIn(this, mOkHttpClient, (String) params[0], (String) params[1]);
return EhEngine.signIn(this, mOkHttpClient, (String) params[0], (String) params[1], (String) params[2], (String) params[3]);
case METHOD_GET_GALLERY_LIST:
return EhEngine.getGalleryList(this, mOkHttpClient, (String) params[0]);
case METHOD_FILL_GALLERY_LIST_BY_API:
@@ -16,7 +16,9 @@
package com.hippo.ehviewer.client;
import com.hippo.okhttp.CookieDBStore;
import android.content.Context;
import com.hippo.network.CookieRepository;
import java.util.ArrayList;
import java.util.Collections;
@@ -26,10 +28,11 @@ import okhttp3.Cookie;
import okhttp3.HttpUrl;
import okhttp3.Request;
public class EhCookieStore extends CookieDBStore {
public class EhCookieStore extends CookieRepository {
public static final String KEY_IPD_MEMBER_ID = "ipb_member_id";
public static final String KEY_IPD_PASS_HASH = "ipb_pass_hash";
public static final String KEY_IGNEOUS = "igneous";
public static final Cookie sTipsCookie =
new Cookie.Builder()
@@ -40,13 +43,18 @@ public class EhCookieStore extends CookieDBStore {
.expiresAt(Long.MAX_VALUE)
.build();
public EhCookieStore(Context context) {
super(context, "okhttp3-cookie.db");
}
public void signOut() {
removeAll();
clear();
}
public boolean hasSignedIn() {
return contain(EhUrl.DOMAIN_EX, KEY_IPD_MEMBER_ID) &&
contain(EhUrl.DOMAIN_EX, KEY_IPD_PASS_HASH);
HttpUrl url = HttpUrl.parse(EhUrl.HOST_E);
return contains(url, KEY_IPD_MEMBER_ID) &&
contains(url, KEY_IPD_PASS_HASH);
}
public static Cookie newCookie(Cookie cookie, String newDomain, boolean forcePersistent,
@@ -81,10 +89,9 @@ public class EhCookieStore extends CookieDBStore {
public List<Cookie> loadForRequest(HttpUrl url, Request request) {
List<Cookie> cookies = super.loadForRequest(url, request);
Object tag = request.tag();
String host = url.host();
boolean checkTips = domainMatch(host, EhUrl.DOMAIN_E);
boolean checkUconfig = (domainMatch(host, EhUrl.DOMAIN_E) || domainMatch(host, EhUrl.DOMAIN_EX)) && tag instanceof EhConfig;
boolean checkTips = domainMatch(url, EhUrl.DOMAIN_E);
boolean checkUconfig = (domainMatch(url, EhUrl.DOMAIN_E) || domainMatch(url, EhUrl.DOMAIN_EX)) && tag instanceof EhConfig;
if (checkTips || checkUconfig) {
List<Cookie> result = new ArrayList<>(cookies.size() + 1);
@@ -108,7 +115,7 @@ public class EhCookieStore extends CookieDBStore {
Cookie uconfigCookie = new Cookie.Builder()
.name(EhConfig.KEY_UCONFIG)
.value(ehConfig.uconfig())
.domain(host)
.domain(url.host())
.path("/")
.expiresAt(Long.MAX_VALUE)
.build();
@@ -119,25 +126,4 @@ public class EhCookieStore extends CookieDBStore {
return cookies;
}
}
@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
List<Cookie> result = new ArrayList<>(cookies.size() + 2);
for (Cookie cookie: cookies) {
if (EhUrl.DOMAIN_E.equals(cookie.domain())) {
// Save id and hash for exhentai
if (KEY_IPD_MEMBER_ID.equals(cookie.name()) ||
KEY_IPD_PASS_HASH.equals(cookie.name())) {
result.add(newCookie(cookie, EhUrl.DOMAIN_E, true, true, true));
result.add(newCookie(cookie, EhUrl.DOMAIN_EX, true, true, true));
continue;
}
}
result.add(cookie);
}
super.saveFromResponse(url, Collections.unmodifiableList(result));
}
}
@@ -17,6 +17,7 @@
package com.hippo.ehviewer.client;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
@@ -120,13 +121,17 @@ public class EhEngine {
}
public static String signIn(@Nullable EhClient.Task task, OkHttpClient okHttpClient,
String username, String password) throws Exception {
String username, String password, String recaptchaChallenge, String recaptchaResponse) throws Exception {
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;
Log.d(TAG, url);
Request request = new EhRequestBuilder(url, null != task ? task.getEhConfig() : Settings.getEhConfig())
@@ -92,6 +92,8 @@ public final class EhFilter {
}
public synchronized void addFilter(Filter filter) {
// enable filter by default before it is added to database
filter.enable = true;
EhDB.addFilter(filter);
switch (filter.mode) {
@@ -116,6 +118,10 @@ public final class EhFilter {
}
}
public synchronized void triggerFilter(Filter filter) {
EhDB.triggerFilter(filter);
}
public synchronized void deleteFilter(Filter filter) {
EhDB.deleteFilter(filter);
@@ -153,7 +159,7 @@ public final class EhFilter {
if (null != title && filters.size() > 0) {
title = title.toLowerCase();
for (int i = 0, n = filters.size(); i < n; i++) {
if (title.contains(filters.get(i).text)) {
if (filters.get(i).enable && title.contains(filters.get(i).text)) {
return false;
}
}
@@ -172,7 +178,7 @@ public final class EhFilter {
List<Filter> filters = mUploaderFilterList;
if (null != uploader && filters.size() > 0) {
for (int i = 0, n = filters.size(); i < n; i++) {
if (uploader.equals(filters.get(i).text)) {
if (filters.get(i).enable && uploader.equals(filters.get(i).text)) {
return false;
}
}
@@ -229,7 +235,7 @@ public final class EhFilter {
if (null != tags && filters.size() > 0) {
for (String tag: tags) {
for (int i = 0, n = filters.size(); i < n; i++) {
if (matchTag(tag, filters.get(i).text)) {
if (filters.get(i).enable && matchTag(tag, filters.get(i).text)) {
return false;
}
}
@@ -264,7 +270,7 @@ public final class EhFilter {
if (null != tags && filters.size() > 0) {
for (String tag: tags) {
for (int i = 0, n = filters.size(); i < n; i++) {
if (matchTagNamespace(tag, filters.get(i).text)) {
if (filters.get(i).enable && matchTagNamespace(tag, filters.get(i).text)) {
return false;
}
}
@@ -59,6 +59,7 @@ public class GalleryDetailParser {
private static final Pattern PATTERN_DETAIL = Pattern.compile("var gid = (\\d+);.+?var token = \"([a-f0-9]+)\";.+?var apiuid = ([\\-\\d]+);.+?var apikey = \"([a-f0-9]+)\";", Pattern.DOTALL);
private static final Pattern PATTERN_TORRENT = Pattern.compile("<a[^<>]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Torrent Download \\( (\\d+) \\)</a>");
private static final Pattern PATTERN_ARCHIVE = Pattern.compile("<a[^<>]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Archive Download</a>");
private static final Pattern PATTERN_COVER = Pattern.compile("width:(\\d+)px; height:(\\d+)px.+?url\\((.+?)\\)");
private static final Pattern PATTERN_TAG_GROUP = Pattern.compile("<tr><td[^<>]+>([\\w\\s]+):</td><td>(?:<div[^<>]+><a[^<>]+>[\\w\\s]+</a></div>)+</td></tr>");
private static final Pattern PATTERN_TAG = Pattern.compile("<div[^<>]+><a[^<>]+>([\\w\\s]+)</a></div>");
private static final Pattern PATTERN_COMMENT = Pattern.compile("<div class=\"c3\">Posted on ([^<>]+) by: &nbsp; <a[^<>]+>([^<>]+)</a>.+?<div class=\"c6\"[^>]*>(.+?)</div><div class=\"c[78]\"");
@@ -140,7 +141,7 @@ public class GalleryDetailParser {
// Thumb url
Element gd1 = gm.getElementById("gd1");
try {
gd.thumb = EhUtils.handleThumbUrlResolution(StringUtils.trim(gd1.child(0).attr("src")));
gd.thumb = parseCoverStyle(StringUtils.trim(gd1.child(0).attr("style")));
} catch (Exception e) {
gd.thumb = "";
}
@@ -164,7 +165,9 @@ public class GalleryDetailParser {
// Category
Element gdc = gm.getElementById("gdc");
try {
gd.category = EhUtils.getCategory(gdc.child(0).child(0).attr("alt"));
String href = gdc.child(0).attr("href");
String category = href.substring(href.lastIndexOf('/') + 1);
gd.category = EhUtils.getCategory(category);
} catch (Exception e) {
gd.category = EhUtils.UNKNOWN;
}
@@ -229,6 +232,16 @@ public class GalleryDetailParser {
}
}
// width:250px; height:356px; background:transparent url(https://exhentai.org/t/fe/1f/fe1fcfa9bf8fba2f03982eda0aa347cc9d6a6372-145921-1050-1492-jpg_250.jpg) 0 0 no-repeat
private static String parseCoverStyle(String str) {
Matcher matcher = PATTERN_COVER.matcher(str);
if (matcher.find()) {
return EhUtils.handleThumbUrlResolution(matcher.group(3));
} else {
return "";
}
}
private static void parseDetailInfo(GalleryDetail gd, Element e, String body) {
Elements es = e.children();
if (es.size() < 2) {
@@ -290,7 +303,7 @@ public class GalleryDetailParser {
// Sometimes parody tag is followed with '|' and english translate, just remove them
int index = tag.indexOf('|');
if (index >= 0) {
tag = tag.substring(0, index);
tag = tag.substring(0, index).trim();
}
group.addTag(tag);
}
@@ -17,6 +17,7 @@
package com.hippo.ehviewer.ui;
import android.content.DialogInterface;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
@@ -77,6 +78,7 @@ public class FilterActivity extends ToolbarActivity {
mRecyclerView.setClipChildren(false);
mRecyclerView.setLayoutManager(new LinearLayoutManager(this));
mRecyclerView.hasFixedSize();
mRecyclerView.setItemAnimator(null);
updateView(false);
}
@@ -247,6 +249,8 @@ public class FilterActivity extends ToolbarActivity {
if (null != icon) {
icon.setOnClickListener(this);
}
// click on the filter text to enable/disable it
text.setOnClickListener(this);
}
@Override
@@ -257,7 +261,15 @@ public class FilterActivity extends ToolbarActivity {
}
Filter filter = mFilterList.get(position);
if (FilterList.MODE_HEADER != filter.mode) {
showDeleteFilterDialog(filter);
if (v instanceof ImageView) {
showDeleteFilterDialog(filter);
} else if (v instanceof TextView) {
mFilterList.trigger(filter);
//for updating delete line on filter text
mAdapter.notifyItemChanged(getAdapterPosition());
}
}
}
}
@@ -314,12 +326,18 @@ public class FilterActivity extends ToolbarActivity {
holder.text.setText(filter.text);
} else {
holder.text.setText(filter.text);
// add a delete line if the filter is disabled
if (!filter.enable) {
holder.text.setPaintFlags(holder.text.getPaintFlags() | Paint.STRIKE_THRU_TEXT_FLAG);
} else {
holder.text.setPaintFlags(holder.text.getPaintFlags() & (~Paint.STRIKE_THRU_TEXT_FLAG));
}
}
}
@Override
public int getItemCount() {
return null != mFilterList ? mFilterList.size(): 0;
return null != mFilterList ? mFilterList.size() : 0;
}
}
@@ -450,5 +468,9 @@ public class FilterActivity extends ToolbarActivity {
public void delete(Filter filter) {
mEhFilter.deleteFilter(filter);
}
public void trigger(Filter filter) {
mEhFilter.triggerFilter(filter);
}
}
}
+18 -1
View File
@@ -16,11 +16,13 @@
package com.hippo.ehviewer.ui;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.text.TextUtils;
import android.view.MenuItem;
import android.view.View;
import android.widget.CheckBox;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
@@ -36,6 +38,8 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
private View mCancel;
@Nullable
private View mSet;
@Nullable
private CheckBox mFingerprint;
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -46,6 +50,7 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
mPatternView = (LockPatternView) ViewUtils.$$(this, R.id.pattern_view);
mCancel = ViewUtils.$$(this, R.id.cancel);
mSet = ViewUtils.$$(this, R.id.set);
mFingerprint = (CheckBox) ViewUtils.$$(this, R.id.fingerprint_checkbox);
String pattern = Settings.getSecurity();
if (!TextUtils.isEmpty(pattern)) {
@@ -53,6 +58,16 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
LockPatternUtils.stringToPattern(pattern));
}
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M) {
FingerprintManager fingerprintManager = getSystemService(FingerprintManager.class);
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
if (fingerprintManager.hasEnrolledFingerprints()) {
mFingerprint.setVisibility(View.VISIBLE);
mFingerprint.setChecked(Settings.getEnableFingerprint());
}
}
mCancel.setOnClickListener(this);
mSet.setOnClickListener(this);
}
@@ -79,7 +94,7 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
if (v == mCancel) {
finish();
} else if (v == mSet) {
if (null != mPatternView) {
if (null != mPatternView && null != mFingerprint) {
String security;
if (mPatternView.getCellSize() <= 1) {
security = "";
@@ -87,6 +102,8 @@ public class SetSecurityActivity extends ToolbarActivity implements View.OnClick
security = mPatternView.getPatternString();
}
Settings.putSecurity(security);
Settings.putEnableFingerprint(mFingerprint.getVisibility() == View.VISIBLE &&
mFingerprint.isChecked() && !security.isEmpty());
}
finish();
}
@@ -30,16 +30,13 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.EditText;
import android.widget.TextView;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.client.EhCookieStore;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.EhUtils;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
import okhttp3.Cookie;
public class CookieSignInScene extends SolidScene implements EditText.OnEditorActionListener,
@@ -53,10 +50,14 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
@Nullable
private TextInputLayout mIpbPassHashLayout;
@Nullable
private TextInputLayout mIgneousLayout;
@Nullable
private EditText mIpbMemberId;
@Nullable
private EditText mIpbPassHash;
@Nullable
private EditText mIgneous;
@Nullable
private View mOk;
@Override
@@ -75,6 +76,9 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
mIpbPassHashLayout = (TextInputLayout) ViewUtils.$$(view, R.id.ipb_pass_hash_layout);
mIpbPassHash = mIpbPassHashLayout.getEditText();
Assert.assertNotNull(mIpbPassHash);
mIgneousLayout = (TextInputLayout) ViewUtils.$$(view, R.id.igneous_layout);
mIgneous = mIgneousLayout.getEditText();
Assert.assertNotNull(mIgneous);
mOk = ViewUtils.$$(view, R.id.ok);
mIpbPassHash.setOnEditorActionListener(this);
@@ -87,6 +91,7 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
SharedPreferences sharedPreferences = context.getSharedPreferences("eh_info", 0);
String ipbMemberId = sharedPreferences.getString("ipb_member_id", null);
String ipbPassHash = sharedPreferences.getString("ipb_pass_hash", null);
String igneous = sharedPreferences.getString("igneous", null);
boolean getIt = false;
if (!TextUtils.isEmpty(ipbMemberId)) {
mIpbMemberId.setText(ipbMemberId);
@@ -96,6 +101,10 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
mIpbPassHash.setText(ipbPassHash);
getIt = true;
}
if (!TextUtils.isEmpty(igneous)) {
mIgneous.setText(igneous);
getIt = true;
}
if (getIt) {
showTip(R.string.found_cookies, LENGTH_SHORT);
}
@@ -117,8 +126,10 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
mIpbMemberIdLayout = null;
mIpbPassHashLayout = null;
mIgneousLayout = null;
mIpbMemberId = null;
mIpbPassHash = null;
mIgneous = null;
}
@Override
@@ -164,12 +175,14 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
public void enter() {
Context context = getContext2();
if (null == context || null == mIpbMemberIdLayout || null == mIpbPassHashLayout ||
null == mIpbMemberId || null == mIpbPassHash) {
null == mIgneousLayout || null == mIpbMemberId || null == mIpbPassHash ||
null == mIgneous) {
return;
}
final String ipbMemberId = mIpbMemberId.getText().toString().trim();
final String ipbPassHash = mIpbPassHash.getText().toString().trim();
final String igneous = mIgneous.getText().toString().trim();
if (TextUtils.isEmpty(ipbMemberId)) {
mIpbMemberIdLayout.setError(getString(R.string.text_is_empty));
@@ -183,6 +196,12 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
} else {
mIpbPassHashLayout.setError(null);
}
if (TextUtils.isEmpty(igneous)) {
mIgneousLayout.setError(getString(R.string.text_is_empty));
return;
} else {
mIgneousLayout.setError(null);
}
hideSoftInput();
@@ -193,13 +212,13 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
.setPositiveButton(R.string.i_will_check_it, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
storeCookie(ipbMemberId, ipbPassHash);
storeCookie(ipbMemberId, ipbPassHash, igneous);
setResult(RESULT_OK, null);
finish();
}
}).show();
} else {
storeCookie(ipbMemberId, ipbPassHash);
storeCookie(ipbMemberId, ipbPassHash, igneous);
setResult(RESULT_OK, null);
finish();
}
@@ -210,7 +229,7 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
.domain(domain).expiresAt(Long.MAX_VALUE).build();
}
private void storeCookie(String id, String hash) {
private void storeCookie(String id, String hash, String igneous) {
Context context = getContext2();
if (null == context) {
return;
@@ -219,9 +238,11 @@ public class CookieSignInScene extends SolidScene implements EditText.OnEditorAc
EhUtils.signOut(context);
EhCookieStore store = EhApplication.getEhCookieStore(context);
store.add(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_E));
store.add(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_EX));
store.add(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_E));
store.add(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_EX));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_MEMBER_ID, id, EhUrl.DOMAIN_EX));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IPD_PASS_HASH, hash, EhUrl.DOMAIN_EX));
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_E));
store.addCookie(newCookie(EhCookieStore.KEY_IGNEOUS, igneous, EhUrl.DOMAIN_EX));
}
}
@@ -103,6 +103,7 @@ import com.hippo.widget.ProgressView;
import com.hippo.widget.SimpleGridAutoSpanLayout;
import com.hippo.yorozuya.FileUtils;
import com.hippo.yorozuya.IOUtils;
import com.hippo.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
@@ -250,7 +251,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene
@Nullable
private GalleryDetail mGalleryDetail;
private int mRequestId;
private int mRequestId = IntIdGenerator.INVALID_ID;
private Pair<String, String>[] mTorrentList;
+88
View File
@@ -19,11 +19,15 @@ package com.hippo.ehviewer.ui.scene;
import android.content.Context;
import android.hardware.Sensor;
import android.hardware.SensorManager;
import android.hardware.fingerprint.FingerprintManager;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import com.hippo.ehviewer.R;
import com.hippo.ehviewer.Settings;
@@ -42,15 +46,21 @@ public class SecurityScene extends SolidScene implements
LockPatternView.OnPatternListener, ShakeDetector.OnShakeListener {
private static final int MAX_RETRY_TIMES = 5;
private static final long ERROR_TIMEOUT_MILLIS = 1200;
private static final long SUCCESS_DELAY_MILLIS = 100;
private static final String KEY_RETRY_TIMES = "retry_times";
@Nullable
private LockPatternView mPatternView;
private ImageView mFingerprintIcon;
private SensorManager mSensorManager;
private Sensor mAccelerometer;
private ShakeDetector mShakeDetector;
private FingerprintManager mFingerprintManager;
private CancellationSignal mFingerprintCancellationSignal;
private int mRetryTimes;
@@ -73,6 +83,9 @@ public class SecurityScene extends SolidScene implements
mShakeDetector.setOnShakeListener(this);
}
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
mFingerprintManager = context.getSystemService(FingerprintManager.class);
}
if (null == savedInstanceState) {
mRetryTimes = MAX_RETRY_TIMES;
@@ -97,6 +110,38 @@ public class SecurityScene extends SolidScene implements
if (null != mShakeDetector) {
mSensorManager.registerListener(mShakeDetector, mAccelerometer, SensorManager.SENSOR_DELAY_UI);
}
if (isFingerprintAuthAvailable()) {
mFingerprintCancellationSignal = new CancellationSignal();
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
mFingerprintManager.authenticate(null, mFingerprintCancellationSignal, 0,
new FingerprintManager.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
fingerprintError(true);
}
@Override
public void onAuthenticationFailed() {
fingerprintError(false);
}
@Override
public void onAuthenticationSucceeded(
FingerprintManager.AuthenticationResult result) {
mFingerprintIcon.setImageResource(R.drawable.ic_fingerprint_success);
mFingerprintIcon.postDelayed(new Runnable() {
@Override
public void run() {
startSceneForCheckStep(CHECK_STEP_SECURITY, getArguments());
finish();
}
}, SUCCESS_DELAY_MILLIS);
}
}, null);
}
}
@Override
@@ -106,6 +151,10 @@ public class SecurityScene extends SolidScene implements
if (null != mShakeDetector) {
mSensorManager.unregisterListener(mShakeDetector);
}
if (isFingerprintAuthAvailable() && mFingerprintCancellationSignal != null) {
mFingerprintCancellationSignal.cancel();
mFingerprintCancellationSignal = null;
}
}
@Override
@@ -123,6 +172,11 @@ public class SecurityScene extends SolidScene implements
mPatternView = (LockPatternView) ViewUtils.$$(view, R.id.pattern_view);
mPatternView.setOnPatternListener(this);
mFingerprintIcon = (ImageView) ViewUtils.$$(view, R.id.fingerprint_icon);
if (Settings.getEnableFingerprint() && isFingerprintAuthAvailable()) {
mFingerprintIcon.setVisibility(View.VISIBLE);
mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
}
return view;
}
@@ -176,4 +230,38 @@ public class SecurityScene extends SolidScene implements
finish();
}
}
private boolean isFingerprintAuthAvailable() {
// The line below prevents the false positive inspection from Android Studio
// noinspection ResourceType
return Build.VERSION.SDK_INT >= Build.VERSION_CODES.M
&& Settings.getEnableFingerprint()
&& mFingerprintManager != null
&& mFingerprintManager.isHardwareDetected()
&& mFingerprintManager.hasEnrolledFingerprints();
}
private Runnable mResetFingerprintRunnable = new Runnable() {
@Override
public void run() {
if (mFingerprintIcon != null)
mFingerprintIcon.setImageResource(R.drawable.ic_fp_40px);
}
};
private void fingerprintError(boolean unrecoverable) {
// Do not decrease mRetryTimes here since Android system will handle it :)
mFingerprintIcon.setImageResource(R.drawable.ic_fingerprint_error);
mFingerprintIcon.removeCallbacks(mResetFingerprintRunnable);
if (unrecoverable) {
mFingerprintIcon.postDelayed(new Runnable() {
@Override
public void run() {
mFingerprintIcon.setVisibility(View.INVISIBLE);
}
}, ERROR_TIMEOUT_MILLIS);
} else {
mFingerprintIcon.postDelayed(mResetFingerprintRunnable, ERROR_TIMEOUT_MILLIS);
}
}
}
@@ -40,8 +40,10 @@ 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.yorozuya.IntIdGenerator;
import com.hippo.yorozuya.ViewUtils;
import junit.framework.Assert;
@@ -67,6 +69,8 @@ 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
@@ -79,7 +83,7 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
private TextView mSkipSigningIn;
private boolean mSigningIn;
private int mRequestId;
private int mRequestId = IntIdGenerator.INVALID_ID;
@Override
public boolean needShowLeftDrawer() {
@@ -124,6 +128,8 @@ public final class SignInScene extends SolidScene implements EditText.OnEditorAc
mPasswordLayout = (TextInputLayout) ViewUtils.$$(loginForm, R.id.password_layout);
mPassword = mPasswordLayout.getEditText();
Assert.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);
@@ -279,12 +285,15 @@ 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)
.setArgs(username, password, challenge, response)
.setCallback(callback);
EhApplication.getEhClient(context).execute(request);
@@ -28,18 +28,14 @@ import android.webkit.CookieManager;
import android.webkit.CookieSyncManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.client.EhCookieStore;
import com.hippo.ehviewer.client.EhUrl;
import com.hippo.ehviewer.client.EhUtils;
import junit.framework.Assert;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import junit.framework.Assert;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
@@ -122,7 +118,7 @@ public class WebViewSignInScene extends SolidScene {
}
private void addCookie(Context context, String domain, Cookie cookie) {
EhApplication.getEhCookieStore(context).add(EhCookieStore.newCookie(cookie, domain, true, true, true));
EhApplication.getEhCookieStore(context).addCookie(EhCookieStore.newCookie(cookie, domain, true, true, true));
}
@Override
@@ -149,6 +145,9 @@ public class WebViewSignInScene extends SolidScene {
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);
}
}
@@ -0,0 +1,183 @@
/*
* 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.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.View;
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();
}
}
}
@@ -0,0 +1,236 @@
/*
* 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.network;
/*
* Created by Hippo on 2017/9/4.
*/
import android.content.ContentValues;
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.support.annotation.Nullable;
import android.util.Log;
import com.hippo.database.MSQLiteBuilder;
import com.hippo.util.SqlUtils;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Cookie;
class CookieDatabase {
private static final String LOG_TAG = CookieDatabase.class.getSimpleName();
private static final int VERSION_1 = 1;
private static final String TABLE_COOKIE = "OK_HTTP_3_COOKIE";
private static final String COLUMN_ID = "_id";
private static final String COLUMN_NAME = "NAME";
private static final String COLUMN_VALUE = "VALUE";
private static final String COLUMN_EXPIRES_AT = "EXPIRES_AT";
private static final String COLUMN_DOMAIN = "DOMAIN";
private static final String COLUMN_PATH = "PATH";
private static final String COLUMN_SECURE = "SECURE";
private static final String COLUMN_HTTP_ONLY = "HTTP_ONLY";
private static final String COLUMN_PERSISTENT = "PERSISTENT";
private static final String COLUMN_HOST_ONLY = "HOST_ONLY";
private static final int DB_VERSION = VERSION_1;
private final Map<Cookie, Long> cookieIdMap = new HashMap<>();
private final SQLiteOpenHelper helper;
private final SQLiteDatabase db;
public CookieDatabase(Context context, String name) {
helper = new MSQLiteBuilder()
.version(VERSION_1)
.createTable(TABLE_COOKIE)
.insertColumn(TABLE_COOKIE, COLUMN_NAME, String.class)
.insertColumn(TABLE_COOKIE, COLUMN_VALUE, String.class)
.insertColumn(TABLE_COOKIE, COLUMN_EXPIRES_AT, long.class)
.insertColumn(TABLE_COOKIE, COLUMN_DOMAIN, String.class)
.insertColumn(TABLE_COOKIE, COLUMN_PATH, String.class)
.insertColumn(TABLE_COOKIE, COLUMN_SECURE, boolean.class)
.insertColumn(TABLE_COOKIE, COLUMN_HTTP_ONLY, boolean.class)
.insertColumn(TABLE_COOKIE, COLUMN_PERSISTENT, boolean.class)
.insertColumn(TABLE_COOKIE, COLUMN_HOST_ONLY, boolean.class)
.build(context, name, DB_VERSION);
db = helper.getWritableDatabase();
}
@Nullable
private static Cookie getCookie(Cursor cursor, long now) {
String name = SqlUtils.getString(cursor, COLUMN_NAME, null);
String value = SqlUtils.getString(cursor, COLUMN_VALUE, null);
long expiresAt = SqlUtils.getLong(cursor, COLUMN_EXPIRES_AT, 0);
String domain = SqlUtils.getString(cursor, COLUMN_DOMAIN, null);
String path = SqlUtils.getString(cursor, COLUMN_PATH, null);
boolean secure = SqlUtils.getBoolean(cursor, COLUMN_SECURE, false);
boolean httpOnly = SqlUtils.getBoolean(cursor, COLUMN_HTTP_ONLY, false);
boolean persistent = SqlUtils.getBoolean(cursor, COLUMN_PERSISTENT, false);
boolean hostOnly = SqlUtils.getBoolean(cursor, COLUMN_HOST_ONLY, false);
if (name == null || domain == null || path == null) {
return null;
}
// Check non-persistent or expired
if (!persistent || expiresAt <= now) {
return null;
}
Cookie.Builder builder = new Cookie.Builder();
builder.name(name);
builder.value(value);
if (hostOnly) {
builder.hostOnlyDomain(domain);
} else {
builder.domain(domain);
}
builder.path(path);
builder.expiresAt(expiresAt);
if (secure) builder.secure();
if (httpOnly) builder.httpOnly();
return builder.build();
}
public Map<String, CookieSet> getAllCookies() {
long now = System.currentTimeMillis();
Map<String, CookieSet> map = new HashMap<>();
List<Long> toRemove = new ArrayList<>();
Cursor cursor = db.rawQuery("SELECT * FROM " + TABLE_COOKIE + ";", null);
try {
while (cursor.moveToNext()) {
long id = SqlUtils.getLong(cursor, COLUMN_ID, 0);
Cookie cookie = getCookie(cursor, now);
if (cookie != null) {
// Save id of the cookie in db
cookieIdMap.put(cookie, id);
// Put cookie to set
CookieSet set = map.get(cookie.domain());
if (set == null) {
set = new CookieSet();
map.put(cookie.domain(), set);
}
set.add(cookie);
} else {
// Mark to remove the cookie
toRemove.add(id);
}
}
} finally {
cursor.close();
}
// Remove invalid or expired cookie
if (!toRemove.isEmpty()) {
SQLiteStatement statement = db.compileStatement(
"DELETE FROM " + TABLE_COOKIE + " WHERE " + COLUMN_ID + " = ?;");
db.beginTransaction();
try {
for (long id : toRemove) {
statement.bindLong(1, id);
statement.executeUpdateDelete();
}
db.setTransactionSuccessful();
} finally {
db.endTransaction();
}
}
return map;
}
public ContentValues toContentValues(Cookie cookie) {
ContentValues contentValues = new ContentValues(9);
contentValues.put(COLUMN_NAME, cookie.name());
contentValues.put(COLUMN_VALUE, cookie.value());
contentValues.put(COLUMN_EXPIRES_AT, cookie.expiresAt());
contentValues.put(COLUMN_DOMAIN, cookie.domain());
contentValues.put(COLUMN_PATH, cookie.path());
contentValues.put(COLUMN_SECURE, cookie.secure());
contentValues.put(COLUMN_HTTP_ONLY, cookie.httpOnly());
contentValues.put(COLUMN_PERSISTENT, cookie.persistent());
contentValues.put(COLUMN_HOST_ONLY, cookie.hostOnly());
return contentValues;
}
public void add(Cookie cookie) {
long id = db.insert(TABLE_COOKIE, null, toContentValues(cookie));
if (id != -1L) {
Long oldId = cookieIdMap.put(cookie, id);
if (oldId != null) Log.e(LOG_TAG, "Add a duplicate cookie");
} else {
Log.e(LOG_TAG, "An error occurred when insert a cookie");
}
}
public void update(Cookie from, Cookie to) {
Long id = cookieIdMap.get(from);
if (id == null) {
Log.e(LOG_TAG, "Can't get id when update the cookie");
return;
}
ContentValues values = toContentValues(to);
String whereClause = COLUMN_ID + " = ?";
String[] whereArgs = { id.toString() };
int count = db.update(TABLE_COOKIE, values, whereClause, whereArgs);
if (count != 1) {
Log.e(LOG_TAG, "Bad result when update cookie: " + count);
}
// Update it in cookie-id map
cookieIdMap.remove(from);
cookieIdMap.put(to, id);
}
public void remove(Cookie cookie) {
Long id = cookieIdMap.get(cookie);
if (id == null) {
Log.e(LOG_TAG, "Can't get id when remove the cookie");
return;
}
String whereClause = COLUMN_ID + " = ?";
String[] whereArgs = { id.toString() };
int count = db.delete(TABLE_COOKIE, whereClause, whereArgs);
if (count != 1) {
Log.e(LOG_TAG, "Bad result when remove cookie: " + count);
}
// Remove it from cookie-id map
cookieIdMap.remove(cookie);
}
public void clear() {
db.delete(TABLE_COOKIE, null, null);
cookieIdMap.clear();
}
public void close() {
db.close();
helper.close();
}
}
@@ -0,0 +1,188 @@
/*
* 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.network;
/*
* Created by Hippo on 2017/9/4.
*/
import android.content.Context;
import com.hippo.yorozuya.ObjectUtils;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import okhttp3.Request;
public class CookieRepository implements CookieJar {
private CookieDatabase db;
private Map<String, CookieSet> map;
public CookieRepository(Context context, String name) {
db = new CookieDatabase(context, name);
map = db.getAllCookies();
}
public synchronized void addCookie(Cookie cookie) {
// For cookie database
Cookie toAdd = null;
Cookie toUpdate = null;
Cookie toRemove = null;
CookieSet set = map.get(cookie.domain());
if (set == null) {
set = new CookieSet();
map.put(cookie.domain(), set);
}
if (cookie.expiresAt() <= System.currentTimeMillis()) {
toRemove = set.remove(cookie);
// If the cookie is not persistent, it's not in database
if (toRemove != null && !toRemove.persistent()) {
toRemove = null;
}
} else {
toAdd = cookie;
toUpdate = set.add(cookie);
// If the cookie is not persistent, it's not in database
if (!toAdd.persistent()) toAdd = null;
if (toUpdate != null && !toUpdate.persistent()) toUpdate = null;
// Remove the cookie if it updates to null
if (toAdd == null && toUpdate != null) {
toRemove = toUpdate;
toUpdate = null;
}
}
if (toRemove != null) {
db.remove(toRemove);
}
if (toAdd != null) {
if (toUpdate != null) {
db.update(toUpdate, toAdd);
} else {
db.add(toAdd);
}
}
}
public synchronized List<Cookie> getCookies(HttpUrl url) {
List<Cookie> accepted = new ArrayList<>();
List<Cookie> expired = new ArrayList<>();
for (Map.Entry<String, CookieSet> entry : map.entrySet()) {
String domain = entry.getKey();
CookieSet cookieSet = entry.getValue();
if (domainMatch(url, domain)) {
cookieSet.get(url, accepted, expired);
}
}
for (Cookie cookie : expired) {
if (cookie.persistent()) {
db.remove(cookie);
}
}
// RFC 6265 Section-5.4 step 2, sort the cookie-list
// Cookies with longer paths are listed before cookies with shorter paths.
// Ignore creation-time, we don't store them.
Collections.sort(accepted, new Comparator<Cookie>() {
@Override
public int compare(Cookie o1, Cookie o2) {
return o2.path().length() - o1.path().length();
}
});
return accepted;
}
public boolean contains(HttpUrl url, String name) {
for (Cookie cookie : getCookies(url)) {
if (ObjectUtils.equal(cookie.name(), name)) {
return true;
}
}
return false;
}
/**
* Remove all cookies in this {@code CookieRepository}.
*/
public synchronized void clear() {
map.clear();
db.clear();
}
public synchronized void close() {
db.close();
}
@Override
public void saveFromResponse(HttpUrl httpUrl, List<Cookie> list) {
for (Cookie cookie : list) {
addCookie(cookie);
}
}
@Override
public List<Cookie> loadForRequest(HttpUrl httpUrl, Request request) {
return getCookies(httpUrl);
}
/**
* Quick and dirty pattern to differentiate IP addresses from hostnames. This is an approximation
* of Android's private InetAddress#isNumeric API.
*
* This matches IPv6 addresses as a hex string containing at least one colon, and possibly
* including dots after the first colon. It matches IPv4 addresses as strings containing only
* decimal digits and dots. This pattern matches strings like "a:.23" and "54" that are neither IP
* addresses nor hostnames; they will be verified as IP addresses (which is a more strict
* verification).
*/
private static final Pattern VERIFY_AS_IP_ADDRESS = Pattern.compile("([0-9a-fA-F]*:[0-9a-fA-F:.]*)|([\\d.]+)");
/**
* Returns true if `host` is not a host name and might be an IP address.
*/
private static boolean verifyAsIpAddress(String host) {
return VERIFY_AS_IP_ADDRESS.matcher(host).matches();
}
// okhttp3.Cookie.domainMatch(HttpUrl, String)
protected static boolean domainMatch(HttpUrl url, String domain) {
String urlHost = url.host();
if (urlHost.equals(domain)) {
return true; // As in 'example.com' matching 'example.com'.
}
if (urlHost.endsWith(domain)
&& urlHost.charAt(urlHost.length() - domain.length() - 1) == '.'
&& !verifyAsIpAddress(urlHost)) {
return true; // As in 'example.com' matching 'www.example.com'.
}
return false;
}
}
@@ -0,0 +1,104 @@
/*
* 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.network;
/*
* Created by Hippo on 2017/9/4.
*/
import com.hippo.util.HashCodeUtils;
import com.hippo.yorozuya.ObjectUtils;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
class CookieSet {
private Map<Key, Cookie> map = new HashMap<>();
/**
* Adds a cookie to this {@code CookieSet}.
* Returns a previous cookie with
* the same name, domain and path or {@code null}.
*/
public Cookie add(Cookie cookie) {
return map.put(new Key(cookie), cookie);
}
/**
* Removes a cookie with the same name,
* domain and path as the cookie.
* Returns the removed cookie or {@code null}.
*/
public Cookie remove(Cookie cookie) {
return map.remove(new Key(cookie));
}
/**
* Get cookies for the url. Fill {@code accepted} and {@code expired}.
*/
public void get(HttpUrl url, List<Cookie> accepted, List<Cookie> expired) {
long now = System.currentTimeMillis();
Iterator<Map.Entry<Key, Cookie>> iterator = map.entrySet().iterator();
while (iterator.hasNext()) {
Cookie cookie = iterator.next().getValue();
if (cookie.expiresAt() <= now) {
iterator.remove();
expired.add(cookie);
} else if (cookie.matches(url)) {
accepted.add(cookie);
}
}
}
static class Key {
private String name;
private String domain;
private String path;
public Key(Cookie cookie) {
this.name = cookie.name();
this.domain = cookie.domain();
this.path = cookie.path();
}
@Override
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof Key) {
Key key = (Key) obj;
return ObjectUtils.equal(key.name, this.name) &&
ObjectUtils.equal(key.domain, this.domain) &&
ObjectUtils.equal(key.path, this.path);
}
return false;
}
@Override
public int hashCode() {
return HashCodeUtils.hashCode(name, domain, path);
}
}
}
@@ -1,134 +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.okhttp;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import com.hippo.okhttp.dao.DaoMaster;
import com.hippo.okhttp.dao.DaoSession;
import com.hippo.okhttp.dao.OkHttp3CookieDao;
import com.hippo.okhttp.dao.OkHttp3CookieRaw;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import okhttp3.Cookie;
public class CookieDB {
private static DaoSession sDaoSession;
private static class DBOpenHelper extends DaoMaster.OpenHelper {
public DBOpenHelper(Context context, String name, SQLiteDatabase.CursorFactory factory) {
super(context, name, factory);
}
@Override
public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
}
}
public static void initialize(Context context) {
DBOpenHelper helper = new DBOpenHelper(
context.getApplicationContext(), "okhttp3-cookie.db", null);
SQLiteDatabase db = helper.getWritableDatabase();
DaoMaster daoMaster = new DaoMaster(db);
sDaoSession = daoMaster.newSession();
}
static Map<String, List<CookieWithID>> getAllCookies() {
OkHttp3CookieDao dao = sDaoSession.getOkHttp3CookieDao();
List<OkHttp3CookieRaw> list = dao.queryBuilder().list();
long now = System.currentTimeMillis();
Map<String, List<CookieWithID>> result = new HashMap<>();
for (OkHttp3CookieRaw raw : list) {
// Check expired
if (!raw.getPersistent() || raw.getExpiresAt() <= now) {
dao.delete(raw);
continue;
}
// Avoid null error
String name = raw.getName();
String value = raw.getValue();
String domain = raw.getDomain();
if (name == null || value == null || domain == null) {
dao.delete(raw);
continue;
}
Cookie.Builder builder = new Cookie.Builder();
builder.name(name);
builder.value(value);
builder.expiresAt(raw.getExpiresAt());
if (raw.getHostOnly()) {
builder.hostOnlyDomain(domain);
} else {
builder.domain(raw.getDomain());
}
builder.path(raw.getPath());
if (raw.getSecure()) {
builder.secure();
}
if (raw.getHttpOnly()) {
builder.httpOnly();
}
List<CookieWithID> cookies = result.get(domain);
if (cookies == null) {
cookies = new ArrayList<>();
result.put(domain, cookies);
}
cookies.add(new CookieWithID(raw.getId(), builder.build()));
}
return result;
}
static void removeCookie(long id) {
sDaoSession.getOkHttp3CookieDao().deleteByKey(id);
}
static void removeAllCookies() {
sDaoSession.getOkHttp3CookieDao().deleteAll();
}
static long addCookie(Cookie cookie) {
OkHttp3CookieDao dao = sDaoSession.getOkHttp3CookieDao();
OkHttp3CookieRaw raw = new OkHttp3CookieRaw();
raw.setName(cookie.name());
raw.setValue(cookie.value());
raw.setExpiresAt(cookie.expiresAt());
raw.setDomain(cookie.domain());
raw.setPath(cookie.path());
raw.setSecure(cookie.secure());
raw.setHttpOnly(cookie.httpOnly());
raw.setPersistent(cookie.persistent());
raw.setHostOnly(cookie.hostOnly());
return dao.insert(raw);
}
}
@@ -1,236 +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.okhttp;
import android.support.annotation.Nullable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import okhttp3.Cookie;
import okhttp3.CookieJar;
import okhttp3.HttpUrl;
import okhttp3.Request;
public class CookieDBStore implements CookieJar {
private final Map<String, List<CookieWithID>> map;
public CookieDBStore() {
map = CookieDB.getAllCookies();
}
private static boolean hasExpired(Cookie cookie) {
return cookie.expiresAt() < System.currentTimeMillis();
}
private static boolean domainMatch(Cookie cookie, String urlHost) {
return cookie.hostOnly()
? urlHost.equals(cookie.domain())
: domainMatch(urlHost, cookie.domain());
}
public static boolean domainMatch(String urlHost, String cookieDomain) {
if (urlHost.equals(cookieDomain)) {
return true; // As in 'example.com' matching 'example.com'.
}
return urlHost.endsWith(cookieDomain)
&& urlHost.charAt(urlHost.length() - cookieDomain.length() - 1) == '.';
}
private static CookieWithID removeCookie(List<CookieWithID> list, String name) {
for (int i = 0, n = list.size(); i < n; i++) {
CookieWithID cwi = list.get(i);
if (cwi.cookie.name().equals(name)) {
list.remove(i);
return cwi;
}
}
return null;
}
private boolean containInternal(String host, String name, List<CookieWithID> cookies) {
for (int i = 0, n = cookies.size(); i < n; i++) {
Cookie cookie = cookies.get(i).cookie;
if (domainMatch(cookie, host) && cookie.name().equals(name)) {
return true;
}
}
return false;
}
public synchronized boolean contain(String host, String name) {
for (String key : map.keySet()) {
if (domainMatch(host, key)) {
List<CookieWithID> cookies = map.get(key);
// cookies can not be null
if (containInternal(host, name, cookies)) {
return true;
}
}
}
return false;
}
private synchronized void removeInternal(Cookie cookie) {
String domain = cookie.domain();
List<CookieWithID> cookies = map.get(domain);
if (cookies != null) {
// Remove from list
CookieWithID cwi = removeCookie(cookies, cookie.name());
if (cwi != null) {
// Remove from DB
CookieDB.removeCookie(cwi.id);
}
}
}
private void removeInternal(String host, List<CookieWithID> cookies) {
for (Iterator<CookieWithID> i = cookies.iterator(); i.hasNext();) {
CookieWithID cwi = i.next();
Cookie cookie = cwi.cookie;
// Check match host or has expired
if (domainMatch(cookie, host) || hasExpired(cookie)) {
// Remove from list
i.remove();
// Remove from DB
CookieDB.removeCookie(cwi.id);
}
}
}
public synchronized void remove(String host) {
for (String key : map.keySet()) {
if (domainMatch(host, key)) {
List<CookieWithID> cookies = map.get(key);
// cookies can not be null
removeInternal(host, cookies);
}
}
}
public synchronized void removeAll() {
map.clear();
CookieDB.removeAllCookies();
}
public synchronized void add(Cookie cookie) {
String domain = cookie.domain();
// Check expired
if (hasExpired(cookie)) {
removeInternal(cookie);
return;
}
List<CookieWithID> cookies = map.get(domain);
if (cookies == null) {
cookies = new ArrayList<>();
map.put(domain, cookies);
} else {
// Remove old cookie
// Remove from list
CookieWithID cwi = removeCookie(cookies, cookie.name());
if (cwi != null) {
// Remove from DB
CookieDB.removeCookie(cwi.id);
}
}
// Add to DB
long id = CookieDB.addCookie(cookie);
// Add to list
cookies.add(new CookieWithID(id, cookie));
}
private void getInternal(HttpUrl url, List<CookieWithID> cookies, List<Cookie> result) {
for (Iterator<CookieWithID> i = cookies.iterator(); i.hasNext();) {
CookieWithID cwi = i.next();
Cookie cookie = cwi.cookie;
// Check expired
if (hasExpired(cookie)) {
// Remove from list
i.remove();
// Remove from DB
CookieDB.removeCookie(cwi.id);
} else if (cookie.matches(url)) {
result.add(cookie);
}
}
}
private Cookie getInternal(HttpUrl url, String name, List<CookieWithID> cookies) {
for (Iterator<CookieWithID> i = cookies.iterator(); i.hasNext();) {
CookieWithID cwi = i.next();
Cookie cookie = cwi.cookie;
// Check expired
if (hasExpired(cookie)) {
// Remove from list
i.remove();
// Remove from DB
CookieDB.removeCookie(cwi.id);
} else if (cookie.name().equals(name) && cookie.matches(url)) {
return cookie;
}
}
return null;
}
@Nullable
public synchronized Cookie get(HttpUrl url, String name) {
String host = url.host();
for (String key : map.keySet()) {
if (domainMatch(host, key)) {
List<CookieWithID> cookies = map.get(key);
return getInternal(url, name, cookies);
}
}
return null;
}
public synchronized List<Cookie> get(HttpUrl url) {
List<Cookie> result = new ArrayList<>();
String host = url.host();
for (String key : map.keySet()) {
if (domainMatch(host, key)) {
List<CookieWithID> cookies = map.get(key);
// cookies can not be null
getInternal(url, cookies, result);
}
}
return Collections.unmodifiableList(result);
}
@Override
public void saveFromResponse(HttpUrl url, List<Cookie> cookies) {
for (Cookie cookie: cookies) {
add(cookie);
}
}
@Override
public List<Cookie> loadForRequest(HttpUrl url, Request request) {
return get(url);
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2016 Hippo Seven
* 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.
@@ -14,17 +14,29 @@
* limitations under the License.
*/
package com.hippo.okhttp;
package com.hippo.util;
/*
* Created by Hippo on 2017/9/4.
*/
import okhttp3.Cookie;
public class HashCodeUtils {
public class CookieWithID {
private static final int X = 31;
public long id;
public Cookie cookie;
public CookieWithID(long id, Cookie cookie) {
this.id = id;
this.cookie = cookie;
/**
* <pre>{@code
* args[0].hashCode()*31^(n-1) + args[1].hashCode()*31^(n-2) + ... + args[n-1].hashCode()
* }</pre>
* Returns 0 if {@code args == null}.
*/
public static int hashCode(Object... args) {
if (args == null) {
return 0;
}
int hash = 0;
for (Object o: args) {
hash = X * hash + (o != null ? o.hashCode() : 0);
}
return hash;
}
}
@@ -69,4 +69,54 @@ public class SqlUtils {
return sb.toString();
}
public static boolean getBoolean(Cursor cursor, String column, boolean defValue) {
try {
int index = cursor.getColumnIndex(column);
if (index != -1) {
return cursor.getInt(index) != 0;
}
} catch (Throwable e) { /* Ignore */ }
return defValue;
}
public static int getInt(Cursor cursor, String column, int defValue) {
try {
int index = cursor.getColumnIndex(column);
if (index != -1) {
return cursor.getInt(index);
}
} catch (Throwable e) { /* Ignore */ }
return defValue;
}
public static long getLong(Cursor cursor, String column, long defValue) {
try {
int index = cursor.getColumnIndex(column);
if (index != -1) {
return cursor.getLong(index);
}
} catch (Throwable e) { /* Ignore */ }
return defValue;
}
public static float getFloat(Cursor cursor, String column, float defValue) {
try {
int index = cursor.getColumnIndex(column);
if (index != -1) {
return cursor.getFloat(index);
}
} catch (Throwable e) { /* Ignore */ }
return defValue;
}
public static String getString(Cursor cursor, String column, String defValue) {
try {
int index = cursor.getColumnIndex(column);
if (index != -1) {
return cursor.getString(index);
}
} catch (Throwable e) { /* Ignore */ }
return defValue;
}
}
@@ -35,6 +35,7 @@ import com.hippo.easyrecyclerview.EasyRecyclerView;
import com.hippo.easyrecyclerview.FastScroller;
import com.hippo.easyrecyclerview.HandlerDrawable;
import com.hippo.easyrecyclerview.LayoutManagerUtils;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.R;
import com.hippo.refreshlayout.RefreshLayout;
import com.hippo.util.DrawableManager;
@@ -856,14 +857,24 @@ public class ContentLayout extends FrameLayout {
}
}
private int mSavedDataId = IntIdGenerator.INVALID_ID;
private Parcelable saveInstanceState(Parcelable superState) {
Bundle bundle = new Bundle();
bundle.putParcelable(KEY_SUPER, superState);
int shownView = mViewTransition.getShownViewIndex();
bundle.putInt(KEY_SHOWN_VIEW, shownView);
bundle.putString(KEY_TIP, mTipView.getText().toString());
// TODO What if data is large
bundle.putParcelableArrayList(KEY_DATA, mData);
// TODO It's a bad design
EhApplication app = (EhApplication) getContext().getApplicationContext();
if (mSavedDataId != IntIdGenerator.INVALID_ID) {
app.removeGlobalStuff(mSavedDataId);
mSavedDataId = IntIdGenerator.INVALID_ID;
}
mSavedDataId = app.putGlobalStuff(mData);
bundle.putInt(KEY_DATA, mSavedDataId);
bundle.putInt(KEY_NEXT_ID, mIdGenerator.nextId());
bundle.putParcelable(KEY_PAGE_DIVIDER, mPageDivider);
bundle.putInt(KEY_START_PAGE, mStartPage);
@@ -877,7 +888,17 @@ public class ContentLayout extends FrameLayout {
Bundle bundle = (Bundle) state;
mViewTransition.showView(bundle.getInt(KEY_SHOWN_VIEW), false);
mTipView.setText(bundle.getString(KEY_TIP));
mData = bundle.getParcelableArrayList(KEY_DATA);
mSavedDataId = bundle.getInt(KEY_DATA);
EhApplication app = (EhApplication) getContext().getApplicationContext();
if (mSavedDataId != IntIdGenerator.INVALID_ID) {
ArrayList<E> data = (ArrayList<E>) app.removeGlobalStuff(mSavedDataId);
mSavedDataId = IntIdGenerator.INVALID_ID;
if (data != null) {
mData = data;
}
}
mIdGenerator.setNextId(bundle.getInt(KEY_NEXT_ID));
mPageDivider = bundle.getParcelable(KEY_PAGE_DIVIDER);
mStartPage = bundle.getInt(KEY_START_PAGE);
Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,0.0C8.96,0.0 0.0,8.95 0.0,20.0s8.96,20.0 20.0,20.0c11.04,0.0 20.0,-8.95 20.0,-20.0S31.04,0.0 20.0,0.0z"
android:fillColor="#F4511E"/>
<path
android:pathData="M21.33,29.33l-2.67,0.0l0.0,-2.67l2.67,0.0L21.33,29.33zM21.33,22.67l-2.67,0.0l0.0,-12.0l2.67,0.0L21.33,22.67z"
android:fillColor="#FFFFFF"/>
</vector>
+28
View File
@@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 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
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,20.0m-20.0,0.0a20.0,20.0 0.0,1.0 1.0,40.0 0.0a20.0,20.0 0.0,1.0 1.0,-40.0 0.0"
android:fillColor="#009688"/>
<path
android:pathData="M11.2,21.41l1.63,-1.619999 4.17,4.169998 10.59,-10.589999 1.619999,1.63 -12.209999,12.209999z"
android:fillColor="#FFFFFF"/>
</vector>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

+9
View File
@@ -40,6 +40,15 @@
android:layout_height="0dp"
android:layout_weight="1"/>
<CheckBox
android:id="@+id/fingerprint_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:visibility="gone"
android:text="@string/enable_fingerprint" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/buttonPanel"
+9
View File
@@ -51,6 +51,15 @@
</com.hippo.widget.MaxSizeContainer>
</FrameLayout>
<CheckBox
android:id="@+id/fingerprint_checkbox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="20dp"
android:visibility="gone"
android:text="@string/enable_fingerprint" />
<LinearLayout
android:id="@+id/buttonPanel"
android:layout_width="match_parent"
@@ -92,13 +92,33 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="ipb_pass_hash"
android:imeOptions="actionDone"
android:imeOptions="actionNext"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="@+id/igneous_layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:minWidth="@dimen/single_max_width">
<android.support.design.widget.TextInputEditText
android:id="@+id/igneous"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="igneous"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"
tools:ignore="HardcodedText" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</ScrollView>
</com.hippo.widget.MaxSizeContainer>
+28 -1
View File
@@ -71,13 +71,40 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/password"
android:imeOptions="actionDone"
android:imeOptions="actionNext"
android:inputType="textPassword"
android:maxLines="1"
android:singleLine="true"/>
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.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.support.design.widget.TextInputEditText
android:id="@+id/recaptcha"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="@string/recaptcha"
android:imeOptions="actionDone"
android:inputType="text"
android:maxLines="1"
android:singleLine="true"/>
</android.support.design.widget.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"/>
<android.support.v4.widget.Space
android:layout_width="wrap_content"
android:layout_height="0dp"
+19 -4
View File
@@ -27,12 +27,27 @@
android:layout_gravity="center"
android:layout_margin="32dp"
app:maxWidth="320dp"
app:maxHeight="320dp">
app:maxHeight="360dp">
<com.hippo.widget.lockpattern.LockPatternView
android:id="@+id/pattern_view"
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
android:orientation="vertical">
<com.hippo.widget.lockpattern.LockPatternView
android:id="@+id/pattern_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<ImageView
android:id="@+id/fingerprint_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_fp_40px"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</LinearLayout>
</com.hippo.widget.MaxSizeContainer>
</FrameLayout>
+622
View File
@@ -0,0 +1,622 @@
<?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.
-->
<resources>
<string name="app_name">EhViewer</string>
<!-- Category -->
<string name="homepage">Página de inicio</string>
<string name="whats_hot">Destacado</string>
<string name="favourite">Favoritos</string>
<string name="history">Historial</string>
<string name="downloads">Descargas</string>
<string name="settings">Configuraciones</string>
<string name="username">Usuario</string>
<string name="password">Contraseña</string>
<string name="sign_in">Iniciar sesión</string>
<string name="register">Registrarse</string>
<string name="sign_in_via_webview">Iniciar sesión vía WebView</string>
<string name="sign_in_via_cookies">Iniciar sesión vía cookies</string>
<string name="display_name_dialog_title">Ingresa un nombre para mostrar</string>
<string name="display_name">Nombre para mostrar</string>
<string name="display_name_is_empty">El nombre a mostrar esta vacío</string>
<string name="sign_in_first">Primero debes iniciar sesión</string>
<string name="default_display_name">Little Hippo</string>
<string name="cookie_explain">Un cookie es una pequeña pieza de datos almacenados en el navegador web. Busque si no conoce lo que es o cómo obtenerlo.\n\nPor favor ingrese cookies especiales para iniciar sesión.</string>
<string name="text_is_empty">El texto esta vacío</string>
<string name="waring">Advertencia.</string>
<string name="wrong_cookie_warning">Parece que las cookies que ingresaste son erróneas. Debe revisarlos.</string>
<string name="i_will_check_it">Comprobar ahora</string>
<string name="i_dont_think_so">No lo creo</string>
<string name="found_cookies">¡Cookies encontradas!</string>
<string name="invalid_download_location">Parece que la ubicación de descarga no está disponible. Configure esta opción en configuraciones.</string>
<string name="cellular_network_warning">Conectado a redes móviles</string>
<string name="error_bad_status_code">Bad status code: %d</string>
<string name="error_timeout">Sin tiempo</string>
<string name="error_unknown_host">Host desconocido</string>
<string name="error_redirection">Demasiadas redirecciones</string>
<string name="error_socket">Error de Red</string>
<string name="error_unknown">Raro</string>
<string name="error_cant_find_activity">No se encuentra la aplicación</string>
<string name="error_cannot_parse_the_url">No se puede analizar el URL</string>
<string name="error_not_folder_path">Sin ruta del directorio</string>
<string name="error_no_provider">Sin proveedor</string>
<string name="error_decoding_failed">Decodificacion fallida</string>
<string name="error_not_found">No encontrado</string>
<string name="error_empty">Vacio</string>
<string name="error_invalid_zip_file">Archivo ZIP invalido</string>
<string name="error_reading_failed">Lectura Fallida</string>
<string name="error_out_of_range">Fuera de rango</string>
<string name="error_write_failed">Falla en la escritura</string>
<string name="error_parse_error">Análisis erróneo</string>
<string name="error_509">509</string>
<string name="error_invalid_url">Url invalida</string>
<string name="error_get_ptoken_error">Error al obtener token</string>
<string name="error_invalid_specify_gallery">Keyword should looks like \"618395 0439fa3666\" for specify gallery</string>
<string name="error_cant_create_temp_file">Imposible crear archivo temporal.</string>
<string name="error_cant_save_image">Imposible guardar la imagen</string>
<string name="error_invalid_number">Numero invalido</string>
<string name="app_waring">The content of this application is from the Internet. Some of it may do physical or mental harm to you. You have learnt the risks above and would like to undertake them.</string>
<string name="error_username_cannot_empty">El usuario no puede estar vacío</string>
<string name="skip_signing_in">Saltar inicio de sesión</string>
<string name="sign_in_failed">Inicio de sesión fallido</string>
<string name="sign_in_failed_plain">Tal ves sea debido a un error de actualización de el sitio web o algo mal sucedió.Pude intentar iniciar sesión vía WebView, ingresar una cookie o saltar el inicio de sesión presionando el boton de abajo.\nPero pude salir un \"Panda Triste\" después de saltar el inicio de sesión. Intente \"Ingresar via cookies\" primero si ha iniciado sesión en la versión 0.6.x de HeViewer.</string>
<string name="press_twice_exit">Presione una ves más para salir</string>
<string name="content_layout_restore_tip">Click para reintentar</string>
<string name="write_rationale">EhViewer solicitara el permiso WRITE_EXTERNAL_STORAGE para descargar galerías. ¿Desea conceder el permiso?</string>
<string name="you_rejected_me">Duele</string>
<string name="analytics_explain">Would you mind if the developer collected your device information and your usage? It will help the developer a lot.&lt;br&gt;&lt;br&gt;Data analysis service is provided by Google Analytics. Its privacy policy can be found at &lt;a href=&quot;https://www.google.com/policies/privacy/&quot;&gt;https://www.google.com/policies/privacy/&lt;/a&gt;.&lt;br&gt;&lt;br&gt;If you agree to join data analysis, your device information and your usage will be collected, including but not limited to Android API version, equipment model, language residence, the application version, conversion time, function times. The developer promise that these information will NOT be collected, including phone number, e-mail address, IMEI.&lt;br&gt;&lt;br&gt;Your information will not be collected until you agree to join data analysis.&lt;br&gt;&lt;br&gt;The collected information will be analyzed by Google Analytics. The analysis report can only be viewed by the developer of this application.</string>
<string name="get_it">Lo tengo</string>
<string name="accept">Aceptar</string>
<string name="reject">Rechazar</string>
<!-- Crash -->
<string name="send">Enviar</string>
<string name="crash_explain">Esta aplicación se crasheó la ultima vez. ¿Desea enviarle un logcat al desarrollador para una mejor experiencia en el futuro? (vía e-mail)</string>
<!-- Select scene -->
<string name="select_scene">¿Qué galería quiere seleccionar?</string>
<string name="select_scene_explain">e-hentai: Disponible para cualquier persona.\nexhentai: Solo para usuarios que iniciaron sesión.</string>
<string name="no_select">Por favor selecciona un sitio</string>
<!-- Update -->
<string name="update">Actualizar.</string>
<string name="update_plain">Versión: %1$s\nSize: %2$s\n\n%3$s</string>
<string name="update_to_date">EhViewer esta actualizado</string>
<!-- Gallery List -->
<string name="gallery_list_search_bar_hint_exhentai">Buscar ExHentai</string>
<string name="gallery_list_search_bar_hint_e_hentai">Buscar E-Hentai</string>
<string name="gallery_list_empty_hit">El Mundo es Grande y el panda está sentado solo</string>
<string name="search">Buscar</string>
<string name="keyword_search">Búsqueda por palabras clave</string>
<string name="image_search">Búsqueda de Imagen</string>
<string name="search_normal">Búsqueda Normal</string>
<string name="search_advance">Opciones Avanzadas</string>
<string name="search_image">Búsqueda de Imágenes</string>
<string name="search_normal_search">Búsqueda General</string>
<string name="search_specify_uploader">Uploader específicos</string>
<string name="search_specify_tag">Etiquetas especificas</string>
<string name="search_specify_gallery">Galerías Especificas</string>
<string name="search_enable_advance">Habilitar opciones avanzadas</string>
<string name="search_tip">Búsqueda Normal: Solo busca.\n\nUploader Especifico: Lista de galerías que subió el uploader. Otras opciones serán ignoradas.\n\nSpecify tag: List galleries which contains the tag. Only one tag accepted. Otras opciones serán ignoradas.\n\nGaleria Especifica: Ir a la Galería. La palabra clave debe ser \"gid token\".</string>
<string name="search_sname">Buscar Galerías</string>
<string name="search_stags">Buscar Etiquetas de Galerías</string>
<string name="search_sdesc">Buscar Descripción de Galería</string>
<string name="search_storr">Buscar por Nombres de Torrent</string>
<string name="search_sto">Mostrar Solo Galerías con Torrents</string>
<string name="search_sdt1">Buscar Etiquetas Low-Power</string>
<string name="search_sdt2">Buscar etiquetas pobres</string>
<string name="search_sh">Mostrar Galerías Borradas</string>
<string name="search_sr">Valoración Mínima:</string>
<string name="select_image">Seleccionar Imagen</string>
<string name="search_uss">Usar búsqueda similar</string>
<string name="search_osc">Buscar solo portadas</string>
<string name="search_se">Mostrar Borrados</string>
<string name="select_image_first">Seleccione la imagen primero</string>
<string name="quick_search">Búsqueda Rápida</string>
<string name="quick_search_tip">Clic \"+\" para añadir a la búsqueda rápida</string>
<string name="add_quick_search_dialog_title">Añadir Búsqueda Rápida</string>
<string name="name_is_empty">Nombre vacío</string>
<string name="delete_quick_search_title">Eliminar Búsqueda Rápida</string>
<string name="delete_quick_search_message">Eliminar \"%s\"?</string>
<string name="no_quick_search">La búsqueda rápida se muestra acá</string>
<string name="add_quick_search_tip">El estado de la lista de galerías se guardara como búsqueda rápida. Aplique la búsqueda primero si usted desea guardar el estado del panel de búsqueda.</string>
<string name="readme">LEEME</string>
<string name="image_search_not_quick_search">No se puede añadir la búsqueda por imágenes la la búsqueda rápida</string>
<string name="duplicate_quick_search">Búsqueda rápida duplicada. El nombre es \"%s\".</string>
<string name="duplicate_name">Nombre duplicado existente</string>
<string name="go_to_hint">Pagina %1$d, total %2$d paginas</string>
<!-- search_min_rating -->
<string name="star_2">2 stars</string>
<string name="star_3">3 stars</string>
<string name="star_4">4 stars</string>
<string name="star_5">5 stars</string>
<!-- Gallery detail -->
<string name="error_cannot_find_gallery">No se encuentra la galería</string>
<string name="download">Descargas</string>
<string name="read">Leer</string>
<string name="more_information">Más información</string>
<plurals name="page_count">
<item quantity="one">%d page</item>
<item quantity="other">%d pages</item>
</plurals>
<string name="favored_times">\u2665 %d</string>
<string name="rating_text">%1$s (%2$.2f, %3$d)</string>
<string name="favorites">Favoritos</string>
<string name="torrent_count">Torrent (%d)</string>
<string name="share">Compartir</string>
<string name="rate">Valorar</string>
<string name="similar_gallery">Similar</string>
<string name="search_cover">Buscar Portada</string>
<string name="no_tags">Sin etiquetas</string>
<string name="no_comments">Sin comentarios</string>
<string name="no_more_comments">No hay más comentarios</string>
<string name="more_comment">Más comentarios</string>
<string name="no_previews">Sin vistas previas</string>
<string name="no_more_previews">No hay más vistas previas</string>
<string name="more_previews">Más vistas previas</string>
<string name="refresh">Refrescar</string>
<string name="open_in_other_app">Abrir en otra app</string>
<string name="rate_successfully">Valoración Completada</string>
<string name="rate_failed">Valoración fallida</string>
<string name="no_torrents">Sin torrents</string>
<string name="torrents">Torrents</string>
<string name="favorited">Favorito</string>
<string name="not_favorited">Sin favoritos</string>
<string name="add_favorites_dialog_title">Añadir a Favoritos</string>
<string name="remember_favorite_collection">Recordar Favoritos</string>
<string name="remove_from_favorite_success">Eliminado de favoritos</string>
<string name="add_to_favorite_failure">No se a podido agregar a favoritos</string>
<string name="remove_from_favorite_failure">Error al borrar de favoritos</string>
<string name="block_the_uploader">Añadir el cargador \"%s\" a la lista de filtros?</string>
<string name="filter_added">Filtro añadido</string>
<!-- Rating -->
<string name="rating10">PIEZA MAESTRA</string>
<string name="rating9">INGREIBLE</string>
<string name="rating8">GRANDIOSO</string>
<string name="rating7">BUENO</string>
<string name="rating6">OKAY</string>
<string name="rating5">MEDIOCRE</string>
<string name="rating4">MALO</string>
<string name="rating3">HORRIBLE</string>
<string name="rating2">DOLOROSO</string>
<string name="rating1">INAGUANTABLE</string>
<string name="rating0">DESASTRE</string>
<!-- Gallery Info -->
<string name="gallery_info">Información de la Galería</string>
<string name="copied_to_clipboard">Copiado al portapapeles</string>
<string name="header_key">Clave</string>
<string name="header_value">Valor</string>
<string name="key_gid">Guía</string>
<string name="key_token">Clave</string>
<string name="key_url">Url</string>
<string name="key_title">Título</string>
<string name="key_title_jpn">Título Japonés</string>
<string name="key_thumb">Thumb</string>
<string name="key_category">Categoría</string>
<string name="key_uploader">Uploader</string>
<string name="key_posted">Publicado</string>
<string name="key_parent">Padre</string>
<string name="key_visible">Visible</string>
<string name="key_language">Lenguaje</string>
<string name="key_pages">Paginas</string>
<string name="key_size">Tamaño</string>
<string name="key_favorite_count">Número de favoritos</string>
<string name="key_favorited">Favorito</string>
<string name="key_rating_count">Número de Valoraciones</string>
<string name="key_rating">Rating</string>
<string name="key_torrents">Torrents</string>
<string name="key_torrent_url">Url de Torrent</string>
<!-- Gallery Comments -->
<string name="gallery_comments">Comentarios de la Galería</string>
<string name="no_one_comments_gallery">Sin comentarios en esta galería</string>
<string name="comment_successfully">Comentario exitoso</string>
<string name="copy_comment_text">Copiar el texto del comentario</string>
<string name="vote_up">Voto positivo</string>
<string name="cancel_vote_up">Cancelar voto positivo</string>
<string name="vote_down">Voto negativo</string>
<string name="vote_up_successfully">Voto positivo completado</string>
<string name="cancel_vote_up_successfully">Voto positivo cancelado satisfactoriamente</string>
<string name="vote_down_successfully">Vote negativo completado</string>
<string name="cancel_vote_down_successfully">Voto negativo cancelado satisfactoriamente</string>
<string name="vote_failed">Voto fallido</string>
<string name="check_vote_status">Verificar estado del voto</string>
<!-- Gallery Previews -->
<string name="gallery_previews">Vista previa de la galeria</string>
<string name="go_to">Ir a</string>
<!-- Download -->
<string name="scene_download_title">Descargar - %s</string>
<string name="no_download_info">Las descargas de archivos se mostraran acá</string>
<string name="download_state_wait">Esperando</string>
<string name="download_state_downloading">Descargando</string>
<string name="download_state_downloaded">Descargado</string>
<string name="download_state_failed_2">%d incompleto</string>
<string name="download_state_finish">Completada</string>
<string name="stat_509_alert_title">Alerta 509</string>
<string name="stat_509_alert_text">Limite de imagen alcanzado. Por favor deje de descargar y espere un poco.</string>
<string name="stat_download_done_title">Descarga Terminada.</string>
<string name="stat_download_done_text_succeeded">%d Completado</string>
<string name="stat_download_done_text_failed">%d fallido</string>
<string name="stat_download_done_text_mix">%1$d completado, %2$d fallido</string>
<string name="stat_download_done_line_succeeded">Completado: %s</string>
<string name="stat_download_done_line_failed">Fallido: %s</string>
<string name="download_remove_dialog_title">Borrar elemento descargado</string>
<string name="download_remove_dialog_message">Borrar %s de la lista de descarga ?</string>
<string name="download_remove_dialog_message_2">Borrar %d elementos de la lista de descarga?</string>
<string name="download_remove_dialog_check_text">Eliminar imágenes</string>
<string name="stat_download_action_stop_all">Detener todo</string>
<string name="drawer_download_label_title">Etiquetas</string>
<string name="default_download_label_name">Predeterminado.</string>
<string name="download_move_dialog_title">Mover</string>
<string name="download_labels">Descargar etiquetas</string>
<string name="download_start_all">Iniciar todo</string>
<string name="download_stop_all">Detener todo</string>
<string name="download_service_label">EhViewer Servicio de Descarga</string>
<string name="download_speed_text">%s</string>
<string name="download_speed_text_2">%1$s, %2$s izquierda</string>
<string name="remember_download_label">Recordar descargas</string>
<string name="default_download_label">Etiqueta predeterminada de descarga</string>
<string name="added_to_download_list">Añadido a la lista de descargas</string>
<!-- Download label -->
<string name="no_download_label">Las etiquetas de descarga se mostraran acá</string>
<string name="add">Añadir</string>
<string name="new_label_title">Nueva etiqueta</string>
<string name="label_text_is_empty">Nombre de la etiqueta vacia</string>
<string name="label_text_is_invalid">\"Defecto\" Es una etiqueta invalida</string>
<string name="label_text_exist">Etiqueta existente</string>
<string name="rename_label_title">Renombrar etiqueta</string>
<string name="delete_label_title">Eliminar etiqueta</string>
<string name="delete_label_message">Eliminar \"%s\"?</string>
<!-- History -->
<string name="no_history">El historial de lectura esta acá</string>
<string name="clear_all_history">Limpiar todo el historial?</string>
<!-- Filter -->
<string name="filter">Filtros</string>
<string name="no_filter">Los filtros se mostrarán acá</string>
<string name="filter_title">Titulo</string>
<string name="filter_uploader">Uploader</string>
<string name="filter_tag">Tag</string>
<string name="filter_tag_namespace">Tag namespace</string>
<string name="delete_title_filter">Eliminar filtro de titulo \"%s\"?</string>
<string name="delete_uploader_filter">Eliminar filtros de uploader \"%s\"?</string>
<string name="delete_tag_filter">Eliminar filtro de etiquetas \"%s\"?</string>
<string name="delete_filter">Eliminar filtro \"%s\"?</string>
<string name="tip">Tip</string>
<string name="add_filter">Añadir Filtros</string>
<string name="show_definition">Mostrar definicion</string>
<string name="filter_text">Filter text</string>
<string name="filter_tip">Title Filter: exclude the gallery whose title contains the word.\n\nUploader Filter: exclude the gallery which was uploaded by the uploader.\n\nTag Filter: exclude the gallery which contain the tag, it takes more time to get gallery list.\n\nTag Namespace Filter: exclude the gallery which contain the tag namespace, it takes more time to get gallery list.</string>
<!-- Set Security -->
<string name="set_pattern_protection">Establecer protección por patrón</string>
<string name="set_pattern_protection_tip">Dibuje un patrón para establecer la protección por patrón. \nDejar en blanco para quitar la protección por patrón.</string>
<string name="set">Establecer</string>
<!-- Gallery Activity -->
<string name="page_menu_title">Pagina %d</string>
<string name="page_menu_refresh">@string/refresh</string>
<string name="page_menu_share">@string/share</string>
<string name="page_menu_save">Guardar</string>
<string name="page_menu_add_bookmark">Añadir a marcadores</string>
<string name="gallery_menu_title">Menú</string>
<string name="share_image">Compartir imagen</string>
<string name="image_saved">Imagen guardada en %s</string>
<string name="settings_eh">EH</string>
<string name="settings_eh_sign_out">Cerrar sesión.</string>
<string name="settings_eh_sign_out_summary">Reiniciar la aplicación para inicia sesion</string>
<string name="settings_eh_sign_out_warning">¿Esta seguro de cerrar sesión?</string>
<string name="settings_eh_sign_out_yes">@android:string/ok</string>
<string name="settings_eh_sign_out_tip">Sesión cerrada. Reinicie la aplicación para iniciar sesión</string>
<string name="settings_eh_gallery_site">Sitio de la Galería</string>
<string name="settings_eh_list_mode">Modo de Lista</string>
<string name="settings_eh_list_mode_detail">Detallado</string>
<string name="settings_eh_list_mode_thumb">Vista previa</string>
<string name="settings_eh_detail_size">Detalles de tamaño</string>
<string name="settings_eh_detail_size_long">Largo</string>
<string name="settings_eh_detail_size_short">Corto</string>
<string name="settings_eh_thumb_size">Tamaño de vista previa</string>
<string name="settings_eh_thumb_size_large">Largo</string>
<string name="settings_eh_thumb_size_middle">Medio</string>
<string name="settings_eh_thumb_size_small">Pequeño</string>
<string name="settings_eh_thumb_resolution">Resolución de vista previa</string>
<string name="settings_eh_thumb_resolution_summary">%s, las resoluciones especiales podrían causar errores en la vista previa</string>
<string name="settings_eh_thumb_resolution_auto">Auto</string>
<string name="settings_eh_fix_thumb_url">Reparar URL de vistas previas</string>
<string name="settings_eh_default_categories">Categorías en la página de inicio</string>
<string name="settings_eh_default_categories_summary">Las categorías que se muestran en la página de inicio por defecto.</string>
<string name="settings_eh_excluded_languages">Idiomas excluidos</string>
<string name="settings_eh_excluded_languages_summary">Ocultar galerías en ciertos idiomas de las búsquedas y la lista de galerías</string>
<string name="settings_eh_excluded_tag_namespaces">Excluir etiquetas variables</string>
<string name="settings_eh_excluded_tag_namespaces_summary">Excluir ciertas variables de una búsqueda de etiquetas por defecto</string>
<string name="settings_eh_hath_proxy">H@H proxy</string>
<string name="settings_eh_hath_proxy_summary_1">%1$s %2$s:%3$d</string>
<string name="settings_eh_hath_proxy_summary_2">Sin Establecer</string>
<string name="settings_eh_show_jpn_title">Mostrar titulo en japonés</string>
<string name="settings_eh_show_jpn_title_summary_on">Intentar mostrar titulo en japonés. Pude tomar más tiempo en cargar la lista de galerías</string>
<string name="settings_eh_show_jpn_title_summary_off">Mostrar titulo por defecto, usualmente es en ingles</string>
<string name="settings_eh_filter">Filtros</string>
<string name="settings_eh_filter_summary">Filtrar por titulo, uploader,etiqueta y etiquetas variables</string>
<string name="settings_eh_cellular_network_warning">Advertencia de redes moviles</string>
<string name="settings_read">Leer</string>
<string name="settings_read_screen_rotation">Orientación de la pantalla</string>
<string name="settings_read_screen_rotation_default">Defecto</string>
<string name="settings_read_screen_rotation_portrait">Retrato</string>
<string name="settings_read_screen_rotation_landscape">Paisaje</string>
<string name="settings_read_reading_direction">Dirección de lectura</string>
<string name="settings_read_reading_direction_left_to_right">Izquierda a Derecha</string>
<string name="settings_read_reading_direction_right_to_Left">Derecha a Izquierda</string>
<string name="settings_read_reading_direction_top_to_bottom">Arriba hacia Abajo</string>
<string name="settings_read_page_scaling">Escala de pagina</string>
<string name="settings_read_page_scaling_actual_size">Tamaño actual</string>
<string name="settings_read_page_scaling_fit_to_width">Ajustar a lo ancho</string>
<string name="settings_read_page_scaling_fit_to_height">Ajustar a la altura</string>
<string name="settings_read_page_scaling_fit_to_screen">Ajustar a la pantalla</string>
<string name="settings_read_page_scaling_fixed_scale">Escala fija</string>
<string name="settings_read_start_position">Posición de inicio</string>
<string name="settings_read_start_position_top_left">Arriba a la izquierda</string>
<string name="settings_read_start_position_top_right">Abajo a la derecha</string>
<string name="settings_read_start_position_bottom_left">Abajo a la izquierda</string>
<string name="settings_read_start_position_bottom_right">Abajo a la derecha</string>
<string name="settings_read_start_position_center">Centro</string>
<string name="settings_read_keep_screen_on">Pantalla siempre encendida</string>
<string name="settings_read_show_clock">Mostrar hora</string>
<string name="settings_read_show_progress">Mostrar progreso</string>
<string name="settings_read_show_battery">Mostrar batería</string>
<string name="settings_read_volume_page">Usar teclas de volumen para pasar paginas</string>
<string name="settings_read_reading_fullscreen">Pantalla Completa</string>
<string name="settings_read_custom_screen_lightness">Brillo de pantalla personalizado</string>
<string name="settings_read_screen_lightness">Brillo de la pantalla</string>
<string name="settings_download">Descargas</string>
<string name="settings_download_download_location">Localización de descargas</string>
<string name="settings_download_invalid_download_location">Ruta de descarga invalida</string>
<string name="settings_download_cant_get_download_location">No se puede obtener ruta de descargas</string>
<string name="settings_download_pick_dir_kk">No puedes escribir ningún tipo de datos en tu memoria SD externa en Android 4.4+ a no ser que la hayas hakeado. Pero &lt;SD card&gt;/Android/data/com.hippo.ehviewer es especial, puedes escribir en ello.</string>
<string name="settings_download_pick_dir_l">Anroid 5.0+ proporciona una nueva API para escribir en una tarjeta SD externa. Haga click en el boton \"DOCUMENT\" si desea establecer la ruta de descarga en una tarjeta SD.</string>
<string name="settings_download_document">Document</string>
<string name="settings_download_continue">Continuar</string>
<string name="settings_download_media_scan">Permitir escaneo de medios</string>
<string name="settings_download_media_scan_summary_on">Por favor mantenga sus aplicaciones de galeria lejor de otras personas (si no quiere que vean sus descargas)</string>
<string name="settings_download_media_scan_summary_off">Las aplicaciones de galería de imágenes ignoraran la ruta de descargas de galerías</string>
<string name="settings_download_multi_thread_download">Multi hilos al descargar</string>
<string name="settings_download_multi_thread_download_summary">Máximo de %s imágenes</string>
<string name="settings_download_preload_image">Precargar Imagen</string>
<string name="settings_download_preload_image_summary">Precargar las siguientes %s imágenes</string>
<string name="settings_download_image_resolution">Resolución de la imagen</string>
<string name="settings_download_image_resolution_summary">%s, resoluciones mayores a 1280x podrían no funcionar</string>
<string name="settings_download_image_resolution_auto">Auto</string>
<string name="settings_download_download_origin_image">Descargar imagen original</string>
<string name="settings_download_download_origin_image_summary">Es peligroso! Puede obtener el error 509</string>
<string name="settings_download_restore_download_items">Restaurar los elementos de descarga</string>
<string name="settings_download_restore_download_items_summary">Restaurar todos los elementos de descarga en la ubicación de descarga</string>
<string name="settings_download_restoring">Restaurando...</string>
<string name="settings_download_restore_not_found">No se han encontrado elementos para restaurar</string>
<string name="settings_download_restore_failed">restauración fallida</string>
<string name="settings_download_restore_successfully">Restauración de %d elementos completados</string>
<string name="settings_download_clean_redundancy">Borrar descargas redundantes</string>
<string name="settings_download_clean_redundancy_summary">Eliminar galería de imágenes si no esta en la lista de descargas pero si en la direccion de descargas</string>
<string name="settings_download_clean_redundancy_no_redundancy">Sin redundancia</string>
<string name="settings_download_clean_redundancy_done">Borrado de redundancia completado, Borrados %d elemtos totales</string>
<string name="settings_advanced">Avanzado</string>
<string name="settings_advanced_save_parse_error_body">Guardar contenido en HTML al analizar el error</string>
<string name="settings_advanced_save_parse_error_body_summary">El contenido HTML puede ser sensible a la privacidad</string>
<string name="settings_advanced_dump_logcat">Dump logcat</string>
<string name="settings_advanced_dump_logcat_summary">Guardar logcat en almacenamiento externo</string>
<string name="settings_advanced_dump_logcat_failed">Dump logcat fallado</string>
<string name="settings_advanced_dump_logcat_to">Logcat guardado en %s</string>
<string name="settings_advanced_clear_download_path_cache">Borrar cache de la ruta de descarga</string>
<string name="settings_advanced_clear_download_path_cache_summary">Gallery download path might be wrong and it need to be redownload. Clearing download path cache might solve the problem.</string>
<string name="settings_advanced_clear_download_path_cache_message">Borrar cache de la ruta de descarga?</string>
<string name="settings_advanced_clear_memory_cache">Borrar cache de memoria</string>
<string name="settings_advanced_clear_memory_cache_summary">Borrar vistas previas, galerías, información y cache de memoria</string>
<string name="settings_advanced_read_cache_size">Leer el tamaño de la caché</string>
<string name="settings_advanced_pattern_protection_title">Protección por patrón</string>
<string name="settings_advanced_pattern_protection_not_set">No se ha configurado la protección por patrón</string>
<string name="settings_advanced_pattern_protection_set">La protección por patrón ha sido configurado</string>
<string name="settings_advanced_export_data">Exportar datos</string>
<string name="settings_advanced_export_data_summary">Guardar datos en almacenamiento externo, tales como la lista de descarga, lista de búsqueda raida, etc</string>
<string name="settings_advanced_export_data_to">Datos exportados en %s</string>
<string name="settings_advanced_export_data_failed">Exportación de datos fallado</string>
<string name="settings_advanced_import_data">importar datos</string>
<string name="settings_advanced_import_data_summary">Cargar datos guardados anteriormente</string>
<string name="settings_advanced_import_data_successfully">Importación de datos completo</string>
<string name="settings_about">Acerca de</string>
<string name="settings_about_author">Autor</string>
<string name="settings_about_google_plus">Comunidad en Google+</string>
<string name="settings_about_website">PaginaWeb</string>
<string name="settings_about_source">Código Fuente</string>
<string name="settings_about_changelog">Registro de Cambios.</string>
<string name="settings_about_help">Ayuda</string>
<string name="settings_about_license">Licencia</string>
<string name="settings_about_license_summary">EhViewer es posible gracias a varios proyectos de código abierto</string>
<string name="settings_about_donate">Donar</string>
<string name="settings_about_donate_summary">Alipay: seven332$163.com</string>
<string name="settings_about_donate_message">Tu donación me ayuda a desarrollar más y mejores aplicaciones.\n\nAlipay: seven332$163.com</string>
<string name="settings_about_donate_toast">Email copiado al portapapeles</string>
<string name="settings_about_enable_analytics">Habilitar analytics</string>
<string name="settings_about_about_analytics">Acerca de analytics</string>
<string name="settings_about_version">Versión de compilación</string>
<string name="settings_about_check_for_updates">Verificar actualizaciones.</string>
<string name="settings_about_beta_update_channel">Canal de actualizaciones Beta</string>
<string name="settings_about_beta_update_channel_summary">Las versiones beta pueden fallar en tu dispositivo.</string>
<string name="enable">Habilitar</string>
<string name="enabled">Habilitado</string>
<string name="ip">IP</string>
<string name="port">Puerto</string>
<string name="Passkey">Clave Maestra</string>
<string name="domain_not_supported">Dominio no soportado</string>
<string name="invalid_port">Puerto Invalido</string>
<string name="cant_get_data_dir">No se puede obtener el directorio de datos</string>
<string name="cant_find_any_data">No se pueden encuentran datos</string>
<string name="cant_read_the_file">No se puede leer el archivo</string>
<!-- ExcludedLanguagesScene -->
<string name="excluded_languages">Excluir idiomas</string>
<string name="select_all">Seleccionar todo</string>
<string name="deselect_all">Ninguno</string>
<string name="invert_selection">Invertir</string>
<string name="language">Idioma</string>
<string name="original">Original</string>
<string name="translated">Traducido</string>
<string name="rewrite">Reescribir</string>
<string name="language_japanese">Japones</string>
<string name="language_english">ingles</string>
<string name="language_chinese">Chino</string>
<string name="language_dutch">Holandés</string>
<string name="language_french">Francés</string>
<string name="language_german">Alemán</string>
<string name="language_hungarian">Húngaro</string>
<string name="language_italian">Italiano</string>
<string name="language_korean">Coreano</string>
<string name="language_polish">Polaco</string>
<string name="language_portuguese">Portugués</string>
<string name="language_russian">Ruso</string>
<string name="language_spanish">Español</string>
<string name="language_thai">Tailandes</string>
<string name="language_vietnamese">Vietnamita</string>
<string name="language_na">N/A</string>
<string name="language_other">Otros</string>
<string name="please_wait">Espere</string>
<!-- License -->
<string name="license">Licencia</string>
<!-- Dir Picker-->
<!-- Favorites -->
<string name="cloud_favorites">Favoritos en la nube</string>
<string name="local_favorites">Favoritos Locales</string>
<string name="favorites_search_bar_hint">Buscar %s</string>
<string name="favorites_title">%s</string>
<string name="favorites_title_2">%1$s - %2$s</string>
<string name="delete_favorites_dialog_title">Eliminar de favoritos</string>
<string name="delete_favorites_dialog_message">Eliminar %d Elementos de favoritos?</string>
<string name="move_favorites_dialog_title">Mover favoritos</string>
<string name="default_favorites_collection">Colección de favoritos por defecto</string>
<string name="let_me_select">Permiteme seleccionar</string>
<string name="favorites_info">Información de favoritos</string>
<string name="collections">Colecciones</string>
<string name="need_sign_in">Inicio de sesión requerido</string>
<!-- Progress Scene -->
<!-- Guide -->
<string name="guide_quick_search_title">Búsqueda rápida</string>
<string name="guide_quick_search_text">Desliza a la derecha para abrir el panel de búsqueda rápida</string>
<string name="guide_collections_title">Colecciones</string>
<string name="guide_collections_text">Desliza hacia la derecha para elegir favoritos</string>
<string name="guide_download_labels_title">Descargas</string>
<string name="guide_download_labels_text">Desliza hacia la derecha para abrir el panel de descarga</string>
<string name="guide_download_thumb_title">Detalles de galería</string>
<string name="guide_download_thumb_text">Clic en la imagen para ver detalles de la galería</string>
<string name="guide_gallery_left">Giro de Pagina</string>
<string name="guide_gallery_right">Giro de Pagina</string>
<string name="guide_gallery_menu">Menú</string>
<string name="guide_gallery_progress">Progreso</string>
<string name="guide_gallery_long_click">Clic largo para abrir el menú de pagina</string>
<!-- Readable Time -->
<string name="from_the_future">Desde el futuro</string>
<string name="just_now">Ahora!</string>
<plurals name="some_minutes_ago">
<item quantity="one">A minute ago</item>
<item quantity="other">%d minutes ago</item>
</plurals>
<plurals name="some_hours_ago">
<item quantity="one">An hour ago</item>
<item quantity="other">%d hours ago</item>
</plurals>
<string name="yesterday">Ayer.</string>
<string name="some_days_ago">%d dias atras</string>
<plurals name="second">
<item quantity="one">sec</item>
<item quantity="other">secs</item>
</plurals>
<plurals name="minute">
<item quantity="one">min</item>
<item quantity="other">mins</item>
</plurals>
<plurals name="hour">
<item quantity="one">hour</item>
<item quantity="other">hours</item>
</plurals>
<plurals name="day">
<item quantity="one">day</item>
<item quantity="other">days</item>
</plurals>
<plurals name="year">
<item quantity="one">year</item>
<item quantity="other">years</item>
</plurals>
<string name="no_archives">Sin Archivos</string>
<string name="download_archive_started">Descarga de archivos iniciada</string>
<string name="download_archive_failure">Error al descargar archivo</string>
<string name="download_archive_failure_no_hath">Necesita un cliente H@H para descargar archivo</string>
<string name="add_to_favorite_success">Añadido a favoritos</string>
<string name="add_to_favourites">Agregar a favoritos</string>
<string name="cancel_vote_down">Cancelar voto negativo</string>
<string name="clear_all">Limpiar Todo</string>
<string name="comment_failed">Comentario Fallido</string>
<string name="count">Contar</string>
<string name="archive">Archivo</string>
<string name="delete">Eliminar</string>
<string name="dir_picker">Seleccionar directorio</string>
<string name="directory_not_writable">No se puede escribir en el directorio</string>
<string name="disabled">Deshabilitado</string>
<string name="download_state_failed">Descarga fallida</string>
<string name="download_state_none">Descarga Parada</string>
<string name="error_password_cannot_empty">La contraseña no puede estar vacia</string>
<string name="error_something_wrong_happened">Sucedió algo malo</string>
<string name="dialog_archive_title">H@H Downloader</string>
</resources>
+6
View File
@@ -28,6 +28,11 @@
<string name="username">用户名</string>
<string name="password">密码</string>
<string name="recaptcha">验证码(非必需)</string>
<string name="recaptcha_none">点我</string>
<string name="recaptcha_loading">加载中…</string>
<string name="recaptcha_failure">失败</string>
<string name="sign_in">登录</string>
<string name="register">注册</string>
@@ -341,6 +346,7 @@
<string name="set_pattern_protection">设置图案保护</string>
<string name="set_pattern_protection_tip">绘制图案来设置图案保护\n留空来取消图案保护</string>
<string name="set">设置</string>
<string name="enable_fingerprint">允许使用指纹解锁</string>
<!-- Gallery Activity -->
<string name="page_menu_title">第 %d 页</string>
+6
View File
@@ -28,6 +28,11 @@
<string name="username">用户名</string>
<string name="password">密碼</string>
<string name="recaptcha">驗證碼(非必需)</string>
<string name="recaptcha_none">點我</string>
<string name="recaptcha_loading">加載中…</string>
<string name="recaptcha_failure">失敗</string>
<string name="sign_in">登錄</string>
<string name="register">註冊</string>
@@ -341,6 +346,7 @@
<string name="set_pattern_protection">設置圖案保護</string>
<string name="set_pattern_protection_tip">繪製圖案來設置圖案保護\n留空來取消圖案保護</string>
<string name="set">設置</string>
<string name="enable_fingerprint">允許使用指紋解鎖</string>
<!-- Gallery Activity -->
<string name="page_menu_title">第 %d 頁</string>
+6
View File
@@ -28,6 +28,11 @@
<string name="username">使用者名稱</string>
<string name="password">密碼</string>
<string name="recaptcha">驗證碼(非必需)</string>
<string name="recaptcha_none">點我</string>
<string name="recaptcha_loading">載入中…</string>
<string name="recaptcha_failure">失敗</string>
<string name="sign_in">登入</string>
<string name="register">註冊</string>
@@ -341,6 +346,7 @@
<string name="set_pattern_protection">設定圖案保護</string>
<string name="set_pattern_protection_tip">繪製圖案來設定圖案保護\n留空來取消圖案保護</string>
<string name="set">設定</string>
<string name="enable_fingerprint">允許使用指紋解鎖</string>
<!-- Gallery Activity -->
<string name="page_menu_title">第 %d 頁</string>
+7
View File
@@ -44,6 +44,11 @@
<string name="username">Username</string>
<string name="password">Password</string>
<string name="recaptcha">Recaptcha (Not required)</string>
<string name="recaptcha_none">Click me</string>
<string name="recaptcha_loading">Loading…</string>
<string name="recaptcha_failure">Failed</string>
<string name="sign_in">Sign in</string>
<string name="register">Register</string>
@@ -385,6 +390,7 @@
<string name="set_pattern_protection">Set pattern protection</string>
<string name="set_pattern_protection_tip">Draw a pattern to set pattern protection\nLeave blank to clear pattern protection</string>
<string name="set">Set</string>
<string name="enable_fingerprint">Also allow unlock with fingerprint</string>
<!-- Gallery Activity -->
<string name="page_menu_title">Page %d</string>
@@ -521,6 +527,7 @@
<string name="settings_about">About</string>
<string name="settings_about_author">Author</string>
<string name="settings_about_author_summary" translatable="false">Hippo &lt;ehviewersu$gmail.com&gt;</string>
<string name="settings_about_telegram">Telegram</string>
<string name="settings_about_google_plus">Google+ Community</string>
<string name="settings_about_website">Website</string>
<string name="settings_about_source">Source</string>
+5
View File
@@ -23,6 +23,11 @@
android:key="author"
android:title="@string/settings_about_author"/>
<com.hippo.preference.UrlPreference
android:key="telegram"
android:title="@string/settings_about_telegram"
app:url="https://t.me/ehviewer"/>
<com.hippo.preference.UrlPreference
android:key="google_plus"
android:title="@string/settings_about_google_plus"
@@ -0,0 +1,51 @@
/*
* 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.database;
/*
* Created by Hippo on 2017/9/4.
*/
import static org.junit.Assert.assertEquals;
import java.util.ArrayList;
import java.util.List;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.annotation.Config;
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class MSQLiteBuilderTest {
@Test
public void testGetStatements() {
MSQLiteBuilder builder = new MSQLiteBuilder()
.version(1)
.statement("11")
.statement("12")
.version(3)
.statement("31")
.statement("32");
List<String> list = new ArrayList<>();
list.add("31");
list.add("32");
assertEquals(list, builder.getStatements(1, 3));
}
}
@@ -0,0 +1,336 @@
/*
* 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.network;
/*
* Created by Hippo on 2017/9/4.
*/
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import android.content.Context;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import okhttp3.Cookie;
import okhttp3.HttpUrl;
import org.joor.Reflect;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@Config(manifest = Config.NONE)
@RunWith(RobolectricTestRunner.class)
public class CookieRepositoryTest {
private void equals(CookieSet cookieSet, List<Cookie> cookies) {
assertNotNull(cookieSet);
assertNotNull(cookies);
Map<CookieSet.Key, Cookie> map = Reflect.on(cookieSet).field("map").get();
assertEquals(cookies.size(), map.size());
for (Cookie cookie: cookies) {
assertEquals(cookie, map.get(new CookieSet.Key(cookie)));
}
}
private void equals(List<Cookie> cookies1, List<Cookie> cookies2) {
assertNotNull(cookies1);
assertNotNull(cookies2);
assertEquals(cookies1.size(), cookies2.size());
for (Cookie cookie: cookies1) {
assertTrue(cookies2.contains(cookie));
}
}
@Test
public void testPersistent() {
Context app = RuntimeEnvironment.application;
HttpUrl urlEh = HttpUrl.parse("http://www.ehviewer.com/");
Cookie cookieEh1 = new Cookie.Builder()
.name("user")
.value("1234567890")
.domain("ehviewer.com")
.path("/")
.build();
Cookie cookieEh2 = new Cookie.Builder()
.name("level")
.value("999")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
Cookie cookieEh3 = new Cookie.Builder()
.name("speed")
.value("10")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
HttpUrl urlNMB = HttpUrl.parse("http://h.nimingban.com/");
Cookie cookieNMB = new Cookie.Builder()
.name("hash")
.value("0987654321")
.domain("nimingban.com")
.expiresAt(System.currentTimeMillis() + 100000)
.path("/")
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(urlEh, Arrays.asList(cookieEh1, cookieEh2, cookieEh3));
repository.saveFromResponse(urlNMB, Collections.singletonList(cookieNMB));
Map<String, CookieSet> map = Reflect.on(repository).field("map").get();
assertEquals(3, map.size());
equals(map.get("ehviewer.com"), Collections.singletonList(cookieEh1));
equals(map.get("www.ehviewer.com"), Arrays.asList(cookieEh2, cookieEh3));
equals(map.get("nimingban.com"), Collections.singletonList(cookieNMB));
repository.close();
repository = new CookieRepository(app, "cookie.db");
map = Reflect.on(repository).field("map").get();
assertEquals(2, map.size());
equals(map.get("www.ehviewer.com"), Arrays.asList(cookieEh2, cookieEh3));
equals(map.get("nimingban.com"), Collections.singletonList(cookieNMB));
repository.close();
}
@Test
public void testUpdate() {
Context app = RuntimeEnvironment.application;
HttpUrl urlEh = HttpUrl.parse("http://www.ehviewer.com/");
Cookie cookieEh1 = new Cookie.Builder()
.name("level")
.value("999")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
Cookie cookieEh2 = new Cookie.Builder()
.name("level")
.value("0")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh1));
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh2));
Map<String, CookieSet> map = Reflect.on(repository).field("map").get();
assertEquals(1, map.size());
equals(map.get("www.ehviewer.com"), Collections.singletonList(cookieEh2));
repository.close();
repository = new CookieRepository(app, "cookie.db");
map = Reflect.on(repository).field("map").get();
assertEquals(1, map.size());
equals(map.get("www.ehviewer.com"), Collections.singletonList(cookieEh2));
repository.close();
}
@Test
public void testRemoveByExpired() {
Context app = RuntimeEnvironment.application;
HttpUrl urlEh = HttpUrl.parse("http://www.ehviewer.com/");
Cookie cookieEh1 = new Cookie.Builder()
.name("level")
.value("999")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
Cookie cookieEh2 = new Cookie.Builder()
.name("level")
.value("0")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() - 100000)
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh1));
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh2));
Map<String, CookieSet> map = Reflect.on(repository).field("map").get();
assertEquals(1, map.size());
equals(map.get("www.ehviewer.com"), Collections.<Cookie>emptyList());
repository.close();
repository = new CookieRepository(app, "cookie.db");
map = Reflect.on(repository).field("map").get();
assertEquals(0, map.size());
repository.close();
}
@Test
public void testRemoveByNonPersistent() {
Context app = RuntimeEnvironment.application;
HttpUrl urlEh = HttpUrl.parse("http://www.ehviewer.com/");
Cookie cookieEh1 = new Cookie.Builder()
.name("level")
.value("999")
.domain("www.ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 100000)
.build();
Cookie cookieEh2 = new Cookie.Builder()
.name("level")
.value("0")
.domain("www.ehviewer.com")
.path("/")
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh1));
repository.saveFromResponse(urlEh, Collections.singletonList(cookieEh2));
Map<String, CookieSet> map = Reflect.on(repository).field("map").get();
assertEquals(1, map.size());
equals(map.get("www.ehviewer.com"), Collections.singletonList(cookieEh2));
repository.close();
repository = new CookieRepository(app, "cookie.db");
map = Reflect.on(repository).field("map").get();
assertEquals(0, map.size());
repository.close();
}
@Test
public void testGet() throws InterruptedException {
Context app = RuntimeEnvironment.application;
HttpUrl urlEh1 = HttpUrl.parse("http://www.ehviewer.com/");
HttpUrl urlEh2 = HttpUrl.parse("http://ehviewer.com/");
Cookie cookieEh1 = new Cookie.Builder()
.name("user")
.value("1234567890")
.domain("ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 3000)
.build();
Cookie cookieEh2 = new Cookie.Builder()
.name("level")
.value("999")
.domain("www.ehviewer.com")
.path("/")
.build();
Cookie cookieEh3 = new Cookie.Builder()
.name("speed")
.value("10")
.domain("ehviewer.com")
.path("/")
.build();
HttpUrl urlNMB = HttpUrl.parse("http://h.nimingban.com/");
Cookie cookieNMB = new Cookie.Builder()
.name("hash")
.value("0987654321")
.domain("nimingban.com")
.path("/")
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(urlEh1, Arrays.asList(cookieEh1, cookieEh2));
repository.saveFromResponse(urlEh1, Collections.singletonList(cookieEh3));
repository.saveFromResponse(urlNMB, Collections.singletonList(cookieNMB));
equals(Arrays.asList(cookieEh1, cookieEh3), repository.loadForRequest(urlEh2, null));
Thread.sleep(3000);
equals(Collections.singletonList(cookieEh3), repository.loadForRequest(urlEh2, null));
repository.close();
}
@Test
public void testClear() {
Context app = RuntimeEnvironment.application;
HttpUrl url = HttpUrl.parse("http://www.ehviewer.com/");
Cookie cookie = new Cookie.Builder()
.name("user")
.value("1234567890")
.domain("ehviewer.com")
.path("/")
.expiresAt(System.currentTimeMillis() + 3000)
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(url, Collections.singletonList(cookie));
Map<String, CookieSet> map = Reflect.on(repository).field("map").get();
assertEquals(1, map.size());
equals(map.get("ehviewer.com"), Collections.singletonList(cookie));
repository.clear();
map = Reflect.on(repository).field("map").get();
assertEquals(0, map.size());
repository.close();
repository = new CookieRepository(app, "cookie.db");
map = Reflect.on(repository).field("map").get();
assertEquals(0, map.size());
repository.close();
}
@Test
public void testSort() {
Context app = RuntimeEnvironment.application;
HttpUrl url = HttpUrl.parse("http://www.ehviewer.com/long/long/long/");
Cookie cookie1 = new Cookie.Builder()
.name("user")
.value("1234567890")
.domain("ehviewer.com")
.path("/")
.build();
Cookie cookie2 = new Cookie.Builder()
.name("supersuperme")
.value("99999")
.domain("ehviewer.com")
.path("/long/")
.build();
Cookie cookie3 = new Cookie.Builder()
.name("a")
.value("b")
.domain("ehviewer.com")
.path("/long/long/long/")
.build();
Cookie cookie4 = new Cookie.Builder()
.name("speed")
.value("100")
.domain("ehviewer.com")
.path("/long/long/")
.build();
CookieRepository repository = new CookieRepository(app, "cookie.db");
repository.saveFromResponse(url, Arrays.asList(cookie1, cookie2, cookie3, cookie4));
List<Cookie> list = repository.loadForRequest(url, null);
List<Cookie> expected = Arrays.asList(cookie3, cookie4, cookie2, cookie1);
assertEquals(expected.size(), list.size());
for (int i = 0; i < list.size(); i++) {
assertEquals(expected.get(i), list.get(i));
}
repository.close();
}
}
+17 -1
View File
@@ -6,7 +6,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.github.seven332:android-chinese-string-gradle-plugin:0.1.0'
// NOTE: Do not place your application dependencies here; they belong
@@ -24,3 +24,19 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
ext {
supportLibrary = '25.3.1'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
// Keep all android support library update to date
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex') ) {
details.useVersion "$supportLibrary"
}
}
}
}
@@ -1,58 +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.daogenerator;
import java.io.File;
import de.greenrobot.daogenerator.DaoGenerator;
import de.greenrobot.daogenerator.Entity;
import de.greenrobot.daogenerator.Schema;
public class CookieDaoGenerator {
private static final String PACKAGE = "com.hippo.okhttp.dao";
private static final String OUT_DIR = "../app/src/main/java-gen";
private static final String DELETE_DIR = "../app/src/main/java-gen/com/hippo/okhttp/dao";
public static void generate() throws Exception {
Utilities.deleteContents(new File(DELETE_DIR));
File outDir = new File(OUT_DIR);
outDir.delete();
outDir.mkdirs();
Schema schema = new Schema(1, PACKAGE);
addOkHttp3Cookie(schema);
new DaoGenerator().generateAll(schema, OUT_DIR);
}
private static void addOkHttp3Cookie(Schema schema) {
Entity entity = schema.addEntity("OkHttp3CookieRaw");
entity.setTableName("OK_HTTP_3_COOKIE");
entity.setClassNameDao("OkHttp3CookieDao");
entity.addIdProperty();
entity.addStringProperty("name");
entity.addStringProperty("value");
entity.addLongProperty("expiresAt");
entity.addStringProperty("domain");
entity.addStringProperty("path");
entity.addBooleanProperty("secure");
entity.addBooleanProperty("httpOnly");
entity.addBooleanProperty("persistent");
entity.addBooleanProperty("hostOnly");
}
}
@@ -32,7 +32,7 @@ public class EhDaoGenerator {
private static final String OUT_DIR = "../app/src/main/java-gen";
private static final String DELETE_DIR = "../app/src/main/java-gen/com/hippo/ehviewer/dao";
private static final int VERSION = 2;
private static final int VERSION = 3;
private static final String DOWNLOAD_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/DownloadInfo.java";
private static final String HISTORY_INFO_PATH = "../app/src/main/java-gen/com/hippo/ehviewer/dao/HistoryInfo.java";
@@ -190,6 +190,7 @@ public class EhDaoGenerator {
entity.addIdProperty();
entity.addIntProperty("mode").notNull();
entity.addStringProperty("text");
entity.addBooleanProperty("enable");
}
private static void adjustDownloadInfo() throws Exception {
@@ -496,6 +497,7 @@ public class EhDaoGenerator {
// Set field public
javaClass.getField("mode").setPublic();
javaClass.getField("text").setPublic();
javaClass.getField("enable").setPublic();
// Add equals method
javaClass.addImport("com.hippo.yorozuya.ObjectUtils");
javaClass.addMethod("\t@Override\n" +
@@ -19,7 +19,6 @@ package com.hippo.ehviewer.daogenerator;
public class Main {
public static void main(String args[]) throws Exception {
CookieDaoGenerator.generate();
EhDaoGenerator.generate();
}
}
+6 -6
View File
@@ -1,6 +1,6 @@
#Mon Jan 18 22:31:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
#Mon Jan 18 22:31:05 CST 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.4.1-all.zip