Skip to content

Commit

Permalink
Merge pull request #8 from sakacyber/v1
Browse files Browse the repository at this point in the history
Push v1 to master
  • Loading branch information
sakacyber authored Nov 24, 2022
2 parents 7a3b017 + fcb065f commit fcfacf7
Show file tree
Hide file tree
Showing 28 changed files with 146 additions and 136 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ It currently supports tags </>:
* ```<u>```

## Quick Start
**HtmlTextView** is availble on jitpack.
**HtmlTextView** is available on jitpack.

Add dependency:

```
implementation "com.github.sakacyber:html-textview:1.0.13"
implementation "com.github.sakacyber:html-textview:1.0.14"
```

## Usage
Expand All @@ -53,5 +53,5 @@ to use **HtmlTextView**:
android:padding="16dp" />
// activity or fragment
htmlTextView.setText(html)
htmlTextView.setText(html, lifecycleScope)
```
12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
apply plugin: "com.android.application"
apply plugin: "kotlin-android"

def versionNameStr = "1.0.14"

android {

compileSdkVersion 31
compileSdkVersion 33

defaultConfig {
applicationId "com.sakacyber.android.sample"
minSdkVersion 23
targetSdkVersion 31
versionCode 13
versionName "1.0.13"
targetSdkVersion 33
versionCode 14
versionName versionNameStr

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand All @@ -30,7 +32,7 @@ android {
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}

namespace "com.sakacyber.android.sample"
}

dependencies {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.sakacyber.android.sample

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.runner.AndroidJUnit4
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
3 changes: 1 addition & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.sakacyber.android.sample">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<uses-permission android:name="android.permission.INTERNET" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/com/sakacyber/android/sample/Content.kt
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ class Content {
return sb.toString()
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.sakacyber.android.sample

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.saka.android.htmltextview.HtmlTextView

Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
android:id="@+id/htmlTextView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="16dp" />
android:padding="16dp"
app:htmlTextColor="@color/colorPrimary" />

</androidx.core.widget.NestedScrollView>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
package com.sakacyber.android.sample

import org.junit.Assert.assertEquals
import org.junit.Test

import org.junit.Assert.*

/**
* Example local unit test, which will execute on the development machine (host).
*
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "com.android.tools.build:gradle:7.3.1"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath "com.github.dcendents:android-maven-gradle-plugin:2.1"

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4-bin.zip
41 changes: 20 additions & 21 deletions html-textview/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
apply plugin: "com.android.library"
apply plugin: "kotlin-android"
apply plugin: "kotlin-kapt"

group = 'com.github.SakaGamer'
group = "com.github.SakaGamer"

android {

Expand All @@ -11,11 +11,9 @@ android {
defaultConfig {
minSdkVersion 21
targetSdkVersion 31
versionCode 1
versionName "1.0"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'consumer-rules.pro'
consumerProguardFiles "consumer-rules.pro"
}

compileOptions {
Expand All @@ -30,32 +28,33 @@ android {
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro"
}
}
namespace "com.saka.android.htmltextview"
}

dependencies {

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.appcompat:appcompat:1.4.1"
implementation "androidx.core:core-ktx:1.7.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.4.1"

// java HTML parser
implementation 'org.jsoup:jsoup:1.13.1'
implementation "org.jsoup:jsoup:1.13.1"

// image loader
implementation 'com.github.bumptech.glide:glide:4.12.0'
kapt 'com.github.bumptech.glide:compiler:4.12.0'
implementation "com.github.bumptech.glide:glide:4.12.0"
kapt "com.github.bumptech.glide:compiler:4.12.0"

implementation 'com.google.android.exoplayer:exoplayer:2.17.1'
implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
implementation 'io.github.muddz:quickshot:1.4.0'
implementation 'com.karumi:dexter:6.2.2'
implementation "com.google.android.exoplayer:exoplayer:2.18.2"
implementation "com.github.stfalcon-studio:StfalconImageViewer:v1.0.1"
implementation "io.github.muddz:quickshot:1.4.0"
implementation "com.karumi:dexter:6.2.2"

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
testImplementation "junit:junit:4.13.2"
androidTestImplementation "androidx.test.ext:junit:1.1.3"
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"

implementation 'com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1'
implementation "com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1"
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.saka.android.htmltextview

import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.ext.junit.runners.AndroidJUnit4

import androidx.test.platform.app.InstrumentationRegistry
import org.junit.Assert.assertEquals
import org.junit.Test
import org.junit.runner.RunWith

import org.junit.Assert.*

/**
* Instrumented test, which will execute on an Android device.
*
Expand Down
3 changes: 1 addition & 2 deletions html-textview/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.saka.android.htmltextview">
<manifest xmlns:android="http://schemas.android.com/apk/res/android">

<application android:label="@string/app_name">

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.saka.android.htmltextview
import android.content.Context
import android.util.AttributeSet
import android.widget.LinearLayout
import androidx.core.content.ContextCompat
import androidx.core.widget.NestedScrollView
import androidx.lifecycle.LifecycleCoroutineScope
import com.saka.android.htmltextview.utility.Conf
Expand All @@ -13,9 +14,9 @@ import org.jsoup.Jsoup
class HtmlTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0,
defStyleAttr: Int = 0
) : NestedScrollView(context, attrs, defStyleAttr) {

init {
val typeArray = context.obtainStyledAttributes(
attrs,
Expand All @@ -25,6 +26,10 @@ class HtmlTextView @JvmOverloads constructor(
R.styleable.HtmlTextView_htmlTextSize,
Conf.DEF_TEXT_SIZE
)
Conf.textColor = typeArray.getColor(
R.styleable.HtmlTextView_htmlTextColor,
ContextCompat.getColor(context, R.color.colorTextPrimary)
)
Conf.textLineSpacing = typeArray.getDimension(
R.styleable.HtmlTextView_htmlLineSpacing,
Conf.DEF_LINE_SPACING
Expand All @@ -40,7 +45,7 @@ class HtmlTextView @JvmOverloads constructor(
htmlContent = typeArray.getString(R.styleable.HtmlTextView_htmlContent) ?: ""
typeArray.recycle()
}

fun setText(html: String?, lifecycle: LifecycleCoroutineScope) {
htmlContent = html ?: return
val children = Jsoup.parse(htmlContent).body().children()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ import com.saka.android.htmltextview.R
import com.saka.android.htmltextview.utility.VideoLoader

class VideoActivity : AppCompatActivity() {

private var player: ExoPlayer? = null

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
setContentView(R.layout.activity_video)
val toolbar = findViewById<Toolbar>(R.id.toolbar)
setSupportActionBar(toolbar)

val youTubePlayerView = findViewById<YouTubePlayerView>(R.id.youtube_player_view)
val playerView = findViewById<StyledPlayerView>(R.id.playerView)
val webView = findViewById<WebView>(R.id.webView)
Expand All @@ -47,28 +47,30 @@ class VideoActivity : AppCompatActivity() {
}
}
}

private fun loadExoPlayer(link: String, playerView: StyledPlayerView, toolbar: Toolbar) {
// create player view
playerView.setShowBuffering(StyledPlayerView.SHOW_BUFFERING_WHEN_PLAYING)
playerView.setControllerVisibilityListener { visibility ->
toolbar.visibility = visibility
}

playerView.setControllerVisibilityListener(
StyledPlayerView.ControllerVisibilityListener {
toolbar.visibility = it
}
)

// create media source
val dataSourceFactory = DefaultDataSource.Factory(this)
val mediaItem = MediaItem.fromUri(link)
val mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory)
.createMediaSource(mediaItem)

// create player
player = ExoPlayer.Builder(this).build()
player?.setMediaSource(mediaSource)
player?.prepare()
player?.playWhenReady = true
playerView.player = player
}

private fun loadYoutubePlayer(
videoId: String?,
playerView: YouTubePlayerView,
Expand All @@ -83,7 +85,7 @@ class VideoActivity : AppCompatActivity() {
}
})
}

@SuppressLint("SetJavaScriptEnabled")
private fun loadIFrameWebView(link: String, webView: WebView) {
webView.settings.javaScriptEnabled = true
Expand All @@ -93,19 +95,19 @@ class VideoActivity : AppCompatActivity() {
)
webView.loadData(encodedHtml, "text/html", "base64")
}

override fun onSupportNavigateUp(): Boolean {
finish()
return super.onSupportNavigateUp()
}

override fun onPause() {
super.onPause()
if (player != null) {
player?.playWhenReady = false
}
}

override fun onDestroy() {
super.onDestroy()
if (player != null) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package com.saka.android.htmltextview.callback

interface ClickEventCallback {
fun onHtmlImageClick(pos: Int, src: String?){}
fun onHtmlVideoClick(pos: Int, src: String?){}
fun onHtmlImageClick(pos: Int, src: String?) {}
fun onHtmlVideoClick(pos: Int, src: String?) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class BlockQuoteView @JvmOverloads constructor(
content: String = "",
coroutineScope: CoroutineScope? = null
) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) {

override fun render() {
orientation = VERTICAL
layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)
Expand All @@ -31,7 +31,7 @@ class BlockQuoteView @JvmOverloads constructor(
}
setText()
}

private fun setText() {
val paragraphView = TextView(context)
paragraphView.setTypeface(paragraphView.typeface, Typeface.ITALIC)
Expand Down
Loading

0 comments on commit fcfacf7

Please sign in to comment.