diff --git a/app/src/main/java/com/hippo/ehviewer/Constants.java b/app/src/main/java/com/hippo/ehviewer/Constants.java
index be3e319b3..89feaff82 100644
--- a/app/src/main/java/com/hippo/ehviewer/Constants.java
+++ b/app/src/main/java/com/hippo/ehviewer/Constants.java
@@ -24,6 +24,7 @@ public final class Constants {
public static final int MESSENGER_ID_SHOW_APP_STATUS;
public static final int MESSENGER_ID_SIGN_IN_OR_OUT;
public static final int MESSENGER_ID_USER_AVATAR;
+ public static final int MESSENGER_ID_JPN_TITLE;
static {
Messenger messenger = Messenger.getInstance();
@@ -31,5 +32,6 @@ public final class Constants {
MESSENGER_ID_SHOW_APP_STATUS = messenger.newId();
MESSENGER_ID_SIGN_IN_OR_OUT = messenger.newId();
MESSENGER_ID_USER_AVATAR = messenger.newId();
+ MESSENGER_ID_JPN_TITLE = messenger.newId();
}
}
diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
index a2ab6d696..97d3d665f 100644
--- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java
+++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
@@ -46,6 +46,11 @@ public class EhApplication extends SceneApplication {
Settings.initialize(this);
+ File sayFile = AppConfig.getFileInAppDir("EhViewer.log");
+ if (sayFile != null) {
+ Say.initSayFile(sayFile);
+ }
+
mEhHttpClient = new EhHttpClient(this);
mEhClient = new EhClient(mEhHttpClient);
diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhClient.java b/app/src/main/java/com/hippo/ehviewer/client/EhClient.java
index 883ed18d3..6633b8ffa 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/EhClient.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/EhClient.java
@@ -19,10 +19,13 @@ package com.hippo.ehviewer.client;
import android.os.AsyncTask;
import android.os.Process;
+import com.hippo.ehviewer.client.data.GalleryApiDetail;
+import com.hippo.ehviewer.client.data.GalleryInfo;
import com.hippo.ehviewer.network.EhHttpRequest;
import com.hippo.httpclient.HttpClient;
import com.hippo.yorozuya.PriorityThreadFactory;
+import java.util.List;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadFactory;
@@ -82,6 +85,31 @@ public final class EhClient {
*/
public static final int METHOD_GET_GALLERY_LIST = 1;
+ /**
+ * Get gallery list with japanese title
+ *
+ *
+ *
+ * | param |
+ * info |
+ *
+ *
+ * | url |
+ * the url to get gallery list |
+ *
+ *
+ * | source |
+ * the source, one of {@link EhUrl#SOURCE_G},
+ * {@link EhUrl#SOURCE_EX} and {@link EhUrl#SOURCE_LOFI} |
+ *
+ *
+ * | listener |
+ * the listener for callback |
+ *
+ *
+ */
+ public static final int METHOD_GET_GALLERY_LIST_JPN = 2;
+
/**
* Get popular
*
@@ -96,7 +124,7 @@ public final class EhClient {
*
*
*/
- public static final int METHOD_GET_POPULAR = 2;
+ public static final int METHOD_GET_POPULAR = 3;
/**
* Get gallery detail
@@ -121,7 +149,7 @@ public final class EhClient {
*
*
*/
- public static final int METHOD_GET_GALLERY_DETAIL = 3;
+ public static final int METHOD_GET_GALLERY_DETAIL = 4;
/**
* Get gallery preview set
@@ -146,7 +174,7 @@ public final class EhClient {
*
*
*/
- public static final int METHOD_GET_PREVIEW_SET = 4;
+ public static final int METHOD_GET_PREVIEW_SET = 5;
private final ThreadPoolExecutor mRequestThreadPool;
@@ -225,6 +253,33 @@ public final class EhClient {
return EhEngine.signIn(mHttpClient, mEhHttpRequest, (String) params[0], (String) params[1]);
case METHOD_GET_GALLERY_LIST:
return EhEngine.getGalleryList(mHttpClient, mEhHttpRequest, (String) params[0], (Integer) params[1]);
+ case METHOD_GET_GALLERY_LIST_JPN:
+ GalleryListParser.Result result = EhEngine.getGalleryList(
+ mHttpClient, mEhHttpRequest, (String) params[0], (Integer) params[1]);
+
+ mEhHttpRequest.clear();
+ List galleryInfos = result.galleryInfos;
+ int length = galleryInfos.size();
+ int[] gids = new int[length];
+ String[] tokens = new String[length];
+ for (int i = 0; i < length; i++) {
+ GalleryInfo gi = galleryInfos.get(i);
+ gids[i] = gi.gid;
+ tokens[i] = gi.token;
+ }
+
+ List galleryApiDetails = EhEngine.getGalleryApiDetail(
+ mHttpClient, mEhHttpRequest, gids, tokens, (Integer) params[1]);
+
+ for (int i = 0; i < length; i++) {
+ GalleryInfo gi = galleryInfos.get(i);
+ GalleryApiDetail gad = galleryApiDetails.get(i);
+ if (gi.gid == gad.gid) {
+ gi.titleJpn = gad.titleJpn;
+ }
+ }
+
+ return result;
case METHOD_GET_POPULAR:
return EhEngine.getPopular(mHttpClient, mEhHttpRequest);
case METHOD_GET_GALLERY_DETAIL:
diff --git a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
index 884ee3e15..592abf902 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/EhEngine.java
@@ -16,6 +16,7 @@
package com.hippo.ehviewer.client;
+import com.hippo.ehviewer.client.data.GalleryApiDetail;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ehviewer.client.data.PreviewSet;
import com.hippo.httpclient.FormPoster;
@@ -23,14 +24,33 @@ import com.hippo.httpclient.HttpClient;
import com.hippo.httpclient.HttpRequest;
import com.hippo.httpclient.HttpResponse;
import com.hippo.httpclient.JsonPoster;
+import com.hippo.yorozuya.Say;
+import org.json.JSONArray;
import org.json.JSONObject;
+import java.util.List;
+
class EhEngine {
private static final String SIGN_IN_URL = "http://forums.e-hentai.org/index.php?act=Login&CODE=01";
public static final String API_EHVIEWER = "http://www.ehviewer.com/API";
+ public static final String API_G = "http://g.e-hentai.org/api.php";
+ public static final String API_EX = "http://exhentai.org/api.php";
+ public static final long APIUID = 1363542;
+ public static final String APIKEY = "f4b5407ab1727b9d08d7";
+
+ private static String getApiUrl(int source) {
+ switch (source) {
+ default:
+ case EhUrl.SOURCE_G:
+ return API_G;
+ case EhUrl.SOURCE_EX:
+ return API_EX;
+ }
+ }
+
public static String signIn(HttpClient httpClient, HttpRequest httpRequest,
String username, String password) throws Exception {
try {
@@ -136,4 +156,51 @@ class EhEngine {
httpRequest.disconnect();
}
}
+
+ public static List getGalleryApiDetail(HttpClient httpClient,
+ HttpRequest httpRequest, int[] gids, String[] tokens, int source) throws Exception {
+ if (gids.length != tokens.length || gids.length > 25 || gids.length <= 0) {
+ throw new EhException("input parameter error");
+ }
+
+ try {
+ JSONObject json = new JSONObject();
+ json.put("method", "gdata");
+ JSONArray ja = new JSONArray();
+ int length = gids.length;
+ for (int i = 0; i < length; i++) {
+ JSONArray g = new JSONArray();
+ g.put(gids[i]);
+ g.put(tokens[i]);
+ ja.put(g);
+ }
+ json.put("gidlist", ja);
+ httpRequest.setUrl(getApiUrl(source));
+ httpRequest.setHttpImpl(new JsonPoster(json));
+
+ Say.f("EhEngine", json.toString());
+
+ HttpResponse response = httpClient.execute(httpRequest);
+ String body = response.getString();
+
+ Say.f("EhEngine", body);
+
+
+ List list = GalleryApiParser.parse(body);
+
+ if (list.size() != gids.length) {
+ throw new EhException("length not match, request length " + gids.length + ", result length " + list.size());
+ }
+
+ return list;
+ } catch (Exception e) {
+ if (httpRequest.isCanceled()) {
+ throw new CanceledException();
+ } else {
+ throw e;
+ }
+ } finally {
+ httpRequest.disconnect();
+ }
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/GalleryApiParser.java b/app/src/main/java/com/hippo/ehviewer/client/GalleryApiParser.java
new file mode 100644
index 000000000..8af773378
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/client/GalleryApiParser.java
@@ -0,0 +1,67 @@
+/*
+ * Copyright 2015 Hippo Seven
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.ehviewer.client;
+
+import com.hippo.ehviewer.client.data.GalleryApiDetail;
+import com.hippo.ehviewer.client.data.GalleryBase;
+import com.hippo.ehviewer.util.EhUtils;
+import com.hippo.yorozuya.FileUtils;
+
+import org.json.JSONArray;
+import org.json.JSONException;
+import org.json.JSONObject;
+
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
+
+public class GalleryApiParser {
+
+ public static List parse(String body) throws JSONException {
+ JSONObject jo = new JSONObject(body);
+ JSONArray ja = jo.getJSONArray("gmetadata");
+ List list = new ArrayList<>();
+ int length = ja.length();
+ for (int i = 0; i < length; i++) {
+ GalleryApiDetail gad = new GalleryApiDetail();
+ JSONObject g = ja.getJSONObject(i);
+ gad.gid = g.getInt("gid");
+ gad.token = g.getString("token");
+ gad.archiverKey = g.getString("archiver_key");
+ gad.title = g.getString("title");
+ gad.titleJpn = g.getString("title_jpn");
+ gad.category = EhUtils.getCategory(g.getString("category"));
+ gad.thumb = g.getString("thumb");
+ gad.uploader = g.getString("uploader");
+ gad.posted = GalleryBase.DEFAULT_DATE_FORMAT.format(new Date(Long.parseLong(g.getString("posted")) * 1000));
+ gad.pageCount = Integer.parseInt(g.getString("filecount"));
+ gad.size = FileUtils.humanReadableByteCount(g.getLong("filesize"), false);
+ gad.expunged = g.getBoolean("expunged");
+ gad.rating = Float.parseFloat(g.getString("rating"));
+ gad.torrentcount = Integer.parseInt(g.getString("torrentcount"));
+ JSONArray tagJa = g.getJSONArray("tags");
+ int length2 = tagJa.length();
+ String[] tags = new String[length2];
+ for (int j = 0; j < length2; j++) {
+ tags[j] = tagJa.getString(j);
+ }
+ gad.tags = tags;
+ list.add(gad);
+ }
+ return list;
+ }
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/GalleryDetailParser.java
index 374fdffb2..edfab2935 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/GalleryDetailParser.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/GalleryDetailParser.java
@@ -17,6 +17,7 @@
package com.hippo.ehviewer.client;
import com.hippo.ehviewer.client.data.Comment;
+import com.hippo.ehviewer.client.data.GalleryBase;
import com.hippo.ehviewer.client.data.GalleryDetail;
import com.hippo.ehviewer.client.data.LargePreviewSet;
import com.hippo.ehviewer.client.data.NormalPreviewSet;
@@ -38,12 +39,11 @@ import java.util.regex.Pattern;
public class GalleryDetailParser {
- private static final DateFormat WEB_COMMENT_DATA_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm z", Locale.US);
- private static final DateFormat OUT_COMMENT_DATA_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+ private static final DateFormat WEB_COMMENT_DATE_FORMAT = new SimpleDateFormat("dd MMMMM yyyy, HH:mm z", Locale.US);
+ private static final DateFormat OUT_COMMENT_DATE_FORMAT = GalleryBase.DEFAULT_DATE_FORMAT;
static {
- WEB_COMMENT_DATA_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
- OUT_COMMENT_DATA_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
+ WEB_COMMENT_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
}
private static final String OFFENSIVE_STRING =
@@ -229,11 +229,11 @@ public class GalleryDetailParser {
String webDateString = ParserUtils.trim(m.group(1));
Date date;
try {
- date = WEB_COMMENT_DATA_FORMAT.parse(webDateString);
+ date = WEB_COMMENT_DATE_FORMAT.parse(webDateString);
} catch (java.text.ParseException e) {
date = new Date(0l);
}
- String outDateString = OUT_COMMENT_DATA_FORMAT.format(date);
+ String outDateString = OUT_COMMENT_DATE_FORMAT.format(date);
galleryDetail.comments.add(new Comment(outDateString, date, ParserUtils.trim(m.group(2)), m.group(3)));
}
Collections.sort(galleryDetail.comments, COMMENT_SORTER);
diff --git a/app/src/main/java/com/hippo/ehviewer/client/GalleryDownloader.java b/app/src/main/java/com/hippo/ehviewer/client/GalleryDownloader.java
new file mode 100644
index 000000000..599cd1a9f
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/client/GalleryDownloader.java
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2015 Hippo Seven
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.ehviewer.client;
+
+public class GalleryDownloader {
+
+ public enum MODE {
+ READ,
+ DOWNLOAD
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ public interface GallerySavers {
+
+ }
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/GalleryListParser.java b/app/src/main/java/com/hippo/ehviewer/client/GalleryListParser.java
index 5de2ddb38..4906e524a 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/GalleryListParser.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/GalleryListParser.java
@@ -168,15 +168,17 @@ public class GalleryListParser {
lgi.category = EhUtils.getCategory(m.group(5));
String tags = m.group(6);
- if (tags.equals("-"))
- lgi.lofiTags = new String[0];
- else
- lgi.lofiTags = tags.split(", ");
+ if (tags.equals("-")) {
+ lgi.tags = new String[0];
+ } else {
+ lgi.tags = tags.split(", ");
+ }
String rating = m.group(7);
- if (rating.equals("-"))
+ if (rating.equals("-")) {
lgi.rating = Float.NaN;
- else
+ } else {
lgi.rating = getStartNum(rating);
+ }
lgi.generateSLang();
list.add(lgi);
@@ -208,14 +210,16 @@ public class GalleryListParser {
int num2;
int rate = 5;
String re;
- if (m.find())
+ if (m.find()) {
num1 = ParserUtils.parseInt(m.group().replace("px", ""));
- else
+ } else {
return null;
- if (m.find())
+ }
+ if (m.find()) {
num2 = ParserUtils.parseInt(m.group().replace("px", ""));
- else
+ } else {
return null;
+ }
rate = rate - num1 / 16;
if (num2 == 21) {
rate--;
diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiDetail.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiDetail.java
new file mode 100644
index 000000000..0c83dff5d
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryApiDetail.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2015 Hippo Seven
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.ehviewer.client.data;
+
+public class GalleryApiDetail extends GalleryBase {
+
+ public String archiverKey;
+ public String titleJpn;
+ public int pageCount;
+ public String size;
+ public boolean expunged;
+ public int torrentcount;
+ public String[] tags;
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryBase.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryBase.java
new file mode 100644
index 000000000..682a3b06e
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryBase.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2015 Hippo Seven
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.hippo.ehviewer.client.data;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Locale;
+import java.util.TimeZone;
+
+public class GalleryBase {
+
+ public static final DateFormat DEFAULT_DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.US);
+
+ static {
+ DEFAULT_DATE_FORMAT.setTimeZone(TimeZone.getTimeZone("UTC"));
+ }
+
+ public int gid;
+ public String token;
+ public String title;
+ public String thumb;
+ public int category;
+ public String posted;
+ public String uploader;
+ public float rating;
+}
diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java
index 09a600843..ceac7fe98 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryDetail.java
@@ -18,20 +18,13 @@ package com.hippo.ehviewer.client.data;
import java.util.List;
-public class GalleryDetail {
+public class GalleryDetail extends GalleryBase {
- public int gid;
- public String token;
- public String thumb;
- public String title;
public String titleJpn;
- public int category;
- public String uploader;
public int torrentCount;
public String torrentUrl;
- public String posted;
public String parent;
public String visible;
public String language;
@@ -40,7 +33,6 @@ public class GalleryDetail {
public int pageCount;
public int favoredTimes;
public boolean isFavored;
- public float rating;
public int ratedTimes;
public List tags;
diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.java b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.java
index 9caffc132..27d1b6dc1 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/data/GalleryInfo.java
@@ -18,7 +18,7 @@ package com.hippo.ehviewer.client.data;
import java.util.regex.Pattern;
-public class GalleryInfo {
+public class GalleryInfo extends GalleryBase {
/**
* ISO 639-1
@@ -74,14 +74,8 @@ public class GalleryInfo {
"[(\\[]dutch[)\\]]",
};
- public int gid;
- public String token;
- public String title;
- public String posted;
- public int category;
- public String thumb;
- public String uploader;
- public float rating;
+ public String titleJpn;
+
/**
* Will not be recond
*/
diff --git a/app/src/main/java/com/hippo/ehviewer/client/data/LofiGalleryInfo.java b/app/src/main/java/com/hippo/ehviewer/client/data/LofiGalleryInfo.java
index 9e104389b..34d328ae8 100644
--- a/app/src/main/java/com/hippo/ehviewer/client/data/LofiGalleryInfo.java
+++ b/app/src/main/java/com/hippo/ehviewer/client/data/LofiGalleryInfo.java
@@ -18,5 +18,7 @@ package com.hippo.ehviewer.client.data;
public class LofiGalleryInfo extends GalleryInfo {
- public String[] lofiTags;
+ public String titleJpn;
+
+ public String[] tags;
}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
index a29f17d8b..4186bc2cf 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java
@@ -21,6 +21,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.text.Html;
+import android.text.TextUtils;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@@ -149,7 +150,13 @@ public class GalleryDetailScene extends Scene implements View.OnClickListener,
Conaco conaco = EhApplication.getConaco(getStageActivity());
mThumb.load(conaco, EhImageKeyFactory.getThumbKey(gi.gid), gi.thumb);
- mTitle.setText(gi.title);
+ String title;
+ if (Settings.getJpnTitle()) {
+ title = TextUtils.isEmpty(gi.titleJpn) ? gi.title : gi.titleJpn;
+ } else {
+ title = gi.title;
+ }
+ mTitle.setText(title);
mUploader.setText(gi.uploader);
mCategory.setText(EhUtils.getCategory(gi.category));
mCategory.setTextColor(EhUtils.getCategoryColor(gi.category));
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
index 6d2e5a50c..10ba3302e 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
@@ -40,6 +40,7 @@ import com.hippo.animation.SimpleAnimatorListener;
import com.hippo.conaco.Conaco;
import com.hippo.drawable.AddDeleteDrawable;
import com.hippo.effect.ViewTransition;
+import com.hippo.ehviewer.Constants;
import com.hippo.ehviewer.EhApplication;
import com.hippo.ehviewer.EhImageKeyFactory;
import com.hippo.ehviewer.R;
@@ -67,12 +68,13 @@ import com.hippo.scene.Scene;
import com.hippo.scene.SimpleDialog;
import com.hippo.scene.TransitionCurtain;
import com.hippo.util.AnimationUtils;
-import com.hippo.yorozuya.SimpleHandler;
-import com.hippo.yorozuya.AssertUtils;
import com.hippo.widget.FabLayout;
import com.hippo.widget.FloatingActionButton;
import com.hippo.widget.recyclerview.EasyRecyclerView;
+import com.hippo.yorozuya.AssertUtils;
import com.hippo.yorozuya.MathUtils;
+import com.hippo.yorozuya.Messenger;
+import com.hippo.yorozuya.SimpleHandler;
import com.hippo.yorozuya.ViewUtils;
// TODO remeber the data in ContentHelper after screen dirction change
@@ -81,7 +83,8 @@ import com.hippo.yorozuya.ViewUtils;
// TODO Dim when expand search list
public final class GalleryListScene extends Scene implements SearchBar.Helper,
View.OnClickListener, FabLayout.OnCancelListener,
- SearchLayout.SearhLayoutHelper, EasyRecyclerView.OnItemClickListener {
+ SearchLayout.SearhLayoutHelper, EasyRecyclerView.OnItemClickListener,
+ Messenger.Receiver {
public static final String KEY_MODE = "mode";
@@ -137,6 +140,8 @@ public final class GalleryListScene extends Scene implements SearchBar.Helper,
private int mDrawerListActivatedPosition;
+ private boolean mJpnTitle;
+
private SimpleDialog.OnCreateCustomViewListener mGoToCreateCustomViewListener =
new SimpleDialog.OnCreateCustomViewListener() {
@Override
@@ -319,10 +324,18 @@ public final class GalleryListScene extends Scene implements SearchBar.Helper,
}
}
+ @Override
+ protected void onInit() {
+ mJpnTitle = Settings.getJpnTitle();
+ Messenger.getInstance().register(Constants.MESSENGER_ID_JPN_TITLE, this);
+ }
+
@Override
protected void onDie() {
super.onDie();
+ Messenger.getInstance().unregister(Constants.MESSENGER_ID_JPN_TITLE, this);
+
// Avoid memory leak
if (mGalleryListHelper.mListener != null) {
mGalleryListHelper.mListener.setGalleryListHelper(null);
@@ -746,6 +759,13 @@ public final class GalleryListScene extends Scene implements SearchBar.Helper,
return true;
}
+ @Override
+ public void onReceive(int id, Object obj) {
+ if (Constants.MESSENGER_ID_JPN_TITLE == id) {
+ mJpnTitle = (Boolean) obj;
+ }
+ }
+
private class TransitonHelper implements TransitionCurtain.ViewPairSet {
private int mPosition;
@@ -913,7 +933,8 @@ public final class GalleryListScene extends Scene implements SearchBar.Helper,
mListener = listener;
EhRequest request = new EhRequest();
- request.setMethod(EhClient.METHOD_GET_GALLERY_LIST);
+ request.setMethod(mJpnTitle ?
+ EhClient.METHOD_GET_GALLERY_LIST_JPN : EhClient.METHOD_GET_GALLERY_LIST);
request.setEhListener(listener);
request.setArgs(url, source);
@@ -936,8 +957,13 @@ public final class GalleryListScene extends Scene implements SearchBar.Helper,
Conaco conaco = EhApplication.getConaco(getStageActivity());
holder.thumb.load(conaco, EhImageKeyFactory.getThumbKey(gi.gid), gi.thumb);
-
- holder.title.setText(gi.title);
+ String title;
+ if (mJpnTitle) {
+ title = TextUtils.isEmpty(gi.titleJpn) ? gi.title : gi.titleJpn;
+ } else {
+ title = gi.title;
+ }
+ holder.title.setText(title);
holder.uploader.setText(gi.uploader);
holder.rating.setRating(gi.rating);
TextView category = holder.category;
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java
index 42482a185..3603c6d18 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/preference/EHSettingsScene.java
@@ -29,6 +29,7 @@ import com.hippo.scene.preference.Preference;
import com.hippo.scene.preference.PreferenceCategory;
import com.hippo.scene.preference.PreferenceScene;
import com.hippo.scene.preference.PreferenceSet;
+import com.hippo.scene.preference.SwitchPreference;
import com.hippo.yorozuya.Messenger;
public final class EHSettingsScene extends PreferenceScene implements Preference.OnClickListener,
@@ -60,6 +61,14 @@ public final class EHSettingsScene extends PreferenceScene implements Preference
sourcePreference.setDefaultValue(Settings.DEFAULT_EH_SOURCE);
sourcePreference.setOnValueChangeListener(this);
+ // Jpn title
+ SwitchPreference jpnTitlePreference = new SwitchPreference(Settings.KEY_JPN_TITLE,
+ resources.getString(R.string.settings_jpn_title_title), null);
+ jpnTitlePreference.setSummaryOn(resources.getString(R.string.settings_jpn_title_summary_on));
+ jpnTitlePreference.setSummaryOff(resources.getString(R.string.settings_jpn_title_summary_off));
+ jpnTitlePreference.setDefaultValue(Settings.DEFAULT_JPN_TITLE);
+ jpnTitlePreference.setOnValueChangeListener(this);
+
// Excluded language
Preference languagePreference = new Preference(
Settings.KEY_EXCLUDED_LANGUAGES,
@@ -80,6 +89,7 @@ public final class EHSettingsScene extends PreferenceScene implements Preference
preferenceSet.setPreferenceList(new Preference[] {
sourcePreference,
+ jpnTitlePreference,
languagePreference,
previewSizePreference
});
@@ -112,6 +122,9 @@ public final class EHSettingsScene extends PreferenceScene implements Preference
EhApplication.getEhHttpClient(getStageActivity()).setPreviewSize(
value == 0? EhConfig.PREVIEW_SIZE_NORMAL : EhConfig.PREVIEW_SIZE_LARGE);
return true;
+ case Settings.KEY_JPN_TITLE:
+ Messenger.getInstance().notify(Constants.MESSENGER_ID_JPN_TITLE, newValue);
+ return true;
default:
return true;
}
diff --git a/app/src/main/java/com/hippo/ehviewer/util/Settings.java b/app/src/main/java/com/hippo/ehviewer/util/Settings.java
index 034bd1512..90562df3d 100644
--- a/app/src/main/java/com/hippo/ehviewer/util/Settings.java
+++ b/app/src/main/java/com/hippo/ehviewer/util/Settings.java
@@ -72,11 +72,7 @@ public final class Settings {
sSettingsPre.edit().putString(key, value).apply();
}
- /****** EH ******/
- public static final String KEY_EH_SOURCE = "eh_source";
- public static final int DEFAULT_EH_SOURCE = EhUrl.SOURCE_G;
- public static final String KEY_EH_API = "eh_api";
- public static final int DEFAULT_EH_API = EhUrl.SOURCE_G;
+ /****** Other ******/
private static final String KEY_SIGN_IN = "sign_in";
private static final boolean DEFAULT_SIGN_IN = false;
private static final String KEY_DISPLAY_NAME = "display_name";
@@ -88,21 +84,6 @@ public final class Settings {
private static final String KEY_IGNEOUS = "igneous";
private static final String DEFAULT_IGNEOUS = null;
- public static int getEhSource() {
- int value = getInt(KEY_EH_SOURCE, DEFAULT_EH_SOURCE);
- if (value < EhUrl.SOURCE_G || value > EhUrl.SOURCE_LOFI) {
- value = DEFAULT_EH_SOURCE;
- }
- return value;
- }
-
- public static void putEhSource(int value) {
- if (value < EhUrl.SOURCE_G || value > EhUrl.SOURCE_LOFI) {
- value = DEFAULT_EH_SOURCE;
- }
- putInt(KEY_EH_SOURCE, value);
- }
-
public static boolean getSignIn() {
return getBoolean(KEY_SIGN_IN, DEFAULT_SIGN_IN);
}
@@ -150,12 +131,39 @@ public final class Settings {
}
}
- /****** EhConfig ******/
+ /****** EH ******/
+ public static final String KEY_EH_SOURCE = "eh_source";
+ public static final int DEFAULT_EH_SOURCE = EhUrl.SOURCE_G;
+ public static final String KEY_JPN_TITLE = "jpn_title";
+ public static final boolean DEFAULT_JPN_TITLE = false;
public static final String KEY_EXCLUDED_LANGUAGES = "excluded_languages";
public static final String DEFAULT_EXCLUDED_LANGUAGES = "";
public static final String KEY_PREVIEW_SIZE = "preview_size";
public static final int DEFAULT_PREVIEW_SIZE = 0;
+ public static void putEhSource(int value) {
+ if (value < EhUrl.SOURCE_G || value > EhUrl.SOURCE_LOFI) {
+ value = DEFAULT_EH_SOURCE;
+ }
+ putInt(KEY_EH_SOURCE, value);
+ }
+
+ public static int getEhSource() {
+ int value = getInt(KEY_EH_SOURCE, DEFAULT_EH_SOURCE);
+ if (value < EhUrl.SOURCE_G || value > EhUrl.SOURCE_LOFI) {
+ value = DEFAULT_EH_SOURCE;
+ }
+ return value;
+ }
+
+ public static void putJpnTitle(boolean value) {
+ putBoolean(KEY_JPN_TITLE, value);
+ }
+
+ public static boolean getJpnTitle() {
+ return getBoolean(KEY_JPN_TITLE, DEFAULT_JPN_TITLE);
+ }
+
public static EhConfig generateEhConfig() {
EhConfig config = new EhConfig();
config.previewSize = getPreviewSize() == 0 ?
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index 74d8c2743..0d0d98fe3 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -116,6 +116,9 @@
显示
EH 源
+ 日文标题
+ 尝试显示日文标题。这可能会花费更多时间
+ 显示默认标题
排除语言
在列表与搜索中隐藏指定语言画廊
预览图大小
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index b04139db1..9786c7379 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -140,6 +140,9 @@
g.e-hentai.org
exhentai.org
lofi.e-hentai.org
+ Japanese title
+ Try to show japanese title. It may takes more time
+ Show default title
Excluded languages
Hide galleries in certain languages from the gallery list and searches
Preview size
diff --git a/httpclient b/httpclient
index 8425de1ba..9a7258f90 160000
--- a/httpclient
+++ b/httpclient
@@ -1 +1 @@
-Subproject commit 8425de1ba128460ed3de15849ce42c72466e4917
+Subproject commit 9a7258f90a1568f954f4ead747a01e498050931d