From c48f282a2d77c610fd101b86888ea9b7fae91883 Mon Sep 17 00:00:00 2001 From: seven332 Date: Thu, 31 Mar 2016 22:33:35 +0800 Subject: [PATCH] Add search cover --- .../ehviewer/ui/scene/GalleryDetailScene.java | 50 +++++++++++++++++++ .../res/drawable/v_file_find_primary_x48.xml | 29 +++++++++++ .../res/layout/gallery_detail_actions.xml | 9 ++++ 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/pathdata.xml | 1 + app/src/main/res/values/strings.xml | 1 + 8 files changed, 93 insertions(+) create mode 100644 app/src/main/res/drawable/v_file_find_primary_x48.xml 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 299b71928..470c0f556 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 @@ -55,7 +55,9 @@ import android.widget.ListView; import android.widget.RatingBar; import android.widget.TextView; +import com.hippo.beerbelly.BeerBelly; import com.hippo.drawable.RoundSideRectDrawable; +import com.hippo.ehviewer.AppConfig; import com.hippo.ehviewer.EhApplication; import com.hippo.ehviewer.EhDB; import com.hippo.ehviewer.R; @@ -98,9 +100,14 @@ import com.hippo.widget.ProgressView; import com.hippo.widget.ProgressiveRatingBar; import com.hippo.widget.SimpleGridAutoSpanLayout; import com.hippo.yorozuya.AssertUtils; +import com.hippo.yorozuya.IOUtils; import com.hippo.yorozuya.SimpleHandler; import com.hippo.yorozuya.ViewUtils; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.OutputStream; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.util.List; @@ -198,6 +205,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene private TextView mRate; @Nullable private TextView mSimilar; + @Nullable + private TextView mSearchCover; // Tags @Nullable private LinearLayout mTags; @@ -456,16 +465,19 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mShare = (TextView) ViewUtils.$$(mActions, R.id.share); mRate = (TextView) ViewUtils.$$(mActions, R.id.rate); mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar); + mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover); RippleSalon.addRipple(mHeartGroup, false); RippleSalon.addRipple(mTorrent, false); RippleSalon.addRipple(mShare, false); RippleSalon.addRipple(mRate, false); RippleSalon.addRipple(mSimilar, false); + RippleSalon.addRipple(mSearchCover, false); mHeartGroup.setOnClickListener(this); mTorrent.setOnClickListener(this); mShare.setOnClickListener(this); mRate.setOnClickListener(this); mSimilar.setOnClickListener(this); + mSearchCover.setOnClickListener(this); ensureActionDrawable(context); mTags = (LinearLayout) ViewUtils.$$(belowHeader, R.id.tags); @@ -553,6 +565,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mShare = null; mRate = null; mSimilar = null; + mSearchCover = null; mTags = null; mNoTags = null; @@ -638,6 +651,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene setActionDrawable(mRate, rate); Drawable similar = DrawableManager.getDrawable(context, R.drawable.v_similar_primary_x48); setActionDrawable(mSimilar, similar); + Drawable searchCover = DrawableManager.getDrawable(context, R.drawable.v_file_find_primary_x48); + setActionDrawable(mSearchCover, searchCover); } private boolean createCircularReveal() { @@ -1029,6 +1044,39 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene } } + private void showCoverGalleryList() { + Context context = getContext2(); + if (null == context) { + return; + } + long gid = getGid(); + if (-1L == gid) { + return; + } + File temp = AppConfig.createTempFile(); + if (null == temp) { + return; + } + BeerBelly beerBelly = EhApplication.getConaco(context).getBeerBelly(); + + OutputStream os = null; + try { + os = new FileOutputStream(temp); + if (beerBelly.pullFromDiskCache(EhCacheKeyFactory.getThumbKey(gid), os)) { + ListUrlBuilder lub = new ListUrlBuilder(); + lub.setMode(ListUrlBuilder.MODE_IMAGE_SEARCH); + lub.setImagePath(temp.getPath()); + lub.setUseSimilarityScan(true); + lub.setShowExpunged(true); + GalleryListScene.startScene(this, lub); + } + } catch (FileNotFoundException e) { + // Ignore + } finally { + IOUtils.closeQuietly(os); + } + } + @Override public void onClick(View v) { Context context = getContext2(); @@ -1141,6 +1189,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene helper.setDialog(dialog, mGalleryDetail.rating); } else if (mSimilar == v) { showSimilarGalleryList(); + } else if (mSearchCover == v) { + showCoverGalleryList(); } else if (mComments == v) { if (mGalleryDetail == null) { return; diff --git a/app/src/main/res/drawable/v_file_find_primary_x48.xml b/app/src/main/res/drawable/v_file_find_primary_x48.xml new file mode 100644 index 000000000..efba8f12b --- /dev/null +++ b/app/src/main/res/drawable/v_file_find_primary_x48.xml @@ -0,0 +1,29 @@ + + + + + + + + diff --git a/app/src/main/res/layout/gallery_detail_actions.xml b/app/src/main/res/layout/gallery_detail_actions.xml index 348cbba8c..f8df9a69d 100644 --- a/app/src/main/res/layout/gallery_detail_actions.xml +++ b/app/src/main/res/layout/gallery_detail_actions.xml @@ -101,6 +101,15 @@ android:drawablePadding="8dp" android:textColor="@color/primary_text_light"/> + + diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 4f9440a11..f61c7d902 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -181,6 +181,7 @@ 分享 评分 相似画廊 + 搜索封面 暂无标签 暂无评论 已显示所有评论 diff --git a/app/src/main/res/values-zh-rHK/strings.xml b/app/src/main/res/values-zh-rHK/strings.xml index d158ab3b7..d79bae753 100644 --- a/app/src/main/res/values-zh-rHK/strings.xml +++ b/app/src/main/res/values-zh-rHK/strings.xml @@ -181,6 +181,7 @@ 分享 評分 相似畫廊 + 搜索封面 暫無標籤 暫無評論 已顯示所有評論 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index b11466a98..a33e7ded5 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -181,6 +181,7 @@ 分享 評分 相似畫廊 + 搜尋封面 暫無標籤 暫無評論 已顯示所有評論 diff --git a/app/src/main/res/values/pathdata.xml b/app/src/main/res/values/pathdata.xml index 833cb45e2..787c35f85 100644 --- a/app/src/main/res/values/pathdata.xml +++ b/app/src/main/res/values/pathdata.xml @@ -59,6 +59,7 @@ M5,13H19V11H5M3,17H17V15H3M7,7V9H21V7 M2,20L17,10L22,22M14,9L2,8L11,2Z M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z + M9,13A3,3 0 0,0 12,16A3,3 0 0,0 15,13A3,3 0 0,0 12,10A3,3 0 0,0 9,13M20,19.59V8L14,2H6A2,2 0 0,0 4,4V20A2,2 0 0,0 6,22H18C18.45,22 18.85,21.85 19.19,21.6L14.76,17.17C13.96,17.69 13,18 12,18A5,5 0 0,1 7,13A5,5 0 0,1 12,8A5,5 0 0,1 17,13C17,14 16.69,14.96 16.17,15.75L20,19.59Z M12.88,2H4V11L14.97,22.14L24,13.1L12.88,2ZM7.26,5.26C7.96,4.58,9.06,4.58,9.74,5.26C10.42,5.96,10.42,7.06,9.74,7.74S7.94,8.42,7.26,7.74S6.58,5.94,7.26,5.26ZM14.98,19.3L8.76,12.95L14.88,6.83L21.18,13.11L14.98,19.31ZM11.6,21.56L10.23,23L0,12.74V5H2V11.9L11.6,21.56Z M20.46,14.65C21.86,16.15,20.31,18.6,18.32,17.87C19.78,17.57,20.79,16.37,20.46,14.65ZM4.32,17.87C6.32,18.6,7.86,16.17,6.46,14.65C6.79,16.38,5.78,17.55,4.32,17.87ZM16.87,4.3C16.6,3.56,15.87,3,15,3C13.7,3,12.7,4.24,13.1,5.58C14.2,5.18,15.44,4.48,16.87,4.31ZM24,16C24,18.76,21.76,21,19,21C14.96,21,14.84,16.88,12,16.88S9.04,21,5,21C2.24,21,0,18.76,0,16C0,13.87,1.53,11.43,3.94,7.18C5.84,3.81,8.69,5.92,10.76,6.58C11.54,6.85,12.41,6.88,13.24,6.58C15.3,5.92,18.14,3.81,20.06,7.18C22.46,11.43,24,13.88,24,16ZM8,16C8,14.35,6.65,13,5,13S2,14.35,2,16S3.35,19,5,19S8,17.65,8,16ZM13,14C13,13.45,12.55,13,12,13S11,13.45,11,14S11.45,15,12,15S13,14.55,13,14ZM22,16C22,14.35,20.65,13,19,13S16,14.35,16,16S17.35,19,19,19S22,17.65,22,16ZM9,3C8.14,3,7.4,3.55,7.13,4.3C8.56,4.48,9.79,5.2,10.9,5.58C11.3,4.24,10.3,3,9,3Z diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index bc16b407c..1b4fc2d4a 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -224,6 +224,7 @@ Share Rate Similar + Search Cover No tags No comments No more comments