diff --git a/app/build.gradle b/app/build.gradle index fa38734..019e80d 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -1,6 +1,6 @@ apply plugin: 'com.android.application' -def Properties mVersionProps = getVersionProperties() +Properties mVersionProps = getVersionProperties() def mVersionCode = getVersionCode() @@ -12,7 +12,7 @@ android { buildToolsVersion '28.0.2' defaultConfig { applicationId "org.mazhuang.guanggoo" - minSdkVersion 15 + minSdkVersion 16 targetSdkVersion 28 versionCode mVersionCode versionName mVersionName @@ -46,7 +46,7 @@ android { } release { - def Properties signingProps = getSignProperties() + Properties signingProps = getSignProperties() if (signingProps != null) { storeFile file(signingProps['STORE_FILE']) storePassword signingProps['STORE_PASSWORD'] @@ -80,7 +80,7 @@ android { } def getVersionProperties() { - def Properties versionProps = new Properties() + Properties versionProps = new Properties() versionProps.load(new FileInputStream(file('../config/version.properties'))) return versionProps } @@ -88,17 +88,17 @@ def getVersionProperties() { static def getVersionCode() { try { String output = 'git rev-list HEAD --count '.execute().text.trim() - return Integer.valueOf(output); + return Integer.valueOf(output) } catch (Exception e) { - System.out.println(e.getMessage()); + System.out.println(e.getMessage()) } - return 1; + return 1 } def getSignProperties() { File signingPropertiesFile = file('../config/signing.properties') if (signingPropertiesFile.exists()) { - def Properties signingProperties = new Properties() + Properties signingProperties = new Properties() signingProperties.load(new FileInputStream(signingPropertiesFile)) if (signingProperties.containsKey('STORE_FILE') && signingProperties.containsKey('STORE_PASSWORD') && @@ -125,7 +125,8 @@ dependencies { implementation 'com.jakewharton:butterknife:8.8.1' implementation 'com.github.bumptech.glide:glide:4.8.0' annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0' - implementation 'org.sufficientlysecure:html-textview:3.5' + implementation 'org.sufficientlysecure:html-textview:3.6' + implementation 'me.saket:better-link-movement-method:2.2.0' implementation 'com.tencent.bugly:crashreport_upgrade:1.3.5' testImplementation 'junit:junit:4.12' annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1' diff --git a/app/src/main/java/org/mazhuang/guanggoo/topicdetail/CommentsListAdapter.java b/app/src/main/java/org/mazhuang/guanggoo/topicdetail/CommentsListAdapter.java index 1fcda0c..947fb11 100644 --- a/app/src/main/java/org/mazhuang/guanggoo/topicdetail/CommentsListAdapter.java +++ b/app/src/main/java/org/mazhuang/guanggoo/topicdetail/CommentsListAdapter.java @@ -1,6 +1,9 @@ package org.mazhuang.guanggoo.topicdetail; +import android.support.v4.app.Fragment; import android.support.v7.widget.RecyclerView; +import android.text.TextUtils; +import android.text.util.Linkify; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; @@ -13,8 +16,10 @@ import org.mazhuang.guanggoo.R; import org.mazhuang.guanggoo.data.OnResponseListener; import org.mazhuang.guanggoo.data.entity.Comment; +import org.mazhuang.guanggoo.router.FragmentFactory; import org.mazhuang.guanggoo.util.GlideUtil; import org.mazhuang.guanggoo.util.MyHtmlHttpImageGetter; +import org.mazhuang.guanggoo.util.UrlUtil; import org.sufficientlysecure.htmltextview.HtmlTextView; import java.util.Map; @@ -23,6 +28,7 @@ import butterknife.ButterKnife; import butterknife.OnClick; import butterknife.OnLongClick; +import me.saket.bettermovementmethod.BetterLinkMovementMethod; /** * @author mazhuang @@ -31,6 +37,23 @@ public class CommentsListAdapter extends RecyclerView.Adapter mData; private final CommentsActionListener mListener; + private BetterLinkMovementMethod.OnLinkClickListener mOnLinkClickListener = new BetterLinkMovementMethod.OnLinkClickListener() { + @Override + public boolean onClick(TextView textView, String url) { + if (mListener == null || TextUtils.isEmpty(url)) { + return false; + } + + url = UrlUtil.removeQuery(url); + + if (FragmentFactory.PageType.NONE != FragmentFactory.getPageTypeByUrl(url)) { + mListener.openPage(url, null); + return true; + } + + return false; + } + }; public CommentsListAdapter(CommentsActionListener listener) { mListener = listener; @@ -79,7 +102,12 @@ public void onBindViewHolder(final ViewHolder holder, int position) { holder.mFloorTextView.setText("#" + holder.mItem.getMeta().getFloor()); MyHtmlHttpImageGetter imageGetter = new MyHtmlHttpImageGetter(holder.mContentTextView); imageGetter.enableCompressImage(true, 30); + holder.mContentTextView.setHtml(holder.mItem.getContent(), imageGetter); + BetterLinkMovementMethod + .linkifyHtml(holder.mContentTextView) + .setOnLinkClickListener(mOnLinkClickListener); + holder.mVoteImageView.setEnabled(!holder.mItem.getMeta().getVote().isVoted()); holder.mVoteCountTextView.setText(String.valueOf(holder.mItem.getMeta().getVote().getCount())); diff --git a/app/src/main/java/org/mazhuang/guanggoo/topicdetail/TopicDetailFragment.java b/app/src/main/java/org/mazhuang/guanggoo/topicdetail/TopicDetailFragment.java index dd4667e..0942fc2 100644 --- a/app/src/main/java/org/mazhuang/guanggoo/topicdetail/TopicDetailFragment.java +++ b/app/src/main/java/org/mazhuang/guanggoo/topicdetail/TopicDetailFragment.java @@ -40,6 +40,7 @@ import org.mazhuang.guanggoo.util.GlideUtil; import org.mazhuang.guanggoo.util.PrefsUtil; import org.mazhuang.guanggoo.util.SoftInputUtil; +import org.mazhuang.guanggoo.util.UrlUtil; import butterknife.BindView; import butterknife.ButterKnife; @@ -348,11 +349,11 @@ private void initWebView() { mContentWebView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { + url = UrlUtil.removeQuery(url); + FragmentFactory.PageType pageType = FragmentFactory.getPageTypeByUrl(url); if (mListener != null) { - if (pageType == FragmentFactory.PageType.VIEW_IMAGE || - pageType == FragmentFactory.PageType.TOPIC_DETAIL || - pageType == FragmentFactory.PageType.USER_PROFILE) { + if (pageType != FragmentFactory.PageType.NONE) { mListener.openPage(url, null); return true; } diff --git a/config/version.properties b/config/version.properties index 6e1fa3c..6d796bc 100644 --- a/config/version.properties +++ b/config/version.properties @@ -1 +1 @@ -MAJOR_VERSION_NAME=2.0 +MAJOR_VERSION_NAME=2.1