Signed-off-by: weiyunxing <weiyunxing@huawei.com>
This commit is contained in:
weiyunxing 2022-06-14 16:45:53 +08:00
parent 07ac739668
commit dc2fb72bc0
17 changed files with 379 additions and 5 deletions

View File

@ -94,6 +94,19 @@ export class ConfigData {
SOFTWARE_UPDATES_ABILITY_NAME = 'com.hmos.ouc.MainAbility';
DEVICE_NAME = 'OpenHarmony 2.0 Canary';
// NFC states
// NFC is off
STATE_OFF = 1;
// NFC is turning on
STATE_TURNING_ON = 2;
// NFC is on
STATE_ON = 3;
// NFC is turning off
STATE_TURN_OFF = 4;
NFC_OPEN = '已开启';
NFC_CLOSE = '已关闭';
}
let configData = new ConfigData();

View File

@ -87,7 +87,9 @@
"pages/passwordInput",
"pages/bluetooth",
"pages/bluetoothPairedDeviceInfo",
"pages/screenMode"
"pages/screenMode",
"pages/moreConnections",
"pages/nfc"
],
"name": ".MainAbility",
"window": {

View File

@ -0,0 +1,37 @@
/**
* 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 LogUtil from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
import ConfigData from '../../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
import nfcController from '@ohos.nfc.controller';
export class NfcModel {
private isNfcOpen: boolean;
private TAG = ConfigData.TAG + 'NfcModel ';
openNfc(): boolean {
let enableNfc = nfcController.openNfc()
LogUtil.info(this.TAG + enableNfc)
return enableNfc;
}
closeNfc(): boolean {
let disableNfc = nfcController.closeNfc()
LogUtil.info(this.TAG + disableNfc)
return disableNfc;
}
}
let nfcModel = new NfcModel();
export default nfcModel as NfcModel;

View File

@ -0,0 +1,97 @@
/**
* 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 LogUtil from '../../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
import HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent';
import {SubEntryComponentWithEndText} from '../../../../../../../common/component/src/main/ets/default/subEntryComponent';
import ResourceUtil from '../../../../../../../common/search/src/main/ets/default/common/ResourceUtil';
import nfcController from '@ohos.nfc.controller';
/**
* MoreConnections
*/
@Entry
@Component
struct MoreConnections {
@State columnMargin: string = '24vp';
@State nfcEnable: string = '';
@State isNfcEnable: boolean = false;
build() {
Column(){
GridContainer({columns:12, sizeType: SizeType.Auto, gutter: vp2px(1) === 2 ? '12vp' : '0vp', margin: vp2px(1) === 2 ? '24vp' : '0vp'}) {
Row({}) {
Column() {
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
});
Column() {
HeadComponent({ headName: $r('app.string.moreConnectionsTab'), isActive: true })
Column({space: this.columnMargin}){
SubEntryComponentWithEndText({targetPage:'pages/nfc', title: $r('app.string.NFC'), endText: this.nfcEnable})
}
.margin({ top: $r("app.float.distance_8") })
.width(ConfigData.WH_100_100)
}
.padding({ left: $r('app.float.distance_24'), right: $r('app.float.distance_24') })
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
});
Column() {
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
});
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
aboutToAppear(){
LogUtil.info('settings moreConnections aboutToAppear in');
ResourceUtil.getString($r('app.float.distance_24')).then(value => this.columnMargin = value);
let nfcState = nfcController.getNfcState();
if (nfcState === ConfigData.STATE_ON) {
this.isNfcEnable = true;
this.nfcEnable = ConfigData.NFC_OPEN;
}
if (nfcState === ConfigData.STATE_OFF) {
this.isNfcEnable = false;
this.nfcEnable = ConfigData.NFC_CLOSE;
}
AppStorage.SetOrCreate('isNfcEnable', this.isNfcEnable)
LogUtil.info('settings moreConnections aboutToAppear out');
}
}

View File

@ -0,0 +1,128 @@
/**
* 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
{
"name": "bluetoothTab", 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 HeadComponent from '../../../../../../../common/component/src/main/ets/default/headComponent';
import ConfigData from '../../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
import NfcModel from '../model/moreConnectionsImpl/NfcModel';
@Entry
@Component
struct Nfc {
@StorageLink('isNfcEnable') isNfcEnable: boolean = false;
build() {
Column() {
GridContainer({
columns: 12,
sizeType: SizeType.Auto,
gutter: vp2px(1) === 2 ? '12vp' : '0vp',
margin: vp2px(1) === 2 ? '24vp' : '0vp'
}) {
Row() {
Column() {
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 0, offset: 0 }, sm: { span: 0, offset: 0 },
md: { span: 0, offset: 0 }, lg: { span: 2, offset: 0 }
});
Column() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems:ItemAlign.Center }) {
HeadComponent({ headName: $r('app.string.NFC'), isActive: true });
}
Image($r("app.media.ic_nfc"))
.height($r("app.float.wh_value_298"))
.width($r("app.float.wh_value_208"))
.margin({ top: $r("app.float.distance_19") })
Text($r("app.string.nfcTips"))
.fontFamily('HarmonyHeiTi')
.fontWeight(FontWeight.Regular)
.fontSize($r("app.float.font_14"))
.height($r("app.float.wh_value_19"))
.lineHeight($r("app.float.lineHeight_19"))
.fontColor($r("app.color.font_color_182431"))
.margin({ bottom: $r("app.float.distance_36"), top: $r("app.float.distance_27_5") })
.opacity($r("app.float.opacity_100_60"))
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text($r('app.string.NFC'))
.fontSize($r('sys.float.ohos_id_text_size_body1'))
.fontColor($r('sys.color.ohos_id_color_text_primary'))
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Start);
}
.alignItems(VerticalAlign.Center)
.width($r("app.float.wh_value_240"))
.height($r("app.float.wh_value_48"))
.margin({ top: $r("app.float.wh_value_4"), bottom: $r("app.float.wh_value_4"),
left: $r("app.float.wh_value_12") })
Toggle({ type: ToggleType.Switch, isOn: this.isNfcEnable })
.width('36vp')
.height('20vp')
.selectedColor('#007DFF')
.margin({ right: $r('app.float.wh_value_6') })
.onChange((isOn: boolean) => {
if (isOn) {
NfcModel.openNfc()
} else {
NfcModel.closeNfc()
}
});
}
.margin({ left: $r("app.float.wh_24"), right: $r("app.float.wh_24"), top: $r("app.float.distance_8") })
.height($r('app.float.wh_value_56'))
.backgroundColor($r("app.color.white_bg_color"))
.borderRadius($r('app.float.radius_24'))
}
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
.padding({
left: $r('app.float.wh_24'),
right: $r('app.float.wh_24'),
bottom: $r('app.float.distance_32')
})
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 12, offset: 0 }, sm: { span: 12, offset: 0 },
md: { span: 12, offset: 0 }, lg: { span: 8, offset: 2 }
});
Column() {
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100)
.useSizeType({
xs: { span: 0, offset: 12 }, sm: { span: 0, offset: 12 },
md: { span: 0, offset: 12 }, lg: { span: 2, offset: 10 }
})
}
.padding({ bottom: $r('sys.float.ohos_id_dialog_margin_bottom') })
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
.width(ConfigData.WH_100_100)
.height(ConfigData.WH_100_100);
}
}

View File

@ -22,7 +22,8 @@ import GlobalResourceManager from '../../../../../../../common/utils/src/main/et
import Router from '@system.router';
import FeatureAbility from '@ohos.ability.featureAbility';
import { BaseData } from '../../../../../../../common/utils/src/main/ets/default/bean/BaseData';
import deviceInfo from '@ohos.deviceInfo'
import deviceInfo from '@ohos.deviceInfo';
import parameter from '@ohos.systemParameter';
const PAGE_SEARCH = 'pages/searchPage'; // for search
const deviceTypeInfo = deviceInfo.deviceType
@ -54,6 +55,15 @@ const SETTINGS_LIST = [
"settingArrow": "/res/image/ic_settings_arrow.svg",
"settingSummary": "",
"settingUri": ""
},
{
"settingIcon": "/res/image/ic_settings_more_connections.svg",
"settingTitle": $r('app.string.moreConnectionsTab'),
"settingAlias": "moreConnectionsTab",
"settingValue": "",
"settingArrow": "/res/image/ic_settings_arrow.svg",
"settingSummary": "",
"settingUri": "pages/moreConnections"
}
],
[
@ -265,9 +275,23 @@ struct SettingList {
@Component
struct EntryComponent {
private settingsList: BaseData[][] = SETTINGS_LIST
@State listSpace: string = '12vp'
@State isPhone: boolean = false
private settingsList: BaseData[][] = SETTINGS_LIST;
private nfcInfo: boolean;
@State listSpace: string = '12vp';
@State isPhone: boolean = false;
aboutToAppear() {
let info: string = parameter.getSync("const.SystemCapability.Communication.NFC.Core" ,"false");
if (info === 'true') {
this.nfcInfo = true;
} else {
this.nfcInfo = false;
}
LogUtil.info('settings SettingList nfc canUse' + this.nfcInfo);
if (!this.nfcInfo) {
this.settingsList[0].pop()
}
}
build() {
Column() {

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>更多连接</title>
<defs>
<path d="M10.0700087,9.4935238 L10.1819649,9.49998243 C10.6594101,9.55543693 11.0300087,9.9612014 11.0300087,10.4535238 C11.0300087,10.9837172 10.600202,11.4135238 10.0700087,11.4135238 L10.0700087,11.4135238 L6.23000867,11.4135238 L6.06078679,11.4184128 C4.54897183,11.5060094 3.35000867,12.7597502 3.35000867,14.2935238 C3.35000867,15.8841039 4.63942859,17.1735238 6.23000867,17.1735238 L6.23000867,17.1735238 L10.0700087,17.1735238 L10.1819649,17.1799824 C10.6594101,17.2354369 11.0300087,17.6412014 11.0300087,18.1335238 C11.0300087,18.6637172 10.600202,19.0935238 10.0700087,19.0935238 L10.0700087,19.0935238 L6.23000867,19.0935238 L6.02179463,19.0890891 C3.46742311,18.9800692 1.43000867,16.8747283 1.43000867,14.2935238 C1.43000867,11.642557 3.57904187,9.4935238 6.23000867,9.4935238 L6.23000867,9.4935238 L10.0700087,9.4935238 Z M17.0229437,13.3335238 C17.5531371,13.3335238 17.9829437,13.7633304 17.9829437,14.2935238 C17.9829437,14.7829331 17.6167179,15.1868057 17.1433641,15.246044 L17.0229437,15.2535238 L8.87707361,15.2535238 C8.34688025,15.2535238 7.91707361,14.8237172 7.91707361,14.2935238 C7.91707361,13.8041145 8.28329938,13.4002419 8.75665325,13.3410036 L8.87707361,13.3335238 L17.0229437,13.3335238 Z" id="path-1"></path>
<path d="M16.7517576,2.44824243 C19.4027244,2.44824243 21.5517576,4.59727563 21.5517576,7.24824243 C21.5517576,9.82944695 19.5143431,11.9347878 16.9599716,12.0438077 L16.7517576,12.0482424 L12.9117576,12.0482424 C12.3815642,12.0482424 11.9517576,11.6184358 11.9517576,11.0882424 C11.9517576,10.59592 12.3223562,10.1901556 12.7998013,10.1347011 L12.9117576,10.1282424 L16.7517576,10.1282424 C18.3423376,10.1282424 19.6317576,8.83882251 19.6317576,7.24824243 C19.6317576,5.71446878 18.4327944,4.46072799 16.9209794,4.37313142 L16.7517576,4.36824243 L12.9117576,4.36824243 C12.3815642,4.36824243 11.9517576,3.93843579 11.9517576,3.40824243 C11.9517576,2.91592002 12.3223562,2.51015556 12.7998013,2.45470105 L12.9117576,2.44824243 L16.7517576,2.44824243 Z" id="path-3"></path>
</defs>
<g id="更多连接" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="WLAN_icon备份-13">
<rect id="矩形" x="0.48" y="0.48" width="23.04" height="23.04"></rect>
<mask id="mask-2" fill="white">
<use xlink:href="#path-1"></use>
</mask>
<use id="形状结合" fill="#FF9800" fill-rule="nonzero" transform="translate(9.706476, 14.293524) rotate(-45.000000) translate(-9.706476, -14.293524) " xlink:href="#path-1"></use>
<mask id="mask-4" fill="white">
<use xlink:href="#path-3"></use>
</mask>
<use id="形状结合" fill="#FF9800" fill-rule="nonzero" transform="translate(16.751758, 7.248242) rotate(-45.000000) translate(-16.751758, -7.248242) " xlink:href="#path-3"></use>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 73 KiB

View File

@ -188,6 +188,10 @@
"name": "wh_value_200",
"value": "200vp"
},
{
"name": "wh_value_208",
"value": "208vp"
},
{
"name": "wh_value_210",
"value": "210vp"
@ -216,6 +220,10 @@
"name": "wh_value_280",
"value": "280vp"
},
{
"name": "wh_value_298",
"value": "298vp"
},
{
"name": "wh_value_336",
"value": "336vp"
@ -408,6 +416,10 @@
"name": "distance_26",
"value": "26vp"
},
{
"name": "distance_27_5",
"value": "27.5vp"
},
{
"name": "distance_30",
"value": "30vp"
@ -995,6 +1007,10 @@
{
"name": "head_font_24",
"value": "24vp"
},
{
"name": "opacity_100_60",
"value": "0.6"
}
]
}

View File

@ -852,6 +852,18 @@
"name": "locationServicesPromptInfo",
"value": "连接usb后开启调试模式"
},
{
"name": "moreConnectionsTab",
"value": "更多连接"
},
{
"name": "NFC",
"value": "NFC"
},
{
"name": "nfcTips",
"value": "若要进行移动支付、钥匙验证、碰一碰等操作,可将本设备背部触碰其他终端 NFC 感应区。"
},
{
"name": "bluetoothTab",
"value": "蓝牙"

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

View File

@ -204,6 +204,18 @@
"name": "applyTab",
"value": "apply"
},
{
"name": "moreConnectionsTab",
"value": "More Connections"
},
{
"name": "NFC",
"value": "NFC"
},
{
"name": "nfcTips",
"value": "To perform mobile payment, key verification, and touch, touch the back of the device to the NFC sensor area of another terminal."
},
{
"name": "dateAndTimeTab",
"value": "dateAndTime"

View File

@ -32,6 +32,18 @@
"name": "searchNoResult",
"value": "没有匹配的结果"
},
{
"name": "moreConnectionsTab",
"value": "更多连接"
},
{
"name": "NFC",
"value": "NFC"
},
{
"name": "nfcTips",
"value": "若要进行移动支付、钥匙验证、碰一碰等操作,可将本设备背部触碰其他终端 NFC 感应区。"
},
{
"name": "wifiTab",
"value": "WLAN"