diff --git a/.gitignore b/.gitignore
index dd9b4a657d47e0297233474fa8e219591e9da405..eeb9500641c774fb1f707fe9a7daad0b40864e4d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,54 +1,17 @@
-# Built application files
-*.apk
-*.ap_
-
-# Files for the Dalvik VM
-*.dex
-
-# Java class files
-*.class
-
-# Generated files
-bin/
-gen/
-
-# Gradle files
-.gradle/
-build/
-/*/build/
-
-
-# Local configuration file (sdk path, etc)
-local.properties
-
-# Proguard folder generated by Eclipse
-proguard/
-
-# Log Files
-*.log
-
-# Android Studio Navigation editor temp files
-.navigation/
-
-# Android Studio captures folder
-captures/
-
-
-# Crashlytics configuations
-com_crashlytics_export_strings.xml
-
-
-# Signing files
-.signing/
-
*.iml
-.idea
-
-# OS-specific files
+.gradle
+/local.properties
+/.idea/caches
+/.idea/libraries
+/.idea/modules.xml
+/.idea/workspace.xml
+/.idea/navEditor.xml
+/.idea/assetWizardSettings.xml
.DS_Store
-.DS_Store?
-._*
-.Spotlight-V100
-.Trashes
-ehthumbs.db
-Thumbs.db
\ No newline at end of file
+/build
+/captures
+.externalNativeBuild
+/entry/.preview
+.cxx
+upload.gradle
+/.idea/
diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index 7812812536b3ed1461348e55a8efad8756cd11d5..0000000000000000000000000000000000000000
--- a/.travis.yml
+++ /dev/null
@@ -1,24 +0,0 @@
-language: android
-jdk: oraclejdk8
-
-android:
- components:
- - tools
- - tools
- - platform-tools
- - build-tools-27.0.0
- - android-27
- - extra-android-m2repository
-
-before_cache:
- - rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
-
-cache:
- directories:
- - $HOME/.gradle/caches/
- - $HOME/.gradle/wrapper/
- - $HOME/.android/build-cache
-
-script:
- ./gradlew build
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000000000000000000000000000000000000..9b958e2f9b9385486660c85dbb78239da5aaf8e1
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,3 @@
+## 0.0.1-SNAPSHOT
+ohos 第一个版本,完整实现了原库的全部 api
+
diff --git a/README.OPENSOURCE b/README.OPENSOURCE
new file mode 100644
index 0000000000000000000000000000000000000000..dd6a6ef472d51a94d0476e4b6490af7fb7fd092e
--- /dev/null
+++ b/README.OPENSOURCE
@@ -0,0 +1,19 @@
+[
+
+ {
+
+ "Name": "ReadMoreTextView",
+
+ "License": "Apache License",
+
+ "License File": "LICENSE",
+
+ "Version Number": "2.1.0",
+
+ "Upstream URL": "https://github.com/bravoborja/ReadMoreTextView",
+
+ "Description": "A Custom TextView with trim text"
+
+ }
+
+]
\ No newline at end of file
diff --git a/README.md b/README.md
index 6a8bb92ace321dc95bffc6876a0d7382ec825e46..4e101bb00c0eb45be4d48e96eea80913e06e1dff 100644
--- a/README.md
+++ b/README.md
@@ -1,41 +1,79 @@
# ReadMoreTextView
-A Custom TextView with trim text
+## 项目介绍
-## Download
-To add the ReadMoreTextView library to your Android Studio project, simply add the following gradle dependency:
-```java
-compile 'com.borjabravo:readmoretextview:2.1.0'
-```
+- 项目名称: ReadMoreTextView
+- 所属系列: openharmony的第三方组件适配移植
+- 功能: 带有修剪文本的自定义文本视图
+- 项目移植状态: 主功能完成
+- 调用差异: 无
+- 开发版本: sdk6,DevEco Studio 2.2 Beta1
+- 基线版本:Releases 2.1.0
-## Usage
-To use the ReadMoreTextView on your app, add the following code to your layout:
+## 效果演示
+
-```xml
-
-```
-You can customize ReadMoreTextView with:
+## 安装教程
+1.在项目根目录下的build.gradle文件中,
+ ```
+allprojects {
+ repositories {
+ maven {
+ url 'https://s01.oss.sonatype.org/content/repositories/snapshots/'
+ }
+ }
+}
+ ```
-- app:trimExpandedText: Text that appears when the view is expanded.
-- app:trimCollapsedText: Text that appears when the view is collapsed.
-- app:trimLength: Trim length to determine when the clickable text is displayed.
-- app:showTrimExpandedText: Show the trim text if it's true.
-- app:colorClickableText: Text color of trim clickable text.
-- app:trimMode: Choose trim mode with two options: trimModeLength or trimModeLines.
+2.在entry模块的build.gradle文件中,
+ ```
+ dependencies {
+ implementation('com.gitee.chinasoft_ohos:ReadMoreTextView:0.0.1-SNAPSHOT')
+ ......
+ }
+```
+在sdk6,DevEco Studio 2.2 Beta1下项目可直接运行
+如无法运行,删除项目.gradle,.idea,build,gradle,build.gradle文件,
+并依据自己的版本创建新项目,将新项目的对应文件复制到根目录下
-## Screenshots
+## 使用说明
-
-
+1) 从XML布局文件创建:
+```
+ xmlns:app="http://schemas.huawei.com/hap/res-auto"
+
+```
+使用方法:
+```
+ ReadMoreTextView text1 = (ReadMoreTextView) findComponentById(ResourceTable.Id_text1);
+ text1.setContent(getString(ResourceTable.String_lorem_ipsum));
+```
-License
-=======
+## 测试信息
+CodeCheck代码测试无异常
+CloudTest代码测试无异常
+
+病毒安全检测通过
+
+当前版本demo功能与原组件基本无差异
+
+## 版本迭代
+- 0.0.1-SNAPSHOT
+
+## 版权和许可信息
+```
Copyright 2016 Borja Bravo
Licensed under the Apache License, Version 2.0 (the "License");
@@ -49,3 +87,4 @@ License
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.
+```
\ No newline at end of file
diff --git a/app/build.gradle b/app/build.gradle
deleted file mode 100644
index 7c556c1c664fadb666613df998ec0fb99c436b0e..0000000000000000000000000000000000000000
--- a/app/build.gradle
+++ /dev/null
@@ -1,32 +0,0 @@
-apply plugin: 'com.android.application'
-
-android {
- compileSdkVersion 27
- buildToolsVersion "27.0.0"
-
- defaultConfig {
- applicationId "com.borjabravo.readmoretextview"
- minSdkVersion 14
- targetSdkVersion 27
- versionCode 1
- versionName "1.0"
- }
-
- buildTypes {
- release {
- minifyEnabled false
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
- }
- }
-
- lintOptions {
- abortOnError false
- }
-}
-
-dependencies {
- implementation 'com.android.support:appcompat-v7:27.0.0'
- implementation 'com.android.support:design:27.0.0'
- implementation project(':readmoretextview')
- testImplementation 'junit:junit:4.12'
-}
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
deleted file mode 100644
index a37606829e07d04d598560933ed2839460958d4a..0000000000000000000000000000000000000000
--- a/app/proguard-rules.pro
+++ /dev/null
@@ -1,17 +0,0 @@
-# Add project specific ProGuard rules here.
-# By default, the flags in this file are appended to flags specified
-# in /Users/borja/Documents/android/adt-bundle-mac-x86_64-20140702/sdk/tools/proguard/proguard-android.txt
-# You can edit the include path and order by changing the proguardFiles
-# directive in build.gradle.
-#
-# For more details, see
-# http://developer.android.com/guide/developing/tools/proguard.html
-
-# Add any project specific keep options here:
-
-# 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 *;
-#}
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
deleted file mode 100644
index 24232d7e4122575e5c1fff11925f382bfe07a454..0000000000000000000000000000000000000000
--- a/app/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/app/src/main/java/com/borjabravo/readmoretextviewsample/MainActivity.java b/app/src/main/java/com/borjabravo/readmoretextviewsample/MainActivity.java
deleted file mode 100644
index 8f504996db772ad881075aa0e918f8689b26c724..0000000000000000000000000000000000000000
--- a/app/src/main/java/com/borjabravo/readmoretextviewsample/MainActivity.java
+++ /dev/null
@@ -1,22 +0,0 @@
-package com.borjabravo.readmoretextviewsample;
-
-import android.os.Bundle;
-import android.support.v7.app.AppCompatActivity;
-import android.widget.TextView;
-
-public class MainActivity extends AppCompatActivity {
-
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- TextView text1 = findViewById(R.id.text1);
- text1.setText(getString(R.string.lorem_ipsum));
- TextView text2 = findViewById(R.id.text2);
- text2.setText(getString(R.string.lorem_ipsum2));
- TextView text3 = findViewById(R.id.text3);
- text3.setText(getString(R.string.lorem_ipsum3));
- TextView text4 = findViewById(R.id.text4);
- text4.setText(getString(R.string.one_line_text));
- }
-}
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
deleted file mode 100644
index 01a64c6c95631fc61c86d2a7e11f5ed75296b5b6..0000000000000000000000000000000000000000
--- a/app/src/main/res/layout/activity_main.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/app/src/main/res/mipmap-hdpi/ic_launcher.png b/app/src/main/res/mipmap-hdpi/ic_launcher.png
deleted file mode 100644
index cde69bcccec65160d92116f20ffce4fce0b5245c..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-hdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png
deleted file mode 100644
index c133a0cbd379f5af6dbf1a899a0293ca5eccfad0..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-mdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/app/src/main/res/mipmap-xhdpi/ic_launcher.png
deleted file mode 100644
index bfa42f0e7b91d006d22352c9ff2f134e504e3c1d..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
deleted file mode 100644
index 324e72cdd7480cb983fa1bcc7ce686e51ef87fe7..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
deleted file mode 100644
index aee44e138434630332d88b1680f33c4b24c70ab3..0000000000000000000000000000000000000000
Binary files a/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and /dev/null differ
diff --git a/app/src/main/res/values-v21/styles.xml b/app/src/main/res/values-v21/styles.xml
deleted file mode 100644
index 251fb9fb74a79b9a0a7a571d09bc22ee119b0659..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-v21/styles.xml
+++ /dev/null
@@ -1,9 +0,0 @@
->
-
-
-
diff --git a/app/src/main/res/values-w820dp/dimens.xml b/app/src/main/res/values-w820dp/dimens.xml
deleted file mode 100644
index 63fc816444614bd64f68a372d1f93211628ee51d..0000000000000000000000000000000000000000
--- a/app/src/main/res/values-w820dp/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 64dp
-
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
deleted file mode 100644
index 3ab3e9cbce07f7cdc941fc8ba424c05e83ed80f0..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
deleted file mode 100644
index 812cb7be0a1565a849a29c08fa07fb9901ccb347..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/dimens.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- 16dp
- 16dp
- 16dp
-
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
deleted file mode 100644
index 23265b0fe9a32159aa0e6e49eb3770a55c2ccaa1..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,8 +0,0 @@
-
- ReadMoreTextViewSample
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis. Donec lacus ligula, commodo quis eleifend ac, rhoncus sed mi. Curabitur luctus justo vel consequat fermentum. Donec facilisis elit in sem suscipit pharetra. Curabitur porta et dolor eget pretium. Mauris quam augue, interdum nec tempor vitae, consectetur at erat.
- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis. Donec lacus ligula, commodo quis eleifend ac, rhoncus sed mi.
- Lorem ipsum dolor sit amet, consectetur adipiscing elit.Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis.
- Show all content
- One line text
-
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
deleted file mode 100644
index 545b9c6d2c45df7938f8ffd5ac2d806dec36f122..0000000000000000000000000000000000000000
--- a/app/src/main/res/values/styles.xml
+++ /dev/null
@@ -1,20 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/build.gradle b/build.gradle
index ea35e684fe71a7abb55bc134d665b820dee08e8f..3a41c328e590c35c56441837592a1f186768a759 100644
--- a/build.gradle
+++ b/build.gradle
@@ -1,21 +1,34 @@
+apply plugin: 'com.huawei.ohos.app'
+
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+}
+
buildscript {
repositories {
- jcenter()
- google()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
dependencies {
- classpath 'com.android.tools.build:gradle:3.0.0'
- classpath 'com.novoda:bintray-release:0.5.0'
+ classpath 'com.huawei.ohos:hap:2.4.5.0'
+ classpath 'com.huawei.ohos:decctest:1.2.4.1'
}
}
allprojects {
repositories {
- jcenter()
- google()
+ maven {
+ url 'https://repo.huaweicloud.com/repository/maven/'
+ }
+ maven {
+ url 'https://developer.huawei.com/repo/'
+ }
}
}
-
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
diff --git a/app/.gitignore b/entry/.gitignore
similarity index 100%
rename from app/.gitignore
rename to entry/.gitignore
diff --git a/entry/build.gradle b/entry/build.gradle
new file mode 100644
index 0000000000000000000000000000000000000000..ffc8ad033350391fb0e4464299f8a7778c326e75
--- /dev/null
+++ b/entry/build.gradle
@@ -0,0 +1,27 @@
+apply plugin: 'com.huawei.ohos.hap'
+apply plugin: 'com.huawei.ohos.decctest'
+ohos {
+ compileSdkVersion 6
+ defaultConfig {
+ compatibleSdkVersion 5
+ }
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
+ testImplementation 'junit:junit:4.13'
+ ohosTestImplementation 'com.huawei.ohos.testkit:runner:1.0.0.200'
+ implementation project(':readmoretextview')
+}
+decc {
+ supportType = ['html','xml']
+}
diff --git a/entry/src/main/config.json b/entry/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..73781ebf2d0022692bea40ef6a51258f249101f9
--- /dev/null
+++ b/entry/src/main/config.json
@@ -0,0 +1,54 @@
+{
+ "app": {
+ "bundleName": "com.borjabravo.readmoretextviewsample2",
+ "vendor": "borjabravo",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {},
+ "module": {
+ "package": "com.borjabravo.readmoretextviewsample",
+ "name": ".MyApplication",
+ "mainAbility": "com.borjabravo.readmoretextviewsample.MainAbility",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "entry",
+ "moduleType": "entry",
+ "installationFree": false
+ },
+ "abilities": [
+ {
+ "skills": [
+ {
+ "entities": [
+ "entity.system.home"
+ ],
+ "actions": [
+ "action.system.home"
+ ]
+ }
+ ],
+ "orientation": "unspecified",
+ "name": "com.borjabravo.readmoretextviewsample.MainAbility",
+ "icon": "$media:icon",
+ "metaData": {
+ "customizeData": [
+ {
+ "name": "hwc-theme",
+ "value": "androidhwext:style/Theme.Emui.Light.NoTitleBar"
+ }
+ ]
+ },
+ "description": "$string:mainability_description",
+ "label": "$string:name",
+ "type": "page",
+ "launchType": "standard"
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/entry/src/main/java/com/borjabravo/readmoretextviewsample/MainAbility.java b/entry/src/main/java/com/borjabravo/readmoretextviewsample/MainAbility.java
new file mode 100644
index 0000000000000000000000000000000000000000..102c238a6d3dfb71cb7eedbe6dac19fc85a21037
--- /dev/null
+++ b/entry/src/main/java/com/borjabravo/readmoretextviewsample/MainAbility.java
@@ -0,0 +1,17 @@
+package com.borjabravo.readmoretextviewsample;
+
+import com.borjabravo.readmoretextviewsample.slice.MainAbilitySlice;
+import ohos.aafwk.ability.Ability;
+import ohos.aafwk.content.Intent;
+import ohos.agp.utils.Color;
+import ohos.agp.window.service.WindowManager;
+
+public class MainAbility extends Ability {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setMainRoute(MainAbilitySlice.class.getName());
+ // 隐藏状态栏
+ WindowManager.getInstance().getTopWindow().get().setStatusBarColor(Color.WHITE.getValue()); // 设置状态栏颜色
+ }
+}
diff --git a/entry/src/main/java/com/borjabravo/readmoretextviewsample/MyApplication.java b/entry/src/main/java/com/borjabravo/readmoretextviewsample/MyApplication.java
new file mode 100644
index 0000000000000000000000000000000000000000..02f7ec17de16610eba18d5a73641ac99a79ba516
--- /dev/null
+++ b/entry/src/main/java/com/borjabravo/readmoretextviewsample/MyApplication.java
@@ -0,0 +1,24 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.
+ */
+package com.borjabravo.readmoretextviewsample;
+
+import ohos.aafwk.ability.AbilityPackage;
+
+public class MyApplication extends AbilityPackage {
+ @Override
+ public void onInitialize() {
+ super.onInitialize();
+ }
+}
diff --git a/entry/src/main/java/com/borjabravo/readmoretextviewsample/slice/MainAbilitySlice.java b/entry/src/main/java/com/borjabravo/readmoretextviewsample/slice/MainAbilitySlice.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3e0e8e9dcc5e15171638012ea7979c590daad2b
--- /dev/null
+++ b/entry/src/main/java/com/borjabravo/readmoretextviewsample/slice/MainAbilitySlice.java
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.
+ */
+package com.borjabravo.readmoretextviewsample.slice;
+
+import com.borjabravo.readmoretextview.ReadMoreTextView;
+import com.borjabravo.readmoretextviewsample.ResourceTable;
+import ohos.aafwk.ability.AbilitySlice;
+import ohos.aafwk.content.Intent;
+
+public class MainAbilitySlice extends AbilitySlice {
+ @Override
+ public void onStart(Intent intent) {
+ super.onStart(intent);
+ super.setUIContent(ResourceTable.Layout_ability_main);
+
+ ReadMoreTextView text1 = (ReadMoreTextView) findComponentById(ResourceTable.Id_text1);
+ text1.setContent(getString(ResourceTable.String_lorem_ipsum));
+
+ ReadMoreTextView text2 = (ReadMoreTextView) findComponentById(ResourceTable.Id_text2);
+ text2.setContent(getString(ResourceTable.String_lorem_ipsum2));
+
+ ReadMoreTextView text3 = (ReadMoreTextView) findComponentById(ResourceTable.Id_text3);
+ text3.setContent(getString(ResourceTable.String_lorem_ipsum3));
+
+ ReadMoreTextView text4 = (ReadMoreTextView) findComponentById(ResourceTable.Id_text4);
+ text4.setContent(getString(ResourceTable.String_one_line_text));
+
+ }
+
+ @Override
+ public void onActive() {
+ super.onActive();
+ }
+
+ @Override
+ public void onForeground(Intent intent) {
+ super.onForeground(intent);
+ }
+}
diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json
new file mode 100644
index 0000000000000000000000000000000000000000..fb69ebc0ac04f01039515bdac36d64d057812a55
--- /dev/null
+++ b/entry/src/main/resources/base/element/color.json
@@ -0,0 +1,40 @@
+{
+ "color": [
+ {
+ "name": "purple_progress",
+ "value": "#ffaa66cc"
+ },
+ {
+ "name": "green_complete",
+ "value": "#ff99cc00"
+ },
+ {
+ "name": "red_error",
+ "value": "#ffff4444"
+ },
+ {
+ "name": "blue_pressed",
+ "value": "#ff0099cc"
+ },
+ {
+ "name": "colorPrimary",
+ "value": "#008577"
+ },
+ {
+ "name": "holo_blue_bright",
+ "value": "#FF00DDFF"
+ },
+ {
+ "name": "holo_green_light",
+ "value": "#ff99cc00"
+ },
+ {
+ "name": "holo_orange_light",
+ "value": "#ffffbb33"
+ },
+ {
+ "name": "holo_red_light",
+ "value": "#ffff4444"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/element/string.json b/entry/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..d101630b09f8b2189e099ad34a508d1756f86946
--- /dev/null
+++ b/entry/src/main/resources/base/element/string.json
@@ -0,0 +1,52 @@
+{
+ "string": [
+ {
+ "name": "app_name",
+ "value": "MyApplication"
+ },
+ {
+ "name": "name",
+ "value": "ReadMoreTextView"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Phone_Empty Feature Ability"
+ },
+ {
+ "name": "HelloWorld",
+ "value": "Hello World"
+ },
+ {
+ "name": "main2abilityslice_description",
+ "value": "hap sample empty provider"
+ },
+ {
+ "name": "lorem_ipsum",
+ "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis. Donec lacus ligula, commodo quis eleifend ac, rhoncus sed mi. Curabitur luctus justo vel consequat fermentum. Donec facilisis elit in sem suscipit pharetra. Curabitur porta et dolor eget pretium. Mauris quam augue, interdum nec tempor vitae, consectetur at erat."
+ },
+ {
+ "name": "lorem_ipsum2",
+ "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis. Donec lacus ligula, commodo quis eleifend ac, rhoncus sed mi. "
+ },
+ {
+ "name": "lorem_ipsum3",
+ "value": "Lorem ipsum dolor sit amet, consectetur adipiscing elit.Cras feugiat, nunc eget volutpat viverra, lacus ligula venenatis nulla, in accumsan eros eros nec ipsum. Fusce eget massa id lorem blandit lobortis."
+ },
+ {
+ "name": "one_line_text",
+ "value": "One line text"
+ },
+ {
+ "name": "show_all_content",
+ "value": "Show all content"
+ },
+ {
+ "name": "read_more",
+ "value": "show more"
+ },
+ {
+ "name": "show_less",
+ "value": "show less"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/main/resources/base/graphic/background_ability_main.xml b/entry/src/main/resources/base/graphic/background_ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..c0c0a3df480fa387a452b9c40ca191cc918a3fc0
--- /dev/null
+++ b/entry/src/main/resources/base/graphic/background_ability_main.xml
@@ -0,0 +1,6 @@
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml
new file mode 100644
index 0000000000000000000000000000000000000000..032038257513520ee50d0fd26a3ae8dbcf160782
--- /dev/null
+++ b/entry/src/main/resources/base/layout/ability_main.xml
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/entry/src/main/resources/base/media/icon.png b/entry/src/main/resources/base/media/icon.png
new file mode 100644
index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c
Binary files /dev/null and b/entry/src/main/resources/base/media/icon.png differ
diff --git a/entry/src/main/resources/en/element/string.json b/entry/src/main/resources/en/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..bcf9f99db439d496a88899a967191af5e7407e15
--- /dev/null
+++ b/entry/src/main/resources/en/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "Hello World"
+ }
+ ]
+}
diff --git a/entry/src/main/resources/zh/element/string.json b/entry/src/main/resources/zh/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..fdc4bd140b689dfcb287ba35be2d478105f47f72
--- /dev/null
+++ b/entry/src/main/resources/zh/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "entry_MainAbility",
+ "value": "entry_MainAbility"
+ },
+ {
+ "name": "mainability_description",
+ "value": "Java_Empty Ability"
+ },
+ {
+ "name": "mainability_HelloWorld",
+ "value": "你好,世界"
+ }
+ ]
+}
\ No newline at end of file
diff --git a/entry/src/ohosTest/java/com/borjabravo/readmoretextviewsample/ExampleOhosTest.java b/entry/src/ohosTest/java/com/borjabravo/readmoretextviewsample/ExampleOhosTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..c0cb34e376cae62d2d56c767a39961e50900c1c3
--- /dev/null
+++ b/entry/src/ohosTest/java/com/borjabravo/readmoretextviewsample/ExampleOhosTest.java
@@ -0,0 +1,15 @@
+package com.borjabravo.readmoretextviewsample;
+
+import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ExampleOhosTest {
+ // UI组件,不涉及单元测试
+ @Test
+ public void testBundleName() {
+ final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
+ assertEquals("com.borjabravo.readmoretextviewsample", actualBundleName);
+ }
+}
\ No newline at end of file
diff --git a/entry/src/test/java/com/borjabravo/readmoretextviewsample/ExampleTest.java b/entry/src/test/java/com/borjabravo/readmoretextviewsample/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..3949bed05d6b6d42c0ceb3183c6a14a9745b2213
--- /dev/null
+++ b/entry/src/test/java/com/borjabravo/readmoretextviewsample/ExampleTest.java
@@ -0,0 +1,10 @@
+package com.borjabravo.readmoretextviewsample;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ // UI组件,不涉及单元测试
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/gradle.properties b/gradle.properties
deleted file mode 100644
index 1d3591c8a4c9c29578c36c87f80c05a6aea3ee3f..0000000000000000000000000000000000000000
--- a/gradle.properties
+++ /dev/null
@@ -1,18 +0,0 @@
-# Project-wide Gradle settings.
-
-# IDE (e.g. Android Studio) users:
-# Gradle settings configured through the IDE *will override*
-# any settings specified in this file.
-
-# For more details on how to configure your build environment visit
-# http://www.gradle.org/docs/current/userguide/build_environment.html
-
-# Specifies the JVM arguments used for the daemon process.
-# The setting is particularly useful for tweaking memory settings.
-# Default value: -Xmx10248m -XX:MaxPermSize=256m
-# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
-
-# When configured, Gradle will run in incubating parallel mode.
-# This option should only be used with decoupled projects. More details, visit
-# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
-# org.gradle.parallel=true
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar
index 05ef575b0cd0173fc735f2857ce4bd594ce4f6bd..490fda8577df6c95960ba7077c43220e5bb2c0d9 100644
Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index b692f5e2b2a2aac61c65e3a567a79908f0fa7233..f59159e865d4b59feb1b8c44b001f62fc5d58df4 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,6 +1,5 @@
-#Sun Nov 12 12:19:18 CET 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
+distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-6.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
diff --git a/gradlew b/gradlew
deleted file mode 100755
index 9d82f78915133e1c35a6ea51252590fb38efac2f..0000000000000000000000000000000000000000
--- a/gradlew
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env bash
-
-##############################################################################
-##
-## Gradle start up script for UN*X
-##
-##############################################################################
-
-# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-DEFAULT_JVM_OPTS=""
-
-APP_NAME="Gradle"
-APP_BASE_NAME=`basename "$0"`
-
-# Use the maximum available, or set MAX_FD != -1 to use that value.
-MAX_FD="maximum"
-
-warn ( ) {
- echo "$*"
-}
-
-die ( ) {
- echo
- echo "$*"
- echo
- exit 1
-}
-
-# OS specific support (must be 'true' or 'false').
-cygwin=false
-msys=false
-darwin=false
-case "`uname`" in
- CYGWIN* )
- cygwin=true
- ;;
- Darwin* )
- darwin=true
- ;;
- MINGW* )
- msys=true
- ;;
-esac
-
-# Attempt to set APP_HOME
-# Resolve links: $0 may be a link
-PRG="$0"
-# Need this for relative symlinks.
-while [ -h "$PRG" ] ; do
- ls=`ls -ld "$PRG"`
- link=`expr "$ls" : '.*-> \(.*\)$'`
- if expr "$link" : '/.*' > /dev/null; then
- PRG="$link"
- else
- PRG=`dirname "$PRG"`"/$link"
- fi
-done
-SAVED="`pwd`"
-cd "`dirname \"$PRG\"`/" >/dev/null
-APP_HOME="`pwd -P`"
-cd "$SAVED" >/dev/null
-
-CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
-
-# Determine the Java command to use to start the JVM.
-if [ -n "$JAVA_HOME" ] ; then
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
- # IBM's JDK on AIX uses strange locations for the executables
- JAVACMD="$JAVA_HOME/jre/sh/java"
- else
- JAVACMD="$JAVA_HOME/bin/java"
- fi
- if [ ! -x "$JAVACMD" ] ; then
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
- fi
-else
- JAVACMD="java"
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-
-Please set the JAVA_HOME variable in your environment to match the
-location of your Java installation."
-fi
-
-# Increase the maximum file descriptors if we can.
-if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
- MAX_FD_LIMIT=`ulimit -H -n`
- if [ $? -eq 0 ] ; then
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
- MAX_FD="$MAX_FD_LIMIT"
- fi
- ulimit -n $MAX_FD
- if [ $? -ne 0 ] ; then
- warn "Could not set maximum file descriptor limit: $MAX_FD"
- fi
- else
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
- fi
-fi
-
-# For Darwin, add options to specify how the application appears in the dock
-if $darwin; then
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
-fi
-
-# For Cygwin, switch paths to Windows format before running java
-if $cygwin ; then
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
- JAVACMD=`cygpath --unix "$JAVACMD"`
-
- # We build the pattern for arguments to be converted via cygpath
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
- SEP=""
- for dir in $ROOTDIRSRAW ; do
- ROOTDIRS="$ROOTDIRS$SEP$dir"
- SEP="|"
- done
- OURCYGPATTERN="(^($ROOTDIRS))"
- # Add a user-defined pattern to the cygpath arguments
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
- fi
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
- i=0
- for arg in "$@" ; do
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
-
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
- else
- eval `echo args$i`="\"$arg\""
- fi
- i=$((i+1))
- done
- case $i in
- (0) set -- ;;
- (1) set -- "$args0" ;;
- (2) set -- "$args0" "$args1" ;;
- (3) set -- "$args0" "$args1" "$args2" ;;
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
- esac
-fi
-
-# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
-function splitJvmOpts() {
- JVM_OPTS=("$@")
-}
-eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
-JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
-
-exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
diff --git a/gradlew.bat b/gradlew.bat
deleted file mode 100644
index aec99730b4e8fcd90b57a0e8e01544fea7c31a89..0000000000000000000000000000000000000000
--- a/gradlew.bat
+++ /dev/null
@@ -1,90 +0,0 @@
-@if "%DEBUG%" == "" @echo off
-@rem ##########################################################################
-@rem
-@rem Gradle startup script for Windows
-@rem
-@rem ##########################################################################
-
-@rem Set local scope for the variables with windows NT shell
-if "%OS%"=="Windows_NT" setlocal
-
-@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
-set DEFAULT_JVM_OPTS=
-
-set DIRNAME=%~dp0
-if "%DIRNAME%" == "" set DIRNAME=.
-set APP_BASE_NAME=%~n0
-set APP_HOME=%DIRNAME%
-
-@rem Find java.exe
-if defined JAVA_HOME goto findJavaFromJavaHome
-
-set JAVA_EXE=java.exe
-%JAVA_EXE% -version >NUL 2>&1
-if "%ERRORLEVEL%" == "0" goto init
-
-echo.
-echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:findJavaFromJavaHome
-set JAVA_HOME=%JAVA_HOME:"=%
-set JAVA_EXE=%JAVA_HOME%/bin/java.exe
-
-if exist "%JAVA_EXE%" goto init
-
-echo.
-echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
-echo.
-echo Please set the JAVA_HOME variable in your environment to match the
-echo location of your Java installation.
-
-goto fail
-
-:init
-@rem Get command-line arguments, handling Windowz variants
-
-if not "%OS%" == "Windows_NT" goto win9xME_args
-if "%@eval[2+2]" == "4" goto 4NT_args
-
-:win9xME_args
-@rem Slurp the command line arguments.
-set CMD_LINE_ARGS=
-set _SKIP=2
-
-:win9xME_args_slurp
-if "x%~1" == "x" goto execute
-
-set CMD_LINE_ARGS=%*
-goto execute
-
-:4NT_args
-@rem Get arguments from the 4NT Shell from JP Software
-set CMD_LINE_ARGS=%$
-
-:execute
-@rem Setup the command line
-
-set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
-
-@rem Execute Gradle
-"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
-
-:end
-@rem End local scope for the variables with windows NT shell
-if "%ERRORLEVEL%"=="0" goto mainEnd
-
-:fail
-rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
-rem the _cmd.exe /c_ return code!
-if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
-exit /b 1
-
-:mainEnd
-if "%OS%"=="Windows_NT" endlocal
-
-:omega
diff --git a/img/demo1.gif b/img/demo1.gif
new file mode 100644
index 0000000000000000000000000000000000000000..cc986dbf7b319ae59aca5ea9d31c34d591e493e3
Binary files /dev/null and b/img/demo1.gif differ
diff --git a/readmoretextview/build.gradle b/readmoretextview/build.gradle
index 1fefb5e16d2a17609f677362422ec08b1bf0364c..09e9f30de24628b6ea4dd241329a4a2ddbb80d81 100644
--- a/readmoretextview/build.gradle
+++ b/readmoretextview/build.gradle
@@ -1,33 +1,22 @@
-apply plugin: 'com.android.library'
-apply plugin: 'com.novoda.bintray-release'
-
-publish {
- userOrg = 'bravoborja'
- groupId = 'com.borjabravo'
- uploadName = 'ReadMoreTextView'
- artifactId = 'readmoretextview'
- publishVersion = '2.1.0'
- desc = 'A Custom TextView with trim text'
- website = 'https://github.com/bravoborja/ReadMoreTextView'
-}
-
-android {
- compileSdkVersion 27
- buildToolsVersion '27.0.0'
+apply plugin: 'com.huawei.ohos.library'
+ohos {
+ compileSdkVersion 6
defaultConfig {
- minSdkVersion 14
- targetSdkVersion 27
- versionCode 1
- versionName "1.0"
+ compatibleSdkVersion 5
}
-
- lintOptions {
- abortOnError false
+ buildTypes {
+ release {
+ proguardOpt {
+ proguardEnabled false
+ rulesFiles 'proguard-rules.pro'
+ }
+ }
}
+
}
dependencies {
- implementation 'com.android.support:support-compat:27.0.0'
- testImplementation 'junit:junit:4.12'
-}
\ No newline at end of file
+ implementation fileTree(dir: 'libs', include: ['*.jar'])
+ testImplementation 'junit:junit:4.13'
+}
diff --git a/readmoretextview/src/main/AndroidManifest.xml b/readmoretextview/src/main/AndroidManifest.xml
deleted file mode 100644
index b486e1d3e15d4a50b46c188c11b62b8634ec7fa9..0000000000000000000000000000000000000000
--- a/readmoretextview/src/main/AndroidManifest.xml
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/readmoretextview/src/main/config.json b/readmoretextview/src/main/config.json
new file mode 100644
index 0000000000000000000000000000000000000000..262ba05edbbc66f14370cea266c8d1a2acb75e6a
--- /dev/null
+++ b/readmoretextview/src/main/config.json
@@ -0,0 +1,23 @@
+{
+ "app": {
+ "bundleName": "com.borjabravo.readmoretextviewsample",
+ "vendor": "borjabravo",
+ "version": {
+ "code": 1000000,
+ "name": "1.0.0"
+ }
+ },
+ "deviceConfig": {
+ },
+ "module": {
+ "package": "com.borjabravo.readmoretextview",
+ "deviceType": [
+ "phone"
+ ],
+ "distro": {
+ "deliveryWithInstall": true,
+ "moduleName": "readmoretextview",
+ "moduleType": "har"
+ }
+ }
+}
\ No newline at end of file
diff --git a/readmoretextview/src/main/java/com/borjabravo/readmoretextview/ReadMoreTextView.java b/readmoretextview/src/main/java/com/borjabravo/readmoretextview/ReadMoreTextView.java
index f56015112322c743e76fd1e82bf87825ab0598c2..cd610c355b9f0e846159c20be0db6e036c8f2f4c 100644
--- a/readmoretextview/src/main/java/com/borjabravo/readmoretextview/ReadMoreTextView.java
+++ b/readmoretextview/src/main/java/com/borjabravo/readmoretextview/ReadMoreTextView.java
@@ -15,211 +15,146 @@
*/
package com.borjabravo.readmoretextview;
-import android.content.Context;
-import android.content.res.TypedArray;
-import android.graphics.Color;
-import android.os.Build;
-import android.support.v4.content.ContextCompat;
-import android.text.SpannableStringBuilder;
-import android.text.Spanned;
-import android.text.TextPaint;
-import android.text.method.LinkMovementMethod;
-import android.text.style.ClickableSpan;
-import android.util.AttributeSet;
-import android.view.View;
-import android.view.ViewTreeObserver;
-import android.widget.TextView;
+import ohos.agp.components.AttrSet;
+import ohos.agp.components.Text;
+import ohos.agp.text.RichTextBuilder;
+import ohos.agp.text.TextForm;
+import ohos.agp.utils.Color;
+import ohos.app.Context;
+
+public class ReadMoreTextView extends Text {
+ private static final int DEFAULT_LENGTH_MAX = 92;
+
+ private boolean mIsShowMore = false;
+ private String mContent;
+ private String mTextLess;
+ private String mTextMore;
+ private int mColorLess = -1;
+ private int mColorMore = -1;
+ private int mContentColor = -1;
+ private int mContentLength = -1;
+ private int mContentSize = -1;
-public class ReadMoreTextView extends TextView {
-
- private static final int TRIM_MODE_LINES = 0;
- private static final int TRIM_MODE_LENGTH = 1;
- private static final int DEFAULT_TRIM_LENGTH = 240;
- private static final int DEFAULT_TRIM_LINES = 2;
- private static final int INVALID_END_INDEX = -1;
- private static final boolean DEFAULT_SHOW_TRIM_EXPANDED_TEXT = true;
- private static final String ELLIPSIZE = "... ";
-
- private CharSequence text;
- private BufferType bufferType;
- private boolean readMore = true;
- private int trimLength;
- private CharSequence trimCollapsedText;
- private CharSequence trimExpandedText;
- private ReadMoreClickableSpan viewMoreSpan;
- private int colorClickableText;
- private boolean showTrimExpandedText;
-
- private int trimMode;
- private int lineEndIndex;
- private int trimLines;
public ReadMoreTextView(Context context) {
- this(context, null);
+ super(context);
+ init();
}
- public ReadMoreTextView(Context context, AttributeSet attrs) {
+ public ReadMoreTextView(Context context, AttrSet attrs) {
super(context, attrs);
- TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ReadMoreTextView);
- this.trimLength = typedArray.getInt(R.styleable.ReadMoreTextView_trimLength, DEFAULT_TRIM_LENGTH);
- int resourceIdTrimCollapsedText =
- typedArray.getResourceId(R.styleable.ReadMoreTextView_trimCollapsedText, R.string.read_more);
- int resourceIdTrimExpandedText =
- typedArray.getResourceId(R.styleable.ReadMoreTextView_trimExpandedText, R.string.read_less);
- this.trimCollapsedText = getResources().getString(resourceIdTrimCollapsedText);
- this.trimExpandedText = getResources().getString(resourceIdTrimExpandedText);
- this.trimLines = typedArray.getInt(R.styleable.ReadMoreTextView_trimLines, DEFAULT_TRIM_LINES);
- this.colorClickableText = typedArray.getColor(R.styleable.ReadMoreTextView_colorClickableText,
- ContextCompat.getColor(context, R.color.accent));
- this.showTrimExpandedText =
- typedArray.getBoolean(R.styleable.ReadMoreTextView_showTrimExpandedText, DEFAULT_SHOW_TRIM_EXPANDED_TEXT);
- this.trimMode = typedArray.getInt(R.styleable.ReadMoreTextView_trimMode, TRIM_MODE_LINES);
- typedArray.recycle();
- viewMoreSpan = new ReadMoreClickableSpan();
- onGlobalLayoutLineEndIndex();
- setText();
- }
-
- private void setText() {
- super.setText(getDisplayableText(), bufferType);
- setMovementMethod(LinkMovementMethod.getInstance());
- setHighlightColor(Color.TRANSPARENT);
- }
-
- private CharSequence getDisplayableText() {
- return getTrimmedText(text);
- }
-
- @Override
- public void setText(CharSequence text, BufferType type) {
- this.text = text;
- bufferType = type;
- setText();
- }
+ if (attrs.getAttr("text_less").isPresent()) {
+ mTextLess = attrs.getAttr("text_less").get().getStringValue();
+ } else {
- private CharSequence getTrimmedText(CharSequence text) {
- if (trimMode == TRIM_MODE_LENGTH) {
- if (text != null && text.length() > trimLength) {
- if (readMore) {
- return updateCollapsedText();
- } else {
- return updateExpandedText();
- }
- }
}
- if (trimMode == TRIM_MODE_LINES) {
- if (text != null && lineEndIndex > 0) {
- if (readMore) {
- if (getLayout().getLineCount() > trimLines) {
- return updateCollapsedText();
- }
- } else {
- return updateExpandedText();
- }
- }
+ if (attrs.getAttr("text_more").isPresent()) {
+ mTextMore = attrs.getAttr("text_more").get().getStringValue();
}
- return text;
- }
+ if (attrs.getAttr("color_less").isPresent()) {
+ mColorLess = attrs.getAttr("color_less").get().getColorValue().getValue();
+ } else {
- private CharSequence updateCollapsedText() {
- int trimEndIndex = text.length();
- switch (trimMode) {
- case TRIM_MODE_LINES:
- trimEndIndex = lineEndIndex - (ELLIPSIZE.length() + trimCollapsedText.length() + 1);
- if (trimEndIndex < 0) {
- trimEndIndex = trimLength + 1;
- }
- break;
- case TRIM_MODE_LENGTH:
- trimEndIndex = trimLength + 1;
- break;
- }
- SpannableStringBuilder s = new SpannableStringBuilder(text, 0, trimEndIndex)
- .append(ELLIPSIZE)
- .append(trimCollapsedText);
- return addClickableSpan(s, trimCollapsedText);
- }
-
- private CharSequence updateExpandedText() {
- if (showTrimExpandedText) {
- SpannableStringBuilder s = new SpannableStringBuilder(text, 0, text.length()).append(trimExpandedText);
- return addClickableSpan(s, trimExpandedText);
}
- return text;
- }
-
- private CharSequence addClickableSpan(SpannableStringBuilder s, CharSequence trimText) {
- s.setSpan(viewMoreSpan, s.length() - trimText.length(), s.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
- return s;
- }
-
- public void setTrimLength(int trimLength) {
- this.trimLength = trimLength;
- setText();
- }
-
- public void setColorClickableText(int colorClickableText) {
- this.colorClickableText = colorClickableText;
- }
-
- public void setTrimCollapsedText(CharSequence trimCollapsedText) {
- this.trimCollapsedText = trimCollapsedText;
- }
-
- public void setTrimExpandedText(CharSequence trimExpandedText) {
- this.trimExpandedText = trimExpandedText;
+ if (attrs.getAttr("color_more").isPresent()) {
+ mColorMore = attrs.getAttr("color_more").get().getColorValue().getValue();
+ }
+ if (attrs.getAttr("content_color").isPresent()) {
+ mContentColor = attrs.getAttr("content_color").get().getColorValue().getValue();
+ }
+ if (attrs.getAttr("content_max_length").isPresent()) {
+ mContentLength = attrs.getAttr("content_max_length").get().getIntegerValue();
+ }
+ if (attrs.getAttr("content_size").isPresent()) {
+ mContentSize = attrs.getAttr("content_size").get().getIntegerValue();
+ }
+ init();
}
- public void setTrimMode(int trimMode) {
- this.trimMode = trimMode;
+ public ReadMoreTextView(Context context, AttrSet attrSet, String styleName) {
+ super(context, attrSet, styleName);
+ init();
}
- public void setTrimLines(int trimLines) {
- this.trimLines = trimLines;
- }
+ private void init() {
+ setMultipleLine(true);
+ if (Utils.isEmpty(mTextLess)) {
- private class ReadMoreClickableSpan extends ClickableSpan {
- @Override
- public void onClick(View widget) {
- readMore = !readMore;
- setText();
+ } else {
+ mTextLess = getContext().getString(ResourceTable.String_read_less);
}
-
- @Override
- public void updateDrawState(TextPaint ds) {
- ds.setColor(colorClickableText);
+ if (Utils.isEmpty(mTextMore)) {
+ mTextMore = getContext().getString(ResourceTable.String_read_more);
+ }
+ if (mColorLess == -1) {
+ mColorLess = Color.BLUE.getValue();
+ }
+ if (mColorMore == -1) {
+ mColorMore = Color.RED.getValue();
+ }
+ if (mContentColor == -1) {
+ mContentColor = Color.getIntColor("#99000000");
+ }
+ if (mContentLength == -1) {
+ mContentLength = DEFAULT_LENGTH_MAX;
+ }
+ if (mContentSize == -1) {
+ mContentSize = getTextSize();
}
}
- private void onGlobalLayoutLineEndIndex() {
- if (trimMode == TRIM_MODE_LINES) {
- getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
- @Override
- public void onGlobalLayout() {
- ViewTreeObserver obs = getViewTreeObserver();
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
- obs.removeOnGlobalLayoutListener(this);
- } else {
- obs.removeGlobalOnLayoutListener(this);
- }
- refreshLineEndIndex();
- setText();
- }
- });
+ /**
+ * setContent
+ *
+ * @param text text
+ */
+ public void setContent(String text) {
+ mContent = text;
+ if (text.length() > mContentLength) {
+ mIsShowMore = true;
+ changeTextStyle();
+ } else {
+ setText(text);
+ setTextSize(mContentSize);
}
}
- private void refreshLineEndIndex() {
- try {
- if (trimLines == 0) {
- lineEndIndex = getLayout().getLineEnd(0);
- } else if (trimLines > 0 && getLineCount() >= trimLines) {
- lineEndIndex = getLayout().getLineEnd(trimLines - 1);
+ private void changeTextStyle() {
+ RichTextBuilder builder = new RichTextBuilder();
+ String content;
+ String tail;
+ int color;
+ if (mIsShowMore) {
+ if (mContent.length() > mContentLength) {
+ content = mContent.substring(0, mContentLength) + "...";
} else {
- lineEndIndex = INVALID_END_INDEX;
+ content = mContent;
}
- } catch (Exception e) {
- e.printStackTrace();
+ tail = mTextMore;
+ color = mColorMore;
+ } else {
+ content = mContent;
+ tail = mTextLess;
+ color = mColorLess;
}
+ TextForm contentForm = new TextForm();
+ contentForm.setTextColor(mContentColor);
+ contentForm.setTextSize(mContentSize);
+ builder.mergeForm(contentForm);
+ builder.addText(content);
+ TextForm tailForm = new TextForm();
+ tailForm.setTextColor(color);
+ tailForm.setTextSize(mContentSize);
+ builder.mergeForm(tailForm);
+ builder.addText(tail);
+ setRichText(builder.build());
+ setClickedListener(component -> {
+ setIClickedListener();
+ });
+ }
+
+ private void setIClickedListener() {
+ mIsShowMore = !mIsShowMore;
+ changeTextStyle();
}
}
diff --git a/readmoretextview/src/main/java/com/borjabravo/readmoretextview/Utils.java b/readmoretextview/src/main/java/com/borjabravo/readmoretextview/Utils.java
new file mode 100644
index 0000000000000000000000000000000000000000..dc4d9dcbdbd41227db82a284b0fcb478de81c462
--- /dev/null
+++ b/readmoretextview/src/main/java/com/borjabravo/readmoretextview/Utils.java
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2021 Huawei Device Co., Ltd.
+ * 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.
+ */
+package com.borjabravo.readmoretextview;
+
+import ohos.app.Context;
+
+import java.util.logging.Logger;
+
+public class Utils {
+ /**
+ * isEmpty
+ *
+ * @param content content
+ * @return isEmpty
+ */
+ public static boolean isEmpty(String content) {
+ return content == null || "".equals(content);
+ }
+
+ /**
+ * px2vp
+ *
+ * @param context context
+ * @param pxValue pxValue
+ * @return int
+ */
+ public static int px2vp(Context context, final float pxValue) {
+ final float scale = context.getResourceManager().getDeviceCapability().screenDensity;
+ return (int) (pxValue / scale + 0.5f);
+ }
+
+ /**
+ * vp2px
+ *
+ * @param context context
+ * @param dpValue dpValue
+ * @return int
+ */
+ public static int vp2px(Context context, final float dpValue) {
+ final float scale = context.getResourceManager().getDeviceCapability().screenDensity;
+ return (int) (dpValue * scale + 0.5f);
+ }
+
+ /**
+ * log
+ *
+ * @param msg msg
+ */
+ public static void log(String msg) {
+ Logger.getGlobal().info("jwen====" + msg);
+ }
+}
diff --git a/readmoretextview/src/main/res/values/attrs.xml b/readmoretextview/src/main/res/values/attrs.xml
deleted file mode 100644
index 54da4a8dc4390f4a2297f37f861c9b26d7a8a9d9..0000000000000000000000000000000000000000
--- a/readmoretextview/src/main/res/values/attrs.xml
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/readmoretextview/src/main/res/values/colors.xml b/readmoretextview/src/main/res/values/colors.xml
deleted file mode 100644
index 4fa043711ff008d48c932d0b28a355bd69d6f98c..0000000000000000000000000000000000000000
--- a/readmoretextview/src/main/res/values/colors.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
- #3F51B5
- #303F9F
- #FF4081
-
diff --git a/readmoretextview/src/main/res/values/strings.xml b/readmoretextview/src/main/res/values/strings.xml
deleted file mode 100644
index d53ca1ca3b5d02fd4f252bbaac1eb6828d375409..0000000000000000000000000000000000000000
--- a/readmoretextview/src/main/res/values/strings.xml
+++ /dev/null
@@ -1,4 +0,0 @@
-
- show more
- show less
-
diff --git a/readmoretextview/src/main/resources/base/element/string.json b/readmoretextview/src/main/resources/base/element/string.json
new file mode 100644
index 0000000000000000000000000000000000000000..b14042a7da24c260b9725b68245151ddf804f271
--- /dev/null
+++ b/readmoretextview/src/main/resources/base/element/string.json
@@ -0,0 +1,16 @@
+{
+ "string": [
+ {
+ "name": "readmoretextview_library",
+ "value": "readmoretextview_library"
+ },
+ {
+ "name": "read_more",
+ "value": "show more"
+ },
+ {
+ "name": "read_less",
+ "value": "show less"
+ }
+ ]
+}
diff --git a/readmoretextview/src/test/java/com/borjabravo/readmoretextview/ExampleTest.java b/readmoretextview/src/test/java/com/borjabravo/readmoretextview/ExampleTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..621a2d8678b4d4125bc0c883050aaf0768e4b679
--- /dev/null
+++ b/readmoretextview/src/test/java/com/borjabravo/readmoretextview/ExampleTest.java
@@ -0,0 +1,9 @@
+package com.borjabravo.readmoretextview;
+
+import org.junit.Test;
+
+public class ExampleTest {
+ @Test
+ public void onStart() {
+ }
+}
diff --git a/screenshots/collapsed.png b/screenshots/collapsed.png
deleted file mode 100644
index dbe376ad8a66a4f6d4c14931612c63d0451d8909..0000000000000000000000000000000000000000
Binary files a/screenshots/collapsed.png and /dev/null differ
diff --git a/screenshots/expanded.png b/screenshots/expanded.png
deleted file mode 100644
index 10b11cc3f71ffaeb547a6ea963eacf9bf8ce368b..0000000000000000000000000000000000000000
Binary files a/screenshots/expanded.png and /dev/null differ
diff --git a/settings.gradle b/settings.gradle
index 2952017cb9e9e14f737f274e46a0f3aa9b42fb3c..0fcd4745621e5df0f30a47e995e1709484e1ea10 100644
--- a/settings.gradle
+++ b/settings.gradle
@@ -1 +1 @@
-include ':app', ':readmoretextview'
+include ':entry', ':readmoretextview'