update .gitignore

Signed-off-by: Y7000p <xcl@xuegao-tzx.top>
This commit is contained in:
田梓萱 2022-05-17 13:08:10 +08:00
parent cbbfa39c0b
commit bd880de720
86 changed files with 4328 additions and 0 deletions

17
.gitignore vendored Normal file
View File

@ -0,0 +1,17 @@
*.iml
/.gradle
/local.properties
/.idea
/key
/material
/supersearch/build
/entry/build
/supersearch/upload.gradle
/supersearch/gradle.properties
.DS_Store
/build
/captures
.externalNativeBuild
/entry/.preview
.cxx
/node_modules

319
README.md Normal file
View File

@ -0,0 +1,319 @@
## SuperSearch
### 项目介绍
一个开源的ohos Java 库,旨在简化多终端搜索相关功能的实现。
### 功能列表
1. 支持模糊匹配以及精确匹配
2. 支持开启、关闭搜索记录
3. 自带搜索算法
4. 支持超多功能自定义
5. 代码高可扩展性
6. 支持多设备使用
7. 支持开箱即用
### 安装教程
- 方法一:
使用前需先导入SuperSearch依赖并在所对应的模块build.gradle中添加依赖
```groovy
allprojects {
repositories {
mavenCentral()
}
}
...
dependencies {
...
implementation 'top.xuegao-tzx:SuperSearch:1.2.3.517'
...
}
```
- 方式二:
1. 下载模块代码添加到自己的工程
2. 关联使用
```
dependencies {
implementation project(":supersearch")
……
}
```
### 使用说明
#### - 添加SuperSearch
##### 1. 加载动画(一个加载中的圆圈)
```xml
<!--示例-->
<com.xcl.supersearch.RoundProgressBar
ohos:id="$id:progressBar"
ohos:height="40vp"
ohos:width="40vp"
ohos:center_in_parent="true"
ohos:visibility="hide"
app:round_progress_color="#FF82F8EF"
app:round_progress_with="5f"
/>
<!--圆的颜色-->
app:round_progress_color="#FF82F8EF"
<!--圆的粗细-->
app:round_progress_with="5f"
```
##### 2. 搜索框
###### 通过 XML 进行定制
```xml
<!--示例-->
<com.xcl.supersearch.SearchView
ohos:id="$+id:searchView"
ohos:height="match_parent"
ohos:left_padding="15vp"
ohos:right_padding="15vp"
ohos:visibility="visible"
ohos:width="match_parent"
ohos:padding="5vp"
app:search_history="$media:ic_history_black_24dp"
app:delete_search_history="$media:ic_close_black_24dp"
app:isDebugEnabled="true"
app:nullWarnByMySelf="true"
app:null_warn_text="$string:search_input_null"
app:null_warn_text_color="#79FF006E"
app:noneWarnByMySelf="true"
app:none_warn_text="$string:search_answer_none"
app:none_warn_text_color="#5CFF0000"
app:suggestion_count="6"
app:queryInput_hint_text="$string:search_hint_text"
app:background_mask_degree="0.35f"
app:queryRadius="5vp"
app:rightButton_Clear="$graphic:ic_close"
app:isrightButton_ClearEnabled="true"
app:leftButton_Back="$graphic:ic_arrow_left"
app:leftButton_Loadding_color="#FF1300FF"
app:queryInput_background_color="#FFF8F3EC"
app:queryInput_buttom_color="#A18770B1"
app:queryInput_cursor_color="#FF8377FF"
app:queryInput_hint_color="#FFFF0000"
app:queryInput_text_color="#FF6B16FF"
/>
<!--是否开启日志输出,默认关闭-->
app:isDebugEnabled="true"
<!--是否为手表,默认不是-->
app:isWearable="true"
<!--颜色为16进制值-->
<!--搜索时背景颜色遮罩程度(0最小到1最大)-->
app:background_mask_degree="0.3f"
<!--搜索时背景的遮罩颜色-->
app:background_mask_color="#FFADEA6C"
<!--搜索边框圆角半径-->
app:queryRadius="5vp"
<!--搜索建议显示条数(仅在已开启搜索建议时有效)-->
app:suggestion_count="6"
<!--搜索建议中每一条的左侧图标(仅在已开启搜索建议时有效)-->
app:search_history="$graphic:ic_history_black"<!--注意:此处仅支持graphic中的文件如果是其它格式请使用下方提供的工具进行转换或自行转换-->
<!--搜索建议中每一条的右侧图标(仅在已开启搜索建议时有效)-->
app:delete_search_history="$graphic:ic_close"<!--注意:此处仅支持graphic中的文件如果是其它格式请使用下方提供的工具进行转换或自行转换-->
<!--搜索输入光标的颜色-->
app:queryInput_cursor_color="#FF8377FF"
<!--搜索输入提示的颜色-->
app:queryInput_hint_color="#FFFF0000"
<!--搜索输入的提示文本-->
app:queryInput_hint_text="$string:search_hint_text"
<!--搜索输入文本的颜色-->
app:queryInput_text_color="#FF000000"
<!--搜索输入框背景颜色-->
app:queryInput_background_color="#FFF8F3EC"
<!--搜索输入框下侧分割线颜色-->
app:queryInput_buttom_color="#A18770B1"
<!--搜索输入框右侧按钮图标(不配置就会自动不显示)-->
app:rightButton="$graphic:ic_filters"
<!--搜索输入框右侧清空按钮图标X-->
app:rightButton_Clear="$graphic:ic_close"
<!--搜索输入框右侧清空按钮是否可用-->
app:isrightButton_ClearEnabled="true"
<!--搜索输入框左侧搜索加载动画图标O颜色-->
app:leftButton_Loadding_color="#FF1300FF"
<!--搜索输入框左侧返回按钮图标-->
app:leftButton_Back="$graphic:ic_arrow_left"
<!--搜索输入值为空-->
<!--搜索输入值为空时,是否自定义出错信息,注意:不会影响默认告警,只是你可以增加其它你想做的-->
app:nullWarnByMySelf="true"
<!--搜索输入值为空时,自定义出错信息中的提示文字,不配置会走默认值-->
app:null_warn_text="$string:search_input_null"
<!--搜索输入值为空时,自定义出错信息中的提示文字颜色,不配置会走默认值-->
app:null_warn_text_color="#FFFF006E"
<!--搜索结果值为空-->
<!--搜索结果值为空时,是否自定义出错信息,注意:不会影响默认告警,只是你可以增加其它你想做的-->
app:noneWarnByMySelf="true"
<!--搜索结果值为空时,自定义出错信息中的提示文字,不配置会走默认值-->
app:none_warn_text="$string:search_answer_none"
<!--搜索结果值为空时,自定义出错信息中的提示文字颜色,不配置会走默认值-->
app:none_warn_text_color="#FFFF003B"
```
###### 通过 Java 代码进行辅助定制
```java
1. 定义方式1
private void initView() {
SearchView sv;
sv = (SearchView) findComponentById(ResourceTable.Id_searchView);//根据id获取控件
sv.Onsearch(getContext(),//获取所在能力的context
(ListContainer) findComponentById(ResourceTable.Id_ListContainer),//根据id获取并绑定结果列表展示控件
sv,//根据id绑定控件
findComponentById(ResourceTable.Id_emptyView),//根据id获取并绑定背景展示控件
(com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar),//根据id获取并绑定背景Loading加载动画控件
getSearch(),//传入搜索的数据
getSuggection(),//传入搜索建议的数据,如果不配置这个,则不会自带搜索建议
true);//是否开启搜索建议
}
//注意:搜索建议如果无需开启可以不配置最后2项如开启搜索建议倒数第2项也可有可无
private List<SRContactor> getSearch(){
List<SRContactor> list = new ArrayList<>();
list.add(new SRContactor("zhtzx5", "clsths2"));//支持只传标题、信息此时后面4个按钮默认不显示
list.add(new SRContactor("zhng", "cl1", null, ",2u", "3g", "7n7"));//支持传null此时传null的将不会显示
list.add(new SRContactor("zhxcl5", null));//支持只传标题同时传null此时后面4个按钮和信息不显示
//TODO:注意:第一个不可为null
list.add(new SRContactor("zhags", "clhhs1", "1操", "2", "3码", "47"));//支持传入全部信息
return list;
}
private List<SHistoryContactor> getSuggection() {
List<SHistoryContactor> list = new ArrayList<>();
list.add(new SHistoryContactor("小草林", ResourceTable.Media_ic_history_black_24dp, -3));//这里-3代表根据默认图标或xml中配置的图标显示
list.add(new SHistoryContactor("TEST", ResourceTable.Media_ic_history_black_24dp, -1));//这里-1代表根据不显示图标
list.add(new SHistoryContactor("测试", -1, ResourceTable.Media_ic_close_black_24dp));
list.add(new SHistoryContactor("test"));//可以只配置建议信息会自动根据默认图标或xml中配置的图标显示
return list;
}
2. 定义方式2
sv.setContext(getContext())//设置所在能力的context
.setRoundProgressBar((com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar))//设置背景Loading加载动画控件
.setSearchView(sv)//设置搜索控件
.setSRListContainer(getSearch())//传入搜索的数据
.setSuggestionisShow(true)//设置是否开启搜索建议
.setSuggestionList(getSuggection())//设置搜索建议的数据
.setBackComponent(findComponentById(ResourceTable.Id_emptyView))//设置背景展示控件
.setListContainer((ListContainer) findComponentById(ResourceTable.Id_ListContainer))//设置结果列表展示控件
.Builder();//执行构造
-----------------------------一下方法2种构造均一样-----------------------------------
sv.setCustomListener(new SearchView.CustomListener() {
@Override
public void onFilter(String filter) {
//TODO:右上角的按钮事件
}
});
sv.setBt1Listener(new SearchView.Bt1Listener() {
@Override
public void onbT1(int position) {
Utils.error(label,"点击了按钮1其的行号为"+position+1);
//TODO:一行列表第一个的按钮事件
}
});
//依次类推此处省略其他3个按钮事件
sv.setBackClickListener(new SearchView.BackClickListener() {
@Override
public void onBackClick() {
terminate();
//TODO:左上角的按钮事件
}
});
sv.setNullWarnListener(new SearchView.NullWarnListener(){
@Override
public void onNullError() {
Utils.error(label, "空搜索警告1");
//TODO:支持自定义空搜索警告
}
});
sv.setNoneWarnListener(new SearchView.NoneWarnListener(){
@Override
public void onNullWarn() {
Utils.error(label, "空结果警告1");
//TODO:支持自定义空结果警告
}
});
```
#### - 使用ImageTracerJava工具
> 参考项目地址: 我的另一个开源项目[ImageTracerJava](https://gitee.com/xuegao-tzx/ImageTracerJava)
1. 在entry/src/test目录下的java文件中含有ImageTracerJava工具的使用示例可以将图片转换成svg图片再通过DevEco Studio自带的svg转xml即可将图片资源从media转到graphic中
2. 使用前需先导入ImageTracerJava工具并在build.gradle中添加依赖
```groovy
allprojects {
repositories {
mavenCentral()
}
}
...
dependencies {
...
implementation 'top.xuegao-tzx:ImageTracerJava:1.1.4.516'
...
}
```
3. 使用示例如下
```java
// Options
HashMap<String,Float> options = new HashMap<String,Float>();
// Tracing
options.put("ltres",1f);
options.put("qtres",1f);
options.put("pathomit",8f);
// Color quantization
options.put("colorsampling",1f); // 1f means true ; 0f means false: starting with generated palette
options.put("numberofcolors",16f);
options.put("mincolorratio",0.02f);
options.put("colorquantcycles",3f);
// SVG rendering
options.put("scale",1f);
options.put("roundcoords",1f); // 1f means rounded to 1 decimal places, like 7.3 ; 3f means rounded to 3 places, like 7.356 ; etc.
options.put("lcpr",0f);
options.put("qcpr",0f);
options.put("desc",1f); // 1f means true ; 0f means false: SVG descriptions deactivated
options.put("viewbox",0f); // 1f means true ; 0f means false: fixed width and height
// Selective Gauss Blur
options.put("blurradius",0f); // 0f means deactivated; 1f .. 5f : blur with this radius
options.put("blurdelta",20f); // smaller than this RGB difference will be blurred
// Palette
// This is an example of a grayscale palette
// please note that signed byte values [ -128 .. 127 ] will be converted to [ 0 .. 255 ] in the getsvgstring function
//下方的两个数字16请参照实际图片动态调整以实现最佳效果
byte[][] palette = new byte[16][4];
for(int colorcnt=0; colorcnt < 16; colorcnt++){
palette[colorcnt][0] = (byte)( -128 + colorcnt * 32); // R
palette[colorcnt][1] = (byte)( -128 + colorcnt * 32); // G
palette[colorcnt][2] = (byte)( -128 + colorcnt * 32); // B
palette[colorcnt][3] = (byte)127; // A
}
ImageTracer.saveString(
"src\\main\\resources\\base\\media\\ic_close_black_24dp.svg" ,
ImageTracer.imageToSVG("src\\main\\resources\\base\\media\\ic_close_black_24dp.png",options,palette)
);
```
### 版本迭代
- v1.2.3.517
## License(许可证)
作者:田梓萱 SuperSearch 在 [AGPL V3.0 License](https://www.gnu.org/licenses/agpl-3.0.txt) 下获得许可

40
build.gradle Normal file
View File

@ -0,0 +1,40 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
apply plugin: 'com.huawei.ohos.app'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
//
compileSdkVersion 6
}
buildscript {
repositories {
maven {
url 'https://repo.huaweicloud.com/repository/maven/'
allowInsecureProtocol = true
}
maven {
url 'https://developer.huawei.com/repo/'
allowInsecureProtocol = true
}
mavenCentral()
}
dependencies {
classpath 'com.huawei.ohos:hap:3.0.5.2'
classpath 'com.huawei.ohos:decctest:1.2.7.2'
}
}
allprojects {
repositories {
maven {
url 'https://repo.huaweicloud.com/repository/maven/'
allowInsecureProtocol = true
}
maven {
url 'https://developer.huawei.com/repo/'
allowInsecureProtocol = true
}
mavenCentral()
}
}

36
entry/build.gradle Normal file
View File

@ -0,0 +1,36 @@
apply plugin: 'com.huawei.ohos.hap'
apply plugin: 'com.huawei.ohos.decctest'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
ohos {
compileSdkVersion 6
defaultConfig {
compatibleSdkVersion 5
}
buildTypes {
release {
proguardOpt {
proguardEnabled false
rulesFiles 'proguard-rules.pro'
}
}
debug {
proguardOpt {
proguardEnabled true
rulesFiles 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar', '*.har'])
//testImplementation files('../libs/ImageTracer.jar')
testImplementation 'top.xuegao-tzx:ImageTracerJava:1.1.4.516'
testImplementation 'junit:junit:4.13.1'
ohosTestImplementation 'com.huawei.ohos.testkit:runner:2.0.0.200'
//implementation project(":supersearch")
implementation 'top.xuegao-tzx:SuperSearch:1.2.3.517'
}
decc {
supportType = ['html', 'xml']
}

76
entry/proguard-rules.pro vendored Normal file
View File

@ -0,0 +1,76 @@
# config module specific ProGuard rules here.
-dontwarn
# 代码混淆压缩比在0~7之间
-optimizationpasses 15
# 混合时不使用大小写混合,混合后的类名为小写
-dontusemixedcaseclassnames
# 在读取依赖的库文件时不要略过那些非public类成员
-dontskipnonpubliclibraryclassmembers
# 指定不去忽略非公共库的类
-dontskipnonpubliclibraryclasses
# 不做预校验preverify是proguard的四个步骤之一去掉这一步能够加快混淆速度
-dontpreverify
-verbose
# google推荐算法
-optimizations !code/simplification/arithmetic,!code/simplification/cast,!field/*,!class/merging/*
#-dontoptimize#注意在上传时配置,本地无需配置
# 保留注解内部类泛型匿名类
-keepattributes *Annotation*,Exceptions,InnerClasses,Signature,EnclosingMethod
# 重命名抛出异常时的文件名称
-renamesourcefileattribute SourceFile
# 抛出异常时保留代码行号
-keepattributes SourceFile,LineNumberTable
-dontwarn javax.annotation.**
# 保留本地native方法不被混淆
-keepclasseswithmembernames,allowshrinking class * {
native <methods>;
}
# 保留枚举类不被混淆
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
# 保留自定义类
-keep enum com.xcl.supersearch.**
-keep class com.xcl.supersearch.**{*;}
-keep class com.xcl.supersearch.**
-keepclassmembers enum com.xcl.supersearch.**{*;}
-keep interface com.xcl.supersearch.**
# 忽略继承
-keepclassmembers class * implements java.io.Serializable {
static final long serialVersionUID;
private static final java.io.ObjectStreamField[] serialPersistentFields;
private void writeObject(java.io.ObjectOutputStream);
private void readObject(java.io.ObjectInputStream);
java.lang.Object writeReplace();
java.lang.Object readResolve();
}
# 保留HMS相关接入[AnalyticsKit SDK和依赖SDK的混淆配置]
-ignorewarnings
-repackageclasses
-keep class com.huawei.agconnect.**{*;}
-keep class com.huawei.hms.analytics.**{*;}
-keep class com.huawei.hms.push.**{*;}
-keep class com.huawei.hms.**{*;}
# HMS接口服务
-keepattributes Exceptions
-keep interface com.huawei.hms.analytics.type.HAEventType{*;}
-keep interface com.huawei.hms.analytics.type.HAParamType{*;}
-keep class com.huawei.hms.analytics.HiAnalyticsInstance{*;}
-keep class com.huawei.hms.analytics.HiAnalytics{*;}
-keep class com.huawei.hianalytics.**{*;}
-keep class com.huawei.updatesdk.**{*;}
-keep class com.huawei.harmony.**{*;}
-keep class com.huawei.mylibrary.**{*;}
# 保留HarmonyOS应用/服务入口类
-keep public class * extends *.aafwk.ability.Ability
-keep public class * extends *.ace.ability.AceAbility
-keep public class * extends *.aafwk.ability.AbilitySlice
-keep public class * extends *.aafwk.ability.AbilityPackage
-dontwarn java.lang.invoke.**
-dontwarn javax.naming.**
-dontwarn ohos.utils.PacMap.**
-keep class **.ResourceTable$* {*;}
-keepattributes Signature, InnerClasses, EnclosingMethod, Exceptions
# 保留配置文件
-printmapping mapping.txt

View File

@ -0,0 +1,69 @@
{
"app": {
"bundleName": "com.xcl.studyt",
"vendor": "tzx",
"version": {
"code": 1000000,
"name": "1.0.0"
}
},
"deviceConfig": {},
"module": {
"package": "com.xcl.search.test",
"name": ".MyApplication",
"mainAbility": "com.xcl.search.test.MainAbility",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable",
"car"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"metaData": {
"customizeData": [
{
"name": "hwc-theme",
"extra": "",
"value": "androidhwext:style/Theme.Emui.Wallpaper.NoTitleBar"
}
]
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"name": "com.xcl.search.test.MainAbility",
"icon": "$media:icon",
"description": "$string:mainability_description",
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"name": "com.xcl.search.test.SearchDemoAbility",
"icon": "$media:icon",
"description": "$string:searchdemoability_description",
"label": "$string:entry_SearchDemoAbility",
"type": "page",
"launchType": "standard"
}
]
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.search.test;
import com.xcl.search.test.slice.MainAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.window.service.WindowManager;
public class MainAbility extends Ability {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setAbilitySliceAnimator(null);
super.setTransitionAnimation(0, 0);
this.getWindow().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
super.setMainRoute(MainAbilitySlice.class.getName());
super.setTransitionAnimation(0, 0);
super.setAbilitySliceAnimator(null);
}
}

View File

@ -0,0 +1,25 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.search.test;
import ohos.aafwk.ability.AbilityPackage;
public class MyApplication extends AbilityPackage {
@Override
public void onInitialize() {
super.onInitialize();
}
}

View File

@ -0,0 +1,34 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.search.test;
import com.xcl.search.test.slice.SearchDemoAbilitySlice;
import ohos.aafwk.ability.Ability;
import ohos.aafwk.content.Intent;
import ohos.agp.window.service.WindowManager;
public class SearchDemoAbility extends Ability {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setAbilitySliceAnimator(null);
super.setTransitionAnimation(0, 0);
this.getWindow().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
super.setMainRoute(SearchDemoAbilitySlice.class.getName());
super.setTransitionAnimation(0, 0);
super.setAbilitySliceAnimator(null);
}
}

View File

@ -0,0 +1,74 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.search.test.slice;
import com.xcl.search.test.ResourceTable;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.aafwk.content.Operation;
import ohos.agp.components.Component;
import ohos.agp.window.service.WindowManager;
import ohos.utils.net.Uri;
public class MainAbilitySlice extends AbilitySlice {
@Override
public void onStart(Intent intent) {
super.onStart(intent);
super.setUIContent(ResourceTable.Layout_ability_main);
this.getWindow().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
this.findComponentById(ResourceTable.Id_withoutSug).setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component v) {
Route("withoutSug");
}
});
this.findComponentById(ResourceTable.Id_recentSug).setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component v) {
Route("recentSug");
}
});
this.findComponentById(ResourceTable.Id_hasknownSug).setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component v) {
Route("hasknownSug");
}
});
}
public void Route(String route) {
Intent intent1 = new Intent();
intent1.setParam("SEARCH_PD", route);
Operation operation = new Intent.OperationBuilder()
.withDeviceId("")
.withBundleName(MainAbilitySlice.this.getBundleName())
.withAbilityName("com.xcl.search.test.SearchDemoAbility")
.build();
intent1.setOperation(operation);
MainAbilitySlice.this.startAbility(intent1);
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
}

View File

@ -0,0 +1,198 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.search.test.slice;
import com.xcl.search.test.ResourceTable;
import com.xcl.supersearch.SHistoryContactor;
import com.xcl.supersearch.SRContactor;
import com.xcl.supersearch.SearchView;
import com.xcl.supersearch.Utils;
import ohos.aafwk.ability.AbilitySlice;
import ohos.aafwk.content.Intent;
import ohos.agp.components.ListContainer;
import ohos.agp.window.service.WindowManager;
import ohos.data.distributed.common.KvManagerConfig;
import ohos.data.distributed.common.KvManagerFactory;
import ohos.distributedhardware.devicemanager.DeviceInfo;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import java.util.ArrayList;
import java.util.List;
public class SearchDemoAbilitySlice extends AbilitySlice {
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "SearchDemoAbilitySlice");
private int PDD = -2;
private SearchView sV;
private static List<SRContactor> getSearch() {
List<SRContactor> list = new ArrayList<>();
for (int i = 0; i < 15; i++) {
list.add(new SRContactor("zhangsan", "class1", "1", "2你", "3", "4.7"));
}
list.add(new SRContactor("zhtzx5", "clsths2"));//支持只传标题信息此时后面4个按钮默认不显示
list.add(new SRContactor("zhng", "cl1", null, ",2u", "3g", "7n7"));//支持传null此时传null的将不会显示
list.add(new SRContactor("zhxcl5", null));//支持只传标题同时传null此时后面4个按钮和信息不显示
//TODO:注意:第一个不可为null
list.add(new SRContactor("zhags", "clhhs1", "1操", "2", "3码", "47"));//支持传入全部信息
return list;
}
private static List<SHistoryContactor> getSuggection() {
List<SHistoryContactor> list = new ArrayList<>();
list.add(new SHistoryContactor("小草林", ResourceTable.Media_ic_history_black_24dp, -3));//这里-3代表根据默认图标或xml中配置的图标显示
list.add(new SHistoryContactor("TEST", ResourceTable.Media_ic_history_black_24dp, -1));//这里-1代表根据不显示图标
list.add(new SHistoryContactor("测试", -1, ResourceTable.Media_ic_close_black_24dp));
list.add(new SHistoryContactor("...", ResourceTable.Media_ic_history_black_24dp, ResourceTable.Media_ic_close_black_24dp));
list.add(new SHistoryContactor("test"));//可以只配置建议信息会自动根据默认图标或xml中配置的图标显示
return list;
}
@Override
public void onStart(Intent intent) {
super.onStart(intent);
getWindow().addFlags(WindowManager.LayoutConfig.MARK_ALLOW_EXTEND_LAYOUT);
ohos.data.distributed.device.DeviceInfo localDeviceInfo = KvManagerFactory.getInstance()
.createKvManager(new KvManagerConfig((getContext()))).getLocalDeviceInfo();
int localDeviceType = Integer.parseInt(localDeviceInfo.getType());
if (localDeviceType == DeviceInfo.DeviceType.WEARABLE.value()) {
super.setUIContent(ResourceTable.Layout_ability_search_demow);
} else {
super.setUIContent(ResourceTable.Layout_ability_search_demo);
}
Utils.pd_pd = true;
sV = (SearchView) findComponentById(ResourceTable.Id_searchview);
if (sV == null) {
Utils.info(SearchDemoAbilitySlice.label, "null");
} else {
Utils.info(SearchDemoAbilitySlice.label, "not null");
}
if (intent != null) {
String action = intent.getStringParam("SEARCH_PD");
if ("withoutSug".equals(action)) {
PDD = -1;
} else if ("recentSug".equals(action)) {
PDD = 0;
} else if ("hasknownSug".equals(action)) {
PDD = 1;
}
} else {
terminate();
}
initView();
}
private void initView() {
if (PDD == 0) {
/*sv.Onsearch(getContext(),
(ListContainer) findComponentById(ResourceTable.Id_ListContainer),
sv,
findComponentById(ResourceTable.Id_emptyView),
(com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar),
getSearch(),
true);*///TODO:方法一无需建议列表只需配置true即可
sV.setContext(getContext())
.setRoundProgressBar((com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar))
.setSearchView(sV)
.setSRListContainer(SearchDemoAbilitySlice.getSearch())
.setSuggestionisShow(true)
.setBackComponent(findComponentById(ResourceTable.Id_emptyView))
.setListContainer((ListContainer) findComponentById(ResourceTable.Id_ListContainer))
.Builder();//TODO:方法二
} else if (PDD == 1) {
/*sv.Onsearch(getContext(),//获取所在能力的context
(ListContainer) findComponentById(ResourceTable.Id_ListContainer),//根据id获取并绑定结果列表展示控件
sv,//根据id绑定控件
findComponentById(ResourceTable.Id_emptyView),//根据id获取并绑定背景展示控件
(com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar),//根据id获取并绑定背景Loading加载动画控件
getSearch(),//传入搜索的数据
getSuggection(),//传入搜索建议的数据如果不配置这个则不会自带搜索建议
true);//是否开启搜索建议
*///TODO:方法一
sV.setContext(getContext())//设置所在能力的context
.setRoundProgressBar((com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar))//设置背景Loading加载动画控件
.setSearchView(sV)//设置搜索控件
.setSRListContainer(SearchDemoAbilitySlice.getSearch())//传入搜索的数据
.setSuggestionisShow(true)//设置是否开启搜索建议
.setSuggestionList(SearchDemoAbilitySlice.getSuggection())//设置搜索建议的数据
.setBackComponent(findComponentById(ResourceTable.Id_emptyView))//设置背景展示控件
.setListContainer((ListContainer) findComponentById(ResourceTable.Id_ListContainer))//设置结果列表展示控件
.Builder();//执行构造
//TODO:方法二
} else if (PDD == -1) {
sV.setContext(getContext())
.setRoundProgressBar((com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar))
.setSearchView(sV)
.setSRListContainer(SearchDemoAbilitySlice.getSearch())
.setBackComponent(findComponentById(ResourceTable.Id_emptyView))
.setListContainer((ListContainer) findComponentById(ResourceTable.Id_ListContainer))
.Builder();//TODO:方法二
/*sv.Onsearch(getContext(),
(ListContainer) findComponentById(ResourceTable.Id_ListContainer),
sv,
findComponentById(ResourceTable.Id_emptyView),
(com.xcl.supersearch.RoundProgressBar) findComponentById(ResourceTable.Id_progressBar),
getSearch());*///TODO:方法一不配置默认不开启搜索建议
}
sV.setCustomListener(new SearchView.CustomListener() {
@Override
public void onFilter(String filter) {
//TODO:右上角的按钮事件
}
});
sV.setBt1Listener(new SearchView.Bt1Listener() {
@Override
public void onbT1(int position) {
HiLog.error(SearchDemoAbilitySlice.label, "点击了按钮1其的行号为" + position + 1);
//TODO:一行列表第一个的按钮事件
}
});
sV.setBackClickListener(new SearchView.BackClickListener() {
@Override
public void onBackClick() {
terminate();
//TODO:左上角的按钮事件
}
});
sV.setNullWarnListener(new SearchView.NullWarnListener() {
@Override
public void onNullError() {
HiLog.error(SearchDemoAbilitySlice.label, "空搜索警告1");
//TODO:支持自定义空搜索警告
}
});
sV.setNoneWarnListener(new SearchView.NoneWarnListener() {
@Override
public void onNullWarn() {
HiLog.error(SearchDemoAbilitySlice.label, "空结果警告1");
//TODO:支持自定义空结果警告
}
});
}
@Override
public void onActive() {
super.onActive();
}
@Override
public void onForeground(Intent intent) {
super.onForeground(intent);
}
}

View File

@ -0,0 +1,64 @@
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "Java_Empty Ability"
},
{
"name": "mainability_HelloWorld",
"value": "Hello World"
},
{
"name": "searchmr",
"value": "搜索默认页面"
},
{
"name": "withoutSug",
"value": "无建议搜索"
},
{
"name": "recentSug",
"value": "有最近建议搜索"
},
{
"name": "hasknownSug",
"value": "有已知建议搜索"
},
{
"name": "suggestion_text",
"value": "建议文本"
},
{
"name": "search_hint_text",
"value": "搜索..."
},
{
"name": "search_hint_text_",
"value": "搜索."
},
{
"name": "search_input_null",
"value": "搜索值为空"
},
{
"name": "search_answer_none",
"value": "搜索结果为空"
},
{
"name": "searchdemoability_description",
"value": "Java_Empty Ability"
},
{
"name": "searchdemoability_HelloWorld",
"value": "Hello World"
},
{
"name": "entry_SearchDemoAbility",
"value": "entry_SearchDemoAbility"
}
]
}

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid
ohos:color="#FFFFFF"/>
</shape>

View File

@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8" ?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid
ohos:color="#F8D4C9C9"/>
</shape>

View File

@ -0,0 +1,12 @@
<!-- drawable/arrow_left.xml -->
<vector
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="24vp"
ohos:width="24vp"
ohos:viewportHeight="24"
ohos:viewportWidth="24">
<path
ohos:fillColor="#FFD2D257"
ohos:pathData="M20,11V13H8L13.5,18.5L12.08,19.92L4.16,12L12.08,4.08L13.5,5.5L8,11H20Z"/>
</vector>

View File

@ -0,0 +1,12 @@
<!-- drawable/close.xml -->
<vector
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="24vp"
ohos:width="24vp"
ohos:viewportHeight="24"
ohos:viewportWidth="24">
<path
ohos:fillColor="#FF391D3C"
ohos:pathData="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z"/>
</vector>

View File

@ -0,0 +1,12 @@
<!-- drawable/filter_variant.xml -->
<vector
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="24vp"
ohos:width="24vp"
ohos:viewportHeight="24"
ohos:viewportWidth="24">
<path
ohos:fillColor="#FFFF0000"
ohos:pathData="M6,13H18V11H6M3,6V8H21V6M10,18H14V16H10V18Z"/>
</vector>

View File

@ -0,0 +1,33 @@
<?xml version="1.0" encoding="UTF-8"?>
<vector
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="72vp"
ohos:width="72vp"
ohos:viewportHeight="72"
ohos:viewportWidth="72">
<path
ohos:fillAlpha="0.011764706"
ohos:fillColor="#000000"
ohos:pathData="M0.5,0L72,0.5L71.5,72L0,71.5L0.5,0Z"
ohos:strokeAlpha="0.011764706"
ohos:strokeColor="#000000"
ohos:strokeWidth="1"></path>
<path
ohos:fillAlpha="0.972549"
ohos:fillColor="#000000"
ohos:pathData="M34.5,9Q44.8,7.8 50,11.5L60,18.5Q67,25.5 66,40.5Q63.5,51 56.5,57Q49.5,64 34.5,63Q25.6,60.9 20,55.5L23.5,51Q29.2,57.8 42.5,57Q52.5,55 57,47.5L59.5,40L60,32.5Q58,22.5 50.5,18L43,15.5L34.5,15Q25.5,17.5 21,24.5L18.5,31L18,35.5L27,36.5L14.5,48L3.5,36L12,35.5L12.5,31L14.5,25L21.5,15L34.5,9Z"
ohos:strokeAlpha="0.972549"
ohos:strokeColor="#000000"
ohos:strokeWidth="1"></path>
<path
ohos:fillAlpha="0.972549"
ohos:fillColor="#000000"
ohos:pathData="M36.5,24L41,24.5L41,33.5Q40.3,38.3 43.5,39L51,43.5L49.5,46L44.5,44L36,38.5L36.5,24Z"
ohos:strokeAlpha="0.972549"
ohos:strokeColor="#000000"
ohos:strokeWidth="1"></path>
</vector>

View File

@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:alignment="center"
ohos:background_element="#F8D4C9C9"
ohos:orientation="vertical"
ohos:padding="10vp">
<DirectionalLayout
ohos:height="match_content"
ohos:width="match_content"
ohos:alignment="horizontal_center"
ohos:center_in_parent="true"
ohos:orientation="vertical">
<Button
ohos:id="$+id:withoutSug"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="#AD5F9EE3"
ohos:padding="10vp"
ohos:text="$string:withoutSug"
ohos:text_size="16vp"
ohos:text_weight="800"/>
<Button
ohos:id="$+id:recentSug"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="#AD5F9EE3"
ohos:padding="10vp"
ohos:text="$string:recentSug"
ohos:text_size="16vp"
ohos:text_weight="800"
ohos:top_margin="10vp"/>
<Button
ohos:id="$+id:hasknownSug"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="#AD5F9EE3"
ohos:padding="10vp"
ohos:text="$string:hasknownSug"
ohos:text_size="16vp"
ohos:text_weight="800"
ohos:top_margin="10vp"/>
</DirectionalLayout>
</DependentLayout>

View File

@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/app/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="#F8D4C9C9"
ohos:top_padding="50vp">
<ListContainer
ohos:id="$+id:ListContainer"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="#C88D8888"
ohos:bottom_padding="16vp"
ohos:color="#FF4C29CB"
ohos:left_padding="15vp"
ohos:orientation="vertical"
ohos:right_padding="15vp"
ohos:top_padding="60vp"
/>
<DirectionalLayout
ohos:id="$+id:emptyView"
ohos:height="match_content"
ohos:width="match_content"
ohos:padding="10vp"
ohos:center_in_parent="true"
ohos:orientation="vertical"
>
<Text
ohos:id="$+id:text_back"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="$graphic:background_ability_search_demo"
ohos:layout_alignment="horizontal_center"
ohos:text="$string:searchmr"
ohos:text_size="30vp"
/>
</DirectionalLayout>
<com.xcl.supersearch.RoundProgressBar
ohos:id="$id:progressBar"
ohos:height="50vp"
ohos:width="50vp"
ohos:center_in_parent="true"
ohos:visibility="hide"
app:round_progress_color="#FF82F8EF"
app:round_progress_with="5f"
/>
<com.xcl.supersearch.SearchView
ohos:id="$+id:searchview"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:left_padding="15vp"
ohos:padding="5vp"
ohos:right_padding="15vp"
ohos:visibility="visible"
app:background_mask_degree="0.35f"
app:delete_search_history="$graphic:ic_close"
app:isDebugEnabled="true"
app:isrightButton_ClearEnabled="true"
app:leftButton_Back="$graphic:ic_arrow_left"
app:leftButton_Loadding_color="#FF1300FF"
app:noneWarnByMySelf="true"
app:none_warn_text="$string:search_answer_none"
app:none_warn_text_color="#5CFF0000"
app:nullWarnByMySelf="true"
app:null_warn_text="$string:search_input_null"
app:null_warn_text_color="#79FF006E"
app:queryInput_background_color="#FFF8F3EC"
app:queryInput_buttom_color="#A18770B1"
app:queryInput_cursor_color="#FF8377FF"
app:queryInput_hint_color="#FFFF0000"
app:queryInput_hint_text="$string:search_hint_text"
app:queryInput_text_color="#FF6B16FF"
app:queryRadius="5vp"
app:rightButton_Clear="$graphic:ic_close"
app:search_history="$graphic:ic_history_black"
app:suggestion_count="6"
/>
</DependentLayout>

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/app/res/ohos"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="#F8D4C9C9">
<ListContainer
ohos:id="$+id:ListContainer"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:background_element="#F8D4C9C9"
ohos:bottom_padding="43.5vp"
ohos:color="#FF4C29CB"
ohos:left_padding="26.5vp"
ohos:orientation="vertical"
ohos:right_padding="26.5vp"
ohos:top_padding="60vp"
/>
<DirectionalLayout
ohos:id="$+id:emptyView"
ohos:height="match_content"
ohos:width="match_content"
ohos:center_in_parent="true"
ohos:orientation="vertical"
>
<Text
ohos:id="$+id:text_back"
ohos:height="match_content"
ohos:width="match_content"
ohos:background_element="$graphic:background_ability_search_demo"
ohos:layout_alignment="horizontal_center"
ohos:text="$string:searchmr"
ohos:text_size="15vp"
/>
</DirectionalLayout>
<com.xcl.supersearch.RoundProgressBar
ohos:id="$id:progressBar"
ohos:height="25vp"
ohos:width="25vp"
ohos:center_in_parent="true"
ohos:visibility="hide"
app:round_progress_color="#FF82F8EF"
app:round_progress_with="3f"
/>
<com.xcl.supersearch.SearchView
ohos:id="$+id:searchview"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:bottom_padding="40vp"
ohos:left_padding="34vp"
ohos:right_padding="34vp"
ohos:top_padding="35.5vp"
ohos:visibility="visible"
app:background_mask_color="#75B5D290"
app:background_mask_degree="0.35f"
app:delete_search_history="$graphic:ic_close"
app:isDebugEnabled="true"
app:isWearable="true"
app:isrightButton_ClearEnabled="true"
app:leftButton_Back="$graphic:ic_arrow_left"
app:leftButton_Loadding_color="#FF1300FF"
app:noneWarnByMySelf="true"
app:none_warn_text="$string:search_answer_none"
app:none_warn_text_color="#5CFF0000"
app:nullWarnByMySelf="true"
app:null_warn_text="$string:search_input_null"
app:null_warn_text_color="#79FF006E"
app:queryInput_background_color="#FFF8F3EC"
app:queryInput_buttom_color="#A18770B1"
app:queryInput_cursor_color="#FF8377FF"
app:queryInput_hint_color="#FFFF0000"
app:queryInput_hint_text="$string:search_hint_text"
app:queryInput_text_color="#FF6B16FF"
app:queryRadius="3vp"
app:rightButton_Clear="$graphic:ic_close"
app:search_history="$graphic:ic_history_black"
app:suggestion_count="6"
/>
</DependentLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

View File

@ -0,0 +1,64 @@
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "mainability_description",
"value": "Java_Empty Ability"
},
{
"name": "mainability_HelloWorld",
"value": "你好,世界"
},
{
"name": "searchmr",
"value": "搜索默认页面"
},
{
"name": "withoutSug",
"value": "无建议搜索"
},
{
"name": "recentSug",
"value": "有最近建议搜索"
},
{
"name": "hasknownSug",
"value": "有已知建议搜索"
},
{
"name": "suggestion_text",
"value": "建议文本"
},
{
"name": "search_hint_text",
"value": "搜索..."
},
{
"name": "search_hint_text_",
"value": "搜索."
},
{
"name": "search_input_null",
"value": "搜索值为空"
},
{
"name": "search_answer_none",
"value": "搜索结果为空"
},
{
"name": "entry_SearchDemoAbility",
"value": "entry_SearchDemoAbility"
},
{
"name": "searchdemoability_description",
"value": "Java_Empty Ability"
},
{
"name": "searchdemoability_HelloWorld",
"value": "你好,世界"
}
]
}

View File

@ -0,0 +1,14 @@
package com.xcl.search.test;
import ohos.aafwk.ability.delegation.AbilityDelegatorRegistry;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ExampleOhosTest {
@Test
public void testBundleName() {
final String actualBundleName = AbilityDelegatorRegistry.getArguments().getTestBundleName();
assertEquals("com.xcl.search.test", actualBundleName);
}
}

View File

@ -0,0 +1,49 @@
package com.xcl.search.test;
import com.xcl.imagetracer_mod.ImageTracer;
import org.junit.Test;
import java.util.HashMap;
public class ExampleTest {
@Test
public void onStart() throws Exception {
// Options
HashMap<String, Float> options = new HashMap<String, Float>();
// Tracing
options.put("ltres", 1f);
options.put("qtres", 1f);
options.put("pathomit", 8f);
// Color quantization
options.put("colorsampling", 1f); // 1f means true ; 0f means false: starting with generated palette
options.put("numberofcolors", 16f);
options.put("mincolorratio", 0.02f);
options.put("colorquantcycles", 3f);
// SVG rendering
options.put("scale", 1f);
options.put("roundcoords", 1f); // 1f means rounded to 1 decimal places, like 7.3 ; 3f means rounded to 3 places, like 7.356 ; etc.
options.put("lcpr", 0f);
options.put("qcpr", 0f);
options.put("desc", 1f); // 1f means true ; 0f means false: SVG descriptions deactivated
options.put("viewbox", 0f); // 1f means true ; 0f means false: fixed width and height
// Selective Gauss Blur
options.put("blurradius", 0f); // 0f means deactivated; 1f .. 5f : blur with this radius
options.put("blurdelta", 20f); // smaller than this RGB difference will be blurred
// Palette
// This is an example of a grayscale palette
// please note that signed byte values [ -128 .. 127 ] will be converted to [ 0 .. 255 ] in the getsvgstring function
//下方的两个数字16请参照实际图片动态调整以实现最佳效果
byte[][] palette = new byte[16][4];
for (int colorcnt = 0; colorcnt < 16; colorcnt++) {
palette[colorcnt][0] = (byte) (-128 + colorcnt * 32); // R
palette[colorcnt][1] = (byte) (-128 + colorcnt * 32); // G
palette[colorcnt][2] = (byte) (-128 + colorcnt * 32); // B
palette[colorcnt][3] = (byte) 127; // A
}
ImageTracer.saveString(
"src\\main\\resources\\base\\media\\ic_close_black_24dp.svg",
ImageTracer.imageToSVG("src\\main\\resources\\base\\media\\ic_close_black_24dp.png", options, palette)
);
}
}

13
gradle.properties Normal file
View File

@ -0,0 +1,13 @@
# Project-wide Gradle settings.
# IDE (e.g. DevEco 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.
# If the Chinese output is garbled, please configure the following parameter.
# This function is enabled by default when the DevEco Studio builds the hap/app,if you need disable gradle parallel,you should set org.gradle.parallel false.
# more information see https://docs.gradle.org/current/userguide/performance.html
# org.gradle.parallel=false
# org.gradle.jvmargs=-Dfile.encoding=GBK

BIN
gradle/wrapper/gradle-wrapper.jar vendored Normal file

Binary file not shown.

View File

@ -0,0 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://repo.huaweicloud.com/gradle/gradle-7.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists

183
gradlew vendored Normal file
View File

@ -0,0 +1,183 @@
#!/usr/bin/env sh
#
# Copyright 2015 the original author or authors.
#
# 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.
#
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# 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
APP_NAME="Gradle"
APP_BASE_NAME=$(basename "$0")
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
# 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
nonstop=false
case "$(uname)" in
CYGWIN*)
cygwin=true
;;
Darwin*)
darwin=true
;;
MINGW*)
msys=true
;;
NONSTOP*)
nonstop=true
;;
esac
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" -a "$nonstop" = "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 or MSYS, switch paths to Windows format before running java
if [ "$cygwin" = "true" -o "$msys" = "true" ]; 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=$(expr $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
# Escape application args
save() {
for i; do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/"; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
exec "$JAVACMD" "$@"

103
gradlew.bat vendored Normal file
View File

@ -0,0 +1,103 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@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
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@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="-Xmx64m" "-Xms64m"
@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 Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_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=%*
: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

BIN
libs/ImageTracer.jar Normal file

Binary file not shown.

1
package.json Normal file
View File

@ -0,0 +1 @@
{}

1
settings.gradle Normal file
View File

@ -0,0 +1 @@
include ':entry', ':supersearch'

28
supersearch/build.gradle Normal file
View File

@ -0,0 +1,28 @@
apply plugin: 'com.huawei.ohos.library'
//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510
//apply from: './upload.gradle'
ohos {
compileSdkVersion 6
defaultConfig {
compatibleSdkVersion 5
}
buildTypes {
release {
proguardOpt {
proguardEnabled false
rulesFiles 'proguard-rules.pro'
}
}
debug {
proguardOpt {
proguardEnabled false
rulesFiles 'proguard-rules.pro'
}
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.13.1'
}

View File

@ -0,0 +1 @@
# Add har specific ProGuard rules for consumer here.

View File

@ -0,0 +1,35 @@
{
"app": {
"bundleName": "com.xcl.search",
"vendor": "xcl",
"version": {
"code": 220517,
"name": "1.2.3.517"
}
},
"deviceConfig": {
},
"module": {
"package": "com.xcl.supersearch",
"deviceType": [
"phone",
"tablet",
"tv",
"wearable"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "supersearch",
"moduleType": "har"
},
"metaData": {
"customizeData": [
{
"name": "hwc-theme",
"extra": "",
"value": "androidhwext:style/Theme.Emui.Wallpaper.NoTitleBar"
}
]
}
}
}

View File

@ -0,0 +1,146 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
import ohos.agp.animation.Animator;
import ohos.agp.animation.AnimatorValue;
import ohos.agp.components.ComponentContainer;
import ohos.agp.components.element.Element;
public final class BackgroundLoadingAnimation {
private boolean isRecycled;
private float fromAlpha;
private float toAlpha;
private ComponentContainer view;
private AnimatorValue animator;
public BackgroundLoadingAnimation(ComponentContainer view, float fromAlpha, float toAlpha) {
this.view = view;
this.fromAlpha = fromAlpha;
this.toAlpha = toAlpha;
this.isRecycled = false;
initAnimator();
}
private void initAnimator() {
animator = new AnimatorValue();
animator.setDuration(200);
animator.setCurveType(Animator.CurveType.LINEAR);
animator.setValueUpdateListener((valueAnimator, v) -> {
Element element = view.getBackgroundElement();
element.setAlpha((int) (fromAlpha * 0xFF + (toAlpha - fromAlpha) * 0xFF * v));
}
);
animator.setStateChangedListener(new Animator.StateChangedListener() {
@Override
public void onStart(Animator animator) {
}
@Override
public void onStop(Animator animator) {
view.setClickable(toAlpha != 0);
}
@Override
public void onCancel(Animator animator) {
}
@Override
public void onEnd(Animator animator) {
}
@Override
public void onPause(Animator animator) {
}
@Override
public void onResume(Animator animator) {
}
});
}
public BackgroundLoadingAnimation setFromAlpha(float fromAlpha) {
this.fromAlpha = fromAlpha;
return this;
}
public BackgroundLoadingAnimation setToAlpha(float toAlpha) {
this.toAlpha = toAlpha;
return this;
}
public BackgroundLoadingAnimation setInterpolator(int interpolator) {
animator.setCurveType(interpolator);
return this;
}
public BackgroundLoadingAnimation setDuration(long duration) {
animator.setDuration(duration);
return this;
}
public void start() {
if (isRecycled() || view.getAlpha() == toAlpha) {
return;
}
stop();
animator.start();
}
public void stop() {
if (!isRecycled() && isRunning()) {
animator.cancel();
}
}
public boolean isRunning() {
return animator.isRunning();
}
public void recycle() {
if (isRecycled) {
return;
}
view = null;
animator = null;
isRecycled = true;
}
public boolean isRecycled() {
return isRecycled;
}
}

View File

@ -0,0 +1,180 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
import ohos.agp.components.*;
import ohos.app.Context;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import java.util.ArrayList;
import java.util.List;
import static com.xcl.supersearch.Utils.iswear;
public class ContactProviderSR extends BaseItemProvider {
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00666, "ContactProviderSR");
private final Context context;
private List<SRContactor> contactArrays = new ArrayList<>(0);
private AdapterClickListener adapterClickListener;
public ContactProviderSR(Context context, List<SRContactor> contactArrays) {
this.context = context;
this.contactArrays = contactArrays;
}
public ContactProviderSR(Context context) {
this.context = context;
}
@Override
public int getCount() {
return this.contactArrays == null ? 0 : this.contactArrays.size();
}
@Override
public SRContactor getItem(int position) {
if (position < this.contactArrays.size() && position >= 0) return this.contactArrays.get(position);
return null;
}
@Override
public long getItemId(int position) {
return position;
}
@Override
public Component getComponent(int position, Component componentPara, ComponentContainer componentContainer) {
Component component = componentPara;
try {
ViewHolder viewHolder = null;
if (component == null) {
if (iswear) {
component = LayoutScatter.getInstance(this.context).parse(ResourceTable.Layout_searchresw,
null, false);
} else {
component = LayoutScatter.getInstance(this.context).parse(ResourceTable.Layout_searchres,
null, false);
}
viewHolder = new ViewHolder();
viewHolder.button1 = (Button) component.findComponentById(ResourceTable.Id_button1);
viewHolder.button2 = (Button) component.findComponentById(ResourceTable.Id_button2);
viewHolder.button3 = (Button) component.findComponentById(ResourceTable.Id_button3);
viewHolder.button4 = (Button) component.findComponentById(ResourceTable.Id_button4);
viewHolder.text2 = (Text) component.findComponentById(ResourceTable.Id_message);
viewHolder.text1 = (Text) component.findComponentById(ResourceTable.Id_title);
component.setTag(viewHolder);
} else if (component.getTag() instanceof ViewHolder) viewHolder = (ViewHolder) component.getTag();
if (viewHolder != null) {
viewHolder.text1.setVisibility(Component.VISIBLE);
viewHolder.text2.setVisibility(Component.VISIBLE);
viewHolder.button1.setVisibility(Component.VISIBLE);
viewHolder.button2.setVisibility(Component.VISIBLE);
viewHolder.button3.setVisibility(Component.VISIBLE);
viewHolder.button4.setVisibility(Component.VISIBLE);
if (this.contactArrays.get(position).getBt1() != null) {
viewHolder.button1.setText(this.contactArrays.get(position).getBt1());
} else {
viewHolder.button1.setVisibility(Component.HIDE);
}
viewHolder.button1.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component deleteComponent) {
if (ContactProviderSR.this.adapterClickListener != null)
ContactProviderSR.this.adapterClickListener.ann1(position);
}
});
if (this.contactArrays.get(position).getBt2() != null) {
viewHolder.button2.setText(this.contactArrays.get(position).getBt2());
} else {
viewHolder.button2.setVisibility(Component.HIDE);
}
viewHolder.button2.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component deleteComponent) {
if (ContactProviderSR.this.adapterClickListener != null)
ContactProviderSR.this.adapterClickListener.ann2(position);
}
});
if (this.contactArrays.get(position).getBt3() != null) {
viewHolder.button3.setText(this.contactArrays.get(position).getBt3());
} else {
viewHolder.button3.setVisibility(Component.HIDE);
}
viewHolder.button3.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component deleteComponent) {
if (ContactProviderSR.this.adapterClickListener != null)
ContactProviderSR.this.adapterClickListener.ann3(position);
}
});
if (this.contactArrays.get(position).getBt4() != null) {
viewHolder.button4.setText(this.contactArrays.get(position).getBt4());
} else {
viewHolder.button4.setVisibility(Component.HIDE);
}
viewHolder.button4.setClickedListener(new Component.ClickedListener() {
@Override
public void onClick(Component deleteComponent) {
if (ContactProviderSR.this.adapterClickListener != null)
ContactProviderSR.this.adapterClickListener.ann4(position);
}
});
if (this.contactArrays.get(position).getTitle() != null) {
viewHolder.text1.setText(this.contactArrays.get(position).getTitle());
} else {
viewHolder.text1.setVisibility(Component.HIDE);
}
if (this.contactArrays.get(position).getMessage() != null) {
viewHolder.text2.setText(this.contactArrays.get(position).getMessage());
} else {
viewHolder.text2.setVisibility(Component.HIDE);
}
}
} catch (Exception e) {
Utils.error(label, e.getMessage());
}
return component;
}
void setAdapterClickListener(AdapterClickListener adapterClickListener) {
this.adapterClickListener = adapterClickListener;
}
public void setData(List<SRContactor> listData) {
contactArrays = listData;
}
public interface AdapterClickListener {
void ann1(int position);
void ann2(int position);
void ann3(int position);
void ann4(int position);
}
private static class ViewHolder {
private Text text1;
private Text text2;
private Button button1;
private Button button2;
private Button button3;
private Button button4;
}
}

View File

@ -0,0 +1,131 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
import ohos.agp.components.AttrSet;
import ohos.agp.components.Component;
import ohos.agp.render.Arc;
import ohos.agp.render.Canvas;
import ohos.agp.render.Paint;
import ohos.agp.utils.Color;
import ohos.agp.utils.RectFloat;
import ohos.agp.window.service.Display;
import ohos.agp.window.service.DisplayAttributes;
import ohos.agp.window.service.DisplayManager;
import ohos.app.Context;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import static com.xcl.supersearch.Utils.*;
public class RoundProgressBar extends Component implements Component.DrawTask {
private static final HiLogLabel label = new HiLogLabel(HiLog.LOG_APP, 0x00234, "RoundProgressBar");
private final DisplayAttributes displayAttributes;
private int backgroundColor = Color.getIntColor("#FF4C29CB");//默认紫色背景
private int arcD = 1;
private int arcO = 0;
private float rotateAngle = 0;
private int limite = 0;
private Paint arcPaint;
private float STROKE_WITH_VP = 3f;
public RoundProgressBar(Context context) {
this(context, null);
}
public RoundProgressBar(Context context, AttrSet attrSet) {
this(context, attrSet, "");
}
public RoundProgressBar(Context context, AttrSet attrSet, String styleName) {
super(context, attrSet, styleName);
DisplayManager displayManager = DisplayManager.getInstance();
Display display = displayManager.getDefaultDisplay(this.getContext()).get();
displayAttributes = display.getAttributes();
setAttributes(attrSet);
addDrawTask(this);
initPaint();
}
protected void initPaint() {
try {
arcPaint = new Paint();
arcPaint.setAntiAlias(true);
arcPaint.setStyle(Paint.Style.STROKE_STYLE);
} catch (Exception e) {
Utils.error(label, e.getMessage());
}
}
protected void setAttributes(AttrSet attrs) {
try {
setMinHeight(vpToPx(32, displayAttributes));
setMinWidth(vpToPx(32, displayAttributes));
if (attrs != null) {
String background = null;
if (background != null) {
setBackgroundColor(Color.getIntColor(background));
}
backgroundColor = getColor(attrs, "round_progress_color", backgroundColor);
STROKE_WITH_VP = getFloat(attrs, "round_progress_with", STROKE_WITH_VP);
}
setMinHeight(vpToPx(3, displayAttributes));
} catch (Exception e) {
Utils.error(label, e.getMessage());
}
}
private void drawAnimation(Canvas canvas) {
try {
int halfWidth = getWidth() / 2;
int halfHeight = getHeight() / 2;
if (arcO == limite) {
arcD += 6;
}
if (arcD >= 290 || arcO > limite) {
arcO += 6;
arcD -= 6;
}
if (arcO > limite + 290) {
limite = arcO;
arcO = limite;
arcD = 1;
}
rotateAngle += 4;
canvas.rotate(rotateAngle, halfWidth, halfHeight);
int strokeWith = vpToPx(STROKE_WITH_VP, displayAttributes);
int halfStrokeWith = vpToPx(STROKE_WITH_VP / 2f, displayAttributes);
arcPaint.setStrokeWidth(strokeWith);
arcPaint.setColor(new Color(backgroundColor));
canvas.drawArc(new RectFloat(halfStrokeWith, halfStrokeWith, getWidth() - halfStrokeWith, getHeight() - halfStrokeWith),
new Arc(arcO, arcD, false), arcPaint);
getContext().getUITaskDispatcher().asyncDispatch(this::invalidate);
} catch (Exception e) {
Utils.error(label, e.getMessage());
}
}
public void setBackgroundColor(int color) {
backgroundColor = color;
getContext().getUITaskDispatcher().asyncDispatch(this::invalidate);
}
@Override
public void onDraw(Component component, Canvas canvas) {
drawAnimation(canvas);
}
}

View File

@ -0,0 +1,59 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
public class SHistoryContactor {
private String searchValue;
private int searchIcon = -1;
private int removeIcon = -1;
public SHistoryContactor(String searchValue, int searchIcon, int removeIcon) {
this.searchValue = searchValue;
this.searchIcon = searchIcon;
this.removeIcon = removeIcon;
}
public SHistoryContactor(String searchValue) {
this.searchValue = searchValue;
this.searchIcon = -3;
this.removeIcon = -3;
}
public String getSearchValue() {
return searchValue;
}
public void setSearchValue(String searchValue) {
this.searchValue = searchValue;
}
public int getSearchIcon() {
return searchIcon;
}
public void setSearchIcon(int searchIcon) {
this.searchIcon = searchIcon;
}
public int getRemoveIcon() {
return removeIcon;
}
public void setRemoveIcon(int removeIcon) {
this.removeIcon = removeIcon;
}
}

View File

@ -0,0 +1,99 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
public class SRContactor {
private String title = null;
private String message = null;
private String bt1 = null;
private String bt2 = null;
private String bt3 = null;
private String bt4 = null;
public SRContactor(String title, String message, String bt1, String bt2, String bt3, String bt4) {
this.title = title;
this.message = message;
this.bt1 = bt1;
this.bt2 = bt2;
this.bt3 = bt3;
this.bt4 = bt4;
}
public SRContactor(String title, String bt1, String bt2, String bt3, String bt4) {
this.title = title;
this.bt1 = bt1;
this.bt2 = bt2;
this.bt3 = bt3;
this.bt4 = bt4;
}
public SRContactor(String title, String message) {
this.title = title;
this.message = message;
}
public String getBt1() {
return bt1;
}
public void setBt1(String bt1) {
this.bt1 = bt1;
}
public String getBt2() {
return bt2;
}
public void setBt2(String bt2) {
this.bt2 = bt2;
}
public String getBt3() {
return bt3;
}
public void setBt3(String bt3) {
this.bt3 = bt3;
}
public String getBt4() {
return bt4;
}
public void setBt4(String bt4) {
this.bt4 = bt4;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public String getCXinxi() {
return title + message;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,158 @@
/*
* Copyright 2022 田梓萱, xcl@xuegao-tzx.top
*
* Licensed under the GNU Affero General Public License, Version 3.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.gnu.org/licenses/agpl-3.0.txt
*
* 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.xcl.supersearch;
import ohos.agp.colors.RgbColor;
import ohos.agp.components.Attr;
import ohos.agp.components.AttrSet;
import ohos.agp.components.element.Element;
import ohos.agp.components.element.ShapeElement;
import ohos.agp.utils.Color;
import ohos.agp.window.service.DisplayAttributes;
import ohos.global.resource.ResourceManager;
import ohos.hiviewdfx.HiLog;
import ohos.hiviewdfx.HiLogLabel;
import java.util.Optional;
public class Utils {
public static boolean pd_pd = false;
public static boolean iswear = false;
static ResourceManager resManager;
public static boolean getBoolean(AttrSet attrSet, String attrName, boolean defaultValue) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultValue;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultValue;
}
return attrOptional.get().getBoolValue();
}
public static float getFloat(AttrSet attrSet, String attrName, float defaultValue) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultValue;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultValue;
}
return attrOptional.get().getFloatValue();
}
public static int getColor(AttrSet attrSet, String attrName, int defaultColor) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultColor;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultColor;
}
return attrOptional.get().getColorValue().getValue();
}
public static int getDimension(AttrSet attrSet, String attrName, int defaultValue) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultValue;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultValue;
}
return attrOptional.get().getDimensionValue() * 3;
}
public static Element getElement(AttrSet attrSet, String attrName, Element defaultElement) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultElement;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultElement;
}
return attrOptional.get().getElement();
}
public static int vpToPx(float vp, DisplayAttributes displayAttributes) {
return (int) (vp * displayAttributes.densityPixels + 0.5f);
}
public static String getString(AttrSet attrSet, String attrName, String defaultValue) {
if (attrSet == null || attrName == null || attrName.isEmpty()) {
return defaultValue;
}
Optional<Attr> attrOptional = attrSet.getAttr(attrName);
if (attrOptional == null || !attrOptional.isPresent()) {
return defaultValue;
}
return attrOptional.get().getStringValue();
}
public static String HQString(int a1) {
try {
String text = resManager.getElement(a1).getString();
return text;
} catch (Exception e) {
return e.getMessage();
}
}
public static Element adjustColorAlpha(int color, float alpha) {
final int alphaChannel = (int) (255 * alpha);
final int redChannel = (color >> 16) & 0xFF;
final int greenChannel = (color >> 8) & 0xFF;
final int blueChannel = color & 0xFF;
ShapeElement element = new ShapeElement();
element.setAlpha(alphaChannel);
element.setRgbColor(RgbColor.fromArgbInt(Color.rgb(redChannel, greenChannel, blueChannel)));
return element;
}
public static void info(HiLogLabel label, String message) {
if (pd_pd) {
HiLog.info(label, "信息:[" + message + "]");
}
}
public static void warn(HiLogLabel label, String message) {
if (pd_pd) {
HiLog.warn(label, "警告:[" + message + "]");
}
}
public static void error(HiLogLabel label, String message) {
if (pd_pd) {
HiLog.error(label, "错误:[" + message + "]");
}
}
public static void debug(HiLogLabel label, String message) {
if (pd_pd) {
HiLog.debug(label, "调试:[" + message + "]");
}
}
protected int makePressColor(int backgroundColor) {
int r = (backgroundColor >> 16) & 0xFF;
int g = (backgroundColor >> 8) & 0xFF;
int b = (backgroundColor) & 0xFF;
return Color.argb(128, r, g, b);
}
}

View File

@ -0,0 +1,40 @@
{
"string": [
{
"name": "searchmr",
"value": "搜索默认页面"
},
{
"name": "withoutSug",
"value": "无建议搜索"
},
{
"name": "recentSug",
"value": "有最近建议搜索"
},
{
"name": "hasknownSug",
"value": "有已知建议搜索"
},
{
"name": "suggestion_text",
"value": "建议文本"
},
{
"name": "search_hint_text",
"value": "搜索..."
},
{
"name": "search_hint_text_",
"value": "搜索."
},
{
"name": "search_input_null",
"value": "搜索值为空"
},
{
"name": "search_answer_none",
"value": "搜索结果为空"
}
]
}

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid ohos:color="#FFF3ECEC"/>
<stroke
ohos:width="1.7vp"
ohos:color="#33999999"/>
<corners
ohos:radius="15vp"/>
</shape>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:shape="rectangle">
<solid ohos:color="#FFFFFF"/>
<stroke
ohos:width="1vp"
ohos:color="#33999999"/>
<corners
ohos:radius="3vp"/>
</shape>

View File

@ -0,0 +1,12 @@
<!-- drawable/magnify.xml -->
<vector
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="24vp"
ohos:width="24vp"
ohos:viewportHeight="24"
ohos:viewportWidth="24">
<path
ohos:fillColor="#657786"
ohos:pathData="M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z"/>
</vector>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="48vp"
ohos:width="match_parent"
ohos:alignment="vertical_center"
ohos:orientation="horizontal"
>
<Image
ohos:id="$+id:iconIv"
ohos:height="48vp"
ohos:width="48vp"
ohos:padding="12vp"
ohos:scale_mode="zoom_center"
/>
<Text
ohos:id="$+id:textTv"
ohos:height="match_parent"
ohos:width="0vp"
ohos:end_margin="16vp"
ohos:max_text_lines="1"
ohos:multiple_lines="false"
ohos:start_margin="16vp"
ohos:text="$string:suggestion_text"
ohos:text_alignment="vertical_center"
ohos:text_color="#000000"
ohos:text_size="14fp"
ohos:truncation_mode="ellipsis_at_end"
ohos:weight="1"
/>
<StackLayout
ohos:id="$+id:removeBtnWrapperFl"
ohos:height="48vp"
ohos:width="48vp"
ohos:align_parent_end="true"
>
<Image
ohos:id="$+id:removeBtnIv"
ohos:height="30vp"
ohos:width="30vp"
ohos:layout_alignment="center"
ohos:padding="5vp"
ohos:scale_mode="zoom_center"
/>
</StackLayout>
</DirectionalLayout>

View File

@ -0,0 +1,53 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="22vp"
ohos:width="match_parent"
ohos:alignment="vertical_center"
ohos:orientation="horizontal"
>
<Image
ohos:id="$+id:iconIv"
ohos:height="20vp"
ohos:width="20vp"
ohos:padding="1vp"
ohos:scale_mode="zoom_center"
/>
<Text
ohos:id="$+id:textTv"
ohos:height="match_parent"
ohos:width="0vp"
ohos:end_margin="16vp"
ohos:max_text_lines="1"
ohos:multiple_lines="false"
ohos:start_margin="13vp"
ohos:text="$string:suggestion_text"
ohos:text_alignment="vertical_center"
ohos:text_color="#000000"
ohos:text_size="13fp"
ohos:truncation_mode="ellipsis_at_end"
ohos:weight="1"
/>
<StackLayout
ohos:id="$+id:removeBtnWrapperFl"
ohos:height="22vp"
ohos:width="22vp"
ohos:align_parent_end="true"
>
<Image
ohos:id="$+id:removeBtnIv"
ohos:height="20vp"
ohos:width="20vp"
ohos:layout_alignment="center"
ohos:padding="1vp"
ohos:scale_mode="zoom_center"
/>
</StackLayout>
</DirectionalLayout>

View File

@ -0,0 +1,124 @@
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/app/res/ohos"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="$graphic:background_search_view"
ohos:clickable="true"
ohos:orientation="vertical">
<DependentLayout
ohos:height="48vp"
ohos:width="match_parent">
<StackLayout
ohos:id="$+id:leftContainerFl"
ohos:height="48vp"
ohos:width="48vp"
ohos:align_parent_start="true"
>
<Image
ohos:id="$+id:leftBtnIv"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:padding="11vp"
ohos:scale_mode="zoom_center"
/>
<com.xcl.supersearch.RoundProgressBar
ohos:id="$+id:progressBar"
ohos:height="24vp"
ohos:width="24vp"
ohos:layout_alignment="center"
ohos:visibility="hide"
app:progress_color="#657786"
app:progress_with="2f"
/>
</StackLayout>
<TextField
ohos:id="$+id:inputEt"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:bubble_height="0vp"
ohos:end_margin="16vp"
ohos:end_of="$+id:leftContainerFl"
ohos:input_enter_key_type="enter_key_type_search"
ohos:multiple_lines="false"
ohos:start_margin="13vp"
ohos:start_of="$+id:inputBtnsContainerFl"
ohos:text_alignment="vertical_center"
ohos:text_size="16fp"
ohos:text_weight="700"
/>
<DirectionalLayout
ohos:id="$+id:inputBtnsContainerFl"
ohos:height="48vp"
ohos:width="match_content"
ohos:align_parent_end="true"
ohos:orientation="horizontal"
>
<Image
ohos:id="$+id:clearInputBtnIv"
ohos:height="match_parent"
ohos:width="48vp"
ohos:layout_alignment="center"
ohos:padding="11vp"
ohos:scale_mode="zoom_center"
ohos:visibility="hide"
/>
<Image
ohos:id="$+id:imgSearch"
ohos:height="match_parent"
ohos:width="48vp"
ohos:image_src="$graphic:ic_search"
ohos:layout_alignment="center"
ohos:padding="11vp"
ohos:scale_mode="zoom_center"
ohos:visibility="hide"
/>
<Image
ohos:id="$+id:rightBtnIv"
ohos:height="match_parent"
ohos:width="48vp"
ohos:image_src="$graphic:ic_search"
ohos:layout_alignment="center"
ohos:padding="11vp"
ohos:scale_mode="zoom_center"
/>
</DirectionalLayout>
</DependentLayout>
<DirectionalLayout
ohos:id="$+id:suggestionsContainerLl"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="vertical"
ohos:top_margin="48vp"
>
<Component
ohos:id="$+id:divider"
ohos:height="0.75vp"
ohos:width="match_parent"
ohos:background_element="#BCBCBC"/>
<ListContainer
ohos:id="$+id:suggestionsRecyclerView"
ohos:height="match_content"
ohos:width="match_parent"
ohos:scrollbar_background_color="#00000000"/>
</DirectionalLayout>
</DependentLayout>

View File

@ -0,0 +1,125 @@
<?xml version="1.0" encoding="utf-8"?>
<DependentLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
xmlns:app="http://schemas.huawei.com/app/res/ohos"
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="$graphic:background_search_view"
ohos:clickable="true"
ohos:orientation="vertical">
<DependentLayout
ohos:height="22vp"
ohos:width="match_parent">
<StackLayout
ohos:id="$+id:leftContainerFl"
ohos:height="20vp"
ohos:width="20vp"
ohos:align_parent_start="true"
>
<Image
ohos:id="$+id:leftBtnIv"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:padding="1.5vp"
ohos:scale_mode="zoom_center"
/>
<com.xcl.supersearch.RoundProgressBar
ohos:id="$+id:progressBar"
ohos:height="16vp"
ohos:width="16vp"
ohos:layout_alignment="center"
ohos:visibility="hide"
app:progress_color="#657786"
app:progress_with="2f"
/>
</StackLayout>
<TextField
ohos:id="$+id:inputEt"
ohos:height="match_parent"
ohos:width="match_parent"
ohos:bubble_height="0vp"
ohos:end_margin="16vp"
ohos:end_of="$+id:leftContainerFl"
ohos:input_enter_key_type="enter_key_type_search"
ohos:multiple_lines="false"
ohos:start_margin="10vp"
ohos:start_of="$+id:inputBtnsContainerFl"
ohos:text_alignment="vertical_center"
ohos:text_size="13fp"
ohos:text_weight="700"
/>
<DirectionalLayout
ohos:id="$+id:inputBtnsContainerFl"
ohos:height="22vp"
ohos:width="match_content"
ohos:align_parent_end="true"
ohos:orientation="horizontal"
>
<Image
ohos:id="$+id:clearInputBtnIv"
ohos:height="match_parent"
ohos:width="20vp"
ohos:layout_alignment="center"
ohos:padding="1vp"
ohos:scale_mode="zoom_center"
ohos:visibility="hide"
/>
<Image
ohos:id="$+id:imgSearch"
ohos:height="match_parent"
ohos:width="20vp"
ohos:image_src="$graphic:ic_search"
ohos:layout_alignment="center"
ohos:padding="1vp"
ohos:scale_mode="zoom_center"
ohos:visibility="hide"
/>
<Image
ohos:id="$+id:rightBtnIv"
ohos:height="match_parent"
ohos:width="20vp"
ohos:image_src="$graphic:ic_search"
ohos:layout_alignment="center"
ohos:padding="1vp"
ohos:scale_mode="zoom_center"
/>
</DirectionalLayout>
</DependentLayout>
<DirectionalLayout
ohos:id="$+id:suggestionsContainerLl"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="vertical"
ohos:top_margin="22vp"
>
<Component
ohos:id="$+id:divider"
ohos:height="0.5vp"
ohos:width="match_parent"
ohos:background_element="#BCBCBC"/>
<ListContainer
ohos:id="$+id:suggestionsRecyclerView"
ohos:height="match_content"
ohos:width="match_parent"
ohos:scrollbar_background_color="#00000000"/>
</DirectionalLayout>
</DependentLayout>

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="vertical"
ohos:padding="1.5vp"
>
<DirectionalLayout
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="$graphic:background_list_item"
ohos:orientation="horizontal"
>
<DirectionalLayout
ohos:height="55vp"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="vertical"
ohos:weight="1"
>
<Text
ohos:id="$+id:title"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="center"
ohos:text="标题"
ohos:text_color="#FF2F2A2A"
ohos:text_size="23vp"
ohos:weight="2"
/>
<Text
ohos:id="$+id:message"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="center"
ohos:text="信息"
ohos:text_color="#FF2F2A2A"
ohos:text_size="18vp"
ohos:weight="1"
/>
</DirectionalLayout>
<DirectionalLayout
ohos:height="55vp"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="horizontal"
ohos:weight="2.3"
>
<Button
ohos:id="$+id:button1"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮1"
ohos:text_color="#EB1F1818"
ohos:text_size="20vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button2"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮2"
ohos:text_color="#EB1F1818"
ohos:text_size="20vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button3"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮3"
ohos:text_color="#EB1F1818"
ohos:text_size="20vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button4"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮4"
ohos:text_color="#EB1F1818"
ohos:text_size="20vp"
ohos:weight="1"
/>
</DirectionalLayout>
</DirectionalLayout>
<DirectionalLayout
ohos:height="2vp"
ohos:width="match_parent"
ohos:orientation="horizontal"
>
</DirectionalLayout>
</DirectionalLayout>

View File

@ -0,0 +1,109 @@
<?xml version="1.0" encoding="utf-8"?>
<DirectionalLayout
xmlns:ohos="http://schemas.huawei.com/res/ohos"
ohos:height="match_content"
ohos:width="match_parent"
ohos:orientation="vertical"
ohos:padding="0.5vp"
>
<DirectionalLayout
ohos:height="match_content"
ohos:width="match_parent"
ohos:background_element="$graphic:background_list_item"
ohos:orientation="horizontal"
>
<DirectionalLayout
ohos:height="25vp"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="vertical"
ohos:weight="1"
>
<Text
ohos:id="$+id:title"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="center"
ohos:text="标题"
ohos:text_color="#FF2F2A2A"
ohos:text_size="12vp"
ohos:weight="2"
/>
<Text
ohos:id="$+id:message"
ohos:height="match_content"
ohos:width="match_content"
ohos:layout_alignment="center"
ohos:text="信息"
ohos:text_color="#FF2F2A2A"
ohos:text_size="9vp"
ohos:weight="1"
/>
</DirectionalLayout>
<DirectionalLayout
ohos:height="25vp"
ohos:width="match_parent"
ohos:alignment="center"
ohos:orientation="horizontal"
ohos:weight="2"
>
<Button
ohos:id="$+id:button1"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮1"
ohos:text_color="#EB1F1818"
ohos:text_size="11vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button2"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮2"
ohos:text_color="#EB1F1818"
ohos:text_size="11vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button3"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮3"
ohos:text_color="#EB1F1818"
ohos:text_size="11vp"
ohos:weight="1"
/>
<Button
ohos:id="$+id:button4"
ohos:height="match_content"
ohos:width="match_parent"
ohos:layout_alignment="center"
ohos:text="按钮4"
ohos:text_color="#EB1F1818"
ohos:text_size="11vp"
ohos:weight="1"
/>
</DirectionalLayout>
</DirectionalLayout>
<DirectionalLayout
ohos:height="2vp"
ohos:width="match_parent"
ohos:orientation="horizontal"
>
</DirectionalLayout>
</DirectionalLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 528 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 680 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 752 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 589 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 630 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 903 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1008 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 451 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 429 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 490 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 532 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -0,0 +1,40 @@
{
"string": [
{
"name": "searchmr",
"value": "SEARCH DEFAULT PAGE"
},
{
"name": "withoutSug",
"value": "NO SUGGESTED SEARCH"
},
{
"name": "recentSug",
"value": "HAS RECENT SUGGESTED SEARCHES"
},
{
"name": "hasknownSug",
"value": "HAS KNOWN SUGGESTED SEARCHES"
},
{
"name": "suggestion_text",
"value": "Suggestion Text"
},
{
"name": "search_hint_text",
"value": "Searching..."
},
{
"name": "search_hint_text_",
"value": "Search ."
},
{
"name": "search_input_null",
"value": "Search Text is Null"
},
{
"name": "search_answer_none",
"value": "Search Answer is None"
}
]
}

View File

@ -0,0 +1,40 @@
{
"string": [
{
"name": "searchmr",
"value": "搜索默认页面"
},
{
"name": "withoutSug",
"value": "无建议搜索"
},
{
"name": "recentSug",
"value": "有最近建议搜索"
},
{
"name": "hasknownSug",
"value": "有已知建议搜索"
},
{
"name": "suggestion_text",
"value": "建议文本"
},
{
"name": "search_hint_text",
"value": "搜索..."
},
{
"name": "search_hint_text_",
"value": "搜索."
},
{
"name": "search_input_null",
"value": "搜索值为空"
},
{
"name": "search_answer_none",
"value": "搜索结果为空"
}
]
}

View File

@ -0,0 +1,9 @@
package com.xcl.supersearch;
import org.junit.Test;
public class ExampleTest {
@Test
public void onStart() {
}
}