From 73b702aa5608a88cd77ded47d634b388465a01b3 Mon Sep 17 00:00:00 2001 From: Tsukatsuki Kanade Date: Mon, 17 Sep 2018 12:18:21 +0800 Subject: [PATCH] feat: Add favorite gallery name to scene --- .../com/hippo/ehviewer/client/data/GalleryDetail.java | 3 +++ .../hippo/ehviewer/client/parser/GalleryDetailParser.java | 8 ++++++++ .../com/hippo/ehviewer/ui/scene/GalleryDetailScene.java | 1 + .../com/hippo/ehviewer/ui/scene/GalleryInfoScene.java | 2 ++ app/src/main/res/values-zh-rCN/strings.xml | 1 + app/src/main/res/values-zh-rHK/strings.xml | 1 + app/src/main/res/values-zh-rTW/strings.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 18 insertions(+) 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 5b11dfbf8..a8889aca1 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 @@ -40,6 +40,7 @@ public class GalleryDetail extends GalleryInfo { public GalleryComment[] comments; public int previewPages; public PreviewSet previewSet; + public String favoriteName; @Override public int describeContents() { @@ -64,6 +65,7 @@ public class GalleryDetail extends GalleryInfo { dest.writeParcelableArray(this.comments, 0); dest.writeInt(this.previewPages); dest.writeParcelable(previewSet, flags); + dest.writeString(this.favoriteName); } public GalleryDetail() { @@ -96,6 +98,7 @@ public class GalleryDetail extends GalleryInfo { } this.previewPages = in.readInt(); this.previewSet = in.readParcelable(PreviewSet.class.getClassLoader()); + this.favoriteName = in.readString(); } public static final Creator CREATOR = new Creator() { diff --git a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java index a9f94123e..f79fdce59 100644 --- a/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java +++ b/app/src/main/java/com/hippo/ehviewer/client/parser/GalleryDetailParser.java @@ -227,6 +227,14 @@ public class GalleryDetailParser { // isFavorited Element gdf = gm.getElementById("gdf"); gd.isFavorited = null != gdf && !StringUtils.trim(gdf.text()).equals("Add to Favorites"); + if (gdf != null) { + final String favoriteName = StringUtils.trim(gdf.text()); + if (favoriteName.equals("Add to Favorites")) { + gd.favoriteName = ""; + } else { + gd.favoriteName = StringUtils.trim(gdf.text()); + } + } } catch (Exception e) { throw new ParseException("Can't parse gallery detail", body); } 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 48ccdee5d..e887dac71 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 @@ -766,6 +766,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene if (gd.isFavorited || EhDB.containLocalFavorites(gd.gid)) { mHeart.setVisibility(View.VISIBLE); + mHeart.setText(gd.favoriteName); mHeartOutline.setVisibility(View.GONE); } else { mHeart.setVisibility(View.GONE); diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryInfoScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryInfoScene.java index 2aca00e92..be1a3534f 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryInfoScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryInfoScene.java @@ -128,6 +128,8 @@ public final class GalleryInfoScene extends ToolbarScene implements EasyRecycler mValues.add(Integer.toString(gd.torrentCount)); mKeys.add(resources.getString(R.string.key_torrent_url)); mValues.add(gd.torrentUrl); + mKeys.add(resources.getString(R.string.favorite_name)); + mValues.add(gd.favoriteName); } protected void onInit() { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index b1738d16e..305cc0545 100755 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -666,4 +666,5 @@ 启用后,将不能截取该应用的屏幕截图,同时,将不会在系统任务切换器中显示该应用的内容预览\n\n重新启动应用以生效此更改 下载服务 + 收藏画廊 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index 19c145c4a..1a3236967 100755 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -662,5 +662,6 @@ 隱私 不允許荧幕抓取 啟用後,將不能截取該應用的螢幕截圖,同時,將不會在系統任務切換器中顯示該應用的內容預覽\n\n重新啟動應用以生效此更改 + 收藏畫廊 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index bb1a04081..be4f041a8 100755 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -662,5 +662,6 @@ 隱私 不允許荧幕抓取 啟用後,將不能截取該應用的螢幕截圖,同時,將不會在系統任務切換器中顯示該應用的內容預覽\n\n重新啟動應用以生效此更改 + 收藏畫廊 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index df2b0a330..0280d9a4d 100755 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -726,4 +726,5 @@ If enabled, you cannot take screenshots of the app, and the system will not display app contents in the task switcher\n\nYou need to restart the app for the changes to take effect Download Service + Favorite