diff --git a/avpicker_static/avpicker/@ohos.multimedia.avCastPicker.ets b/avpicker_static/avpicker/@ohos.multimedia.avCastPicker.ets index d0c908399a5cd639dd362fcce3b5dd944144ba83..70a0f9cd0be44ff638c6e2d68a0254272bdcd7de 100644 --- a/avpicker_static/avpicker/@ohos.multimedia.avCastPicker.ets +++ b/avpicker_static/avpicker/@ohos.multimedia.avCastPicker.ets @@ -26,7 +26,7 @@ import { AVCastPickerState, AVCastPickerStyle, AVCastPickerColorMode } from '@oh import Want from '@ohos.app.ability.Want' const TAG = 'avcastpicker_component '; -const castPlusAudioType: number = 8.0; +const castPlusAudioType: number = 8; enum DeviceSource { /** @@ -83,17 +83,17 @@ export struct AVCastPicker { /** * Assigns the color of picker component at normal state. */ - @PropRef normalColor: Color | number | string = ''; + @PropRef normalColor?: Color | number | string = undefined; /** * Assigns the color of picker component at active state. */ - @PropRef activeColor: Color | number | string = ''; + @PropRef activeColor?: Color | number | string = 'undefined; /** * Definition of color mode of picker. */ - @PropRef colorMode: AVCastPickerColorMode = AVCastPickerColorMode.AUTO; + @PropRef colorMode?: AVCastPickerColorMode = AVCastPickerColorMode.AUTO; /** * The device that is displayed in the menu. @@ -103,7 +103,7 @@ export struct AVCastPicker { /** * The scale of font size. */ - @State fontSizeScale: number = 1.0; + @State fontSizeScale: number = 1; /** * Session type transferred by the application. @@ -113,7 +113,7 @@ export struct AVCastPicker { /** * Display form of application transfer. */ - @PropRef pickerStyle: AVCastPickerStyle = AVCastPickerStyle.STYLE_PANEL; + @PropRef pickerStyle?: AVCastPickerStyle = AVCastPickerStyle.STYLE_PANEL; /** * Display form mediaController. @@ -128,7 +128,7 @@ export struct AVCastPicker { /** * Touch item index. */ - @State touchMenuItemIndex: number = -1.0; + @State touchMenuItemIndex: number = -1; /** * Picker state change callback. @@ -140,12 +140,12 @@ export struct AVCastPicker { */ private extensionProxy: UIExtensionProxy | null = null; - private pickerClickTime: number = -1.0; + private pickerClickTime: number = -1; /** * Custom builder from application. */ - @BuilderParam customPicker?: () => void = () => {}; + @BuilderParam customPicker?: () => void = undefined; /** * Configuration color mode. @@ -157,7 +157,7 @@ export struct AVCastPicker { /** * Max Font and graphic magnification. */ - @State maxFontSizeScale: number = 1.0; + @State maxFontSizeScale: number = 1; /** * Accessibility Strings @@ -167,20 +167,20 @@ export struct AVCastPicker { @State isPc: boolean = false; @State isRTL: boolean = false; - @State restartUECMessage: number = 1.0; + @State restartUECMessage: number = 1; private needToRestart: boolean = false; @State isShowLoadingProgress: boolean = false; - private pickerCountOnCreation: number = 0.0; + private pickerCountOnCreation: number = 0; - private static currentPickerCount: number = 0.0; + private static currentPickerCount: number = 0; aboutToAppear(): void { - AVCastPicker.currentPickerCount += 1.0; + AVCastPicker.currentPickerCount += 1; this.pickerCountOnCreation = AVCastPicker.currentPickerCount; } aboutToDisappear(): void { - AVCastPicker.currentPickerCount -= 1.0; + AVCastPicker.currentPickerCount -= 1; } MenuStateChange(MenuStateChange: string){ @@ -194,7 +194,7 @@ export struct AVCastPicker { return false; } const protocols = item.supportedProtocols as number; - return (protocols & castPlusAudioType) !== 0.0; + return (protocols & castPlusAudioType) !== 0; } build() { @@ -218,8 +218,8 @@ export struct AVCastPicker { .renderingStrategy(SymbolRenderingStrategy.MULTIPLE_OPACITY) } else { Image(!isSelected ? $r(item.deviceIconName) : $r(item.selectedIconName)) - .width(24.0) - .height(24.0) + .width(24) + .height(24) .fillColor((isSelected && this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK) ? $r('sys.color.comp_background_emphasize') : $r('sys.color.icon_primary')) } @@ -235,9 +235,9 @@ export struct AVCastPicker { $r('sys.color.font_emphasize') : $r('sys.color.font_primary')) : (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? $r('sys.color.font_primary') : $r('sys.color.font_secondary'))) - .width(this.isPc ? 254.0 : 144.0) + .width(this.isPc ? 254 : 144) .textOverflow({ overflow: TextOverflow.Ellipsis }) - .maxLines(2.0) + .maxLines(2) .wordBreak(WordBreak.BREAK_ALL) .maxFontScale(this.maxFontSizeScale) .direction(this.isRTL ? Direction.Rtl : Direction.Ltr) @@ -250,7 +250,7 @@ export struct AVCastPicker { .highQualityStyles(this.maxFontSizeScale) Text(params.iconRight) .highQualityStyles(this.maxFontSizeScale) - .margin({ left: 2.0 * (Math.min(this.maxFontSizeScale, this.fontSizeScale)) } as Margin) + .margin({ left: 2 * (Math.min(this.maxFontSizeScale, this.fontSizeScale)) } as Margin) } .direction(Direction.Ltr) } @@ -281,16 +281,16 @@ export struct AVCastPicker { .borderRadius(3.0) .border({ width: 0.5 * (Math.min(this.maxFontSizeScale, this.fontSizeScale)),color: $r('sys.color.font_secondary')}) - .padding({top: 1.5, right: 4.0, bottom: 1.5, left: 4.0} as Padding) - .margin({ top: 2.0 } as Margin) + .padding({top: 1.5, right: 4, bottom: 1.5, left: 4} as Padding) + .margin({ top: 2 } as Margin) .width('auto') } } .padding({ - left: 8.0, - top: this.isPc ? 11.0 : (this.showHighQuality(item as AVCastPickerDeviceInfo) ? 7.0 : 17.0), - right: 8.0, - bottom: this.isPc ? 11.0 : (this.showHighQuality(item as AVCastPickerDeviceInfo) ? 7.0 : 17.0), + left: 8, + top: this.isPc ? 11 : (this.showHighQuality(item as AVCastPickerDeviceInfo) ? 7 : 17), + right: 8, + bottom: this.isPc ? 11 : (this.showHighQuality(item as AVCastPickerDeviceInfo) ? 7 : 17), } as Padding) } .alignItems(VerticalAlign.Center) @@ -304,13 +304,13 @@ export struct AVCastPicker { .accessibilityText(this.accessibilityConnectedStr) } } - .constraintSize({ minHeight: this.isPc ? 40.0 : 48.0 }) - .padding({ left: 12.0, right: 12.0 } as Padding) + .constraintSize({ minHeight: this.isPc ? 40 : 48 }) + .padding({ left: 12, right: 12 } as Padding) .onTouch((event: TouchEvent) => { if (event.type === TouchType.Down) { this.touchMenuItemIndex = index; } else if (event.type === TouchType.Up) { - this.touchMenuItemIndex = -1.0; + this.touchMenuItemIndex = -1; } }) .backgroundColor(this.touchMenuItemIndex === index ? @@ -318,15 +318,15 @@ export struct AVCastPicker { .borderRadius(this.touchMenuItemIndex === index ? (this.isPc ? $r('sys.float.corner_radius_level2') : $r('sys.float.corner_radius_level8')) : 0.0) - if (!this.isPc && (index != this.deviceList!.length - 1.0)) { + if (!this.isPc && (index != this.deviceList!.length - 1)) { Divider() - .height(1.0) + .height(1) .color($r('sys.color.comp_divider')) - .padding({ right: (this.isRTL ? 44.0 : 12.0), left: (this.isRTL ? 12.0 : 44.0) } as Padding) - } else if (this.isPc && (index != this.deviceList!.length - 1.0)) { + .padding({ right: (this.isRTL ? 44 : 12), left: (this.isRTL ? 12 : 44) } as Padding) + } else if (this.isPc && (index != this.deviceList!.length - 1)) { Row() .width('100%') - .height(2.0) + .height(2) } } .width('100%') @@ -338,7 +338,7 @@ export struct AVCastPicker { }) } .width(this.isPc ? 326 : 216) - .borderRadius(this.isPc ? 8 : 20) + .borderRadius(this.isPc ? 8.0 : 20.0) } @Builder @@ -379,9 +379,9 @@ export struct AVCastPicker { console.info(TAG, `picker device list : ${JSON.stringify(data['deviceList'])}`); this.deviceList = JSON.parse(JSON.stringify(data!['deviceList'] as string), Type.from())! as Array; - let hasOnlySpeakerAndEarpiece: boolean = this.deviceList!.length === 2.0 && + let hasOnlySpeakerAndEarpiece: boolean = this.deviceList!.length === 2 && !this.hasExtDevice(this.deviceList!); - let hasNoDevices: boolean = this.deviceList === null || this.deviceList!.length === 0.0; + let hasNoDevices: boolean = this.deviceList === null || this.deviceList!.length === 0; let isCalling: boolean = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; let isExtMenuScene = isCalling && (hasNoDevices || hasOnlySpeakerAndEarpiece); let isPanelForMedia: boolean = !isCalling && @@ -389,7 +389,7 @@ export struct AVCastPicker { this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); if (isExtMenuScene || isPanelForMedia) { this.isMenuShow = false; - this.touchMenuItemIndex = -1.0; + this.touchMenuItemIndex = -1; } } @@ -466,20 +466,20 @@ export struct AVCastPicker { placement: Placement.BottomRight, onDisappear: () => { this.isMenuShow = false; - this.touchMenuItemIndex = -1.0; + this.touchMenuItemIndex = -1; this.menuShowStateCallback(this.isMenuShow); }, onAppear: () => { - if (this.extensionProxy != null && this.pickerClickTime !== -1.0) { + if (this.extensionProxy != null && this.pickerClickTime !== -1) { this.extensionProxy?.send({ 'timeCost': new Date().getTime() - this.pickerClickTime }); - this.pickerClickTime = -1.0; + this.pickerClickTime = -1; } this.menuShowStateCallback(this.isMenuShow); } } as MenuOptions) .onTerminated((releaseCode: TerminationInfo) => { console.error(TAG, `onRelease code ${releaseCode.code}`); - if (releaseCode.code === 1.0) { + if (releaseCode.code === 1) { this.needToRestart = true; } } as Callback) @@ -499,11 +499,11 @@ export struct AVCastPicker { .onClick((e: ClickEvent) => { if (this.needToRestart) { this.needToRestart = false; - this.restartUECMessage += 1.0; + this.restartUECMessage += 1; return; } - let hasOnlySpeakerAndEarpiece: boolean = this.deviceList!.length === 2.0 && !this.hasExtDevice(this.deviceList!); - let hasNoDevices: boolean = this.deviceList === null || this.deviceList!.length === 0.0; + let hasOnlySpeakerAndEarpiece: boolean = this.deviceList!.length === 2 && !this.hasExtDevice(this.deviceList!); + let hasNoDevices: boolean = this.deviceList === null || this.deviceList!.length === 0; let isCalling: boolean = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; let isExtMenuScene: boolean = isCalling && (hasNoDevices || hasOnlySpeakerAndEarpiece); let isPanelForMedia: boolean = !isCalling && @@ -511,7 +511,7 @@ export struct AVCastPicker { this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); if (isExtMenuScene || isPanelForMedia) { this.isMenuShow = false; - this.touchMenuItemIndex = -1.0; + this.touchMenuItemIndex = -1; if (this.extensionProxy != null) { this.extensionProxy?.send({ 'clickEvent': true }); } @@ -520,16 +520,16 @@ export struct AVCastPicker { if (this.isMenuShow) { this.pickerClickTime = new Date().getTime(); } else { - this.touchMenuItemIndex = -1.0; + this.touchMenuItemIndex = -1; } } }) } private hasExtDevice(allDevice: Array): boolean { - for (let i: number = 0.0; i < allDevice.length; i++) { + for (let i: number = 0; i < allDevice.length; i++) { let isEarpieceOrSpeaker: boolean = - (allDevice[Double.toInt(i)].deviceType === 1.0 || allDevice[Double.toInt(i)].deviceType === 2.0) && + (allDevice[Double.toInt(i)].deviceType === 1 || allDevice[Double.toInt(i)].deviceType === 2) && allDevice[Double.toInt(i)].networkId === 'LocalDevice'; if (!isEarpieceOrSpeaker) { return true; @@ -572,14 +572,14 @@ export struct AVCastPicker { .alignItems(HorizontalAlign.Center) .justifyContent(FlexAlign.Center) .size({ width: '100%', height: '100%' }) - .zIndex(1.0) + .zIndex(1) } .size({ width: '100%', height: '100%' }) } } function highQualityStyles(this: TextAttribute, maxScale: number): this { - this.fontSize(7.0); + this.fontSize(7); this.fontWeight(FontWeight.Medium); this.fontColor($r('sys.color.font_secondary')); this.maxFontScale(maxScale); diff --git a/avpicker_static/avpicker_mock/@ohos.multimedia.avCastPicker.ets b/avpicker_static/avpicker_mock/@ohos.multimedia.avCastPicker.ets index d28dd59e17fdc88eedf6a57b5da3a7413e19edc9..a455b7d44531dd19ba666520ef1af36c6642fd7d 100644 --- a/avpicker_static/avpicker_mock/@ohos.multimedia.avCastPicker.ets +++ b/avpicker_static/avpicker_mock/@ohos.multimedia.avCastPicker.ets @@ -26,7 +26,7 @@ export struct AVCastPicker { /** * Custom builder from application */ - @BuilderParam customPicker: () => void = () => {}; + @BuilderParam customPicker: () => void = undefined; build() { Column() { @@ -58,7 +58,7 @@ export struct AVCastPicker { private buildCustomPicker() { Column() { Button({ type: ButtonType.Normal } as ButtonOptions) { - this.customPicker(); + this.customPicker?.(); } .type(ButtonType.Circle) .backgroundColor('#00000000')