1/* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16if (!('finalizeConstruction' in ViewPU.prototype)) { 17 Reflect.set(ViewPU.prototype, 'finalizeConstruction', () => { }); 18} 19 20const TAG = 'avcastpicker_component '; 21const castPlusAudioType = 8; 22const t = 20; 23 24export let AVCastPickerState; 25(function(l11) { 26 l11[l11.STATE_APPEARING = 0] = 'STATE_APPEARING'; 27 l11[l11.STATE_DISAPPEARING = 1] = 'STATE_DISAPPEARING'; 28})(AVCastPickerState || (AVCastPickerState = {})); 29 30export let AVCastPickerStyle; 31(function(k11) { 32 k11[k11.STYLE_PANEL = 0] = 'STYLE_PANEL'; 33 k11[k11.STYLE_MENU = 1] = 'STYLE_MENU'; 34})(AVCastPickerStyle || (AVCastPickerStyle = {})); 35 36export let DeviceSource; 37(function(j11) { 38 j11[j11.LOCAL = 0] = 'LOCAL'; 39 j11[j11.CAST = 1] = 'CAST'; 40})(DeviceSource || (DeviceSource = {})); 41 42export let ConfigurationColorMode; 43(function(u11) { 44 u11[u11.COLOR_MODE_NOT_SET = -1] = 'COLOR_MODE_NOT_SET'; 45 u11[u11.COLOR_MODE_DARK = 0] = 'COLOR_MODE_DARK'; 46 u11[u11.COLOR_MODE_LIGHT = 1] = 'COLOR_MODE_LIGHT'; 47})(ConfigurationColorMode || (ConfigurationColorMode = {})); 48 49export let AVCastPickerColorMode; 50(function(v11) { 51 v11[v11.AUTO = 0] = 'AUTO'; 52 v11[v11.DARK = 1] = 'DARK'; 53 v11[v11.LIGHT = 2] = 'LIGHT'; 54})(AVCastPickerColorMode || (AVCastPickerColorMode = {})); 55 56export class AVCastPicker extends ViewPU { 57 constructor(d11, e11, f11, g11 = -1, h11 = undefined, i11) { 58 super(d11, f11, g11, i11); 59 if (typeof h11 === 'function') { 60 this.paramsGenerator_ = h11; 61 } 62 this.__normalColor = new ObservedPropertySimplePU(undefined, this, 'normalColor'); 63 this.__activeColor = new ObservedPropertySimplePU(undefined, this, 'activeColor'); 64 this.__colorMode = new ObservedPropertySimplePU(AVCastPickerColorMode.AUTO, this, 'colorMode'); 65 this.__deviceList = new ObservedPropertyObjectPU([], this, 'deviceList'); 66 this.__fontSizeScale = new ObservedPropertyObjectPU(1, this, 'fontSizeScale'); 67 this.__sessionType = new ObservedPropertySimplePU('audio', this, 'sessionType'); 68 this.__pickerStyle = new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyle'); 69 this.__pickerStyleFromMediaController = 70 new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyleFromMediaController'); 71 this.__isMenuShow = new ObservedPropertySimplePU(false, this, 'isMenuShow'); 72 this.__touchMenuItemIndex = new ObservedPropertySimplePU(-1, this, 'touchMenuItemIndex'); 73 this.onStateChange = undefined; 74 this.extensionProxy = null; 75 this.pickerClickTime = -1; 76 this.customPicker = undefined; 77 this.__configurationColorMode = 78 new ObservedPropertySimplePU(ConfigurationColorMode.COLOR_MODE_NOT_SET, this, 'configurationColorMode'); 79 this.__deviceInfoType = new ObservedPropertySimplePU('', this, 'deviceInfoType'); 80 this.__maxFontSizeScale = new ObservedPropertySimplePU(1, this, 'maxFontSizeScale'); 81 this.__accessibilityConnectedStr = new ObservedPropertySimplePU('已连接', this, 'accessibilityConnectedStr'); 82 this.__accessibilityAudioControlStr = new ObservedPropertySimplePU('音视频投播', this, 'accessibilityAudioControlStr'); 83 this.__isPc = new ObservedPropertySimplePU(false, this, 'isPc'); 84 this.__isRTL = new ObservedPropertySimplePU(false, this, 'isRTL'); 85 this.__restartUECMessage = new ObservedPropertySimplePU(1, this, 'restartUECMessage'); 86 this.needToRestart = false; 87 this.__isShowLoadingProgress = new ObservedPropertySimplePU(false, this, 'isShowLoadingProgress'); 88 this.pickerCountOnCreation = 0; 89 this.__isDisabledByPickerLimit = new ObservedPropertySimplePU(false, this, 'isDisabledByPickerLimit'); 90 this.setInitiallyProvidedValue(e11); 91 this.declareWatch('isMenuShow', this.MenuStateChange); 92 this.finalizeConstruction(); 93 } 94 95 setInitiallyProvidedValue(c11) { 96 if (c11.normalColor !== undefined) { 97 this.normalColor = c11.normalColor; 98 } 99 if (c11.activeColor !== undefined) { 100 this.activeColor = c11.activeColor; 101 } 102 if (c11.colorMode !== undefined) { 103 this.colorMode = c11.colorMode; 104 } 105 if (c11.deviceList !== undefined) { 106 this.deviceList = c11.deviceList; 107 } 108 if (c11.fontSizeScale !== undefined) { 109 this.fontSizeScale = c11.fontSizeScale; 110 } 111 if (c11.sessionType !== undefined) { 112 this.sessionType = c11.sessionType; 113 } 114 if (c11.pickerStyle !== undefined) { 115 this.pickerStyle = c11.pickerStyle; 116 } 117 if (c11.pickerStyleFromMediaController !== undefined) { 118 this.pickerStyleFromMediaController = c11.pickerStyleFromMediaController; 119 } 120 if (c11.isMenuShow !== undefined) { 121 this.isMenuShow = c11.isMenuShow; 122 } 123 if (c11.touchMenuItemIndex !== undefined) { 124 this.touchMenuItemIndex = c11.touchMenuItemIndex; 125 } 126 if (c11.onStateChange !== undefined) { 127 this.onStateChange = c11.onStateChange; 128 } 129 if (c11.extensionProxy !== undefined) { 130 this.extensionProxy = c11.extensionProxy; 131 } 132 if (c11.pickerClickTime !== undefined) { 133 this.pickerClickTime = c11.pickerClickTime; 134 } 135 if (c11.customPicker !== undefined) { 136 this.customPicker = c11.customPicker; 137 } 138 if (c11.configurationColorMode !== undefined) { 139 this.configurationColorMode = c11.configurationColorMode; 140 } 141 if (c11.deviceInfoType !== undefined) { 142 this.deviceInfoType = c11.deviceInfoType; 143 } 144 if (c11.maxFontSizeScale !== undefined) { 145 this.maxFontSizeScale = c11.maxFontSizeScale; 146 } 147 if (c11.accessibilityConnectedStr !== undefined) { 148 this.accessibilityConnectedStr = c11.accessibilityConnectedStr; 149 } 150 if (c11.accessibilityAudioControlStr !== undefined) { 151 this.accessibilityAudioControlStr = c11.accessibilityAudioControlStr; 152 } 153 if (c11.isPc !== undefined) { 154 this.isPc = c11.isPc; 155 } 156 if (c11.isRTL !== undefined) { 157 this.isRTL = c11.isRTL; 158 } 159 if (c11.restartUECMessage !== undefined) { 160 this.restartUECMessage = c11.restartUECMessage; 161 } 162 if (c11.needToRestart !== undefined) { 163 this.needToRestart = c11.needToRestart; 164 } 165 if (c11.isShowLoadingProgress !== undefined) { 166 this.isShowLoadingProgress = c11.isShowLoadingProgress; 167 } 168 if (c11.pickerCountOnCreation !== undefined) { 169 this.pickerCountOnCreation = c11.pickerCountOnCreation; 170 } 171 if (c11.isDisabledByPickerLimit !== undefined) { 172 this.isDisabledByPickerLimit = c11.isDisabledByPickerLimit; 173 } 174 } 175 176 updateStateVars(b11) { 177 } 178 179 purgeVariableDependenciesOnElmtId(a11) { 180 this.__normalColor.purgeDependencyOnElmtId(a11); 181 this.__activeColor.purgeDependencyOnElmtId(a11); 182 this.__colorMode.purgeDependencyOnElmtId(a11); 183 this.__deviceList.purgeDependencyOnElmtId(a11); 184 this.__fontSizeScale.purgeDependencyOnElmtId(a11); 185 this.__sessionType.purgeDependencyOnElmtId(a11); 186 this.__pickerStyle.purgeDependencyOnElmtId(a11); 187 this.__pickerStyleFromMediaController.purgeDependencyOnElmtId(a11); 188 this.__isMenuShow.purgeDependencyOnElmtId(a11); 189 this.__touchMenuItemIndex.purgeDependencyOnElmtId(a11); 190 this.__configurationColorMode.purgeDependencyOnElmtId(a11); 191 this.__deviceInfoType.purgeDependencyOnElmtId(a11); 192 this.__maxFontSizeScale.purgeDependencyOnElmtId(a11); 193 this.__accessibilityConnectedStr.purgeDependencyOnElmtId(a11); 194 this.__accessibilityAudioControlStr.purgeDependencyOnElmtId(a11); 195 this.__isPc.purgeDependencyOnElmtId(a11); 196 this.__isRTL.purgeDependencyOnElmtId(a11); 197 this.__restartUECMessage.purgeDependencyOnElmtId(a11); 198 this.__isShowLoadingProgress.purgeDependencyOnElmtId(a11); 199 this.__isDisabledByPickerLimit.purgeDependencyOnElmtId(a11); 200 } 201 202 aboutToBeDeleted() { 203 this.__normalColor.aboutToBeDeleted(); 204 this.__activeColor.aboutToBeDeleted(); 205 this.__colorMode.aboutToBeDeleted(); 206 this.__deviceList.aboutToBeDeleted(); 207 this.__fontSizeScale.aboutToBeDeleted(); 208 this.__sessionType.aboutToBeDeleted(); 209 this.__pickerStyle.aboutToBeDeleted(); 210 this.__pickerStyleFromMediaController.aboutToBeDeleted(); 211 this.__isMenuShow.aboutToBeDeleted(); 212 this.__touchMenuItemIndex.aboutToBeDeleted(); 213 this.__configurationColorMode.aboutToBeDeleted(); 214 this.__deviceInfoType.aboutToBeDeleted(); 215 this.__maxFontSizeScale.aboutToBeDeleted(); 216 this.__accessibilityConnectedStr.aboutToBeDeleted(); 217 this.__accessibilityAudioControlStr.aboutToBeDeleted(); 218 this.__isPc.aboutToBeDeleted(); 219 this.__isRTL.aboutToBeDeleted(); 220 this.__restartUECMessage.aboutToBeDeleted(); 221 this.__isShowLoadingProgress.aboutToBeDeleted(); 222 this.__isDisabledByPickerLimit.aboutToBeDeleted(); 223 SubscriberManager.Get().delete(this.id__()); 224 this.aboutToBeDeletedInternal(); 225 } 226 227 get normalColor() { 228 return this.__normalColor.get(); 229 } 230 231 set normalColor(z10) { 232 this.__normalColor.set(z10); 233 } 234 235 get activeColor() { 236 return this.__activeColor.get(); 237 } 238 239 set activeColor(y10) { 240 this.__activeColor.set(y10); 241 } 242 243 get colorMode() { 244 return this.__colorMode.get(); 245 } 246 247 set colorMode(b1) { 248 this.__colorMode.set(b1); 249 } 250 251 get deviceList() { 252 return this.__deviceList.get(); 253 } 254 255 set deviceList(x10) { 256 this.__deviceList.set(x10); 257 } 258 259 get fontSizeScale() { 260 return this.__fontSizeScale.get(); 261 } 262 263 set fontSizeScale(x10) { 264 this.__fontSizeScale.set(x10); 265 } 266 267 get sessionType() { 268 return this.__sessionType.get(); 269 } 270 271 set sessionType(w10) { 272 this.__sessionType.set(w10); 273 } 274 275 get pickerStyle() { 276 return this.__pickerStyle.get(); 277 } 278 279 set pickerStyle(v10) { 280 this.__pickerStyle.set(v10); 281 } 282 283 get pickerStyleFromMediaController() { 284 return this.__pickerStyleFromMediaController.get(); 285 } 286 287 set pickerStyleFromMediaController(b1) { 288 this.__pickerStyleFromMediaController.set(b1); 289 } 290 291 get isMenuShow() { 292 return this.__isMenuShow.get(); 293 } 294 295 set isMenuShow(u10) { 296 this.__isMenuShow.set(u10); 297 } 298 299 get touchMenuItemIndex() { 300 return this.__touchMenuItemIndex.get(); 301 } 302 303 set touchMenuItemIndex(t10) { 304 this.__touchMenuItemIndex.set(t10); 305 } 306 307 get configurationColorMode() { 308 return this.__configurationColorMode.get(); 309 } 310 311 set configurationColorMode(a1) { 312 this.__configurationColorMode.set(a1); 313 } 314 315 get deviceInfoType() { 316 return this.__deviceInfoType.get(); 317 } 318 319 set deviceInfoType(b1) { 320 this.__deviceInfoType.set(b1); 321 } 322 323 get maxFontSizeScale() { 324 return this.__maxFontSizeScale.get(); 325 } 326 327 set maxFontSizeScale(e1) { 328 this.__maxFontSizeScale.set(e1); 329 } 330 331 get accessibilityConnectedStr() { 332 return this.__accessibilityConnectedStr.get(); 333 } 334 335 set accessibilityConnectedStr(c1) { 336 this.__accessibilityConnectedStr.set(c1); 337 } 338 339 get accessibilityAudioControlStr() { 340 return this.__accessibilityAudioControlStr.get(); 341 } 342 343 set accessibilityAudioControlStr(d1) { 344 this.__accessibilityAudioControlStr.set(d1); 345 } 346 347 get isPc() { 348 return this.__isPc.get(); 349 } 350 351 set isPc(e1) { 352 this.__isPc.set(e1); 353 } 354 355 get isRTL() { 356 return this.__isRTL.get(); 357 } 358 359 set isRTL(f1) { 360 this.__isRTL.set(f1); 361 } 362 363 get restartUECMessage() { 364 return this.__restartUECMessage.get(); 365 } 366 367 set restartUECMessage(f1) { 368 this.__restartUECMessage.set(f1); 369 } 370 371 get isShowLoadingProgress() { 372 return this.__isShowLoadingProgress.get(); 373 } 374 375 set isShowLoadingProgress(g1) { 376 this.__isShowLoadingProgress.set(g1); 377 } 378 379 get isDisabledByPickerLimit() { 380 return this.__isDisabledByPickerLimit.get(); 381 } 382 383 set isDisabledByPickerLimit(g1) { 384 this.__isDisabledByPickerLimit.set(g1); 385 } 386 387 aboutToAppear() { 388 AVCastPicker.currentPickerCount += 1; 389 this.pickerCountOnCreation = AVCastPicker.currentPickerCount; 390 if (this.pickerCountOnCreation > t) { 391 console.info(TAG, 'disable picker'); 392 this.isDisabledByPickerLimit = true; 393 } 394 } 395 396 aboutToDisappear() { 397 AVCastPicker.currentPickerCount -= 1; 398 } 399 400 MenuStateChange() { 401 if (this.extensionProxy != null) { 402 this.extensionProxy.send({ 'isMenuShow': this.isMenuShow }); 403 } 404 } 405 406 showHighQuality(item) { 407 if (item.supportedProtocols === undefined) { 408 return false; 409 } 410 return (item.supportedProtocols & castPlusAudioType) !== 0; 411 } 412 413 initialRender() { 414 this.observeComponentCreation2((r10, s10) => { 415 Column.create(); 416 Column.size({ width: '100%', height: '100%'}); 417 }, Column); 418 this.observeComponentCreation2((n10, o10) => { 419 If.create(); 420 if (this.isDisabledByPickerLimit) { 421 this.ifElseBranchUpdateFunction(0, () => { 422 this.buildDisabledPicker.bind(this)(); 423 }); 424 } else if (this.customPicker === undefined) { 425 this.ifElseBranchUpdateFunction(0, () => { 426 this.buildDefaultPicker.bind(this)(false); 427 }); 428 } else { 429 this.ifElseBranchUpdateFunction(1, () => { 430 this.buildCustomPicker.bind(this)(); 431 }); 432 } 433 }, If); 434 If.pop(); 435 Column.pop(); 436 } 437 438 iconBuilder(b3, c3, d3 = null) { 439 this.observeComponentCreation2((f3, g3) => { 440 If.create(); 441 if (this.deviceInfoType === 'true') { 442 this.ifElseBranchUpdateFunction(0, () => { 443 this.observeComponentCreation2((n3, o3) => { 444 SymbolGlyph.create(!c3 ? { 'id': -1, 'type': -1, params: [b3.deviceIconName], 445 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 446 { 'id': -1, 'type': -1, params: [b3.selectedIconName], 447 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 448 SymbolGlyph.fontSize('24vp'); 449 SymbolGlyph.fontColor((c3 && this.configurationColorMode !== 450 ConfigurationColorMode.COLOR_MODE_DARK) ? 451 [{ 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 452 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }] : 453 [{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 454 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]); 455 SymbolGlyph.renderingStrategy(2); 456 }, SymbolGlyph); 457 }); 458 } else { 459 this.ifElseBranchUpdateFunction(1, () => { 460 this.observeComponentCreation2((j3, k3) => { 461 Image.create(!c3 ? { 'id': -1, 'type': -1, 462 params: [b3.deviceIconName], 'bundleName': '__harDefaultBundleName__', 463 'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': -1, params: [b3.selectedIconName], 464 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 465 Image.width(24); 466 Image.height(24); 467 Image.fillColor((c3 && this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK) ? 468 { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 469 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 470 { 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 471 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 472 }, Image); 473 }); 474 } 475 }, If); 476 If.pop(); 477 } 478 479 textBuilder(u1, v1 = null) { 480 this.observeComponentCreation2((x1, y1) => { 481 Text.create(u1.deviceName); 482 Text.fontSize({ 'id': -1, 'type': 10002, 483 params: ['sys.float.ohos_id_text_size_body2'], 'bundleName': '__harDefaultBundleName__', 484 'moduleName': '__harDefaultModuleName__' }); 485 Text.fontColor(u1.isConnected ? 486 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 487 { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 488 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 489 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 490 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }) : 491 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 492 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 493 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 494 { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 495 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 496 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 497 Text.maxLines(2); 498 Text.wordBreak(WordBreak.BREAK_WORD); 499 Text.maxFontScale(this.maxFontSizeScale); 500 Text.direction(this.isRTL ? Direction.Rtl : Direction.Ltr); 501 }, Text); 502 Text.pop(); 503 } 504 505 subTextBuilder(u3, v1 = null) { 506 this.observeComponentCreation2((x1, y1) => { 507 Row.create(); 508 Row.width('100%'); 509 }, Row); 510 this.observeComponentCreation2((x1, y1) => { 511 Text.create(`${u3.deviceSubName}...`); 512 Text.fontSize({ 'id': -1, 'type': 10002, 513 params: ['sys.float.ohos_id_text_size_body2'], 'bundleName': '__harDefaultBundleName__', 514 'moduleName': '__harDefaultModuleName__' }); 515 Text.fontColor(u3.isConnected ? 516 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 517 { 'id': -1, 'type': 10001, params: ['sys.color.font_emphasize'], 518 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 519 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 520 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }) : 521 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 522 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 523 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 524 { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 525 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 526 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 527 Text.maxLines(1); 528 Text.maxFontScale(this.maxFontSizeScale); 529 Text.direction(this.isRTL ? Direction.Rtl : Direction.Ltr); 530 }, Text); 531 Text.pop(); 532 Row.pop(); 533 } 534 535 highQualityIconBuilder(u2, v1 = null) { 536 Row.create(); 537 Row.direction(Direction.Ltr); 538 this.observeComponentCreation2((x1, y1) => { 539 Text.create(u2 ? u2.iconLeft : ''); 540 Text.fontSize(7); 541 Text.fontWeight(FontWeight.Medium); 542 Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 543 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 544 Text.maxFontScale(this.maxFontSizeScale); 545 }, Text); 546 Text.pop(); 547 this.observeComponentCreation2((x1, y1) => { 548 Text.create(u2 ? u2.iconRight : ''); 549 Text.fontSize(7); 550 Text.fontWeight(FontWeight.Medium); 551 Text.fontColor({ 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 552 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 553 Text.maxFontScale(this.maxFontSizeScale); 554 Text.margin({left: 2 * (Math.min(this.maxFontSizeScale, this.fontSizeScale))}); 555 }, Text); 556 Text.pop(); 557 Row.pop(); 558 } 559 560 deviceMenu(o8 = null) { 561 this.observeComponentCreation2((j10, k10) => { 562 Column.create(); 563 Column.width(this.isPc ? 326 : 216); 564 Column.borderRadius(this.isPc ? 8 : 20); 565 }, Column); 566 this.observeComponentCreation2((r8, s8) => { 567 ForEach.create(); 568 const t8 = (v8, w8) => { 569 const x8 = v8; 570 this.observeComponentCreation2((g10, h10) => { 571 Flex.create({ 572 direction: FlexDirection.Column, 573 justifyContent: FlexAlign.SpaceBetween, 574 alignItems: ItemAlign.End 575 }); 576 Flex.width('100%'); 577 Flex.onClick(() => { 578 if (this.extensionProxy != null && !x8.isConnected) { 579 this.extensionProxy.send({ 'selectedDeviceInfo': x8 }); 580 } 581 }); 582 }, Flex); 583 this.observeComponentCreation2((c10, d10) => { 584 Flex.create({ 585 direction: FlexDirection.Row, 586 justifyContent: FlexAlign.SpaceBetween, 587 alignItems: ItemAlign.Center 588 }); 589 Flex.constraintSize({ minHeight: this.isPc ? 40 : 48 }); 590 Flex.padding({ left: 12, right: 12 }); 591 Flex.onTouch((f10) => { 592 if (f10.type === TouchType.Down) { 593 this.touchMenuItemIndex = w8; 594 } 595 else if (f10.type === TouchType.Up) { 596 this.touchMenuItemIndex = -1; 597 } 598 }); 599 Flex.backgroundColor(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10001, 600 params: ['sys.color.interactive_click'], 'bundleName': '__harDefaultBundleName__', 601 'moduleName': '__harDefaultModuleName__' } : '#00FFFFFF'); 602 Flex.borderRadius(this.touchMenuItemIndex === w8 ? (this.isPc ? { 'id': -1, 'type': 10002, 603 params: ['sys.float.corner_radius_level2'], 'bundleName': '__harDefaultBundleName__', 604 'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': 10002, 605 params: ['sys.float.corner_radius_level8'], 'bundleName': '__harDefaultBundleName__', 606 'moduleName': '__harDefaultModuleName__' }) : 0); 607 }, Flex); 608 this.observeComponentCreation2((a10, b10) => { 609 Row.create(); 610 Row.alignItems(VerticalAlign.Center); 611 }, Row); 612 this.iconBuilder.bind(this)(x8, false); 613 614 this.observeComponentCreation2((a10, b10) => { 615 Column.create(); 616 Column.width(this.isPc ? 254 : 144); 617 Column.padding({ 618 left: 8, 619 top: this.isPc ? 11 : (this.showHighQuality(x8) ? 7 : 17), 620 right: 8, 621 bottom: this.isPc ? 11 : (this.showHighQuality(x8) ? 7 : 17), 622 }); 623 }, Column); 624 this.observeComponentCreation2((m9, n9) => { 625 Flex.create({ direction: FlexDirection.Row, justifyContent: FlexAlign.Start }); 626 Flex.width('100%'); 627 }, Flex); 628 this.textBuilder.bind(this)(x8); 629 this.observeComponentCreation2((m9, n9) => { 630 If.create(); 631 if (x8.highQualityParams !== undefined && this.showHighQuality(x8)) { 632 this.ifElseBranchUpdateFunction(0, () => { 633 this.observeComponentCreation2((u9, v9) => { 634 Flex.create(); 635 Flex.borderRadius(3); 636 Flex.border({ 637 width: 0.5 * (Math.min(this.maxFontSizeScale, this.fontSizeScale)), 638 color: { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 639 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } 640 }); 641 Flex.padding({top: 1.5, right: 4, bottom: 1.5, left: 4}); 642 Flex.margin({top: 2}); 643 Flex.width('auto'); 644 }, Flex); 645 this.highQualityIconBuilder.bind(this)(x8.highQualityParams); 646 Flex.pop(); 647 }); 648 } else { 649 this.ifElseBranchUpdateFunction(1, () => { 650 }); 651 } 652 }, If); 653 If.pop(); 654 Flex.pop(); 655 656 this.observeComponentCreation2((m9, n9) => { 657 If.create(); 658 if (x8.fromCall) { 659 this.ifElseBranchUpdateFunction(0, () => { 660 this.subTextBuilder.bind(this)(x8); 661 }); 662 } 663 else { 664 this.ifElseBranchUpdateFunction(1, () => { 665 }); 666 } 667 }, If); 668 If.pop(); 669 Column.pop(); 670 671 Row.pop(); 672 this.observeComponentCreation2((m9, n9) => { 673 If.create(); 674 if (x8.isConnected && x8.selectedIconName !== null && x8.selectedIconName !== undefined) { 675 this.ifElseBranchUpdateFunction(0, () => { 676 this.observeComponentCreation2((u9, v9) => { 677 Row.create(); 678 Row.alignItems(VerticalAlign.Center); 679 Row.accessibilityLevel('yes'); 680 Row.accessibilityText(this.accessibilityConnectedStr); 681 }, Row); 682 this.iconBuilder.bind(this)(x8, true); 683 Row.pop(); 684 }); 685 } else { 686 this.ifElseBranchUpdateFunction(1, () => { 687 }); 688 } 689 }, If); 690 If.pop(); 691 Flex.pop(); 692 this.observeComponentCreation2((f9, g9) => { 693 If.create(); 694 if (!this.isPc && (w8 !== this.deviceList.length - 1)) { 695 this.ifElseBranchUpdateFunction(0, () => { 696 this.observeComponentCreation2((k9, l9) => { 697 Divider.create(); 698 Divider.height(1); 699 Divider.color({ 'id': -1, 'type': 10001, params: ['sys.color.comp_divider'], 700 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 701 Divider.padding({ right: (this.isRTL ? 44 : 12), left: (this.isRTL ? 12 : 44) }); 702 }, Divider); 703 }); 704 } else if (this.isPc && (w8 !== this.deviceList.length - 1)) { 705 this.ifElseBranchUpdateFunction(1, () => { 706 this.observeComponentCreation2((c2, d2) => { 707 Row.create(); 708 Row.width('100%'); 709 Row.height(2); 710 }, Row); 711 Row.pop(); 712 }); 713 } else { 714 this.ifElseBranchUpdateFunction(2, () => { 715 }); 716 } 717 }, If); 718 If.pop(); 719 Flex.pop(); 720 }; 721 this.forEachUpdateFunction(r8, this.deviceList, t8, undefined, true, false); 722 }, ForEach); 723 ForEach.pop(); 724 Column.pop(); 725 } 726 727 buildDisabledPicker(parent = null) { 728 this.observeComponentCreation2((elmtId, isInitialRender) => { 729 Column.create(); 730 }, Column); 731 Column.pop(); 732 } 733 buildDefaultPicker(c8, d8 = null) { 734 this.observeComponentCreation2((f8, g8) => { 735 Button.createWithChild(); 736 Button.size({ width: '100%', height: '100%' }); 737 Button.hoverEffect(HoverEffect.None); 738 Button.stateEffect(false); 739 Button.backgroundColor('#00000000'); 740 Button.accessibilityLevel('yes'); 741 Button.accessibilityText(this.accessibilityAudioControlStr); 742 Button.onClick(() => { 743 if (this.needToRestart) { 744 this.needToRestart = false; 745 this.restartUECMessage += 1; 746 return; 747 } 748 let u = this.deviceList.length === 2 && 749 !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 750 let v = this.deviceList === null || this.deviceList.length === 0; 751 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 752 let x = w && (v || u); 753 let y = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 754 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 755 if (x || y) { 756 this.isMenuShow = false; 757 this.touchMenuItemIndex = -1; 758 if (this.extensionProxy != null) { 759 this.extensionProxy.send({'clickEvent': true}); 760 } 761 } else { 762 this.isMenuShow = !this.isMenuShow; 763 if (this.isMenuShow) { 764 this.pickerClickTime = new Date().getTime(); 765 } else { 766 this.touchMenuItemIndex = -1; 767 } 768 } 769 }); 770 }, Button); 771 this.observeComponentCreation2((f8, g8) => { 772 Column.create(); 773 Column.accessibilityLevel('no-hide-descendants'); 774 Column.size({ width: '100%', height: '100%' }); 775 }, Column); 776 this.observeComponentCreation2((f8, g8) => { 777 UIExtensionComponent.create({ 778 abilityName: 'UIExtAbility', 779 bundleName: 'com.hmos.mediacontroller', 780 parameters: { 781 'normalColor': this.normalColor, 782 'activeColor': this.activeColor, 783 'pickerColorMode': this.colorMode, 784 'avCastPickerStyle': this.pickerStyle, 785 'ability.want.params.uiExtensionType': 'sysPicker/mediaControl', 786 'isCustomPicker': c8, 787 'message': this.restartUECMessage, 788 'currentPickerCount': this.pickerCountOnCreation, 789 } 790 }); 791 UIExtensionComponent.onRemoteReady((n8) => { 792 console.info(TAG, 'onRemoteReady'); 793 this.extensionProxy = n8; 794 }); 795 UIExtensionComponent.onReceive((l8) => { 796 if (l8.deviceInfoType !== undefined) { 797 console.info(TAG, `deviceInfoType : ${JSON.stringify(l8.deviceInfoType)}`); 798 this.deviceInfoType = l8.deviceInfoType; 799 } 800 801 if (l8.pickerStyle !== undefined) { 802 console.info(TAG, `picker style : ${JSON.stringify(l8.pickerStyle)}`); 803 this.pickerStyleFromMediaController = l8.pickerStyle; 804 } 805 806 if (l8.deviceList !== undefined) { 807 console.info(TAG, `picker device list : ${JSON.stringify(l8.deviceList)}`); 808 this.deviceList = JSON.parse(JSON.stringify(l8.deviceList)); 809 let u = this.deviceList.length === 2 && !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 810 let v = this.deviceList === null || this.deviceList.length === 0; 811 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 812 let x = w && (v || u); 813 let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 814 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 815 if (x || b21) { 816 this.isMenuShow = false; 817 this.touchMenuItemIndex = -1; 818 } 819 } 820 821 if (l8.fontSizeScale !== undefined) { 822 console.info(TAG, `font size scale : ${JSON.stringify(l8.fontSizeScale)}`); 823 this.fontSizeScale = l8.fontSizeScale; 824 } 825 826 if (l8.state !== undefined) { 827 console.info(TAG, `picker state change : ${JSON.stringify(l8.state)}`); 828 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 829 let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 830 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 831 if (this.onStateChange != null && b21) { 832 if (parseInt(JSON.stringify(l8.state)) === AVCastPickerState.STATE_APPEARING) { 833 this.onStateChange(AVCastPickerState.STATE_APPEARING); 834 } 835 else { 836 this.onStateChange(AVCastPickerState.STATE_DISAPPEARING); 837 } 838 } 839 } 840 841 if (l8.sessionType !== undefined) { 842 console.info(TAG, `session type : ${JSON.stringify(l8.sessionType)}`); 843 this.sessionType = l8.sessionType; 844 } 845 846 if (l8.isShowMenu !== undefined) { 847 console.info(TAG, `isShowMenu : ${l8.isShowMenu}`); 848 this.isMenuShow = l8.isShowMenu; 849 if (!this.isMenuShow) { 850 this.touchMenuItemIndex = -1; 851 } 852 } 853 854 if (l8.configurationColorMode !== undefined) { 855 console.info(TAG, `configurationColorMode : ${l8.configurationColorMode}`); 856 this.configurationColorMode = l8.configurationColorMode; 857 } 858 859 if (l8.accessConnected !== undefined) { 860 console.info(TAG, `accessibilityConnectedStr : ${l8.accessConnected}`); 861 this.accessibilityConnectedStr = l8.accessConnected; 862 } 863 864 if (l8.accessAudioControl !== undefined) { 865 console.info(TAG, `accessibilityAudioControlStr : ${l8.accessAudioControl}`); 866 this.accessibilityAudioControlStr = l8.accessAudioControl; 867 } 868 869 if (l8.isPc !== undefined) { 870 console.info(TAG, `isPc : ${l8.isPc}`); 871 this.isPc = l8.isPc; 872 } 873 874 if (l8.isRTL !== undefined) { 875 console.info(TAG, `isRTL : ${l8.isRTL}`); 876 this.isRTL = l8.isRTL; 877 } 878 879 if (l8.maxFontSizeScale !== undefined) { 880 console.info(TAG, `maxFontSizeScale : ${l8.maxFontSizeScale}`); 881 this.maxFontSizeScale = l8.maxFontSizeScale; 882 } 883 884 if (l8.isShowLoadingProgress !== undefined) { 885 console.info(TAG, `isShowLoadingProgress : ${l8.isShowLoadingProgress}`); 886 this.isShowLoadingProgress = l8.isShowLoadingProgress; 887 } 888 }); 889 UIExtensionComponent.size({ width: '100%', height: '100%' }); 890 UIExtensionComponent.bindMenu(this.isMenuShow, { builder: () => { this.deviceMenu.call(this); }}, { 891 placement: Placement.BottomRight, 892 onDisappear: () => { 893 this.isMenuShow = false; 894 this.touchMenuItemIndex = -1; 895 this.menuShowStateCallback(this.isMenuShow); 896 }, 897 onAppear: () => { 898 if (this.extensionProxy != null && this.pickerClickTime !== -1) { 899 this.extensionProxy.send({ 'timeCost': new Date().getTime() - this.pickerClickTime }); 900 this.pickerClickTime = -1; 901 } 902 this.menuShowStateCallback(this.isMenuShow); 903 } 904 }); 905 UIExtensionComponent.onRelease((releaseCode) => { 906 console.error(TAG, `onRelease code ${releaseCode}`); 907 if (releaseCode === 1) { 908 this.needToRestart = true; 909 } 910 }); 911 UIExtensionComponent.onError(() => { 912 console.error(TAG, 'onError ready to restart'); 913 this.needToRestart = true; 914 }); 915 UIExtensionComponent.accessibilityLevel('yes'); 916 UIExtensionComponent.accessibilityText(this.__accessibilityAudioControlStr); 917 UIExtensionComponent.accessibilityUseSamePage(AccessibilitySamePageMode.FULL_SILENT); 918 }, UIExtensionComponent); 919 Column.pop(); 920 Button.pop(); 921 } 922 923 hasExtDevice(a) { 924 for (let b = 0; b < a.length; b++) { 925 let q1 = (a[b].deviceType === 1 || a[b].deviceType === 2) && a[b].networkId === 'LocalDevice'; 926 if (!q1) { 927 return true; 928 } 929 } 930 return false; 931 } 932 933 menuShowStateCallback(k) { 934 if (this.onStateChange != null && (this.pickerStyle === AVCastPickerStyle.STYLE_MENU || 935 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_MENU)) { 936 let l = k ? AVCastPickerState.STATE_APPEARING : AVCastPickerState.STATE_DISAPPEARING; 937 this.onStateChange(l); 938 } 939 } 940 941 buildCustomPicker(s7 = null) { 942 this.observeComponentCreation2((a8, b8) => { 943 Stack.create({ alignContent: Alignment.Center}); 944 Stack.size({ width: '100%', height: '100%' }); 945 }, Stack); 946 this.observeComponentCreation2((y7, z7) => { 947 Column.create(); 948 Column.alignItems(HorizontalAlign.Center); 949 Column.justifyContent(FlexAlign.Center); 950 Column.size({ width: '100%', height: '100%' }); 951 Column.zIndex(0); 952 }, Column); 953 this.observeComponentCreation2((c7, s7) => { 954 If.create(); 955 if (this.isShowLoadingProgress) { 956 this.ifElseBranchUpdateFunction(0, () => { 957 this.observeComponentCreation2((c7, s7) => { 958 LoadingProgress.create(); 959 LoadingProgress.color({'id': -1, 'type': 10001, params: ['sys.color.icon_secondary'], 960 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__'}); 961 LoadingProgress.width('20vp'); 962 LoadingProgress.height('20vp'); 963 }, LoadingProgress); 964 }); 965 } else { 966 this.ifElseBranchUpdateFunction(1, () => { 967 this.customPicker.bind(this)(); 968 }); 969 } 970 }, If); 971 If.pop(); 972 Column.pop(); 973 this.observeComponentCreation2((w7, x7) => { 974 Column.create(); 975 Column.alignItems(HorizontalAlign.Center); 976 Column.justifyContent(FlexAlign.Center); 977 Column.size({ width: '100%', height: '100%' }); 978 Column.zIndex(1); 979 }, Column); 980 this.buildDefaultPicker.bind(this)(true); 981 Column.pop(); 982 Stack.pop(); 983 } 984 985 rerender() { 986 this.updateDirtyElements(); 987 } 988 989 static getEntryName() { 990 return 'AVCastPicker'; 991 } 992} 993AVCastPicker.currentPickerCount = 0; 994export default AVCastPicker;