蓝牙、NFC优化,fullSDK适配

Signed-off-by: weiyunxing <weiyunxing@huawei.com>
This commit is contained in:
weiyunxing 2022-08-16 14:49:19 +08:00
parent 2e286cd278
commit 1b53a05a1e
35 changed files with 252 additions and 126 deletions

View File

@ -19,7 +19,7 @@ import BaseSettingsController from './BaseSettingsController'
*/
export default abstract class SwitchController extends BaseSettingsController {
isOn: boolean = false;
protected enabled: boolean = true;
protected isEnabled: boolean = true;
/**
* Set toggle value

View File

@ -27,10 +27,10 @@ export default struct DoubleLineComponent {
@Prop settingArrowStyle: string;
@Prop settingUri: string;
@State titleFontColor: Color | number | string | Resource = $r('sys.color.ohos_id_color_text_primary');
private enabled: boolean = true;
private isEnabled: boolean = true;
private onArrowClick?: () => void;
@State isTouched: boolean = false;
@State height: string | Resource = $r('app.float.wh_value_72');
@State heights: string | Resource = $r('app.float.wh_value_72');
@State image_wh: string | Resource = $r('app.float.wh_value_40');
@State fontSize: string | Resource = $r('sys.float.ohos_id_text_size_body1');
@State valueFontSize: string | Resource = $r('sys.float.ohos_id_text_size_body2');
@ -46,7 +46,7 @@ export default struct DoubleLineComponent {
Column() {
Text(this.settingTitle)
.fontColor(this.enabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary"))
.fontColor(this.isEnabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary"))
.fontSize(this.fontSize)
.fontWeight(FontWeight.Medium)
.textAlign(TextAlign.Start)
@ -103,7 +103,7 @@ export default struct DoubleLineComponent {
}
.align(Alignment.End);
}
.height(this.height)
.height(this.heights)
.width(ComponentConfig.WH_100_100)
.padding({
left: $r('sys.float.ohos_id_card_margin_end'),
@ -112,7 +112,7 @@ export default struct DoubleLineComponent {
bottom: $r('sys.float.ohos_id_elements_margin_vertical_m')
})
.borderRadius($r("sys.float.ohos_id_corner_radius_default_l"))
.linearGradient((this.enabled && this.isTouched) ? {
.linearGradient((this.isEnabled && this.isTouched) ? {
angle: 90,
direction: GradientDirection.Right,
colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]

View File

@ -29,10 +29,10 @@ export default struct EntryComponent {
@Prop settingArrowStyle: string;
private settingUri: string;
@State titleFontColor: Color | number | string | Resource = $r('sys.color.ohos_id_color_text_primary');
private enabled: boolean = true;
private isEnabled: boolean = true;
private onArrowClick?: () => void;
@State isTouched: boolean = false;
private height ?= $r('app.float.wh_value_70');
private heights ?= $r('app.float.wh_value_70');
private image_wh ?= $r('app.float.wh_value_50');
private fontSize ?= $r('sys.float.ohos_id_text_size_body1');
private valueFontSize ?= $r('sys.float.ohos_id_text_size_body2');
@ -49,7 +49,7 @@ export default struct EntryComponent {
.fillColor($r("sys.color.ohos_id_color_primary"))
Column() {
Text(this.settingTitle)
.fontColor(this.enabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary"))
.fontColor(this.isEnabled ? this.titleFontColor : $r("sys.color.ohos_id_color_primary"))
.fontSize(this.fontSize)
.textAlign(TextAlign.Start)
.maxLines(ComponentConfig.MAX_LINES_3)
@ -116,12 +116,12 @@ export default struct EntryComponent {
.alignItems(VerticalAlign.Center)
.align(Alignment.End);
}
.opacity(this.enabled?1:$r('sys.float.ohos_id_alpha_disabled'))
.height(this.height)
.opacity(this.isEnabled?1:$r('sys.float.ohos_id_alpha_disabled'))
.height(this.heights)
.width(ComponentConfig.WH_100_100)
.padding({ left: $r('sys.float.ohos_id_default_padding_start') })
.borderRadius($r("sys.float.ohos_id_corner_radius_default_l"))
.linearGradient((this.enabled && this.isTouched) ? {
.linearGradient((this.isEnabled && this.isTouched) ? {
angle: 90,
direction: GradientDirection.Right,
colors: [[$r("app.color.DCEAF9"), 0.0], [$r("app.color.FAFAFA"), 1.0]]

View File

@ -27,7 +27,7 @@ export default struct SwitchComponent {
private controller: SwitchController;
private summary?: string | Resource;
private switchHeight?: string | Resource;
@State enabled?: boolean = true;
@State isEnabled?: boolean = true;
private cssValue: {
margin?: {
top?: number | string | Resource,
@ -67,7 +67,7 @@ export default struct SwitchComponent {
.margin({ left: '6vp' })
.selectedColor('#007DFF')
.onChange((isOn: boolean) => {
if (!this.enabled) return;
if (!this.isEnabled) return;
this.isOn = new Boolean(isOn).valueOf();
this.toggleValue(this.isOn);
});
@ -91,7 +91,7 @@ export default struct SwitchComponent {
// bind component and initialize
this.controller.bindComponent(this)
.bindProperties(["isOn", "enabled"])
.bindProperties(["isOn", "isEnabled"])
.initData()
.subscribe();
}

View File

@ -49,7 +49,7 @@ export struct SubHeader {
export struct TitleText {
private title: string | Resource;
private color: ResourceColor = $r('app.color.font_color_182431');
private visibility: Visibility = Visibility.Visible;
private visible: Visibility = Visibility.Visible;
private clickEvent: (event?: ClickEvent) => void;
@State isTouched: boolean = false;
@ -90,7 +90,7 @@ export struct TitleText {
.margin({ top: $r("app.float.distance_12") })
.borderRadius($r("app.float.radius_24"))
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"))
.visibility(this.visibility);
.visibility(this.visible);
}
}

View File

@ -1,4 +1,3 @@
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -1,4 +1,3 @@
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");

View File

@ -12,4 +12,4 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
module.exports = require('@ohos/hvigor-ohos-plugin').legacyAppTasks
module.exports = require('@ohos/hvigor-ohos-plugin').appTasks

View File

@ -7,12 +7,13 @@
"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"
"description": "example description",
"repository": {},
"version": "1.0.0",
"dependencies": {
"@ohos/hypium": "1.0.0",
"@ohos/hvigor-ohos-plugin": "1.1.3",
"hypium": "^1.0.0",
"@ohos/hvigor": "1.1.3"
}
}

View File

@ -304,13 +304,16 @@ export default class BluetoothDeviceController extends BaseSettingsController {
deviceId: string;
bondState: number;
}) => {
LogUtil.info(this.TAG + "data.bondState" + JSON.stringify(data.bondState))
//paired devices
if (data.bondState !== BondState.BOND_STATE_BONDING) {
AppStorage.SetOrCreate("controlPairing", true)
this.refreshPairedDevices();
}
//available devices
if (data.bondState == BondState.BOND_STATE_BONDING) {
AppStorage.SetOrCreate("controlPairing", false)
// case bonding
// do nothing and still listening
LogUtil.log(this.TAG + 'bluetooth continue listening bondStateChange.');
@ -321,6 +324,7 @@ export default class BluetoothDeviceController extends BaseSettingsController {
AppStorage.SetOrCreate('bluetoothAvailableDevices', this.availableDevices);
} else if (data.bondState == BondState.BOND_STATE_INVALID) {
AppStorage.SetOrCreate("controlPairing", true)
// case failed
if(this.getAvailableDevice(data.deviceId) != null){
this.getAvailableDevice(data.deviceId).connectionState = ProfileConnectionState.STATE_DISCONNECTED;

View File

@ -39,11 +39,17 @@ export default class LayoutBoundariesController extends SwitchController {
*/
afterCurrentValueChanged() {
if(this.isOn){
parameter.setSync("persist.ace.debug.boundary.enabled", "true")
LogUtil.info(MODULE_TAG + "open boundary " + JSON.stringify(parameter.setSync("persist.ace.debug.boundary.enabled", "true")))
parameter.set("persist.ace.debug.boundary.enabled", "true").then(()=>{
LogUtil.info(MODULE_TAG + "open boundary success ")
}).catch((error)=>{
LogUtil.info(MODULE_TAG + "open boundary fail " + JSON.stringify(error))
})
} else {
parameter.setSync("persist.ace.debug.boundary.enabled", "false");
LogUtil.info(MODULE_TAG + "close boundary " + JSON.stringify(parameter.setSync("persist.ace.debug.boundary.enabled", "false")))
parameter.set("persist.ace.debug.boundary.enabled", "false").then(()=>{
LogUtil.info(MODULE_TAG + "close boundary success ")
}).catch((error)=>{
LogUtil.info(MODULE_TAG + "close boundary fail " + JSON.stringify(error))
});
}
}
}

View File

@ -39,11 +39,17 @@ export default class OverdrawController extends SwitchController {
*/
afterCurrentValueChanged() {
if(this.isOn){
parameter.setSync("debug.graphic.overdraw", "true");
LogUtil.info(MODULE_TAG + "open overdraw " + JSON.stringify( parameter.setSync("debug.graphic.overdraw", "true")))
parameter.set("debug.graphic.overdraw", "true").then(()=>{
LogUtil.info(MODULE_TAG + "open overdraw success")
}).catch((err)=>{
LogUtil.info(MODULE_TAG + "open overdraw fail" + JSON.stringify(err))
});
} else {
parameter.setSync("debug.graphic.overdraw", "false");
LogUtil.info(MODULE_TAG + " close overdraw " + JSON.stringify( parameter.setSync("debug.graphic.overdraw", "false")))
parameter.set("debug.graphic.overdraw", "false").then(()=>{
LogUtil.info(MODULE_TAG + " close overdraw success")
}) .catch((err)=>{
LogUtil.info(MODULE_TAG + " close overdraw fail " + JSON.stringify(err))
});
}
}
}

View File

@ -100,8 +100,13 @@ export class BluetoothModel extends BaseModel {
super();
try{
LogUtil.info('bluetooth.getProfile start')
this.profiles[1] = bluetooth.getProfile(1);
this.profiles[4] = bluetooth.getProfile(4);
let ProfileId = bluetooth.ProfileId;
this.profiles[ProfileId.PROFILE_A2DP_SOURCE]
= bluetooth.getProfile(ProfileId.PROFILE_A2DP_SOURCE);
this.profiles[ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY]
= bluetooth.getProfile(ProfileId.PROFILE_HANDS_FREE_AUDIO_GATEWAY);
this.profiles[ProfileId.PROFILE_HID_HOST]
= bluetooth.getProfile(ProfileId.PROFILE_HID_HOST);
LogUtil.info('bluetooth.getProfile end')
this.canUse = true;
}

View File

@ -20,6 +20,9 @@ import nfcController from '@ohos.nfc.controller';
const TAG = ConfigData.TAG + 'NfcModel: ';
export class NfcModel {
private nfcStatus: boolean;
private isNfcEnabled: boolean;
/**
* register Nfc Status change
* @param callback
@ -27,9 +30,22 @@ export class NfcModel {
registerNfcStatusObserver(callback) {
LogUtil.info(TAG + 'start register nfc status observer' );
nfcController.on('nfcStateChange', (code) => {
AppStorage.SetOrCreate('nfcStatus', nfcController.isNfcOpen());
if(code == nfcController.NfcState.STATE_OFF || code == nfcController.NfcState.STATE_ON) {
if (code == nfcController.NfcState.STATE_ON) {
this.isNfcEnabled = true;
this.nfcStatus = true;
}
if (code == nfcController.NfcState.STATE_OFF) {
this.isNfcEnabled = false;
this.nfcStatus = false;
}
AppStorage.SetOrCreate('isNfcEnabled', this.isNfcEnabled);
AppStorage.SetOrCreate('nfcStatus', this.nfcStatus);
LogUtil.info(TAG + 'nfc active status code : ' + code + " isNfcEnabled" + this.isNfcEnabled);
}
callback(code);
})
LogUtil.info(TAG + 'end register nfc status observer' );
}
/**

View File

@ -1,4 +1,3 @@
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
@ -66,7 +65,7 @@ class LanguageAndRegionModel extends BaseModel {
* Init App Storage
*/
@Log
async initAppStorage():void{
async initAppStorage():Promise<void>{
this.storage = await dataStorage.getPreferences(globalThis.settingsAbilityContext, 'languageAndRegion')
LogUtil.info(`${this.TAG} initAppStorage in` + JSON.stringify(this.storage));
if(!(await this.storage.has(this.addStr))){
@ -91,7 +90,7 @@ class LanguageAndRegionModel extends BaseModel {
* Set system language
*/
@Log
async setSystemLanguage(language:string):void{
async setSystemLanguage(language:string):Promise<void>{
LogUtil.info(`${this.TAG} setSystemLanguage in`);
this.addedLanguages = this.getAddedLanguages();
this.addedLanguages.splice(this.addedLanguages.indexOf(language), 1);
@ -109,7 +108,7 @@ class LanguageAndRegionModel extends BaseModel {
* Add language to the addedLanguages list
*/
@Log
async addLanguage(language:string):void{
async addLanguage(language:string):Promise<void>{
LogUtil.info(`${this.TAG} addLanguage in, language: ${language}` );
this.addedLanguages = AppStorage.Get(this.addStr);
this.addedLanguages.push(language);
@ -124,7 +123,7 @@ class LanguageAndRegionModel extends BaseModel {
* Remove language from the addedLanguages list
*/
@Log
async deleteLanguage(language:string):void{
async deleteLanguage(language:string):Promise<void>{
LogUtil.info(`${this.TAG} deleteLanguage in`);
this.addedLanguages = AppStorage.Get(this.addStr);
this.addedLanguages.splice(this.addedLanguages.indexOf(language), 1);

View File

@ -18,7 +18,7 @@ import wifi from '@ohos.wifi';
import BaseModel from '../../../../../../../common/utils/src/main/ets/default/model/BaseModel';
const MODULE_TAG = ConfigData.TAG + 'WifiModel -> ';
const Undefined_TaskId = -1;
export interface WifiScanInfo {
ssid: string,
bssid: string,
@ -218,7 +218,7 @@ export class WifiModel extends BaseModel {
private userSelectedAp: ApScanResult = new ApScanResult();
private linkedApInfo: any = undefined;
private scanTaskId: number = -1;
private scanTaskId: number = Undefined_TaskId;
private isScanning: boolean = false;
destroyWiFiModelData() {
@ -504,6 +504,12 @@ export class WifiModel extends BaseModel {
startScanTask() {
LogUtil.info(MODULE_TAG + 'start the wifi scan task');
if (this.scanTaskId !== Undefined_TaskId) {
clearInterval(this.scanTaskId);
this.scanTaskId = Undefined_TaskId;
}
this.scanTaskId = setInterval(() => {
if (this.isWiFiActive() === true && this.isScanning === true) {
this.refreshApScanResults();
@ -519,9 +525,9 @@ export class WifiModel extends BaseModel {
stopScanTask() {
LogUtil.info(MODULE_TAG + 'stop the wifi scan task');
if (this.scanTaskId !== -1) {
if (this.scanTaskId !== Undefined_TaskId) {
clearInterval(this.scanTaskId);
this.scanTaskId = -1;
this.scanTaskId = Undefined_TaskId;
}
this.isScanning = false;
}

View File

@ -95,7 +95,7 @@ struct ApplicationStorage {
settingArrow: item.settingArrow,
settingArrowStyle: '',
settingUri: '',
height: $r('app.float.wh_value_48'),
heights: $r('app.float.wh_value_48'),
fontSize: $r('app.float.font_16')
});
}
@ -112,7 +112,7 @@ struct ApplicationStorage {
.backgroundColor($r("app.color.white_bg_color"))
.padding($r('app.float.distance_4'))
ButtonComponent({ text: $r("app.string.deleteDataTab"), onClick: () => {
ButtonComponent({ text: $r("app.string.deleteDataTab"), onClickEvent: () => {
this.showDialog(this.controller.clearUpApplicationData.bind(this, appInfo.settingBundleName));
} })
@ -157,7 +157,7 @@ struct ApplicationStorage {
.borderRadius($r("sys.float.ohos_id_corner_radius_default_l"))
.backgroundColor($r("sys.color.ohos_id_color_foreground_contrary"));
ButtonComponent({ text: $r("app.string.clearCacheTab"), onClick: () => {
ButtonComponent({ text: $r("app.string.clearCacheTab"), onClickEvent: () => {
this.controller.cleanBundleCacheFiles(appInfo.settingBundleName);
} })
@ -240,7 +240,7 @@ struct ApplicationStorage {
struct ButtonComponent {
@State isTouched: boolean = false;
private text;
private onClick = () => {
private onClickEvent = () => {
};
build() {
@ -264,7 +264,7 @@ struct ButtonComponent {
}
})
.onClick(() => {
this.onClick();
this.onClickEvent();
})
}
.align(Alignment.Center);

View File

@ -38,7 +38,7 @@ struct Bluetooth {
private deviceController: BluetoothDeviceController = new BluetoothDeviceController();
@State isPhone: boolean = false
@StorageLink('bluetoothIsOn') isOn: boolean = false;
@StorageLink('bluetoothToggleEnabled') enabled: boolean = true;
@StorageLink('bluetoothToggleEnabled') isEnabled: boolean = true;
@StorageLink('bluetoothLocalName') localName: string = '';
@Log
@ -101,8 +101,8 @@ struct Bluetooth {
.selectedColor('#007DFF')
.margin({ left: $r('app.float.wh_value_6') })
.onChange(() => {
LogUtil.log(this.PAGE_TAG + 'Toggle onClick: isOn = ' + this.isOn + ', enabled = ' + this.enabled)
if (!this.enabled) return;
LogUtil.log(this.PAGE_TAG + 'Toggle onClick: isOn = ' + this.isOn + ', enabled = ' + this.isEnabled)
if (!this.isEnabled) return;
this.deviceController.toggleValue(!this.isOn);
});
}
@ -130,7 +130,7 @@ struct Bluetooth {
Column() {
DeviceNameComponent({
enabled: $isOn,
isEnabled: $isOn,
localName: $localName
})
@ -142,7 +142,7 @@ struct Bluetooth {
AvailableDeviceComponent({
controller: this.deviceController,
isPhone:this.isPhone
isPhone: this.isPhone
})
}
@ -192,7 +192,7 @@ struct Bluetooth {
*/
@Component
struct DeviceNameComponent {
@Link enabled: boolean;
@Link isEnabled: boolean;
@Link localName: string;
build() {
@ -205,18 +205,18 @@ struct DeviceNameComponent {
settingArrow: $r("app.media.ic_settings_arrow"),
settingArrowStyle: '',
settingUri: '',
enabled: this.enabled,
height: ($r('app.float.wh_value_48')),
isEnabled: this.isEnabled,
heights: ($r('app.float.wh_value_48')),
fontSize: ($r('app.float.font_16'))
})
}
.margin({ top: this.enabled ? $r('app.float.wh_value_0') : $r('app.float.wh_value_12') })
.margin({ top: this.isEnabled ? $r('app.float.wh_value_0') : $r('app.float.wh_value_12') })
.width(ConfigData.WH_100_100)
.height($r('app.float.wh_value_56'))
.borderRadius($r("app.float.radius_24"))
.backgroundColor($r("app.color.white_bg_color"))
.onClick(() => {
if (this.enabled) {
if (this.isEnabled) {
Router.push({ uri: PAGE_URI_DEVICE_NAME });
}
});
@ -281,7 +281,7 @@ struct PairedDeviceComponent {
settingUri: '',
titleFontColor: this.isHeadPhoneConnected(item) ? $r("app.color.bluetooth_text_color_highlight") : $r("sys.color.ohos_id_color_text_primary"),
image_wh: $r('app.float.wh_value_24'),
height: this.getConnectionStateText(item) == '' ? $r('app.float.wh_value_56') : ($r('app.float.wh_value_64')),
heights: this.getConnectionStateText(item) == '' ? $r('app.float.wh_value_56') : ($r('app.float.wh_value_64')),
fontSize: ($r('app.float.font_16')),
onArrowClick: () => {
LogUtil.info(this.TAG_PAGE + 'item go detail');
@ -481,7 +481,8 @@ struct AvailableDeviceComponent {
@StorageLink('bluetoothAvailableDevices') availableDevices: BluetoothDevice[] = [];
@State pairPinCode: string = '';
private pairingDevice: BluetoothDevice = undefined;
@State isPhone: boolean = false
private isPhone: boolean = false;
@StorageLink("controlPairing") controlPairing: boolean = true ;
pairDialog: CustomDialogController = new CustomDialogController({
builder: PairDialog({
deviceName: this.pairingDevice.deviceName,
@ -546,7 +547,7 @@ struct AvailableDeviceComponent {
settingArrowStyle: '',
settingUri: '',
image_wh: $r('app.float.wh_value_24'),
height: this.getPairStateText(item) == '' ? $r('app.float.wh_value_56') : ($r('app.float.wh_value_64')),
heights: this.getPairStateText(item) == '' ? $r('app.float.wh_value_56') : ($r('app.float.wh_value_64')),
fontSize: ($r('app.float.font_16')),
});
}
@ -555,7 +556,11 @@ struct AvailableDeviceComponent {
.backgroundColor($r("app.color.white_bg_color"))
.onClick(() => {
LogUtil.info(this.TAG_PAGE + 'item on click');
this.pairDevice(item)
if(this.controlPairing){
this.pairDevice(item)
} else {
return
}
})
}
}, item => JSON.stringify(item));

View File

@ -21,7 +21,7 @@ import DateAndTimeModel from '../model/dateAndTimeImpl/DateAndTimeModel'
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
import ResourceUtil from '../../../../../../common/search/src/main/ets/default/common/ResourceUtil';
import { BaseData } from '../../../../../../common/utils/src/main/ets/default/bean/BaseData';
import CommonEvent from '@ohos.commonevent';
import CommonEvent from '@ohos.commonEvent';
import deviceInfo from '@ohos.deviceInfo'
const MODULE_TAG = ConfigData.TAG + '.dateAndTime -> ';
const deviceTypeInfo = deviceInfo.deviceType
@ -37,7 +37,12 @@ struct dateAndTime {
private dateMark: string = 'date';
private timeMark: string = 'time';
private commonEventSubscribeInfo = {
events: [CommonEvent.Support.COMMON_EVENT_TIME_CHANGED, CommonEvent.Support.COMMON_EVENT_DATE_CHANGED]
events: [
CommonEvent.Support.COMMON_EVENT_TIME_CHANGED,
CommonEvent.Support.COMMON_EVENT_TIMEZONE_CHANGED,
CommonEvent.Support.COMMON_EVENT_TIME_TICK,
CommonEvent.Support.COMMON_EVENT_DATE_CHANGED,
]
};
private subscriber;
private headName: string = '';

View File

@ -19,6 +19,7 @@ import AboutDeviceModel from '../model/aboutDeviceImpl/AboutDeviceModel'
import Router from '@system.router';
import InputMethod from '@ohos.inputmethod';
import prompt from "@ohos.prompt"
import ResourceUtil from '../../../../../../common/search/src/main/ets/default/common/ResourceUtil';
/**
* about phone
*/
@ -81,10 +82,12 @@ struct DeviceName {
}
if (this.deviceName.length == 30) {
this.isFocused = false
prompt.showToast({
message: "输入已达上限",
duration: 2000,
bottom: 1000
ResourceUtil.getString($r("app.string.Input_Reached_Limited")).then(value => {
prompt.showToast({
message:value,
duration: 2000,
bottom: 1000
})
})
}
})
@ -101,7 +104,7 @@ struct DeviceName {
Row() {
Flex({ direction: FlexDirection.Row, justifyContent: FlexAlign.Center, alignItems: ItemAlign.Center }) {
Row() {
ButtonComponent({ text: $r("app.string.cancel"),deviceName : $deviceName ,buttonFlag : $cancelButton, onClick: () => {
ButtonComponent({ text: $r("app.string.cancel"),deviceName : $deviceName ,buttonFlag : $cancelButton, onClickEvent: () => {
Router.back();
} })
}
@ -110,7 +113,7 @@ struct DeviceName {
.margin({ right: $r("app.float.distance_12") })
Row() {
ButtonComponent({ text: $r("app.string.confirm"),deviceName : $deviceName ,buttonFlag : $confirmsButton,onClick: () => {
ButtonComponent({ text: $r("app.string.confirm"),deviceName : $deviceName ,buttonFlag : $confirmsButton,onClickEvent: () => {
if(this.deviceName.length >0){
AboutDeviceModel.setSystemName(this.deviceName)
Router.back();
@ -164,7 +167,7 @@ struct ButtonComponent {
@Link deviceName: string ;
@Link buttonFlag : boolean;
private text;
private onClick = () => {
private onClickEvent = () => {
};
build() {
@ -192,7 +195,7 @@ struct ButtonComponent {
}
})
.onClick(() => {
this.onClick();
this.onClickEvent();
})
}
.opacity(this.deviceName.length === 0 && this.buttonFlag != true ? $r('sys.float.ohos_fa_alpha_disabled') : 1)

View File

@ -32,7 +32,7 @@ const deviceTypeInfo = deviceInfo.deviceType;
struct MoreConnections {
@State columnMargin: string = '24vp';
@State nfcEnable: string = '';
@StorageLink('nfcStatus') nfcStatus: boolean = NfcModel.isNfcOpen();
@StorageLink('nfcStatus') nfcStatus: boolean = false;
private maxScreenWidth;
private maxScreenHeight;
private nfcImageWidth;
@ -92,6 +92,18 @@ struct MoreConnections {
LogUtil.info(TAG + 'aboutToAppear in');
ResourceUtil.getString($r('app.float.distance_24')).then(value => this.columnMargin = value);
try {
this.nfcStatus = !!NfcModel.isNfcOpen();
LogUtil.info(TAG + 'check whether NFC is open: ' + this.nfcStatus);
AppStorage.SetOrCreate('nfcStatus', this.nfcStatus);
} catch(err) {
LogUtil.error(TAG + 'check nfcStatus api failed');
}
NfcModel.registerNfcStatusObserver((code) => {
LogUtil.info(TAG + 'NFC state code: ' + code);
})
// get screen max width and max height to show nfc image width and height
display.getDefaultDisplay((err, data) => {
if (err.code) {

View File

@ -103,7 +103,7 @@ struct MultipleUsers {
TitleText({
title: $r("app.string.addUser"),
color: $r("app.color.font_color_007DFF"),
visibility: this.isShowAddUser ? Visibility.Visible : Visibility.None,
visible: this.isShowAddUser ? Visibility.Visible : Visibility.None,
clickEvent: (event => {
LogUtil.info("Add user.");
this.addUserDialogController.open();
@ -118,7 +118,7 @@ struct MultipleUsers {
TitleText({
title: $r("app.string.addGuest"),
color: $r("app.color.font_color_007DFF"),
visibility: this.isShowAddGuest ? Visibility.Visible : Visibility.None,
visible: this.isShowAddGuest ? Visibility.Visible : Visibility.None,
clickEvent: ((event) => {
AlertDialog.show({
message: $r("app.string.askAddGuest"),

View File

@ -23,9 +23,10 @@ const TAG = ConfigData.TAG + 'Nfc: ';
@Entry
@Component
struct Nfc {
@State isNfcEnable: boolean = false;
@StorageLink('isNfcEnabled') isNfcEnabled: boolean = false;
@StorageLink('nfcImageWidth') nfcImageWidth: number = null;
@StorageLink('nfcImageWidth') nfcImageHeight: number = null;
private switchDebounceFlag = undefined;
build() {
Column() {
@ -71,22 +72,13 @@ struct Nfc {
Blank()
Stack({ alignContent: Alignment.Start }) {
Toggle({ type: ToggleType.Switch, isOn: this.isNfcEnable })
Toggle({ type: ToggleType.Switch, isOn: this.isNfcEnabled })
.width('36vp')
.height('20vp')
.selectedColor($r("app.color.toggle_selected_color_007DFF"))
.margin({ left: $r('app.float.wh_value_6') })
.onChange((isOn: boolean) => {
this.isNfcEnable = !this.isNfcEnable;
if (this.isNfcEnable) {
// open NFC
NfcModel.openNfc()
LogUtil.info(TAG + 'enable nfc: ' + NfcModel.openNfc());
} else {
// close NFC
NfcModel.closeNfc()
LogUtil.info(TAG + 'disable nfc: ' + NfcModel.openNfc());
}
this.switchNfcActiveStatus();
});
}
}
@ -127,15 +119,37 @@ struct Nfc {
.height(ConfigData.WH_100_100);
}
switchNfcActiveStatus() {
// make the ui change quickly
this.isNfcEnabled = !this.isNfcEnabled;
LogUtil.info(TAG + 'current enable status: ' + this.isNfcEnabled);
// delay the nfc status change event
if (this.switchDebounceFlag) {
clearTimeout(this.switchDebounceFlag);
}
this.switchDebounceFlag = setTimeout(() => {
if (this.isNfcEnabled) {
let enableNFC = NfcModel.openNfc();
LogUtil.info(TAG + 'enable nfc: ' + enableNFC);
} else {
let disableNFC = NfcModel.closeNfc();
LogUtil.info(TAG + 'disable nfc: ' + disableNFC);
}
this.switchDebounceFlag = undefined;
}, 1500);
}
aboutToAppear() {
LogUtil.info(TAG + 'aboutToAppear in');
NfcModel.registerNfcStatusObserver((code) => {
LogUtil.info(TAG + 'aboutToAppear status code: ' + code);
this.isNfcEnable = NfcModel.isNfcOpen();
LogUtil.info(TAG + 'aboutToAppear nfc open status: ' + this.isNfcEnable);
})
// init nfc active status
this.isNfcEnable = NfcModel.isNfcOpen();
if (!this.switchDebounceFlag) {
NfcModel.registerNfcStatusObserver((code) => {
LogUtil.info(TAG + 'register status code: ' + code);
})
}
// init wifi active status
this.isNfcEnabled = NfcModel.isNfcOpen();
LogUtil.info(TAG + 'aboutToAppear out');
}
}

View File

@ -76,7 +76,7 @@ struct PasswordSetting {
settingArrow: '/res/image/ic_settings_arrow.svg',
settingArrowStyle: '',
settingUri: '',
height: $r('app.float.password_list_item_height'),
heights: $r('app.float.password_list_item_height'),
fontSize: $r('app.float.password_list_item_title_font_size')
})
}
@ -115,7 +115,7 @@ struct PasswordSetting {
settingUri: item.settingUri,
settingArrowStyle: '',
titleFontColor: $r("app.color.font_color_007DFF"),
height: $r('app.float.password_list_item_height'),
heights: $r('app.float.password_list_item_height'),
fontSize: $r('app.float.font_16')
});
}
@ -141,7 +141,7 @@ struct PasswordSetting {
settingArrow: item.settingArrow,
settingArrowStyle: '',
settingUri: item.settingUri,
height: $r('app.float.password_list_item_height'),
heights: $r('app.float.password_list_item_height'),
fontSize: $r('app.float.font_16')
});
}

View File

@ -164,7 +164,7 @@ const SETTINGS_LIST = [
struct SettingList {
@State placeholder: string= ''; // for search
@State placeholdersize: string = '22'
@State listSpace: string = '12vp'
@State listSpaces: string = '12vp'
@State isPhone: boolean = false
@Builder NavigationTitle() {
@ -199,14 +199,14 @@ struct SettingList {
Column() {
if (this.isPhone) {
Navigation() {
EntryComponent({ listSpace: this.listSpace, isPhone: this.isPhone })
EntryComponent({ listSpaces: this.listSpaces, isPhone: this.isPhone })
}
.title(this.NavigationTitle)
.titleMode(NavigationTitleMode.Free)
.hideTitleBar(false)
.hideBackButton(true)
} else {
EntryComponent({ listSpace: this.listSpace })
EntryComponent({ listSpaces: this.listSpaces })
}
}
.backgroundColor($r("sys.color.ohos_id_color_sub_background"))
@ -243,7 +243,7 @@ struct SettingList {
LogUtil.info('settings SettingList aboutToAppear enter');
ResourceUtil.getString($r("app.string.searchHint")).then(value => this.placeholder = value) // for search
ResourceUtil.getString($r("app.float.search_placeholder_font")).then(value => this.placeholdersize = value);
ResourceUtil.getString($r('app.float.distance_12')).then(value => this.listSpace = value);
ResourceUtil.getString($r('app.float.distance_12')).then(value => this.listSpaces = value);
let nYear = GlobalResourceManager.getStringByResource($r('app.string.year'));
nYear.then(resp => AppStorage.SetOrCreate(ConfigData.DATE_AND_TIME_YEAR, resp));
let nMonth = GlobalResourceManager.getStringByResource($r('app.string.month'));
@ -277,8 +277,8 @@ struct SettingList {
struct EntryComponent {
private settingsList: BaseData[][] = SETTINGS_LIST;
private nfcInfo: boolean;
@State listSpace: string = '12vp';
@State isPhone: boolean = false;
private listSpaces: string = '12vp';
private isPhone: boolean = false;
aboutToAppear() {
let info: string = parameter.getSync("const.SystemCapability.Communication.NFC.Core" ,"false");
@ -309,7 +309,7 @@ struct EntryComponent {
bottom: $r('app.float.distance_17')
})
}
List({ space: this.listSpace }) {
List({ space: this.listSpaces }) {
// for search
ListItem() {
Column() {

View File

@ -205,7 +205,7 @@ struct Storage {
.height(ConfigData.WH_100_100);
}
onPageShow(): void{
aboutToAppear(): void{
// bind component and initialize
if (this.controller) {
this.controller.bindComponent(this)

View File

@ -18,6 +18,7 @@ import HeadComponent from '../../../../../../common/component/src/main/ets/defau
import ImageAnimatorComponent from '../../../../../../common/component/src/main/ets/default/imageAnimatorComponent';
import ConfigData from '../../../../../../common/utils/src/main/ets/default/baseUtil/ConfigData';
import LogUtil from '../../../../../../common/utils/src/main/ets/default/baseUtil/LogUtil';
import ResourceUtil from '../../../../../../common/search/src/main/ets/default/common/ResourceUtil';
import router from '@system.router';
import deviceInfo from '@ohos.deviceInfo'
import prompt from '@system.prompt';
@ -101,6 +102,7 @@ struct Index {
@State isPhone: boolean = false;
private switchDebounceFlag = undefined;
private timerId: number = -1;
private errorMessage: string = "";
private clickApInfoDialog: CustomDialogController = new CustomDialogController({
builder: apInfoDialog({
apInfo: this.userSelectedApInfo,
@ -356,7 +358,7 @@ struct Index {
LogUtil.error(MODULE_TAG + 'wifi timeLimits active status : ' + this.isWiFiEnabled);
this.timerId = -1;
prompt.showToast({
message: $r('app.string.ERROR_WIFI_CHANGE'),
message: this.errorMessage,
duration: 1000,
});
}, 5000)
@ -389,6 +391,13 @@ struct Index {
aboutToAppear(): void {
LogUtil.info(MODULE_TAG + 'about to appear wifi page');
try{
ResourceUtil.getString($r('app.string.ERROR_WIFI_CHANGE')).then((data)=>{
this.errorMessage = data
})
}catch(error){
LogUtil.error(MODULE_TAG + 'get errorMessage String error:' + JSON.stringify(error));
}
WifiModel.registerWiFiStatusObserver((code) => {
LogUtil.info(MODULE_TAG + 'wifi status code : ' + code + ' taskId : ' + this.switchDebounceFlag);
if ((!this.switchDebounceFlag) && (code == 0 || code == 1)) {
@ -438,13 +447,13 @@ struct Index {
@Component
export default struct ApInfoComponent {
@Prop key: string;
@Prop label: string;
@Prop value: string;
build() {
Flex({ justifyContent: FlexAlign.SpaceBetween, alignItems: ItemAlign.Center }) {
Row() {
Text(this.key)
Text(this.label)
.fontSize($r('sys.float.ohos_id_text_size_body1'))
.fontColor($r('sys.color.ohos_id_color_text_primary'))
.fontWeight(FontWeight.Medium)
@ -500,7 +509,7 @@ struct apInfoDialog {
ForEach(this.dataList, (item) => {
ListItem() {
ApInfoComponent({
key: item.key,
label: item.key,
value: item.value
});
}
@ -643,7 +652,7 @@ struct apInfoDetailsDialog {
ForEach(this.dataList, (item) => {
ListItem() {
ApInfoComponent({
key: item.key,
label: item.key,
value: item.value
});
}

View File

@ -6,7 +6,7 @@
"description": "$string:mainability_description",
"mainElement": "com.ohos.settings.MainAbility",
"deviceTypes": [
"phone",
"default",
"tablet"
],
"deliveryWithInstall": true,
@ -31,10 +31,11 @@
"action.system.home"
]
}
]
],
"startWindowIcon": "$media:app_icon",
"startWindowBackground": "$color:white",
}
],
"requestPermissions": [
{
"name": "ohos.permission.MANAGE_LOCAL_ACCOUNTS",
@ -160,6 +161,6 @@
"name": "ohos.permission.MODIFY_AUDIO_SETTINGS",
"reason": "$string:MODIFY_AUDIO_SETTINGS"
}
],
]
}
}

View File

@ -79,6 +79,10 @@
{
"name": "D1D0DB",
"value": "#D1D0DB"
},
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -1203,6 +1203,10 @@
{
"name": "Cancel_Animation",
"value": "取消"
},
{
"name": "Input_Reached_Limited",
"value": "输入已达上限"
}
]
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -10,7 +10,7 @@
},
{
"name": "enabled",
"value": "Enabled"
"value": "On"
},
{
"name": "disable_",
@ -18,7 +18,7 @@
},
{
"name": "disabled",
"value": "Disabled"
"value": "Off"
},
{
"name": "settings",
@ -158,7 +158,7 @@
},
{
"name": "brightnessTab",
"value": "Display and Brightness"
"value": "Display & Brightness"
},
{
"name": "volumeControl",
@ -170,7 +170,7 @@
},
{
"name": "volumeControlTab",
"value": "Volume"
"value": "Sounds"
},
{
"name": "volumeControlRing",
@ -202,7 +202,7 @@
},
{
"name": "applyTab",
"value": "apply"
"value": "Apps"
},
{
"name": "moreConnectionsTab",
@ -222,7 +222,7 @@
},
{
"name": "aboutTab",
"value": "about"
"value": "About Device"
},
{
"name": "applicationInfo",
@ -502,7 +502,7 @@
},
{
"name": "systemTab",
"value": "system"
"value": "System & Updates"
},
{
"name": "languageTab",
@ -598,7 +598,7 @@
},
{
"name": "storageTab",
"value": "storageTab"
"value": "Storage"
},
{
"name": "totalSpace",
@ -1199,6 +1199,10 @@
{
"name": "Cancel_Animation",
"value": "Cancel"
},
{
"name": "Input_Reached_Limited",
"value": "Input has reached the upper limit"
}
]
}

View File

@ -1203,6 +1203,10 @@
{
"name": "Cancel_Animation",
"value": "取消"
},
{
"name": "Input_Reached_Limited",
"value": "输入已达上限"
}
]
}

View File

@ -0,0 +1,8 @@
{
"color": [
{
"name": "white",
"value": "#FFFFFF"
}
]
}

View File

@ -1203,6 +1203,10 @@
{
"name": "Cancel_Animation",
"value": "取消"
},
{
"name": "Input_Reached_Limited",
"value": "输入已达上限"
}
]
}