diff --git a/CommonEventAndNotification/AlarmClock/AppScope/app.json5 b/CommonEventAndNotification/AlarmClock/AppScope/app.json5 deleted file mode 100644 index 5bb3dd05a4bb9b30d8dbad1876998a92604f4df8..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/AppScope/app.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "app": { - "bundleName": "com.example.helloworld0218", - "vendor": "example", - "versionCode": 1000000, - "versionName": "1.0.0", - "icon": "$media:app_icon", - "label": "$string:app_name", - "distributedNotificationEnabled": true, - "minAPIVersion": 9, - "targetAPIVersion": 9 - } -} diff --git a/CommonEventAndNotification/AlarmClock/AppScope/resources/base/element/string.json b/CommonEventAndNotification/AlarmClock/AppScope/resources/base/element/string.json deleted file mode 100644 index 0135ac818a531d0adc91a4f9f9d765deed56c748..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/AppScope/resources/base/element/string.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "string": [ - { - "name": "app_name", - "value": "AlarmClock" - } - ] -} diff --git a/CommonEventAndNotification/AlarmClock/AppScope/resources/base/media/app_icon.png b/CommonEventAndNotification/AlarmClock/AppScope/resources/base/media/app_icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/CommonEventAndNotification/AlarmClock/AppScope/resources/base/media/app_icon.png and /dev/null differ diff --git a/CommonEventAndNotification/AlarmClock/README.md b/CommonEventAndNotification/AlarmClock/README.md deleted file mode 100644 index 5224e2ca52142e7f006a3015853ef104228c4a6c..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/README.md +++ /dev/null @@ -1,857 +0,0 @@ -# 介绍 - -本篇Codelab是基于TS扩展的声明式开发范式及OpenHarmony的后台代理提醒能力实现的一个简单闹钟的示例。 - -本篇Codelab实现如下功能: - -- 展示指针表盘和数字时间。 -- 添加、修改和删除闹钟。 -- 展示闹钟列表,并可打开和关闭单个闹钟。 -- 闹钟到设定的时间后进行后台代理提醒。 -- 闹钟定时数据保存到首选项数据库中。 - -最终效果图如下: - -![](figures/1.png) ![](figures/2.png) ![](figures/3.png) ![](figures/4.png) - -# 相关概念 - -- [Canvas](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-js/js-components-canvas-canvas.md):提供画布组件,用于自定义绘制图形。 -- [后台代理提醒](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-reminderAgent.md):发布一个后台代理提醒。 -- [TextPicker](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/arkui-ts/ts-basic-components-textpicker.md):文本类滑动选择器组件。 -- [CustomDialog](https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ts-component-based-customdialog-0000001192355895):@CustomDialog装饰器用于装饰自定义弹窗。 -- [首选项](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/reference/apis/js-apis-data-preferences.md#flush):为应用提供key-value键值型的数据处理能力,支持应用持久化轻量级数据,并对其修改和查询。 - -# 搭建OpenHarmony环境 - -完成本篇Codelab我们首先要完成开发环境的搭建,本示例以**RK3568**开发板为例,参照以下步骤进行: - -1. [获取OpenHarmony系统版本](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md#%E8%8E%B7%E5%8F%96%E6%96%B9%E5%BC%8F3%E4%BB%8E%E9%95%9C%E5%83%8F%E7%AB%99%E7%82%B9%E8%8E%B7%E5%8F%96):标准系统解决方案(二进制)。 - - 以3.1版本为例: - - ![](figures/zh-cn_image_0000001214154402.png) - -2. 搭建烧录环境。 - 1. [完成DevEco Device Tool的安装](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-ide-env--win.md) - 2. [完成RK3568开发板的烧录](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/quick-start/quickstart-ide-3568-burn.md) - -3. 搭建开发环境。 - 1. 开始前请参考[工具准备](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/start-overview.md#%E5%B7%A5%E5%85%B7%E5%87%86%E5%A4%87),完成DevEco Studio的安装和开发环境配置。 - 2. 开发环境配置完成后,请参考[使用工程向导](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/start-with-ets-stage.md#%E5%88%9B%E5%BB%BAets%E5%B7%A5%E7%A8%8B)创建工程(模板选择“Empty Ability”),选择JS或者eTS语言开发。 - 3. 工程创建完成后,选择使用[真机进行调测](https://gitee.com/openharmony/docs/blob/master/zh-cn/application-dev/quick-start/start-with-ets-stage.md#%E4%BD%BF%E7%94%A8%E7%9C%9F%E6%9C%BA%E8%BF%90%E8%A1%8C%E5%BA%94%E7%94%A8)。 - -# 代码结构解读 - -![](figures/目录.png) - -- AppScope:App作用域目录。 -- entry/src/main/ets:程序目录。 - - Application:stage模型目录。 - - AbilityStage.ts:stage模型文件。 - - - images:本篇Codelab对应demo中用到的图标。 - - MainAbility:程序入口目录。 - - MainAbility.ts:程序入口类。 - - - pages:界面目录。 - - detail.ets:详情界面。 - - index.ets:主界面。 - - -- entry/src/main/resources:资源文件目录。 -- entry/src/main/module.json5:应用配置文件。 -- entry/src/build-profile.json5:应用构建配置文件。 -- build-profile.json5:版本信息配置文件。 - -# 相关权限 - -本篇Codelab需要在module.json5中配置如下权限: - -``` -"requestPermissions" :[ - { - // 后台代理提醒权限 - "name": "ohos.permission.PUBLISH_AGENT_REMINDER" - } -] -``` - -# 闹钟主界面 - -闹钟界面包括当前时间、闹钟列表、添加闹钟子组件,具体包括以下模块: - -1. Canvas组件,默认展示指针表盘,指针表盘与数字时钟可通过点击屏幕来回切换。如下图所示: - - ![](figures/video1.gif) - - 在index.ets中获取屏幕宽高,根据屏幕宽高设置Canvas画布尺寸,并将原点移到画布中间,示例代码如下: - - ``` - aboutToAppear(){ - // 从首选项数据库获取数据 - this.getDate() - // 获取屏幕宽高 - display.getDefaultDisplay((err, data) => { - if(err.code === 0) { - console.info('Failed to obtain the default display object. Code: ' + JSON.stringify(err)) - } - this.screenWidth = data.width - this.screenHeight = data.height - // 设置canvas尺寸,竖屏取值为宽高最小值的1/3,横屏取值为宽高最小值的1/4 - this.canvasOnScreenRatio = (this.screenWidth < this.screenHeight ? 3 : 4) - this.canvasSize = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio - // 重置原点到canvas画布中间 - this.context.translate(this.canvasSize, this.canvasSize / 2) - }); - } - ``` - - 在index.ets中初始化Canvas画布,并绑定指针表盘和数字时钟切换事件,示例代码如下: - - ``` - Canvas(this.context) - .height(this.canvasSize) - .aspectRatio(2.0) - .onReady(() =>{ - // 获取半径 - this.radius = this.canvasSize / 2 - 2.5 - var that = this - // 避免时钟闪现,先画一遍 - that.draw() - // 定时器 - this.interval = setInterval(function() { - that.draw() - }, 1000) - }) - .onClick(() => { - // 切换指针表盘和数字时钟 - this.showClock = !this.showClock - }) - ``` - - 在index.ets中利用Canvas画布组件绘制指针表盘和数字时钟,示例代码如下: - - ``` - // 开始绘制 - private draw(): void{ - // 清空绘制 - this.context.clearRect(-this.canvasSize, this.canvasSize / -2, this.canvasSize * 2, this.canvasSize) - // 获取当前时间 - let date = new Date() - if(this.showClock) { - // 画表盘 - this.drawDials() - // 画秒针 - this.drawSecond(date.getSeconds()) - // 画分针 - this.drawMinute(date.getMinutes(), date.getSeconds()) - // 画时针 - this.drawHour(date.getHours(), date.getMinutes()) - } else { - this.drawTime(date.getHours().toString(), date.getMinutes().toString(), date.getSeconds().toString()) - } - } - - // 画时间 - private drawTime(hour: string, minute: string, second: string): void{ - let time = this.fillZero(hour) + ':' + this.fillZero(minute) + ':' + this.fillZero(second) - this.context.save() - this.context.font = '100px' - this.context.beginPath() - this.context.textAlign = 'center' - this.context.fillText(time, 0, 0) - this.context.restore() - } - - // 补零:HH:mm:ss - private fillZero(val): string{ - var len = val.length; - while(len < 2) { - val = "0" + val; - len++; - } - return val; - } - - // 画表盘 - private drawDials(): void{ - // 画原点 - this.context.save() - this.context.beginPath() - this.context.arc(0, 0, 5, 0, Math.PI * 2) - this.context.fill() - this.context.stroke() - this.context.restore() - // 字体大小 - this.context.font = '20px' - // 画圆 - this.context.save() - this.context.lineWidth = 5 - this.context.beginPath() - this.context.arc(0, 0, this.radius, 0, 2 * Math.PI) - this.context.stroke() - this.context.restore() - - // 画刻度 - for (let n = 1; n <= 60; n++) { - // 从三点钟方向开始获取60个刻度的角度 - var theta = (n - 3) * (Math.PI * 2) / 60; - this.context.save() - // 刻度宽度为2 - this.context.lineWidth = 2 - this.context.beginPath() - // 刻度起始位置 - var x_move = this.radius * Math.cos(theta); - var y_move = this.radius * Math.sin(theta); - // 非整点刻度结束位置 - var x_to = (this.radius - 5) * Math.cos(theta); - var y_to = (this.radius - 5) * Math.sin(theta); - // 整点刻度 - if((n-3) % 5 == 0) { - //整点刻度宽度 - this.context.lineWidth = 3 - // 整点刻度结束位置 - x_to = (this.radius - 10) * Math.cos(theta); - y_to = (this.radius - 10) * Math.sin(theta); - // 整点时间位置 - var x_time = (this.radius - 25) * Math.cos(theta); - var y_time = (this.radius - 25) * Math.sin(theta); - // 绘制整点时间 - this.context.fillText(this.times[(n - 3) / 5] + '', x_time - 5, y_time + 3) - } - // 绘制刻度线 - this.context.moveTo(x_move, y_move) - this.context.lineTo(x_to, y_to) - this.context.stroke() - this.context.restore() - } - } - - // 画秒针 - private drawSecond(second: number): void{ - this.context.save() - this.context.fillStyle = 'red' - var theta = (second - 15) * 2 * Math.PI / 60; - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -3); - this.context.lineTo(-15, 3); - this.context.lineTo(this.radius * 0.9, 1); - this.context.lineTo(this.radius * 0.9, -1); - this.context.fill(); - this.context.restore(); - } - - // 画分针 - private drawMinute(minute: number, second: number): void{ - this.context.save() - var theta = ((minute + second / 60 - 15) * 2 * Math.PI / 60) - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -4); - this.context.lineTo(-15, 4); - this.context.lineTo(this.radius * 0.8, 1); - this.context.lineTo(this.radius * 0.8, -1); - this.context.fill(); - this.context.restore(); - } - - // 画时针 - private drawHour(hour:number, minute: number): void{ - this.context.save() - var theta = ((hour + minute / 60 - 3) * 2 * Math.PI / 12) - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -5); - this.context.lineTo(-15, 5); - this.context.lineTo(this.radius * 0.5, 1); - this.context.lineTo(this.radius * 0.5, -1); - this.context.fill(); - this.context.restore(); - } - ``` - -2. 闹钟列表,展示已添加的闹钟信息,可对闹钟进行启停操作,点击闹钟可跳转到闹钟操作界面(修改和删除闹钟)。如下图所示: - - ![](figures/video2.gif) ![](figures/video3.gif) - - 在index.ets中添加闹钟列表子组件,并绑定启停、跳转事件,示例代码如下: - - ``` - List({ space: 10, initialIndex: 0 }) { - ForEach(this.clockItems.map((item, index) => { - return { i: index, data: item } - }), - (item, index) => { - ListItem() { - Stack({alignContent: Alignment.End}) { - Column() { - Row() { - Text(item.data.partition).fontSize(15) - Text(item.data.hour+ ':' + item.data.minute).fontSize(25).margin({left: 10}) - } - Row() { - Text(item.data.name).fontSize(15) - Text('不重复').fontSize(15).margin({left: 10}) - }.margin({top: 5}) - } - .width('100%') - .margin({left: 10}) - .alignItems(HorizontalAlign.Start) - Toggle({ type: ToggleType.Switch, isOn: item.data.open }) - .selectedColor(0x39a2db) - .switchPointColor(0xe5ffffff) - .onChange((isOn: boolean) => { - item.data.open = isOn - console.info('Component status:' + isOn) - // 关闭、打开闹钟 - this.modifyMsg = [isOn ? 0 : 2, index, item.data.reminderId] - this.resetAlarm() - }) - .width(30) - .aspectRatio(1.0) - } - .width('90%') - .height(60) - .backgroundColor('#E2E2E2') - .borderRadius(10) - }.width('100%') - .onClick(() => { - // 下标 - this.nowIndex = index - // 展示修改界面 - this.showIndex = false - }) - }, - item => item.data.name.toString()) - } - .listDirection(Axis.Vertical) // 排列方向 - .flexGrow(1) - .margin({top: 10}) - ``` - -3. 添加闹钟,点击界面底部闹钟添加按钮,跳转到闹钟操作界面(新增闹钟)。如下图所示: - - ![](figures/video1-0.gif) - - 在index.ets中为添加按钮绑定跳转事件,示例代码如下: - - ``` - Image('images/add.png') - .width(100) - .aspectRatio(1.0) - .margin({bottom: 10}) - .onClick(() => { - // 新增闹钟,值为-1 - this.nowIndex = -1 - // 展示新增闹钟界面 - this.showIndex = false - }).visibility(this.showIndex ? Visibility.Visible : Visibility.Hidden) - ``` - -4. 后台代理提醒,根据闹钟列表中的数据来设置(启停)闹钟实例。 - - 观测闹钟数据变化(新增、修改、删除、启停),示例代码如下: - - ``` - @State @Watch("resetAlarm") clockItems: Array = [] // 闹钟-定时 - - // 观测闹钟数据变化 - private resetAlarm(): void{ - let opeNum = this.modifyMsg[0] - let index = this.modifyMsg[1] - let reminderId = this.modifyMsg[2] - if(opeNum == 0) { - // 新增 - reminderAgent.publishReminder(this.addAlarm(this.clockItems[index], index), (err, reminderId) =>{ - if(err.code == 0) { - // 设置reminderId - this.clockItems[index].reminderId = reminderId - }else { - console.info("publishReminder" + index + "error: " + err.message) - } - }); - } else if(opeNum == 1) { - // 修改,先停止原先的闹钟再开启修改后的 - reminderAgent.cancelReminder(reminderId) - reminderAgent.publishReminder(this.addAlarm(this.clockItems[index], index), (err, reminderId) =>{ - if(err.code == 0) { - // 设置reminderId - this.clockItems[index].reminderId = reminderId - }else { - console.info("publishReminder" + index + "error: " + err.message) - } - }); - } else { - // 删除 - reminderAgent.cancelReminder(reminderId) - } - } - ``` - - 新增闹钟,示例代码如下: - - ``` - private addAlarm(item: ClockItem, index: number): reminderAgent.ReminderRequestAlarm{ - return { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, - // 小时 - hour: item.partition == '上午' ? parseInt(item.hour) : ((parseInt(item.hour) + 12) == 24 ? 0 : parseInt(item.hour) + 12), - // 分钟 - minute: parseInt(item.minute), - // 星期几 - daysOfWeek: [1, 2, 3, 4, 5, 6, 7], - actionButton: [ - { - title: "close", - type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE - }, - { - title: "snooze", - type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE - }, - ], - wantAgent: { - pkgName: "com.example.helloworld0218", - abilityName: "com.example.helloworld0218.MainAbility" - }, - maxScreenWantAgent: { - pkgName: "com.example.helloworld0218", - abilityName: "com.example.helloworld0218.MainAbility" - }, - // 响铃时长 - ringDuration: item.duration * 60, - // 延迟提醒次数 - snoozeTimes: item.intervalTimes, - // 延迟提醒间隔 最小五分钟 - timeInterval: item.intervalMinute, - title: item.name, - content: item.partition + item.hour + ':' + item.minute, - expiredContent: "this reminder has expired", - snoozeContent: "remind later", - notificationId: index, - slotType: notification.SlotType.SOCIAL_COMMUNICATION - } - } - ``` - -5. 首选项数据库,保存闹钟定时数据。 - - 保存闹钟定时数据,示例代码如下: - - ``` - private saveData() { - let promise = data_preferences.getPreferences(globalThis.context, 'mystore') - promise.then((preferences) => { - let promisePut = preferences.put('data', JSON.stringify(this.objs2array())) - promisePut.then(() => { - preferences.flush() - console.info("Put the value of startup successfully.") - }).catch((err) => { - console.info("Put the value of startup failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - ``` - - 获取闹钟定时数据,示例代码如下: - - ``` - private getDate() { - let promise = data_preferences.getPreferences(globalThis.context, 'mystore') - promise.then((preferences) => { - let promiseGet = preferences.get('data', '') - promiseGet.then(value => { - this.clockItems = JSON.parse(value) - }) - }) - } - ``` - -# 闹钟操作界面 - -闹钟操作界面分为新增和修改界面,其中在修改界面可删除闹钟。具体分为以下模块: - -1. 关闭闹钟操作界面子组件,点击左上角“x”图标关闭操作界面,点击右上角“√”图标,保存当前设置并关闭操作界面。如下图所示: - - ![](figures/video5.gif) ![](figures/video6.gif) - - 在detail.ets中添加取消(“x”)、确定(“√”)子组件,并绑定点击事件,示例代码如下: - - ``` - Stack({alignContent: Alignment.End}) { - Row() { - // 取消 - Image('images/cancel.png') - .width(50) - .aspectRatio(1.0) - .onClick(() => { - this.cancel() - }) - // 描述 - Text(this.nowIndex == -1 ? '新建闹钟' : '修改闹钟') - .fontSize(30) - .margin({left: 20}) - } - .height('100%') - .width('100%') - // 确定 - Image('images/confirm.png') - .width(50) - .aspectRatio(1.0) - .onClick(() => { - this.confirm() - }) - } - .margin({top: 20, bottom: 15}) - .width('90%').height(50) - - // 确定 '√' - private confirm(): void{ - // 新增 - if(this.nowIndex == -1) { - // 判断当前闹钟时间是否存在 - let exist = false - this.clockItems.forEach(item => { - if(item.partition == this.timedArray[0] && item.hour == this.timedArray[1] && item.minute == this.timedArray[2]) { - exist = true - return - } - }) - if(exist) { - AlertDialog.show({ message: '该时间闹钟已添加!' }) - } else { - // 新增信息 - this.modifyMsg = [0, this.clockItems.length, this.clockItems.length] - this.clockItems.push(new ClockItem(this.clockName, this.partitionIndex, this.timedArray[0], this.hourIndex, this.timedArray[1], - this.minuteIndex, this.timedArray[2], this.duration, this.intervalMinute, this.intervalTimes, true)) - this.showIndex = true - } - } else { - // 修改 - // 修改信息 - this.modifyMsg = [1, this.nowIndex,this.clockItems[this.nowIndex].reminderId] - this.clockItems[this.nowIndex] = new ClockItem(this.clockName, this.partitionIndex, this.timedArray[0], this.hourIndex, this.timedArray[1], - this.minuteIndex, this.timedArray[2], this.duration, this.intervalMinute, this.intervalTimes, true) - this.showIndex = true - } - - } - - // 取消 '×' - private cancel(): void{ - this.showIndex = true - } - ``` - -2. 设置闹钟提醒时间,在闹钟操作界面可通过滑动选择器设置闹钟的提醒时间(包括:时段、小时、分钟)。如下图所示: - - ![](figures/video7.gif) - - 在detail.ets中初始化时段、小时、分钟数据,示例代码如下: - - ``` - // 时段 - private partitions: string[] = ['上午', '下午'] - // 小时 - private hours: string[] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] - // 分钟 - private minutes: string[] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', - '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', - '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', - '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', - '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '00', - ] - ``` - - 在detail.ets中添加闹钟时间选择器子组件,示例代码如下: - - ``` - Row() { - // 上午下午 - TextPicker({range: this.partitions, selected: this.partitionIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[0] = value - this.partitionIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - // 小时 - TextPicker({range: this.hours, selected: this.hourIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[1] = value - this.hourIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - // 分钟 - TextPicker({range: this.minutes, selected: this.minuteIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[2] = value - this.minuteIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - } - .backgroundColor('#E2E2E2') - .borderRadius(10) - ``` - -3. 闹钟名子组件。如下图所示: - - ![](figures/video8.gif) - - 在detail.ets中添加闹钟名子组件,点击闹钟名打设置开闹钟名弹框,示例代码如下: - - ``` - Stack({alignContent: Alignment.End}) { - Row() { - Text('闹钟名') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.clockName + ' >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .margin({top: 20, bottom: 10}) - .onClick(() => { - this.dialogControllerName.open() - }) - - // 闹钟名弹框 - dialogControllerName : CustomDialogController = new CustomDialogController({ - builder: DialogName({action: this.onAccept}), - autoCancel: true - }); - - // 闹钟名弹框 - @CustomDialog - struct DialogName { - @Consume clockName: string - name: string - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('闹钟名').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - TextArea({text: this.clockName}) - .width('90%').margin({top: 20}) - .onChange((value: string) => { - this.name = value - }) - Divider().width('90%').margin({top: 10}) - Row() { - Text('取消').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - Text('确定').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.clockName = this.name - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } - } - ``` - -4. 响铃时长子组件。如下图所示: - - ![](figures/video9.gif) - - 在detail.ets中添加响铃时长文本框子组件,点击后打开响铃时长选择框,示例代码如下: - - ``` - Stack({alignContent: Alignment.End}) { - Row() { - Text('响铃时长') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.duration.toFixed(0) + ' 分钟 >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .margin({bottom: 10}) - .onClick(() => { - this.dialogControllerDuration.open() - }) - - // 响铃时长弹框 - dialogControllerDuration : CustomDialogController = new CustomDialogController({ - builder: DialogDuration({action: this.onAccept}), - autoCancel: true - }); - - // 响铃时长弹框 - @CustomDialog - struct DialogDuration { - @Consume duration: number - //响铃时长,分钟 - private durations: Array = [1, 5, 10, 15, 20, 30] - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('响铃时长').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10, bottom: 10}) - ForEach(this.durations, item => { - Stack({alignContent: Alignment.End}) { - Row() { - Text(item + ' 分钟') - }.width('100%') - Radio({ value: item, group: 'radioGroup' }).checked(item == this.duration ? true: false) - .height(20) - .width(20) - .onChange((value: boolean) => { - this.controller.close(); - this.duration = item - }) - }.width('90%') - Divider().width('90%') - }) - Row() { - Text('取消').fontSize(15).width('100%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } - } - ``` - -5. 再响间隔子组件,包括响铃间隔时间(最少5分钟)和重复响铃次数。如下图所示: - - ![](figures/video10.gif) - - 在detail.ets中添加再响间隔文本框子组件,点击后打开再响间隔弹框,示例代码如下: - - ``` - Stack({alignContent: Alignment.End}) { - Row() { - Text('再响间隔') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.intervalMinute.toFixed(0) + ' 分钟,' + this.intervalTimes.toFixed(0) + ' 次 >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .onClick(() => { - this.dialogControllerInterval.open() - }) - - //再响间隔弹框 - dialogControllerInterval : CustomDialogController = new CustomDialogController({ - builder: DialogInterval({action: this.onAccept}), - autoCancel: true - }); - - // 再响间隔弹框 - @CustomDialog - struct DialogInterval { - // 再响间隔分钟,默认10分钟 - @Consume intervalMinute: number - // 再响间隔次数,默认3次 - @Consume intervalTimes: number - // 再响间隔分钟,界面选择值 - @State intervalMinuteSelect: number = 0 - // 再响间隔次数,界面选择值 - @State intervalTimesSelect: number = 0 - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('再响间隔').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Text('响铃间隔时间(分钟)').fontSize(10).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Row() { - Slider({ - value: this.intervalMinuteSelect, - min: 5, - max: 30, - step: 5, - style: SliderStyle.OutSet - }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) - .showSteps(true) - .showTips(true) - .onChange((value: number, mode: SliderChangeMode) => { - this.intervalMinuteSelect = value - }) - Text(this.intervalMinuteSelect.toFixed(0)).fontSize(16) - } - .padding({ top: 30 }) - .width('90%') - Divider().width('90%').margin({top: 10}) - Text('重复响铃次数').fontSize(10).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Row() { - Slider({ - value: this.intervalTimesSelect, - min: 0, - max: 10, - step: 2, - style: SliderStyle.OutSet - }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) - .showSteps(true) - .showTips(true) - .onChange((value: number, mode: SliderChangeMode) => { - this.intervalTimesSelect = value - }) - Text(this.intervalTimesSelect.toFixed(0)).fontSize(16) - } - .padding({ top: 50 }) - .width('90%') - Row() { - Text('取消').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - Text('确定').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.intervalMinute = this.intervalMinuteSelect - this.intervalTimes = this.intervalTimesSelect - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } - aboutToAppear(): void{ - // 再响间隔分钟,界面选择值 - this.intervalMinuteSelect = this.intervalMinute - // 再响间隔次数,界面选择值 - this.intervalTimesSelect = this.intervalTimes - } - } - ``` - -# 恭喜您 - -目前你已经成功完成了Codelab并且学到了: - -- 如何使用Canvas画布组件绘制图形。 -- 如何使用后台代理提醒。 -- 如何使用TextPicker。 -- 如何使用CustomDialog组件进行自定义弹框。 -- 如何使用首选项数据库。 \ No newline at end of file diff --git a/CommonEventAndNotification/AlarmClock/build-profile.json5 b/CommonEventAndNotification/AlarmClock/build-profile.json5 deleted file mode 100644 index 5110f748cf2402cd9946b02d419cd7494b22af38..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/build-profile.json5 +++ /dev/null @@ -1,28 +0,0 @@ -{ - "app": { - "signingConfigs": [ - ], - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default", - }, - ], - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default", - ], - }, - ], - }, - ], -} \ No newline at end of file diff --git a/CommonEventAndNotification/AlarmClock/entry/build-profile.json5 b/CommonEventAndNotification/AlarmClock/entry/build-profile.json5 deleted file mode 100644 index 7dc37bb919dada5132609c409200db266559004f..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/build-profile.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apiType": 'stageMode', - "buildOption": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/CommonEventAndNotification/AlarmClock/entry/hvigorfile.js b/CommonEventAndNotification/AlarmClock/entry/hvigorfile.js deleted file mode 100644 index d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/hvigorfile.js +++ /dev/null @@ -1,2 +0,0 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/CommonEventAndNotification/AlarmClock/entry/package.json b/CommonEventAndNotification/AlarmClock/entry/package.json deleted file mode 100644 index c4e988f30f2ec9e3430a4d0c8f05e89fabbc2659..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/package.json +++ /dev/null @@ -1,13 +0,0 @@ -{ - "name": "entry", - "version": "1.0.0", - "ohos": { - "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "module" - }, - "description": "example description", - "repository": {}, - "license": "ISC", - "dependencies": {} -} diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/Application/AbilityStage.ts b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100644 index 1c9fcaafa50d6605b274c4a54a4b6225bc9bc1d0..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * 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. - */ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - } -} \ No newline at end of file diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/MainAbility/MainAbility.ts b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100644 index 3097d0a082069d7d0135f2e8eb61c5048bc224a6..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - */ -import Ability from '@ohos.application.Ability' -import notification from '@ohos.notification'; - -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - globalThis.context = this.context - } - - onDestroy() { - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - let context = this.context - // 通知权限弹框 - notification.requestEnableNotification() - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - - windowStage.setUIContent(this.context, "pages/index", null) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/add.png b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/add.png deleted file mode 100644 index 34252da2cb7c751f8baf24488010a03d21f3176b..0000000000000000000000000000000000000000 Binary files a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/add.png and /dev/null differ diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/cancel.png b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/cancel.png deleted file mode 100644 index e57c208b981f448316a49278088c2fc9c0d1c6d8..0000000000000000000000000000000000000000 Binary files a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/cancel.png and /dev/null differ diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/confirm.png b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/confirm.png deleted file mode 100644 index 82c1e234962af3a9e75d2fae8468dfa95d759480..0000000000000000000000000000000000000000 Binary files a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/images/confirm.png and /dev/null differ diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/detail.ets b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/detail.ets deleted file mode 100644 index 4f7997a770c839990e8b7d6dadc0cf2f6e43b1b1..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/detail.ets +++ /dev/null @@ -1,459 +0,0 @@ -/* - * 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. - */ -@Component -export struct Detail { - @Link showIndex: boolean //true主界面 false详情界面 - @Link nowIndex: number // 新增时值为-1,修改时值为当前数组索引 - @State partitionIndex: number = 1 - private partitions: string[] = ['上午', '下午'] // 时段 - @State hourIndex: number = 1 - private hours: string[] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] // 小时 - @State minuteIndex: number = 1 - private minutes: string[] = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12', - '13', '14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24', - '25', '26', '27', '28', '29', '30', '31', '32', '33', '34', '35', '36', - '37', '38', '39', '40', '41', '42', '43', '44', '45', '46', '47', '48', - '49', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '00', - ] // 分钟 - @State timedArray: Array = ['下午', '02', '02'] //闹钟时间,三个值分别为:上下午、小时、分钟 - @Link clockItems: Array // 闹钟-定时数组 - @Link modifyMsg: Array // 记录clockItems变化数据,三个数值,第一个:0新增、1修改、2删除;第二个:修改闹钟的index值;第三个:闹钟reminderId - @Provide clockName: string = '闹钟' // 闹钟名,默认闹钟 - @Provide duration: number = 5 // 响铃时长, 默认5分钟 - @Provide intervalMinute: number = 10 // 再响间隔分钟,默认10分钟 - @Provide intervalTimes: number = 3 // 再响间隔次数,默认3次 - - // 闹钟名弹框 - dialogControllerName : CustomDialogController = new CustomDialogController({ - builder: DialogName({action: this.onAccept}), - autoCancel: true - }); - // 响铃时长弹框 - dialogControllerDuration : CustomDialogController = new CustomDialogController({ - builder: DialogDuration({action: this.onAccept}), - autoCancel: true - }); - //再响时长弹框 - dialogControllerInterval : CustomDialogController = new CustomDialogController({ - builder: DialogInterval({action: this.onAccept}), - autoCancel: true - }); - - onAccept() { - } - - build() { - Stack({alignContent: Alignment.Bottom}) { - Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center}) { - Stack({alignContent: Alignment.End}) { - Row() { - // 取消 - Image('images/cancel.png') - .width(50) - .aspectRatio(1.0) - .onClick(() => { - this.cancel() - }) - // 描述 - Text(this.nowIndex == -1 ? '新建闹钟' : '修改闹钟') - .fontSize(30) - .margin({left: 20}) - } - .height('100%') - .width('100%') - // 确定 - Image('images/confirm.png') - .width(50) - .aspectRatio(1.0) - .onClick(() => { - this.confirm() - }) - } - .margin({top: 20, bottom: 15}) - .width('90%').height(50) - - Scroll() { - Column() { - // 时间选择 - Row() { - // 上午下午 - TextPicker({range: this.partitions, selected: this.partitionIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[0] = value - this.partitionIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - // 小时 - TextPicker({range: this.hours, selected: this.hourIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[1] = value - this.hourIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - // 分钟 - TextPicker({range: this.minutes, selected: this.minuteIndex}) - .width('33%') - .onChange((value: string, index: number) => { - this.timedArray[2] = value - this.minuteIndex = index - console.info('Picker item changed, value: ' + value + ', index: ' + index) - }) - } - .backgroundColor('#E2E2E2') - .borderRadius(10) - - // 信息 - Stack({alignContent: Alignment.End}) { - Row() { - Text('闹钟名') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.clockName + ' >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .margin({top: 20, bottom: 10}) - .onClick(() => { - this.dialogControllerName.open() - }) - - Divider().margin({bottom: 10}) - - Stack({alignContent: Alignment.End}) { - Row() { - Text('响铃时长') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.duration.toFixed(0) + ' 分钟 >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .margin({bottom: 10}) - .onClick(() => { - this.dialogControllerDuration.open() - }) - - Divider().margin({bottom: 10}) - - Stack({alignContent: Alignment.End}) { - Row() { - Text('再响间隔') - .fontSize(20) - } - .height('100%') - .width('100%') - Text(this.intervalMinute.toFixed(0) + ' 分钟,' + this.intervalTimes.toFixed(0) + ' 次 >') - .fontSize(15) - .fontColor('#E2E2E2') - } - .width('100%') - .height(30) - .onClick(() => { - this.dialogControllerInterval.open() - }) - } - } - .flexGrow(1) - .width('90%') - } - .width('100%') - .height('100%') - - // 删除按钮 - Text('删除') - .width('50%') - .height(45) - .textAlign(TextAlign.Center) - .fontSize(25) - .fontColor('#DE1A33') - .backgroundColor('#E2E2E2') - .borderRadius(20) - .margin({bottom: 10}) - .onClick(() => { - this.delete() - }) - .visibility(this.nowIndex == -1 ? Visibility.None : Visibility.Visible) - } - .width('100%') - .height('100%') - } - - // 确定 '√' - private confirm(): void{ - // 新增 - if(this.nowIndex == -1) { - // 判断当前闹钟时间是否存在 - let exist = false - this.clockItems.forEach(item => { - if(item.partition == this.timedArray[0] && item.hour == this.timedArray[1] && item.minute == this.timedArray[2]) { - exist = true - return - } - }) - if(exist) { - AlertDialog.show({ message: '该时间闹钟已添加!' }) - } else { - this.modifyMsg = [0, this.clockItems.length, this.clockItems.length] // 新增信息 - this.clockItems.push(new ClockItem(this.clockName, this.partitionIndex, this.timedArray[0], this.hourIndex, this.timedArray[1], - this.minuteIndex, this.timedArray[2], this.duration, this.intervalMinute, this.intervalTimes, true)) - this.showIndex = true - } - } else { - // 修改 - this.modifyMsg = [1, this.nowIndex,this.clockItems[this.nowIndex].reminderId] // 修改信息 - this.clockItems[this.nowIndex] = new ClockItem(this.clockName, this.partitionIndex, this.timedArray[0], this.hourIndex, this.timedArray[1], - this.minuteIndex, this.timedArray[2], this.duration, this.intervalMinute, this.intervalTimes, true) - this.showIndex = true - } - - } - - // 取消 '×' - private cancel(): void{ - this.showIndex = true - } - - // 删除 - private delete(): void{ - this.modifyMsg = [2, this.nowIndex, this.clockItems[this.nowIndex].reminderId] // 删除信息 - this.clockItems.splice(this.nowIndex, 1) - this.timedArray = ['下午', '02', '02'] - this.partitionIndex = 1 - this.hourIndex = 1 - this.minuteIndex = 1 - this.clockName = '闹钟' - this.duration = 5 - this.intervalMinute = 10 - this.intervalTimes = 3 - this.showIndex = true - } - - // 页面显示触发 - aboutToAppear(): void{ - // 修改 - if (this.nowIndex != -1){ - // 设置值 ClockItem - let item = this.clockItems[this.nowIndex] - this.timedArray = [item.partition, item.hour, item.minute] - this.partitionIndex = item.partitionIndex - this.hourIndex = item.hourIndex - this.minuteIndex = item.minuteIndex - this.clockName = item.name - this.duration = item.duration - this.intervalMinute = item.intervalMinute - this.intervalTimes = item.intervalTimes - } - } -} - -/** - * 闹钟-定时类 - * @param name 闹钟名 - * @param partitionIndex 上午、下午下标 - * @param partition 上午、下午 - * @param hourIndex 时下标 - * @param hour 时 - * @param minuteIndex 分下标 - * @param minute 分 - * @param duration 响铃时长 - * @param intervalMinute 再响间隔时间(分钟) - * @param intervalTimes 再响间隔次数 - * @param open 是否开启 true false - * @param reminderId 闹钟的reminderId - */ -@Observed export class ClockItem { - name: string - partitionIndex: number - partition: string - hourIndex: number - hour: string - minuteIndex: number - minute: string - duration: number - intervalMinute: number - intervalTimes: number - open: boolean - reminderId: number - - constructor(name: string, partitionIndex: number, partition: string, - hourIndex: number, hour: string, minuteIndex: number, minute: string, - duration: number, intervalMinute: number, intervalTimes: number, open: boolean) { - this.name = name - this.partitionIndex = partitionIndex - this.partition = partition - this.hourIndex = hourIndex - this.hour = hour - this.minuteIndex = minuteIndex - this.minute = minute - this.duration = duration - this.intervalMinute = intervalMinute - this.intervalTimes = intervalTimes - this.open = open - } -} - -// 闹钟名弹框 -@CustomDialog -struct DialogName { - @Consume clockName: string - name: string - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('闹钟名').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - TextArea({text: this.clockName}) - .width('90%').margin({top: 20}) - .onChange((value: string) => { - this.name = value - }) - Divider().width('90%').margin({top: 10}) - Row() { - Text('取消').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - Text('确定').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.clockName = this.name - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } -} - -// 响铃时长弹框 -@CustomDialog -struct DialogDuration { - @Consume duration: number - private durations: Array = [1, 5, 10, 15, 20, 30] //响铃时长,分钟 - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('响铃时长').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10, bottom: 10}) - ForEach(this.durations, item => { - Stack({alignContent: Alignment.End}) { - Row() { - Text(item + ' 分钟') - }.width('100%') - Radio({ value: item, group: 'radioGroup' }).checked(item == this.duration ? true: false) - .height(20) - .width(20) - .onChange((value: boolean) => { - this.controller.close(); - this.duration = item - }) - }.width('90%') - Divider().width('90%') - }) - Row() { - Text('取消').fontSize(15).width('100%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } -} - -// 再响间隔弹框 -@CustomDialog -struct DialogInterval { - @Consume intervalMinute: number // 再响间隔分钟,默认10分钟 - @Consume intervalTimes: number // 再响间隔次数,默认3次 - @State intervalMinuteSelect: number = 0 // 再响间隔分钟,界面选择值 - @State intervalTimesSelect: number = 0 // 再响间隔次数,界面选择值 - controller: CustomDialogController; - action: () => void; - - build() { - Column(){ - Text('再响间隔').fontSize(20).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Text('响铃间隔时间(分钟)').fontSize(10).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Row() { - Slider({ - value: this.intervalMinuteSelect, - min: 5, - max: 30, - step: 5, - style: SliderStyle.OutSet - }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) - .showSteps(true) - .showTips(true) - .onChange((value: number, mode: SliderChangeMode) => { - this.intervalMinuteSelect = value - }) - Text(this.intervalMinuteSelect.toFixed(0)).fontSize(16) - } - .padding({ top: 30 }) - .width('90%') - Divider().width('90%').margin({top: 10}) - Text('重复响铃次数').fontSize(10).width('90%').textAlign(TextAlign.Start).margin({top: 10}) - Row() { - Slider({ - value: this.intervalTimesSelect, - min: 0, - max: 10, - step: 2, - style: SliderStyle.OutSet - }) - .blockColor(Color.Blue) - .trackColor(Color.Gray) - .selectedColor(Color.Blue) - .showSteps(true) - .showTips(true) - .onChange((value: number, mode: SliderChangeMode) => { - this.intervalTimesSelect = value - }) - Text(this.intervalTimesSelect.toFixed(0)).fontSize(16) - } - .padding({ top: 50 }) - .width('90%') - Row() { - Text('取消').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.controller.close(); - }) - Text('确定').fontSize(15).width('50%').textAlign(TextAlign.Center).fontColor('#17A98E') - .onClick(() => { - this.intervalMinute = this.intervalMinuteSelect - this.intervalTimes = this.intervalTimesSelect - this.controller.close(); - }) - }.margin({top: 10, bottom: 20}) - }.width('100%') - } - aboutToAppear(): void{ - this.intervalMinuteSelect = this.intervalMinute // 再响间隔分钟,界面选择值 - this.intervalTimesSelect = this.intervalTimes // 再响间隔次数,界面选择值 - } -} \ No newline at end of file diff --git a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets b/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets deleted file mode 100644 index 3e6926d08a3f5b29b43afc927d696dc645b19e94..0000000000000000000000000000000000000000 --- a/CommonEventAndNotification/AlarmClock/entry/src/main/ets/pages/index.ets +++ /dev/null @@ -1,404 +0,0 @@ - /* - * 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. - */ -import reminderAgent from'@ohos.reminderAgent'; -import notification from '@ohos.notification' -import display from '@ohos.display'; -import {Detail, ClockItem} from './detail' -import data_preferences from '@ohos.data.preferences'; - -@Entry -@Component -struct Index { - private times: Array = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 1, 2] //时间刻度值 - private settings: RenderingContextSettings = new RenderingContextSettings(true) - private context: CanvasRenderingContext2D = new CanvasRenderingContext2D(this.settings) - @State canvasSize: number = 0 // canvas宽高 - @State canvasOnScreenRatio: number = 3 // 时钟画布是屏幕的几分之一,竖屏:宽度的1/3,此值为3。横屏:高度的1/4,此值为4 - private radius: number = 0 // 半径 - private sixtyParts = Math.PI * 2 / 60 // 60等分 - private twelveParts = Math.PI * 2 / 12 // 12等分 - @State screenWidth: number = 0 // 屏幕宽度 - @State screenHeight: number = 0 // 屏幕高度 - @State interval: any = -1 // 定时器 - @State showClock: boolean = true // true显示时钟 false显示时间 - @State showIndex: boolean = true // true主界面 false详情界面 - @State nowIndex: number = -1 // 新增时值为-1,修改时值为当前数组索引 - @State @Watch("resetAlarm") clockItems: Array = [] // 闹钟-定时 - @State modifyMsg: Array = [-1, -1, -1] // 记录clockItems变化数据,三个数值,第一个:0新增、1修改、2删除;第二个:修改闹钟的index值;第三个:闹钟reminderId - - aboutToAppear(){ - // 从首选项数据库获取数据 - this.getDate() - // 获取屏幕宽高 - display.getDefaultDisplay((err, data) => { - if(err.code === 0) { - console.info('Failed to obtain the default display object. Code: ' + JSON.stringify(err)) - } - this.screenWidth = data.width - this.screenHeight = data.height - // 设置canvas尺寸,竖屏取值为宽高最小值的1/3,横屏取值为宽高最小值的1/4 - this.canvasOnScreenRatio = (this.screenWidth < this.screenHeight ? 3 : 4) - this.canvasSize = (this.screenWidth < this.screenHeight ? this.screenWidth : this.screenHeight) / this.canvasOnScreenRatio - // 重置原点到canvas画布中间 - this.context.translate(this.canvasSize, this.canvasSize / 2) - }); - } - - build() { - Stack({alignContent: Alignment.Bottom}) { - Column() { - Column(){ - Text('闹钟') - .fontSize(30) - .margin({left: 20}) - }.height(80).width('100%').alignItems(HorizontalAlign.Start) - Canvas(this.context) - .height(this.canvasSize) - .aspectRatio(2.0) - .onReady(() =>{ - // 获取半径 - this.radius = this.canvasSize / 2 - 2.5 - var that = this - // 避免时钟闪现,先画一遍 - that.draw() - // 定时器 - this.interval = setInterval(function() { - that.draw() - }, 1000) - }) - .onClick(() => { - // 切换指针表盘和数字时钟 - this.showClock = !this.showClock - }) - - // 闹钟列表 - List({ space: 10, initialIndex: 0 }) { - ForEach(this.clockItems.map((item, index) => { - return { i: index, data: item } - }), - (item, index) => { - ListItem() { - Stack({alignContent: Alignment.End}) { - Column() { - Row() { - Text(item.data.partition).fontSize(15) - Text(item.data.hour+ ':' + item.data.minute).fontSize(25).margin({left: 10}) - } - Row() { - Text(item.data.name).fontSize(15) - Text('不重复').fontSize(15).margin({left: 10}) - }.margin({top: 5}) - } - .width('100%') - .margin({left: 10}) - .alignItems(HorizontalAlign.Start) - Toggle({ type: ToggleType.Switch, isOn: item.data.open }) - .selectedColor(0x39a2db) - .switchPointColor(0xe5ffffff) - .onChange((isOn: boolean) => { - item.data.open = !item.data.open - console.info('Component status:' + isOn) - // 关闭、打开闹钟 - this.modifyMsg = [item.data.open ? 0 : 2, index, item.data.reminderId] - this.resetAlarm() - }) - .width(30) - .aspectRatio(1.0) - } - .width('90%') - .height(60) - .backgroundColor('#E2E2E2') - .borderRadius(10) - }.width('100%') - .onClick(() => { - this.nowIndex = index // 下标 - this.showIndex = false // 展示修改界面 - }) - }, - item => item.data.name.toString()) - } - .listDirection(Axis.Vertical) // 排列方向 - .flexGrow(1) - .margin({top: 10}) - } - .width('100%') - .height('100%') - .visibility(this.showIndex ? Visibility.Visible : Visibility.Hidden) - - Column(){ - Detail({showIndex: $showIndex, clockItems: $clockItems, nowIndex: $nowIndex, modifyMsg: $modifyMsg}) - }.width('100%').height('100%').visibility(this.showIndex ? Visibility.Hidden : Visibility.Visible) - - Image('images/add.png') - .width(100) - .aspectRatio(1.0) - .margin({bottom: 10}) - .onClick(() => { - this.nowIndex = -1 // 新增闹钟,值为-1 - this.showIndex = false // 展示新增闹钟界面 - }).visibility(this.showIndex ? Visibility.Visible : Visibility.Hidden) - } - .width('100%') - .height('100%') - } - - // 开始绘制 - private draw(): void{ - // 清空绘制 - this.context.clearRect(-this.canvasSize, this.canvasSize / -2, this.canvasSize * 2, this.canvasSize) - // 获取当前时间 - let date = new Date() - if(this.showClock) { - // 画表盘 - this.drawDials() - // 画秒针 - this.drawSecond(date.getSeconds()) - // 画分针 - this.drawMinute(date.getMinutes(), date.getSeconds()) - // 画时针 - this.drawHour(date.getHours(), date.getMinutes()) - } else { - this.drawTime(date.getHours().toString(), date.getMinutes().toString(), date.getSeconds().toString()) - } - } - - // 画时间 - private drawTime(hour: string, minute: string, second: string): void{ - let time = this.fillZero(hour) + ':' + this.fillZero(minute) + ':' + this.fillZero(second) - this.context.save() - this.context.font = '100px' - this.context.beginPath() - this.context.textAlign = 'center' - this.context.fillText(time, 0, 0) - this.context.restore() - } - - // 补零:HH:mm:ss - private fillZero(val): string{ - var len = val.length; - while(len < 2) { - val = "0" + val; - len++; - } - return val; - } - - // 画表盘 - private drawDials(): void{ - // 画原点 - this.context.save() - this.context.beginPath() - this.context.arc(0, 0, 5, 0, Math.PI * 2) - this.context.fill() - this.context.stroke() - this.context.restore() - // 字体大小 - this.context.font = '20px' - // 画圆 - this.context.save() - this.context.lineWidth = 5 - this.context.beginPath() - this.context.arc(0, 0, this.radius, 0, 2 * Math.PI) - this.context.stroke() - this.context.restore() - - // 画刻度 - for (let n = 1; n <= 60; n++) { - // 从三点钟方向开始获取60个刻度的角度 - var theta = (n - 3) * (Math.PI * 2) / 60; - this.context.save() - // 刻度宽度为2 - this.context.lineWidth = 2 - this.context.beginPath() - // 刻度起始位置 - var x_move = this.radius * Math.cos(theta); - var y_move = this.radius * Math.sin(theta); - // 非整点刻度结束位置 - var x_to = (this.radius - 5) * Math.cos(theta); - var y_to = (this.radius - 5) * Math.sin(theta); - // 整点刻度 - if((n-3) % 5 == 0) { - //整点刻度宽度 - this.context.lineWidth = 3 - // 整点刻度结束位置 - x_to = (this.radius - 10) * Math.cos(theta); - y_to = (this.radius - 10) * Math.sin(theta); - // 整点时间位置 - var x_time = (this.radius - 25) * Math.cos(theta); - var y_time = (this.radius - 25) * Math.sin(theta); - // 绘制整点时间 - this.context.fillText(this.times[(n - 3) / 5] + '', x_time - 5, y_time + 3) - } - // 绘制刻度线 - this.context.moveTo(x_move, y_move) - this.context.lineTo(x_to, y_to) - this.context.stroke() - this.context.restore() - } - } - - // 画秒针 - private drawSecond(second: number): void{ - this.context.save() - this.context.fillStyle = 'red' - var theta = (second - 15) * 2 * Math.PI / 60; - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -3); - this.context.lineTo(-15, 3); - this.context.lineTo(this.radius * 0.9, 1); - this.context.lineTo(this.radius * 0.9, -1); - this.context.fill(); - this.context.restore(); - } - - // 画分针 - private drawMinute(minute: number, second: number): void{ - this.context.save() - var theta = ((minute + second / 60 - 15) * 2 * Math.PI / 60) - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -4); - this.context.lineTo(-15, 4); - this.context.lineTo(this.radius * 0.8, 1); - this.context.lineTo(this.radius * 0.8, -1); - this.context.fill(); - this.context.restore(); - } - - // 画时针 - private drawHour(hour:number, minute: number): void{ - this.context.save() - var theta = ((hour + minute / 60 - 3) * 2 * Math.PI / 12) - this.context.rotate(theta) - this.context.beginPath() - this.context.moveTo(-15, -5); - this.context.lineTo(-15, 5); - this.context.lineTo(this.radius * 0.5, 1); - this.context.lineTo(this.radius * 0.5, -1); - this.context.fill(); - this.context.restore(); - } - - // 监听闹钟数据变化 - private resetAlarm(): void{ - let opeNum = this.modifyMsg[0] - let index = this.modifyMsg[1] - let reminderId = this.modifyMsg[2] - if(opeNum == 0) { - // 新增 - reminderAgent.publishReminder(this.addAlarm(this.clockItems[index], index), (err, reminderId) =>{ - if(err.code == 0) { - this.clockItems[index].reminderId = reminderId // 设置reminderId - this.saveData() // 保存闹钟数据 - }else { - console.info("publishReminder" + index + "error: " + err.message) - } - }); - } else if(opeNum == 1) { - // 修改,先停止原先的闹钟再开启修改后的 - reminderAgent.cancelReminder(reminderId) - reminderAgent.publishReminder(this.addAlarm(this.clockItems[index], index), (err, reminderId) =>{ - if(err.code == 0) { - this.clockItems[index].reminderId = reminderId // 设置reminderId - this.saveData() // 保存闹钟数据 - }else { - console.info("publishReminder" + index + "error: " + err.message) - } - }); - } else { - // 删除 - reminderAgent.cancelReminder(reminderId) - this.saveData() // 保存闹钟数据 - } - } - - // 根据闹钟数据,新增闹钟 - private addAlarm(item: ClockItem, index: number): reminderAgent.ReminderRequestAlarm{ - return { - reminderType: reminderAgent.ReminderType.REMINDER_TYPE_ALARM, - hour: item.partition == '上午' ? parseInt(item.hour) : ((parseInt(item.hour) + 12) == 24 ? 0 : parseInt(item.hour) + 12), // 小时 - minute: parseInt(item.minute), // 分钟 - daysOfWeek: [1, 2, 3, 4, 5, 6, 7], // 星期几 - actionButton: [ - { - title: "close", - type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_CLOSE - }, - { - title: "snooze", - type: reminderAgent.ActionButtonType.ACTION_BUTTON_TYPE_SNOOZE - }, - ], - wantAgent: { - pkgName: "com.example.helloworld0218", - abilityName: "com.example.helloworld0218.MainAbility" - }, - maxScreenWantAgent: { - pkgName: "com.example.helloworld0218", - abilityName: "com.example.helloworld0218.MainAbility" - }, - ringDuration: item.duration * 60, // 响铃时长 - snoozeTimes: item.intervalTimes, // 延迟提醒次数 - timeInterval: item.intervalMinute, // 延迟提醒间隔 最小五分钟 - title: item.name, - content: item.partition + item.hour + ':' + item.minute, - expiredContent: "this reminder has expired", - snoozeContent: "remind later", - notificationId: index, - slotType: notification.SlotType.SOCIAL_COMMUNICATION - } - } - - // 保存闹钟数据到首选项数据库 - private saveData() { - let promise = data_preferences.getPreferences(globalThis.context, 'mystore') - promise.then((preferences) => { - let promisePut = preferences.put('data', JSON.stringify(this.objs2array())) - promisePut.then(() => { - preferences.flush() - console.info("Put the value of startup successfully.") - }).catch((err) => { - console.info("Put the value of startup failed, err: " + err) - }) - }).catch((err) => { - console.info("Get the preferences failed, err: " + err) - }) - } - - // 从首选项数据库中获取闹钟数据 - private getDate() { - let promise = data_preferences.getPreferences(globalThis.context, 'mystore') - promise.then((preferences) => { - let promiseGet = preferences.get('data', '') - promiseGet.then(value => { - this.clockItems = JSON.parse(value.toString()) - }) - }) - } - - // 将对象数组转换成数组 - private objs2array() { - let array = [] - for(let i=0;i - - -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • 点击抽奖
  • - -
  • 奖品
  • -
- - ``` - -2. 抽奖盘CSS - - 通过绝对定位的方式,可以快速的将一个无序列表变为九宫格效果。 - - ``` - /* 抽奖div */ - .luckyDraw { - width: 480px; - margin: 0 auto; - } - - /* 抽奖列表 */ - .prizes { - width: 480px; - margin: 30px auto; - position: relative; - } - - /* 奖品格子 */ - .prizes li { - width: 160px; - height: 160px; - box-sizing: border-box; - text-align: center; - line-height: 160px; - position: absolute; - border-radius: 25px; - padding: 10px,10px; - } - - /* 奖品格子位置 */ - .prizes li:nth-of-type(1) { - left: 0; - top: 0; - } - .... - ``` - -3. 抽奖盘JS - - 预先随机好结果,通过可变速的旋转动作,旋转指定的圈数后,最后落在指定位置。运行时的旋转效果通过给元素动态添加CSS效果来实现。 - - ``` - let i = 0; //转到哪个位置 - let count = 0; //转圈初始值 - let totalCount = 8; //至少转动的总圈数 - let speed = 500; //转圈速度,值越大越慢 - let index = 3; //转到哪个奖品 - - // 旋转函数,预先随机好结果,通过可变速的旋转动作,到达指定的圈数后,最后落在指定位置 - function roll() { - //速度衰减 - speed -= 50; - if (speed <= 10) { - speed = 10; - } - //每次调用都去掉全部active类名 - for (var j = 0;j < ali.length; j++) { - ali[j].classList.remove('active'); - } - i++; - //计算转圈次数 - if (i >= ali.length - 1) { - i = 0; - count++; - } - prizeText.innerHTML = arr[i]; //显示当前奖品名称 - ali[i].classList.add('active'); //添加激活类名,给奖品加样式 - //满足转圈数和指定位置就停止 - if (count >= totalCount && (i + 1) == index) { - clearTimeout(timer); - isClick = true; - speed = initSpeed; - dialogText.innerHTML = "恭喜获得 " + arr[i] + " 请填写收件地址"; - dialogImg.src = arrImg[i]; - timer = setTimeout(openDialog, 1000); // 等待1s打开弹窗 - } else { - timer = setTimeout(roll, speed); //不满足条件时调用定时器 - //最后一圈减速 - if (count >= totalCount - 1 || speed <= 50) { - speed += 100; - } - } - } - // 抽奖开始函数 - function start() { - finishText.style.display = "none"; - // 防止抽奖多次触发 - if (isClick) { - count = 0; - //随机产生中奖位置 - index = Math.floor(Math.random() * arr.length + 1); - roll(); - isClick = false; - } - } - ``` - -# Web组件 - -通过Web组件不仅可以在OpenHarmony设备上展示H5小程序的界面,也可以通过runJavaScript\(\)执行小程序的JS函数,来实现eTS与H5小程序的交互功能。 - -Web组件代码: - -``` -@Entry -@Component -struct Index { - // Web组件控制器可以控制Web组件各种行为 - webController: WebController = new WebController() - - build() { - Row() { - Column() { - Text("Web组件外") - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button("点击抽奖") - .fontSize(40) - .height("8%") - .width("30%") - .onClick(() => { - this.webController.runJavaScript({ script: 'start()' }); // 运行web加载的本地JS函数 - console.log("点击抽奖按钮") - }) - Text("-----------------------------") - .fontSize(50) - Text("Web组件内") - .fontSize(50) - .fontWeight(FontWeight.Bold) - // Web组件加载本地H5 - Web({ src: $rawfile('index.html'), controller: this.webController }) - // 设置是否开启通过$rawfile(filepath/filename)访问应用中rawfile路径的文件, 默认启用。 - .fileAccess(true) - // 设置是否允许自动加载图片资源,默认允许。 - .imageAccess(true) - // 设置是否允许执行JavaScript脚本,默认允许执行。 - .javaScriptAccess(true) - .backgroundColor(Color.Pink) - } - .width('100%') - } - .height('100%') - } -} -``` - -# 恭喜您 - -通过本篇Codelab,您可以学到: - -1、Web组件加载本地H5小程序。 - -2、Web组件运行本地H5小程序的JS函数。 \ No newline at end of file diff --git a/ETSUI/WebComponent/build-profile.json5 b/ETSUI/WebComponent/build-profile.json5 deleted file mode 100644 index fc53829be062f3a883f815802e6039c733ebb352..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/build-profile.json5 +++ /dev/null @@ -1,26 +0,0 @@ -{ - "app": { - "compileSdkVersion": 9, - "compatibleSdkVersion": 9, - "products": [ - { - "name": "default", - "signingConfig": "default", - } - ] - }, - "modules": [ - { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - } - ] -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/build-profile.json5 b/ETSUI/WebComponent/entry/build-profile.json5 deleted file mode 100644 index 7dc37bb919dada5132609c409200db266559004f..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/build-profile.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "apiType": 'stageMode', - "buildOption": { - }, - "targets": [ - { - "name": "default", - }, - { - "name": "ohosTest", - } - ] -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/hvigorfile.js b/ETSUI/WebComponent/entry/hvigorfile.js deleted file mode 100644 index d7720ee6a7aad5c617d1fd2f6fc8c87067bfa32c..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/hvigorfile.js +++ /dev/null @@ -1,2 +0,0 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').hapTasks diff --git a/ETSUI/WebComponent/entry/package.json b/ETSUI/WebComponent/entry/package.json deleted file mode 100644 index c7685ac4e7c0d79df04c96744f0d8f22cb4a9025..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "license": "ISC", - "devDependencies": {}, - "name": "entry", - "ohos": { - "org": "huawei", - "directoryLevel": "module", - "buildTool": "hvigor" - }, - "description": "example description", - "repository": {}, - "version": "1.0.0", - "dependencies": {} -} diff --git a/ETSUI/WebComponent/entry/src/main/ets/Application/AbilityStage.ts b/ETSUI/WebComponent/entry/src/main/ets/Application/AbilityStage.ts deleted file mode 100644 index 2f96918c937982a919a3d818c59b58c0b48839c9..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/ets/Application/AbilityStage.ts +++ /dev/null @@ -1,22 +0,0 @@ -/* - * 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. - */ - -import AbilityStage from "@ohos.application.AbilityStage" - -export default class MyAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] MyAbilityStage onCreate") - } -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/src/main/ets/MainAbility/MainAbility.ts b/ETSUI/WebComponent/entry/src/main/ets/MainAbility/MainAbility.ts deleted file mode 100644 index 50f32a075d2ce8e0e644fa28f7b0b0eaa8d812ad..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/ets/MainAbility/MainAbility.ts +++ /dev/null @@ -1,49 +0,0 @@ -/* - * 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. - */ - -import Ability from '@ohos.application.Ability' - -export default class MainAbility extends Ability { - onCreate(want, launchParam) { - console.log("[Demo] MainAbility onCreate") - globalThis.abilityWant = want; - } - - onDestroy() { - console.log("[Demo] MainAbility onDestroy") - } - - onWindowStageCreate(windowStage) { - // Main window is created, set main page for this ability - console.log("[Demo] MainAbility onWindowStageCreate") - - windowStage.setUIContent(this.context, "pages/index", null) - } - - onWindowStageDestroy() { - // Main window is destroyed, release UI related resources - console.log("[Demo] MainAbility onWindowStageDestroy") - } - - onForeground() { - // Ability has brought to foreground - console.log("[Demo] MainAbility onForeground") - } - - onBackground() { - // Ability has back to background - console.log("[Demo] MainAbility onBackground") - } -}; diff --git a/ETSUI/WebComponent/entry/src/main/ets/pages/index.ets b/ETSUI/WebComponent/entry/src/main/ets/pages/index.ets deleted file mode 100644 index 6300ac2714a108edc90bc5c8c2ce99de91f106d5..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/ets/pages/index.ets +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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. - */ - -@Entry -@Component -struct Index { - // web组件控制器可以控制Web组件各种行为 - webController: WebController = new WebController() - - build() { - Row() { - Column() { - Text("Web组件外") - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button("点击抽奖") - .fontSize(40) - .height("8%") - .width("30%") - .onClick(() => { - this.webController.runJavaScript({ script: 'start()' }); - console.log("点击抽奖按钮") - }) - Text("-----------------------------") - .fontSize(50) - Text("Web组件内") - .fontSize(50) - .fontWeight(FontWeight.Bold) - // web组件加载本地H5 - Web({ src: $rawfile('index.html'), controller: this.webController }) - // 设置是否开启通过$rawfile(filepath/filename)访问应用中rawfile路径的文件, 默认启用。 - .fileAccess(true) - // 设置是否允许自动加载图片资源,默认允许。 - .imageAccess(true) - // 设置是否允许执行JavaScript脚本,默认允许执行。 - .javaScriptAccess(true) - .backgroundColor(Color.Pink) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/src/main/module.json5 b/ETSUI/WebComponent/entry/src/main/module.json5 deleted file mode 100644 index 1cc42784a7ca48aced098c4f1444cff29f645b27..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/module.json5 +++ /dev/null @@ -1,42 +0,0 @@ -{ - "module": { - "name": "entry", - "type": "entry", - "srcEntrance": "./ets/Application/AbilityStage.ts", - "description": "$string:entry_desc", - "mainElement": "MainAbility", - "deviceTypes": [ - "phone", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:main_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "MainAbility", - "srcEntrance": "./ets/MainAbility/MainAbility.ts", - "description": "$string:MainAbility_desc", - "icon": "$media:icon", - "label": "$string:MainAbility_label", - "visible": true, - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ] - } - ], - "requestPermissions": [ - { - name: "ohos.permission.INTERNET" - } - ] - } -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/src/main/resources/base/element/string.json b/ETSUI/WebComponent/entry/src/main/resources/base/element/string.json deleted file mode 100644 index 6631d602a5b72ee29874ec0abab7b93ccf769220..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_desc", - "value": "description" - }, - { - "name": "MainAbility_desc", - "value": "description" - }, - { - "name": "MainAbility_label", - "value": "web组件加载本地H5小程序" - } - ] -} \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/src/main/resources/base/media/icon.png b/ETSUI/WebComponent/entry/src/main/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/base/media/icon.png and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/base/profile/main_pages.json b/ETSUI/WebComponent/entry/src/main/resources/base/profile/main_pages.json deleted file mode 100644 index feec276e105eeb8d621c20aaf838f318b0a94150..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/resources/base/profile/main_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "pages/index" - ] -} diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/css/index.css b/ETSUI/WebComponent/entry/src/main/resources/rawfile/css/index.css deleted file mode 100644 index 3a025534918c771ca1c6993fc10a3ff9f728a4bf..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/resources/rawfile/css/index.css +++ /dev/null @@ -1,214 +0,0 @@ -/* - * 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. - */ - -/* 重置样式 */ -* { - margin: 0; - padding: 0;/* 去除无序列表的样式 */ - list-style: none;/* 去除文本的样式 */ - text-decoration: none; -} - -/* 图片样式 */ -img { - width: 100%; - height: 100%; - margin: auto; - display: block; -} - -/* 抽奖div */ -.luckyDraw { - width: 480px; - margin: 0 auto; -} - -/* 抽奖列表 */ -.prizes { - width: 480px; - margin: 30px auto; - position: relative; -} - -/* 开始抽奖文本 */ -.trigger { - font-size: 20px; - text-align: center; - display:block; - line-height:140px; -} - -/* 奖品格子 */ -.prizes li { - width: 160px; - height: 160px; - box-sizing: border-box; - text-align: center; - line-height: 160px; - position: absolute; - border-radius: 25px; - padding: 10px,10px; -} - -/* 奖品格子位置 */ -.prizes li:nth-of-type(1) { - left: 0; - top: 0; -} - -.prizes li:nth-of-type(2) { - left: 160px; - top: 0; -} - -.prizes li:nth-of-type(3) { - left: 320px; - top: 0; -} - -.prizes li:nth-of-type(4) { - left: 320px; - top: 160px; -} - -.prizes li:nth-of-type(5) { - left: 320px; - top: 320px; -} - -.prizes li:nth-of-type(6) { - left: 160px; - top: 320px; -} - -.prizes li:nth-of-type(7) { - left: 0; - top: 320px; -} - -.prizes li:nth-of-type(8) { - left: 0; - top: 160px; -} - -.prizes li:nth-of-type(9) { - width: 140px; - height: 140px; - left: 160px; - top: 160px; - background: pink; - margin: 10px; - text-align: center; -} - -/* 抽奖效果 */ -.active:after { - top: 0; - left: 0; - content: ""; - width: 100%; - height: 100%; - position: absolute; - border-radius: 24px; - background: rgba(1, 1, 1, 0.3); -} - -/* 奖品显示区样式 */ -#prizeText { -left: 0px; -top: 500px; -width: 480px; -margin: 0 auto; -font-size: 28px; -text-align: center; -position: absolute; -} - -/* 弹窗样式 */ -.dialog { - top: 0; - left: 0; - z-index: 1; - width: 100%; - height: 100%; - display: none; - overflow: auto; - position: fixed; - background-color: rgba(1, 1, 1, 0.3); -} - -/* 弹窗内容 */ -.dialog-content { - width: 480px; - height: 410px; - padding: 20px; - position: static; - margin: 100px auto; - border-radius: 15px; - background-color: #fefefe; - border: 1px solid #888; -} - -/* 收货信息 */ -.infoBox{ - padding: 24px; - margin-bottom: 10px; - vertical-align: middle; - border-bottom: 1px solid #DDE0E8; -} - -/* 弹窗内容 */ -.infoBox .infoInput { - border: 1px solid #D2D9dC; - border-radius: 2px; - color: #444; - font: 12px; - padding: 8px 14px; - margin-bottom: 8px; - width: 310px; -} - -/* 弹窗图片 */ -.dialogImg { - width: 150px; - margin: 10px,10px,10px,10px -} - -/* 提交按钮 */ -.btn { - border: none; - color: white; - padding: 15px 30px; - text-align: center; - text-decoration: none; - display: inline-block; - font-size: 18px; - border-radius: 15px; - display: block; - margin: auto; - background-color: #4CAF50; /* 绿色 */ -} - -/* 关闭按钮 */ -.close { - color: #aaa; - float: right; - font-size: 28px; - font-weight: bold; -} -.close:hover, -.close:focus { - color: black; -} diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/1-band.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/1-band.jpg deleted file mode 100644 index 26b8a82d1093d0373569b456c8fe805f8946285f..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/1-band.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/2-buds.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/2-buds.jpg deleted file mode 100644 index 9c954eda456a83e93872e31cbc988ec530b97017..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/2-buds.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/3-car.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/3-car.jpg deleted file mode 100644 index 337a7735cce62499a3bc88851a446b72f27e01a6..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/3-car.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/4-computer.png b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/4-computer.png deleted file mode 100644 index 37cf717a45d19cb48de9918ba8fde56c18213d63..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/4-computer.png and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/5-pad.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/5-pad.jpg deleted file mode 100644 index 5bf7164d5103d0304ef03d93da42ec664b5960a7..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/5-pad.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/6-phone.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/6-phone.jpg deleted file mode 100644 index dd9cdb5de63f18b60bd4356c8fe5f589f5b829f0..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/6-phone.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/7-router.jpg b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/7-router.jpg deleted file mode 100644 index dea3ad9c1508472084b888c7a3602fe2e2e13380..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/7-router.jpg and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/8-watch.png b/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/8-watch.png deleted file mode 100644 index 6f718a2878a9f74278204fd425a48c5e0856d4e7..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/entry/src/main/resources/rawfile/img/8-watch.png and /dev/null differ diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/index.html b/ETSUI/WebComponent/entry/src/main/resources/rawfile/index.html deleted file mode 100644 index 8b1e70216910bf8b70a922cc108faa7bdfa6ebdf..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/resources/rawfile/index.html +++ /dev/null @@ -1,60 +0,0 @@ - - - - - - - - 抽奖页面 - - -
- - -
    -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • -
  • 点击抽奖
  • - -
  • 奖品
  • -
-
- - -
- -
- × -
-

恭喜获得如下奖品,请填写收货地址

- -
-

-

-

-
- -
-
-
- - - - \ No newline at end of file diff --git a/ETSUI/WebComponent/entry/src/main/resources/rawfile/js/index.js b/ETSUI/WebComponent/entry/src/main/resources/rawfile/js/index.js deleted file mode 100644 index a2091680c78c5a9a4a1dd6c1561b97958f500c27..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/entry/src/main/resources/rawfile/js/index.js +++ /dev/null @@ -1,142 +0,0 @@ -/* - * 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. - */ - -// 奖品名数组 -let arr = ["手环", "耳机", "汽车", "电脑", "平板", "手机", "路由", "手表"]; -// 奖品图片数组 -let arrImg = ["./img/1-band.jpg", "./img/2-buds.jpg", "./img/3-car.jpg", - "./img/4-computer.png", "./img/5-pad.jpg", "./img/6-phone.jpg", - "./img/7-router.jpg", "./img/8-watch.png"]; -// 获取奖品列表 -let prizes = document.querySelector('.prizes'); -// 获取奖品区名称 -let prizeText = document.querySelector('#prizeText'); -// 获取全部奖品单元格 -let ali = document.querySelectorAll('.prizes-li'); -// 获取弹窗 -let dialog = document.querySelector('.dialog'); -// 获取关闭弹窗span -let close = document.querySelector('.close'); -// 获取提交按钮 -let btn = document.querySelector('.btn'); -// 获取弹窗文本 -let dialogText = document.querySelector('.dialogText'); -// 获取弹窗图片 -let dialogImg = document.querySelector('.dialogImg'); -// 获取奖品img -let pic = document.querySelectorAll('.pic'); -// 抽奖结束文字 -let finishText = document.querySelector('.finishText'); -// 信息输入框 -let infoInput = document.querySelectorAll('.infoInput'); - -let i = 0; //转到哪个位置 -let count = 0; //转圈初始值 -let totalCount = 8; //至少转动的总圈数 -let speed = 500; //转圈速度,值越大越慢 -let initSpeed = 500; -let timer; -let isClick = true; -let index = 3; //指定转到哪个奖品 - -// 绑定img -for (let j = 0;j < pic.length; j++) { - pic[j].src = arrImg[j]; -} - -// 旋转函数,预先随机好结果,通过可变速的旋转动作,到达指定的圈数后,最后落在指定位置 -function roll() { - //速度衰减 - speed -= 50; - if (speed <= 10) { - speed = 10; - } - //每次调用都去掉全部active类名 - for (let j = 0; j < ali.length; j++) { - ali[j].classList.remove('active'); - } - i++; - //计算转圈次数 - if (i >= ali.length - 1) { - i = 0; - count++; - } - - prizeText.innerHTML = arr[i]; //显示当前奖品名称 - - ali[i].classList.add('active'); //添加激活类名,给奖品加样式 - //满足转圈数和指定位置就停止 - if (count >= totalCount && (i + 1) == index) { - clearTimeout(timer); - isClick = true; - speed = initSpeed; - dialogText.innerHTML = "恭喜获得 " + arr[i] + " 请填写收件地址"; - dialogImg.src = arrImg[i]; - timer = setTimeout(openDialog, 1000); // 等待1s打开弹窗 - } else { - timer = setTimeout(roll, speed); //不满足条件时调用定时器 - //最后一圈减速 - if (count >= totalCount - 1 || speed <= 50) { - speed += 100; - } - } -} - -// 抽奖开始函数 -function start() { - finishText.style.display = "none"; - // 防止抽奖多次触发 - if (isClick) { - count = 0; - //随机产生中奖位置 - index = Math.floor(Math.random() * arr.length + 1); - roll(); - isClick = false; - } -} - -// 打开弹窗 -function openDialog() { - dialog.style.display = "block"; - // 清楚输入框内容 - for (var i = 0;i < infoInput.length; i++) { - infoInput[i].value = ""; - } -} - -// 关闭弹窗 -function closeDialog() { - dialog.style.display = "none"; -} - -// 点击 (x), 关闭弹窗 -close.onclick = function () { - closeDialog(); -} - -// 在用户点击其他地方时,关闭弹窗 -window.onclick = function (event) { - if (event.target == dialog) { - closeDialog(); - } -} -// 提交按钮 -btn.onclick = function () { - closeDialog(); - finishText.style.display = "block"; -} - -// 结束语 - diff --git a/ETSUI/WebComponent/figures/GIF-2022-5-6-17-53-58.gif b/ETSUI/WebComponent/figures/GIF-2022-5-6-17-53-58.gif deleted file mode 100644 index a3f64e532545420169f47478afa072ab4ddb6648..0000000000000000000000000000000000000000 Binary files a/ETSUI/WebComponent/figures/GIF-2022-5-6-17-53-58.gif and /dev/null differ diff --git a/ETSUI/WebComponent/hvigorfile.js b/ETSUI/WebComponent/hvigorfile.js deleted file mode 100644 index 5f2735e3deeaf655828407544bbed9365c258278..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/hvigorfile.js +++ /dev/null @@ -1,2 +0,0 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').appTasks \ No newline at end of file diff --git a/ETSUI/WebComponent/package.json b/ETSUI/WebComponent/package.json deleted file mode 100644 index ec5d226fa60c3ba501a253ad6f521614c3249d28..0000000000000000000000000000000000000000 --- a/ETSUI/WebComponent/package.json +++ /dev/null @@ -1,18 +0,0 @@ -{ - "license":"ISC", - "devDependencies":{}, - "name":"webcomponent", - "ohos":{ - "org":"huawei", - "directoryLevel":"project", - "buildTool":"hvigor" - }, - "description":"example description", - "repository":{}, - "version":"1.0.0", - "dependencies":{ - "@ohos/hvigor-ohos-plugin":"1.0.6", - "hypium":"^1.0.0", - "@ohos/hvigor":"1.0.6" - } -} \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/build-profile.json5 b/Media/Audio_OH_ETS/entry/build-profile.json5 index 7dc37bb919dada5132609c409200db266559004f..7e16d13222e9cefcf5c59688c6b5607912069114 100644 --- a/Media/Audio_OH_ETS/entry/build-profile.json5 +++ b/Media/Audio_OH_ETS/entry/build-profile.json5 @@ -5,9 +5,6 @@ "targets": [ { "name": "default", - }, - { - "name": "ohosTest", } ] } \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/main/ets/pages/index.ets b/Media/Audio_OH_ETS/entry/src/main/ets/pages/index.ets index f27e673f5e60204075c42d00a8d64536fdf6ccca..82756ea89a7d80b54734d2e363b47e3bddd3fc86 100644 --- a/Media/Audio_OH_ETS/entry/src/main/ets/pages/index.ets +++ b/Media/Audio_OH_ETS/entry/src/main/ets/pages/index.ets @@ -133,14 +133,20 @@ struct Index { @Builder RecordItem(item) { Column() { Text('录音名称:' + item.displayName) + .maxLines(1) .width('100%') - .fontSize(24) + .fontSize(16) + .textOverflow({overflow:TextOverflow.Ellipsis}) Text('录音时间:' + DateTimeUtils.dateFormat(item.dateAdded)) + .maxLines(1) .width('100%') - .fontSize(24) + .fontSize(16) + .textOverflow({overflow:TextOverflow.Ellipsis}) Text('录音目录:' + item.uri) + .maxLines(1) .width('100%') - .fontSize(24) + .fontSize(16) + .textOverflow({overflow:TextOverflow.Ellipsis}) } .stateStyles({ normal: this.normalStyles, diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/TestAbility.ts b/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/TestAbility.ts deleted file mode 100644 index d5e778f1fe8d47f6caa1d0d939c12e2ee9ef379b..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/TestAbility.ts +++ /dev/null @@ -1,39 +0,0 @@ -import Ability from '@ohos.application.Ability' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from 'hypium/index' -import testsuite from '../test/List.test' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - console.log('TestAbility onCreate') - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - console.log('TestAbility onDestroy') - } - - onWindowStageCreate(windowStage) { - console.log('TestAbility onWindowStageCreate') - windowStage.setUIContent(this.context, 'TestAbility/pages/index', null) - - globalThis.abilityContext = this.context; - } - - onWindowStageDestroy() { - console.log('TestAbility onWindowStageDestroy') - } - - onForeground() { - console.log('TestAbility onForeground') - } - - onBackground() { - console.log('TestAbility onBackground') - } -}; \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/pages/index.ets deleted file mode 100644 index 733600abc03d7e777ef1a55eaddd77f4d1d7d66d..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestAbility/pages/index.ets +++ /dev/null @@ -1,34 +0,0 @@ -import router from '@ohos.router'; - -@Entry -@Component -struct Index { - aboutToAppear() { - console.info('TestAbility index aboutToAppear') - } - @State message: string = 'Hello World' - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - }.type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(()=>{ - }) - } - .width('100%') - } - .height('100%') - } - } \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index 7a0024d415832196a3493adf328476a98597aeaf..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,58 +0,0 @@ -import TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' - -var abilityDelegator = undefined -var abilityDelegatorArguments = undefined - -function translateParamsToString(parameters) { - const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s it', - '-s level', '-s testType', '-s size', '-s timeout' - ]) - let targetParams = ''; - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - console.log("onAbilityCreateCallback"); -} - -async function addAbilityMonitorCallback(err: any) { - console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - console.info("OpenHarmonyTestRunner OnPrepare ") - } - - async onRun() { - console.log('OpenHarmonyTestRunner onRun run') - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName - cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters) - console.info('cmd : '+cmd) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - console.info('executeShellCommand : err : ' + JSON.stringify(err)); - console.info('executeShellCommand : data : ' + d.stdResult); - console.info('executeShellCommand : data : ' + d.exitCode); - }) - console.info('OpenHarmonyTestRunner onRun end') - } -}; \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/Ability.test.ets b/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 1236e0ce6077de4c6a4dbc22c79b1298173c07ac..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,13 +0,0 @@ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from 'hypium/index' - -export default function abilityTest() { - describe('ActsAbilityTest', function () { - it('assertContain',0, function () { - console.info("it begin") - let a = 'abc' - let b = 'b' - expect(a).assertContain(b) - expect(a).assertEqual(a) - }) - }) -} \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/List.test.ets b/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index d766fe249dfc3ada636f27e64d9b64451ce32c93..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test' - -export default function testsuite() { - abilityTest() -} \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/module.json5 b/Media/Audio_OH_ETS/entry/src/ohosTest/module.json5 deleted file mode 100644 index cd9aae6f6983ac8b23d8be72e1a6fcf8bd651d21..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,39 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:entry_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "default", - "tablet" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "uiSyntax": "ets", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/TestAbility/TestAbility.ts", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:white", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/element/string.json b/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 8407800739f589b2e0620ae2cd1601f8a338721a..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "entry_test_desc", - "value": "i am an entry for tv" - }, - { - "name": "TestAbility_desc", - "value": "the tv entry test ability" - }, - { - "name": "TestAbility_label", - "value": "tvBase" - } - ] -} \ No newline at end of file diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/media/icon.png b/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/profile/test_pages.json b/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/profile/test_pages.json deleted file mode 100644 index fcef82b4dfc18e28106ff9ecd1c8b48ec74d18a4..0000000000000000000000000000000000000000 --- a/Media/Audio_OH_ETS/entry/src/ohosTest/resources/base/profile/test_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "TestAbility/pages/index" - ] -} diff --git a/Media/Audio_OH_ETS/package.json b/Media/Audio_OH_ETS/package.json index 379ccc8884e10a52b47bd8c7f8a8ff7ed9278e83..7e700b63c5327266c07dfa0a6fee83cccb230a00 100644 --- a/Media/Audio_OH_ETS/package.json +++ b/Media/Audio_OH_ETS/package.json @@ -11,8 +11,8 @@ "repository":{}, "version":"1.0.0", "dependencies":{ - "@ohos/hypium":"1.0.0", - "@ohos/hvigor-ohos-plugin":"1.1.3", - "@ohos/hvigor":"1.1.3" + "@ohos/hypium":"1.0.3", + "@ohos/hvigor-ohos-plugin":"1.3.1", + "@ohos/hvigor":"1.3.1" } } \ No newline at end of file diff --git a/README.md b/README.md index f288a3e3f9b94e3d4264ba6cf68a9c7d31b5f3a3..f59eb05615b58ba8137ada09e34951d5c1c4760d 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,6 @@ - [分布式邮件(eTS)(Full SDK)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OHMailETS)(API 8+) - [分布式亲子早教系统(eTS)(Full SDK)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/OpenHarmonyPictureGame)(API 8+) - [分布式遥控器(eTS)(Full SDK)](https://gitee.com/openharmony/codelabs/tree/master/Distributed/RemoteControllerETS)(API 8+) -- 公共事件与通知 - - [闹钟应用(eTS)(Full SDK)](https://gitee.com/openharmony/codelabs/tree/master/CommonEventAndNotification/AlarmClock)(API 9+) - 媒体 - [图片编辑模板(JS)](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageEditorTemplate)(API 8+) - [图片常见操作(JS)](https://gitee.com/openharmony/codelabs/tree/master/Media/ImageJsDemo)(API 8+) @@ -67,7 +65,7 @@ - [OLED屏幕显示](https://gitee.com/openharmony/codelabs/tree/master/Device/OLED%E5%B1%8F%E5%B9%95%E7%9A%84%E6%98%BE%E7%A4%BA)(开发板类型:Hi3861,OpenHarmony系统:OpenHarmony 3.0 LTS) - [智能门禁](https://gitee.com/openharmony/codelabs/tree/master/Device/smart_door_access)(开发板类型:RK3568,OpenHarmony系统:OpenHarmony 3.0.2 LTS) - 三方库 - - [VCard(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ThirdPartyComponents/VCardDemo)(API 8+) + - [VCard(eTS)](https://gitee.com/openharmony/codelabs/tree/master/ThirdPartyComponents/VCardDemo)(API 9+) - 网络管理 - [使用UDP实现与服务端通信(eTS)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/UdpDemoOH)(API 9+) - [使用HTTP实现与服务端通信(eTS)](https://gitee.com/openharmony/codelabs/tree/master/NetworkManagement/SmartChatEtsOH)(API 9+) diff --git a/ThirdPartyComponents/VCardDemo/build-profile.json5 b/ThirdPartyComponents/VCardDemo/build-profile.json5 index fd8257fffcc462dc03b8c4588e2f889f6f2bf350..d7b1117cdb34aab2983ac65026d9e8dcc91332d1 100644 --- a/ThirdPartyComponents/VCardDemo/build-profile.json5 +++ b/ThirdPartyComponents/VCardDemo/build-profile.json5 @@ -1,14 +1,14 @@ { "app": { "signingConfigs": [], - "compileSdkVersion": 8, - "compatibleSdkVersion": 8, + "compileSdkVersion": 9, + "compatibleSdkVersion": 9, "products": [ { "name": "default", "signingConfig": "default", - }, - ], + } + ] }, "modules": [ { @@ -18,10 +18,10 @@ { "name": "default", "applyToProducts": [ - "default", - ], - }, - ], - }, - ], + "default" + ] + } + ] + } + ] } \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/entry/build-profile.json5 b/ThirdPartyComponents/VCardDemo/entry/build-profile.json5 index ae58d1d0a70c602c9cfe1909b00dfec899ba1944..f8f03407f77914b43168aeca6bb0929efd6700b4 100644 --- a/ThirdPartyComponents/VCardDemo/entry/build-profile.json5 +++ b/ThirdPartyComponents/VCardDemo/entry/build-profile.json5 @@ -1,10 +1,10 @@ { - "apiType": 'faMode', + "apiType": 'stageMode', "buildOption": { }, "targets": [ { - "name": "default", + "name": "default" }, { "name": "ohosTest", diff --git a/ThirdPartyComponents/VCardDemo/entry/hvigorfile.js b/ThirdPartyComponents/VCardDemo/entry/hvigorfile.js deleted file mode 100644 index bcec4c99653062cbf17702c40a2dd2a7b809b81a..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/entry/hvigorfile.js +++ /dev/null @@ -1,2 +0,0 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyHapTasks diff --git a/ThirdPartyComponents/VCardDemo/entry/package.json b/ThirdPartyComponents/VCardDemo/entry/package.json index c4e988f30f2ec9e3430a4d0c8f05e89fabbc2659..bcbe61fd8bf63d97d44218e5d63c582a6f76bcce 100644 --- a/ThirdPartyComponents/VCardDemo/entry/package.json +++ b/ThirdPartyComponents/VCardDemo/entry/package.json @@ -1,13 +1,16 @@ { - "name": "entry", - "version": "1.0.0", - "ohos": { - "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "module" - }, - "description": "example description", - "repository": {}, - "license": "ISC", - "dependencies": {} -} + "license":"ISC", + "devDependencies":{}, + "name":"entry", + "ohos":{ + "org":"huawei", + "directoryLevel":"module", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/vcard":"^2.1.0" + } +} \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/entry/src/main/config.json b/ThirdPartyComponents/VCardDemo/entry/src/main/config.json deleted file mode 100644 index bb90fad761dd7a1268dc04dbadad30b089e3889b..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/entry/src/main/config.json +++ /dev/null @@ -1,68 +0,0 @@ -{ - "app": { - "vendor": "example", - "bundleName": "com.example.myapplication", - "version": { - "code": 1000000, - "name": "1.0.0" - } - }, - "deviceConfig": {}, - "module": { - "mainAbility": ".MainAbility", - "deviceType": [ - "phone", - "tablet" - ], - "abilities": [ - { - "skills": [ - { - "entities": [ - "entity.system.home" - ], - "actions": [ - "action.system.home" - ] - } - ], - "orientation": "unspecified", - "visible": true, - "srcPath": "MainAbility", - "name": ".MainAbility", - "srcLanguage": "ets", - "icon": "$media:icon", - "description": "$string:MainAbility_desc", - "formsEnabled": false, - "label": "$string:MainAbility_label", - "type": "page", - "launchType": "standard" - } - ], - "distro": { - "moduleType": "entry", - "installationFree": false, - "deliveryWithInstall": true, - "moduleName": "entry" - }, - "package": "com.example.entry", - "srcPath": "", - "name": ".entry", - "js": [ - { - "mode": { - "syntax": "ets", - "type": "pageAbility" - }, - "pages": [ - "pages/index" - ], - "name": ".MainAbility", - "window": { - "designWidth": 720, - "autoDesignWidth": false - } - } - ] - } -} \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/app.ets b/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/app.ets deleted file mode 100644 index b7a0995c8e441cac86e21e06e7c9071664482b1c..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/app.ets +++ /dev/null @@ -1,8 +0,0 @@ -export default { - onCreate() { - console.info('Application onCreate') - }, - onDestroy() { - console.info('Application onDestroy') - }, -} \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/index.ets b/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/index.ets deleted file mode 100644 index b8d64a68aad532e2f06e974a40f3dd7681b7053c..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/index.ets +++ /dev/null @@ -1,360 +0,0 @@ -/* - * 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. - */ - -import router from "@system.router"; -import {contact} from "@ohos/vcard"; -import {VCardBuilder} from "@ohos/vcard"; -import {VCardConfig} from "@ohos/vcard"; - -@Entry -@Component -struct FlexExample { - private scroller: Scroller = new Scroller() // 滚动 - @State name: string= "zhangsan"// router.getParams() == null ? "姓名" - @State OrganizationName: string= "chengmai" - @State phonename: string= "13537292684"// 电话号码 - @State emails : string= "qq.q@qq.com"// 电子邮件 - @State note : string= "程序员苦逼"// 备注 - @State PostalAddreSSA : string= "wuhan"// 地址 - @State website : string= "baidu"// 网站 - @State EventA: string="20000000" // 生日 - @State index: string= '手机'// 手机下拉框 - @State index1: string= '私人'// 邮箱下拉框 - @State index2: string= '住宅'// 住宅下拉框 - @State fd: number = 0 - - build() { - Column({space:5}) { - Scroll(this.scroller) { - Column({ space: 5 }) { - Stack() { - Text('编辑联系人') - .fontSize(30) - .fontWeight(FontWeight.Bold) - .align(Alignment.Center) - Stack({ alignContent: Alignment.End }) { - Button("保存",{ type: ButtonType.Normal, stateEffect: true }) - .borderRadius(12) - .backgroundColor(0x317aff) - .fontSize(30) - .margin({right:12}) - .onClick(() => - { - console.info('onClick start') - // 姓名模块 - let name = new contact.Name() - let contactall = new contact.Contact() - contactall.name = name - contactall.name.fullName = this.name // 将名字存入name类中fullname - - // 单位 - let Organization = new contact.Organization() - contactall.organization = Organization - contactall.organization.name = this.OrganizationName - - // 手机模块12 - let phoneNumber = new contact.PhoneNumber() - phoneNumber.labelName = this.index - phoneNumber.labelId = parseInt(this.index) - phoneNumber.phoneNumber = this.phonename - contactall.phoneNumbers = [phoneNumber] // 只能传一个,不能更改或者添加 - - // 邮件模块 - let Email = new contact.Email() - Email.labelName = this.index1 - Email.labelId = parseInt(this.index1) - Email.email = this.emails - contactall.emails = [Email] - - // 备注 - let note = new contact.Note() - contactall.note = note - contactall.note.noteContent = this.note - - // 住宅地址 - let PostalAddreSS = new contact.PostalAddress() - PostalAddreSS.labelId = parseInt(this.index2) - PostalAddreSS.region = this.PostalAddreSSA - contactall.postalAddresses = [PostalAddreSS] - - // 网站 - let website = new contact.Website() - contactall.websites = [website] - contactall.websites[0].website = this.website - - // 生日 - let event = new contact.Event() - event.eventDate = this.EventA - contactall.events = [event] - - let vcardBuilder = new VCardBuilder(VCardConfig.VCARD_TYPE_V21_GENERIC,"UTF-8") - vcardBuilder.appendNameProperties(contactall) - vcardBuilder.appendOrganizations(contactall) - vcardBuilder.appendPhones(contactall,null) - vcardBuilder.appendEmails(contactall) - vcardBuilder.appendNotes(contactall) - vcardBuilder.appendPostals(contactall) - vcardBuilder.appendWebsites(contactall) - vcardBuilder.appendEvents(contactall) - router.push({ - uri:"pages/there", - params: { - cvs: vcardBuilder.toString() - } - }) - }) - }.width('100%') - } - .height(50) - .width('100%') - // 姓名填写 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { //1 - Image($r('app.media.ic_public_contacts')) // 图片 - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({top:5}) - TextInput({ placeholder:"输入姓名", text: this.name }) - .placeholderFont({size: "14fp",weight: "100"}) - .height(45) - .width("100%") - .backgroundColor(Color.White) - .onChange((name) => { - this.name = name - }) - } - .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - - // 单位 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }) { - Image($r('app.media.ic_edit_company')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - - TextInput({ placeholder:"公司", text: this.OrganizationName }) - .placeholderFont({size: "14fp",weight: "100"}) - .height(45) - .width("100%") - .onChange((OrganizationName) => { - this.OrganizationName = OrganizationName - }) - } - .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - - // 手机 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}) { - Image($r('app.media.ic_public_phone')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text(this.index) - .width(80) - .height(20) - .fontSize(16) - .margin({left:5}) - } - .width('45%') - - // 下拉菜单 - TextInput({ placeholder:"电话号码", text: this.phonename }) - .placeholderFont({size: "14fp",weight: "40"}) - .width('55%') - .type(InputType.Number) - .onChange((value) => { - this.phonename = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - // 電子郵件 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}){ - Image($r('app.media.ic_public_email')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text(this.index1) - .width(80) - .height(40) - .fontSize(16) - .margin({left:5}) - } - .width('45%') - // 下拉菜单 - TextInput({ placeholder:"电子邮件", text: this.emails }) - .placeholderFont({size: "14fp",weight: "40"}) - .width('55%') - .type(InputType.Email) - .onChange((value) => { - this.emails = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - // 备注 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}){ - Image($r('app.media.ic_public_drawer')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text("备注") - .width(80) - .height(40) - .fontSize(16) - .margin({left:5}) - }.width('45%') - TextInput({ placeholder:"备注", text: this.note }) - .placeholderFont({size: "14fp",weight: "40"}) - .width('55%') - .onChange((value) => { - this.note = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - - // 住宅 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}){ - Image($r('app.media.ic_public_phone')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text(this.index2) - .width(80) - .height(40) - .fontSize(16) - .margin({left:5}) - } - .width('45%') - // 下拉菜单 - TextInput({ placeholder:"地址", text: this.PostalAddreSSA }) - .placeholderFont({size: "14fp",weight: "40"}) - .width('55%') - .onChange((value) => { - this.PostalAddreSSA = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - - // 网址 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}) { - Image($r('app.media.ic_public_worldclock')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text('网站') - .width(80) - .height(40) - .fontSize(16) - .margin({left:5}) - }.width('45%') - // 下拉菜单 - TextInput({ placeholder:"网站", text: this.website }) - .placeholderFont({size: "14fp",weight: "40"}) - .width('55%') - .onChange((value) => { - this.website = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - - // 生日 - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center }){ - Flex({ justifyContent: FlexAlign.Start, alignItems: ItemAlign.Center}){ - Image($r('app.media.ic_Edit_Birthday')) - .objectFit(ImageFit.Contain) - .height(30) - .width(30) - .margin({ top: 5 }) - Text('生日') - .width(80) - .height(40) - .fontSize(16) - .margin({left:5}) - } - .width('45%') - // 下拉菜单 - TextInput({ placeholder:"日期", text: this.EventA }) - .placeholderFont({size: "14fp",weight: "40"}) - .width("55%") - .type(InputType.Number) - .onChange((value) => { - this.EventA = value - }) - } .height(60) - .width('90%') - .padding({left:10}) - .backgroundColor(Color.White) - .borderStyle(BorderStyle.Dashed) - .borderWidth(0) - .borderColor(Color.Red) - .borderRadius(15) - }.width('100%').margin({ top: 5 }) - } - }.width('100%').backgroundColor('#FFf1f3f5').height('100%') - } -} diff --git a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/there.ets b/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/there.ets deleted file mode 100644 index e5aefe94d9d4cbd391f5f9263349701d509c8961..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/entry/src/main/ets/MainAbility/pages/there.ets +++ /dev/null @@ -1,47 +0,0 @@ -/* - * 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. - */ - -// @ts-nocheck -import router from '@system.router'; - -@Entry -@Component -struct there { - - @State readText: string= (router.getParams()==null?"default":router.getParams().cvs) - - build() { - Column() { - Text($r('app.string.title')) - .width('100%') - .height(50) - .backgroundColor('#0D9FFB') - .fontColor(Color.White) - .fontSize(20) - .padding({ left: 15 }) - - Text(this.readText) - .width('100%') - .height(200) - .backgroundColor('#DFDFDF') - .fontSize(20) - .margin({ top: 20 }) - .textAlign(TextAlign.Start) - .padding(10) - } - .width('100%').height('100%') - .padding(15) - } -} \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/entry/src/main/resources/base/element/string.json b/ThirdPartyComponents/VCardDemo/entry/src/main/resources/base/element/string.json index aba73c7067f0288f455472e5e5316a8179aa5fee..4e5d12b22de157bcf0c6b75716a4924a78ad5c68 100644 --- a/ThirdPartyComponents/VCardDemo/entry/src/main/resources/base/element/string.json +++ b/ThirdPartyComponents/VCardDemo/entry/src/main/resources/base/element/string.json @@ -1,15 +1,15 @@ { "string": [ { - "name": "entry_desc", - "value": "description" + "name": "module_desc", + "value": "module description" }, { - "name": "MainAbility_desc", + "name": "EntryAbility_desc", "value": "description" }, { - "name": "MainAbility_label", + "name": "EntryAbility_label", "value": "label" }, { diff --git a/ThirdPartyComponents/VCardDemo/hvigorfile.js b/ThirdPartyComponents/VCardDemo/hvigorfile.js deleted file mode 100644 index cff9f0dfcf8cb00cca34e7f50d61380cf5496868..0000000000000000000000000000000000000000 --- a/ThirdPartyComponents/VCardDemo/hvigorfile.js +++ /dev/null @@ -1,2 +0,0 @@ -// Script for compiling build behavior. It is built in the build plug-in and cannot be modified currently. -module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks \ No newline at end of file diff --git a/ThirdPartyComponents/VCardDemo/package.json b/ThirdPartyComponents/VCardDemo/package.json index d47d386ca32f7957d0857a31b1b43fa0f812d799..6c17b048f37dd7b30b2f3546571ba6f84332389c 100644 --- a/ThirdPartyComponents/VCardDemo/package.json +++ b/ThirdPartyComponents/VCardDemo/package.json @@ -1,18 +1,18 @@ { - "name": "myapplication", - "version": "1.0.0", - "ohos": { - "org": "huawei", - "buildTool": "hvigor", - "directoryLevel": "project" - }, - "description": "example description", - "repository": {}, - "license": "ISC", - "dependencies": { - "@ohos/hvigor": "1.0.6", - "@ohos/hvigor-ohos-plugin": "1.0.6", - "@ohos/vcard": "^2.1.0", - "hypium": "^1.0.0" - } -} + "license":"ISC", + "devDependencies":{}, + "name":"vcarddemo", + "ohos":{ + "org":"huawei", + "directoryLevel":"project", + "buildTool":"hvigor" + }, + "description":"example description", + "repository":{}, + "version":"1.0.0", + "dependencies":{ + "@ohos/hypium":"1.0.3", + "@ohos/hvigor-ohos-plugin":"1.3.1", + "@ohos/hvigor":"1.3.1" + } +} \ No newline at end of file