diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000000000000000000000000000000000000..af9e8247f6daaec491bfb73592d0b8b55cebd845 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,44 @@ +## 0.0.1-SNAPSHOT +* refactor: For module library Android-to-OpenHarmony + +## v2.0.7-beta +* add file + +## v2.0.7 +* v2.0.7发布 + +## v2.0.6 +* Merge remote-tracking branch 'remotes/origin/dev' + + +## v2.0.5 +* Merge remote-tracking branch 'origin/master' + + +## v2.0.4 +* Merge remote-tracking branch 'remotes/origin/dev' + + +## v2.0.3 +* Merge pull request #17 from zfman/dev v2.0.3 + + +## v2.0.2 +* Update README.md + + +## v2.0.1 +* Update README.md + + +## v1.0.4 +* modify readme + + +## v1.0.0 +* Update README.md + + +## v1.0.1 +* Update README.md + diff --git a/README.md b/README.md index 9122fe62738517e7451ea68b3bb1ad13c8e1c86e..6f7efb24c84ea065f5d24522229fcc92c3ba7038 100644 --- a/README.md +++ b/README.md @@ -29,7 +29,7 @@ - 课程颜色可指定 #### 效果演示 -![输入图片说明](https://images.gitee.com/uploads/images/2021/0415/175209_4c600fae_8784697.png "screenshot_20210415174728114.png") +![](https://images.gitee.com/uploads/images/2021/0415/175209_4c600fae_8784697.png "截图.PNG") #### 安装教程 @@ -346,7 +346,9 @@ XML中添加控件: ``` ##### 基础能力 -###### 配置属性 + + **配置属性** + 我直接把这部分整个代码放出来了,分以下三步: 1. 获取控件 @@ -435,7 +437,8 @@ XML中添加控件: } ``` -###### 删除课程 +**删除课程** + ```java /** @@ -454,7 +457,8 @@ XML中添加控件: ``` -###### 添加课程 +**添加课程** + ```java /** @@ -473,7 +477,8 @@ XML中添加控件: } ``` -###### 非本周课程显示与隐藏 +**非本周课程显示与隐藏** + ```java /** @@ -497,7 +502,8 @@ XML中添加控件: } ``` -###### 最大节次设置 +**最大节次设置** + ```java /** @@ -510,7 +516,8 @@ XML中添加控件: ``` -###### 节次时间显示与隐藏 +**节次时间显示与隐藏** + ```java /** @@ -536,7 +543,8 @@ XML中添加控件: } ``` -###### WeekView显示与隐藏 +**WeekView显示与隐藏** + ```java /** @@ -554,7 +562,8 @@ XML中添加控件: } ``` -###### 月份宽度设置 +**月份宽度设置** + ```java /** @@ -573,7 +582,8 @@ XML中添加控件: ``` -###### 周末显示与隐藏 +**周末显示与隐藏** + ```java /** @@ -594,7 +604,8 @@ XML中添加控件: ##### 周次选择控件 周次选择栏WeekView是控件实现的一个默认的周次选择控件,你可以使用它快速的拥有周次选择功能,TimetableView`本身是没有周次选择功能的,所以需要两者配合使用,完整代码参见 BaseFuncSlice -###### 默认的周次选择栏 +**默认的周次选择栏** + 1.添加控件 @@ -654,7 +665,8 @@ XML中添加控件: .showView(); ``` -###### 自定义周次选择栏 +**自定义周次选择栏** + 你可以选择以下方法来实现周次选择栏的自定义: - 任意定制,因为周次选择栏和课表是没有关系的,所以你可以任意实现 @@ -665,7 +677,8 @@ XML中添加控件: 本节主要演示如何对日期栏的属性设置以及自定义日期栏的步骤,通用步骤比如:添加控件、获取控件,设置数据源以及显示视图什么的都不再重复了,只讲解核心部分 完整代码参见 DateSlice -###### 日期栏显示与隐藏 +**日期栏显示与隐藏** + ```java /** @@ -684,7 +697,8 @@ XML中添加控件: ``` -###### 恢复默认日期栏 +**恢复默认日期栏** + ```java /** @@ -696,7 +710,7 @@ XML中添加控件: } ``` -###### 自定义日期栏 +**自定义日期栏** Step1:自定义布局 @@ -790,7 +804,7 @@ Step2:自定义实现类 ``` -###### 日期延迟显示案例 +**日期延迟显示案例** 需求:设定一个开学时间,在开学时间到来之前,一直显示开学时的第一周的日期 @@ -987,7 +1001,7 @@ Step2:自定义实现类 在课程视图的左侧有一列是侧边栏,本节演示如何对侧边栏的属性进行配置以及自定义侧边栏的步骤 完整代码参见 SlideSlice -###### 准备 +**准备** 添加控件 @@ -1019,7 +1033,7 @@ Step2:自定义实现类 } ``` -###### 节次时间显示与隐藏 +**节次时间显示与隐藏** ```java @@ -1049,7 +1063,7 @@ Step2:自定义实现类 } ``` -###### 修改侧边栏背景 +**修改侧边栏背景** ```java @@ -1066,7 +1080,7 @@ Step2:自定义实现类 } ``` -###### 修改节次文本颜色 +**修改节次文本颜色** ```java @@ -1082,7 +1096,7 @@ Step2:自定义实现类 } ``` -###### 修改时间文本颜色 +**修改时间文本颜色** ```java @@ -1100,7 +1114,7 @@ Step2:自定义实现类 } ``` -###### 侧边栏效果重置 +**侧边栏效果重置** ```java @@ -1114,7 +1128,7 @@ Step2:自定义实现类 } ``` -###### 自定义侧边栏 +**自定义侧边栏** Step1:创建布局 @@ -1174,7 +1188,7 @@ Step2:设置监听 本节将演示如何配置课程项的样式,完整代码参见 ItemStyleSlice -###### 非本周课程显示与隐藏 +**非本周课程显示与隐藏** ```java @@ -1197,7 +1211,7 @@ Step2:设置监听 } ``` -###### 设置间距以及弧度 +**设置间距以及弧度** ```java @@ -1213,7 +1227,7 @@ Step2:设置监听 } ``` -###### 设置单个角弧度 +**设置单个角弧度** ```java @@ -1241,7 +1255,7 @@ Step2:设置监听 } ``` -###### 修改显示的文本 +**修改显示的文本** ```java @@ -1264,7 +1278,7 @@ Step2:设置监听 ``` -###### 设置非本周课的背景 +**设置非本周课的背景** ```java @@ -1279,7 +1293,7 @@ Step2:设置监听 } ``` -###### 课程重叠的样式 +**课程重叠的样式** ```java @@ -1304,32 +1318,7 @@ Step2:设置监听 } ``` -###### 课程重叠的样式 - -```java - - /** - * 修改课程重叠的样式,在该接口中,你可以自定义出很多的效果 - */ - protected void modifyOverlayStyle() { - mTimetableView.callback(new OnItemBuildAdapter() { - @Override - public void onItemUpdate(StackLayout layout, Text textView, Text countTextView, Schedule schedule, ShapeElement gd) { - super.onItemUpdate(layout, textView, countTextView, schedule, gd); - /** - * 可见说明重叠,取消角标,添加角度 - */ - if (countTextView.getVisibility() == Component.VISIBLE) { - countTextView.setVisibility(Component.HIDE); - gd.setCornerRadiiArray(new float[]{0, 0, 20, 20, 0, 0, 0, 0}); - } - } - }); - mTimetableView.updateView(); - } -``` - -###### 添加广告 +**添加广告** 广告一般是一张图片和一个链接,所以整体思路是这样的,首先向数据集里插入一条数据,数据的名字可以任意,但是必须和普通课程有所区分,根据这个名字可以判断出它是广告,然后给该数据设置上课周次、开始节次、持续节次;然后监听课程项的构建,如果监测到该课程是广告,那么将默认的课程布局remove掉,然后添加一个广告图片,再给它设置一个点击事件 @@ -1414,7 +1403,7 @@ Step2:设置监听 .showView(); ``` -###### 中英文切换 +**中英文切换** step1:英文日期栏 @@ -1507,12 +1496,12 @@ step3:设置监听 ##### 课程颜色管理 -###### 颜色池 +**颜色池** 颜色池ScheduleColorPool的内部实现是控件维护的一个集合,它管理着课程项的颜色,负责对颜色的存取 完整代码参见 ColorPoolSlice -###### 获取颜色池 +**获取颜色池** 以下代码的返回结果就是一个ScheduleColorPool实例对象 @@ -1521,7 +1510,7 @@ step3:设置监听 mTimetableView.colorPool(); ``` -###### 指定颜色 +**指定颜色** 如果需要让所有课程只在某几种颜色中分配颜色,只需要清空颜色池并加入特定的颜色,在分配颜色时会循环分配颜色池中的颜色 @@ -1540,7 +1529,7 @@ step3:设置监听 } ``` -###### 重置颜色池 +**重置颜色池** 重置后,颜色池恢复到初始状态 @@ -1555,7 +1544,7 @@ step3:设置监听 } ``` -###### 追加颜色 +**追加颜色** 向颜色池中追加颜色,在为课程项分配颜色时,会按照颜色池中的顺序依次取出颜色,所以并不保证追加的颜色一定会被用到 @@ -1572,7 +1561,7 @@ step3:设置监听 } ``` -###### 设置非本周课程颜色 +**设置非本周课程颜色** 向颜色池中追加颜色,在为课程项分配颜色时,会按照颜色池中的顺序依次取出颜色,所以并不保证追加的颜色一定会被用到 @@ -1589,7 +1578,7 @@ step3:设置监听 } ``` -###### 指定课程的颜色 +**指定课程的颜色** setIgnoreUserlessColor 用来设置颜色映射是否忽略非本周的课程颜色,如果设置为true,表示该课程在颜色映射中能够查找到,那么不管是本周还是非本周它都将显示映射中的颜色;如果设置为false,表示如果该课程在颜色映射中能够查找到,并且该课程是本周的,那么将该课程设置为映射中的颜色,如果非本周,则使用非本周颜色对其渲染 @@ -1614,7 +1603,7 @@ setIgnoreUserlessColor 用来设置颜色映射是否忽略非本周的课程颜 本节将演示如何实现一个有下拉反弹效果的课表界面,自定义View的知识不在本节的范围之内,有兴趣可以百度。 完整代码参见 ElasticSlice -###### 自定义View +**自定义View** 你需要先准备好一个自定义View,根据你的需求而定,可以参考以下的弹性滚动布局ElasticScrollView @@ -1768,7 +1757,7 @@ setIgnoreUserlessColor 用来设置颜色映射是否忽略非本周的课程颜 } ``` -###### 布局文件 +**布局文件** 备一个布局文件,命名任意,将以下内容复制到布局文件中,然后将根控件换成自定义控件,注意ID不能改变 @@ -1788,7 +1777,7 @@ setIgnoreUserlessColor 用来设置颜色映射是否忽略非本周的课程颜 ``` -###### 设置监听 +**设置监听** ```java @@ -1824,7 +1813,7 @@ setIgnoreUserlessColor 用来设置颜色映射是否忽略非本周的课程颜 默认情况下,旗标布局是开启状态的,即不需要任何配置,在空白格子处点击会出现旗标布局,当然,它也可以关闭。 -###### 事件监听 +**事件监听** OnSpaceItemClickListener是空白格子点击监听器,当用户点击空白格子时,会回调该接口中的方法并传入点击的格子的位置,然后需要将旗标布局移动到指定格子位置,OnSpaceItemClickAdapter是这个接口的默认实现,这部分一般不用开发者关心 @@ -1869,7 +1858,8 @@ OnSpaceItemClickListener是空白格子点击监听器,当用户点击空白 } ``` -###### 背景修改与重置 +**背景修改与重置** + ```java /** @@ -1889,7 +1879,8 @@ OnSpaceItemClickListener是空白格子点击监听器,当用户点击空白 } ``` -###### 开启与关闭 +**开启与关闭** + ```java /** @@ -1908,7 +1899,8 @@ OnSpaceItemClickListener是空白格子点击监听器,当用户点击空白 ``` -###### 显示与隐藏 +**显示与隐藏** + ```java /** @@ -1927,7 +1919,7 @@ OnSpaceItemClickListener是空白格子点击监听器,当用户点击空白 设置数据源时可以使用自定义的数据类型,但是必须实现ScheduleEnable接口,为什么呢?因为在TimetableView内部保存的数据格式是List的,接口只是起到一个转换的作用,点击事件会回调,会获取到点击位置的一个List集合,此时我们已经拿不到自定义的数据类型了,那么此时我想拿到这门课程的ID怎么办? 完整代码参见 ExtrasSlice -###### 存入额外数据 +**存入额外数据** Schedule中没有这个字段,自定义类型中有,所以在Schedule新增了一个extras字段,它是一个Map。所以现在这个问题可以这样解决: @@ -2128,7 +2120,7 @@ Schedule中没有这个字段,自定义类型中有,所以在Schedule新增 } ``` -###### 读出额外数据 +**读出额外数据** ```java @@ -2168,7 +2160,7 @@ Schedule中没有这个字段,自定义类型中有,所以在Schedule新增 控件提供了一个工具类,可以方便的以无界面的方式操作课程数据,本节演示如何使用工具类实现对课程颜色的可视化展示 完整代码参见 NonViewSlice -###### 列表与适配器 +**列表与适配器** 在Slice的布局中放一个ListContainer @@ -2347,7 +2339,7 @@ item_nonview.xml是ListView中每一项的布局,它的内容如下: ``` -###### 显示所有课程 +**显示所有课程** ```java @@ -2361,7 +2353,7 @@ item_nonview.xml是ListView中每一项的布局,它的内容如下: } ``` -###### 第一周有课的课程 +**第一周有课的课程** ```java @@ -2385,7 +2377,7 @@ item_nonview.xml是ListView中每一项的布局,它的内容如下: } ``` -###### 周一有课的课程 +**周一有课的课程** ```java @@ -2411,7 +2403,7 @@ CloudTest代码测试无异常 当前版本demo功能与安卓原组件基本无差异 -测试员:陈翔 +测试员:陈翔,朱品,邓世雄 #### 版本迭代 diff --git a/entry/build.gradle b/entry/build.gradle index 41046100f2647f120b6998a274271483e3c947f9..3881a490cfc985cc4a7ae83389bdeca4cd034653 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -11,6 +11,6 @@ dependencies { implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) implementation project(path: ':timetable') testCompile 'junit:junit:4.12' + compile project(path: ':timetable') implementation 'com.alibaba:fastjson:1.2.55' - implementation('com.gitee.chinasoft_ohos:timetable-view:0.0.1-SNAPSHOT') } diff --git a/entry/src/main/config.json b/entry/src/main/config.json index 9f1ea6bacc4ee7e236dbc48c70fcadb4d2feb2d7..68c8a339175f32c46a3cb2a77735cf922327b8b5 100644 --- a/entry/src/main/config.json +++ b/entry/src/main/config.json @@ -17,8 +17,7 @@ "package": "com.chinasoft.ohos", "name": ".MyApplication", "deviceType": [ - "phone", - "tv" + "phone" ], "reqPermissions": [ { diff --git a/entry/src/main/java/com/chinasoft/ohos/MainAbility.java b/entry/src/main/java/com/chinasoft/ohos/MainAbility.java index c1b4180c6f5e36e6ea5a22e4a9f47386c39d7d26..099fac3503ec2c1c19d893822670537fa12503bd 100644 --- a/entry/src/main/java/com/chinasoft/ohos/MainAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/MainAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos ; diff --git a/entry/src/main/java/com/chinasoft/ohos/MyApplication.java b/entry/src/main/java/com/chinasoft/ohos/MyApplication.java index a6e53dad79ebf21be032fa43c370c864328a6fda..fa0954dd87a81868e1b79140db421b8ec4f68ec5 100644 --- a/entry/src/main/java/com/chinasoft/ohos/MyApplication.java +++ b/entry/src/main/java/com/chinasoft/ohos/MyApplication.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/AttrAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/AttrAbility.java index ffef86c6bef9a4e59288d8b150a9a76ee55f0e8e..0c338a396db48be93a80bf890d16a1ebe95358ba 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/AttrAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/AttrAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/BaseFucAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/BaseFucAbility.java index 05db7cfc1910eff235fe81e9f0699c82071495ed..f65301ba7d6986f04ec281734cb5d7e6481244fa 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/BaseFucAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/BaseFucAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/ColorPoolAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/ColorPoolAbility.java index 6548574aaded042a7ba4e777afdfc0bf5b974bdc..c48f92962c3292996888c9ee178c01687ac62542 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/ColorPoolAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/ColorPoolAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/CustomWidthAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/CustomWidthAbility.java index 11dcb151aac5a6dd51adade60aa462a12495d4ad..aec39bf9aa9968d7e51ff579853376c55a6b0a0d 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/CustomWidthAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/CustomWidthAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/DateAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/DateAbility.java index 3c8eb88953aeaa5fd46b9095156ec60aa2d7992a..dd2312659b0a559f7674e3fcdc24a60c8037e2ec 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/DateAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/DateAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/DateDelayAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/DateDelayAbility.java index b49130d0cf0fcc14aeb2864b6aa33114212d9bca..dd844b810ed0ba4fb1dedf0ca4efa4a090748576 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/DateDelayAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/DateDelayAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/ElasticAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/ElasticAbility.java index e09de8e280de5e70d75c804d9bcd48acfab193c3..2690fddbf20ed8c04f6a12e09860e0f7d3b15658 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/ElasticAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/ElasticAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/ExtrasAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/ExtrasAbility.java index d24e9605140de2c3ab801b70961f9e627eb692cc..0c549c73623464a32fc34810d9bd1b39f57ab474 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/ExtrasAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/ExtrasAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/FlaglayoutAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/FlaglayoutAbility.java index 2d40661072c7cfb92fa71d0f8cf1a2a889eddc8a..684cae1a7ef05a0df8bc52b1b72aade7bbcf78c8 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/FlaglayoutAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/FlaglayoutAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/ItemStyleAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/ItemStyleAbility.java index e849d82ee6063f34a8fb9f80b00a54ffc77dc452..077174e7df5ecf2d3edc8b14b6d4aa0e4005a691 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/ItemStyleAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/ItemStyleAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/LocalConfigAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/LocalConfigAbility.java index 8724aabcc3fb4b248943c06df6ca46ecf1e89e27..5717e65f091cf8c81214922c0e6334e75c650d37 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/LocalConfigAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/LocalConfigAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/NonViewAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/NonViewAbility.java index 91c3bca39061f1a478b55cfa097ce8c36eaea747..3bab63478876abb2c999cad44d1f6ea6866e8e7c 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/NonViewAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/NonViewAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/SimpleAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/SimpleAbility.java index a550910bda457256b2819414bbef8f6706bfc1a0..2bedd6692982787bcff4606dc1763643db4ff013 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/SimpleAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/SimpleAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/ability/SlideAbility.java b/entry/src/main/java/com/chinasoft/ohos/ability/SlideAbility.java index 266b6705f716c55fbea4f4224a366cc6dfdffe05..fc3785aa1d06434d8da5385215b7d42e8da6bb29 100644 --- a/entry/src/main/java/com/chinasoft/ohos/ability/SlideAbility.java +++ b/entry/src/main/java/com/chinasoft/ohos/ability/SlideAbility.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.ability; diff --git a/entry/src/main/java/com/chinasoft/ohos/adapter/ChooseAdapter.java b/entry/src/main/java/com/chinasoft/ohos/adapter/ChooseAdapter.java new file mode 100644 index 0000000000000000000000000000000000000000..04eccf6ec0ba1fcaaacf551aba4bd42d16510839 --- /dev/null +++ b/entry/src/main/java/com/chinasoft/ohos/adapter/ChooseAdapter.java @@ -0,0 +1,106 @@ +/* + * 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.chinasoft.ohos.adapter; + + +import com.chinasoft.ohos.ResourceTable; +import com.chinasoft.ohos.bean.WeekChooseBean; +import com.chinasoft.ohos.slice.CustomWidthSlice; +import com.zhuangfei.timetable.model.Schedule; +import com.zhuangfei.timetable.model.ScheduleColorPool; +import ohos.agp.colors.RgbColor; +import ohos.agp.components.*; +import ohos.agp.components.element.PixelMapElement; +import ohos.agp.components.element.ShapeElement; +import ohos.app.Context; +import ohos.global.resource.Element; +import ohos.media.image.PixelMap; + +import java.util.ArrayList; +import java.util.List; + +/** + * Created by Liu ZhuangFei on 2018/6/18. BaseAdapter + */ +public class ChooseAdapter extends BaseItemProvider { + + ArrayList datas; + Context context; + LayoutScatter inflater; + private CheckListen checkListen; + + public ChooseAdapter(Context context, ArrayList data) { + this.context = context; + this.datas = data; + inflater = LayoutScatter.getInstance(context); + } + + @Override + public int getCount() { + return datas.size(); + } + + @Override + public Object getItem(int i) { + return datas.get(i); + } + + @Override + public long getItemId(int i) { + return i; + } + + @Override + public Component getComponent(int i, Component convertView, ComponentContainer viewGroup) { + convertView = inflater.parse(ResourceTable.Layout_item_choose, null, false); + RadioButton mRbCheck = (RadioButton) convertView.findComponentById(ResourceTable.Id_rb_check); + Text mTvCheck = (Text) convertView.findComponentById(ResourceTable.Id_tv_check); + + WeekChooseBean data = datas.get(i); + + mTvCheck.setText(data.getWeek()); + + if (data.isSelect()) { + mRbCheck.setChecked(true); + } else { + mRbCheck.setChecked(false); + } + + convertView.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + int index = i; + for (int ii = 0; ii < datas.size(); ii++) { + if (index == ii) { + datas.get(ii).setSelect(true); + } else { + datas.get(ii).setSelect(false); + } + } + notifyDataChanged(); + checkListen.check(i); + } + }); + return convertView; + } + + public void setCheckListen(CheckListen listen) { + this.checkListen = listen; + } + + public interface CheckListen { + void check(int index); + } +} diff --git a/entry/src/main/java/com/chinasoft/ohos/adapter/NonViewAdapter.java b/entry/src/main/java/com/chinasoft/ohos/adapter/NonViewAdapter.java index 57e902bab519dcd146887295412c2add056726f0..cbef109ddd5dce3fbcb00cf2c4ec20a6f6c6ef42 100644 --- a/entry/src/main/java/com/chinasoft/ohos/adapter/NonViewAdapter.java +++ b/entry/src/main/java/com/chinasoft/ohos/adapter/NonViewAdapter.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.adapter; diff --git a/entry/src/main/java/com/chinasoft/ohos/base/BaseAbilitySlice.java b/entry/src/main/java/com/chinasoft/ohos/base/BaseAbilitySlice.java index 70161aa666621b4182e93e94f82f52c8277ea3d2..e39f8be194ab0b9abc103b0ccf204545810e3b06 100644 --- a/entry/src/main/java/com/chinasoft/ohos/base/BaseAbilitySlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/base/BaseAbilitySlice.java @@ -16,6 +16,6 @@ public class BaseAbilitySlice extends AbilitySlice { @Override protected void onStart(Intent intent) { super.onStart(intent); - WindowManager.getInstance().getTopWindow().get().setStatusBarColor(Color.YELLOW.getValue()); + WindowManager.getInstance().getTopWindow().get().setStatusBarColor(Color.rgb(220,126,44)); } } diff --git a/entry/src/main/java/com/chinasoft/ohos/bean/WeekChooseBean.java b/entry/src/main/java/com/chinasoft/ohos/bean/WeekChooseBean.java new file mode 100644 index 0000000000000000000000000000000000000000..d210163e53cc6b07409fe9b51fa96724fdcd16e1 --- /dev/null +++ b/entry/src/main/java/com/chinasoft/ohos/bean/WeekChooseBean.java @@ -0,0 +1,42 @@ +package com.chinasoft.ohos.bean; + +import ohos.agp.components.RadioButton; + +/** + * author :Administrator + * date : 2021/4/19 14:32 + * package:com.chinasoft.ohos.bean + * description : + */ +public class WeekChooseBean { + private String week; + /** + * 0 未选择 1 选择 + */ + private boolean isSelect; + private RadioButton radioButton; + + public String getWeek() { + return week; + } + + public void setWeek(String week) { + this.week = week; + } + + public boolean isSelect() { + return isSelect; + } + + public void setSelect(boolean select) { + isSelect = select; + } + + public RadioButton getRadioButton() { + return radioButton; + } + + public void setRadioButton(RadioButton radioButton) { + this.radioButton = radioButton; + } +} diff --git a/entry/src/main/java/com/chinasoft/ohos/dialog/ChooseWeekDialog.java b/entry/src/main/java/com/chinasoft/ohos/dialog/ChooseWeekDialog.java new file mode 100644 index 0000000000000000000000000000000000000000..b830d69f3f368ec5dbe44e458b2a153de661d5d4 --- /dev/null +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/ChooseWeekDialog.java @@ -0,0 +1,131 @@ +/* + * 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.chinasoft.ohos.dialog; + +import com.chinasoft.ohos.ResourceTable; +import com.chinasoft.ohos.adapter.ChooseAdapter; +import com.chinasoft.ohos.bean.WeekChooseBean; +import com.zhuangfei.timetable.utils.ScreenUtils; +import ohos.agp.components.*; +import ohos.agp.utils.LayoutAlignment; +import ohos.agp.window.dialog.PopupDialog; +import ohos.app.Context; + +import java.util.ArrayList; + +/** + * ChooseWeekDialog + * + * @since 2021-03-29 + */ +public class ChooseWeekDialog{ + + private final int target; + private Context context; + private String title = null; + private ArrayList data = null; + private CancleClickListen mCancleClickListen; + private ConfimClickListen mConfimClickListen; + private int mIndex; + + public ChooseWeekDialog(Context context, int target) { + this.target = target; + this.context = context; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setData(ArrayList data) { + this.data = data; + } + + public void setCancleButton(CancleClickListen cancleClickListen) { + this.mCancleClickListen = cancleClickListen; + } + + public void setmConfimClickListen(ConfimClickListen confimClickListen) { + this.mConfimClickListen = confimClickListen; + } + + public void show() { + ComponentContainer customToastLayout = (ComponentContainer) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_choose_dialog_layout, null, false); + Text mTitle = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_title); + ListContainer listContainer = (ListContainer) customToastLayout.findComponentById(ResourceTable.Id_lv_choose); + Text mBtCancle = (Text) customToastLayout.findComponentById(ResourceTable.Id_bt_cancle); + Text mBtConfim = (Text) customToastLayout.findComponentById(ResourceTable.Id_bt_confim); + + if (title != null) { + mTitle.setText(title); + } + if (data != null) { + setAdapter(listContainer); + } + + DirectionalLayout.LayoutConfig layoutConfig = new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT,ScreenUtils.getDisplayHeight(context) / 7 * 6); + customToastLayout.setLayoutConfig(layoutConfig); + + + PopupDialog toastDialog = new PopupDialog(context, null); + toastDialog.setCustomComponent(customToastLayout); + toastDialog.setAutoClosable(false); + toastDialog.setSize(ScreenUtils.getDisplayWidth(context) / 6 * 5, DirectionalLayout.LayoutConfig.MATCH_CONTENT); + toastDialog.setAlignment(LayoutAlignment.CENTER); + toastDialog.show(); + mBtCancle.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + mCancleClickListen.onCancleClick(); + toastDialog.hide(); + } + }); + mBtConfim.setClickedListener(new Component.ClickedListener() { + @Override + public void onClick(Component component) { + mConfimClickListen.onConfimClick(mIndex); + toastDialog.hide(); + } + }); + } + + private void setAdapter(ListContainer listContainer) { + for (int i = 0; i < data.size(); i++) { + if (i == target) { + data.get(i).setSelect(true); + } else { + data.get(i).setSelect(false); + } + } + ChooseAdapter adapter = new ChooseAdapter(context, data); + adapter.setCheckListen(new ChooseAdapter.CheckListen() { + @Override + public void check(int index) { + mIndex = index; + } + }); + listContainer.setItemProvider(adapter); + listContainer.scrollTo(target); + adapter.notifyDataChanged(); + } + + public interface CancleClickListen { + void onCancleClick(); + } + + public interface ConfimClickListen { + void onConfimClick(int index); + } +} diff --git a/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java b/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java index 6b9e4381f6b1c23e39720b107611fffadcc4e8a7..99416001c8ae13f1caeafc41565063c1e64d3c79 100644 --- a/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java @@ -17,10 +17,8 @@ import ohos.app.Context; * ToastUtil * * @since 2021-03-29 - * */ public class DialogUtil { - Context context; @@ -29,7 +27,9 @@ public class DialogUtil { } - public static void show(Context context, String title,String content) { + public static void show(Context context, String title, String content, Component mBgComponent) { + mBgComponent.setVisibility(Component.VISIBLE); + ComponentContainer customToastLayout = (ComponentContainer) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_layout, null, false); Text mTitle = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_title); Text mContent = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_content); @@ -38,10 +38,11 @@ public class DialogUtil { mTitle.setText(title); mContent.setText(content); - ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(); + ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_CONTENT); customToastLayout.setLayoutConfig(layoutConfig); - PopupDialog toastDialog = new PopupDialog(context,null); + + PopupDialog toastDialog = new PopupDialog(context, null); toastDialog.setCustomComponent(customToastLayout); toastDialog.setAutoClosable(false); toastDialog.setSize(ScreenUtils.getDisplayWidth(context) / 7 * 6, DirectionalLayout.LayoutConfig.MATCH_CONTENT); @@ -53,35 +54,8 @@ public class DialogUtil { @Override public void onClick(Component component) { toastDialog.hide(); + mBgComponent.setVisibility(Component.HIDE); } }); } - - public static void showChoose(Context context, String[] item,String title) { -// ComponentContainer customToastLayout = (ComponentContainer) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_dialog_layout, null, false); -// Text mTitle = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_title); -// Text mContent = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_content); -// Text mBtConfim = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_confim); -// -// mTitle.setText(title); -// mContent.setText(content); -// -// ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(); -// customToastLayout.setLayoutConfig(layoutConfig); -// -// PopupDialog toastDialog = new PopupDialog(context,null); -// toastDialog.setCustomComponent(customToastLayout); -// toastDialog.setAutoClosable(false); -// toastDialog.setSize(ScreenUtils.getDisplayWidth(context) / 7 * 6, DirectionalLayout.LayoutConfig.MATCH_CONTENT); -// toastDialog.setAlignment(LayoutAlignment.CENTER); -// toastDialog.show(); -// -// -// mBtConfim.setClickedListener(new Component.ClickedListener() { -// @Override -// public void onClick(Component component) { -// toastDialog.hide(); -// } -// }); - } } diff --git a/entry/src/main/java/com/chinasoft/ohos/dialog/TipsDialogUtil.java b/entry/src/main/java/com/chinasoft/ohos/dialog/TipsDialogUtil.java new file mode 100644 index 0000000000000000000000000000000000000000..7c1014db7a2bce7d66012e45255c69131de5ab95 --- /dev/null +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/TipsDialogUtil.java @@ -0,0 +1,55 @@ +package com.chinasoft.ohos.dialog; + +import com.chinasoft.ohos.ResourceTable; +import com.zhuangfei.timetable.utils.ScreenUtils; +import ohos.agp.colors.RgbColor; +import ohos.agp.components.*; +import ohos.agp.components.element.ShapeElement; +import ohos.agp.utils.Color; +import ohos.agp.utils.LayoutAlignment; +import ohos.agp.window.dialog.BaseDialog; +import ohos.agp.window.dialog.PopupDialog; +import ohos.app.Context; + +/** + * ToastUtil + * + * @since 2021-03-29 + */ +public class TipsDialogUtil { + private PopupDialog toastDialog; + Context context; + + + public TipsDialogUtil(Context context) { + this.context = context; + toastDialog = new PopupDialog(context, null); + } + + /** + * + * @param context + * @param title + * @param content + */ + public void show(Context context, String title, String content) { + ComponentContainer customToastLayout = (ComponentContainer) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_tips_dialog_layout, null, false); + Text mTitle = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_title); + Text mContent = (Text) customToastLayout.findComponentById(ResourceTable.Id_tv_content); + + mTitle.setText(title); + mContent.setText(content); + + + toastDialog.setCustomComponent(customToastLayout); + toastDialog.setAutoClosable(false); + toastDialog.setTransparent(true); + toastDialog.setSize(ScreenUtils.getDisplayWidth(context) / 7 * 6, DirectionalLayout.LayoutConfig.MATCH_CONTENT); + toastDialog.setAlignment(LayoutAlignment.CENTER); + toastDialog.show(); + } + + public void dismiss() { + toastDialog.hide(); + } +} diff --git a/entry/src/main/java/com/chinasoft/ohos/dialog/ToastUtil.java b/entry/src/main/java/com/chinasoft/ohos/dialog/ToastUtil.java index 68c086809ac17a85d8b32c223bf879bb5906438b..619e6d943f22290adce37852aec1b9a98b06ff65 100644 --- a/entry/src/main/java/com/chinasoft/ohos/dialog/ToastUtil.java +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/ToastUtil.java @@ -1,6 +1,7 @@ package com.chinasoft.ohos.dialog; import com.chinasoft.ohos.ResourceTable; +import com.zhuangfei.timetable.utils.ScreenUtils; import ohos.agp.components.*; import ohos.agp.utils.LayoutAlignment; import ohos.agp.window.dialog.ToastDialog; @@ -78,12 +79,17 @@ public class ToastUtil { Text textView = (Text) customToastLayout.findComponentById(ResourceTable.Id_toast_text); textView.setText(text); + + DirectionalLayout.LayoutConfig layoutConfig = new DirectionalLayout.LayoutConfig(DirectionalLayout.LayoutConfig.MATCH_PARENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT); + layoutConfig.setMarginBottom(50); + customToastLayout.setLayoutConfig(layoutConfig); + ToastDialog toastDialog = new ToastDialog(context); toastDialog.setComponent(customToastLayout); toastDialog.setCornerRadius(radius); - toastDialog.setDuration(2000); + toastDialog.setDuration(5000); toastDialog.setSize(ComponentContainer.LayoutConfig.MATCH_CONTENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT); - toastDialog.setAlignment(LayoutAlignment.BOTTOM); + toastDialog.setAlignment(LayoutAlignment.BOTTOM|LayoutAlignment.HORIZONTAL_CENTER); toastDialog.show(); } diff --git a/entry/src/main/java/com/chinasoft/ohos/dialog/ToastViewDialog.java b/entry/src/main/java/com/chinasoft/ohos/dialog/ToastViewDialog.java index 2f99210d57077b2814a7bcfcd77d57f1162c4e0b..72a68f188a9b797d92782c3252188a54d0c063e7 100644 --- a/entry/src/main/java/com/chinasoft/ohos/dialog/ToastViewDialog.java +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/ToastViewDialog.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.dialog; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/AttrSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/AttrSlice.java index fbe73020ecf59a79632deb498aac38ceefab7994..a0f945b6acfb30a786ff7757d548ef09e671483c 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/AttrSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/AttrSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/BaseFuncSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/BaseFuncSlice.java index f10a4e5a610f6c6b1eea0bcd6cf1abe93d00fb98..8b17bc27619f34cccf3f65b51130594fa1e07422 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/BaseFuncSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/BaseFuncSlice.java @@ -1,22 +1,23 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; import com.chinasoft.ohos.ResourceTable; import com.chinasoft.ohos.base.BaseAbilitySlice; +import com.chinasoft.ohos.bean.WeekChooseBean; +import com.chinasoft.ohos.dialog.ChooseWeekDialog; import com.chinasoft.ohos.dialog.ToastViewDialog; import com.chinasoft.ohos.model.MySubject; import com.chinasoft.ohos.model.SubjectRepertory; @@ -33,9 +34,11 @@ import ohos.agp.components.Component; import ohos.agp.components.DirectionalLayout; import ohos.agp.components.Text; import ohos.agp.utils.Color; +import ohos.multimodalinput.event.KeyEvent; import ohos.utils.IntentConstants; import java.security.SecureRandom; +import java.util.ArrayList; import java.util.List; /** @@ -52,12 +55,14 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked DirectionalLayout layout; Text titleTextView; List mySubjects; + Component mBgComponent; /** * 记录切换的周次,不一定是当前周 */ int target = -1; + @Override public void onStart(Intent intent) { super.onStart(intent); @@ -71,6 +76,8 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked titleTextView = (Text) findComponentById(ResourceTable.Id_id_title); layout = (DirectionalLayout) findComponentById(ResourceTable.Id_id_layout); MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); + mBgComponent = findComponentById(ResourceTable.Id_bg_component); + mySubjects = SubjectRepertory.loadDefaultSubjects2(); mySubjects.addAll(SubjectRepertory.loadDefaultSubjects()); @@ -92,7 +99,6 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked spinner.setShowFalse(); } }); - initTimetableView(); } @@ -187,33 +193,42 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked * 对话框修改当前周次 */ protected void onWeekLeftLayoutClicked() { - final String items[] = new String[20]; + mBgComponent.setVisibility(Component.VISIBLE); + final ArrayList items = new ArrayList<>(); int itemCount = mWeekView.itemCount(); for (int i = 0; i < itemCount; i++) { - items[i] = "第" + (i + 1) + "周"; + WeekChooseBean bean = new WeekChooseBean(); + bean.setWeek("第" + (i + 1) + "周"); + if (i == 0) { + bean.setSelect(true); + }else { + bean.setSelect(false); + } + items.add(bean); } target = -1; -// AlertDialog.Builder builder = new AlertDialog.Builder(this); -// builder.setTitle("设置当前周"); -// builder.setSingleChoiceItems(items, mTimetableView.curWeek() - 1, -// new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialogInterface, int i) { -// target = i; -// } -// }); -// builder.setPositiveButton("设置为当前周", new DialogInterface.OnClickListener() { -// @Override -// public void onClick(DialogInterface dialog, int which) { -// if (target != -1) { -// mWeekView.curWeek(target + 1).updateView(); -// mTimetableView.changeWeekForce(target + 1); -// } -// } -// }); -// builder.setNegativeButton("取消", null); -// builder.create().show(); + ChooseWeekDialog chooseWeekDialog = new ChooseWeekDialog(this,mTimetableView.curWeek() - 1); + chooseWeekDialog.setTitle("设置当前周"); + chooseWeekDialog.setData(items); + chooseWeekDialog.setmConfimClickListen(new ChooseWeekDialog.ConfimClickListen() { + @Override + public void onConfimClick(int index) { + target = index; + if (target != -1) { + mWeekView.curWeek(target + 1).updateView(); + mTimetableView.changeWeekForce(target + 1); + mBgComponent.setVisibility(Component.HIDE); + } + } + }); + chooseWeekDialog.setCancleButton(new ChooseWeekDialog.CancleClickListen() { + @Override + public void onCancleClick() { + mBgComponent.setVisibility(Component.HIDE); + } + }); + chooseWeekDialog.show(); } /** @@ -393,6 +408,7 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked * 显示WeekView */ protected void showWeekView() { + mTimetableView.setShowWeekView(true); mWeekView.isShow(true); } @@ -400,6 +416,7 @@ public class BaseFuncSlice extends BaseAbilitySlice implements Component.Clicked * 隐藏WeekView */ protected void hideWeekView() { + mTimetableView.setShowWeekView(false); mWeekView.isShow(false); } diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/ColorPoolSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/ColorPoolSlice.java index 985a94782adb38247a25a19ff877aa768524a08e..d31c7f31ecc7b6029730ed3e224591f379e13007 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/ColorPoolSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/ColorPoolSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -95,28 +94,6 @@ public class ColorPoolSlice extends BaseAbilitySlice { private static final String[] SPIN_MUNE = {"指定三种颜色", "默认颜色池", "扩充颜色池", "指定课程颜色"}; - /** - * 显示弹出菜单 - */ - public void showPopmenu() { - MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); - spinner.setOnItemSelectedListener(new MaterialSpinner.OnItemSelectedListener() { - @Override - public void onItemSelected(MaterialSpinner view, int position, long id, String item) { - selectLayout(position); - spinner.setShowFalse(); - } - }); - spinner.setItems(SPIN_MUNE); - spinner.setOnNothingSelectedListener(new MaterialSpinner.OnNothingSelectedListener() { - - @Override - public void onNothingSelected(MaterialSpinner spinner) { - spinner.setShowFalse(); - } - }); - } - private void selectLayout(int position) { switch (position) { case 0: diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/CustomWidthSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/CustomWidthSlice.java index 6c97786434c3791ddad7edcdfda17f62c0e0c6db..38f94ceec29fc8855d94dbbf34089b678f87a29d 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/CustomWidthSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/CustomWidthSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/DateDelaySlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/DateDelaySlice.java index c6d418b86670ece752deeff883035fde2c24911f..06ea5aea6732d7f168b342c5a255dc69682c895f 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/DateDelaySlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/DateDelaySlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -20,6 +19,7 @@ import com.chinasoft.ohos.adapter.OnDateDelayAdapter; import com.chinasoft.ohos.base.BaseAbilitySlice; import com.chinasoft.ohos.model.MySubject; import com.chinasoft.ohos.model.SubjectRepertory; +import com.chinasoft.ohos.spinner.MaterialSpinner; import com.zhuangfei.timetable.TimetableView; import com.zhuangfei.timetable.listener.ISchedule; import ohos.aafwk.ability.AbilitySlice; @@ -50,7 +50,8 @@ public class DateDelaySlice extends BaseAbilitySlice { mySubjects = SubjectRepertory.loadDefaultSubjects(); titleTextView = (Text) findComponentById(ResourceTable.Id_id_title); mTimetableView = (TimetableView) findComponentById(ResourceTable.Id_id_timetableView); - + MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); + spinner.setShowFalse(true); initTimetableView(); data(); } diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/DateSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/DateSlice.java index 20153e432438644c8134b9e2315d78b64c5f6ff5..07c36bac1ec05bfd5b7f876bc9f93efb166a6507 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/DateSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/DateSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/ElasticSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/ElasticSlice.java index d0f38cd3032941acdd5b5fab9d8f9fa935e20280..e2f59ef25726c69cdcb17613d90975546a9909cd 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/ElasticSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/ElasticSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/ExtrasSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/ExtrasSlice.java index 7f0a3c25b7796eb1ba6007bbbe99be00340f2a93..958354466d4d3c284de08f9e2346397f94c1be9f 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/ExtrasSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/ExtrasSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -20,6 +19,7 @@ import com.chinasoft.ohos.base.BaseAbilitySlice; import com.chinasoft.ohos.dialog.ToastViewDialog; import com.chinasoft.ohos.model.MySubject; import com.chinasoft.ohos.model.SubjectRepertory; +import com.chinasoft.ohos.spinner.MaterialSpinner; import com.zhuangfei.timetable.TimetableView; import com.zhuangfei.timetable.listener.ISchedule; import com.zhuangfei.timetable.model.Schedule; @@ -42,12 +42,17 @@ public class ExtrasSlice extends BaseAbilitySlice { public void onStart(Intent intent) { super.onStart(intent); super.setUIContent(ResourceTable.Layout_ability_extras); + mySubjects = SubjectRepertory.loadDefaultSubjects(); + initViews(); } private void initViews() { mTimetableView = (TimetableView) findComponentById(ResourceTable.Id_id_timetableView); + MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); + + spinner.setShowFalse(true); mTimetableView.source(mySubjects) .curWeek(1) diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/FlaglayoutSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/FlaglayoutSlice.java index a55a70f5fc98599359380eb6635284de23fcd37e..a53efe9f103482e1fc272aa940ea153420937756 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/FlaglayoutSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/FlaglayoutSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -48,7 +47,7 @@ public class FlaglayoutSlice extends BaseAbilitySlice { showPopmenu(); } - private static final String[] SPIN_MUNE = {"点击空白格子试试","修改旗标布局背景","重置旗标布局背景","取消旗标布局","恢复旗标布局"}; + private static final String[] SPIN_MUNE = {"点击空白格子试试~","修改旗标布局背景","重置旗标布局背景","取消旗标布局","恢复旗标布局"}; public void showPopmenu() { MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/ItemStyleSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/ItemStyleSlice.java index e13b57cc8548e110eeb91abcb3fefdff5e81ea9d..7cffddd82373b85cedfa2355d591d299c929c61a 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/ItemStyleSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/ItemStyleSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -147,7 +146,7 @@ public class ItemStyleSlice extends BaseAbilitySlice { setCorner(0, 10, 0, 0); break; case 7: - setNonThisWeekBgcolor(new RgbColor(255, 255, 0)); + setNonThisWeekBgcolor(new RgbColor(255,255,0)); break; case 8: modifyOverlayStyle(); diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/LocalConfigSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/LocalConfigSlice.java index aae76cd5b98e49d4e0d110056a2763d6073d70d8..048098884fec11d84a7380479d3a229132eda8db 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/LocalConfigSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/LocalConfigSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; @@ -25,10 +24,9 @@ import com.chinasoft.ohos.model.SubjectRepertory; import com.chinasoft.ohos.spinner.MaterialSpinner; import com.zhuangfei.timetable.TimetableView; import com.zhuangfei.timetable.model.ScheduleConfig; -import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.content.Intent; +import ohos.agp.components.Component; import ohos.agp.components.Text; -import ohos.agp.window.dialog.CommonDialog; import java.util.List; import java.util.Set; @@ -43,6 +41,8 @@ public class LocalConfigSlice extends BaseAbilitySlice { TimetableView timetableView; MaterialSpinner moreButton; Text titleTextView; + private Component mBgComponent; + List mySubjects; int target = -1; boolean initFinish = false; @@ -52,6 +52,7 @@ public class LocalConfigSlice extends BaseAbilitySlice { private static final String[] SPIN_MUNE = {"加载本地配置", "清除本地配置", "导出配置至文本", "加载配置文本"}; + @Override public void onStart(Intent intent) { super.onStart(intent); @@ -63,6 +64,7 @@ public class LocalConfigSlice extends BaseAbilitySlice { timetableView = (TimetableView) findComponentById(ResourceTable.Id_id_timetableView); moreButton = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); titleTextView = (Text) findComponentById(ResourceTable.Id_id_title); + mBgComponent = findComponentById(ResourceTable.Id_bg_component); mySubjects = SubjectRepertory.loadDefaultSubjects2(); mySubjects.addAll(SubjectRepertory.loadDefaultSubjects()); @@ -162,7 +164,9 @@ public class LocalConfigSlice extends BaseAbilitySlice { for (String s : set){ content += s + "\n"; } - DialogUtil.show(this, "配置导出", content); + DialogUtil.show(this, "配置导出", content,mBgComponent); + + } /** @@ -170,7 +174,7 @@ public class LocalConfigSlice extends BaseAbilitySlice { */ private void loadLocalConfigSet() { if (configSet == null) { - DialogUtil.show(this, "配置导出", "还没有导出,先导出再来试试吧"); + DialogUtil.show(this, "配置导入", "还没有导出,先导出再来试试吧", mBgComponent); } else { mScheduleConfig.load(configSet); ToastViewDialog.toast(this, "配置已生效"); diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/MainAbilitySlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/MainAbilitySlice.java index 1d50a9f37d084e3f06a241e8a7de06e865116154..b767d6f3296b4ab861586d23ff76fe120967da64 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/MainAbilitySlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/MainAbilitySlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/NonViewSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/NonViewSlice.java index 5a3be4bdab966307a6af0e7a2b2ec2ef3fd8f23e..9857fef7468b60be45b53872fddd49b609b95ea5 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/NonViewSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/NonViewSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/SimpleSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/SimpleSlice.java index 2066ab031ff514285ad17ff4d225fbaaeeb94b31..e38e0188599f647c40508c75124a3b58b513294d 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/SimpleSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/SimpleSlice.java @@ -1,32 +1,34 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; import com.chinasoft.ohos.ResourceTable; import com.chinasoft.ohos.base.BaseAbilitySlice; +import com.chinasoft.ohos.bean.WeekChooseBean; +import com.chinasoft.ohos.dialog.ChooseWeekDialog; +import com.chinasoft.ohos.dialog.TipsDialogUtil; import com.chinasoft.ohos.dialog.ToastViewDialog; import com.chinasoft.ohos.model.MySubject; import com.chinasoft.ohos.model.SubjectRepertory; +import com.chinasoft.ohos.spinner.MaterialSpinner; import com.zhuangfei.timetable.TimetableView; import com.zhuangfei.timetable.listener.ISchedule; import com.zhuangfei.timetable.listener.IWeekView; import com.zhuangfei.timetable.listener.OnItemBuildAdapter; import com.zhuangfei.timetable.model.Schedule; import com.zhuangfei.timetable.view.WeekView; -import ohos.aafwk.ability.AbilitySlice; import ohos.aafwk.content.Intent; import ohos.agp.components.*; import ohos.agp.components.element.ShapeElement; @@ -62,11 +64,16 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi DirectionalLayout layout; Text titleTextView; List mySubjects; + private Component mBgComponent; + /** * 记录切换的周次,不一定是当前周 */ + int target = -1; + private TipsDialogUtil tipsDialogUtil; + @Override public void onStart(Intent intent) { @@ -78,9 +85,14 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi private void initViews() { titleTextView = (Text) findComponentById(ResourceTable.Id_id_title); layout = (DirectionalLayout) findComponentById(ResourceTable.Id_id_layout); + MaterialSpinner spinner = (MaterialSpinner) findComponentById(ResourceTable.Id_id_more); + mBgComponent = findComponentById(ResourceTable.Id_bg_component); + layout.setClickedListener(this); - initTimetableView(); + spinner.setShowFalse(true); + + initTimetableView(); requestData(); } @@ -111,7 +123,10 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi SimpleSlice.this.getUITaskDispatcher().asyncDispatch(() -> { mWeekView.source(mySubjects).showView(); mTimetableView.source(mySubjects).showView(); + tipsDialogUtil.dismiss(); + mBgComponent.setVisibility(Component.HIDE); }); + } }; @@ -123,6 +138,12 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi @Override public void run() { try { + SimpleSlice.this.getUITaskDispatcher().asyncDispatch(() -> { + mBgComponent.setVisibility(Component.VISIBLE); + tipsDialogUtil = new TipsDialogUtil(SimpleSlice.this); + tipsDialogUtil.show(SimpleSlice.this, "Tips", "模拟请求网络中.."); + }); + Thread.sleep(2000); } catch (InterruptedException e) { String errorString = e.toString(); @@ -257,12 +278,41 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi * 对话框修改当前周次 */ protected void onWeekLeftLayoutClicked() { - final String items[] = new String[20]; + mBgComponent.setVisibility(Component.VISIBLE); + final ArrayList items = new ArrayList(); int itemCount = mWeekView.itemCount(); for (int i = 0; i < itemCount; i++) { - items[i] = "第" + (i + 1) + "周"; + WeekChooseBean bean = new WeekChooseBean(); + bean.setWeek("第" + (i + 1) + "周"); + if (i == 0) { + bean.setSelect(true); + }else { + bean.setSelect(false); + } + items.add(bean); } - target = -1; + + ChooseWeekDialog chooseWeekDialog = new ChooseWeekDialog(this,mTimetableView.curWeek() - 1); + chooseWeekDialog.setTitle("设置当前周"); + chooseWeekDialog.setData(items); + chooseWeekDialog.setmConfimClickListen(new ChooseWeekDialog.ConfimClickListen() { + @Override + public void onConfimClick(int index) { + target = index; + if (target != -1) { + mWeekView.curWeek(target + 1).updateView(); + mTimetableView.changeWeekForce(target + 1); + mBgComponent.setVisibility(Component.HIDE); + } + } + }); + chooseWeekDialog.setCancleButton(new ChooseWeekDialog.CancleClickListen() { + @Override + public void onCancleClick() { + mBgComponent.setVisibility(Component.HIDE); + } + }); + chooseWeekDialog.show(); } /** @@ -283,7 +333,8 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi */ public void hideWeekView() { mWeekView.isShow(false); - titleTextView.setTextColor(Color.BLUE); + mTimetableView.setShowWeekView(false); + titleTextView.setTextColor(new Color(Color.rgb(19,176,241))); int cur = mTimetableView.curWeek(); mTimetableView.onDateBuildListener() .onUpdateDate(cur, cur); @@ -292,6 +343,7 @@ public class SimpleSlice extends BaseAbilitySlice implements Component.ClickedLi public void showWeekView() { mWeekView.isShow(true); + mTimetableView.setShowWeekView(true); titleTextView.setTextColor(Color.RED); } diff --git a/entry/src/main/java/com/chinasoft/ohos/slice/SlideSlice.java b/entry/src/main/java/com/chinasoft/ohos/slice/SlideSlice.java index a4f5a6ac9bdd2e5c102dceb6e05382a6e67e34ad..18dec906671a1f6fc2e616b3c2c665ff2ff1f24e 100644 --- a/entry/src/main/java/com/chinasoft/ohos/slice/SlideSlice.java +++ b/entry/src/main/java/com/chinasoft/ohos/slice/SlideSlice.java @@ -1,17 +1,16 @@ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.slice; diff --git a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinner.java b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinner.java index 8a6d7e2d3cbcf6ddd5a932ea3d41f02a5ee3fae8..24f058d2cfe615cdca7eae2a24e997ee2ca95768 100644 --- a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinner.java +++ b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinner.java @@ -16,19 +16,18 @@ */ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.spinner; @@ -163,7 +162,7 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene hideArrow = com.chinasoft.ohos.spinner.TypedAttrUtils.getBoolean(attrs, "ms_hide_arrow", false); hintText = com.chinasoft.ohos.spinner.TypedAttrUtils.getString(attrs, "ms_hint", ""); - popupWindowMaxHeight = com.chinasoft.ohos.spinner.TypedAttrUtils.getDimensionPixelSize(attrs, "ms_dropdown_max_height", 1080); + popupWindowMaxHeight = com.chinasoft.ohos.spinner.TypedAttrUtils.getDimensionPixelSize(attrs, "ms_dropdown_max_height", 1680); popupWindowHeight = com.chinasoft.ohos.spinner.TypedAttrUtils.getLayoutDimension(attrs, "ms_dropdown_height", ComponentContainer.LayoutConfig.MATCH_CONTENT); paddingTop = com.chinasoft.ohos.spinner.TypedAttrUtils.getDimensionPixelSize(attrs, "ms_padding_top", defaultPaddingTop); @@ -221,23 +220,19 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene } private void initPopupWindow(Context context) { - - listView = new ListContainer(context); - ComponentContainer.LayoutConfig layoutConfig = - new ComponentContainer.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_PARENT); + ComponentContainer customToastLayout = (ComponentContainer) LayoutScatter.getInstance(context).parse(ResourceTable.Layout_list_spinner, null, false); + listView = (ListContainer) customToastLayout.findComponentById(ResourceTable.Id_lv_spinner); + DirectionalLayout.LayoutConfig layoutConfig = + new DirectionalLayout.LayoutConfig(ComponentContainer.LayoutConfig.MATCH_PARENT, ComponentContainer.LayoutConfig.MATCH_CONTENT); listView.setLayoutConfig(layoutConfig); listView.setId(getId()); listView.setLayoutManager(new DirectionalLayoutManager()); listView.setScrollbarColor(Color.DKGRAY); - listView.setScrollbarThickness(20); + listView.setScrollbarThickness(0); listView.setScrollbarFadingEnabled(true); listView.enableScrollBar(AXIS_Y, true); listView.setScrollbarRoundRect(true); listView.setScrollbarRadius(10); - ShapeElement background = new ShapeElement(this.getContext(), ResourceTable.Graphic_ms__drawable); - background.setCornerRadius(20); - background.setStroke(3, RgbColor.fromArgbInt(Color.getIntColor("#9496A3"))); - listView.setBackground(background); listView.setItemProvider(mAdapter); listView.setItemClickedListener(new ListContainer.ItemClickedListener() { @@ -256,7 +251,7 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene }); popupWindow = new PopupDialog(context, null); - popupWindow.setCustomComponent(listView); + popupWindow.setCustomComponent(customToastLayout); HiLog.info(LABEL, "backgroundColor = " + (backgroundColor != Color.WHITE.getValue())); if (backgroundColor != Color.WHITE.getValue()) { // default color is white ShapeElement element = new ShapeElement(); @@ -320,6 +315,10 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene isShow = false; } + public void setShowFalse(Boolean isShows) { + isShow = isShows; + } + @Override public void setTextSize(int size) { HiLog.info(LABEL, "setTextSize adapter = " + adapter + ", textSize = " + textSize); @@ -452,7 +451,8 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene setText(""); } if (shouldResetPopupHeight) { - popupWindow.setSize(getWidth(), calculatePopupWindowHeight()); + popupWindow.setSize(getWidth(), adapterInternal.getCount() * ScreenUtils.pxToFp(mContext,36) + 10); + listView.setComponentSize(getWidth(), adapterInternal.getCount() * ScreenUtils.pxToFp(mContext,36) + 10); } } @@ -482,10 +482,13 @@ public class MaterialSpinner extends Text implements Component.TouchEventListene } nothingSelected = true; initPopupWindow(mContext); - popupWindow.setSize(ScreenUtils.getDisplayWidth(mContext) / 5 * 2, calculatePopupWindowHeight()); + + popupWindow.setSize(ScreenUtils.getDisplayWidth(mContext) / 5 * 2, adapter.getCount() * ScreenUtils.pxToFp(mContext,36) + 10); + listView.setComponentSize(ScreenUtils.getDisplayWidth(mContext) / 5 * 2, adapter.getCount() * ScreenUtils.pxToFp(mContext,36) + 10); + // popupWindow.setSize(ScreenUtils.getDisplayWidth(mContext) / 5 * 2, calculatePopupWindowHeight()); int[] locationOnScreen = this.getLocationOnScreen(); HiLog.info(LABEL, "locationOnScreen[1] = " + locationOnScreen[1] + ", " + spinnerWidth + ",locationOnScreen[1]" + locationOnScreen[1]); - popupWindow.showOnCertainPosition(LayoutAlignment.LEFT | LayoutAlignment.TOP, locationOnScreen[0] + 60, locationOnScreen[1] + this.getComponentSize().getSizeYToInt()); + popupWindow.showOnCertainPosition(LayoutAlignment.LEFT | LayoutAlignment.TOP, locationOnScreen[0] + 60, locationOnScreen[1] + this.getComponentSize().getSizeYToInt() + 10); isShow = true; } } diff --git a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerAdapter.java b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerAdapter.java index 59522d17e082a02846bc2fa3036bc63e2c64a8cc..bd675d252046fd205a38bbc1d9221dec8b6770bc 100644 --- a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerAdapter.java +++ b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerAdapter.java @@ -16,19 +16,18 @@ */ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.spinner; diff --git a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerBaseAdapter.java b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerBaseAdapter.java index 837c8d518313eb668c4dd8dd33cec567583d93d3..6691f9fef024114a42df1f442142b0b500d2dd41 100644 --- a/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerBaseAdapter.java +++ b/entry/src/main/java/com/chinasoft/ohos/spinner/MaterialSpinnerBaseAdapter.java @@ -16,19 +16,18 @@ */ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.spinner; diff --git a/entry/src/main/java/com/chinasoft/ohos/spinner/TypedAttrUtils.java b/entry/src/main/java/com/chinasoft/ohos/spinner/TypedAttrUtils.java index b5f8ba900a7010f423ad566fa71148531e3aae18..c5287e4e590ca0125c542d5fc373278028a92275 100644 --- a/entry/src/main/java/com/chinasoft/ohos/spinner/TypedAttrUtils.java +++ b/entry/src/main/java/com/chinasoft/ohos/spinner/TypedAttrUtils.java @@ -16,19 +16,18 @@ */ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.spinner; @@ -46,7 +45,7 @@ import java.util.NoSuchElementException; * * @since 2021-03-29 */ -final class TypedAttrUtils { +public class TypedAttrUtils { static final HiLogLabel LOG_LABEL = new HiLogLabel(HiLog.LOG_APP, 0x00201, "TypedAttrUtils"); public static int getIntColor(AttrSet attrs, String attrName, int defValue) { @@ -85,6 +84,24 @@ final class TypedAttrUtils { } } + public static float getFloat(AttrSet attrs, String attrName, float defValue) { + Attr attr = attrNoSuchElement(attrs, attrName); + if (attr == null) { + return defValue; + } else { + return attr.getFloatValue(); + } + } + + public static int getInteger(AttrSet attrs, String attrName, int defValue) { + Attr attr = attrNoSuchElement(attrs, attrName); + if (attr == null) { + return defValue; + } else { + return attr.getIntegerValue(); + } + } + public static int getDimensionPixelSize(AttrSet attrs, String attrName, int defValue) { Attr attr = attrNoSuchElement(attrs, attrName); if (attr == null) { diff --git a/entry/src/main/java/com/chinasoft/ohos/spinner/Utils.java b/entry/src/main/java/com/chinasoft/ohos/spinner/Utils.java index d5df94afb50b1a541d403609d7c616d734f72cea..31ee746b233576ac5f39baa2fe7b2402ae7da6af 100644 --- a/entry/src/main/java/com/chinasoft/ohos/spinner/Utils.java +++ b/entry/src/main/java/com/chinasoft/ohos/spinner/Utils.java @@ -16,19 +16,18 @@ */ /* - * Copyright (C) 2021 The Chinese Software International Co., Ltd. + * 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 + * 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.chinasoft.ohos.spinner; diff --git a/entry/src/main/resources/base/element/color.json b/entry/src/main/resources/base/element/color.json index 73ff154d497bc9e8e9c67c02a205b5018f5d51ef..c28e2ce65e218fbe882b107e4fafcf854620302b 100644 --- a/entry/src/main/resources/base/element/color.json +++ b/entry/src/main/resources/base/element/color.json @@ -115,7 +115,7 @@ "value":"#FF7A59" },{ "name": "colorPrimary", - "value": "#E6000000" + "value": "#dc7e2c" }, { "name": "colorSecondary", diff --git a/entry/src/main/resources/base/graphic/choose_background.xml b/entry/src/main/resources/base/graphic/choose_background.xml new file mode 100644 index 0000000000000000000000000000000000000000..559387bb2b9040ff8ee71c21dac5d619959fb04f --- /dev/null +++ b/entry/src/main/resources/base/graphic/choose_background.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/entry/src/main/resources/base/graphic/toast_background_shape.xml b/entry/src/main/resources/base/graphic/toast_background_shape.xml index b9b535e3a9633fbdf7d7e30fdda804e5bec4027c..39c4272457408e069dac66e9533cfe322c846191 100644 --- a/entry/src/main/resources/base/graphic/toast_background_shape.xml +++ b/entry/src/main/resources/base/graphic/toast_background_shape.xml @@ -4,5 +4,5 @@ + ohos:color="#BBF0F0F0"/> \ No newline at end of file diff --git a/entry/src/main/resources/base/layout/ability_base_func.xml b/entry/src/main/resources/base/layout/ability_base_func.xml index e2d4ba397bba58fcc01ef560272e00d1d99e2947..9642ffc438d9f0689d49c12fcbace6df32b42bc9 100644 --- a/entry/src/main/resources/base/layout/ability_base_func.xml +++ b/entry/src/main/resources/base/layout/ability_base_func.xml @@ -1,24 +1,36 @@ - + ohos:height="match_parent"> - - - + ohos:orientation="vertical"> - + + + + - + + + + diff --git a/entry/src/main/resources/base/layout/ability_local_config.xml b/entry/src/main/resources/base/layout/ability_local_config.xml index 2c4619f07a80aa752c3a973b0a260b6f487eb0be..f665f6d41b706124eab7a0a2fd536da511367721 100644 --- a/entry/src/main/resources/base/layout/ability_local_config.xml +++ b/entry/src/main/resources/base/layout/ability_local_config.xml @@ -1,21 +1,32 @@ - - - - - + ohos:width="match_parent" + ohos:orientation="vertical"> + + - + + + + + + diff --git a/entry/src/main/resources/base/layout/ability_main.xml b/entry/src/main/resources/base/layout/ability_main.xml index 6f2a62ea4adcc629aa78a1f71ea64b36bd836eb1..6b6b4b3fb5c50f8f8ebfa91897b508a80db086fd 100644 --- a/entry/src/main/resources/base/layout/ability_main.xml +++ b/entry/src/main/resources/base/layout/ability_main.xml @@ -12,143 +12,172 @@