diff --git a/Telephony/eTSCall/README_zh.md b/Telephony/eTSCall/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..5cca28606660bafe5fcd7918b91b3a1a9cf0c547 --- /dev/null +++ b/Telephony/eTSCall/README_zh.md @@ -0,0 +1,15 @@ +# 电话服务-拨打电话 + +### 简介 + +本示例通过输入电话,进行电话拨打,及电话相关信息的显示。 + +### 使用说明 + +1.输入电话号码后,点击**电话**按钮,进行拨打电话。 + +2.拨打电话后文本框会显示拨打是否成功,是否存在通话,通话状态,是否紧急号码,格式化后的电话号码。 + +### 约束与限制 + +本示例仅支持在标准系统上运行。 \ No newline at end of file diff --git a/Telephony/eTSCall/build.gradle b/Telephony/eTSCall/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..f1b1a556a0c09953268d32e7da54b1e1ba664bac --- /dev/null +++ b/Telephony/eTSCall/build.gradle @@ -0,0 +1,34 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +apply plugin: 'com.huawei.ohos.app' + +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 8 + supportSystem "standard" +} + +buildscript { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } + dependencies { + classpath 'com.huawei.ohos:hap:3.0.5.2' + classpath 'com.huawei.ohos:decctest:1.2.7.2' + } +} + +allprojects { + repositories { + maven { + url 'https://repo.huaweicloud.com/repository/maven/' + } + maven { + url 'https://developer.huawei.com/repo/' + } + } +} diff --git a/Telephony/eTSCall/entry/build.gradle b/Telephony/eTSCall/entry/build.gradle new file mode 100644 index 0000000000000000000000000000000000000000..05a33cd3adb09a68a581b9f7c02c57d3911630e8 --- /dev/null +++ b/Telephony/eTSCall/entry/build.gradle @@ -0,0 +1,21 @@ +apply plugin: 'com.huawei.ohos.hap' +//For instructions on signature configuration, see https://developer.harmonyos.com/cn/docs/documentation/doc-guides/ide_debug_device-0000001053822404#section1112183053510 +ohos { + compileSdkVersion 8 + defaultConfig { + compatibleSdkVersion 8 + } + buildTypes { + release { + proguardOpt { + proguardEnabled false + rulesFiles 'proguard-rules.pro' + } + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar', '*.har']) + testImplementation 'junit:junit:4.13.1' +} diff --git a/Telephony/eTSCall/entry/src/main/config.json b/Telephony/eTSCall/entry/src/main/config.json new file mode 100644 index 0000000000000000000000000000000000000000..7a0d2be55be4c33dcdabdf69658d25edba92155d --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/config.json @@ -0,0 +1,73 @@ +{ + "app": { + "bundleName": "ohos.samples.etscall", + "vendor": "samples", + "version": { + "code": 1000000, + "name": "1.0.0" + } + }, + "deviceConfig": {}, + "module": { + "package": "ohos.samples.etscall", + "name": ".MyApplication", + "mainAbility": ".MainAbility", + "srcPath": "", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry", + "installationFree": false + }, + "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:description_mainability", + "formsEnabled": false, + "label": "$string:entry_MainAbility", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "mode": { + "syntax": "ets", + "type": "pageAbility" + }, + "pages": [ + "pages/index" + ], + "name": ".MainAbility", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ], + "reqPermissions": [ + { + "name": "ohos.permission.PLACE_CALL" + } + ] + } + +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/ets/MainAbility/app.ets b/Telephony/eTSCall/entry/src/main/ets/MainAbility/app.ets new file mode 100644 index 0000000000000000000000000000000000000000..bf28e58b36cf11db491d3f00768ef2c9e41d05cf --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/ets/MainAbility/app.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +export default { + onCreate() { + console.info('Application onCreate') + }, + onDestroy() { + console.info('Application onDestroy') + }, +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/ets/MainAbility/common/callView.ets b/Telephony/eTSCall/entry/src/main/ets/MainAbility/common/callView.ets new file mode 100644 index 0000000000000000000000000000000000000000..cf7cc551ddd68514bb3e11b9fbdffb0bfd00ddcf --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/ets/MainAbility/common/callView.ets @@ -0,0 +1,72 @@ +/* + * 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 call from '@ohos.telephony.call' + +@Component +export struct CallView { + private on: Resource = $r("app.media.call_on") + private off: Resource = $r('app.media.call_off') + @State src: Resource = this.off + @Link input: string + @Link output: string + + build() { + Column() { + Image(this.src) + .width(70) + .height(70) + .onClick(() => { + if (this.src == this.on) { + this.src = this.off + } else { + this.src = this.on + call.dial(this.input, { extras: false }, (err, data) => { + this.output = this.output + `dial: ${JSON.stringify(data)}\n` + console.log(`callback: dial err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + + call.hasCall((err, data) => { + this.output = this.output + `hasCall: ${JSON.stringify(data)}\n` + console.log(`callback: hasCall err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + + call.getCallState((err, data) => { + this.output = this.output + `getCallState: ${JSON.stringify(data)}\n` + console.log(`callback: getCallState err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + + call.isEmergencyPhoneNumber(this.input, (err, data) => { + this.output = this.output + `isEmergencyPhoneNumber: ${JSON.stringify(data)}\n` + console.log(`callback: isEmergencyPhoneNumber err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + + call.formatPhoneNumber(this.input, (err, data) => { + this.output = this.output + `formatPhoneNumber: ${JSON.stringify(data)}\n` + console.log(`callback: formatPhoneNumber err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + + call.formatPhoneNumberToE164(this.input, "CN", (err, data) => { + this.output = this.output + `formatPhoneNumberToE164: ${JSON.stringify(data)}\n` + console.log(`callback: formatPhoneNumberToE164 err->${JSON.stringify(err)}, data->${JSON.stringify(data)}`); + }) + } + }) + .onFinish(() => { + this.src = this.off + }) + } + } +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/ets/MainAbility/pages/index.ets b/Telephony/eTSCall/entry/src/main/ets/MainAbility/pages/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..3d73f933f8abdccdd4de8ffb149d2b37b4c3ccdb --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/ets/MainAbility/pages/index.ets @@ -0,0 +1,66 @@ +/* + * 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 { CallView } from '../common/callView' + +@Entry +@Component +struct Index { + @State input: string = '' + @State output: string = `call information\n` + + build() { + Flex() { + Column() { + Text($r('app.string.entry_MainAbility')) + .width('100%') + .height(50) + .backgroundColor('#0D9FFB') + .fontColor(Color.White) + .fontSize(20) + .padding({ left: 20 }) + Scroll() { + Column() { + TextInput({ placeholder: $r('app.string.input_hint') }) + .type(InputType.Number) + .placeholderColor(Color.Grey) + .placeholderFont({ size: 20, weight: FontWeight.Normal, family: "sans-serif", style: FontStyle.Normal }) + .enterKeyType(EnterKeyType.Next) + .caretColor('#0D9FFB') + .height(60) + .fontSize(30) + .fontWeight(FontWeight.Bold) + .fontFamily("cursive") + .maxLength(11) + .margin({ left: 20, right: 20, top: 20, bottom: 20 }) + .onChange((value: string) => { + this.input = value + }) + CallView({ input: $input, output: $output }) + Text(this.output) + .width('90%') + .height('45%') + .fontSize(20) + .padding(15) + .margin({ left: 20, right: 20, top: 20 }) + .border({ width: 2, radius: 15, color: Color.Grey }) + } + } + } + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/resources/base/element/string.json b/Telephony/eTSCall/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8a940d42fbf8536a7817e071b4db38d1c040cdba --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "eTSCall" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "input_hint", + "value": "enter a phone number" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/resources/base/media/call_off.png b/Telephony/eTSCall/entry/src/main/resources/base/media/call_off.png new file mode 100644 index 0000000000000000000000000000000000000000..d6a4fb8e296bceb58dd1eaf5f7c7ca8ef868b57d Binary files /dev/null and b/Telephony/eTSCall/entry/src/main/resources/base/media/call_off.png differ diff --git a/Telephony/eTSCall/entry/src/main/resources/base/media/call_on.png b/Telephony/eTSCall/entry/src/main/resources/base/media/call_on.png new file mode 100644 index 0000000000000000000000000000000000000000..a01a335306d993c95816109c8b307decd3f26e1b Binary files /dev/null and b/Telephony/eTSCall/entry/src/main/resources/base/media/call_on.png differ diff --git a/Telephony/eTSCall/entry/src/main/resources/base/media/icon.png b/Telephony/eTSCall/entry/src/main/resources/base/media/icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ce307a8827bd75456441ceb57d530e4c8d45d36c Binary files /dev/null and b/Telephony/eTSCall/entry/src/main/resources/base/media/icon.png differ diff --git a/Telephony/eTSCall/entry/src/main/resources/en/element/string.json b/Telephony/eTSCall/entry/src/main/resources/en/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..8a940d42fbf8536a7817e071b4db38d1c040cdba --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/resources/en/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "eTSCall" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "input_hint", + "value": "enter a phone number" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSCall/entry/src/main/resources/zh/element/string.json b/Telephony/eTSCall/entry/src/main/resources/zh/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..ed0bc8fab9365357392545529f82d036c6cfb306 --- /dev/null +++ b/Telephony/eTSCall/entry/src/main/resources/zh/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "entry_MainAbility", + "value": "eTSCall" + }, + { + "name": "description_mainability", + "value": "eTS_Empty Ability" + }, + { + "name": "input_hint", + "value": "输入电话号码" + } + ] +} \ No newline at end of file diff --git a/Telephony/eTSCall/screenshots/device/call.png b/Telephony/eTSCall/screenshots/device/call.png new file mode 100644 index 0000000000000000000000000000000000000000..4a79e34dd03dfeea56a61aba085c13ba09d94856 Binary files /dev/null and b/Telephony/eTSCall/screenshots/device/call.png differ diff --git a/Telephony/eTSCall/settings.gradle b/Telephony/eTSCall/settings.gradle new file mode 100644 index 0000000000000000000000000000000000000000..4773db73233a570c2d0c01a22e75321acfbf7a07 --- /dev/null +++ b/Telephony/eTSCall/settings.gradle @@ -0,0 +1 @@ +include ':entry'