├── .gitignore ├── .idea ├── .name ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── compiler.xml ├── dictionaries │ └── saka.xml ├── gradle.xml ├── jarRepositories.xml ├── kotlinc.xml ├── misc.xml └── vcs.xml ├── LICENSE.txt ├── README.md ├── _config.yml ├── app ├── .gitignore ├── build.gradle ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── sakacyber │ │ └── android │ │ └── sample │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── sakacyber │ │ │ └── android │ │ │ └── sample │ │ │ ├── Content.kt │ │ │ └── MainActivity.kt │ └── res │ │ ├── drawable-v24 │ │ └── ic_launcher_foreground.xml │ │ ├── drawable │ │ └── ic_launcher_background.xml │ │ ├── layout │ │ └── activity_main.xml │ │ ├── mipmap-anydpi-v26 │ │ ├── ic_launcher.xml │ │ └── ic_launcher_round.xml │ │ ├── mipmap-hdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-mdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── mipmap-xxxhdpi │ │ ├── ic_launcher.png │ │ └── ic_launcher_round.png │ │ ├── raw │ │ └── content.json │ │ └── values │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── styles.xml │ └── test │ └── java │ └── com │ └── sakacyber │ └── android │ └── sample │ └── ExampleUnitTest.kt ├── build.gradle ├── gradle.properties ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradlew ├── gradlew.bat ├── html-textview ├── .gitignore ├── build.gradle ├── consumer-rules.pro ├── proguard-rules.pro └── src │ ├── androidTest │ └── java │ │ └── com │ │ └── saka │ │ └── android │ │ └── htmltextview │ │ └── ExampleInstrumentedTest.kt │ ├── main │ ├── AndroidManifest.xml │ ├── java │ │ └── com │ │ │ └── saka │ │ │ └── android │ │ │ └── htmltextview │ │ │ ├── HtmlTextView.kt │ │ │ ├── activity │ │ │ ├── ImageActivity.kt │ │ │ ├── OverlayView.kt │ │ │ └── VideoActivity.kt │ │ │ ├── callback │ │ │ └── ClickEventCallback.kt │ │ │ ├── element │ │ │ ├── BaseElement.kt │ │ │ ├── BlockQuoteView.kt │ │ │ ├── DivView.kt │ │ │ ├── HeaderView.kt │ │ │ ├── IFrameView.kt │ │ │ ├── ImageView.kt │ │ │ ├── ParagraphView.kt │ │ │ ├── RoundImageView.kt │ │ │ ├── WebView.kt │ │ │ └── WebViewCompat.kt │ │ │ └── utility │ │ │ ├── Conf.kt │ │ │ ├── EManager.kt │ │ │ ├── Extension.kt │ │ │ ├── MyActivity.kt │ │ │ ├── ThumbnailLoader.kt │ │ │ └── VideoLoader.kt │ └── res │ │ ├── drawable │ │ ├── bg_placeholder.xml │ │ ├── bg_ripple_effect.xml │ │ ├── ic_close_24.xml │ │ ├── ic_more_vert_24.xml │ │ ├── ic_play_circle_24.xml │ │ └── img_holder.png │ │ ├── font │ │ └── font_battambang_regular.ttf │ │ ├── layout │ │ ├── activity_video.xml │ │ ├── main.xml │ │ ├── video_progress.xml │ │ ├── view_overlay.xml │ │ └── view_video_controller.xml │ │ ├── menu │ │ └── save_menu.xml │ │ └── values │ │ ├── attr.xml │ │ ├── colors.xml │ │ ├── strings.xml │ │ └── values.xml │ └── test │ └── java │ └── com │ └── saka │ └── android │ └── htmltextview │ └── ExampleUnitTest.kt ├── jitpack.yml └── settings.gradle /.gitignore: -------------------------------------------------------------------------------- 1 | *.iml 2 | .gradle 3 | /local.properties 4 | /.idea/caches 5 | /.idea/libraries 6 | /.idea/modules.xml 7 | /.idea/workspace.xml 8 | /.idea/navEditor.xml 9 | /.idea/assetWizardSettings.xml 10 | .DS_Store 11 | /build 12 | /captures 13 | .externalNativeBuild 14 | .cxx 15 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | HtmlTextView -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | xmlns:android 17 | 18 | ^$ 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | xmlns:.* 28 | 29 | ^$ 30 | 31 | 32 | BY_NAME 33 | 34 | 35 | 36 | 37 | 38 | 39 | .*:id 40 | 41 | http://schemas.android.com/apk/res/android 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | .*:name 51 | 52 | http://schemas.android.com/apk/res/android 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | name 62 | 63 | ^$ 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | style 73 | 74 | ^$ 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | .* 84 | 85 | ^$ 86 | 87 | 88 | BY_NAME 89 | 90 | 91 | 92 | 93 | 94 | 95 | .* 96 | 97 | http://schemas.android.com/apk/res/android 98 | 99 | 100 | ANDROID_ATTRIBUTE_ORDER 101 | 102 | 103 | 104 | 105 | 106 | 107 | .* 108 | 109 | .* 110 | 111 | 112 | BY_NAME 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/dictionaries/saka.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | blockquote 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/jarRepositories.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /.idea/kotlinc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Saka 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://jitpack.io/#sakacyber/html-textview) 2 | 3 | # HtmlTextView 4 | 5 | **HtmlTextView** Android project is an open-source library that enables developers to display formatted HTML content in a TextView widget within an Android application. 6 | 7 | With this library, developers can easily display HTML content, including text, images, links, and other media, using a TextView widget without the need for any additional customization or coding. This is particularly useful when developers want to display formatted content that has been obtained from a web API or other online source, or when they want to create rich-text documents within their application. 8 | 9 | Support tag base on build in [Html.fromHtml (String source, 10 | int flags)](https://developer.android.com/reference/android/text/Html#fromHtml(java.lang.String,%20int)) in android 11 | 12 | ## Quick Start 13 | 14 | **HtmlTextView** is available on jitpack. 15 | 16 | Add dependency: 17 | 18 | ```groovy 19 | implementation "com.github.sakacyber:html-textview:1.0.15" 20 | ``` 21 | 22 | ## Usage 23 | 24 | to use **HtmlTextView**: 25 | 26 | ```xml 27 | 32 | ``` 33 | 34 | In Activity or Fragment 35 | 36 | ```kotlin 37 | // activity or fragment 38 | htmlTextView.setText(html, lifecycleScope) 39 | ``` 40 | 41 | update text size 42 | 43 | ```kotlin 44 | // size in dp 45 | htmlTextView.updateTextSize(18f) 46 | ``` -------------------------------------------------------------------------------- /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-cayman -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.application" 2 | apply plugin: "kotlin-android" 3 | 4 | def versionNameStr = "1.0.15" 5 | 6 | android { 7 | 8 | compileSdkVersion 33 9 | 10 | defaultConfig { 11 | applicationId "com.sakacyber.android.sample" 12 | minSdkVersion 23 13 | targetSdkVersion 33 14 | versionCode 14 15 | versionName versionNameStr 16 | 17 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 18 | } 19 | 20 | compileOptions { 21 | sourceCompatibility JavaVersion.VERSION_17 22 | targetCompatibility JavaVersion.VERSION_17 23 | } 24 | 25 | kotlinOptions { 26 | jvmTarget = "17" 27 | } 28 | 29 | buildTypes { 30 | release { 31 | minifyEnabled false 32 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" 33 | } 34 | } 35 | 36 | buildFeatures { 37 | buildConfig = true 38 | } 39 | 40 | namespace "com.sakacyber.android.sample" 41 | } 42 | 43 | dependencies { 44 | 45 | implementation "androidx.appcompat:appcompat:$appCompatVersion" 46 | implementation "androidx.core:core-ktx:$coreVersion" 47 | implementation "androidx.constraintlayout:constraintlayout:$constrainLayoutVersion" 48 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" 49 | 50 | implementation 'com.google.code.gson:gson:2.10.1' 51 | implementation project(":html-textview") 52 | 53 | testImplementation "junit:junit:$junitVersion" 54 | androidTestImplementation "androidx.test:runner:$testRuner" 55 | androidTestImplementation "androidx.test.espresso:espresso-core:$testEspressoVersion" 56 | } 57 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/sakacyber/android/sample/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.sakacyber.android.sample 2 | 3 | import androidx.test.platform.app.InstrumentationRegistry 4 | import androidx.test.runner.AndroidJUnit4 5 | import org.junit.Assert.assertEquals 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * Instrumented test, which will execute on an Android device. 11 | * 12 | * See [testing documentation](http://d.android.com/tools/testing). 13 | */ 14 | @RunWith(AndroidJUnit4::class) 15 | class ExampleInstrumentedTest { 16 | @Test 17 | fun useAppContext() { 18 | // Context of the app under test. 19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 20 | assertEquals("com.saka.android.htmltextview", appContext.packageName) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 14 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /app/src/main/java/com/sakacyber/android/sample/Content.kt: -------------------------------------------------------------------------------- 1 | package com.sakacyber.android.sample 2 | 3 | import android.content.Context 4 | import com.google.gson.Gson 5 | import java.io.BufferedReader 6 | import java.io.IOException 7 | import java.io.InputStream 8 | import java.io.InputStreamReader 9 | 10 | class Content { 11 | 12 | val content: String = "" 13 | 14 | companion object { 15 | 16 | @JvmStatic 17 | fun deserialize(context: Context): Content? { 18 | try { 19 | val jsonString = parseResource(context, R.raw.content) 20 | return Gson().fromJson(jsonString, Content::class.java) 21 | } catch (e: IOException) { 22 | e.printStackTrace() 23 | } 24 | return null 25 | } 26 | 27 | @Throws(IOException::class) 28 | fun parseResource(context: Context, resource: Int): String { 29 | val inputStream: InputStream = context.resources.openRawResource(resource) 30 | val sb = StringBuilder() 31 | val br = BufferedReader(InputStreamReader(inputStream)) 32 | var read = br.readLine() 33 | while (read != null) { 34 | sb.append(read) 35 | read = br.readLine() 36 | } 37 | return sb.toString() 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /app/src/main/java/com/sakacyber/android/sample/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.sakacyber.android.sample 2 | 3 | import android.os.Bundle 4 | import android.widget.Button 5 | import androidx.appcompat.app.AppCompatActivity 6 | import androidx.lifecycle.lifecycleScope 7 | import com.saka.android.htmltextview.HtmlTextView 8 | 9 | class MainActivity : AppCompatActivity() { 10 | 11 | private var fontLarge = false 12 | 13 | override fun onCreate(savedInstanceState: Bundle?) { 14 | super.onCreate(savedInstanceState) 15 | setContentView(R.layout.activity_main) 16 | 17 | val content = Content.deserialize(this) 18 | val htmlTextView = findViewById(R.id.htmlTextView) 19 | htmlTextView.setText(content?.content, lifecycleScope) 20 | 21 | val button = findViewById(R.id.buttonFont) 22 | button.setOnClickListener { 23 | if (fontLarge) 24 | htmlTextView.updateTextSize(16f) 25 | else 26 | htmlTextView.updateTextSize(24f) 27 | fontLarge = !fontLarge 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /app/src/main/res/drawable-v24/ic_launcher_foreground.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 15 | 18 | 21 | 22 | 23 | 24 | 30 | -------------------------------------------------------------------------------- /app/src/main/res/drawable/ic_launcher_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 10 | 15 | 20 | 25 | 30 | 35 | 40 | 45 | 50 | 55 | 60 | 65 | 70 | 75 | 80 | 85 | 90 | 95 | 100 | 105 | 110 | 115 | 120 | 125 | 130 | 135 | 140 | 145 | 150 | 155 | 160 | 165 | 170 | 171 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 16 | 17 | 24 | 25 | 26 | 27 | 36 | 37 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-hdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-mdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png -------------------------------------------------------------------------------- /app/src/main/res/raw/content.json: -------------------------------------------------------------------------------- 1 | { 2 | "content": "Header 2រថយន្ត Chevrolet Blazer ឆ្នាំ២០២០ ដែលមានទាំងជម្រើសកៅអី ២ជួរ និង ៣ជួរ ត្រូវបានដាក់លក់ក្នុងតម្លៃចាប់ពីខ្ទង់ ៣៦ ៧៣០ដុល្លារ ដល់ ៤៦ ៦២៥ដុល្លារ ក្នុងប្រទេសចិន ខណៈតម្លៃលក់នៅសហរដ្ឋអាមេរិក គឺត្រឹមតែ ២៨ ៨០០ដុល្លារប៉ុណ្ណោះ។រថយន្តតួខ្ពស់របស់អាមេរិកនេះ ផ្តល់នូវមុខងារពិសេសៗជាច្រើន ដូចជា MyLink+ Infotainment System ជាមួយ OnStar, Apple CarPlay និង Baidu CarLife, Real-time Traffic, ផែនទី និងដំបូល Panoramic Sunroof ជាដើម។ក្រៅពីនោះ វាក៏បំពាក់ប្រព័ន្ធកាមេរ៉ាមើលជុំវិញរថយន្ត ៣៦០ដឺក្រេ, មុខងារ Automatic Parking Assist, Adaptive Cruise Control, Hill Descent Control, Vehicle Stability Control, Roll Over Protection, Electronic Stability Control និងជាច្រើនទៀត។រថយន្ត Chevrolet Blazer បំពាក់ម៉ាស៊ីនចំណុះ ២,០លីត្រ Ecotec Turbocharged ទំហំ ៤ស៊ីឡាំង មានកម្លាំង ២៣៣សេះ អាចរត់ស្ទុះពីកុងទ័រ ០-១០០គីឡូម៉ែត្រក្នុងមួយម៉ោង ប្រើពេល ៩វិនាទី ហើយមានកម្រិតស៊ីសាំងជាមធ្យម ៧,៤លីត្រ សម្រាប់ការបើកបរចម្ងាយ ១០០គីឡូម៉ែត្រ។ វាមានមុខងារបើកប ៤ គឺ Normal, AWD, Off-Road និង Sport៕" 3 | } -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #6200EE 4 | #3700B3 5 | #03DAC5 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | HtmlTextView 3 | 4 | 5 | -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/test/java/com/sakacyber/android/sample/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.sakacyber.android.sample 2 | 3 | import org.junit.Assert.assertEquals 4 | import org.junit.Test 5 | 6 | /** 7 | * Example local unit test, which will execute on the development machine (host). 8 | * 9 | * See [testing documentation](http://d.android.com/tools/testing). 10 | */ 11 | class ExampleUnitTest { 12 | @Test 13 | fun addition_isCorrect() { 14 | assertEquals(4, 2 + 2) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | buildscript { 3 | 4 | ext { 5 | kotlinVersion = "1.8.0" 6 | appCompatVersion = "1.6.1" 7 | coreVersion = "1.10.0" 8 | constrainLayoutVersion = "2.1.4" 9 | lifecycleVersion = "2.6.1" 10 | 11 | junitVersion = "4.13.2" 12 | testRuner = "1.4.0" 13 | testEspressoVersion = "3.4.0" 14 | } 15 | 16 | repositories { 17 | google() 18 | mavenCentral() 19 | maven { url "https://jitpack.io" } 20 | } 21 | 22 | dependencies { 23 | classpath 'com.android.tools.build:gradle:8.0.0' 24 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion" 25 | classpath "com.github.dcendents:android-maven-gradle-plugin:2.1" 26 | 27 | // NOTE: Do not place your application dependencies here; they belong 28 | // in the individual module build.gradle files 29 | } 30 | } 31 | 32 | allprojects { 33 | repositories { 34 | google() 35 | mavenCentral() 36 | maven { url "https://jitpack.io" } 37 | } 38 | } 39 | 40 | task clean(type: Delete) { 41 | delete rootProject.buildDir 42 | } 43 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | android.defaults.buildfeatures.buildconfig=true 23 | android.nonTransitiveRClass=true 24 | android.nonFinalResIds=false 25 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Thu May 21 10:17:31 ICT 2020 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip 7 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto init 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto init 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :init 68 | @rem Get command-line arguments, handling Windows variants 69 | 70 | if not "%OS%" == "Windows_NT" goto win9xME_args 71 | 72 | :win9xME_args 73 | @rem Slurp the command line arguments. 74 | set CMD_LINE_ARGS= 75 | set _SKIP=2 76 | 77 | :win9xME_args_slurp 78 | if "x%~1" == "x" goto execute 79 | 80 | set CMD_LINE_ARGS=%* 81 | 82 | :execute 83 | @rem Setup the command line 84 | 85 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 86 | 87 | 88 | @rem Execute Gradle 89 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 90 | 91 | :end 92 | @rem End local scope for the variables with windows NT shell 93 | if "%ERRORLEVEL%"=="0" goto mainEnd 94 | 95 | :fail 96 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 97 | rem the _cmd.exe /c_ return code! 98 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 99 | exit /b 1 100 | 101 | :mainEnd 102 | if "%OS%"=="Windows_NT" endlocal 103 | 104 | :omega 105 | -------------------------------------------------------------------------------- /html-textview/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /html-textview/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: "com.android.library" 2 | apply plugin: "kotlin-android" 3 | apply plugin: "kotlin-kapt" 4 | 5 | group = "com.github.sakacyber" 6 | 7 | android { 8 | 9 | compileSdkVersion 33 10 | 11 | defaultConfig { 12 | minSdkVersion 21 13 | targetSdkVersion 33 14 | 15 | testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 16 | consumerProguardFiles "consumer-rules.pro" 17 | } 18 | 19 | compileOptions { 20 | sourceCompatibility JavaVersion.VERSION_17 21 | targetCompatibility JavaVersion.VERSION_17 22 | } 23 | 24 | kotlinOptions { 25 | jvmTarget = "17" 26 | } 27 | 28 | buildTypes { 29 | release { 30 | minifyEnabled false 31 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" 32 | } 33 | } 34 | 35 | buildFeatures { 36 | buildConfig = true 37 | } 38 | 39 | namespace "com.saka.android.htmltextview" 40 | } 41 | 42 | dependencies { 43 | 44 | implementation "androidx.appcompat:appcompat:$appCompatVersion" 45 | implementation "androidx.core:core-ktx:$coreVersion" 46 | implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion" 47 | 48 | // java HTML parser 49 | implementation "org.jsoup:jsoup:1.13.1" 50 | 51 | // image loader 52 | implementation "com.github.bumptech.glide:glide:4.12.0" 53 | kapt "com.github.bumptech.glide:compiler:4.12.0" 54 | 55 | implementation "com.google.android.exoplayer:exoplayer:2.18.2" 56 | implementation "com.github.stfalcon-studio:StfalconImageViewer:v1.0.1" 57 | implementation "io.github.muddz:quickshot:1.4.0" 58 | implementation "com.karumi:dexter:6.2.2" 59 | 60 | testImplementation "junit:junit:4.13.2" 61 | androidTestImplementation "androidx.test.ext:junit:1.1.3" 62 | androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0" 63 | 64 | implementation "com.pierfrancescosoffritti.androidyoutubeplayer:core:11.0.1" 65 | } 66 | -------------------------------------------------------------------------------- /html-textview/consumer-rules.pro: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/html-textview/consumer-rules.pro -------------------------------------------------------------------------------- /html-textview/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # You can control the set of applied configuration files using the 3 | # proguardFiles setting in build.gradle. 4 | # 5 | # For more details, see 6 | # http://developer.android.com/guide/developing/tools/proguard.html 7 | 8 | # If your project uses WebView with JS, uncomment the following 9 | # and specify the fully qualified class name to the JavaScript interface 10 | # class: 11 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 12 | # public *; 13 | #} 14 | 15 | # Uncomment this to preserve the line number information for 16 | # debugging stack traces. 17 | #-keepattributes SourceFile,LineNumberTable 18 | 19 | # If you keep the line number information, uncomment this to 20 | # hide the original source file name. 21 | #-renamesourcefileattribute SourceFile 22 | -------------------------------------------------------------------------------- /html-textview/src/androidTest/java/com/saka/android/htmltextview/ExampleInstrumentedTest.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview 2 | 3 | import androidx.test.ext.junit.runners.AndroidJUnit4 4 | import androidx.test.platform.app.InstrumentationRegistry 5 | import org.junit.Assert.assertEquals 6 | import org.junit.Test 7 | import org.junit.runner.RunWith 8 | 9 | /** 10 | * Instrumented test, which will execute on an Android device. 11 | * 12 | * See [testing documentation](http://d.android.com/tools/testing). 13 | */ 14 | @RunWith(AndroidJUnit4::class) 15 | class ExampleInstrumentedTest { 16 | @Test 17 | fun useAppContext() { 18 | // Context of the app under test. 19 | val appContext = InstrumentationRegistry.getInstrumentation().targetContext 20 | assertEquals("com.saka.android.html_textview.test", appContext.packageName) 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /html-textview/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/HtmlTextView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview 2 | 3 | import android.content.Context 4 | import android.util.AttributeSet 5 | import android.widget.LinearLayout 6 | import androidx.core.content.ContextCompat 7 | import androidx.core.widget.NestedScrollView 8 | import androidx.lifecycle.LifecycleCoroutineScope 9 | import com.saka.android.htmltextview.utility.Conf 10 | import com.saka.android.htmltextview.utility.Conf.htmlContent 11 | import com.saka.android.htmltextview.utility.EManager 12 | import org.jsoup.Jsoup 13 | 14 | class HtmlTextView @JvmOverloads constructor( 15 | context: Context, 16 | attrs: AttributeSet? = null, 17 | defStyleAttr: Int = 0 18 | ) : NestedScrollView(context, attrs, defStyleAttr) { 19 | 20 | init { 21 | val typeArray = context.obtainStyledAttributes( 22 | attrs, 23 | R.styleable.HtmlTextView 24 | ) 25 | Conf.textSize = typeArray.getDimension( 26 | R.styleable.HtmlTextView_htmlTextSize, 27 | Conf.DEF_TEXT_SIZE 28 | ) 29 | Conf.textColor = typeArray.getColor( 30 | R.styleable.HtmlTextView_htmlTextColor, 31 | ContextCompat.getColor(context, R.color.colorTextPrimary) 32 | ) 33 | Conf.textLineSpacing = typeArray.getDimension( 34 | R.styleable.HtmlTextView_htmlLineSpacing, 35 | Conf.DEF_LINE_SPACING 36 | ) 37 | Conf.imageRoundCorner = typeArray.getDimension( 38 | R.styleable.HtmlTextView_htmlImageRound, 39 | Conf.DEF_IMAGE_ROUND 40 | ) 41 | Conf.textPadding = typeArray.getDimension( 42 | R.styleable.HtmlTextView_htmlTextPadding, 43 | Conf.DEF_PADDING 44 | ) 45 | htmlContent = typeArray.getString(R.styleable.HtmlTextView_htmlContent) ?: "" 46 | typeArray.recycle() 47 | } 48 | 49 | fun setText(html: String?, lifecycle: LifecycleCoroutineScope) { 50 | htmlContent = html ?: return 51 | val children = Jsoup.parse(htmlContent).body().children() 52 | val linearLayout = LinearLayout(context) 53 | linearLayout.orientation = LinearLayout.VERTICAL 54 | addView(linearLayout, LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)) 55 | if (!children.isNullOrEmpty()) { 56 | EManager.appendView(linearLayout, children, htmlContent, lifecycle) 57 | } 58 | } 59 | 60 | fun updateTextSize(fontSize: Float) { 61 | EManager.updateParagraphFontSize(fontSize) 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/activity/ImageActivity.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.activity 2 | 3 | import android.Manifest 4 | import android.content.pm.PackageManager 5 | import android.graphics.drawable.Drawable 6 | import android.os.Bundle 7 | import android.widget.ImageView 8 | import android.widget.Toast 9 | import androidx.appcompat.app.AppCompatActivity 10 | import androidx.core.content.ContextCompat 11 | import androidx.core.graphics.drawable.toBitmap 12 | import com.bumptech.glide.Glide 13 | import com.bumptech.glide.request.target.CustomTarget 14 | import com.bumptech.glide.request.transition.Transition 15 | import com.karumi.dexter.Dexter 16 | import com.karumi.dexter.PermissionToken 17 | import com.karumi.dexter.listener.PermissionDeniedResponse 18 | import com.karumi.dexter.listener.PermissionGrantedResponse 19 | import com.karumi.dexter.listener.PermissionRequest 20 | import com.karumi.dexter.listener.single.PermissionListener 21 | import com.saka.android.htmltextview.R 22 | import com.saka.android.htmltextview.utility.findAllImageLinks 23 | import com.saka.android.htmltextview.utility.load 24 | import com.stfalcon.imageviewer.StfalconImageViewer 25 | import io.github.muddz.quickshot.QuickShot 26 | 27 | class ImageActivity : AppCompatActivity(), OverlayView.EventCallback, PermissionListener { 28 | 29 | private var list = listOf() 30 | private var link = "" 31 | private var isPermissionGranted = false 32 | 33 | override fun onCreate(savedInstanceState: Bundle?) { 34 | super.onCreate(savedInstanceState) 35 | 36 | link = intent.getStringExtra("link") ?: "" 37 | val htmlContent = intent.getStringExtra("html") ?: "" 38 | list = htmlContent.findAllImageLinks() 39 | val currentIndex = list.indexOf(link) 40 | 41 | // view overlay 42 | val overlayView = OverlayView(this, callback = this) 43 | overlayView.updateText(currentIndex, list.size) 44 | 45 | StfalconImageViewer.Builder(this, list, ::loadImage) 46 | .withDismissListener { 47 | finishOverlay() 48 | } 49 | .withImageChangeListener { 50 | link = list[it] 51 | overlayView.updateText(it, list.size) 52 | } 53 | .withStartPosition(currentIndex) 54 | .withOverlayView(overlayView) 55 | .withBackgroundColor(ContextCompat.getColor(this, R.color.colorOverlay)) 56 | .show() 57 | 58 | isPermissionGranted = ContextCompat.checkSelfPermission( 59 | this, 60 | Manifest.permission.WRITE_EXTERNAL_STORAGE 61 | ) == PackageManager.PERMISSION_GRANTED 62 | } 63 | 64 | private fun loadImage(imageView: ImageView, src: String) { 65 | imageView.load(src) 66 | } 67 | 68 | private fun finishOverlay() { 69 | finish() 70 | overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out) 71 | } 72 | 73 | override fun onSaveClick() { 74 | loadAndSaveImage() 75 | } 76 | 77 | private fun loadAndSaveImage() { 78 | if (!isPermissionGranted) { 79 | Dexter.withContext(this) 80 | .withPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) 81 | .withListener(this) 82 | .check() 83 | return 84 | } 85 | // importance to use applicationContext 86 | Glide.with(applicationContext).load(link).into(object : CustomTarget() { 87 | override fun onLoadCleared(placeholder: Drawable?) { 88 | } 89 | 90 | override fun onResourceReady(resource: Drawable, transition: Transition?) { 91 | QuickShot.of(resource.toBitmap(), this@ImageActivity) 92 | .setResultListener(quickShotListener).save() 93 | } 94 | }) 95 | } 96 | 97 | private val quickShotListener = object : QuickShot.QuickShotListener { 98 | override fun onQuickShotSuccess(path: String?) { 99 | Toast.makeText( 100 | this@ImageActivity, 101 | getString(R.string.msg_save_image), 102 | Toast.LENGTH_SHORT 103 | ).show() 104 | } 105 | 106 | override fun onQuickShotFailed(path: String?, errorMsg: String?) { 107 | } 108 | } 109 | 110 | override fun onPermissionGranted(p0: PermissionGrantedResponse?) { 111 | isPermissionGranted = true 112 | loadAndSaveImage() 113 | } 114 | 115 | override fun onPermissionRationaleShouldBeShown(p0: PermissionRequest?, p1: PermissionToken?) { 116 | Toast.makeText( 117 | this, 118 | getString(R.string.msg_permission_rational), 119 | Toast.LENGTH_SHORT 120 | ).show() 121 | p1?.continuePermissionRequest() 122 | } 123 | 124 | override fun onPermissionDenied(p0: PermissionDeniedResponse?) { 125 | Toast.makeText( 126 | this, 127 | getString(R.string.msg_need_permission), 128 | Toast.LENGTH_SHORT 129 | ).show() 130 | } 131 | } 132 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/activity/OverlayView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.activity 2 | 3 | import android.content.Context 4 | import android.util.AttributeSet 5 | import android.view.View 6 | import android.widget.FrameLayout 7 | import android.widget.ImageView 8 | import android.widget.PopupMenu 9 | import android.widget.TextView 10 | import com.saka.android.htmltextview.R 11 | 12 | class OverlayView @JvmOverloads constructor( 13 | context: Context, 14 | attrs: AttributeSet? = null, 15 | defStyleAttr: Int = 0, 16 | private val callback: EventCallback? = null 17 | ) : FrameLayout(context, attrs, defStyleAttr) { 18 | 19 | init { 20 | val viewOverlay = View.inflate(context, R.layout.view_overlay, this) 21 | viewOverlay.findViewById(R.id.imageMore).setOnClickListener { 22 | shopPopupMenu(it) 23 | } 24 | } 25 | 26 | fun updateText(curr: Int, size: Int) { 27 | val currIndex = "${curr + 1}/$size" 28 | findViewById(R.id.viewIndex).text = currIndex 29 | } 30 | 31 | private fun shopPopupMenu(it: View) { 32 | val popupMenu = PopupMenu(it.context, it) 33 | popupMenu.inflate(R.menu.save_menu) 34 | popupMenu.setOnMenuItemClickListener { menu -> 35 | when (menu.itemId) { 36 | R.id.menu_save -> { 37 | callback?.onSaveClick() 38 | } 39 | } 40 | true 41 | } 42 | popupMenu.show() 43 | } 44 | 45 | interface EventCallback { 46 | fun onSaveClick() 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/activity/VideoActivity.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.activity 2 | 3 | import android.annotation.SuppressLint 4 | import android.os.Bundle 5 | import android.util.Base64 6 | import android.view.WindowManager 7 | import android.webkit.WebView 8 | import androidx.appcompat.app.AppCompatActivity 9 | import androidx.appcompat.widget.Toolbar 10 | import androidx.core.view.isVisible 11 | import com.google.android.exoplayer2.ExoPlayer 12 | import com.google.android.exoplayer2.MediaItem 13 | import com.google.android.exoplayer2.source.ProgressiveMediaSource 14 | import com.google.android.exoplayer2.ui.StyledPlayerView 15 | import com.google.android.exoplayer2.upstream.DefaultDataSource 16 | import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.YouTubePlayer 17 | import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.listeners.AbstractYouTubePlayerListener 18 | import com.pierfrancescosoffritti.androidyoutubeplayer.core.player.views.YouTubePlayerView 19 | import com.saka.android.htmltextview.R 20 | import com.saka.android.htmltextview.utility.VideoLoader 21 | 22 | class VideoActivity : AppCompatActivity() { 23 | 24 | private var player: ExoPlayer? = null 25 | 26 | override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | window.addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN) 29 | setContentView(R.layout.activity_video) 30 | val toolbar = findViewById(R.id.toolbar) 31 | setSupportActionBar(toolbar) 32 | 33 | val youTubePlayerView = findViewById(R.id.youtube_player_view) 34 | val playerView = findViewById(R.id.playerView) 35 | val webView = findViewById(R.id.webView) 36 | val link = intent.getStringExtra("link") 37 | link?.let { 38 | when { 39 | VideoLoader.isYoutubeFormat(it) -> { 40 | youTubePlayerView.isVisible = true 41 | loadYoutubePlayer(VideoLoader.getYouTubeId(link), youTubePlayerView, toolbar) 42 | } 43 | else -> { 44 | webView.isVisible = true 45 | loadIFrameWebView(it, webView) 46 | } 47 | } 48 | } 49 | } 50 | 51 | private fun loadExoPlayer(link: String, playerView: StyledPlayerView, toolbar: Toolbar) { 52 | // create player view 53 | playerView.setShowBuffering(StyledPlayerView.SHOW_BUFFERING_WHEN_PLAYING) 54 | playerView.setControllerVisibilityListener( 55 | StyledPlayerView.ControllerVisibilityListener { 56 | toolbar.visibility = it 57 | } 58 | ) 59 | 60 | // create media source 61 | val dataSourceFactory = DefaultDataSource.Factory(this) 62 | val mediaItem = MediaItem.fromUri(link) 63 | val mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory) 64 | .createMediaSource(mediaItem) 65 | 66 | // create player 67 | player = ExoPlayer.Builder(this).build() 68 | player?.setMediaSource(mediaSource) 69 | player?.prepare() 70 | player?.playWhenReady = true 71 | playerView.player = player 72 | } 73 | 74 | private fun loadYoutubePlayer( 75 | videoId: String?, 76 | playerView: YouTubePlayerView, 77 | toolbar: Toolbar 78 | ) { 79 | if (videoId == null) return 80 | lifecycle.addObserver(playerView) 81 | playerView.addYouTubePlayerListener(object : AbstractYouTubePlayerListener() { 82 | override fun onReady(youTubePlayer: YouTubePlayer) { 83 | toolbar.isVisible = true 84 | youTubePlayer.loadVideo(videoId, 0f) 85 | } 86 | }) 87 | } 88 | 89 | @SuppressLint("SetJavaScriptEnabled") 90 | private fun loadIFrameWebView(link: String, webView: WebView) { 91 | webView.settings.javaScriptEnabled = true 92 | val encodedHtml = Base64.encodeToString( 93 | VideoLoader.generateIFrameEncode(link).toByteArray(), 94 | Base64.NO_PADDING 95 | ) 96 | webView.loadData(encodedHtml, "text/html", "base64") 97 | } 98 | 99 | override fun onSupportNavigateUp(): Boolean { 100 | finish() 101 | return super.onSupportNavigateUp() 102 | } 103 | 104 | override fun onPause() { 105 | super.onPause() 106 | if (player != null) { 107 | player?.playWhenReady = false 108 | } 109 | } 110 | 111 | override fun onDestroy() { 112 | super.onDestroy() 113 | if (player != null) { 114 | player?.stop() 115 | player?.release() 116 | player = null 117 | } 118 | } 119 | } 120 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/callback/ClickEventCallback.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.callback 2 | 3 | interface ClickEventCallback { 4 | fun onHtmlImageClick(pos: Int, src: String?) {} 5 | fun onHtmlVideoClick(pos: Int, src: String?) {} 6 | } 7 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/BaseElement.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.util.AttributeSet 5 | import android.widget.LinearLayout 6 | import kotlinx.coroutines.CoroutineScope 7 | import org.jsoup.nodes.Element 8 | 9 | abstract class BaseElement : LinearLayout { 10 | 11 | constructor(context: Context) : super(context) 12 | 13 | constructor( 14 | context: Context, 15 | attrs: AttributeSet? = null, 16 | defStyleAttr: Int = 0, 17 | element: Element? = null, 18 | content: String = "", 19 | coroutineScope: CoroutineScope? = null 20 | ) : super(context, attrs, defStyleAttr) { 21 | this.element = element 22 | this.htmlContent = content 23 | this.scope = coroutineScope 24 | this.render() 25 | } 26 | 27 | var htmlContent: String = "" 28 | var element: Element? = null 29 | var scope: CoroutineScope? = null 30 | 31 | abstract fun render() 32 | } 33 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/BlockQuoteView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.graphics.Typeface 5 | import android.util.AttributeSet 6 | import android.widget.TextView 7 | import com.saka.android.htmltextview.utility.EManager 8 | import kotlinx.coroutines.CoroutineScope 9 | import org.jsoup.nodes.Element 10 | 11 | class BlockQuoteView @JvmOverloads constructor( 12 | context: Context, 13 | attrs: AttributeSet? = null, 14 | defStyleAttr: Int = 0, 15 | element: Element? = null, 16 | content: String = "", 17 | coroutineScope: CoroutineScope? = null 18 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 19 | 20 | override fun render() { 21 | orientation = VERTICAL 22 | layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 23 | val children = element?.children() 24 | if (children?.isNotEmpty() == true) { 25 | EManager.appendView( 26 | view = this, 27 | elements = children, 28 | content = htmlContent, 29 | coroutineScope = scope 30 | ) 31 | } 32 | setText() 33 | } 34 | 35 | private fun setText() { 36 | val paragraphView = TextView(context) 37 | paragraphView.setTypeface(paragraphView.typeface, Typeface.ITALIC) 38 | paragraphView.text = element?.text() 39 | addView(paragraphView) 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/DivView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.util.AttributeSet 5 | import com.saka.android.htmltextview.utility.EManager 6 | import kotlinx.coroutines.CoroutineScope 7 | import org.jsoup.nodes.Element 8 | 9 | class DivView @JvmOverloads constructor( 10 | context: Context, 11 | attrs: AttributeSet? = null, 12 | defStyleAttr: Int = 0, 13 | element: Element? = null, 14 | content: String = "", 15 | coroutineScope: CoroutineScope? = null 16 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 17 | 18 | override fun render() { 19 | orientation = VERTICAL 20 | layoutParams = LayoutParams( 21 | LayoutParams.MATCH_PARENT, 22 | LayoutParams.WRAP_CONTENT 23 | ) 24 | val children = element?.children() 25 | if (children?.isNotEmpty() == true) { 26 | EManager.appendView(view = this, elements = children, coroutineScope = scope) 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/HeaderView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.util.AttributeSet 6 | import android.webkit.WebViewClient 7 | import kotlinx.coroutines.CoroutineScope 8 | import org.jsoup.nodes.Element 9 | 10 | class HeaderView @JvmOverloads constructor( 11 | context: Context, 12 | attrs: AttributeSet? = null, 13 | defStyleAttr: Int = 0, 14 | element: Element? = null, 15 | content: String = "", 16 | coroutineScope: CoroutineScope? = null 17 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 18 | 19 | override fun render() { 20 | orientation = VERTICAL 21 | layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 22 | setContent() 23 | } 24 | 25 | @SuppressLint("SetJavaScriptEnabled") 26 | private fun setContent() { 27 | val webView = WebViewCompat(context) 28 | webView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 29 | webView.webViewClient = WebViewClient() 30 | webView.settings.javaScriptEnabled = true 31 | element?.attr("width", "100%") 32 | webView.loadData(element.toString(), "text/html", "UTF-8") 33 | addView(webView) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/IFrameView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.content.Intent 6 | import android.content.res.Resources 7 | import android.graphics.drawable.BitmapDrawable 8 | import android.graphics.drawable.InsetDrawable 9 | import android.util.AttributeSet 10 | import android.util.Base64 11 | import android.view.MotionEvent 12 | import android.webkit.WebView 13 | import android.widget.ImageView 14 | import androidx.core.content.ContextCompat 15 | import com.saka.android.htmltextview.R 16 | import com.saka.android.htmltextview.activity.VideoActivity 17 | import com.saka.android.htmltextview.utility.MyActivity 18 | import com.saka.android.htmltextview.utility.VideoLoader 19 | import com.saka.android.htmltextview.utility.dp 20 | import com.saka.android.htmltextview.utility.loadBitmap 21 | import kotlinx.coroutines.CoroutineScope 22 | import kotlinx.coroutines.launch 23 | import org.jsoup.nodes.Element 24 | 25 | class IFrameView @JvmOverloads constructor( 26 | context: Context, 27 | attrs: AttributeSet? = null, 28 | defStyleAttr: Int = 0, 29 | element: Element? = null, 30 | content: String = "", 31 | coroutineScope: CoroutineScope? = null 32 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 33 | 34 | private var isInProgress = false 35 | 36 | companion object { 37 | const val BASE_URL = "http://13.250.71.15:81" 38 | } 39 | 40 | override fun render() { 41 | orientation = VERTICAL 42 | setContent() 43 | } 44 | 45 | @SuppressLint("ClickableViewAccessibility") 46 | private fun setContent() { 47 | link?.let { 48 | if (VideoLoader.isYoutubeFormat(it) || it.contains(BASE_URL)) { 49 | val imagePreview = ImageView(context) 50 | imagePreview.layoutParams = LayoutParams(-1, 240.dp().toInt()) 51 | imagePreview.adjustViewBounds = true 52 | imagePreview.setImageDrawable( 53 | ContextCompat.getDrawable(context, R.drawable.img_holder) 54 | ) 55 | 56 | scope?.launch { 57 | it.loadBitmap { bitmap -> 58 | imagePreview.background = BitmapDrawable(Resources.getSystem(), bitmap) 59 | imagePreview.setImageDrawable( 60 | InsetDrawable( 61 | ContextCompat.getDrawable( 62 | imagePreview.context, 63 | R.drawable.ic_play_circle_24 64 | ), 65 | 80 66 | ) 67 | ) 68 | } 69 | } 70 | 71 | addView(imagePreview) 72 | setOnClickListener { 73 | startVideoPlayer() 74 | } 75 | } else { 76 | val webView = WebView(context) 77 | val maxTouchDuration = 100 78 | var mDownTime: Long = 0 79 | webView.layoutParams = LayoutParams(-1, 220.dp().toInt()) 80 | webView.settings.javaScriptEnabled = true 81 | webView.setOnTouchListener { _, event -> 82 | when (event.action) { 83 | MotionEvent.ACTION_DOWN -> { 84 | mDownTime = event.eventTime 85 | } 86 | MotionEvent.ACTION_UP -> { 87 | if (event.eventTime - mDownTime <= maxTouchDuration) { 88 | if (!isInProgress) { 89 | isInProgress = true 90 | val intent = Intent(context, MyActivity::class.java) 91 | .putExtra("link", link) 92 | ContextCompat.startActivity(context, intent, null) 93 | } 94 | } 95 | } 96 | } 97 | true 98 | } 99 | val htmlStart = """ 100 | 101 | 102 | 103 | 114 | 115 | 116 | """ 117 | val htmlEnd = "" 118 | val content = "" 119 | val htmlString = "$htmlStart$content$htmlEnd" 120 | val encodedHtml = Base64.encodeToString(htmlString.toByteArray(), Base64.NO_PADDING) 121 | webView.loadData(encodedHtml, "text/html", "base64") 122 | addView(webView) 123 | } 124 | } 125 | } 126 | 127 | private fun startVideoPlayer() { 128 | if (isInProgress) return 129 | isInProgress = true 130 | val intent = Intent(context, VideoActivity::class.java) 131 | .putExtra("link", link) 132 | ContextCompat.startActivity(context, intent, null) 133 | } 134 | 135 | override fun onWindowFocusChanged(hasWindowFocus: Boolean) { 136 | super.onWindowFocusChanged(hasWindowFocus) 137 | if (hasWindowFocus) isInProgress = false 138 | } 139 | 140 | private val link: String? 141 | get() = element?.attr("abs:src") 142 | } 143 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/ImageView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.content.Intent 5 | import android.util.AttributeSet 6 | import androidx.core.content.ContextCompat 7 | import com.saka.android.htmltextview.activity.ImageActivity 8 | import com.saka.android.htmltextview.utility.load 9 | import kotlinx.coroutines.CoroutineScope 10 | import org.jsoup.nodes.Element 11 | 12 | class ImageView @JvmOverloads constructor( 13 | context: Context, 14 | attrs: AttributeSet? = null, 15 | defStyleAttr: Int = 0, 16 | element: Element? = null, 17 | content: String = "", 18 | coroutineScope: CoroutineScope? = null 19 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 20 | 21 | private var isInProgress = false 22 | 23 | override fun render() { 24 | orientation = VERTICAL 25 | setImage() 26 | } 27 | 28 | private fun setImage() { 29 | val roundImageView = RoundImageView(context) 30 | roundImageView.adjustViewBounds = true 31 | roundImageView.load(link) 32 | val layoutParams = LayoutParams(-1, -2) 33 | layoutParams.setMargins(0, 18, 0, 18) 34 | addView(roundImageView, layoutParams) 35 | setOnClickListener { 36 | startPreviewImage() 37 | } 38 | } 39 | 40 | private fun startPreviewImage() { 41 | if (isInProgress) return 42 | isInProgress = true 43 | val intent = Intent(context, ImageActivity::class.java) 44 | .putExtra("link", link) 45 | .putExtra("html", htmlContent) 46 | ContextCompat.startActivity(context, intent, null) 47 | } 48 | 49 | override fun onWindowFocusChanged(hasWindowFocus: Boolean) { 50 | super.onWindowFocusChanged(hasWindowFocus) 51 | if (hasWindowFocus) isInProgress = false 52 | } 53 | 54 | private val link: String? get() = element?.attr("abs:src") 55 | } 56 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/ParagraphView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.text.util.Linkify 5 | import android.util.AttributeSet 6 | import android.util.TypedValue 7 | import android.widget.TextView 8 | import androidx.core.content.ContextCompat 9 | import androidx.core.content.res.ResourcesCompat 10 | import androidx.core.view.setPadding 11 | import com.saka.android.htmltextview.R 12 | import com.saka.android.htmltextview.utility.Conf 13 | import com.saka.android.htmltextview.utility.EManager 14 | import kotlinx.coroutines.CoroutineScope 15 | import org.jsoup.nodes.Element 16 | 17 | class ParagraphView @JvmOverloads constructor( 18 | context: Context, 19 | attrs: AttributeSet? = null, 20 | defStyleAttr: Int = 0, 21 | element: Element? = null, 22 | content: String = "", 23 | coroutineScope: CoroutineScope? = null 24 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 25 | 26 | lateinit var paragraphView: TextView 27 | 28 | override fun render() { 29 | orientation = VERTICAL 30 | layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 31 | val children = element?.children() 32 | if (children?.isNotEmpty() == true) { 33 | EManager.appendView( 34 | view = this, 35 | elements = children, 36 | content = htmlContent, 37 | coroutineScope = scope 38 | ) 39 | } 40 | setText() 41 | } 42 | 43 | private fun setText() { 44 | paragraphView = TextView(context) 45 | paragraphView.autoLinkMask = Linkify.ALL 46 | paragraphView.setTextColor( 47 | if (Conf.textColor != 0) { 48 | Conf.textColor 49 | } else { 50 | ContextCompat.getColor(context, R.color.colorTextPrimary) 51 | } 52 | ) 53 | paragraphView.typeface = ResourcesCompat.getFont(context, R.font.font_battambang_regular) 54 | paragraphView.setTextSize(TypedValue.COMPLEX_UNIT_SP, Conf.textSize) 55 | paragraphView.setLineSpacing(Conf.textLineSpacing, 1f) 56 | paragraphView.setPadding(Conf.textPadding.toInt()) 57 | paragraphView.text = element?.text() 58 | addView(paragraphView) 59 | } 60 | 61 | fun updateFontSize(fontSize: Float) { 62 | paragraphView.setTextSize(TypedValue.COMPLEX_UNIT_SP, fontSize) 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/RoundImageView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.graphics.Canvas 5 | import android.graphics.Path 6 | import android.graphics.RectF 7 | import android.util.AttributeSet 8 | import com.saka.android.htmltextview.utility.Conf 9 | 10 | class RoundImageView @JvmOverloads constructor( 11 | context: Context, 12 | attrs: AttributeSet? = null, 13 | defStyleAttr: Int = 0 14 | ) : androidx.appcompat.widget.AppCompatImageView(context, attrs, defStyleAttr) { 15 | 16 | private var radius = Conf.imageRoundCorner 17 | private var rect: RectF = RectF() 18 | private var path: Path = Path() 19 | 20 | override fun onDraw(canvas: Canvas?) { 21 | rect.set(0f, 0f, width.toFloat(), height.toFloat()) 22 | path.addRoundRect(rect, radius, radius, Path.Direction.CW) 23 | canvas?.clipPath(path) 24 | super.onDraw(canvas) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/WebView.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.annotation.SuppressLint 4 | import android.content.Context 5 | import android.util.AttributeSet 6 | import android.webkit.WebViewClient 7 | import kotlinx.coroutines.CoroutineScope 8 | import org.jsoup.nodes.Element 9 | 10 | class WebView @JvmOverloads constructor( 11 | context: Context, 12 | attrs: AttributeSet? = null, 13 | defStyleAttr: Int = 0, 14 | element: Element? = null, 15 | content: String = "", 16 | coroutineScope: CoroutineScope? = null 17 | ) : BaseElement(context, attrs, defStyleAttr, element, content, coroutineScope) { 18 | 19 | override fun render() { 20 | orientation = VERTICAL 21 | layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 22 | setContent() 23 | } 24 | 25 | @SuppressLint("SetJavaScriptEnabled") 26 | private fun setContent() { 27 | val webView = WebViewCompat(context) 28 | webView.layoutParams = LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT) 29 | webView.webViewClient = WebViewClient() 30 | webView.settings.javaScriptEnabled = true 31 | element?.attr("width", "100%") 32 | webView.loadData(element.toString(), "text/html", "UTF-8") 33 | addView(webView) 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/element/WebViewCompat.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.element 2 | 3 | import android.content.Context 4 | import android.content.res.Configuration 5 | import android.util.AttributeSet 6 | import android.webkit.WebView 7 | 8 | open class WebViewCompat @JvmOverloads constructor( 9 | context: Context, 10 | attrs: AttributeSet? = null, 11 | defStyleAttr: Int = 0, 12 | defStyleRes: Int = 0 13 | ) : WebView(context.createConfigurationContext(Configuration()), attrs, defStyleAttr, defStyleRes) 14 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/Conf.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | object Conf { 4 | 5 | // default 6 | const val DEF_TEXT_SIZE = 14f 7 | const val DEF_TEXT_COLOR = 0 8 | const val DEF_LINE_SPACING = 0f 9 | const val DEF_IMAGE_ROUND = 0f 10 | const val DEF_PADDING = 0f 11 | 12 | // config 13 | var textSize = DEF_TEXT_SIZE 14 | var textLineSpacing = DEF_LINE_SPACING 15 | var imageRoundCorner = DEF_IMAGE_ROUND 16 | var textPadding = DEF_PADDING 17 | var textColor = DEF_TEXT_COLOR 18 | var htmlContent = "" 19 | 20 | private var imageList = mutableListOf() 21 | 22 | fun addImage(url: String?) { 23 | imageList.add(url) 24 | } 25 | 26 | fun getImageList(): Array { 27 | return imageList.toTypedArray() 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/EManager.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | import android.content.Context 4 | import android.util.DisplayMetrics 5 | import android.view.ViewGroup 6 | import com.saka.android.htmltextview.element.BaseElement 7 | import com.saka.android.htmltextview.element.BlockQuoteView 8 | import com.saka.android.htmltextview.element.DivView 9 | import com.saka.android.htmltextview.element.HeaderView 10 | import com.saka.android.htmltextview.element.IFrameView 11 | import com.saka.android.htmltextview.element.ImageView 12 | import com.saka.android.htmltextview.element.ParagraphView 13 | import com.saka.android.htmltextview.element.WebView 14 | import kotlinx.coroutines.CoroutineScope 15 | import org.jsoup.Jsoup 16 | import org.jsoup.select.Elements 17 | 18 | object EManager { 19 | 20 | private val listElement = mutableListOf() 21 | 22 | fun appendView( 23 | view: ViewGroup, 24 | elements: Elements, 25 | content: String = "", 26 | coroutineScope: CoroutineScope? 27 | ) { 28 | var child: BaseElement 29 | for (e in elements) { 30 | when (e.tagName()) { 31 | "blockquote" -> { 32 | child = BlockQuoteView( 33 | context = view.context, 34 | element = e, 35 | content = content, 36 | coroutineScope = coroutineScope 37 | ) 38 | } 39 | 40 | "h" -> { 41 | child = HeaderView( 42 | context = view.context, 43 | element = e, 44 | content = content, 45 | coroutineScope = coroutineScope 46 | ) 47 | } 48 | 49 | "iframe" -> { 50 | child = IFrameView( 51 | context = view.context, 52 | element = e, 53 | content = content, 54 | coroutineScope = coroutineScope 55 | ) 56 | } 57 | 58 | "p" -> { 59 | child = ParagraphView( 60 | context = view.context, 61 | element = e, 62 | content = content, 63 | coroutineScope = coroutineScope 64 | ) 65 | } 66 | 67 | "img" -> { 68 | child = ImageView( 69 | context = view.context, 70 | element = e, 71 | content = content, 72 | coroutineScope = coroutineScope 73 | ) 74 | } 75 | 76 | "div" -> { 77 | child = DivView( 78 | context = view.context, 79 | element = e, 80 | content = content, 81 | coroutineScope = coroutineScope 82 | ) 83 | } 84 | 85 | "table" -> { 86 | child = WebView( 87 | context = view.context, 88 | element = e, 89 | content = content, 90 | coroutineScope = coroutineScope 91 | ) 92 | } 93 | 94 | "ul" -> { 95 | child = WebView( 96 | context = view.context, 97 | element = e, 98 | content = content, 99 | coroutineScope = coroutineScope 100 | ) 101 | } 102 | 103 | "ol" -> { 104 | child = WebView( 105 | context = view.context, 106 | element = e, 107 | content = content, 108 | coroutineScope = coroutineScope 109 | ) 110 | } 111 | 112 | else -> { 113 | child = HeaderView( 114 | context = view.context, 115 | element = e, 116 | content = content, 117 | coroutineScope = coroutineScope 118 | ) 119 | } 120 | } 121 | view.addView(child) 122 | listElement.add(child) 123 | } 124 | } 125 | 126 | fun updateParagraphFontSize(fontSize: Float) { 127 | listElement.filterIsInstance().forEach { par -> 128 | par.updateFontSize(fontSize) 129 | } 130 | } 131 | 132 | fun dpToPx(context: Context, dp: Int): Float { 133 | val displayMetrics = context.resources.displayMetrics 134 | return (dp * (displayMetrics.xdpi / DisplayMetrics.DENSITY_DEFAULT)) 135 | } 136 | 137 | fun findAllVideoLinks(content: String?): List { 138 | content ?: return emptyList() 139 | val links: MutableList = ArrayList() 140 | val document = Jsoup.parse(content) 141 | val medias = document.select("[src]") 142 | for (element in medias) { 143 | if (element.tagName() == "iframe") { 144 | links.add(element.attr("abs:src")) 145 | } 146 | } 147 | return links 148 | } 149 | 150 | fun findAllImagesLinks(content: String?): List { 151 | content ?: return emptyList() 152 | val links: MutableList = ArrayList() 153 | val document = Jsoup.parse(content) 154 | val medias = document.select("[src]") 155 | for (element in medias) { 156 | if (element.tagName() == "img") { 157 | links.add(element.attr("abs:src")) 158 | } 159 | } 160 | return links 161 | } 162 | } 163 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/Extension.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | import android.content.res.Resources 4 | import android.graphics.Bitmap 5 | import android.util.DisplayMetrics 6 | import android.util.TypedValue 7 | import android.widget.ImageView 8 | import androidx.annotation.DrawableRes 9 | import com.bumptech.glide.Glide 10 | import com.saka.android.htmltextview.R 11 | import org.jsoup.Jsoup 12 | import java.util.* 13 | 14 | fun ImageView.load(url: String?) { 15 | Glide.with(this).load(url).error(R.drawable.bg_placeholder).into(this) 16 | } 17 | 18 | fun ImageView.loadBitmap(bitmap: Bitmap?) { 19 | Glide.with(this).load(bitmap).error(R.drawable.bg_placeholder).into(this) 20 | } 21 | 22 | fun ImageView.loadDrawable(@DrawableRes drawableResId: Int) { 23 | Glide.with(this).load(drawableResId).into(this) 24 | } 25 | 26 | fun Number.dp(): Float { 27 | return this.toFloat() * Resources.getSystem().displayMetrics.densityDpi / DisplayMetrics.DENSITY_DEFAULT 28 | } 29 | 30 | fun Number.dpi(): Float { 31 | return TypedValue.applyDimension( 32 | TypedValue.COMPLEX_UNIT_PX, 33 | this.toFloat(), 34 | Resources.getSystem().displayMetrics 35 | ) 36 | } 37 | 38 | fun String.findAllImageLinks(): List { 39 | val links: MutableList = ArrayList() 40 | val document = Jsoup.parse(this) 41 | val medias = document.select("[src]") 42 | for (element in medias) { 43 | if (element.tagName() == "img") { 44 | links.add(element.attr("abs:src")) 45 | } 46 | } 47 | return links 48 | } 49 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/MyActivity.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | import android.annotation.SuppressLint 4 | import android.app.Activity 5 | import android.os.Bundle 6 | import android.view.KeyEvent 7 | import android.view.LayoutInflater 8 | import android.view.View 9 | import android.webkit.WebChromeClient 10 | import android.webkit.WebChromeClient.CustomViewCallback 11 | import android.webkit.WebView 12 | import android.webkit.WebViewClient 13 | import android.widget.FrameLayout 14 | import com.saka.android.htmltextview.R.id 15 | import com.saka.android.htmltextview.R.layout 16 | 17 | class MyActivity : Activity() { 18 | 19 | private var webView: WebView? = null 20 | private var customViewContainer: FrameLayout? = null 21 | private var customViewCallback: CustomViewCallback? = null 22 | private var mCustomView: View? = null 23 | private var mWebChromeClient: MyWebChromeClient? = null 24 | 25 | @SuppressLint("SetJavaScriptEnabled") 26 | public override fun onCreate(savedInstanceState: Bundle?) { 27 | super.onCreate(savedInstanceState) 28 | setContentView(layout.main) 29 | customViewContainer = findViewById(id.customViewContainer) 30 | webView = findViewById(id.webView) 31 | 32 | val webView = webView ?: return 33 | val link = intent.getStringExtra("link") 34 | val mWebViewClient = MyWebViewClient() 35 | 36 | webView.webViewClient = mWebViewClient 37 | mWebChromeClient = MyWebChromeClient() 38 | webView.webChromeClient = mWebChromeClient 39 | webView.settings.javaScriptEnabled = true 40 | val url = """ 41 | 42 | 43 | 60 | 61 | 62 | 63 | 64 | """ 65 | webView.loadData(url, "text/html", "UTF-8") 66 | } 67 | 68 | private fun inCustomView(): Boolean { 69 | return mCustomView != null 70 | } 71 | 72 | private fun hideCustomView() { 73 | mWebChromeClient?.onHideCustomView() 74 | } 75 | 76 | override fun onPause() { 77 | super.onPause() 78 | webView?.onPause() 79 | } 80 | 81 | override fun onResume() { 82 | super.onResume() 83 | webView?.onResume() 84 | } 85 | 86 | override fun onStop() { 87 | super.onStop() 88 | if (inCustomView()) { 89 | hideCustomView() 90 | } 91 | } 92 | 93 | override fun onKeyDown(keyCode: Int, event: KeyEvent): Boolean { 94 | if (keyCode == KeyEvent.KEYCODE_BACK) { 95 | if (inCustomView()) { 96 | hideCustomView() 97 | return true 98 | } 99 | if (mCustomView == null && webView?.canGoBack() == true) { 100 | webView?.goBack() 101 | return true 102 | } 103 | } 104 | return super.onKeyDown(keyCode, event) 105 | } 106 | 107 | internal inner class MyWebChromeClient : WebChromeClient() { 108 | 109 | // private val mDefaultVideoPoster: Bitmap? = null 110 | private var mVideoProgressView: View? = null 111 | 112 | override fun onShowCustomView(view: View, callback: CustomViewCallback) { 113 | // if a view already exists then immediately terminate the new one 114 | if (mCustomView != null) { 115 | callback.onCustomViewHidden() 116 | return 117 | } 118 | mCustomView = view 119 | webView?.visibility = View.GONE 120 | customViewContainer?.visibility = View.VISIBLE 121 | customViewContainer?.addView(view) 122 | customViewCallback = callback 123 | } 124 | 125 | override fun getVideoLoadingProgressView(): View? { 126 | if (mVideoProgressView == null) { 127 | val inflater = LayoutInflater.from(this@MyActivity) 128 | mVideoProgressView = inflater.inflate(layout.video_progress, null) 129 | } 130 | return mVideoProgressView 131 | } 132 | 133 | override fun onHideCustomView() { 134 | super.onHideCustomView() 135 | 136 | if (mCustomView == null) return 137 | webView?.visibility = View.VISIBLE 138 | customViewContainer?.visibility = View.GONE 139 | 140 | // Hide the custom view. 141 | mCustomView?.visibility = View.GONE 142 | 143 | // Remove the custom view from its container. 144 | customViewContainer?.removeView(mCustomView) 145 | customViewCallback?.onCustomViewHidden() 146 | mCustomView = null 147 | } 148 | } 149 | 150 | internal class MyWebViewClient : WebViewClient() 151 | } 152 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/ThumbnailLoader.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | import android.graphics.Bitmap 4 | import android.graphics.BitmapFactory 5 | import android.media.MediaMetadataRetriever 6 | import kotlinx.coroutines.CoroutineScope 7 | import kotlinx.coroutines.Dispatchers 8 | import kotlinx.coroutines.launch 9 | import kotlinx.coroutines.withContext 10 | import java.net.URL 11 | 12 | suspend fun String?.loadBitmap( 13 | onPostExecute: (Bitmap?) -> Unit 14 | ) { 15 | val url = this ?: return 16 | var bitmap: Bitmap? = null 17 | withContext(Dispatchers.IO) { 18 | if (VideoLoader.isYoutubeFormat(url)) { 19 | try { 20 | val link = 21 | URL("http://img.youtube.com/vi/${VideoLoader.getYouTubeId(url)}/0.jpg") 22 | bitmap = BitmapFactory.decodeStream(link.openConnection().getInputStream()) 23 | } catch (ex: Exception) { 24 | ex.printStackTrace() 25 | } 26 | } else { 27 | var mediaMetadataRetriever: MediaMetadataRetriever? = null 28 | try { 29 | mediaMetadataRetriever = MediaMetadataRetriever() 30 | mediaMetadataRetriever.setDataSource(url, HashMap()) 31 | bitmap = mediaMetadataRetriever.getFrameAtTime( 32 | 6_000_000, 33 | MediaMetadataRetriever.OPTION_CLOSEST 34 | ) 35 | } catch (ex: Exception) { 36 | ex.printStackTrace() 37 | } finally { 38 | mediaMetadataRetriever?.release() 39 | } 40 | } 41 | } 42 | onPostExecute.invoke(bitmap) 43 | } 44 | 45 | fun CoroutineScope.executeAsyncTask( 46 | onPreExecute: () -> Unit, 47 | doInBackground: () -> R, 48 | onPostExecute: (R) -> Unit 49 | ) = launch { 50 | onPreExecute() 51 | val result = 52 | withContext(Dispatchers.IO) { // runs in background thread without blocking the Main Thread 53 | doInBackground() 54 | } 55 | onPostExecute(result) 56 | } 57 | -------------------------------------------------------------------------------- /html-textview/src/main/java/com/saka/android/htmltextview/utility/VideoLoader.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview.utility 2 | 3 | import java.util.regex.Matcher 4 | import java.util.regex.Pattern 5 | 6 | object VideoLoader { 7 | 8 | fun isYoutubeFormat(it: String): Boolean { 9 | return it.contains("youtube.com/") || it.contains("youtu.be/") 10 | } 11 | 12 | fun getYouTubeId(youTubeUrl: String?): String? { 13 | val pattern = 14 | "https?://(?:[0-9A-Z-]+\\.)?(?:youtu\\.be/|youtube\\.com\\S*[^\\w\\-\\s])([\\w\\-]{11})(?=[^\\w\\-]|$)(?![?=&+%\\w]*(?:['\"][^<>]*>|))[?=&+%\\w]*" 15 | val compiledPattern: Pattern = Pattern.compile( 16 | pattern, 17 | Pattern.CASE_INSENSITIVE 18 | ) 19 | val matcher: Matcher = compiledPattern.matcher(youTubeUrl) 20 | return if (matcher.find()) { 21 | matcher.group(1) 22 | } else { 23 | null 24 | } 25 | } 26 | 27 | fun generateIFrameEncode(link: String): String { 28 | val htmlStart = """ 29 | 30 | 31 | 41 | 42 | 43 | """ 44 | val htmlEnd = "" 45 | val content = "" 46 | return "$htmlStart$content$htmlEnd" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/bg_placeholder.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/bg_ripple_effect.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/ic_close_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/ic_more_vert_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 10 | 11 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/ic_play_circle_24.xml: -------------------------------------------------------------------------------- 1 | 7 | 8 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /html-textview/src/main/res/drawable/img_holder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/html-textview/src/main/res/drawable/img_holder.png -------------------------------------------------------------------------------- /html-textview/src/main/res/font/font_battambang_regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sakacyber/html-textview/0672db02272811e47c6adb9804a51432ef04aca5/html-textview/src/main/res/font/font_battambang_regular.ttf -------------------------------------------------------------------------------- /html-textview/src/main/res/layout/activity_video.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 13 | 14 | 19 | 20 | 25 | 26 | 34 | 35 | -------------------------------------------------------------------------------- /html-textview/src/main/res/layout/main.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 13 | 14 | 19 | 20 | -------------------------------------------------------------------------------- /html-textview/src/main/res/layout/video_progress.xml: -------------------------------------------------------------------------------- 1 | 2 | 8 | 9 | 15 | 16 | 24 | -------------------------------------------------------------------------------- /html-textview/src/main/res/layout/view_overlay.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 31 | 32 | 33 | 34 | 44 | 45 | -------------------------------------------------------------------------------- /html-textview/src/main/res/layout/view_video_controller.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 15 | 16 | 22 | 23 | 26 | 27 | 30 | 31 | 34 | 35 | 38 | 39 | 42 | 43 | 46 | 47 | 50 | 51 | 54 | 55 | 58 | 59 | 60 | 61 | 67 | 68 | 78 | 79 | 84 | 85 | 95 | 96 | 97 | 98 | 99 | 100 | 105 | 106 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /html-textview/src/main/res/menu/save_menu.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | -------------------------------------------------------------------------------- /html-textview/src/main/res/values/attr.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /html-textview/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | #DDDDDD 5 | #333333 6 | #808080 7 | #fafafa 8 | #E6000000 9 | #4D000000 10 | #39474747 11 | 12 | -------------------------------------------------------------------------------- /html-textview/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | HtmlTextView 5 | KangSakur 6 | image 7 | រក្សាទុក 8 | ព័ត៌មានលម្អិត 9 | បានរក្សាទុករូបភាព 10 | មានបញ្ហារក្សាទុករូបភាព 11 | ត្រូវការការសិទ្ធអនុញ្ញាតការផ្ទុកឯកសារ 12 | ដើម្បីរក្សាទុករូបភាព ត្រូវការការសិទ្ធអនុញ្ញាតការផ្ទុកឯកសារ 13 | 14 | -------------------------------------------------------------------------------- /html-textview/src/main/res/values/values.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 12 | 13 | -------------------------------------------------------------------------------- /html-textview/src/test/java/com/saka/android/htmltextview/ExampleUnitTest.kt: -------------------------------------------------------------------------------- 1 | package com.saka.android.htmltextview 2 | 3 | import org.junit.Assert.assertEquals 4 | import org.junit.Test 5 | 6 | /** 7 | * Example local unit test, which will execute on the development machine (host). 8 | * 9 | * See [testing documentation](http://d.android.com/tools/testing). 10 | */ 11 | class ExampleUnitTest { 12 | @Test 13 | fun addition_isCorrect() { 14 | assertEquals(4, 2 + 2) 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /jitpack.yml: -------------------------------------------------------------------------------- 1 | before_install: 2 | - sdk install java 11.0.10-open 3 | - sdk use java 11.0.10-open -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name='HtmlTextView' 2 | include ':app' 3 | include ':html-textview' 4 | --------------------------------------------------------------------------------
Header 2
រថយន្ត Chevrolet Blazer ឆ្នាំ២០២០ ដែលមានទាំងជម្រើសកៅអី ២ជួរ និង ៣ជួរ ត្រូវបានដាក់លក់ក្នុងតម្លៃចាប់ពីខ្ទង់ ៣៦ ៧៣០ដុល្លារ ដល់ ៤៦ ៦២៥ដុល្លារ ក្នុងប្រទេសចិន ខណៈតម្លៃលក់នៅសហរដ្ឋអាមេរិក គឺត្រឹមតែ ២៨ ៨០០ដុល្លារប៉ុណ្ណោះ។
រថយន្តតួខ្ពស់របស់អាមេរិកនេះ ផ្តល់នូវមុខងារពិសេសៗជាច្រើន ដូចជា MyLink+ Infotainment System ជាមួយ OnStar, Apple CarPlay និង Baidu CarLife, Real-time Traffic, ផែនទី និងដំបូល Panoramic Sunroof ជាដើម។
ក្រៅពីនោះ វាក៏បំពាក់ប្រព័ន្ធកាមេរ៉ាមើលជុំវិញរថយន្ត ៣៦០ដឺក្រេ, មុខងារ Automatic Parking Assist, Adaptive Cruise Control, Hill Descent Control, Vehicle Stability Control, Roll Over Protection, Electronic Stability Control និងជាច្រើនទៀត។
រថយន្ត Chevrolet Blazer បំពាក់ម៉ាស៊ីនចំណុះ ២,០លីត្រ Ecotec Turbocharged ទំហំ ៤ស៊ីឡាំង មានកម្លាំង ២៣៣សេះ អាចរត់ស្ទុះពីកុងទ័រ ០-១០០គីឡូម៉ែត្រក្នុងមួយម៉ោង ប្រើពេល ៩វិនាទី ហើយមានកម្រិតស៊ីសាំងជាមធ្យម ៧,៤លីត្រ សម្រាប់ការបើកបរចម្ងាយ ១០០គីឡូម៉ែត្រ។ វាមានមុខងារបើកប ៤ គឺ Normal, AWD, Off-Road និង Sport៕