Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

支持 Android X #396

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 5 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# RichText [ ![Download](https://api.bintray.com/packages/zzhoujay/maven/richtext/images/download.svg) ](https://bintray.com/zzhoujay/maven/richtext/_latestVersion)
# RichText-AndroidX

### 注意:此项目已不再维护
### 注意:原项目作者已经不维护了,不支持AndroidX,此项目使用原作者代码改造为支持Androidx

> Android平台下的富文本解析器

Expand All @@ -24,18 +24,10 @@
![演示](image/image.jpg "演示")


### gradle中引用的方法
### 引入方法

clone 该项目然后跑起来,打出 aar包然后引入自己的项目

```
compile 'com.zzhoujay.richtext:richtext:latest-version'
```

### 使用新的Html解析器

只需加入此依赖即可,无须其他操作,新Html解析器对原生Html解析器的功能做了补充
```
compile 'com.zzhoujay:html:latest-version'
```

新Html解析器增加了对代码块的支持,代码块可以触发点击事件,通过`urlClick`设置,
代码块回调的参数由`code://`开头
Expand Down
33 changes: 15 additions & 18 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
apply plugin: 'com.android.application'

android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
compileSdk 33
defaultConfig {
applicationId "zhou.demo"
minSdkVersion 15
targetSdkVersion 26
minSdkVersion 21
targetSdkVersion 33
versionCode 1
versionName "1.0"
}
Expand All @@ -16,24 +15,22 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
productFlavors {
}
dexOptions {
preDexLibraries = false
namespace 'zhou.demo'
lint {
abortOnError false
}
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile project(':richtext')
// compile project(':okhttpimagedownloader')
// compile 'com.zzhoujay.richtext:richtext:3.0.7'
compile 'com.zzhoujay:html:1.0.1'
// compile 'com.zzhoujay.okhttpimagedownloader:OkHttpImageDownloader:1.0.0'
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
// appcompat 1.7.0 会强制 compile = 34 这里先用 1.6.1
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'androidx.recyclerview:recyclerview:1.3.2'
implementation project(':richtext')
// implementation project(':okhttpimagedownloader')
// implementation 'com.zzhoujay.richtext:richtext:3.0.8'
implementation 'com.zzhoujay:html:1.0.2'
}
10 changes: 0 additions & 10 deletions app/src/androidTest/java/zhou/demo/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
package zhou.demo;

import android.app.Application;
import android.test.ApplicationTestCase;

/**
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
}
}
4 changes: 3 additions & 1 deletion app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<activity android:name=".MainActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/zhou/demo/DebugActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.app.Activity;
import android.os.Bundle;
import android.support.annotation.Nullable;
import androidx.annotation.Nullable;
import android.util.Log;
import android.widget.ImageView;
import android.widget.TextView;
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/zhou/demo/GifActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package zhou.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.view.View;
import android.widget.TextView;

Expand Down
30 changes: 15 additions & 15 deletions app/src/main/java/zhou/demo/ListViewActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package zhou.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
Expand All @@ -21,7 +21,7 @@
public class ListViewActivity extends AppCompatActivity {

// private static final String[] testString = new String[]{
// "<h3>Test1</h3><img src=\"http://h.hiphotos.baidu.com/image/h%3D200/sign=e72c850a09f3d7ca13f63876c21fbe3c/a2cc7cd98d1001e9460fd63bbd0e7bec54e797d7.jpg\" />",
// "<h3>Test1</h3><img src=\"https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6567102e7b814573bafbc56ca1309b82~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp\" />",
// "<h3>Test2</h3><img src=\"http://c.hiphotos.baidu.com/image/pic/item/f7246b600c3387448982f948540fd9f9d72aa0bb.jpg\" />",
// "<h3>Test3</h3><img src=\"http://c.hiphotos.baidu.com/image/pic/item/267f9e2f070828382dcc0b20bd99a9014d08f1c5.jpg\" />",
// "<h3>Test4</h3><img src=\"http://f.hiphotos.baidu.com/image/pic/item/32fa828ba61ea8d358824a0d950a304e251f5812.jpg\" />",
Expand All @@ -35,20 +35,20 @@ public class ListViewActivity extends AppCompatActivity {
private static final String gifTest = "<h3>Gif Test</h3><img src=\"http://ww4.sinaimg.cn/large/5cfc088ejw1f3jcujb6d6g20ap08mb2c.gif\"/>";

private static final String[] testString = {
"<h3>Test1</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/1.gif\" />",
"<h3>Test2</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/2.gif\" />",
"<h3>Test3</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/3.gif\" />",
"<h3>Test4</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/4.gif\" />",
"<h3>Test5</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/5.gif\" />",
"<h3>Test6</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/6.gif\" />",
"<h3>Test7</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/7.gif\" />",
"<h3>Test8</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/8.gif\" />",
"<h3>Test9</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/9.gif\" />"
"<h3>Test1</h3><img src=\"http://img.soogif.com/Xm3zewwGUgBRunDeS7Of8NwmQ4t3sakO.gif\" />",
"<h3>Test2</h3><img src=\"http://img.soogif.com/iAYcT06yJ5q2nCMZWAA5EhsqIXctOt8y.gif\" />",
"<h3>Test3</h3><img src=\"https://img.soogif.com/rSlMSm7msQagXhSSgIQ0LtqTusCK712l.gif\" />",
"<h3>Test4</h3><img src=\"http://img.soogif.com/0KrElalx3tSiiL2vJGf1YWjIHUfiq73d.gif\" />",
"<h3>Test5</h3><img src=\"http://img.soogif.com/s95N1KWG8fGeQHPdiwvmiy4SJUU5zTnr.gif\" />",
"<h3>Test6</h3><img src=\"https://img.soogif.com/ECtUVa5UQsiDDU7og85Ue4NHfysXbeMm.gif\" />",
"<h3>Test7</h3><img src=\"https://img.soogif.com/UPv53hBqhwuUKs5E5FDPh4gsRx5Ew02F.gif\" />",
"<h3>Test8</h3><img src=\"https://img.soogif.com/osrtKN8i84Kq0EjKQeMaKpiba2n6oX7D.gif\" />",
"<h3>Test9</h3><img src=\"https://img.soogif.com/O0o2yMSfsE5buC6o7DLNBgRWie3piZyA.gif\" />"
};
private static final String[] testString__ = {
"<h3>Test1</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/1.gif\" />",
"<h3>Test2</h3><img src=\"http://d.hiphotos.baidu.com/image/pic/item/54fbb2fb43166d22dc28839a442309f79052d265.jpg\" />",
"<h3>Test9</h3><img src=\"http://www.aikf.com/ask/resources/images/facialExpression/qq/8.gif\" />",
"<h3>Test1</h3><img src=\"http://img.soogif.com/0KrElalx3tSiiL2vJGf1YWjIHUfiq73d.gif\" />",
"<h3>Test2</h3><img src=\"https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/d78f9d5f2fa14d1cae48dc6dee3ba6d1~tplv-k3u1fbpfcp-zoom-in-crop-mark:3024:0:0:0.awebp\" />",
"<h3>Test9</h3><img src=\"https://img.soogif.com/UPv53hBqhwuUKs5E5FDPh4gsRx5Ew02F.gif\" />",
"<h3>Test3</h3><img src=\"http://f.hiphotos.baidu.com/image/pic/item/3b87e950352ac65cad5ff279f9f2b21193138a66.jpg\" />",
"<h3>Test4</h3><img src=\"http://c.hiphotos.baidu.com/image/pic/item/63d9f2d3572c11dfd3042623612762d0f603c2dd.jpg\" />",
"<h3>Test5</h3><img src=\"http://d.hiphotos.baidu.com/image/pic/item/562c11dfa9ec8a13f075f10cf303918fa1ecc0eb.jpg\" />",
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/zhou/demo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import androidx.appcompat.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
Expand Down Expand Up @@ -78,7 +78,7 @@ public class MainActivity extends AppCompatActivity {
"<h3><a href=\"#效果\" aria-hidden=\"true\" class=\"anchor\" id=\"user-content-效果\"><svg aria-hidden=\"true\" class=\"octicon octicon-link\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>效果</h3>\n" +
"<p><a href=\"/zzhoujay/RichText/blob/master/image/image.jpg\" target=\"_blank\"><img src=\"/zzhoujay/RichText/raw/master/image/image.jpg\" alt=\"演示\" title=\"演示\" style=\"max-width:100%;\"></a></p>\n" +
"<h3><a href=\"#gradle中引用的方法\" aria-hidden=\"true\" class=\"anchor\" id=\"user-content-gradle中引用的方法\"><svg aria-hidden=\"true\" class=\"octicon octicon-link\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>gradle中引用的方法</h3>\n" +
"<pre><code>compile 'com.zzhoujay.richtext:richtext:3.0.5'\n" +
"<pre><code>implementation 'com.zzhoujay.richtext:richtext:3.0.5'\n" +
"</code></pre>\n" +
"<h3><a href=\"#关于issue\" aria-hidden=\"true\" class=\"anchor\" id=\"user-content-关于issue\"><svg aria-hidden=\"true\" class=\"octicon octicon-link\" height=\"16\" version=\"1.1\" viewBox=\"0 0 16 16\" width=\"16\"><path fill-rule=\"evenodd\" d=\"M4 9h1v1H4c-1.5 0-3-1.69-3-3.5S2.55 3 4 3h4c1.45 0 3 1.69 3 3.5 0 1.41-.91 2.72-2 3.25V8.59c.58-.45 1-1.27 1-2.09C10 5.22 8.98 4 8 4H4c-.98 0-2 1.22-2 2.5S3 9 4 9zm9-3h-1v1h1c1 0 2 1.22 2 2.5S13.98 12 13 12H9c-.98 0-2-1.22-2-2.5 0-.83.42-1.64 1-2.09V6.25c-1.09.53-2 1.84-2 3.25C6 11.31 7.55 13 9 13h4c1.45 0 3-1.69 3-3.5S14.5 6 13 6z\"></path></svg></a>关于issue</h3>\n" +
"<p style=\"text-indent:50px;\">最近一段时间会比较忙,issue不能及时处理,一般会定时抽空集中解决issue,但时间有限解决速度上不敢保证。</p>\n" +
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/zhou/demo/RecyclerViewActivity.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package zhou.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -18,7 +18,7 @@
public class RecyclerViewActivity extends AppCompatActivity {

private static final String[] testString1 = new String[]{
"<h3>Test1</h3><img src=\"http://h.hiphotos.baidu.com/image/h%3D200/sign=e72c850a09f3d7ca13f63876c21fbe3c/a2cc7cd98d1001e9460fd63bbd0e7bec54e797d7.jpg\" />",
"<h3>Test1</h3><img src=\"https://p9-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/6567102e7b814573bafbc56ca1309b82~tplv-k3u1fbpfcp-zoom-crop-mark:3024:3024:3024:1702.awebp\" />",
"<h3>Test2</h3><img src=\"http://c.hiphotos.baidu.com/image/pic/item/f7246b600c3387448982f948540fd9f9d72aa0bb.jpg\" />",
"<h3>Test3</h3><img src=\"http://c.hiphotos.baidu.com/image/pic/item/267f9e2f070828382dcc0b20bd99a9014d08f1c5.jpg\" />",
"<h3>Test4</h3><img src=\"http://f.hiphotos.baidu.com/image/pic/item/32fa828ba61ea8d358824a0d950a304e251f5812.jpg\" />",
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/zhou/demo/TestActivity.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package zhou.demo;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v7.app.AppCompatActivity;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import android.widget.TextView;
import android.widget.Toast;

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/activity_recycler.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
android:layout_height="match_parent"
android:orientation="vertical">

<android.support.v7.widget.RecyclerView
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent" />
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/hello.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
### gradle中引用的方法

```
compile 'com.zzhoujay.richtext:richtext:1.1.5'
implementation 'com.zzhoujay.richtext:richtext:1.1.5'
```

---
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/raw/tt.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ RichText.fromMarkdown(markdown).into(textView);

### Use in Gradle

`compile 'com.zzhoujay.markdown:markdown:0.0.4'`
`implementation 'com.zzhoujay.markdown:markdown:0.0.4'`


### 已知问题
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/network_security_config.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">ww4.sinaimg.cn</domain>
<domain includeSubdomains="true">baidu.com</domain>
</domain-config>
</network-security-config>
33 changes: 9 additions & 24 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,24 @@

buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
mavenCentral()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
classpath 'com.novoda:bintray-release:0.7.0'

// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.android.tools.build:gradle:7.2.2'
}
}

allprojects {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}

tasks.withType(Javadoc) {
options {
encoding "UTF-8"
charSet 'UTF-8'
links "http://docs.oracle.com/javase/7/docs/api"
}
maven { url 'https://maven.aliyun.com/repository/public' }
maven { url 'https://maven.aliyun.com/repository/central' }
maven { url 'https://maven.aliyun.com/repository/jcenter' }
mavenCentral()
google()
}
}

task clean(type: Delete) {
tasks.register('clean', Delete) {
delete rootProject.buildDir
}
17 changes: 8 additions & 9 deletions glideimagegetter/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,11 @@ def version_code = 6
def version_name = "1.0.5"

android {
compileSdkVersion 24
buildToolsVersion "25.0.0"
compileSdkVersion 33

defaultConfig {
minSdkVersion 7
targetSdkVersion 24
minSdkVersion 15
targetSdkVersion 33
versionCode version_code
versionName version_name

Expand All @@ -32,11 +31,11 @@ android {
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.zzhoujay.richtext:richtext:2.5.+'
// compile project(':richtext')
implementation fileTree(include: ['*.jar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.zzhoujay.richtext:richtext:3.0.8'
// implementation project(':richtext')
}

publish {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v4.util.LruCache;
import androidx.collection.LruCache;
import android.widget.TextView;

import com.bumptech.glide.BitmapTypeRequest;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.support.v7.widget.TintContextWrapper;
import androidx.appcompat.widget.TintContextWrapper;
import android.widget.TextView;

import com.bumptech.glide.request.target.BaseTarget;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.annotation.NonNull;
import androidx.annotation.NonNull;
import android.widget.TextView;

import com.bumptech.glide.Glide;
Expand Down
4 changes: 3 additions & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,6 @@
# When configured, Gradle will run in incubating parallel mode.
# This option should only be used with decoupled projects. More details, visit
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true
# org.gradle.parallel=true
android.enableJetifier=true
android.useAndroidX=true
Loading