180922886Sopenharmony_ci/* 280922886Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 380922886Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 480922886Sopenharmony_ci * you may not use this file except in compliance with the License. 580922886Sopenharmony_ci * You may obtain a copy of the License at 680922886Sopenharmony_ci * 780922886Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 880922886Sopenharmony_ci * 980922886Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 1080922886Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 1180922886Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1280922886Sopenharmony_ci * See the License for the specific language governing permissions and 1380922886Sopenharmony_ci * limitations under the License. 1480922886Sopenharmony_ci */ 1580922886Sopenharmony_ci 1680922886Sopenharmony_ciif (!('finalizeConstruction' in ViewPU.prototype)) { 1780922886Sopenharmony_ci Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { }); 1880922886Sopenharmony_ci} 1980922886Sopenharmony_ci 2080922886Sopenharmony_ciconst TAG = 'avcastpicker_component '; 2180922886Sopenharmony_ci 2280922886Sopenharmony_ciexport let AVCastPickerState; 2380922886Sopenharmony_ci(function(l11) { 2480922886Sopenharmony_ci l11[l11.STATE_APPEARING = 0] = 'STATE_APPEARING'; 2580922886Sopenharmony_ci l11[l11.STATE_DISAPPEARING = 1] = 'STATE_DISAPPEARING'; 2680922886Sopenharmony_ci})(AVCastPickerState || (AVCastPickerState = {})); 2780922886Sopenharmony_ci 2880922886Sopenharmony_ciexport let AVCastPickerStyle; 2980922886Sopenharmony_ci(function(k11) { 3080922886Sopenharmony_ci k11[k11.STYLE_PANEL = 0] = 'STYLE_PANEL'; 3180922886Sopenharmony_ci k11[k11.STYLE_MENU = 1] = 'STYLE_MENU'; 3280922886Sopenharmony_ci})(AVCastPickerStyle || (AVCastPickerStyle = {})); 3380922886Sopenharmony_ci 3480922886Sopenharmony_ciexport let DeviceSource; 3580922886Sopenharmony_ci(function(j11) { 3680922886Sopenharmony_ci j11[j11.LOCAL = 0] = 'LOCAL'; 3780922886Sopenharmony_ci j11[j11.CAST = 1] = 'CAST'; 3880922886Sopenharmony_ci})(DeviceSource || (DeviceSource = {})); 3980922886Sopenharmony_ci 4080922886Sopenharmony_ciexport let ConfigurationColorMode; 4180922886Sopenharmony_ci(function(u11) { 4280922886Sopenharmony_ci u11[u11.COLOR_MODE_NOT_SET = -1] = 'COLOR_MODE_NOT_SET'; 4380922886Sopenharmony_ci u11[u11.COLOR_MODE_DARK = 0] = 'COLOR_MODE_DARK'; 4480922886Sopenharmony_ci u11[u11.COLOR_MODE_LIGHT = 1] = 'COLOR_MODE_LIGHT'; 4580922886Sopenharmony_ci})(ConfigurationColorMode || (ConfigurationColorMode = {})); 4680922886Sopenharmony_ci 4780922886Sopenharmony_ciexport let AVCastPickerColorMode; 4880922886Sopenharmony_ci(function(v11) { 4980922886Sopenharmony_ci v11[v11.AUTO = 0] = 'AUTO'; 5080922886Sopenharmony_ci v11[v11.DARK = 1] = 'DARK'; 5180922886Sopenharmony_ci v11[v11.LIGHT = 2] = 'LIGHT'; 5280922886Sopenharmony_ci})(AVCastPickerColorMode || (AVCastPickerColorMode = {})); 5380922886Sopenharmony_ci 5480922886Sopenharmony_ciexport class AVCastPicker extends ViewPU { 5580922886Sopenharmony_ci constructor(d11, e11, f11, g11 = -1, h11 = undefined, i11) { 5680922886Sopenharmony_ci super(d11, f11, g11, i11); 5780922886Sopenharmony_ci if (typeof h11 === 'function') { 5880922886Sopenharmony_ci this.paramsGenerator_ = h11; 5980922886Sopenharmony_ci } 6080922886Sopenharmony_ci this.__normalColor = new ObservedPropertySimplePU(undefined, this, 'normalColor'); 6180922886Sopenharmony_ci this.__activeColor = new ObservedPropertySimplePU(undefined, this, 'activeColor'); 6280922886Sopenharmony_ci this.__colorMode = new ObservedPropertySimplePU(AVCastPickerColorMode.AUTO, this, 'colorMode'); 6380922886Sopenharmony_ci this.__deviceList = new ObservedPropertyObjectPU([], this, 'deviceList'); 6480922886Sopenharmony_ci this.__sessionType = new ObservedPropertySimplePU('audio', this, 'sessionType'); 6580922886Sopenharmony_ci this.__pickerStyle = new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyle'); 6680922886Sopenharmony_ci this.__pickerStyleFromMediaController = 6780922886Sopenharmony_ci new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyleFromMediaController'); 6880922886Sopenharmony_ci this.__isMenuShow = new ObservedPropertySimplePU(false, this, 'isMenuShow'); 6980922886Sopenharmony_ci this.__touchMenuItemIndex = new ObservedPropertySimplePU(-1, this, 'touchMenuItemIndex'); 7080922886Sopenharmony_ci this.onStateChange = undefined; 7180922886Sopenharmony_ci this.extensionProxy = null; 7280922886Sopenharmony_ci this.pickerClickTime = -1; 7380922886Sopenharmony_ci this.customPicker = undefined; 7480922886Sopenharmony_ci this.__configurationColorMode = 7580922886Sopenharmony_ci new ObservedPropertySimplePU(ConfigurationColorMode.COLOR_MODE_NOT_SET, this, 'configurationColorMode'); 7680922886Sopenharmony_ci this.__deviceInfoType = new ObservedPropertySimplePU('', this, 'deviceInfoType'); 7780922886Sopenharmony_ci this.maxFontSizeScale = 2; 7880922886Sopenharmony_ci this.__accessibilityConnectedStr = new ObservedPropertySimplePU('已连接', this, 'accessibilityConnectedStr'); 7980922886Sopenharmony_ci this.__accessibilityAudioControlStr = new ObservedPropertySimplePU('音视频投播', this, 'accessibilityAudioControlStr'); 8080922886Sopenharmony_ci this.setInitiallyProvidedValue(e11); 8180922886Sopenharmony_ci this.declareWatch('isMenuShow', this.MenuStateChange); 8280922886Sopenharmony_ci this.finalizeConstruction(); 8380922886Sopenharmony_ci } 8480922886Sopenharmony_ci 8580922886Sopenharmony_ci setInitiallyProvidedValue(c11) { 8680922886Sopenharmony_ci if (c11.normalColor !== undefined) { 8780922886Sopenharmony_ci this.normalColor = c11.normalColor; 8880922886Sopenharmony_ci } 8980922886Sopenharmony_ci if (c11.activeColor !== undefined) { 9080922886Sopenharmony_ci this.activeColor = c11.activeColor; 9180922886Sopenharmony_ci } 9280922886Sopenharmony_ci if (c11.colorMode !== undefined) { 9380922886Sopenharmony_ci this.colorMode = c11.colorMode; 9480922886Sopenharmony_ci } 9580922886Sopenharmony_ci if (c11.deviceList !== undefined) { 9680922886Sopenharmony_ci this.deviceList = c11.deviceList; 9780922886Sopenharmony_ci } 9880922886Sopenharmony_ci if (c11.sessionType !== undefined) { 9980922886Sopenharmony_ci this.sessionType = c11.sessionType; 10080922886Sopenharmony_ci } 10180922886Sopenharmony_ci if (c11.pickerStyle !== undefined) { 10280922886Sopenharmony_ci this.pickerStyle = c11.pickerStyle; 10380922886Sopenharmony_ci } 10480922886Sopenharmony_ci if (c11.pickerStyleFromMediaController !== undefined) { 10580922886Sopenharmony_ci this.pickerStyleFromMediaController = c11.pickerStyleFromMediaController; 10680922886Sopenharmony_ci } 10780922886Sopenharmony_ci if (c11.isMenuShow !== undefined) { 10880922886Sopenharmony_ci this.isMenuShow = c11.isMenuShow; 10980922886Sopenharmony_ci } 11080922886Sopenharmony_ci if (c11.touchMenuItemIndex !== undefined) { 11180922886Sopenharmony_ci this.touchMenuItemIndex = c11.touchMenuItemIndex; 11280922886Sopenharmony_ci } 11380922886Sopenharmony_ci if (c11.onStateChange !== undefined) { 11480922886Sopenharmony_ci this.onStateChange = c11.onStateChange; 11580922886Sopenharmony_ci } 11680922886Sopenharmony_ci if (c11.extensionProxy !== undefined) { 11780922886Sopenharmony_ci this.extensionProxy = c11.extensionProxy; 11880922886Sopenharmony_ci } 11980922886Sopenharmony_ci if (c11.pickerClickTime !== undefined) { 12080922886Sopenharmony_ci this.pickerClickTime = c11.pickerClickTime; 12180922886Sopenharmony_ci } 12280922886Sopenharmony_ci if (c11.customPicker !== undefined) { 12380922886Sopenharmony_ci this.customPicker = c11.customPicker; 12480922886Sopenharmony_ci } 12580922886Sopenharmony_ci if (c11.configurationColorMode !== undefined) { 12680922886Sopenharmony_ci this.configurationColorMode = c11.configurationColorMode; 12780922886Sopenharmony_ci } 12880922886Sopenharmony_ci if (c11.deviceInfoType !== undefined) { 12980922886Sopenharmony_ci this.deviceInfoType = c11.deviceInfoType; 13080922886Sopenharmony_ci } 13180922886Sopenharmony_ci if (c11.maxFontSizeScale !== undefined) { 13280922886Sopenharmony_ci this.maxFontSizeScale = c11.maxFontSizeScale; 13380922886Sopenharmony_ci } 13480922886Sopenharmony_ci if (c11.accessibilityConnectedStr !== undefined) { 13580922886Sopenharmony_ci this.accessibilityConnectedStr = c11.accessibilityConnectedStr; 13680922886Sopenharmony_ci } 13780922886Sopenharmony_ci if (c11.__accessibilityAudioControlStr !== undefined) { 13880922886Sopenharmony_ci this.accessibilityAudioControlStr = c11.accessibilityAudioControlStr; 13980922886Sopenharmony_ci } 14080922886Sopenharmony_ci } 14180922886Sopenharmony_ci 14280922886Sopenharmony_ci updateStateVars(b11) { 14380922886Sopenharmony_ci } 14480922886Sopenharmony_ci 14580922886Sopenharmony_ci purgeVariableDependenciesOnElmtId(a11) { 14680922886Sopenharmony_ci this.__normalColor.purgeDependencyOnElmtId(a11); 14780922886Sopenharmony_ci this.__activeColor.purgeDependencyOnElmtId(a11); 14880922886Sopenharmony_ci this.__colorMode.purgeDependencyOnElmtId(a11); 14980922886Sopenharmony_ci this.__deviceList.purgeDependencyOnElmtId(a11); 15080922886Sopenharmony_ci this.__sessionType.purgeDependencyOnElmtId(a11); 15180922886Sopenharmony_ci this.__pickerStyle.purgeDependencyOnElmtId(a11); 15280922886Sopenharmony_ci this.__pickerStyleFromMediaController.purgeDependencyOnElmtId(a11); 15380922886Sopenharmony_ci this.__isMenuShow.purgeDependencyOnElmtId(a11); 15480922886Sopenharmony_ci this.__touchMenuItemIndex.purgeDependencyOnElmtId(a11); 15580922886Sopenharmony_ci this.__configurationColorMode.purgeDependencyOnElmtId(a11); 15680922886Sopenharmony_ci this.__deviceInfoType.purgeDependencyOnElmtId(a11); 15780922886Sopenharmony_ci this.__accessibilityConnectedStr.purgeDependencyOnElmtId(a11); 15880922886Sopenharmony_ci this.__accessibilityAudioControlStr.purgeDependencyOnElmtId(a11); 15980922886Sopenharmony_ci } 16080922886Sopenharmony_ci 16180922886Sopenharmony_ci aboutToBeDeleted() { 16280922886Sopenharmony_ci this.__normalColor.aboutToBeDeleted(); 16380922886Sopenharmony_ci this.__activeColor.aboutToBeDeleted(); 16480922886Sopenharmony_ci this.__colorMode.aboutToBeDeleted(); 16580922886Sopenharmony_ci this.__deviceList.aboutToBeDeleted(); 16680922886Sopenharmony_ci this.__sessionType.aboutToBeDeleted(); 16780922886Sopenharmony_ci this.__pickerStyle.aboutToBeDeleted(); 16880922886Sopenharmony_ci this.__pickerStyleFromMediaController.aboutToBeDeleted(); 16980922886Sopenharmony_ci this.__isMenuShow.aboutToBeDeleted(); 17080922886Sopenharmony_ci this.__touchMenuItemIndex.aboutToBeDeleted(); 17180922886Sopenharmony_ci this.__configurationColorMode.aboutToBeDeleted(); 17280922886Sopenharmony_ci this.__deviceInfoType.aboutToBeDeleted(); 17380922886Sopenharmony_ci this.__accessibilityConnectedStr.aboutToBeDeleted(); 17480922886Sopenharmony_ci this.__accessibilityAudioControlStr.aboutToBeDeleted(); 17580922886Sopenharmony_ci SubscriberManager.Get().delete(this.id__()); 17680922886Sopenharmony_ci this.aboutToBeDeletedInternal(); 17780922886Sopenharmony_ci } 17880922886Sopenharmony_ci 17980922886Sopenharmony_ci get normalColor() { 18080922886Sopenharmony_ci return this.__normalColor.get(); 18180922886Sopenharmony_ci } 18280922886Sopenharmony_ci 18380922886Sopenharmony_ci set normalColor(z10) { 18480922886Sopenharmony_ci this.__normalColor.set(z10); 18580922886Sopenharmony_ci } 18680922886Sopenharmony_ci 18780922886Sopenharmony_ci get activeColor() { 18880922886Sopenharmony_ci return this.__activeColor.get(); 18980922886Sopenharmony_ci } 19080922886Sopenharmony_ci 19180922886Sopenharmony_ci set activeColor(y10) { 19280922886Sopenharmony_ci this.__activeColor.set(y10); 19380922886Sopenharmony_ci } 19480922886Sopenharmony_ci 19580922886Sopenharmony_ci get colorMode() { 19680922886Sopenharmony_ci return this.__colorMode.get(); 19780922886Sopenharmony_ci } 19880922886Sopenharmony_ci 19980922886Sopenharmony_ci set colorMode(b1) { 20080922886Sopenharmony_ci this.__colorMode.set(b1); 20180922886Sopenharmony_ci } 20280922886Sopenharmony_ci 20380922886Sopenharmony_ci get deviceList() { 20480922886Sopenharmony_ci return this.__deviceList.get(); 20580922886Sopenharmony_ci } 20680922886Sopenharmony_ci 20780922886Sopenharmony_ci set deviceList(x10) { 20880922886Sopenharmony_ci this.__deviceList.set(x10); 20980922886Sopenharmony_ci } 21080922886Sopenharmony_ci 21180922886Sopenharmony_ci get sessionType() { 21280922886Sopenharmony_ci return this.__sessionType.get(); 21380922886Sopenharmony_ci } 21480922886Sopenharmony_ci 21580922886Sopenharmony_ci set sessionType(w10) { 21680922886Sopenharmony_ci this.__sessionType.set(w10); 21780922886Sopenharmony_ci } 21880922886Sopenharmony_ci 21980922886Sopenharmony_ci get pickerStyle() { 22080922886Sopenharmony_ci return this.__pickerStyle.get(); 22180922886Sopenharmony_ci } 22280922886Sopenharmony_ci 22380922886Sopenharmony_ci set pickerStyle(v10) { 22480922886Sopenharmony_ci this.__pickerStyle.set(v10); 22580922886Sopenharmony_ci } 22680922886Sopenharmony_ci 22780922886Sopenharmony_ci get pickerStyleFromMediaController() { 22880922886Sopenharmony_ci return this.__pickerStyleFromMediaController.get(); 22980922886Sopenharmony_ci } 23080922886Sopenharmony_ci 23180922886Sopenharmony_ci set pickerStyleFromMediaController(b1) { 23280922886Sopenharmony_ci this.__pickerStyleFromMediaController.set(b1); 23380922886Sopenharmony_ci } 23480922886Sopenharmony_ci 23580922886Sopenharmony_ci get isMenuShow() { 23680922886Sopenharmony_ci return this.__isMenuShow.get(); 23780922886Sopenharmony_ci } 23880922886Sopenharmony_ci 23980922886Sopenharmony_ci set isMenuShow(u10) { 24080922886Sopenharmony_ci this.__isMenuShow.set(u10); 24180922886Sopenharmony_ci } 24280922886Sopenharmony_ci 24380922886Sopenharmony_ci get touchMenuItemIndex() { 24480922886Sopenharmony_ci return this.__touchMenuItemIndex.get(); 24580922886Sopenharmony_ci } 24680922886Sopenharmony_ci 24780922886Sopenharmony_ci set touchMenuItemIndex(t10) { 24880922886Sopenharmony_ci this.__touchMenuItemIndex.set(t10); 24980922886Sopenharmony_ci } 25080922886Sopenharmony_ci 25180922886Sopenharmony_ci get configurationColorMode() { 25280922886Sopenharmony_ci return this.__configurationColorMode.get(); 25380922886Sopenharmony_ci } 25480922886Sopenharmony_ci 25580922886Sopenharmony_ci set configurationColorMode(a1) { 25680922886Sopenharmony_ci this.__configurationColorMode.set(a1); 25780922886Sopenharmony_ci } 25880922886Sopenharmony_ci 25980922886Sopenharmony_ci get deviceInfoType() { 26080922886Sopenharmony_ci return this.__deviceInfoType.get(); 26180922886Sopenharmony_ci } 26280922886Sopenharmony_ci 26380922886Sopenharmony_ci set deviceInfoType(b1) { 26480922886Sopenharmony_ci this.__deviceInfoType.set(b1); 26580922886Sopenharmony_ci } 26680922886Sopenharmony_ci 26780922886Sopenharmony_ci get accessibilityConnectedStr() { 26880922886Sopenharmony_ci return this.__accessibilityConnectedStr.get(); 26980922886Sopenharmony_ci } 27080922886Sopenharmony_ci 27180922886Sopenharmony_ci set accessibilityConnectedStr(c1) { 27280922886Sopenharmony_ci this.__accessibilityConnectedStr.set(c1); 27380922886Sopenharmony_ci } 27480922886Sopenharmony_ci 27580922886Sopenharmony_ci get accessibilityAudioControlStr() { 27680922886Sopenharmony_ci return this.__accessibilityAudioControlStr.get(); 27780922886Sopenharmony_ci } 27880922886Sopenharmony_ci 27980922886Sopenharmony_ci set accessibilityAudioControlStr(d1) { 28080922886Sopenharmony_ci this.__accessibilityAudioControlStr.set(d1); 28180922886Sopenharmony_ci } 28280922886Sopenharmony_ci 28380922886Sopenharmony_ci MenuStateChange() { 28480922886Sopenharmony_ci if (this.extensionProxy != null) { 28580922886Sopenharmony_ci this.extensionProxy.send({ 'isMenuShow': this.isMenuShow }); 28680922886Sopenharmony_ci } 28780922886Sopenharmony_ci } 28880922886Sopenharmony_ci 28980922886Sopenharmony_ci initialRender() { 29080922886Sopenharmony_ci this.observeComponentCreation2((r10, s10) => { 29180922886Sopenharmony_ci Column.create(); 29280922886Sopenharmony_ci Column.size({ width: '100%', height: '100%'}); 29380922886Sopenharmony_ci }, Column); 29480922886Sopenharmony_ci this.observeComponentCreation2((n10, o10) => { 29580922886Sopenharmony_ci If.create(); 29680922886Sopenharmony_ci if (this.customPicker === undefined) { 29780922886Sopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 29880922886Sopenharmony_ci this.buildDefaultPicker.bind(this)(false); 29980922886Sopenharmony_ci }); 30080922886Sopenharmony_ci } else { 30180922886Sopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 30280922886Sopenharmony_ci this.buildCustomPicker.bind(this)(); 30380922886Sopenharmony_ci }); 30480922886Sopenharmony_ci } 30580922886Sopenharmony_ci }, If); 30680922886Sopenharmony_ci If.pop(); 30780922886Sopenharmony_ci Column.pop(); 30880922886Sopenharmony_ci } 30980922886Sopenharmony_ci 31080922886Sopenharmony_ci buildIcon(b3, c3, d3 = null) { 31180922886Sopenharmony_ci this.observeComponentCreation2((f3, g3) => { 31280922886Sopenharmony_ci If.create(); 31380922886Sopenharmony_ci if (this.deviceInfoType === 'true') { 31480922886Sopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 31580922886Sopenharmony_ci this.observeComponentCreation2((n3, o3) => { 31680922886Sopenharmony_ci SymbolGlyph.create(!c3 ? { 'id': -1, 'type': -1, params: [b3.deviceIconName], 31780922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 31880922886Sopenharmony_ci { 'id': -1, 'type': -1, params: [b3.selectedIconName], 31980922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 32080922886Sopenharmony_ci SymbolGlyph.fontSize('24vp'); 32180922886Sopenharmony_ci SymbolGlyph.fontColor((c3 && this.configurationColorMode !== 32280922886Sopenharmony_ci ConfigurationColorMode.COLOR_MODE_DARK) ? 32380922886Sopenharmony_ci [{ 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 32480922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }] : 32580922886Sopenharmony_ci [{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 32680922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]); 32780922886Sopenharmony_ci SymbolGlyph.renderingStrategy(2); 32880922886Sopenharmony_ci }, SymbolGlyph); 32980922886Sopenharmony_ci }); 33080922886Sopenharmony_ci } else { 33180922886Sopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 33280922886Sopenharmony_ci this.observeComponentCreation2((j3, k3) => { 33380922886Sopenharmony_ci Image.create(!c3 ? { 'id': -1, 'type': -1, 33480922886Sopenharmony_ci params: [b3.deviceIconName], 'bundleName': '__harDefaultBundleName__', 33580922886Sopenharmony_ci 'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': -1, params: [b3.selectedIconName], 33680922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 33780922886Sopenharmony_ci Image.width(24); 33880922886Sopenharmony_ci Image.height(24); 33980922886Sopenharmony_ci Image.fillColor((c3 && this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK) ? 34080922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 34180922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 34280922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 34380922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 34480922886Sopenharmony_ci }, Image); 34580922886Sopenharmony_ci }); 34680922886Sopenharmony_ci } 34780922886Sopenharmony_ci }, If); 34880922886Sopenharmony_ci If.pop(); 34980922886Sopenharmony_ci } 35080922886Sopenharmony_ci 35180922886Sopenharmony_ci deviceMenu(o8 = null) { 35280922886Sopenharmony_ci this.observeComponentCreation2((j10, k10) => { 35380922886Sopenharmony_ci Column.create(); 35480922886Sopenharmony_ci Column.width(216); 35580922886Sopenharmony_ci }, Column); 35680922886Sopenharmony_ci this.observeComponentCreation2((r8, s8) => { 35780922886Sopenharmony_ci ForEach.create(); 35880922886Sopenharmony_ci const t8 = (v8, w8) => { 35980922886Sopenharmony_ci const x8 = v8; 36080922886Sopenharmony_ci this.observeComponentCreation2((g10, h10) => { 36180922886Sopenharmony_ci Flex.create({ 36280922886Sopenharmony_ci direction: FlexDirection.Column, 36380922886Sopenharmony_ci justifyContent: FlexAlign.SpaceBetween, 36480922886Sopenharmony_ci alignItems: ItemAlign.End 36580922886Sopenharmony_ci }); 36680922886Sopenharmony_ci Flex.width('100%'); 36780922886Sopenharmony_ci Flex.onClick(() => { 36880922886Sopenharmony_ci if (this.extensionProxy != null && !x8.isConnected) { 36980922886Sopenharmony_ci this.extensionProxy.send({ 'selectedDeviceInfo': x8 }); 37080922886Sopenharmony_ci } 37180922886Sopenharmony_ci }); 37280922886Sopenharmony_ci }, Flex); 37380922886Sopenharmony_ci this.observeComponentCreation2((c10, d10) => { 37480922886Sopenharmony_ci Flex.create({ 37580922886Sopenharmony_ci direction: FlexDirection.Row, 37680922886Sopenharmony_ci justifyContent: FlexAlign.SpaceBetween, 37780922886Sopenharmony_ci alignItems: ItemAlign.Center 37880922886Sopenharmony_ci }); 37980922886Sopenharmony_ci Flex.constraintSize({ minHeight: 48 }); 38080922886Sopenharmony_ci Flex.padding({ left: 12, right: 12 }); 38180922886Sopenharmony_ci Flex.onTouch((f10) => { 38280922886Sopenharmony_ci if (f10.type === TouchType.Down) { 38380922886Sopenharmony_ci this.touchMenuItemIndex = w8; 38480922886Sopenharmony_ci } 38580922886Sopenharmony_ci else if (f10.type === TouchType.Up) { 38680922886Sopenharmony_ci this.touchMenuItemIndex = -1; 38780922886Sopenharmony_ci } 38880922886Sopenharmony_ci }); 38980922886Sopenharmony_ci Flex.backgroundColor(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10001, 39080922886Sopenharmony_ci params: ['sys.color.interactive_click'], 'bundleName': '__harDefaultModuleName__', 39180922886Sopenharmony_ci 'moduleName': '__harDefaultModuleName__' } : '#00FFFFFF'); 39280922886Sopenharmony_ci Flex.borderRadius(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10002, 39380922886Sopenharmony_ci params: ['sys.float.corner_radius_level8'], 'bundleName': '__harDefaultModuleName__', 39480922886Sopenharmony_ci 'moduleName': '__harDefaultModuleName__' } : 0); 39580922886Sopenharmony_ci }, Flex); 39680922886Sopenharmony_ci this.observeComponentCreation2((a10, b10) => { 39780922886Sopenharmony_ci Row.create(); 39880922886Sopenharmony_ci Row.justifyContent(FlexAlign.Start); 39980922886Sopenharmony_ci Row.alignItems(VerticalAlign.Center); 40080922886Sopenharmony_ci }, Row); 40180922886Sopenharmony_ci this.buildIcon.bind(this)(x8, false); 40280922886Sopenharmony_ci this.observeComponentCreation2((w9, x9) => { 40380922886Sopenharmony_ci Text.create(x8.deviceName); 40480922886Sopenharmony_ci Text.fontSize({ 'id': -1, 'type': 10002, 40580922886Sopenharmony_ci params: ['sys.float.ohos_id_text_size_body2'], 'bundleName': '__harDefaultModuleName__', 40680922886Sopenharmony_ci 'moduleName': '__harDefaultModuleName__' }); 40780922886Sopenharmony_ci Text.fontColor(x8.isConnected ? 40880922886Sopenharmony_ci (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 40980922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 41080922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 41180922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 41280922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }) : 41380922886Sopenharmony_ci (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 41480922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 41580922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 41680922886Sopenharmony_ci { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 41780922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 41880922886Sopenharmony_ci Text.width(144); 41980922886Sopenharmony_ci Text.padding({ 42080922886Sopenharmony_ci left: 8, 42180922886Sopenharmony_ci top: 12, 42280922886Sopenharmony_ci right: 8, 42380922886Sopenharmony_ci bottom: 12 42480922886Sopenharmony_ci }); 42580922886Sopenharmony_ci Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 42680922886Sopenharmony_ci Text.maxLines(2); 42780922886Sopenharmony_ci Text.wordBreak(WordBreak.BREAK_ALL); 42880922886Sopenharmony_ci Text.maxFontScale(this.maxFontSizeScale); 42980922886Sopenharmony_ci }, Text); 43080922886Sopenharmony_ci Text.pop(); 43180922886Sopenharmony_ci Row.pop(); 43280922886Sopenharmony_ci this.observeComponentCreation2((m9, n9) => { 43380922886Sopenharmony_ci If.create(); 43480922886Sopenharmony_ci if (x8.isConnected && x8.selectedIconName !== null && x8.selectedIconName !== undefined) { 43580922886Sopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 43680922886Sopenharmony_ci this.observeComponentCreation2((u9, v9) => { 43780922886Sopenharmony_ci Row.create(); 43880922886Sopenharmony_ci Row.justifyContent(FlexAlign.Start); 43980922886Sopenharmony_ci Row.alignItems(VerticalAlign.Center); 44080922886Sopenharmony_ci Row.accessibilityLevel('yes'); 44180922886Sopenharmony_ci Row.accessibilityText(this.accessibilityConnectedStr); 44280922886Sopenharmony_ci }, Row); 44380922886Sopenharmony_ci this.buildIcon.bind(this)(x8, true); 44480922886Sopenharmony_ci Row.pop(); 44580922886Sopenharmony_ci }); 44680922886Sopenharmony_ci } else { 44780922886Sopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 44880922886Sopenharmony_ci }); 44980922886Sopenharmony_ci } 45080922886Sopenharmony_ci }, If); 45180922886Sopenharmony_ci If.pop(); 45280922886Sopenharmony_ci Flex.pop(); 45380922886Sopenharmony_ci this.observeComponentCreation2((f9, g9) => { 45480922886Sopenharmony_ci If.create(); 45580922886Sopenharmony_ci if (w8 !== this.deviceList.length - 1) { 45680922886Sopenharmony_ci this.ifElseBranchUpdateFunction(0, () => { 45780922886Sopenharmony_ci this.observeComponentCreation2((k9, l9) => { 45880922886Sopenharmony_ci Divider.create(); 45980922886Sopenharmony_ci Divider.height(1); 46080922886Sopenharmony_ci Divider.width(172); 46180922886Sopenharmony_ci Divider.color({ 'id': -1, 'type': 10001, params: ['sys.color.comp_divider'], 46280922886Sopenharmony_ci 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 46380922886Sopenharmony_ci Divider.padding({ right: 12 }); 46480922886Sopenharmony_ci }, Divider); 46580922886Sopenharmony_ci }); 46680922886Sopenharmony_ci } 46780922886Sopenharmony_ci else { 46880922886Sopenharmony_ci this.ifElseBranchUpdateFunction(1, () => { 46980922886Sopenharmony_ci }); 47080922886Sopenharmony_ci } 47180922886Sopenharmony_ci }, If); 47280922886Sopenharmony_ci If.pop(); 47380922886Sopenharmony_ci Flex.pop(); 47480922886Sopenharmony_ci }; 47580922886Sopenharmony_ci this.forEachUpdateFunction(r8, this.deviceList, t8, undefined, true, false); 47680922886Sopenharmony_ci }, ForEach); 47780922886Sopenharmony_ci ForEach.pop(); 47880922886Sopenharmony_ci Column.pop(); 47980922886Sopenharmony_ci } 48080922886Sopenharmony_ci 48180922886Sopenharmony_ci buildDefaultPicker(c8, d8 = null) { 48280922886Sopenharmony_ci this.observeComponentCreation2((f8, g8) => { 48380922886Sopenharmony_ci UIExtensionComponent.create({ 48480922886Sopenharmony_ci abilityName: 'UIExtAbility', 48580922886Sopenharmony_ci bundleName: 'com.hmos.mediacontroller', 48680922886Sopenharmony_ci parameters: { 48780922886Sopenharmony_ci 'normalColor': this.normalColor, 48880922886Sopenharmony_ci 'activeColor': this.activeColor, 48980922886Sopenharmony_ci 'pickerColorMode': this.colorMode, 49080922886Sopenharmony_ci 'avCastPickerStyle': this.pickerStyle, 49180922886Sopenharmony_ci 'ability.want.params.uiExtensionType': 'sysPicker/mediaControl', 49280922886Sopenharmony_ci 'isCustomPicker': c8, 49380922886Sopenharmony_ci } 49480922886Sopenharmony_ci }); 49580922886Sopenharmony_ci UIExtensionComponent.onRemoteReady((n8) => { 49680922886Sopenharmony_ci console.info(TAG, 'onRemoteReady'); 49780922886Sopenharmony_ci this.extensionProxy = n8; 49880922886Sopenharmony_ci }); 49980922886Sopenharmony_ci UIExtensionComponent.onReceive((l8) => { 50080922886Sopenharmony_ci if (JSON.stringify(l8.deviceInfoType) !== undefined) { 50180922886Sopenharmony_ci console.info(TAG, `deviceInfoType : ${JSON.stringify(l8.deviceInfoType)}`); 50280922886Sopenharmony_ci this.deviceInfoType = l8.deviceInfoType; 50380922886Sopenharmony_ci } 50480922886Sopenharmony_ci 50580922886Sopenharmony_ci if (JSON.stringify(l8.pickerStyle) !== undefined) { 50680922886Sopenharmony_ci console.info(TAG, `picker style : ${JSON.stringify(l8.pickerStyle)}`); 50780922886Sopenharmony_ci this.pickerStyleFromMediaController = l8.pickerStyle; 50880922886Sopenharmony_ci } 50980922886Sopenharmony_ci 51080922886Sopenharmony_ci if (JSON.stringify(l8.deviceList) !== undefined) { 51180922886Sopenharmony_ci console.info(TAG, `picker device list : ${JSON.stringify(l8.deviceList)}`); 51280922886Sopenharmony_ci this.deviceList = JSON.parse(JSON.stringify(l8.deviceList)); 51380922886Sopenharmony_ci let u = this.deviceList.length === 2 && !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 51480922886Sopenharmony_ci let v = this.deviceList === null || this.deviceList.length === 0; 51580922886Sopenharmony_ci let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 51680922886Sopenharmony_ci let x = w && (v || u); 51780922886Sopenharmony_ci let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 51880922886Sopenharmony_ci this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 51980922886Sopenharmony_ci if (x || b21) { 52080922886Sopenharmony_ci this.isMenuShow = false; 52180922886Sopenharmony_ci this.touchMenuItemIndex = -1; 52280922886Sopenharmony_ci } 52380922886Sopenharmony_ci } 52480922886Sopenharmony_ci 52580922886Sopenharmony_ci if (JSON.stringify(l8.state) !== undefined) { 52680922886Sopenharmony_ci console.info(TAG, `picker state change : ${JSON.stringify(l8.state)}`); 52780922886Sopenharmony_ci let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 52880922886Sopenharmony_ci let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 52980922886Sopenharmony_ci this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 53080922886Sopenharmony_ci if (this.onStateChange != null && b21) { 53180922886Sopenharmony_ci if (parseInt(JSON.stringify(l8.state)) === AVCastPickerState.STATE_APPEARING) { 53280922886Sopenharmony_ci this.onStateChange(AVCastPickerState.STATE_APPEARING); 53380922886Sopenharmony_ci } 53480922886Sopenharmony_ci else { 53580922886Sopenharmony_ci this.onStateChange(AVCastPickerState.STATE_DISAPPEARING); 53680922886Sopenharmony_ci } 53780922886Sopenharmony_ci } 53880922886Sopenharmony_ci } 53980922886Sopenharmony_ci 54080922886Sopenharmony_ci if (JSON.stringify(l8.sessionType) !== undefined) { 54180922886Sopenharmony_ci console.info(TAG, `session type : ${JSON.stringify(l8.sessionType)}`); 54280922886Sopenharmony_ci this.sessionType = l8.sessionType; 54380922886Sopenharmony_ci } 54480922886Sopenharmony_ci 54580922886Sopenharmony_ci if (JSON.stringify(l8.isShowMenu) !== undefined) { 54680922886Sopenharmony_ci console.info(TAG, `isShowMenu : ${l8.isShowMenu}`); 54780922886Sopenharmony_ci this.isMenuShow = l8.isShowMenu; 54880922886Sopenharmony_ci if (!this.isMenuShow) { 54980922886Sopenharmony_ci this.touchMenuItemIndex = -1; 55080922886Sopenharmony_ci } 55180922886Sopenharmony_ci } 55280922886Sopenharmony_ci 55380922886Sopenharmony_ci if (JSON.stringify(l8.configurationColorMode) !== undefined) { 55480922886Sopenharmony_ci console.info(TAG, `configurationColorMode : ${l8.configurationColorMode}`); 55580922886Sopenharmony_ci this.configurationColorMode = l8.configurationColorMode; 55680922886Sopenharmony_ci } 55780922886Sopenharmony_ci 55880922886Sopenharmony_ci if (JSON.stringify(l8.accessConnected) !== undefined) { 55980922886Sopenharmony_ci console.info(TAG, `accessibilityConnectedStr : ${l8.accessConnected}`); 56080922886Sopenharmony_ci this.accessibilityConnectedStr = l8.accessConnected; 56180922886Sopenharmony_ci } 56280922886Sopenharmony_ci 56380922886Sopenharmony_ci 56480922886Sopenharmony_ci if (JSON.stringify(l8.accessAudioControl) !== undefined) { 56580922886Sopenharmony_ci console.info(TAG, `accessibilityAudioControlStr : ${l8.accessAudioControl}`); 56680922886Sopenharmony_ci this.accessibilityAudioControlStr = l8.accessAudioControl; 56780922886Sopenharmony_ci } 56880922886Sopenharmony_ci }); 56980922886Sopenharmony_ci UIExtensionComponent.size({ width: '100%', height: '100%' }); 57080922886Sopenharmony_ci UIExtensionComponent.bindMenu(this.isMenuShow, { builder: () => { this.deviceMenu.call(this); }}, { 57180922886Sopenharmony_ci placement: Placement.TopRight, 57280922886Sopenharmony_ci onDisappear: () => { 57380922886Sopenharmony_ci this.isMenuShow = false; 57480922886Sopenharmony_ci this.touchMenuItemIndex = -1; 57580922886Sopenharmony_ci this.menuShowStateCallback(this.isMenuShow); 57680922886Sopenharmony_ci }, 57780922886Sopenharmony_ci onAppear: () => { 57880922886Sopenharmony_ci if (this.extensionProxy != null && this.pickerClickTime !== -1) { 57980922886Sopenharmony_ci this.extensionProxy.send({ 'timeCost': new Date().getTime() - this.pickerClickTime }); 58080922886Sopenharmony_ci this.pickerClickTime = -1; 58180922886Sopenharmony_ci } 58280922886Sopenharmony_ci this.menuShowStateCallback(this.isMenuShow); 58380922886Sopenharmony_ci } 58480922886Sopenharmony_ci }); 58580922886Sopenharmony_ci UIExtensionComponent.onClick(() => { 58680922886Sopenharmony_ci let u = this.deviceList.length === 2 && 58780922886Sopenharmony_ci !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 58880922886Sopenharmony_ci let v = this.deviceList === null || this.deviceList.length === 0; 58980922886Sopenharmony_ci let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 59080922886Sopenharmony_ci let x = w && (v || u); 59180922886Sopenharmony_ci let y = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 59280922886Sopenharmony_ci this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 59380922886Sopenharmony_ci if (x || y) { 59480922886Sopenharmony_ci this.isMenuShow = false; 59580922886Sopenharmony_ci this.touchMenuItemIndex = -1; 59680922886Sopenharmony_ci if (this.extensionProxy != null) { 59780922886Sopenharmony_ci this.extensionProxy.send({'clickEvent': true}); 59880922886Sopenharmony_ci } 59980922886Sopenharmony_ci } else { 60080922886Sopenharmony_ci this.isMenuShow = !this.isMenuShow; 60180922886Sopenharmony_ci if (this.isMenuShow) { 60280922886Sopenharmony_ci this.pickerClickTime = new Date().getTime(); 60380922886Sopenharmony_ci } else { 60480922886Sopenharmony_ci this.touchMenuItemIndex = -1; 60580922886Sopenharmony_ci } 60680922886Sopenharmony_ci } 60780922886Sopenharmony_ci }); 60880922886Sopenharmony_ci UIExtensionComponent.accessibilityLevel('yes'); 60980922886Sopenharmony_ci UIExtensionComponent.accessibilityText(this.__accessibilityAudioControlStr); 61080922886Sopenharmony_ci }, UIExtensionComponent); 61180922886Sopenharmony_ci } 61280922886Sopenharmony_ci 61380922886Sopenharmony_ci hasExtDevice(a) { 61480922886Sopenharmony_ci for (let b = 0; b < a.length; b++) { 61580922886Sopenharmony_ci if (a[b].deviceType !== 1 && // 1 is audio.DeviceType.EARPIECE 61680922886Sopenharmony_ci a[b].deviceType !== 2) { // 2 is audio.DeviceType.SPEAKER 61780922886Sopenharmony_ci return true; 61880922886Sopenharmony_ci } 61980922886Sopenharmony_ci } 62080922886Sopenharmony_ci return false; 62180922886Sopenharmony_ci } 62280922886Sopenharmony_ci 62380922886Sopenharmony_ci menuShowStateCallback(k) { 62480922886Sopenharmony_ci if (this.onStateChange != null && (this.pickerStyle === AVCastPickerStyle.STYLE_MENU || 62580922886Sopenharmony_ci this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_MENU)) { 62680922886Sopenharmony_ci let l = k ? AVCastPickerState.STATE_APPEARING : AVCastPickerState.STATE_DISAPPEARING; 62780922886Sopenharmony_ci this.onStateChange(l); 62880922886Sopenharmony_ci } 62980922886Sopenharmony_ci } 63080922886Sopenharmony_ci 63180922886Sopenharmony_ci buildCustomPicker(s7 = null) { 63280922886Sopenharmony_ci this.observeComponentCreation2((a8, b8) => { 63380922886Sopenharmony_ci Stack.create({ alignContent: Alignment.Center}); 63480922886Sopenharmony_ci Stack.size({ width: '100%', height: '100%' }); 63580922886Sopenharmony_ci }, Stack); 63680922886Sopenharmony_ci this.observeComponentCreation2((y7, z7) => { 63780922886Sopenharmony_ci Column.create(); 63880922886Sopenharmony_ci Column.alignItems(HorizontalAlign.Center); 63980922886Sopenharmony_ci Column.justifyContent(FlexAlign.Center); 64080922886Sopenharmony_ci Column.size({ width: '100%', height: '100%' }); 64180922886Sopenharmony_ci Column.zIndex(0); 64280922886Sopenharmony_ci }, Column); 64380922886Sopenharmony_ci this.customPicker.bind(this)(); 64480922886Sopenharmony_ci Column.pop(); 64580922886Sopenharmony_ci this.observeComponentCreation2((w7, x7) => { 64680922886Sopenharmony_ci Column.create(); 64780922886Sopenharmony_ci Column.alignItems(HorizontalAlign.Center); 64880922886Sopenharmony_ci Column.justifyContent(FlexAlign.Center); 64980922886Sopenharmony_ci Column.size({ width: '100%', height: '100%' }); 65080922886Sopenharmony_ci Column.zIndex(1); 65180922886Sopenharmony_ci }, Column); 65280922886Sopenharmony_ci this.buildDefaultPicker.bind(this)(true); 65380922886Sopenharmony_ci Column.pop(); 65480922886Sopenharmony_ci Stack.pop(); 65580922886Sopenharmony_ci } 65680922886Sopenharmony_ci 65780922886Sopenharmony_ci rerender() { 65880922886Sopenharmony_ci this.updateDirtyElements(); 65980922886Sopenharmony_ci } 66080922886Sopenharmony_ci 66180922886Sopenharmony_ci static getEntryName() { 66280922886Sopenharmony_ci return 'AVCastPicker'; 66380922886Sopenharmony_ci } 66480922886Sopenharmony_ci} 66580922886Sopenharmony_ci 66680922886Sopenharmony_ciexport default AVCastPicker;