diff --git a/app/build.gradle b/app/build.gradle index ae3ecb5ca..26c4886c0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -3,7 +3,7 @@ apply plugin: 'com.google.android.gms.oss-licenses-plugin' android { compileSdkVersion 30 - buildToolsVersion "30.0.1" + buildToolsVersion "30.0.2" ndkVersion "21.3.6528147" signingConfigs { def keystorePwd = null @@ -76,12 +76,12 @@ tasks.withType(JavaCompile) { dependencies { implementation fileTree(include: ['*.jar'], dir: 'libs') - implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' + implementation 'androidx.appcompat:appcompat:1.2.0' implementation 'androidx.biometric:biometric:1.0.1' implementation "androidx.browser:browser:1.2.0" implementation 'androidx.cardview:cardview:1.0.0' implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0' - implementation 'com.google.android.material:material:1.3.0-alpha02' + implementation 'com.google.android.material:material:1.2.0' implementation 'com.getkeepsafe.relinker:relinker:1.4.1' implementation 'com.github.amlcurran.showcaseview:library:5.4.3' implementation 'com.github.seven332.a7zip:extract-lite:1b21783' @@ -102,7 +102,7 @@ dependencies { implementation 'com.github.seven332:yorozuya-thread:0.1.1' implementation 'com.github.seven332:yorozuya-collect:0.1.4' implementation 'com.h6ah4i.android.widget.advrecyclerview:advrecyclerview:1.0.0' - def appCenterSdkVersion = '3.2.2' + def appCenterSdkVersion = '3.3.0' implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}" implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}" implementation "com.microsoft.appcenter:appcenter-distribute:${appCenterSdkVersion}" 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 7db250b62..0a2b527dc 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,9 @@ public class GalleryDetail extends GalleryInfo { public String torrentUrl; public String archiveUrl; public String parent; + public String newerUrl; + public String newerName; + public String newerDate; public String visible; public String language; public String size; @@ -61,6 +64,9 @@ public class GalleryDetail extends GalleryInfo { this.torrentUrl = in.readString(); this.archiveUrl = in.readString(); this.parent = in.readString(); + this.newerUrl = in.readString(); + this.newerName = in.readString(); + this.newerDate = in.readString(); this.visible = in.readString(); this.language = in.readString(); this.size = in.readString(); @@ -91,6 +97,9 @@ public class GalleryDetail extends GalleryInfo { dest.writeString(this.torrentUrl); dest.writeString(this.archiveUrl); dest.writeString(this.parent); + dest.writeString(this.newerUrl); + dest.writeString(this.newerName); + dest.writeString(this.newerDate); dest.writeString(this.visible); dest.writeString(this.language); dest.writeString(this.size); 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 0766e17c0..bf16be461 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 @@ -62,7 +62,7 @@ public class GalleryDetailParser { private static final Pattern PATTERN_ERROR = Pattern.compile("
\n

([^<]+)

"); 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("]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Torrent Download \\((\\d+)\\)"); + private static final Pattern PATTERN_TORRENT = Pattern.compile("]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Torrent Download[^<]+(\\d+)[^<]+]*onclick=\"return popUp\\('([^']+)'[^)]+\\)\">Archive Download"); private static final Pattern PATTERN_COVER = Pattern.compile("width:(\\d+)px; height:(\\d+)px.+?url\\((.+?)\\)"); private static final Pattern PATTERN_TAG_GROUP = Pattern.compile("]+>([\\w\\s]+):(?:]+>]+>[\\w\\s]+
)+"); @@ -72,6 +72,7 @@ public class GalleryDetailParser { private static final Pattern PATTERN_PREVIEW_PAGES = Pattern.compile("]+>]+>([\\d,]+)]+>(?:]+>)?>(?:)?"); private static final Pattern PATTERN_NORMAL_PREVIEW = Pattern.compile("
]*>]*width:(\\d+)[^<>]*height:(\\d+)[^<>]*\\((.+?)\\)[^<>]*-(\\d+)px[^<>]*>]*href=\"(.+?)\"[^<>]*>\"([\\d,]+)\"");\"([\\d,]+)\".+?src=\"(.+?)\"");]+)\">([^<>]+).+?added ([^<>]+)
"); private static final GalleryTagGroup[] EMPTY_GALLERY_TAG_GROUP_ARRAY = new GalleryTagGroup[0]; private static final GalleryCommentList EMPTY_GALLERY_COMMENT_ARRAY = new GalleryCommentList(new GalleryComment[0], false); @@ -135,6 +136,17 @@ public class GalleryDetailParser { gd.torrentUrl = ""; } + matcher = PATTERN_NEWER_VERSION.matcher(body); + if (matcher.find()) { + gd.newerUrl = StringUtils.unescapeXml(StringUtils.trim(matcher.group(1))); + gd.newerName = StringUtils.unescapeXml(StringUtils.trim(matcher.group(2))); + gd.newerDate = StringUtils.unescapeXml(StringUtils.trim(matcher.group(3))); + } else { + gd.newerUrl = ""; + gd.newerName = ""; + gd.newerDate = ""; + } + matcher = PATTERN_ARCHIVE.matcher(body); if (matcher.find()) { gd.archiveUrl = StringUtils.unescapeXml(StringUtils.trim(matcher.group(1))); 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 939736d14..57f3d75c1 100755 --- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryDetailScene.java @@ -84,6 +84,7 @@ import com.hippo.ehviewer.client.data.GalleryTagGroup; import com.hippo.ehviewer.client.data.ListUrlBuilder; import com.hippo.ehviewer.client.data.PreviewSet; import com.hippo.ehviewer.client.exception.NoHAtHClientException; +import com.hippo.ehviewer.client.parser.GalleryDetailUrlParser; import com.hippo.ehviewer.client.parser.RateGalleryParser; import com.hippo.ehviewer.dao.DownloadInfo; import com.hippo.ehviewer.dao.Filter; @@ -189,6 +190,8 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene private TextView mPosted; @Nullable private TextView mFavoredTimes; + @Nullable + private TextView mNewerVersion; // Actions @Nullable private View mActions; @@ -542,6 +545,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mInfo.setOnClickListener(this); mActions = ViewUtils.$$(belowHeader, R.id.actions); + mNewerVersion = (TextView) ViewUtils.$$(mActions, R.id.newerVersion); mRatingText = (TextView) ViewUtils.$$(mActions, R.id.rating_text); mRating = (RatingBar) ViewUtils.$$(mActions, R.id.rating); mHeartGroup = ViewUtils.$$(mActions, R.id.heart_group); @@ -553,6 +557,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mRate = (TextView) ViewUtils.$$(mActions, R.id.rate); mSimilar = (TextView) ViewUtils.$$(mActions, R.id.similar); mSearchCover = (TextView) ViewUtils.$$(mActions, R.id.search_cover); + mNewerVersion.setOnClickListener(this); mHeartGroup.setOnClickListener(this); mTorrent.setOnClickListener(this); mArchive.setOnClickListener(this); @@ -637,6 +642,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mFavoredTimes = null; mActions = null; + mNewerVersion = null; mRatingText = null; mRating = null; mHeartGroup = null; @@ -861,7 +867,7 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene } if (mThumb == null || mTitle == null || mUploader == null || mCategory == null || mLanguage == null || mPages == null || mSize == null || mPosted == null || - mFavoredTimes == null || mRatingText == null || mRating == null || mTorrent == null) { + mFavoredTimes == null || mRatingText == null || mRating == null || mTorrent == null || mNewerVersion == null) { return; } @@ -881,6 +887,9 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene mSize.setText(gd.size); mPosted.setText(gd.posted); mFavoredTimes.setText(resources.getString(R.string.favored_times, gd.favoriteCount)); + if (!TextUtils.isEmpty(gd.newerUrl)) { + mNewerVersion.setVisibility(View.VISIBLE); + } mRatingText.setText(getAllRatingText(gd.rating, gd.ratingCount)); mRating.setRating(gd.rating); @@ -1199,6 +1208,17 @@ public class GalleryDetailScene extends BaseScene implements View.OnClickListene intent.putExtra(GalleryActivity.KEY_GALLERY_INFO, galleryInfo); startActivity(intent); } + } else if (mNewerVersion == v) { + if (mGalleryDetail != null) { + GalleryDetailUrlParser.Result result = GalleryDetailUrlParser.parse(mGalleryDetail.newerUrl, false); + if (result != null) { + Bundle args = new Bundle(); + args.putString(GalleryDetailScene.KEY_ACTION, GalleryDetailScene.ACTION_GID_TOKEN); + args.putLong(GalleryDetailScene.KEY_GID, result.gid); + args.putString(GalleryDetailScene.KEY_TOKEN, result.token); + startScene(new Announcer(GalleryDetailScene.class).setArgs(args)); + } + } } else if (mInfo == v) { Bundle args = new Bundle(); args.putParcelable(GalleryInfoScene.KEY_GALLERY_DETAIL, mGalleryDetail); diff --git a/app/src/main/res/layout/gallery_detail_actions.xml b/app/src/main/res/layout/gallery_detail_actions.xml index edf246b6d..67b4984d7 100644 --- a/app/src/main/res/layout/gallery_detail_actions.xml +++ b/app/src/main/res/layout/gallery_detail_actions.xml @@ -22,6 +22,17 @@ android:paddingTop="@dimen/keyline_margin" android:paddingBottom="@dimen/keyline_margin"> + + Block the uploader \"%s\"? Block the tag \"%s\"? Blocker added + There are newer versions of this gallery available. MASTERPIECE