commit 57a0ecc385904b41d1bfcb6999993421907cba91 Author: fankesyooni Date: Mon Feb 10 03:05:25 2025 +0800 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..d9b9b1a --- /dev/null +++ b/.editorconfig @@ -0,0 +1,35 @@ +# noinspection EditorConfigKeyCorrectness +[{*.kt,*.kts}] +ktlint_standard_annotation = disabled +ktlint_standard_filename = disabled +ktlint_standard_wrapping = disabled +ktlint_standard_import-ordering = enabled +ktlint_standard_max-line-length = disabled +ktlint_standard_multiline-if-else = disabled +ktlint_standard_argument-list-wrapping = disabled +ktlint_standard_parameter-list-wrapping = disabled +ktlint_standard_trailing-comma-on-declaration-site = disabled +ktlint_function_signature_body_expression_wrapping = multiline +ktlint_standard_string-template-indent = disabled +ktlint_standard_function-signature = disabled +ktlint_standard_trailing-comma-on-call-site = disabled +ktlint_standard_multiline-expression-wrapping = disabled +ktlint_standard_no-empty-first-line-in-class-body = disabled +ktlint_standard_if-else-wrapping = disabled +ktlint_standard_if-else-bracing = disabled +ktlint_standard_statement-wrapping = disabled +ktlint_standard_blank-line-before-declaration = disabled +ktlint_standard_no-empty-file = disabled +ktlint_standard_property-naming = disabled +ktlint_standard_function-naming = disabled +ktlint_standard_chain-method-continuation = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_condition-wrapping = disabled +ktlint_standard_class-signature = disabled +ktlint_standard_no-trailing-spaces = disabled +ktlint_standard_multiline-loop = disabled +ij_continuation_indent_size = 2 +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 150 \ No newline at end of file diff --git a/.github/workflows/docs-deploy.yml b/.github/workflows/docs-deploy.yml new file mode 100644 index 0000000..bb6cecc --- /dev/null +++ b/.github/workflows/docs-deploy.yml @@ -0,0 +1,57 @@ +name: Deploy to GitHub pages + +on: + workflow_dispatch: + push: + branches: [ main ] + paths: + - 'pangutext-android/src/**' + - 'docs-source/**' + - '.github/workflows/**' + +permissions: + contents: write + pages: write + id-token: write + +jobs: + docs: + if: ${{ success() }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Prepare Java 17 + uses: actions/setup-java@v3 + with: + java-version: 17 + java-package: jdk + distribution: 'temurin' + cache: 'gradle' + - name: Cache Gradle Dependencies + uses: actions/cache@v3 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + !~/.gradle/caches/build-cache-* + key: gradle-deps-core-${{ hashFiles('**/build.gradle.kts') }} + restore-keys: | + gradle-deps + - name: Build VuePress site + run: | + cd docs-source + yarn -i + yarn docs:build-gh-pages + - name: Deploy to GitHub Pages + uses: crazy-max/ghaction-github-pages@v4 + with: + target_branch: gh-pages + build_dir: docs-source/dist + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3842e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,107 @@ +## Fully .gtignore for IntelliJ, Android Studio and Gradle based Java projects +## References: +## - https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore +## - https://github.com/android/platform-samples/blob/main/.gitignore + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +.idea/.name +.idea/artifacts +.idea/compiler.xml +.idea/jarRepositories.xml +.idea/modules.xml +.idea/*.iml +.idea/modules +.idea/caches +.idea/material_theme** +.idea/other.xml +*.iml +*.ipr + +# Misc +.idea/misc.xml + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser + +# Android studio 3.1+ additional +.idea/deployment*.xml +.idea/assetWizardSettings.xml +.idea/androidTestResultsUserPreferences.xml + +# Android projects +**/local.properties +/captures +.externalNativeBuild +.cxx + +# Gradle projects +.gradle +build/ + +# Mkdocs temporary serving folder +docs-gen +site +*.bak +.idea/appInsightsSettings.xml + +# Mac OS +.DS_Store \ No newline at end of file diff --git a/.idea/icon.png b/.idea/icon.png new file mode 100644 index 0000000..55e4d67 Binary files /dev/null and b/.idea/icon.png differ diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..146ab09 --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,10 @@ + + + + \ No newline at end of file diff --git a/.idea/kotlinc.xml b/.idea/kotlinc.xml new file mode 100644 index 0000000..c224ad5 --- /dev/null +++ b/.idea/kotlinc.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/ktlint-plugin.xml b/.idea/ktlint-plugin.xml new file mode 100644 index 0000000..53c26b4 --- /dev/null +++ b/.idea/ktlint-plugin.xml @@ -0,0 +1,6 @@ + + + + MANUAL + + \ No newline at end of file diff --git a/.idea/migrations.xml b/.idea/migrations.xml new file mode 100644 index 0000000..f8051a6 --- /dev/null +++ b/.idea/migrations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. diff --git a/README-zh-CN.md b/README-zh-CN.md new file mode 100644 index 0000000..7adf872 --- /dev/null +++ b/README-zh-CN.md @@ -0,0 +1,92 @@ +# Pangu Text + +[![GitHub license](https://img.shields.io/github/license/BetterAndroid/android-app-template?color=blue)](https://github.com/BetterAndroid/android-app-template/blob/main/LICENSE) +[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/BetterAndroid) +[![Telegram](https://img.shields.io/badge/discussion%20dev-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev) +[![QQ](https://img.shields.io/badge/discussion%20dev-QQ-blue.svg?logo=tencent-qq&logoColor=red)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf) + +LOGO + +一个中日韩 (CJK) 与英文单词、半角数字排版的解决方案。 + +[English](README.md) | 简体中文 + +| LOGO | [BetterAndroid](https://github.com/BetterAndroid) | +|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------| + +这个项目属于上述组织,**点击上方链接关注这个组织**,发现更多好项目。 + +## 项目缘由 + +这个项目的起因是因为直到目前为止还没有一套公开的方案能够完美解决中文、日文、韩文与英文之间的排版问题, +正常情况下我们将 CJK (即中日韩) 与英文混排的时候,都会涉及到美观性问题,这算是一个历史遗留问题,全角文字与半角文字之间的书写规范不一样。虽然现在 W3C 规定了 +CJK 排版规范, +但是还是仅有部分愿意遵守排版要求的个人或企业选择了这种方案。 + +目前已知的厂商解决方案如下 + +- Apple 全系 (iOS、iPadOS、macOS、tvOS、watchOS) 文本排版解决方案 +- 小米 (HyperOS) 文本排版优化 +- OrginOS 基于字体的文本排版优化 + +但是这些方案都是封闭的,无法在其他平台上使用,因此我们希望能够提供一套开源的解决方案,能够适应各种场景、侵入性低且更容易集成,让更多的开发者能够使用这个方案来解决文本排版问题。 + +本项目得以进行的主要来源为 [pangu.js](https://github.com/vinta/pangu.js),它提供了一套 CJK 排版的正则,我们对其加以优化,实现各个平台不需要插入空格字符即可格式化文本排版的效果, +衷心感谢这个项目的开发者提供的方案,我们在这个方案上加以扩展,提供了更多解决方案的可能性。 + +## 效果 + +如你所见,`PanguText` 的排版方案并不是向 CJK 与英文单词之间插入空格来完成,而是使用每个平台对应的处理方案自动在这些字符之间添加空白间距来达到排版效果以达到最低的侵入性。 + +> 应用前 (上)、应用后 (下) + + + +> 动态应用 + + + +`PanguText` 支持动态应用,它允许你在输入文本的同时动态为每个字符添加空白间距。 + +## 开始使用 + +[点击这里](https://betterandroid.github.io/PanguText/zh-cn) 前往文档页面查看更多详细教程和内容。 + +## 项目推广 + + +
+

嘿,还请君留步!👋

+

这里有 Android 开发工具、UI 设计、Gradle 插件、Xposed 模块和实用软件等相关项目。

+

如果下方的项目能为你提供帮助,不妨为我点个 star 吧!

+

所有项目免费、开源,遵循对应开源许可协议。

+

→ 查看更多关于我的项目,请点击这里 ←

+
+ +## Star History + +![Star History Chart](https://api.star-history.com/svg?repos=BetterAndroid/PanguText&type=Date) + +## 许可证 + +- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) + +``` +Apache License Version 2.0 + +Copyright (C) 2019 HighCapable + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +版权所有 © 2019 HighCapable \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..60588f8 --- /dev/null +++ b/README.md @@ -0,0 +1,100 @@ +# Pangu Text + +[![GitHub license](https://img.shields.io/github/license/BetterAndroid/android-app-template?color=blue)](https://github.com/BetterAndroid/android-app-template/blob/main/LICENSE) +[![Telegram](https://img.shields.io/badge/discussion-Telegram-blue.svg?logo=telegram)](https://t.me/BetterAndroid) +[![Telegram](https://img.shields.io/badge/discussion%20dev-Telegram-blue.svg?logo=telegram)](https://t.me/HighCapable_Dev) +[![QQ](https://img.shields.io/badge/discussion%20dev-QQ-blue.svg?logo=tencent-qq&logoColor=red)](https://qm.qq.com/cgi-bin/qm/qr?k=Pnsc5RY6N2mBKFjOLPiYldbAbprAU3V7&jump_from=webapi&authKey=X5EsOVzLXt1dRunge8ryTxDRrh9/IiW1Pua75eDLh9RE3KXE+bwXIYF5cWri/9lf) + +LOGO + +A typographic solution for the optimal alignment of CJK characters, English words, and half-width digits. + +English | [简体中文](README-zh-CN.md) + +| LOGO | [BetterAndroid](https://github.com/BetterAndroid) | +|---------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------| + +This project belongs to the above-mentioned organization, **click the link above to follow this organization** and discover more good projects. + +## Project Reason + +This project was created because, until now, there hasn’t been a public solution to perfectly address the typography issues between Chinese, Japanese, +Korean, and English. +Typically, when mixing CJK (i.e. Chinese, Japanese, Korean) with English, aesthetic issues can arise—a historical legacy stemming from the differences +in writing conventions between full-width and half-width characters. Although the W3C has now established CJK typography guidelines, only a few +individuals or companies willing to adhere to these standards have adopted this approach. + +Currently, the known vendor solutions are as follows: + +- Apple platforms (iOS, iPadOS, macOS, tvOS, watchOS) text typography solutions +- Xiaomi’s (HyperOS) text typography optimization +- OrginOS’s font-based text typography optimization + +However, these solutions are closed and cannot be implemented on other platforms. +We aim to provide an open-source solution adaptable to various scenarios, featuring low intrusiveness and easy integration, allowing more developers +to effectively address text typography issues. + +The primary inspiration for this project comes from [pangu.js](https://github.com/vinta/pangu.js), which offers a set of regular expressions for CJK +typography. +We have optimized these solutions to format text across platforms without inserting extra space characters. We extend this approach further to explore +additional possibilities. + +Heartfelt thanks to the original developer of **pangu.js** for providing the foundational solution. + +## Effects + +As you can see, the typography scheme of `PanguText` does not work by simply inserting spaces between CJK characters and English words. +Instead, it leverages each platform's native handling to automatically add whitespace between these characters, ensuring minimal intrusion. + +> Before Applying (Top) vs. After Applying (Bottom) + + + +> Dynamic Application + + + +`PanguText` supports dynamic application, which means it can add whitespace gaps to each character on-the-fly as you input text. + +## Get Started + +[Click here](https://betterandroid.github.io/PanguText/en) go to the documentation page for more detailed tutorials and content. + +## Promotion + + +
+

Hey, please stay! 👋

+

Here are related projects such as Android development tools, UI design, Gradle plugins, Xposed Modules and practical software.

+

If the project below can help you, please give me a star!

+

All projects are free, open source, and follow the corresponding open source license agreement.

+

→ To see more about my projects, please click here ←

+
+ +## Star History + +![Star History Chart](https://api.star-history.com/svg?repos=BetterAndroid/PanguText&type=Date) + +## License + +- [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0) + +``` +Apache License Version 2.0 + +Copyright (C) 2019 HighCapable + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + https://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +``` + +Copyright © 2019 HighCapable \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts new file mode 100644 index 0000000..46f3b6e --- /dev/null +++ b/build.gradle.kts @@ -0,0 +1,64 @@ +import com.vanniktech.maven.publish.AndroidSingleVariantLibrary +import com.vanniktech.maven.publish.MavenPublishBaseExtension +import org.jetbrains.dokka.gradle.DokkaTask + +plugins { + autowire(libs.plugins.android.application) apply false + autowire(libs.plugins.android.library) apply false + autowire(libs.plugins.kotlin.android) apply false + autowire(libs.plugins.kotlin.dokka) apply false + autowire(libs.plugins.maven.publish) apply false +} + +libraryProjects { + afterEvaluate { + configure { + repositories { + val repositoryDir = gradle.gradleUserHomeDir + .resolve("highcapable-maven-repository") + .resolve("repository") + maven { + name = "HighCapableMavenReleases" + url = repositoryDir.resolve("releases").toURI() + } + maven { + name = "HighCapableMavenSnapShots" + url = repositoryDir.resolve("snapshots").toURI() + } + } + } + configure { + configure(AndroidSingleVariantLibrary(publishJavadocJar = false)) + } + } + tasks.withType().configureEach { + val configuration = """{ "footerMessage": "PanguText | Apache-2.0 License | Copyright (C) 2019 HighCapable" }""" + pluginsMapConfiguration.set(mapOf("org.jetbrains.dokka.base.DokkaBase" to configuration)) + } + tasks.register("publishKDoc") { + group = "documentation" + dependsOn("dokkaHtml") + doLast { + val docsDir = rootProject.projectDir + .resolve("docs-source") + .resolve("dist") + .resolve("KDoc") + .resolve(project.name) + if (docsDir.exists()) docsDir.deleteRecursively() else docsDir.mkdirs() + layout.buildDirectory.dir("dokka/html").get().asFile.copyRecursively(docsDir) + } + } +} + +fun libraryProjects(action: Action) { + val libraries = listOf( + Libraries.PANGUTEXT_ANDROID, + Libraries.PANGUTEXT_COMPOSE + ) + allprojects { if (libraries.contains(name)) action.execute(this) } +} + +object Libraries { + const val PANGUTEXT_ANDROID = "pangutext-android" + const val PANGUTEXT_COMPOSE = "pangutext-compose" +} \ No newline at end of file diff --git a/demo-android/build.gradle.kts b/demo-android/build.gradle.kts new file mode 100644 index 0000000..09c96a1 --- /dev/null +++ b/demo-android/build.gradle.kts @@ -0,0 +1,54 @@ +plugins { + autowire(libs.plugins.android.application) + autowire(libs.plugins.kotlin.android) +} + +android { + namespace = property.project.app.packageName + compileSdk = property.project.android.compileSdk + + defaultConfig { + applicationId = property.project.app.packageName + minSdk = property.project.android.minSdk + targetSdk = property.project.android.targetSdk + versionName = property.project.app.versionName + versionCode = property.project.app.versionCode + testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" + } + buildTypes { + release { + isMinifyEnabled = false + proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro") + } + } + compileOptions { + sourceCompatibility = JavaVersion.VERSION_17 + targetCompatibility = JavaVersion.VERSION_17 + } + kotlinOptions { + jvmTarget = "17" + freeCompilerArgs = listOf( + "-Xno-param-assertions", + "-Xno-call-assertions", + "-Xno-receiver-assertions" + ) + } + buildFeatures { + buildConfig = true + viewBinding = true + } +} + +dependencies { + implementation(projects.pangutextAndroid) + implementation(com.highcapable.betterandroid.ui.component) + implementation(com.highcapable.betterandroid.ui.extension) + implementation(com.highcapable.betterandroid.system.extension) + implementation(androidx.core.core.ktx) + implementation(androidx.appcompat.appcompat) + implementation(com.google.android.material.material) + implementation(androidx.constraintlayout.constraintlayout) + testImplementation(junit.junit) + androidTestImplementation(androidx.test.ext.junit) + androidTestImplementation(androidx.test.espresso.espresso.core) +} \ No newline at end of file diff --git a/demo-android/proguard-rules.pro b/demo-android/proguard-rules.pro new file mode 100644 index 0000000..e819dd1 --- /dev/null +++ b/demo-android/proguard-rules.pro @@ -0,0 +1,32 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle.kts. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile + +-assumenosideeffects class kotlin.jvm.internal.Intrinsics { + public static *** throwUninitializedProperty(...); + public static *** throwUninitializedPropertyAccessException(...); +} + +-keep class * extends android.app.Activity +-keep class * implements androidx.viewbinding.ViewBinding { + (); + *** inflate(android.view.LayoutInflater); +} \ No newline at end of file diff --git a/demo-android/src/androidTest/java/com/highcapable/pangutext/demo/ExampleInstrumentedTest.kt b/demo-android/src/androidTest/java/com/highcapable/pangutext/demo/ExampleInstrumentedTest.kt new file mode 100644 index 0000000..22ce155 --- /dev/null +++ b/demo-android/src/androidTest/java/com/highcapable/pangutext/demo/ExampleInstrumentedTest.kt @@ -0,0 +1,24 @@ +package com.highcapable.pangutext.demo + +import androidx.test.platform.app.InstrumentationRegistry +import androidx.test.ext.junit.runners.AndroidJUnit4 + +import org.junit.Test +import org.junit.runner.RunWith + +import org.junit.Assert.* + +/** + * Instrumented test, which will execute on an Android device. + * + * See [testing documentation](http://d.android.com/tools/testing). + */ +@RunWith(AndroidJUnit4::class) +class ExampleInstrumentedTest { + @Test + fun useAppContext() { + // Context of the app under test. + val appContext = InstrumentationRegistry.getInstrumentation().targetContext + assertEquals("com.highcapable.pangutext", appContext.packageName) + } +} \ No newline at end of file diff --git a/demo-android/src/main/AndroidManifest.xml b/demo-android/src/main/AndroidManifest.xml new file mode 100644 index 0000000..f7b8a70 --- /dev/null +++ b/demo-android/src/main/AndroidManifest.xml @@ -0,0 +1,29 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/ListActivity.kt b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/ListActivity.kt new file mode 100644 index 0000000..d5a312a --- /dev/null +++ b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/ListActivity.kt @@ -0,0 +1,50 @@ +/* + * PanguText - A typographic solution for the optimal alignment of CJK characters, English words, and half-width digits. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/PanguText + * + * Apache License Version 2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is created by fankes on 2025/2/9. + */ +package com.highcapable.pangutext.demo.ui + +import android.graphics.Color +import android.os.Bundle +import com.highcapable.betterandroid.ui.component.adapter.factory.bindAdapter +import com.highcapable.betterandroid.ui.extension.view.textColor +import com.highcapable.pangutext.demo.databinding.ActivityListBinding +import com.highcapable.pangutext.demo.databinding.AdapterListBinding +import com.highcapable.pangutext.demo.ui.base.BaseActivity + +class ListActivity : BaseActivity() { + + private val listData = List(100) { "这是第${it}条Data演示" } + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding.recyclerView.bindAdapter { + onBindData { listData } + onBindViews { binding, text, _ -> + binding.text.text = text + binding.text.textColor = Color.rgb( + (0..255).random(), + (0..255).random(), + (0..255).random() + ) + } + } + } +} \ No newline at end of file diff --git a/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/MainActivity.kt b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/MainActivity.kt new file mode 100644 index 0000000..61be721 --- /dev/null +++ b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/MainActivity.kt @@ -0,0 +1,64 @@ +/* + * PanguText - A typographic solution for the optimal alignment of CJK characters, English words, and half-width digits. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/PanguText + * + * Apache License Version 2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is created by fankes on 2025/1/12. + */ +package com.highcapable.pangutext.demo.ui + +import android.os.Bundle +import android.text.method.LinkMovementMethod +import androidx.core.text.HtmlCompat +import com.highcapable.betterandroid.ui.component.insets.factory.handleOnWindowInsetsChanged +import com.highcapable.betterandroid.ui.component.insets.factory.setInsetsPadding +import com.highcapable.betterandroid.ui.extension.component.startActivity +import com.highcapable.pangutext.demo.databinding.ActivityMainBinding +import com.highcapable.pangutext.demo.ui.base.BaseActivity + +class MainActivity : BaseActivity() { + + private val demoText = HtmlCompat.fromHtml( + "今天下午,我去了一家新开的咖啡店,店里环境非常舒适,感觉很cozy。" + + "我点了一杯latte,坐在窗边,透过玻璃看着街上的人来人往。店员还特别热情," + + "给我推荐了一款很特别的chocolate cake,味道真是不错!
" + + "我发现现在很多人都喜欢在咖啡店里工作,几乎每桌都有laptop。我的旁边有一位女士,正在忙着处理emails。" + + "我想,这样的环境真是适合集中精力工作。
" + + "总的来说,今天的体验很不错,下次还想再来尝试其他的drinksdesserts
" + + "合word样式测试。
" + + "You can点击这里访问项目地址。", + HtmlCompat.FROM_HTML_MODE_LEGACY + ) + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + binding.root.handleOnWindowInsetsChanged(animated = true) { linearLayout, insetsWrapper -> + linearLayout.setInsetsPadding(insetsWrapper.safeDrawing) + } + listOf( + binding.textViewPanguText, + binding.textViewPanguTextCjkSpacingRatio, + binding.textViewNoPanguText + ).forEach { + it.movementMethod = LinkMovementMethod.getInstance() + it.text = demoText + } + binding.buttonJumpList.setOnClickListener { + startActivity() + } + } +} \ No newline at end of file diff --git a/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/base/BaseActivity.kt b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/base/BaseActivity.kt new file mode 100644 index 0000000..bee2adc --- /dev/null +++ b/demo-android/src/main/java/com/highcapable/pangutext/demo/ui/base/BaseActivity.kt @@ -0,0 +1,37 @@ +/* + * PanguText - A typographic solution for the optimal alignment of CJK characters, English words, and half-width digits. + * Copyright (C) 2019 HighCapable + * https://github.com/BetterAndroid/PanguText + * + * Apache License Version 2.0 + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * This file is created by fankes on 2025/2/10. + */ +package com.highcapable.pangutext.demo.ui.base + +import android.os.Bundle +import android.view.LayoutInflater +import androidx.viewbinding.ViewBinding +import com.highcapable.betterandroid.ui.component.activity.AppBindingActivity +import com.highcapable.pangutext.android.factory.PanguTextFactory2 + +open class BaseActivity : AppBindingActivity() { + + override fun onPrepareContentView(savedInstanceState: Bundle?): LayoutInflater { + val inflater = super.onPrepareContentView(savedInstanceState) + PanguTextFactory2.inject(inflater) + return inflater + } +} \ No newline at end of file diff --git a/demo-android/src/main/res/drawable/ic_launcher_foreground.xml b/demo-android/src/main/res/drawable/ic_launcher_foreground.xml new file mode 100644 index 0000000..e42c27e --- /dev/null +++ b/demo-android/src/main/res/drawable/ic_launcher_foreground.xml @@ -0,0 +1,31 @@ + + + + + + + + \ No newline at end of file diff --git a/demo-android/src/main/res/layout/activity_list.xml b/demo-android/src/main/res/layout/activity_list.xml new file mode 100644 index 0000000..d7e4d4b --- /dev/null +++ b/demo-android/src/main/res/layout/activity_list.xml @@ -0,0 +1,21 @@ + + + + + + + \ No newline at end of file diff --git a/demo-android/src/main/res/layout/activity_main.xml b/demo-android/src/main/res/layout/activity_main.xml new file mode 100644 index 0000000..a334ff5 --- /dev/null +++ b/demo-android/src/main/res/layout/activity_main.xml @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +