├── app ├── .gitignore ├── src │ ├── main │ │ ├── res │ │ │ ├── values │ │ │ │ ├── strings.xml │ │ │ │ ├── colors.xml │ │ │ │ ├── dimens.xml │ │ │ │ └── styles.xml │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxxhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── values-w820dp │ │ │ │ └── dimens.xml │ │ │ └── layout │ │ │ │ └── activity_main.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── xys │ │ │ └── textviewforfullhtml │ │ │ └── MainActivity.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xys │ │ │ └── textviewforfullhtml │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xys │ │ └── textviewforfullhtml │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── app.iml ├── .idea ├── .name ├── copyright │ └── profiles_settings.xml ├── dictionaries │ └── xuyisheng.xml ├── vcs.xml ├── inspectionProfiles │ ├── profiles_settings.xml │ └── Project_Default.xml ├── modules.xml ├── runConfigurations.xml ├── compiler.xml ├── gradle.xml ├── misc.xml └── codeStyleSettings.xml ├── lib_tv_fullhtml ├── .gitignore ├── libs │ ├── htmllexer.jar │ └── htmlparser.jar ├── src │ ├── main │ │ ├── res │ │ │ └── values │ │ │ │ └── strings.xml │ │ ├── AndroidManifest.xml │ │ └── java │ │ │ └── com │ │ │ └── xys │ │ │ └── lib_tv_fullhtml │ │ │ ├── tagsoup │ │ │ ├── Scanner.java │ │ │ ├── AutoDetector.java │ │ │ ├── jaxp │ │ │ │ ├── JAXPTest.java │ │ │ │ ├── SAXParserImpl.java │ │ │ │ ├── SAXFactoryImpl.java │ │ │ │ └── SAX1ParserAdapter.java │ │ │ ├── HTMLModels.java │ │ │ ├── ScanHandler.java │ │ │ ├── PYXScanner.java │ │ │ ├── Schema.java │ │ │ ├── Element.java │ │ │ ├── PYXWriter.java │ │ │ ├── ElementType.java │ │ │ ├── CommandLine.java │ │ │ ├── AttributesImpl.java │ │ │ └── HTMLScanner.java │ │ │ ├── TextViewForFullHtml.java │ │ │ └── ActionscriptTextUtils.java │ ├── test │ │ └── java │ │ │ └── com │ │ │ └── xys │ │ │ └── lib_tv_fullhtml │ │ │ └── ExampleUnitTest.java │ └── androidTest │ │ └── java │ │ └── com │ │ └── xys │ │ └── lib_tv_fullhtml │ │ └── ApplicationTest.java ├── proguard-rules.pro ├── build.gradle └── lib_tv_fullhtml.iml ├── settings.gradle ├── art └── demo.png ├── .gitignore ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── gradle.properties ├── TextViewForFullHtml.iml ├── README.md ├── gradlew.bat └── gradlew /app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /.idea/.name: -------------------------------------------------------------------------------- 1 | TextViewForFullHtml -------------------------------------------------------------------------------- /lib_tv_fullhtml/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app', ':lib_tv_fullhtml' 2 | -------------------------------------------------------------------------------- /art/demo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/art/demo.png -------------------------------------------------------------------------------- /.idea/copyright/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.idea/dictionaries/xuyisheng.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /app/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | TextViewForFullHtml 3 | 4 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lib_tv_fullhtml/libs/htmllexer.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/lib_tv_fullhtml/libs/htmllexer.jar -------------------------------------------------------------------------------- /lib_tv_fullhtml/libs/htmlparser.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/lib_tv_fullhtml/libs/htmlparser.jar -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | lib_tv_fullhtml 3 | 4 | -------------------------------------------------------------------------------- /app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xuyisheng/TextViewForFullHtml/HEAD/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /app/src/main/res/values/colors.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | #3F51B5 4 | #303F9F 5 | #FF4081 6 | 7 | -------------------------------------------------------------------------------- /app/src/main/res/values/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 16dp 4 | 16dp 5 | 6 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Nov 04 19:18:25 CST 2015 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-2.8-all.zip 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/Project_Default.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 4 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/values-w820dp/dimens.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 64dp 6 | 7 | -------------------------------------------------------------------------------- /app/src/test/java/com/xys/textviewforfullhtml/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xys.textviewforfullhtml; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/test/java/com/xys/lib_tv_fullhtml/ExampleUnitTest.java: -------------------------------------------------------------------------------- 1 | package com.xys.lib_tv_fullhtml; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.*; 6 | 7 | /** 8 | * To work on unit tests, switch the Test Artifact in the Build Variants view. 9 | */ 10 | public class ExampleUnitTest { 11 | @Test 12 | public void addition_isCorrect() throws Exception { 13 | assertEquals(4, 2 + 2); 14 | } 15 | } -------------------------------------------------------------------------------- /app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/androidTest/java/com/xys/textviewforfullhtml/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xys.textviewforfullhtml; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/androidTest/java/com/xys/lib_tv_fullhtml/ApplicationTest.java: -------------------------------------------------------------------------------- 1 | package com.xys.lib_tv_fullhtml; 2 | 3 | import android.app.Application; 4 | import android.test.ApplicationTestCase; 5 | 6 | /** 7 | * Testing Fundamentals 8 | */ 9 | public class ApplicationTest extends ApplicationTestCase { 10 | public ApplicationTest() { 11 | super(Application.class); 12 | } 13 | } -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/runConfigurations.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 12 | -------------------------------------------------------------------------------- /app/src/main/res/layout/activity_main.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/xuyisheng/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in /Users/xuyisheng/Library/Android/sdk/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /.idea/compiler.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.library' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | minSdkVersion 19 9 | targetSdkVersion 23 10 | versionCode 1 11 | versionName "1.0" 12 | } 13 | buildTypes { 14 | release { 15 | minifyEnabled false 16 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 17 | } 18 | } 19 | } 20 | 21 | dependencies { 22 | compile fileTree(include: ['*.jar'], dir: 'libs') 23 | testCompile 'junit:junit:4.12' 24 | compile 'com.android.support:appcompat-v7:23.1.0' 25 | compile files('libs/htmllexer.jar') 26 | compile files('libs/htmlparser.jar') 27 | } 28 | -------------------------------------------------------------------------------- /app/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'com.android.application' 2 | 3 | android { 4 | compileSdkVersion 23 5 | buildToolsVersion "23.0.1" 6 | 7 | defaultConfig { 8 | applicationId "com.xys.textviewforfullhtml" 9 | minSdkVersion 19 10 | targetSdkVersion 23 11 | versionCode 1 12 | versionName "1.0" 13 | } 14 | buildTypes { 15 | release { 16 | minifyEnabled false 17 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 18 | } 19 | } 20 | } 21 | 22 | dependencies { 23 | compile fileTree(include: ['*.jar'], dir: 'libs') 24 | testCompile 'junit:junit:4.12' 25 | compile 'com.android.support:appcompat-v7:23.1.0' 26 | compile project(':lib_tv_fullhtml') 27 | } 28 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 19 | 20 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true -------------------------------------------------------------------------------- /TextViewForFullHtml.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/Scanner.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // Scanner 16 | 17 | package com.xys.lib_tv_fullhtml.tagsoup; 18 | 19 | import org.xml.sax.SAXException; 20 | 21 | import java.io.IOException; 22 | import java.io.Reader; 23 | 24 | /** 25 | * An interface allowing Parser to invoke scanners. 26 | **/ 27 | 28 | public interface Scanner { 29 | 30 | /** 31 | * Invoke a scanner. 32 | * 33 | * @param r A source of characters to scan 34 | * @param h A ScanHandler to report events to 35 | **/ 36 | 37 | public void scan(Reader r, ScanHandler h) throws IOException, SAXException; 38 | 39 | /** 40 | * Reset the embedded locator. 41 | * 42 | * @param publicid The publicid of the source 43 | * @param systemid The systemid of the source 44 | **/ 45 | 46 | public void resetDocumentLocator(String publicid, String systemid); 47 | 48 | /** 49 | * Signal to the scanner to start CDATA content mode. 50 | **/ 51 | 52 | public void startCDATA(); 53 | 54 | } 55 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/AutoDetector.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // Interface to objects that translate InputStreams to Readers by auto-detection 16 | 17 | package com.xys.lib_tv_fullhtml.tagsoup; 18 | 19 | import java.io.InputStream; 20 | import java.io.Reader; 21 | 22 | /** 23 | * Classes which accept an InputStream and provide a Reader which figures 24 | * out the encoding of the InputStream and reads characters from it should 25 | * conform to this interface. 26 | * 27 | * @see InputStream 28 | * @see Reader 29 | */ 30 | 31 | public interface AutoDetector { 32 | 33 | /** 34 | * Given an InputStream, return a suitable Reader that understands 35 | * the presumed character encoding of that InputStream. 36 | * If bytes are consumed from the InputStream in the process, they 37 | * must be pushed back onto the InputStream so that they can be 38 | * reinterpreted as characters. 39 | * 40 | * @param i The InputStream 41 | * @return A Reader that reads from the InputStream 42 | */ 43 | 44 | public Reader autoDetectingReader(InputStream i); 45 | 46 | } 47 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/jaxp/JAXPTest.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | package com.xys.lib_tv_fullhtml.tagsoup.jaxp; 15 | 16 | import org.w3c.dom.Document; 17 | 18 | import java.io.File; 19 | 20 | import javax.xml.parsers.DocumentBuilderFactory; 21 | import javax.xml.parsers.SAXParserFactory; 22 | 23 | /** 24 | * Trivial non-robust test class, to show that TagSoup can be accessed using 25 | * JAXP interface. 26 | */ 27 | public class JAXPTest { 28 | public static void main(String[] args) 29 | throws Exception { 30 | new JAXPTest().test(args); 31 | } 32 | 33 | private void test(String[] args) 34 | throws Exception { 35 | if (args.length != 1) { 36 | System.err.println("Usage: java " + getClass() + " [input-file]"); 37 | System.exit(1); 38 | } 39 | File f = new File(args[0]); 40 | //System.setProperty("javax.xml.parsers.SAXParserFactory", SAXFactoryImpl.class.toString()); 41 | System.setProperty("javax.xml.parsers.SAXParserFactory", "org.ccil.cowan.tagsoup.jaxp.SAXFactoryImpl"); 42 | 43 | SAXParserFactory spf = SAXParserFactory.newInstance(); 44 | System.out.println("Ok, SAX factory JAXP creates is: " + spf); 45 | System.out.println("Let's parse..."); 46 | spf.newSAXParser().parse(f, new org.xml.sax.helpers.DefaultHandler()); 47 | System.out.println("Done. And then DOM build:"); 48 | 49 | Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(f); 50 | 51 | System.out.println("Succesfully built DOM tree from '" + f + "', -> " + doc); 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 46 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/HTMLModels.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // Defines models for HTMLSchema 16 | 17 | /** 18 | * This interface contains generated constants representing HTML content 19 | * models. Logically, it is part of HTMLSchema, but it is more 20 | * convenient to generate the constants into a separate interface. 21 | */ 22 | 23 | package com.xys.lib_tv_fullhtml.tagsoup; 24 | 25 | public interface HTMLModels { 26 | 27 | // Start of model definitions 28 | public static final int M_AREA = 1 << 1; 29 | public static final int M_BLOCK = 1 << 2; 30 | public static final int M_BLOCKINLINE = 1 << 3; 31 | public static final int M_BODY = 1 << 4; 32 | public static final int M_CELL = 1 << 5; 33 | public static final int M_COL = 1 << 6; 34 | public static final int M_DEF = 1 << 7; 35 | public static final int M_FORM = 1 << 8; 36 | public static final int M_FRAME = 1 << 9; 37 | public static final int M_HEAD = 1 << 10; 38 | public static final int M_HTML = 1 << 11; 39 | public static final int M_INLINE = 1 << 12; 40 | public static final int M_LEGEND = 1 << 13; 41 | public static final int M_LI = 1 << 14; 42 | public static final int M_NOLINK = 1 << 15; 43 | public static final int M_OPTION = 1 << 16; 44 | public static final int M_OPTIONS = 1 << 17; 45 | public static final int M_P = 1 << 18; 46 | public static final int M_PARAM = 1 << 19; 47 | public static final int M_TABLE = 1 << 20; 48 | public static final int M_TABULAR = 1 << 21; 49 | public static final int M_TR = 1 << 22; 50 | 51 | 52 | // End of model definitions 53 | 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TextViewForFullHtml 2 | 3 | TextViewForFullHtml是对原生TextView解析Html格式文本的增强。 4 | 5 | ## 原生TextView对Html的支持 6 | 7 | 原生的TextView同样支持Html的显示,但是Develop Doc里面也写了,并不是支持所有的Html标签,例如,font的size,默认的Android系统只支持small、normal、big三种,但是不支持具体的字号,比如textsize=14这种。 8 | 9 | ## TextViewForFullHtml 10 | 11 | TextViewForFullHtml这个库的目的在于在同一个TextView中给不同的文字设置不同大小的字体,当然,顺便也支持了其他的一些效果,比如对齐方式、字体风格等。 12 | 13 | 具体可以看示例图: 14 | 15 | ![](https://github.com/xuyisheng/TextViewForFullHtml/blob/master/art/demo.png) 16 | 17 | ## 代码使用示例 18 | 19 | 目前给出的String示例是ActionScript的,Html应该也可以支持(需要具体测试)。 20 | 21 | ``` 22 | String mContentTextSize = "

我是很大的字……我居然比旁边的字小我最小...啊啊啊......居然可以设置不同的字体字号

"; 23 | String mContentGravityCenter = "

我先来个居中对齐!

"; 24 | String mContentGravityRight = "

我是来右对齐的!

"; 25 | String mContentStyle = "

我可以设置很多不同的字体风格,比如:加粗斜体下划线

"; 26 | String mContentUrl = "

我可以设置一个超链接,牛逼吗 快戳我看看

"; 27 | ``` 28 | 29 | 使用方法: 30 | 31 | ``` 32 | // 示例:演示设置不同文字的字体大小 33 | TextViewForFullHtml textViewTextSize = new TextViewForFullHtml(this); 34 | textViewTextSize.loadContent(mContentTextSize); 35 | // 示例:演示设置不同文字的对齐风格——居中 36 | TextViewForFullHtml textViewGravityCenter = new TextViewForFullHtml(this); 37 | textViewGravityCenter.loadContent(mContentGravityCenter); 38 | // 示例:演示设置不同文字的对齐风格——右对齐 39 | TextViewForFullHtml textViewGravityRight = new TextViewForFullHtml(this); 40 | textViewGravityRight.loadContent(mContentGravityRight); 41 | // 示例:演示设置不同文字的字体风格 42 | TextViewForFullHtml textViewStyle = new TextViewForFullHtml(this); 43 | textViewStyle.loadContent(mContentStyle); 44 | // 示例:演示设置不同文字的超链接 45 | TextViewForFullHtml textViewUrl = new TextViewForFullHtml(this); 46 | textViewUrl.loadContent(mContentUrl); 47 | ``` 48 | 49 | 使用非常简单,用TextViewForFullHtml替换掉TextView并调用loadContent方法即可。 -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /app/src/main/java/com/xys/textviewforfullhtml/MainActivity.java: -------------------------------------------------------------------------------- 1 | package com.xys.textviewforfullhtml; 2 | 3 | import android.os.Bundle; 4 | import android.support.v7.app.AppCompatActivity; 5 | import android.widget.LinearLayout; 6 | 7 | import com.xys.lib_tv_fullhtml.TextViewForFullHtml; 8 | 9 | public class MainActivity extends AppCompatActivity { 10 | 11 | String mContentTextSize = "

我是很大的字……我居然比旁边的字小我最小...啊啊啊......居然可以设置不同的字体字号

"; 12 | String mContentGravityCenter = "

我先来个居中对齐!

"; 13 | String mContentGravityRight = "

我是来右对齐的!

"; 14 | String mContentStyle = "

我可以设置很多不同的字体风格,比如:加粗斜体下划线

"; 15 | String mContentUrl = "

我可以设置一个超链接,牛逼吗 快戳我看看

"; 16 | 17 | @Override 18 | protected void onCreate(Bundle savedInstanceState) { 19 | super.onCreate(savedInstanceState); 20 | setContentView(R.layout.activity_main); 21 | LinearLayout container = (LinearLayout) findViewById(R.id.container); 22 | // 示例:演示设置不同文字的字体大小 23 | TextViewForFullHtml textViewTextSize = new TextViewForFullHtml(this); 24 | textViewTextSize.loadContent(mContentTextSize); 25 | // 示例:演示设置不同文字的对齐风格——居中 26 | TextViewForFullHtml textViewGravityCenter = new TextViewForFullHtml(this); 27 | textViewGravityCenter.loadContent(mContentGravityCenter); 28 | // 示例:演示设置不同文字的对齐风格——右对齐 29 | TextViewForFullHtml textViewGravityRight = new TextViewForFullHtml(this); 30 | textViewGravityRight.loadContent(mContentGravityRight); 31 | // 示例:演示设置不同文字的字体风格 32 | TextViewForFullHtml textViewStyle = new TextViewForFullHtml(this); 33 | textViewStyle.loadContent(mContentStyle); 34 | // 示例:演示设置不同文字的超链接 35 | TextViewForFullHtml textViewUrl = new TextViewForFullHtml(this); 36 | textViewUrl.loadContent(mContentUrl); 37 | 38 | container.addView(textViewTextSize); 39 | container.addView(textViewGravityCenter); 40 | container.addView(textViewGravityRight); 41 | container.addView(textViewStyle); 42 | container.addView(textViewUrl); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/TextViewForFullHtml.java: -------------------------------------------------------------------------------- 1 | package com.xys.lib_tv_fullhtml; 2 | 3 | import android.content.Context; 4 | import android.text.Spannable; 5 | import android.text.SpannableStringBuilder; 6 | import android.text.Spanned; 7 | import android.text.method.LinkMovementMethod; 8 | import android.text.style.URLSpan; 9 | import android.view.Gravity; 10 | import android.view.View; 11 | import android.widget.TextView; 12 | import android.widget.Toast; 13 | 14 | import java.util.regex.Matcher; 15 | import java.util.regex.Pattern; 16 | 17 | /** 18 | * TextViewForFullHtml是一个增强的TextView,修改了TextView.fromHtml不能设置 19 | * 字体大小的问题(原生的只能设置small\normal\big),同时,兼容了ActionScript脚本 20 | */ 21 | public class TextViewForFullHtml extends TextView { 22 | 23 | private static Context sContext; 24 | 25 | public TextViewForFullHtml(Context context) { 26 | super(context); 27 | sContext = context; 28 | } 29 | 30 | private void txtViewSetText(TextView view, CharSequence text, BufferType type) { 31 | CharSequence t = text; 32 | if (t instanceof Spannable) { 33 | int end = text.length(); 34 | Spannable sp = (Spannable) t; 35 | URLSpan[] urls = sp.getSpans(0, end, URLSpan.class); 36 | SpannableStringBuilder style = new SpannableStringBuilder(text); 37 | if (urls.length > 0) { 38 | view.setMovementMethod(LinkMovementMethod.getInstance()); 39 | for (URLSpan url : urls) { 40 | HJURLSpan myURLSpan = new HJURLSpan(view, url.getURL()); 41 | style.clearSpans(); 42 | style.setSpan(myURLSpan, sp.getSpanStart(url), 43 | sp.getSpanEnd(url), 44 | Spannable.SPAN_EXCLUSIVE_INCLUSIVE); 45 | } 46 | } 47 | view.setText(style, type); 48 | } 49 | } 50 | 51 | public void loadContent(String content) { 52 | int gravity = Gravity.NO_GRAVITY; 53 | content = content.replace("", "
"); 55 | 56 | content = ActionscriptTextUtils.parseFontHTML(content); 57 | 58 | String p_regex = ""; 59 | Pattern p2 = Pattern.compile(p_regex); 60 | Matcher m2 = p2.matcher(content); 61 | String c_str = "left"; 62 | while (m2.find()) { 63 | c_str = m2.group(1); 64 | break; 65 | } 66 | if (c_str.equalsIgnoreCase("LEFT")) { 67 | gravity = Gravity.LEFT; 68 | } else if (c_str.equalsIgnoreCase("CENTER")) { 69 | gravity = Gravity.CENTER; 70 | } else if (c_str.equalsIgnoreCase("RIGHT")) { 71 | gravity = Gravity.RIGHT; 72 | } 73 | Spanned spaned = FullHtml.fromHtml(content); 74 | txtViewSetText(TextViewForFullHtml.this, spaned, BufferType.SPANNABLE); 75 | setGravity(gravity); 76 | } 77 | 78 | private static class HJURLSpan extends URLSpan { 79 | private String mUrl; 80 | private View mView; 81 | 82 | public HJURLSpan(View view, String url) { 83 | super(url); 84 | mView = view; 85 | mUrl = url; 86 | } 87 | 88 | @Override 89 | public void onClick(View widget) { 90 | Toast.makeText(sContext, mUrl, Toast.LENGTH_SHORT).show(); 91 | } 92 | } 93 | } 94 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/ScanHandler.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // Scanner handler 16 | 17 | package com.xys.lib_tv_fullhtml.tagsoup; 18 | 19 | import org.xml.sax.SAXException; 20 | 21 | /** 22 | * An interface that Scanners use to report events in the input stream. 23 | **/ 24 | 25 | public interface ScanHandler { 26 | /** 27 | * Reports an attribute name without a value. 28 | **/ 29 | 30 | public void adup(char[] buff, int offset, int length) throws SAXException; 31 | 32 | /** 33 | * Reports an attribute name; a value will follow. 34 | **/ 35 | 36 | public void aname(char[] buff, int offset, int length) throws SAXException; 37 | 38 | /** 39 | * Reports an attribute value. 40 | **/ 41 | 42 | public void aval(char[] buff, int offset, int length) throws SAXException; 43 | 44 | /** 45 | * Reports the content of a CDATA section (not a CDATA element) 46 | */ 47 | public void cdsect(char[] buff, int offset, int length) throws SAXException; 48 | 49 | /** 50 | * Reports a declaration - typically a DOCTYPE 51 | */ 52 | 53 | public void decl(char[] buff, int offset, int length) throws SAXException; 54 | 55 | /** 56 | * Reports an entity reference or character reference. 57 | **/ 58 | 59 | public void entity(char[] buff, int offset, int length) throws SAXException; 60 | 61 | /** 62 | * Reports EOF. 63 | **/ 64 | 65 | public void eof(char[] buff, int offset, int length) throws SAXException; 66 | 67 | /** 68 | * Reports an end-tag. 69 | **/ 70 | 71 | public void etag(char[] buff, int offset, int length) throws SAXException; 72 | 73 | /** 74 | * Reports the general identifier (element type name) of a start-tag. 75 | **/ 76 | 77 | public void gi(char[] buff, int offset, int length) throws SAXException; 78 | 79 | /** 80 | * Reports character content. 81 | **/ 82 | 83 | public void pcdata(char[] buff, int offset, int length) throws SAXException; 84 | 85 | /** 86 | * Reports the data part of a processing instruction. 87 | **/ 88 | 89 | public void pi(char[] buff, int offset, int length) throws SAXException; 90 | 91 | /** 92 | * Reports the target part of a processing instruction. 93 | **/ 94 | 95 | public void pitarget(char[] buff, int offset, int length) throws SAXException; 96 | 97 | /** 98 | * Reports the close of a start-tag. 99 | **/ 100 | 101 | public void stagc(char[] buff, int offset, int length) throws SAXException; 102 | 103 | /** 104 | * Reports the close of an empty-tag. 105 | **/ 106 | 107 | public void stage(char[] buff, int offset, int length) throws SAXException; 108 | 109 | /** 110 | * Reports a comment. 111 | **/ 112 | 113 | public void cmnt(char[] buff, int offset, int length) throws SAXException; 114 | 115 | /** 116 | * Returns the value of the last entity or character reference reported. 117 | **/ 118 | 119 | public int getEntity(); 120 | } 121 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/jaxp/SAXParserImpl.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | package com.xys.lib_tv_fullhtml.tagsoup.jaxp; 15 | 16 | 17 | import com.xys.lib_tv_fullhtml.tagsoup.Parser; 18 | 19 | import org.xml.sax.SAXException; 20 | import org.xml.sax.SAXNotRecognizedException; 21 | import org.xml.sax.SAXNotSupportedException; 22 | import org.xml.sax.XMLReader; 23 | 24 | import java.util.Iterator; 25 | import java.util.Map; 26 | 27 | import javax.xml.parsers.SAXParser; 28 | 29 | 30 | /** 31 | * This is a simple implementation of JAXP {@link SAXParser}, 32 | * to allow easier integration of TagSoup with the default JDK 33 | * xml processing stack. 34 | * 35 | * @author Tatu Saloranta (cowtowncoder@yahoo.com) 36 | */ 37 | public class SAXParserImpl 38 | extends SAXParser { 39 | final Parser parser; 40 | 41 | protected SAXParserImpl() // used by factory, for prototypes 42 | { 43 | super(); 44 | parser = new Parser(); 45 | } 46 | 47 | public static SAXParserImpl newInstance(Map features) 48 | throws SAXException { 49 | SAXParserImpl parser = new SAXParserImpl(); 50 | if (features != null) { 51 | Iterator it = features.entrySet().iterator(); 52 | while (it.hasNext()) { 53 | Map.Entry entry = (Map.Entry) it.next(); 54 | parser.setFeature((String) entry.getKey(), ((Boolean) entry.getValue()).booleanValue()); 55 | } 56 | } 57 | return parser; 58 | } 59 | 60 | // // // JAXP API implementation: 61 | 62 | /** 63 | * To support SAX1 interface, we'll need to use an adapter. 64 | * 65 | * @deprecated 66 | */ 67 | public org.xml.sax.Parser getParser() 68 | throws SAXException { 69 | return new SAX1ParserAdapter(parser); 70 | } 71 | 72 | public XMLReader getXMLReader() { 73 | return parser; 74 | } 75 | 76 | public boolean isNamespaceAware() { 77 | try { 78 | return parser.getFeature(Parser.namespacesFeature); 79 | } catch (SAXException sex) { 80 | throw new RuntimeException(sex.getMessage()); 81 | } 82 | } 83 | 84 | public boolean isValidating() { 85 | try { 86 | return parser.getFeature(Parser.validationFeature); 87 | } catch (SAXException sex) { 88 | throw new RuntimeException(sex.getMessage()); 89 | } 90 | } 91 | 92 | public void setProperty(String name, Object value) 93 | throws SAXNotRecognizedException, SAXNotSupportedException { 94 | parser.setProperty(name, value); 95 | } 96 | 97 | public Object getProperty(String name) 98 | throws SAXNotRecognizedException, SAXNotSupportedException { 99 | return parser.getProperty(name); 100 | } 101 | 102 | // // // Additional convenience methods 103 | 104 | public void setFeature(String name, boolean value) 105 | throws SAXNotRecognizedException, SAXNotSupportedException { 106 | parser.setFeature(name, value); 107 | } 108 | 109 | public boolean getFeature(String name) 110 | throws SAXNotRecognizedException, SAXNotSupportedException { 111 | return parser.getFeature(name); 112 | } 113 | } 114 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/jaxp/SAXFactoryImpl.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | package com.xys.lib_tv_fullhtml.tagsoup.jaxp; 15 | 16 | import org.xml.sax.SAXException; 17 | import org.xml.sax.SAXNotRecognizedException; 18 | import org.xml.sax.SAXNotSupportedException; 19 | 20 | import java.util.HashMap; 21 | import java.util.LinkedHashMap; 22 | 23 | import javax.xml.parsers.ParserConfigurationException; 24 | import javax.xml.parsers.SAXParser; 25 | import javax.xml.parsers.SAXParserFactory; 26 | 27 | /** 28 | * This is a simple implementation of JAXP {@link SAXParserFactory}, 29 | * to allow easier integration of TagSoup with the default JDK 30 | * xml processing stack. 31 | * 32 | * @author Tatu Saloranta (cowtowncoder@yahoo.com) 33 | */ 34 | public class SAXFactoryImpl 35 | extends SAXParserFactory { 36 | /** 37 | * The easiest way to test validity of features to set is to use 38 | * a prototype object. Currently this is actually not a real prototype, 39 | * in the sense that the configuration is actually passed separately 40 | * (as opposed to instantiating new readers from this prototype), but 41 | * this could be changed in future, if TagSoup parser object allowed 42 | * cloning. 43 | */ 44 | private SAXParserImpl prototypeParser = null; 45 | 46 | /** 47 | * This Map contains explicitly set features that can be succesfully 48 | * set for XMLReader instances. Temporary storage is needed due to 49 | * JAXP design: multiple readers can be instantiated from a single 50 | * factory, and settings can be changed between instantiations. 51 | *

52 | * Note that we wouldn't need this map if we could create instances 53 | * directly using the prototype instance. 54 | */ 55 | private HashMap features = null; 56 | 57 | public SAXFactoryImpl() { 58 | super(); 59 | } 60 | 61 | // // // JAXP API implementation: 62 | 63 | /** 64 | * Creates a new instance of SAXParser using the currently 65 | * configured factory parameters. 66 | */ 67 | public SAXParser newSAXParser() 68 | throws ParserConfigurationException { 69 | try { 70 | return SAXParserImpl.newInstance(features); 71 | } catch (SAXException se) { 72 | // Translate to ParserConfigurationException 73 | throw new ParserConfigurationException(se.getMessage()); 74 | } 75 | } 76 | 77 | /** 78 | * Defines that the specified feature is to enabled/disabled (as 79 | * per second argument) on reader instances created by this 80 | * factory. 81 | */ 82 | public void setFeature(String name, boolean value) 83 | throws ParserConfigurationException, SAXNotRecognizedException, 84 | SAXNotSupportedException { 85 | // First, let's see if it's a valid call 86 | getPrototype().setFeature(name, value); 87 | 88 | // If not, exception was thrown: so we are good now: 89 | if (features == null) { 90 | // Let's retain the ordering as well 91 | features = new LinkedHashMap(); 92 | } 93 | features.put(name, value ? Boolean.TRUE : Boolean.FALSE); 94 | } 95 | 96 | /** 97 | * Returns whether the specified property will be enabled or disabled 98 | * on reader instances constructed by this factory. 99 | */ 100 | public boolean getFeature(String name) 101 | throws ParserConfigurationException, SAXNotRecognizedException, 102 | SAXNotSupportedException { 103 | return getPrototype().getFeature(name); 104 | } 105 | 106 | // // // Internal methods 107 | 108 | private SAXParserImpl getPrototype() { 109 | if (prototypeParser == null) { 110 | prototypeParser = new SAXParserImpl(); 111 | } 112 | return prototypeParser; 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/PYXScanner.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // This file is part of TagSoup. 16 | // 17 | // This program is free software; you can redistribute it and/or modify 18 | // it under the terms of the GNU General Public License as published by 19 | // the Free Software Foundation; either version 2 of the License, or 20 | // (at your option) any later version. You may also distribute 21 | // and/or modify it under version 2.1 of the Academic Free License. 22 | // 23 | // This program is distributed in the hope that it will be useful, 24 | // but WITHOUT ANY WARRANTY; without even the implied warranty of 25 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 26 | // 27 | // 28 | // PYX Scanner 29 | 30 | package com.xys.lib_tv_fullhtml.tagsoup; 31 | 32 | import org.xml.sax.SAXException; 33 | 34 | import java.io.BufferedReader; 35 | import java.io.BufferedWriter; 36 | import java.io.IOException; 37 | import java.io.InputStreamReader; 38 | import java.io.OutputStreamWriter; 39 | import java.io.Reader; 40 | import java.io.Writer; 41 | 42 | /** 43 | * A Scanner that accepts PYX format instead of HTML. 44 | * Useful primarily for debugging. 45 | **/ 46 | public class PYXScanner implements Scanner { 47 | 48 | public static void main(String[] argv) throws IOException, SAXException { 49 | Scanner s = new PYXScanner(); 50 | Reader r = new InputStreamReader(System.in, "UTF-8"); 51 | Writer w = new BufferedWriter(new OutputStreamWriter(System.out, "UTF-8")); 52 | s.scan(r, new PYXWriter(w)); 53 | } 54 | 55 | public void resetDocumentLocator(String publicid, String systemid) { 56 | // Need this method for interface compatibility, but note 57 | // that PyxScanner does not implement Locator. 58 | } 59 | 60 | public void scan(Reader r, ScanHandler h) throws IOException, SAXException { 61 | BufferedReader br = new BufferedReader(r); 62 | String s; 63 | char[] buff = null; 64 | boolean instag = false; 65 | while ((s = br.readLine()) != null) { 66 | int size = s.length(); 67 | if (buff == null || buff.length < size) { 68 | buff = new char[size]; 69 | } 70 | s.getChars(0, size, buff, 0); 71 | switch (buff[0]) { 72 | case '(': 73 | if (instag) { 74 | h.stagc(buff, 0, 0); 75 | instag = false; 76 | } 77 | h.gi(buff, 1, size - 1); 78 | instag = true; 79 | break; 80 | case ')': 81 | if (instag) { 82 | h.stagc(buff, 0, 0); 83 | instag = false; 84 | } 85 | h.etag(buff, 1, size - 1); 86 | break; 87 | case '?': 88 | if (instag) { 89 | h.stagc(buff, 0, 0); 90 | instag = false; 91 | } 92 | h.pi(buff, 1, size - 1); 93 | break; 94 | case 'A': 95 | int sp = s.indexOf(' '); 96 | h.aname(buff, 1, sp - 1); 97 | h.aval(buff, sp + 1, size - sp - 1); 98 | break; 99 | case '-': 100 | if (instag) { 101 | h.stagc(buff, 0, 0); 102 | instag = false; 103 | } 104 | if (s.equals("-\\n")) { 105 | buff[0] = '\n'; 106 | h.pcdata(buff, 0, 1); 107 | } else { 108 | // FIXME: 109 | // Does not decode \t and \\ in input 110 | h.pcdata(buff, 1, size - 1); 111 | } 112 | break; 113 | case 'E': 114 | if (instag) { 115 | h.stagc(buff, 0, 0); 116 | instag = false; 117 | } 118 | h.entity(buff, 1, size - 1); 119 | break; 120 | default: 121 | // System.err.print("Gotcha "); 122 | // System.err.print(s); 123 | // System.err.print('\n'); 124 | break; 125 | } 126 | } 127 | h.eof(buff, 0, 0); 128 | } 129 | 130 | public void startCDATA() { 131 | } 132 | } 133 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # Attempt to set APP_HOME 46 | # Resolve links: $0 may be a link 47 | PRG="$0" 48 | # Need this for relative symlinks. 49 | while [ -h "$PRG" ] ; do 50 | ls=`ls -ld "$PRG"` 51 | link=`expr "$ls" : '.*-> \(.*\)$'` 52 | if expr "$link" : '/.*' > /dev/null; then 53 | PRG="$link" 54 | else 55 | PRG=`dirname "$PRG"`"/$link" 56 | fi 57 | done 58 | SAVED="`pwd`" 59 | cd "`dirname \"$PRG\"`/" >/dev/null 60 | APP_HOME="`pwd -P`" 61 | cd "$SAVED" >/dev/null 62 | 63 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 64 | 65 | # Determine the Java command to use to start the JVM. 66 | if [ -n "$JAVA_HOME" ] ; then 67 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 68 | # IBM's JDK on AIX uses strange locations for the executables 69 | JAVACMD="$JAVA_HOME/jre/sh/java" 70 | else 71 | JAVACMD="$JAVA_HOME/bin/java" 72 | fi 73 | if [ ! -x "$JAVACMD" ] ; then 74 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 75 | 76 | Please set the JAVA_HOME variable in your environment to match the 77 | location of your Java installation." 78 | fi 79 | else 80 | JAVACMD="java" 81 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 82 | 83 | Please set the JAVA_HOME variable in your environment to match the 84 | location of your Java installation." 85 | fi 86 | 87 | # Increase the maximum file descriptors if we can. 88 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 89 | MAX_FD_LIMIT=`ulimit -H -n` 90 | if [ $? -eq 0 ] ; then 91 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 92 | MAX_FD="$MAX_FD_LIMIT" 93 | fi 94 | ulimit -n $MAX_FD 95 | if [ $? -ne 0 ] ; then 96 | warn "Could not set maximum file descriptor limit: $MAX_FD" 97 | fi 98 | else 99 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 100 | fi 101 | fi 102 | 103 | # For Darwin, add options to specify how the application appears in the dock 104 | if $darwin; then 105 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 106 | fi 107 | 108 | # For Cygwin, switch paths to Windows format before running java 109 | if $cygwin ; then 110 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 111 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 112 | JAVACMD=`cygpath --unix "$JAVACMD"` 113 | 114 | # We build the pattern for arguments to be converted via cygpath 115 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 116 | SEP="" 117 | for dir in $ROOTDIRSRAW ; do 118 | ROOTDIRS="$ROOTDIRS$SEP$dir" 119 | SEP="|" 120 | done 121 | OURCYGPATTERN="(^($ROOTDIRS))" 122 | # Add a user-defined pattern to the cygpath arguments 123 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 124 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 125 | fi 126 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 127 | i=0 128 | for arg in "$@" ; do 129 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 130 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 131 | 132 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 133 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 134 | else 135 | eval `echo args$i`="\"$arg\"" 136 | fi 137 | i=$((i+1)) 138 | done 139 | case $i in 140 | (0) set -- ;; 141 | (1) set -- "$args0" ;; 142 | (2) set -- "$args0" "$args1" ;; 143 | (3) set -- "$args0" "$args1" "$args2" ;; 144 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 145 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 146 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 147 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 148 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 149 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 150 | esac 151 | fi 152 | 153 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 154 | function splitJvmOpts() { 155 | JVM_OPTS=("$@") 156 | } 157 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 158 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 159 | 160 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 161 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/Schema.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // Model of document 16 | 17 | package com.xys.lib_tv_fullhtml.tagsoup; 18 | 19 | import java.util.HashMap; 20 | 21 | /** 22 | * Abstract class representing a TSSL schema. 23 | * Actual TSSL schemas are compiled into concrete subclasses of this class. 24 | **/ 25 | 26 | public abstract class Schema { 27 | 28 | public static final int M_ANY = 0xFFFFFFFF; 29 | public static final int M_EMPTY = 0; 30 | public static final int M_PCDATA = 1 << 30; 31 | public static final int M_ROOT = 1 << 31; 32 | 33 | 34 | public static final int F_RESTART = 1; 35 | public static final int F_CDATA = 2; 36 | public static final int F_NOFORCE = 4; 37 | 38 | private HashMap theEntities = 39 | new HashMap(); // String -> Character 40 | private HashMap theElementTypes = 41 | new HashMap(); // String -> ElementType 42 | 43 | private String theURI = ""; 44 | private String thePrefix = ""; 45 | private ElementType theRoot = null; 46 | 47 | /** 48 | * Add or replace an element type for this schema. 49 | * 50 | * @param name Name (Qname) of the element 51 | * @param model Models of the element's content as a vector of bits 52 | * @param memberOf Models the element is a member of as a vector of bits 53 | * @param flags Flags for the element 54 | **/ 55 | 56 | public void elementType(String name, int model, int memberOf, int flags) { 57 | ElementType e = new ElementType(name, model, memberOf, flags, this); 58 | theElementTypes.put(name.toLowerCase(), e); 59 | if (memberOf == M_ROOT) theRoot = e; 60 | } 61 | 62 | /** 63 | * Get the root element of this schema 64 | **/ 65 | 66 | public ElementType rootElementType() { 67 | return theRoot; 68 | } 69 | 70 | /** 71 | * Add or replace a default attribute for an element type in this schema. 72 | * 73 | * @param elemName Name (Qname) of the element type 74 | * @param attrName Name (Qname) of the attribute 75 | * @param type Type of the attribute 76 | * @param value Default value of the attribute; null if no default 77 | **/ 78 | 79 | public void attribute(String elemName, String attrName, 80 | String type, String value) { 81 | ElementType e = getElementType(elemName); 82 | if (e == null) { 83 | throw new Error("Attribute " + attrName + 84 | " specified for unknown element type " + 85 | elemName); 86 | } 87 | e.setAttribute(attrName, type, value); 88 | } 89 | 90 | /** 91 | * Specify natural parent of an element in this schema. 92 | * 93 | * @param name Name of the child element 94 | * @param parentName Name of the parent element 95 | **/ 96 | 97 | public void parent(String name, String parentName) { 98 | ElementType child = getElementType(name); 99 | ElementType parent = getElementType(parentName); 100 | if (child == null) { 101 | throw new Error("No child " + name + " for parent " + parentName); 102 | } 103 | if (parent == null) { 104 | throw new Error("No parent " + parentName + " for child " + name); 105 | } 106 | child.setParent(parent); 107 | } 108 | 109 | /** 110 | * Add to or replace a character entity in this schema. 111 | * 112 | * @param name Name of the entity 113 | * @param value Value of the entity 114 | **/ 115 | 116 | public void entity(String name, int value) { 117 | theEntities.put(name, new Integer(value)); 118 | } 119 | 120 | /** 121 | * Get an ElementType by name. 122 | * 123 | * @param name Name (Qname) of the element type 124 | * @return The corresponding ElementType 125 | **/ 126 | 127 | public ElementType getElementType(String name) { 128 | return (ElementType) (theElementTypes.get(name.toLowerCase())); 129 | } 130 | 131 | /** 132 | * Get an entity value by name. 133 | * 134 | * @param name Name of the entity 135 | * @return The corresponding character, or 0 if none 136 | **/ 137 | 138 | public int getEntity(String name) { 139 | // System.err.println("%% Looking up entity " + name); 140 | Integer ch = (Integer) theEntities.get(name); 141 | if (ch == null) return 0; 142 | return ch.intValue(); 143 | } 144 | 145 | /** 146 | * Return the URI (namespace name) of this schema. 147 | **/ 148 | 149 | public String getURI() { 150 | return theURI; 151 | } 152 | 153 | /** 154 | * Change the URI (namespace name) of this schema. 155 | **/ 156 | 157 | public void setURI(String uri) { 158 | theURI = uri; 159 | } 160 | 161 | /** 162 | * Return the prefix of this schema. 163 | **/ 164 | 165 | public String getPrefix() { 166 | return thePrefix; 167 | } 168 | 169 | /** 170 | * Change the prefix of this schema. 171 | **/ 172 | 173 | public void setPrefix(String prefix) { 174 | thePrefix = prefix; 175 | } 176 | 177 | } 178 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/jaxp/SAX1ParserAdapter.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | package com.xys.lib_tv_fullhtml.tagsoup.jaxp; 15 | 16 | import org.xml.sax.AttributeList; 17 | import org.xml.sax.Attributes; 18 | import org.xml.sax.ContentHandler; 19 | import org.xml.sax.DTDHandler; 20 | import org.xml.sax.DocumentHandler; 21 | import org.xml.sax.EntityResolver; 22 | import org.xml.sax.ErrorHandler; 23 | import org.xml.sax.InputSource; 24 | import org.xml.sax.Locator; 25 | import org.xml.sax.SAXException; 26 | import org.xml.sax.SAXNotSupportedException; 27 | import org.xml.sax.XMLReader; 28 | 29 | import java.io.IOException; 30 | 31 | /** 32 | * This is a simpler adapter class that allows using SAX1 interface on top 33 | * of basic SAX2 implementation, such as TagSoup. 34 | * 35 | * @author Tatu Saloranta (cowtowncoder@yahoo.com) 36 | * @deprecated 37 | */ 38 | public class SAX1ParserAdapter 39 | implements org.xml.sax.Parser { 40 | final XMLReader xmlReader; 41 | 42 | public SAX1ParserAdapter(XMLReader xr) { 43 | xmlReader = xr; 44 | } 45 | 46 | // Sax1 API impl 47 | 48 | public void parse(InputSource source) 49 | throws SAXException { 50 | try { 51 | xmlReader.parse(source); 52 | } catch (IOException ioe) { 53 | throw new SAXException(ioe); 54 | } 55 | } 56 | 57 | public void parse(String systemId) 58 | throws SAXException { 59 | try { 60 | xmlReader.parse(systemId); 61 | } catch (IOException ioe) { 62 | throw new SAXException(ioe); 63 | } 64 | } 65 | 66 | /** 67 | * @deprecated 68 | */ 69 | public void setDocumentHandler(DocumentHandler h) { 70 | xmlReader.setContentHandler(new DocHandlerWrapper(h)); 71 | } 72 | 73 | public void setDTDHandler(DTDHandler h) { 74 | xmlReader.setDTDHandler(h); 75 | } 76 | 77 | public void setEntityResolver(EntityResolver r) { 78 | xmlReader.setEntityResolver(r); 79 | } 80 | 81 | public void setErrorHandler(ErrorHandler h) { 82 | xmlReader.setErrorHandler(h); 83 | } 84 | 85 | public void setLocale(java.util.Locale locale) 86 | throws SAXException { 87 | /* I have no idea what this is supposed to do... so let's 88 | * throw an exception 89 | */ 90 | throw new SAXNotSupportedException("TagSoup does not implement setLocale() method"); 91 | } 92 | 93 | // Helper classes: 94 | 95 | /** 96 | * We need another helper class to deal with differences between 97 | * Sax2 handler (content handler), and Sax1 handler (document handler) 98 | * 99 | * @deprecated 100 | */ 101 | final static class DocHandlerWrapper 102 | implements ContentHandler { 103 | final DocumentHandler docHandler; 104 | 105 | final AttributesWrapper mAttrWrapper = new AttributesWrapper(); 106 | 107 | /** 108 | * @deprecated 109 | */ 110 | DocHandlerWrapper(DocumentHandler h) { 111 | docHandler = h; 112 | } 113 | 114 | public void characters(char[] ch, int start, int length) 115 | throws SAXException { 116 | docHandler.characters(ch, start, length); 117 | } 118 | 119 | public void endDocument() 120 | throws SAXException { 121 | docHandler.endDocument(); 122 | } 123 | 124 | public void endElement(String uri, String localName, String qName) 125 | throws SAXException { 126 | if (qName == null) { 127 | qName = localName; 128 | } 129 | docHandler.endElement(qName); 130 | } 131 | 132 | public void endPrefixMapping(String prefix) { 133 | // no equivalent in SAX1, ignore 134 | } 135 | 136 | public void ignorableWhitespace(char[] ch, int start, int length) 137 | throws SAXException { 138 | docHandler.ignorableWhitespace(ch, start, length); 139 | } 140 | 141 | public void processingInstruction(String target, String data) 142 | throws SAXException { 143 | docHandler.processingInstruction(target, data); 144 | } 145 | 146 | public void setDocumentLocator(Locator locator) { 147 | docHandler.setDocumentLocator(locator); 148 | } 149 | 150 | public void skippedEntity(String name) { 151 | // no equivalent in SAX1, ignore 152 | } 153 | 154 | public void startDocument() 155 | throws SAXException { 156 | docHandler.startDocument(); 157 | } 158 | 159 | public void startElement(String uri, String localName, String qName, 160 | Attributes attrs) 161 | throws SAXException { 162 | if (qName == null) { 163 | qName = localName; 164 | } 165 | // Also, need to wrap Attributes to look like AttributeLost 166 | mAttrWrapper.setAttributes(attrs); 167 | docHandler.startElement(qName, mAttrWrapper); 168 | } 169 | 170 | public void startPrefixMapping(String prefix, String uri) { 171 | // no equivalent in SAX1, ignore 172 | } 173 | } 174 | 175 | /** 176 | * And one more helper to deal with attribute access differences 177 | * 178 | * @deprecated 179 | */ 180 | final static class AttributesWrapper 181 | implements AttributeList { 182 | Attributes attrs; 183 | 184 | public AttributesWrapper() { 185 | } 186 | 187 | public void setAttributes(Attributes a) { 188 | attrs = a; 189 | } 190 | 191 | public int getLength() { 192 | return attrs.getLength(); 193 | } 194 | 195 | public String getName(int i) { 196 | String n = attrs.getQName(i); 197 | return (n == null) ? attrs.getLocalName(i) : n; 198 | } 199 | 200 | public String getType(int i) { 201 | return attrs.getType(i); 202 | } 203 | 204 | public String getType(String name) { 205 | return attrs.getType(name); 206 | } 207 | 208 | public String getValue(int i) { 209 | return attrs.getValue(i); 210 | } 211 | 212 | public String getValue(String name) { 213 | return attrs.getValue(name); 214 | } 215 | } 216 | } 217 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/Element.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | 14 | package com.xys.lib_tv_fullhtml.tagsoup; 15 | 16 | /** 17 | * The internal representation of an actual element (not an element type). 18 | * An Element has an element type, attributes, and a successor Element 19 | * for use in constructing stacks and queues of Elements. 20 | * 21 | * @see ElementType 22 | * @see AttributesImpl 23 | */ 24 | public class Element { 25 | 26 | 27 | private ElementType theType; // type of element 28 | private AttributesImpl theAtts; // attributes of element 29 | private Element theNext; // successor of element 30 | private boolean preclosed; // this element has been preclosed 31 | 32 | /** 33 | * Return an Element from a specified ElementType. 34 | * 35 | * @param type The element type of the newly constructed element 36 | * @param defaultAttributes True if default attributes are wanted 37 | */ 38 | 39 | public Element(ElementType type, boolean defaultAttributes) { 40 | theType = type; 41 | if (defaultAttributes) theAtts = new AttributesImpl(type.atts()); 42 | else theAtts = new AttributesImpl(); 43 | theNext = null; 44 | preclosed = false; 45 | } 46 | 47 | /** 48 | * Return the element type. 49 | * 50 | * @return The element type. 51 | */ 52 | 53 | public ElementType type() { 54 | return theType; 55 | } 56 | 57 | /** 58 | * Return the attributes as an AttributesImpl object. 59 | * Returning an AttributesImpl makes the attributes mutable. 60 | * 61 | * @return The attributes 62 | * @see AttributesImpl 63 | */ 64 | public AttributesImpl atts() { 65 | return theAtts; 66 | } 67 | 68 | /** 69 | * Return the next element in an element stack or queue. 70 | * 71 | * @return The next element 72 | */ 73 | 74 | public Element next() { 75 | return theNext; 76 | } 77 | 78 | /** 79 | * Change the next element in an element stack or queue. 80 | * 81 | * @param next The new next element 82 | */ 83 | 84 | public void setNext(Element next) { 85 | theNext = next; 86 | } 87 | 88 | /** 89 | * Return the name of the element's type. 90 | * Convenience method. 91 | * 92 | * @return The element type name 93 | */ 94 | 95 | public String name() { 96 | return theType.name(); 97 | } 98 | 99 | /** 100 | * Return the namespace name of the element's type. 101 | * Convenience method. 102 | * 103 | * @return The element type namespace name 104 | */ 105 | 106 | public String namespace() { 107 | return theType.namespace(); 108 | } 109 | 110 | /** 111 | * Return the local name of the element's type. 112 | * Convenience method. 113 | * 114 | * @return The element type local name 115 | */ 116 | 117 | public String localName() { 118 | return theType.localName(); 119 | } 120 | 121 | /** 122 | * Return the content model vector of the element's type. 123 | * Convenience method. 124 | * 125 | * @return The content model vector 126 | */ 127 | 128 | public int model() { 129 | return theType.model(); 130 | } 131 | 132 | /** 133 | * Return the member-of vector of the element's type. 134 | * Convenience method. 135 | * 136 | * @return The member-of vector 137 | */ 138 | 139 | public int memberOf() { 140 | return theType.memberOf(); 141 | } 142 | 143 | /** 144 | * Return the flags vector of the element's type. 145 | * Convenience method. 146 | * 147 | * @return The flags vector 148 | */ 149 | 150 | public int flags() { 151 | return theType.flags(); 152 | } 153 | 154 | /** 155 | * Return the parent element type of the element's type. 156 | * Convenience method. 157 | * 158 | * @return The parent element type 159 | */ 160 | 161 | public ElementType parent() { 162 | return theType.parent(); 163 | } 164 | 165 | /** 166 | * Return true if the type of this element can contain the type of 167 | * another element. 168 | * Convenience method. 169 | * 170 | * @param other The other element 171 | */ 172 | 173 | public boolean canContain(Element other) { 174 | return theType.canContain(other.theType); 175 | } 176 | 177 | 178 | /** 179 | * Set an attribute and its value into this element. 180 | * 181 | * @param name The attribute name (Qname) 182 | * @param type The attribute type 183 | * @param value The attribute value 184 | */ 185 | 186 | public void setAttribute(String name, String type, String value) { 187 | theType.setAttribute(theAtts, name, type, value); 188 | } 189 | 190 | /** 191 | * Make this element anonymous. 192 | * Remove any id or name attribute present 193 | * in the element's attributes. 194 | */ 195 | 196 | public void anonymize() { 197 | for (int i = theAtts.getLength() - 1; i >= 0; i--) { 198 | if (theAtts.getType(i).equals("ID") || 199 | theAtts.getQName(i).equals("name")) { 200 | theAtts.removeAttribute(i); 201 | } 202 | } 203 | } 204 | 205 | /** 206 | * Clean the attributes of this element. 207 | * Attributes with null name (the name was ill-formed) 208 | * or null value (the attribute was present in the element type but 209 | * not in this actual element) are removed. 210 | */ 211 | 212 | public void clean() { 213 | for (int i = theAtts.getLength() - 1; i >= 0; i--) { 214 | String name = theAtts.getLocalName(i); 215 | if (theAtts.getValue(i) == null || name == null || 216 | name.length() == 0) { 217 | theAtts.removeAttribute(i); 218 | continue; 219 | } 220 | } 221 | } 222 | 223 | /** 224 | * Force this element to preclosed status, meaning that an end-tag has 225 | * been seen but the element cannot yet be closed for structural reasons. 226 | */ 227 | 228 | public void preclose() { 229 | preclosed = true; 230 | } 231 | 232 | /** 233 | * Return true if this element has been preclosed. 234 | */ 235 | 236 | public boolean isPreclosed() { 237 | return preclosed; 238 | } 239 | 240 | } 241 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/lib_tv_fullhtml.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/ActionscriptTextUtils.java: -------------------------------------------------------------------------------- 1 | package com.xys.lib_tv_fullhtml; 2 | 3 | import android.text.TextUtils; 4 | 5 | import org.htmlparser.Node; 6 | import org.htmlparser.Parser; 7 | import org.htmlparser.nodes.TagNode; 8 | import org.htmlparser.nodes.TextNode; 9 | import org.htmlparser.tags.ParagraphTag; 10 | import org.htmlparser.util.NodeIterator; 11 | import org.htmlparser.util.NodeList; 12 | import org.htmlparser.util.ParserException; 13 | 14 | import java.util.ArrayList; 15 | 16 | /** 17 | * utils api for adobe action script/html. 18 | */ 19 | public class ActionscriptTextUtils { 20 | 21 | static boolean hasData = false; 22 | 23 | public static float getScaleYNumber(int h) { 24 | float f_num = 1f; 25 | if (h == 1080) { 26 | //OK 27 | f_num = 1.2f; 28 | } else if (h == 480) { 29 | //OK 30 | f_num = 0.9375f; 31 | } else if (h == 540) { 32 | f_num = 1.05f; 33 | } else if (h == 800) { 34 | //ok 35 | f_num = 1.0888f; 36 | } else if (h == 720) { 37 | //OK 38 | f_num = 1.0788f; 39 | } else if (h == 320) { 40 | f_num = 1f; 41 | } 42 | return f_num; 43 | } 44 | 45 | public static float getScaleXNumber(int w) { 46 | float f_num = 1.04f; 47 | if (w == 1920) { 48 | f_num = 1.05f; 49 | } else if (w == 800) { 50 | f_num = 1.04888f; 51 | } else if (w == 960) { 52 | f_num = 1.088888f; 53 | } else if (w == 1280) { 54 | f_num = 1.04f; 55 | } 56 | return f_num; 57 | } 58 | 59 | public static String parseFontHTML(String content) { 60 | hasData = false; 61 | Parser parser = Parser.createParser(content, "UTF-8"); 62 | 63 | StringBuilder sb = null; 64 | try { 65 | NodeList list = (NodeList) parser.parse(null); 66 | if (hasFont(list)) { 67 | sb = getNewHtml(list); 68 | } 69 | } catch (ParserException e) { 70 | e.printStackTrace(); 71 | } 72 | if (sb == null) { 73 | return content; 74 | } 75 | return sb.toString().replace("", "").replace("", ""); 76 | 77 | } 78 | 79 | private static boolean hasFont(NodeList list) { 80 | int count = 0; 81 | try { 82 | int len = list.size(); 83 | for (int i = 0; i < len; i++) { 84 | Node node = list.elementAt(i); 85 | if (node instanceof ParagraphTag) { 86 | NodeList p_list = node.getChildren(); 87 | count = checkFontTag(p_list); 88 | } else { 89 | if (node instanceof TagNode && ((TagNode) node).getRawTagName().equals("FONT")) { 90 | count++; 91 | } 92 | if (count >= 2) { 93 | break; 94 | } 95 | } 96 | } 97 | } catch (Exception e) { 98 | e.printStackTrace(); 99 | } 100 | return count >= 2; 101 | } 102 | 103 | private static int checkFontTag(NodeList list) { 104 | int count = 0; 105 | int len = list.size(); 106 | for (int i = 0; i < len; i++) { 107 | Node node = list.elementAt(i); 108 | if (node instanceof TagNode && ((TagNode) node).getRawTagName().equals("FONT")) { 109 | count++; 110 | } 111 | if (count >= 2) { 112 | break; 113 | } 114 | } 115 | return count; 116 | } 117 | 118 | private static StringBuilder getNewHtml(NodeList list) { 119 | int level = 0; 120 | ArrayList fontList = new ArrayList(); 121 | StringBuilder rt = new StringBuilder(); 122 | int defaultSize = 22; 123 | try { 124 | for (NodeIterator e = list.elements(); e.hasMoreNodes(); ) { 125 | Node node = e.nextNode(); 126 | StringBuilder _sbBuilder = null; 127 | if (node instanceof ParagraphTag) { 128 | _sbBuilder = getNewHtml(node.getChildren()); 129 | if (_sbBuilder != null) { 130 | rt.append(_sbBuilder.toString()); 131 | } 132 | } else { 133 | if (node instanceof TagNode) { 134 | TagNode tagNode = (TagNode) node; 135 | if (tagNode.getRawTagName().equals("FONT")) { 136 | level++; 137 | String sizeStr = getFontAttribute("SIZE", tagNode, fontList); 138 | String colorStr = getFontAttribute("COLOR", tagNode, fontList); 139 | // String sizeStr = tagNode.getAttribute("SIZE"); 140 | if (sizeStr != null) { 141 | int tmpSize = Integer.parseInt(sizeStr); 142 | tagNode.setAttribute("SIZE", "" + tmpSize); 143 | } else { 144 | tagNode.setAttribute("SIZE", "" + defaultSize); 145 | } 146 | if (colorStr != null) { 147 | tagNode.setAttribute("COLOR", colorStr); 148 | } 149 | fontList.add(tagNode); 150 | } else if (tagNode.getRawTagName().equals("/FONT")) { 151 | if (level > 0) { 152 | fontList.remove(level - 1); 153 | level--; 154 | } 155 | } else { 156 | String str = node.toHtml(); 157 | rt.append(str); 158 | } 159 | } else if (node instanceof TextNode) { 160 | if (level <= 0) { 161 | level = 1; 162 | } 163 | TagNode fontStr = fontList.get((level - 1)); 164 | String str = node.toHtml(); 165 | str = clearLastSpace(str); 166 | 167 | rt.append(fontStr.toHtml()).append(str).append(""); 168 | } 169 | } 170 | } 171 | } catch (ParserException e) { 172 | e.printStackTrace(); 173 | } catch (Exception e) { 174 | e.printStackTrace(); 175 | } 176 | return rt; 177 | 178 | } 179 | 180 | private static String getFontAttribute(String attribute, 181 | TagNode tagNode, ArrayList fontList) { 182 | String attrStr = tagNode.getAttribute(attribute); 183 | if (attrStr == null) { 184 | for (TagNode fontNode : fontList) { 185 | attrStr = fontNode.getAttribute(attribute); 186 | if (attrStr != null) { 187 | break; 188 | } 189 | } 190 | } 191 | return attrStr; 192 | } 193 | 194 | private static String clearLastSpace(String txt) { 195 | if (TextUtils.isEmpty(txt)) { 196 | return txt; 197 | } 198 | 199 | return txt.replaceAll("( )*$", ""); 200 | } 201 | } 202 | -------------------------------------------------------------------------------- /app/app.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 8 | 9 | 10 | 11 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /lib_tv_fullhtml/src/main/java/com/xys/lib_tv_fullhtml/tagsoup/PYXWriter.java: -------------------------------------------------------------------------------- 1 | // This file is part of TagSoup and is Copyright 2002-2008 by John Cowan. 2 | // 3 | // TagSoup is licensed under the Apache License, 4 | // Version 2.0. You may obtain a copy of this license at 5 | // http://www.apache.org/licenses/LICENSE-2.0 . You may also have 6 | // additional legal rights not granted by this license. 7 | // 8 | // TagSoup is distributed in the hope that it will be useful, but 9 | // unless required by applicable law or agreed to in writing, TagSoup 10 | // is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS 11 | // OF ANY KIND, either express or implied; not even the implied warranty 12 | // of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 13 | // 14 | // 15 | // PYX Writer 16 | // FIXME: does not do escapes in attribute values 17 | // FIXME: outputs entities as bare '&' character 18 | 19 | package com.xys.lib_tv_fullhtml.tagsoup; 20 | 21 | import org.xml.sax.Attributes; 22 | import org.xml.sax.ContentHandler; 23 | import org.xml.sax.Locator; 24 | import org.xml.sax.SAXException; 25 | import org.xml.sax.ext.LexicalHandler; 26 | 27 | import java.io.PrintWriter; 28 | import java.io.Writer; 29 | 30 | /** 31 | * A ContentHandler that generates PYX format instead of XML. 32 | * Primarily useful for debugging. 33 | **/ 34 | public class PYXWriter 35 | implements ScanHandler, ContentHandler, LexicalHandler { 36 | 37 | private static char[] dummy = new char[1]; 38 | private PrintWriter theWriter; // where we write to 39 | private String attrName; // saved attribute name 40 | 41 | // ScanHandler implementation 42 | 43 | public PYXWriter(Writer w) { 44 | if (w instanceof PrintWriter) { 45 | theWriter = (PrintWriter) w; 46 | } else { 47 | theWriter = new PrintWriter(w); 48 | } 49 | } 50 | 51 | public void adup(char[] buff, int offset, int length) throws SAXException { 52 | theWriter.println(attrName); 53 | attrName = null; 54 | } 55 | 56 | public void aname(char[] buff, int offset, int length) throws SAXException { 57 | theWriter.print('A'); 58 | theWriter.write(buff, offset, length); 59 | theWriter.print(' '); 60 | attrName = new String(buff, offset, length); 61 | } 62 | 63 | public void aval(char[] buff, int offset, int length) throws SAXException { 64 | theWriter.write(buff, offset, length); 65 | theWriter.println(); 66 | attrName = null; 67 | } 68 | 69 | public void cmnt(char[] buff, int offset, int length) throws SAXException { 70 | // theWriter.print('!'); 71 | // theWriter.write(buff, offset, length); 72 | // theWriter.println(); 73 | } 74 | 75 | public void entity(char[] buff, int offset, int length) throws SAXException { 76 | } 77 | 78 | public int getEntity() { 79 | return 0; 80 | } 81 | 82 | public void eof(char[] buff, int offset, int length) throws SAXException { 83 | theWriter.close(); 84 | } 85 | 86 | public void etag(char[] buff, int offset, int length) throws SAXException { 87 | theWriter.print(')'); 88 | theWriter.write(buff, offset, length); 89 | theWriter.println(); 90 | } 91 | 92 | public void decl(char[] buff, int offset, int length) throws SAXException { 93 | } 94 | 95 | public void gi(char[] buff, int offset, int length) throws SAXException { 96 | theWriter.print('('); 97 | theWriter.write(buff, offset, length); 98 | theWriter.println(); 99 | } 100 | 101 | public void cdsect(char[] buff, int offset, int length) throws SAXException { 102 | pcdata(buff, offset, length); 103 | } 104 | 105 | public void pcdata(char[] buff, int offset, int length) throws SAXException { 106 | if (length == 0) return; // nothing to do 107 | boolean inProgress = false; 108 | length += offset; 109 | for (int i = offset; i < length; i++) { 110 | if (buff[i] == '\n') { 111 | if (inProgress) { 112 | theWriter.println(); 113 | } 114 | theWriter.println("-\\n"); 115 | inProgress = false; 116 | } else { 117 | if (!inProgress) { 118 | theWriter.print('-'); 119 | } 120 | switch (buff[i]) { 121 | case '\t': 122 | theWriter.print("\\t"); 123 | break; 124 | case '\\': 125 | theWriter.print("\\\\"); 126 | break; 127 | default: 128 | theWriter.print(buff[i]); 129 | } 130 | inProgress = true; 131 | } 132 | } 133 | if (inProgress) { 134 | theWriter.println(); 135 | } 136 | } 137 | 138 | public void pitarget(char[] buff, int offset, int length) throws SAXException { 139 | theWriter.print('?'); 140 | theWriter.write(buff, offset, length); 141 | theWriter.write(' '); 142 | } 143 | 144 | public void pi(char[] buff, int offset, int length) throws SAXException { 145 | theWriter.write(buff, offset, length); 146 | theWriter.println(); 147 | } 148 | 149 | public void stagc(char[] buff, int offset, int length) throws SAXException { 150 | // theWriter.println("!"); // FIXME 151 | } 152 | 153 | // SAX ContentHandler implementation 154 | 155 | public void stage(char[] buff, int offset, int length) throws SAXException { 156 | theWriter.println("!"); // FIXME 157 | } 158 | 159 | public void characters(char[] buff, int offset, int length) throws SAXException { 160 | pcdata(buff, offset, length); 161 | } 162 | 163 | public void endDocument() throws SAXException { 164 | theWriter.close(); 165 | } 166 | 167 | public void endElement(String uri, String localname, String qname) throws SAXException { 168 | if (qname.length() == 0) qname = localname; 169 | theWriter.print(')'); 170 | theWriter.println(qname); 171 | } 172 | 173 | public void endPrefixMapping(String prefix) throws SAXException { 174 | } 175 | 176 | public void ignorableWhitespace(char[] buff, int offset, int length) throws SAXException { 177 | characters(buff, offset, length); 178 | } 179 | 180 | public void processingInstruction(String target, String data) throws SAXException { 181 | theWriter.print('?'); 182 | theWriter.print(target); 183 | theWriter.print(' '); 184 | theWriter.println(data); 185 | } 186 | 187 | public void setDocumentLocator(Locator locator) { 188 | } 189 | 190 | public void skippedEntity(String name) throws SAXException { 191 | } 192 | 193 | public void startDocument() throws SAXException { 194 | } 195 | 196 | public void startElement(String uri, String localname, String qname, 197 | Attributes atts) throws SAXException { 198 | if (qname.length() == 0) qname = localname; 199 | theWriter.print('('); 200 | theWriter.println(qname); 201 | int length = atts.getLength(); 202 | for (int i = 0; i < length; i++) { 203 | qname = atts.getQName(i); 204 | if (qname.length() == 0) qname = atts.getLocalName(i); 205 | theWriter.print('A'); 206 | // theWriter.print(atts.getType(i)); // DEBUG 207 | theWriter.print(qname); 208 | theWriter.print(' '); 209 | theWriter.println(atts.getValue(i)); 210 | } 211 | } 212 | 213 | // Default LexicalHandler implementation 214 | 215 | public void startPrefixMapping(String prefix, String uri) throws SAXException { 216 | } 217 | 218 | public void comment(char[] ch, int start, int length) throws SAXException { 219 | cmnt(ch, start, length); 220 | } 221 | 222 | public void endCDATA() throws SAXException { 223 | } 224 | 225 | public void endDTD() throws SAXException { 226 | } 227 | 228 | public void endEntity(String name) throws SAXException { 229 | } 230 | 231 | public void startCDATA() throws SAXException { 232 | } 233 | 234 | public void startDTD(String name, String publicId, String systemId) throws SAXException { 235 | } 236 | 237 | // Constructor 238 | 239 | public void startEntity(String name) throws SAXException { 240 | } 241 | } 242 | -------------------------------------------------------------------------------- /.idea/codeStyleSettings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 |

78 | 79 | 80 | 81 | xmlns:android 82 | 83 | 84 | 85 | 86 |
87 |
88 | 89 | 90 | 91 | xmlns:.* 92 | 93 | 94 | 95 | BY_NAME 96 | 97 |
98 |
99 | 100 | 101 | 102 | .*:id 103 | http://schemas.android.com/apk/res/android 104 | 105 | 106 | 107 |
108 |
109 | 110 | 111 | 112 | .*:name 113 | http://schemas.android.com/apk/res/android 114 | 115 | 116 | 117 |
118 |
119 | 120 | 121 | 122 | name 123 | ^$ 124 | 125 | 126 | 127 |
128 |
129 | 130 | 131 | 132 | style 133 | ^$ 134 | 135 | 136 | 137 |
138 |
139 | 140 | 141 | 142 | .* 143 | ^$ 144 | 145 | 146 | BY_NAME 147 | 148 |
149 |
150 | 151 | 152 | 153 | .*:layout_width 154 | http://schemas.android.com/apk/res/android 155 | 156 | 157 | 158 |
159 |
160 | 161 | 162 | 163 | .*:layout_height 164 | http://schemas.android.com/apk/res/android 165 | 166 | 167 | 168 |
169 |
170 | 171 | 172 | 173 | .*:layout_.* 174 | http://schemas.android.com/apk/res/android 175 | 176 | 177 | BY_NAME 178 | 179 |
180 |
181 | 182 | 183 | 184 | .*:width 185 | http://schemas.android.com/apk/res/android 186 | 187 | 188 | BY_NAME 189 | 190 |
191 |
192 | 193 | 194 | 195 | .*:height 196 | http://schemas.android.com/apk/res/android 197 | 198 | 199 | BY_NAME 200 | 201 |
202 |
203 | 204 | 205 | 206 | .* 207 | http://schemas.android.com/apk/res/android 208 | 209 | 210 | BY_NAME 211 | 212 |
213 |
214 | 215 | 216 | 217 | .* 218 | .* 219 | 220 | 221 | BY_NAME 222 | 223 |
224 | 225 | 226 | 227 | 228 | 229 |