From f4da42939b026ace0c929fc4b43297eab2505d13 Mon Sep 17 00:00:00 2001 From: HYL123698745 <1252347619@qq.com> Date: Mon, 19 Apr 2021 16:00:39 +0800 Subject: [PATCH 1/4] test --- entry/build.gradle | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/entry/build.gradle b/entry/build.gradle index badd2e1..466ac93 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,10 +1,11 @@ apply plugin: 'com.huawei.ohos.hap' ohos { + compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 } - + } dependencies { -- Gitee From 24b30e8380026f2bfe33b894a6bae484e59b1f2f Mon Sep 17 00:00:00 2001 From: HYL123698745 <1252347619@qq.com> Date: Mon, 19 Apr 2021 16:02:52 +0800 Subject: [PATCH 2/4] test --- entry/build.gradle | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/entry/build.gradle b/entry/build.gradle index 466ac93..e235140 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,6 +1,16 @@ apply plugin: 'com.huawei.ohos.hap' ohos { - + signingConfigs { + debug { + storeFile file('E:\\HarmonyWorkSpace\\SOW-33\\共用\\root_1.p12') + storePassword '0000002045693FD8BED19E75819E60FBC4BA5F9295E17FDEDA8B53BEF29F6CE2E897471DD417898752A1E213402B2522' + keyAlias = 'hos_platform_os' + keyPassword '00000020A9E2800C943924849DE623AFB1D72B60D1C0A4CC26A22F7E3B3027FC4E015C830BD0804E1799B0FF2084721A' + signAlg = 'SHA256withECDSA' + profile file('E:\\HarmonyWorkSpace\\SOW-33\\三期key\\TimetableViewDebug (1).p7b') + certpath file('E:\\HarmonyWorkSpace\\SOW-33\\共用\\root.cer') + } + } compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 -- Gitee From 2e4523077aeec242704ecb44fee03d79fe149473 Mon Sep 17 00:00:00 2001 From: HYL123698745 <1252347619@qq.com> Date: Mon, 19 Apr 2021 16:04:52 +0800 Subject: [PATCH 3/4] test --- .../com/chinasoft/ohos/dialog/DialogUtil.java | 35 ++----------------- .../base/graphic/background_shape.xml | 3 +- .../resources/base/layout/dialog_layout.xml | 2 +- 3 files changed, 5 insertions(+), 35 deletions(-) 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 6b9e438..644c557 100644 --- a/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java @@ -1,14 +1,11 @@ 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.IDialog; -import ohos.agp.window.dialog.ListDialog; import ohos.agp.window.dialog.PopupDialog; import ohos.agp.window.dialog.ToastDialog; import ohos.app.Context; @@ -39,16 +36,17 @@ public class DialogUtil { mContent.setText(content); ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(); + layoutConfig.setMarginLeft(20); + layoutConfig.setMarginRight(20); 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.setSize(ComponentContainer.LayoutConfig.MATCH_PARENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT); toastDialog.setAlignment(LayoutAlignment.CENTER); toastDialog.show(); - mBtConfim.setClickedListener(new Component.ClickedListener() { @Override public void onClick(Component component) { @@ -57,31 +55,4 @@ public class DialogUtil { }); } - 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/resources/base/graphic/background_shape.xml b/entry/src/main/resources/base/graphic/background_shape.xml index ef24b47..9aef3ae 100644 --- a/entry/src/main/resources/base/graphic/background_shape.xml +++ b/entry/src/main/resources/base/graphic/background_shape.xml @@ -1,6 +1,5 @@ - + \ No newline at end of file diff --git a/entry/src/main/resources/base/layout/dialog_layout.xml b/entry/src/main/resources/base/layout/dialog_layout.xml index 61ae8ae..a3f3a1d 100644 --- a/entry/src/main/resources/base/layout/dialog_layout.xml +++ b/entry/src/main/resources/base/layout/dialog_layout.xml @@ -1,7 +1,7 @@ -- Gitee From 9714f26f2f148c89436c012503ed69f11c2638a8 Mon Sep 17 00:00:00 2001 From: HYL123698745 <1252347619@qq.com> Date: Wed, 21 Apr 2021 15:57:36 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E5=86=85?= =?UTF-8?q?=E5=AE=B9=E3=80=91=201.=E6=8F=90=E4=BA=A4readme.md=E6=96=87?= =?UTF-8?q?=E4=BB=B6=202.=E4=BF=AE=E6=94=B9bug=203.=E6=8F=90=E4=BA=A4CHANG?= =?UTF-8?q?ELOG=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG.md | 44 ++++++ README.md | 146 +++++++++--------- entry/build.gradle | 13 +- entry/src/main/config.json | 3 +- .../java/com/chinasoft/ohos/MainAbility.java | 5 +- .../com/chinasoft/ohos/MyApplication.java | 5 +- .../chinasoft/ohos/ability/AttrAbility.java | 5 +- .../ohos/ability/BaseFucAbility.java | 5 +- .../ohos/ability/ColorPoolAbility.java | 5 +- .../ohos/ability/CustomWidthAbility.java | 5 +- .../chinasoft/ohos/ability/DateAbility.java | 5 +- .../ohos/ability/DateDelayAbility.java | 5 +- .../ohos/ability/ElasticAbility.java | 5 +- .../chinasoft/ohos/ability/ExtrasAbility.java | 5 +- .../ohos/ability/FlaglayoutAbility.java | 5 +- .../ohos/ability/ItemStyleAbility.java | 5 +- .../ohos/ability/LocalConfigAbility.java | 5 +- .../ohos/ability/NonViewAbility.java | 5 +- .../chinasoft/ohos/ability/SimpleAbility.java | 5 +- .../chinasoft/ohos/ability/SlideAbility.java | 5 +- .../chinasoft/ohos/adapter/ChooseAdapter.java | 106 +++++++++++++ .../ohos/adapter/NonViewAdapter.java | 5 +- .../chinasoft/ohos/base/BaseAbilitySlice.java | 2 +- .../chinasoft/ohos/bean/WeekChooseBean.java | 42 +++++ .../ohos/dialog/ChooseWeekDialog.java | 131 ++++++++++++++++ .../com/chinasoft/ohos/dialog/DialogUtil.java | 21 +-- .../chinasoft/ohos/dialog/TipsDialogUtil.java | 55 +++++++ .../com/chinasoft/ohos/dialog/ToastUtil.java | 10 +- .../ohos/dialog/ToastViewDialog.java | 5 +- .../com/chinasoft/ohos/slice/AttrSlice.java | 5 +- .../chinasoft/ohos/slice/BaseFuncSlice.java | 69 +++++---- .../chinasoft/ohos/slice/ColorPoolSlice.java | 27 +--- .../ohos/slice/CustomWidthSlice.java | 5 +- .../chinasoft/ohos/slice/DateDelaySlice.java | 9 +- .../com/chinasoft/ohos/slice/DateSlice.java | 5 +- .../chinasoft/ohos/slice/ElasticSlice.java | 5 +- .../com/chinasoft/ohos/slice/ExtrasSlice.java | 11 +- .../chinasoft/ohos/slice/FlaglayoutSlice.java | 7 +- .../chinasoft/ohos/slice/ItemStyleSlice.java | 7 +- .../ohos/slice/LocalConfigSlice.java | 18 ++- .../ohos/slice/MainAbilitySlice.java | 5 +- .../chinasoft/ohos/slice/NonViewSlice.java | 5 +- .../com/chinasoft/ohos/slice/SimpleSlice.java | 70 +++++++-- .../com/chinasoft/ohos/slice/SlideSlice.java | 5 +- .../ohos/spinner/MaterialSpinner.java | 37 +++-- .../ohos/spinner/MaterialSpinnerAdapter.java | 5 +- .../spinner/MaterialSpinnerBaseAdapter.java | 5 +- .../ohos/spinner/TypedAttrUtils.java | 25 ++- .../com/chinasoft/ohos/spinner/Utils.java | 5 +- .../main/resources/base/element/color.json | 2 +- .../base/graphic/background_shape.xml | 3 +- .../base/graphic/choose_background.xml | 5 + .../base/graphic/toast_background_shape.xml | 2 +- .../base/layout/ability_base_func.xml | 46 ++++-- .../base/layout/ability_local_config.xml | 39 +++-- .../resources/base/layout/ability_main.xml | 113 +++++++++----- .../resources/base/layout/ability_slide.xml | 3 +- .../base/layout/choose_dialog_layout.xml | 49 ++++-- .../resources/base/layout/dialog_layout.xml | 15 +- .../base/layout/header_base_func.xml | 2 - .../resources/base/layout/item_choose.xml | 26 ++++ .../resources/base/layout/item_nonview.xml | 14 +- .../resources/base/layout/list_spinner.xml | 14 ++ .../base/layout/tips_dialog_layout.xml | 40 +++++ .../base/layout/toast_dialog_layout.xml | 6 +- .../resources/base/media/radio_button_off.png | Bin 0 -> 1009 bytes .../resources/base/media/radio_button_on.png | Bin 0 -> 2029 bytes .../java/com/chinasoft/ohos/ExampleTest.java | 5 +- timetable/build.gradle | 6 - .../zhuangfei/timetable/TimetableView.java | 9 ++ .../timetable/model/ScheduleColorPool.java | 2 +- .../timetable/operater/SimpleOperater.java | 15 +- .../timetable/utils/ScreenUtils.java | 5 +- .../zhuangfei/timetable/view/WeekView.java | 4 +- .../resources/base/layout/item_dateview.xml | 1 + .../base/layout/item_dateview_first.xml | 1 + .../resources/base/layout/item_weekview.xml | 3 + .../resources/base/layout/view_weekview.xml | 3 +- 78 files changed, 1006 insertions(+), 420 deletions(-) create mode 100644 CHANGELOG.md create mode 100644 entry/src/main/java/com/chinasoft/ohos/adapter/ChooseAdapter.java create mode 100644 entry/src/main/java/com/chinasoft/ohos/bean/WeekChooseBean.java create mode 100644 entry/src/main/java/com/chinasoft/ohos/dialog/ChooseWeekDialog.java create mode 100644 entry/src/main/java/com/chinasoft/ohos/dialog/TipsDialogUtil.java create mode 100644 entry/src/main/resources/base/graphic/choose_background.xml create mode 100644 entry/src/main/resources/base/layout/item_choose.xml create mode 100644 entry/src/main/resources/base/layout/list_spinner.xml create mode 100644 entry/src/main/resources/base/layout/tips_dialog_layout.xml create mode 100644 entry/src/main/resources/base/media/radio_button_off.png create mode 100644 entry/src/main/resources/base/media/radio_button_on.png diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..af9e824 --- /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 9122fe6..6f7efb2 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 2337deb..3881a49 100644 --- a/entry/build.gradle +++ b/entry/build.gradle @@ -1,16 +1,5 @@ apply plugin: 'com.huawei.ohos.hap' ohos { - signingConfigs { - debug { - storeFile file('E:\\HarmonyWorkSpace\\SOW-33\\共用\\root_1.p12') - storePassword '0000002045693FD8BED19E75819E60FBC4BA5F9295E17FDEDA8B53BEF29F6CE2E897471DD417898752A1E213402B2522' - keyAlias = 'hos_platform_os' - keyPassword '00000020A9E2800C943924849DE623AFB1D72B60D1C0A4CC26A22F7E3B3027FC4E015C830BD0804E1799B0FF2084721A' - signAlg = 'SHA256withECDSA' - profile file('E:\\HarmonyWorkSpace\\SOW-33\\三期key\\TimetableViewDebug (1).p7b') - certpath file('E:\\HarmonyWorkSpace\\SOW-33\\共用\\root.cer') - } - } compileSdkVersion 5 defaultConfig { compatibleSdkVersion 5 @@ -22,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 9f1ea6b..68c8a33 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 c1b4180..099fac3 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 a6e53da..fa0954d 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 ffef86c..0c338a3 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 05db7cf..f65301b 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 6548574..c48f929 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 11dcb15..aec39bf 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 3c8eb88..dd23126 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 b49130d..dd844b8 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 e09de8e..2690fdd 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 d24e960..0c549c7 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 2d40661..684cae1 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 e849d82..077174e 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 8724aab..5717e65 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 91c3bca..3bab634 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 a550910..2bedd66 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 266b670..fc3785a 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 0000000..04eccf6 --- /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 57e902b..cbef109 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 70161aa..e39f8be 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 0000000..d210163 --- /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 0000000..b830d69 --- /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 644c557..9941600 100644 --- a/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java +++ b/entry/src/main/java/com/chinasoft/ohos/dialog/DialogUtil.java @@ -1,11 +1,14 @@ 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.IDialog; +import ohos.agp.window.dialog.ListDialog; import ohos.agp.window.dialog.PopupDialog; import ohos.agp.window.dialog.ToastDialog; import ohos.app.Context; @@ -14,10 +17,8 @@ import ohos.app.Context; * ToastUtil * * @since 2021-03-29 - * */ public class DialogUtil { - Context context; @@ -26,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); @@ -35,24 +38,24 @@ public class DialogUtil { mTitle.setText(title); mContent.setText(content); - ComponentContainer.LayoutConfig layoutConfig = new ComponentContainer.LayoutConfig(); - layoutConfig.setMarginLeft(20); - layoutConfig.setMarginRight(20); + 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(ComponentContainer.LayoutConfig.MATCH_PARENT, DirectionalLayout.LayoutConfig.MATCH_CONTENT); + 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(); + mBgComponent.setVisibility(Component.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 0000000..7c1014d --- /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 68c0868..619e6d9 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 2f99210..72a68f1 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 fbe7302..a0f945b 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 f10a4e5..8b17bc2 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 985a947..d31c7f3 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 6c97786..38f94ce 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 c6d418b..06ea5ae 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 20153e4..07c36ba 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 d0f38cd..e2f59ef 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 7f0a3c2..9583544 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 a55a70f..a53efe9 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 e13b57c..7cffddd 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 aae76cd..0480988 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 1d50a9f..b767d6f 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 5a3be4b..9857fef 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 2066ab0..e38e018 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 a4f5a6a..18dec90 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 8a6d7e2..24f058d 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 59522d1..bd675d2 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 837c8d5..6691f9f 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 b5f8ba9..c5287e4 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 d5df94a..31ee746 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 73ff154..c28e2ce 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/background_shape.xml b/entry/src/main/resources/base/graphic/background_shape.xml index 9aef3ae..ef24b47 100644 --- a/entry/src/main/resources/base/graphic/background_shape.xml +++ b/entry/src/main/resources/base/graphic/background_shape.xml @@ -1,5 +1,6 @@ - + \ No newline at end of file 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 0000000..559387b --- /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 b9b535e..39c4272 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 e2d4ba3..9642ffc 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 2c4619f..f665f6d 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 6f2a62e..6b6b4b3 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 @@