1/* 2 * Copyright (c) 2023-2024 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 '; 21 22export let AVCastPickerState; 23(function(l11) { 24 l11[l11.STATE_APPEARING = 0] = 'STATE_APPEARING'; 25 l11[l11.STATE_DISAPPEARING = 1] = 'STATE_DISAPPEARING'; 26})(AVCastPickerState || (AVCastPickerState = {})); 27 28export let AVCastPickerStyle; 29(function(k11) { 30 k11[k11.STYLE_PANEL = 0] = 'STYLE_PANEL'; 31 k11[k11.STYLE_MENU = 1] = 'STYLE_MENU'; 32})(AVCastPickerStyle || (AVCastPickerStyle = {})); 33 34export let DeviceSource; 35(function(j11) { 36 j11[j11.LOCAL = 0] = 'LOCAL'; 37 j11[j11.CAST = 1] = 'CAST'; 38})(DeviceSource || (DeviceSource = {})); 39 40export let ConfigurationColorMode; 41(function(u11) { 42 u11[u11.COLOR_MODE_NOT_SET = -1] = 'COLOR_MODE_NOT_SET'; 43 u11[u11.COLOR_MODE_DARK = 0] = 'COLOR_MODE_DARK'; 44 u11[u11.COLOR_MODE_LIGHT = 1] = 'COLOR_MODE_LIGHT'; 45})(ConfigurationColorMode || (ConfigurationColorMode = {})); 46 47export let AVCastPickerColorMode; 48(function(v11) { 49 v11[v11.AUTO = 0] = 'AUTO'; 50 v11[v11.DARK = 1] = 'DARK'; 51 v11[v11.LIGHT = 2] = 'LIGHT'; 52})(AVCastPickerColorMode || (AVCastPickerColorMode = {})); 53 54export class AVCastPicker extends ViewPU { 55 constructor(d11, e11, f11, g11 = -1, h11 = undefined, i11) { 56 super(d11, f11, g11, i11); 57 if (typeof h11 === 'function') { 58 this.paramsGenerator_ = h11; 59 } 60 this.__normalColor = new ObservedPropertySimplePU(undefined, this, 'normalColor'); 61 this.__activeColor = new ObservedPropertySimplePU(undefined, this, 'activeColor'); 62 this.__colorMode = new ObservedPropertySimplePU(AVCastPickerColorMode.AUTO, this, 'colorMode'); 63 this.__deviceList = new ObservedPropertyObjectPU([], this, 'deviceList'); 64 this.__sessionType = new ObservedPropertySimplePU('audio', this, 'sessionType'); 65 this.__pickerStyle = new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyle'); 66 this.__pickerStyleFromMediaController = 67 new ObservedPropertySimplePU(AVCastPickerStyle.STYLE_PANEL, this, 'pickerStyleFromMediaController'); 68 this.__isMenuShow = new ObservedPropertySimplePU(false, this, 'isMenuShow'); 69 this.__touchMenuItemIndex = new ObservedPropertySimplePU(-1, this, 'touchMenuItemIndex'); 70 this.onStateChange = undefined; 71 this.extensionProxy = null; 72 this.pickerClickTime = -1; 73 this.customPicker = undefined; 74 this.__configurationColorMode = 75 new ObservedPropertySimplePU(ConfigurationColorMode.COLOR_MODE_NOT_SET, this, 'configurationColorMode'); 76 this.__deviceInfoType = new ObservedPropertySimplePU('', this, 'deviceInfoType'); 77 this.maxFontSizeScale = 2; 78 this.__accessibilityConnectedStr = new ObservedPropertySimplePU('已连接', this, 'accessibilityConnectedStr'); 79 this.__accessibilityAudioControlStr = new ObservedPropertySimplePU('音视频投播', this, 'accessibilityAudioControlStr'); 80 this.__restartUECMessage = new ObservedPropertySimplePU(1, this, 'restartUECMessage'); 81 this.setInitiallyProvidedValue(e11); 82 this.declareWatch('isMenuShow', this.MenuStateChange); 83 this.finalizeConstruction(); 84 } 85 86 setInitiallyProvidedValue(c11) { 87 if (c11.normalColor !== undefined) { 88 this.normalColor = c11.normalColor; 89 } 90 if (c11.activeColor !== undefined) { 91 this.activeColor = c11.activeColor; 92 } 93 if (c11.colorMode !== undefined) { 94 this.colorMode = c11.colorMode; 95 } 96 if (c11.deviceList !== undefined) { 97 this.deviceList = c11.deviceList; 98 } 99 if (c11.sessionType !== undefined) { 100 this.sessionType = c11.sessionType; 101 } 102 if (c11.pickerStyle !== undefined) { 103 this.pickerStyle = c11.pickerStyle; 104 } 105 if (c11.pickerStyleFromMediaController !== undefined) { 106 this.pickerStyleFromMediaController = c11.pickerStyleFromMediaController; 107 } 108 if (c11.isMenuShow !== undefined) { 109 this.isMenuShow = c11.isMenuShow; 110 } 111 if (c11.touchMenuItemIndex !== undefined) { 112 this.touchMenuItemIndex = c11.touchMenuItemIndex; 113 } 114 if (c11.onStateChange !== undefined) { 115 this.onStateChange = c11.onStateChange; 116 } 117 if (c11.extensionProxy !== undefined) { 118 this.extensionProxy = c11.extensionProxy; 119 } 120 if (c11.pickerClickTime !== undefined) { 121 this.pickerClickTime = c11.pickerClickTime; 122 } 123 if (c11.customPicker !== undefined) { 124 this.customPicker = c11.customPicker; 125 } 126 if (c11.configurationColorMode !== undefined) { 127 this.configurationColorMode = c11.configurationColorMode; 128 } 129 if (c11.deviceInfoType !== undefined) { 130 this.deviceInfoType = c11.deviceInfoType; 131 } 132 if (c11.maxFontSizeScale !== undefined) { 133 this.maxFontSizeScale = c11.maxFontSizeScale; 134 } 135 if (c11.accessibilityConnectedStr !== undefined) { 136 this.accessibilityConnectedStr = c11.accessibilityConnectedStr; 137 } 138 if (c11.__accessibilityAudioControlStr !== undefined) { 139 this.accessibilityAudioControlStr = c11.accessibilityAudioControlStr; 140 } 141 if (c11.restartUECMessage !== undefined) { 142 this.restartUECMessage = c11.restartUECMessage; 143 } 144 } 145 146 updateStateVars(b11) { 147 } 148 149 purgeVariableDependenciesOnElmtId(a11) { 150 this.__normalColor.purgeDependencyOnElmtId(a11); 151 this.__activeColor.purgeDependencyOnElmtId(a11); 152 this.__colorMode.purgeDependencyOnElmtId(a11); 153 this.__deviceList.purgeDependencyOnElmtId(a11); 154 this.__sessionType.purgeDependencyOnElmtId(a11); 155 this.__pickerStyle.purgeDependencyOnElmtId(a11); 156 this.__pickerStyleFromMediaController.purgeDependencyOnElmtId(a11); 157 this.__isMenuShow.purgeDependencyOnElmtId(a11); 158 this.__touchMenuItemIndex.purgeDependencyOnElmtId(a11); 159 this.__configurationColorMode.purgeDependencyOnElmtId(a11); 160 this.__deviceInfoType.purgeDependencyOnElmtId(a11); 161 this.__accessibilityConnectedStr.purgeDependencyOnElmtId(a11); 162 this.__accessibilityAudioControlStr.purgeDependencyOnElmtId(a11); 163 this.__restartUECMessage.purgeDependencyOnElmtId(a11); 164 } 165 166 aboutToBeDeleted() { 167 this.__normalColor.aboutToBeDeleted(); 168 this.__activeColor.aboutToBeDeleted(); 169 this.__colorMode.aboutToBeDeleted(); 170 this.__deviceList.aboutToBeDeleted(); 171 this.__sessionType.aboutToBeDeleted(); 172 this.__pickerStyle.aboutToBeDeleted(); 173 this.__pickerStyleFromMediaController.aboutToBeDeleted(); 174 this.__isMenuShow.aboutToBeDeleted(); 175 this.__touchMenuItemIndex.aboutToBeDeleted(); 176 this.__configurationColorMode.aboutToBeDeleted(); 177 this.__deviceInfoType.aboutToBeDeleted(); 178 this.__accessibilityConnectedStr.aboutToBeDeleted(); 179 this.__accessibilityAudioControlStr.aboutToBeDeleted(); 180 this.__restartUECMessage.aboutToBeDeleted(); 181 SubscriberManager.Get().delete(this.id__()); 182 this.aboutToBeDeletedInternal(); 183 } 184 185 get normalColor() { 186 return this.__normalColor.get(); 187 } 188 189 set normalColor(z10) { 190 this.__normalColor.set(z10); 191 } 192 193 get activeColor() { 194 return this.__activeColor.get(); 195 } 196 197 set activeColor(y10) { 198 this.__activeColor.set(y10); 199 } 200 201 get colorMode() { 202 return this.__colorMode.get(); 203 } 204 205 set colorMode(b1) { 206 this.__colorMode.set(b1); 207 } 208 209 get deviceList() { 210 return this.__deviceList.get(); 211 } 212 213 set deviceList(x10) { 214 this.__deviceList.set(x10); 215 } 216 217 get sessionType() { 218 return this.__sessionType.get(); 219 } 220 221 set sessionType(w10) { 222 this.__sessionType.set(w10); 223 } 224 225 get pickerStyle() { 226 return this.__pickerStyle.get(); 227 } 228 229 set pickerStyle(v10) { 230 this.__pickerStyle.set(v10); 231 } 232 233 get pickerStyleFromMediaController() { 234 return this.__pickerStyleFromMediaController.get(); 235 } 236 237 set pickerStyleFromMediaController(b1) { 238 this.__pickerStyleFromMediaController.set(b1); 239 } 240 241 get isMenuShow() { 242 return this.__isMenuShow.get(); 243 } 244 245 set isMenuShow(u10) { 246 this.__isMenuShow.set(u10); 247 } 248 249 get touchMenuItemIndex() { 250 return this.__touchMenuItemIndex.get(); 251 } 252 253 set touchMenuItemIndex(t10) { 254 this.__touchMenuItemIndex.set(t10); 255 } 256 257 get configurationColorMode() { 258 return this.__configurationColorMode.get(); 259 } 260 261 set configurationColorMode(a1) { 262 this.__configurationColorMode.set(a1); 263 } 264 265 get deviceInfoType() { 266 return this.__deviceInfoType.get(); 267 } 268 269 set deviceInfoType(b1) { 270 this.__deviceInfoType.set(b1); 271 } 272 273 get accessibilityConnectedStr() { 274 return this.__accessibilityConnectedStr.get(); 275 } 276 277 set accessibilityConnectedStr(c1) { 278 this.__accessibilityConnectedStr.set(c1); 279 } 280 281 get accessibilityAudioControlStr() { 282 return this.__accessibilityAudioControlStr.get(); 283 } 284 285 set accessibilityAudioControlStr(d1) { 286 this.__accessibilityAudioControlStr.set(d1); 287 } 288 289 get restartUECMessage() { 290 return this.__restartUECMessage.get(); 291 } 292 293 set restartUECMessage(f1) { 294 this.__restartUECMessage.set(f1); 295 } 296 297 MenuStateChange() { 298 if (this.extensionProxy != null) { 299 this.extensionProxy.send({ 'isMenuShow': this.isMenuShow }); 300 } 301 } 302 303 initialRender() { 304 this.observeComponentCreation2((r10, s10) => { 305 Column.create(); 306 Column.size({ width: '100%', height: '100%'}); 307 }, Column); 308 this.observeComponentCreation2((n10, o10) => { 309 If.create(); 310 if (this.customPicker === undefined) { 311 this.ifElseBranchUpdateFunction(0, () => { 312 this.buildDefaultPicker.bind(this)(false); 313 }); 314 } else { 315 this.ifElseBranchUpdateFunction(1, () => { 316 this.buildCustomPicker.bind(this)(); 317 }); 318 } 319 }, If); 320 If.pop(); 321 Column.pop(); 322 } 323 324 buildIcon(b3, c3, d3 = null) { 325 this.observeComponentCreation2((f3, g3) => { 326 If.create(); 327 if (this.deviceInfoType === 'true') { 328 this.ifElseBranchUpdateFunction(0, () => { 329 this.observeComponentCreation2((n3, o3) => { 330 SymbolGlyph.create(!c3 ? { 'id': -1, 'type': -1, params: [b3.deviceIconName], 331 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 332 { 'id': -1, 'type': -1, params: [b3.selectedIconName], 333 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 334 SymbolGlyph.fontSize('24vp'); 335 SymbolGlyph.fontColor((c3 && this.configurationColorMode !== 336 ConfigurationColorMode.COLOR_MODE_DARK) ? 337 [{ 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 338 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }] : 339 [{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 340 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]); 341 SymbolGlyph.renderingStrategy(2); 342 }, SymbolGlyph); 343 }); 344 } else { 345 this.ifElseBranchUpdateFunction(1, () => { 346 this.observeComponentCreation2((j3, k3) => { 347 Image.create(!c3 ? { 'id': -1, 'type': -1, 348 params: [b3.deviceIconName], 'bundleName': '__harDefaultBundleName__', 349 'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': -1, params: [b3.selectedIconName], 350 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 351 Image.width(24); 352 Image.height(24); 353 Image.fillColor((c3 && this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK) ? 354 { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 355 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 356 { 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'], 357 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 358 }, Image); 359 }); 360 } 361 }, If); 362 If.pop(); 363 } 364 365 deviceMenu(o8 = null) { 366 this.observeComponentCreation2((j10, k10) => { 367 Column.create(); 368 Column.width(216); 369 }, Column); 370 this.observeComponentCreation2((r8, s8) => { 371 ForEach.create(); 372 const t8 = (v8, w8) => { 373 const x8 = v8; 374 this.observeComponentCreation2((g10, h10) => { 375 Flex.create({ 376 direction: FlexDirection.Column, 377 justifyContent: FlexAlign.SpaceBetween, 378 alignItems: ItemAlign.End 379 }); 380 Flex.width('100%'); 381 Flex.onClick(() => { 382 if (this.extensionProxy != null && !x8.isConnected) { 383 this.extensionProxy.send({ 'selectedDeviceInfo': x8 }); 384 } 385 }); 386 }, Flex); 387 this.observeComponentCreation2((c10, d10) => { 388 Flex.create({ 389 direction: FlexDirection.Row, 390 justifyContent: FlexAlign.SpaceBetween, 391 alignItems: ItemAlign.Center 392 }); 393 Flex.constraintSize({ minHeight: 48 }); 394 Flex.padding({ left: 12, right: 12 }); 395 Flex.onTouch((f10) => { 396 if (f10.type === TouchType.Down) { 397 this.touchMenuItemIndex = w8; 398 } 399 else if (f10.type === TouchType.Up) { 400 this.touchMenuItemIndex = -1; 401 } 402 }); 403 Flex.backgroundColor(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10001, 404 params: ['sys.color.interactive_click'], 'bundleName': '__harDefaultModuleName__', 405 'moduleName': '__harDefaultModuleName__' } : '#00FFFFFF'); 406 Flex.borderRadius(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10002, 407 params: ['sys.float.corner_radius_level8'], 'bundleName': '__harDefaultModuleName__', 408 'moduleName': '__harDefaultModuleName__' } : 0); 409 }, Flex); 410 this.observeComponentCreation2((a10, b10) => { 411 Row.create(); 412 Row.justifyContent(FlexAlign.Start); 413 Row.alignItems(VerticalAlign.Center); 414 }, Row); 415 this.buildIcon.bind(this)(x8, false); 416 this.observeComponentCreation2((w9, x9) => { 417 Text.create(x8.deviceName); 418 Text.fontSize({ 'id': -1, 'type': 10002, 419 params: ['sys.float.ohos_id_text_size_body2'], 'bundleName': '__harDefaultModuleName__', 420 'moduleName': '__harDefaultModuleName__' }); 421 Text.fontColor(x8.isConnected ? 422 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 423 { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'], 424 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 425 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 426 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }) : 427 (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ? 428 { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'], 429 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } : 430 { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'], 431 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' })); 432 Text.width(144); 433 Text.padding({ 434 left: 8, 435 top: 12, 436 right: 8, 437 bottom: 12 438 }); 439 Text.textOverflow({ overflow: TextOverflow.Ellipsis }); 440 Text.maxLines(2); 441 Text.wordBreak(WordBreak.BREAK_ALL); 442 Text.maxFontScale(this.maxFontSizeScale); 443 }, Text); 444 Text.pop(); 445 Row.pop(); 446 this.observeComponentCreation2((m9, n9) => { 447 If.create(); 448 if (x8.isConnected && x8.selectedIconName !== null && x8.selectedIconName !== undefined) { 449 this.ifElseBranchUpdateFunction(0, () => { 450 this.observeComponentCreation2((u9, v9) => { 451 Row.create(); 452 Row.justifyContent(FlexAlign.Start); 453 Row.alignItems(VerticalAlign.Center); 454 Row.accessibilityLevel('yes'); 455 Row.accessibilityText(this.accessibilityConnectedStr); 456 }, Row); 457 this.buildIcon.bind(this)(x8, true); 458 Row.pop(); 459 }); 460 } else { 461 this.ifElseBranchUpdateFunction(1, () => { 462 }); 463 } 464 }, If); 465 If.pop(); 466 Flex.pop(); 467 this.observeComponentCreation2((f9, g9) => { 468 If.create(); 469 if (w8 !== this.deviceList.length - 1) { 470 this.ifElseBranchUpdateFunction(0, () => { 471 this.observeComponentCreation2((k9, l9) => { 472 Divider.create(); 473 Divider.height(1); 474 Divider.width(172); 475 Divider.color({ 'id': -1, 'type': 10001, params: ['sys.color.comp_divider'], 476 'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }); 477 Divider.padding({ right: 12 }); 478 }, Divider); 479 }); 480 } 481 else { 482 this.ifElseBranchUpdateFunction(1, () => { 483 }); 484 } 485 }, If); 486 If.pop(); 487 Flex.pop(); 488 }; 489 this.forEachUpdateFunction(r8, this.deviceList, t8, undefined, true, false); 490 }, ForEach); 491 ForEach.pop(); 492 Column.pop(); 493 } 494 495 buildDefaultPicker(c8, d8 = null) { 496 this.observeComponentCreation2((f8, g8) => { 497 UIExtensionComponent.create({ 498 abilityName: 'UIExtAbility', 499 bundleName: 'com.hmos.mediacontroller', 500 parameters: { 501 'normalColor': this.normalColor, 502 'activeColor': this.activeColor, 503 'pickerColorMode': this.colorMode, 504 'avCastPickerStyle': this.pickerStyle, 505 'ability.want.params.uiExtensionType': 'sysPicker/mediaControl', 506 'isCustomPicker': c8, 507 'message': this.restartUECMessage, 508 } 509 }); 510 UIExtensionComponent.onRemoteReady((n8) => { 511 console.info(TAG, 'onRemoteReady'); 512 this.extensionProxy = n8; 513 }); 514 UIExtensionComponent.onReceive((l8) => { 515 if (JSON.stringify(l8.deviceInfoType) !== undefined) { 516 console.info(TAG, `deviceInfoType : ${JSON.stringify(l8.deviceInfoType)}`); 517 this.deviceInfoType = l8.deviceInfoType; 518 } 519 520 if (JSON.stringify(l8.pickerStyle) !== undefined) { 521 console.info(TAG, `picker style : ${JSON.stringify(l8.pickerStyle)}`); 522 this.pickerStyleFromMediaController = l8.pickerStyle; 523 } 524 525 if (JSON.stringify(l8.deviceList) !== undefined) { 526 console.info(TAG, `picker device list : ${JSON.stringify(l8.deviceList)}`); 527 this.deviceList = JSON.parse(JSON.stringify(l8.deviceList)); 528 let u = this.deviceList.length === 2 && !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 529 let v = this.deviceList === null || this.deviceList.length === 0; 530 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 531 let x = w && (v || u); 532 let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 533 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 534 if (x || b21) { 535 this.isMenuShow = false; 536 } 537 } 538 539 if (JSON.stringify(l8.state) !== undefined) { 540 console.info(TAG, `picker state change : ${JSON.stringify(l8.state)}`); 541 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 542 let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 543 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 544 if (this.onStateChange != null && b21) { 545 if (parseInt(JSON.stringify(l8.state)) === AVCastPickerState.STATE_APPEARING) { 546 this.onStateChange(AVCastPickerState.STATE_APPEARING); 547 } 548 else { 549 this.onStateChange(AVCastPickerState.STATE_DISAPPEARING); 550 } 551 } 552 } 553 554 if (JSON.stringify(l8.sessionType) !== undefined) { 555 console.info(TAG, `session type : ${JSON.stringify(l8.sessionType)}`); 556 this.sessionType = l8.sessionType; 557 } 558 559 if (JSON.stringify(l8.isShowMenu) !== undefined) { 560 console.info(TAG, `isShowMenu : ${l8.isShowMenu}`); 561 this.isMenuShow = l8.isShowMenu; 562 } 563 564 if (JSON.stringify(l8.configurationColorMode) !== undefined) { 565 console.info(TAG, `configurationColorMode : ${l8.configurationColorMode}`); 566 this.configurationColorMode = l8.configurationColorMode; 567 } 568 569 if (JSON.stringify(l8.accessConnected) !== undefined) { 570 console.info(TAG, `accessibilityConnectedStr : ${l8.accessConnected}`); 571 this.accessibilityConnectedStr = l8.accessConnected; 572 } 573 574 575 if (JSON.stringify(l8.accessAudioControl) !== undefined) { 576 console.info(TAG, `accessibilityAudioControlStr : ${l8.accessAudioControl}`); 577 this.accessibilityAudioControlStr = l8.accessAudioControl; 578 } 579 }); 580 UIExtensionComponent.size({ width: '100%', height: '100%' }); 581 UIExtensionComponent.bindMenu(this.isMenuShow, { builder: () => { this.deviceMenu.call(this); }}, { 582 placement: Placement.TopRight, 583 onDisappear: () => { 584 this.isMenuShow = false; 585 this.menuShowStateCallback(this.isMenuShow); 586 }, 587 onAppear: () => { 588 if (this.extensionProxy != null && this.pickerClickTime !== -1) { 589 this.extensionProxy.send({ 'timeCost': new Date().getTime() - this.pickerClickTime }); 590 this.pickerClickTime = -1; 591 } 592 this.menuShowStateCallback(this.isMenuShow); 593 } 594 }); 595 UIExtensionComponent.onClick(() => { 596 let u = this.deviceList.length === 2 && 597 !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList)); 598 let v = this.deviceList === null || this.deviceList.length === 0; 599 let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call'; 600 let x = w && (v || u); 601 let y = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL && 602 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL); 603 if (x || y) { 604 this.isMenuShow = false; 605 if (this.extensionProxy != null) { 606 this.extensionProxy.send({'clickEvent': true}); 607 } 608 } else { 609 this.isMenuShow = !this.isMenuShow; 610 if (this.isMenuShow) { 611 this.pickerClickTime = new Date().getTime(); 612 } 613 } 614 }); 615 UIExtensionComponent.onRelease((releaseCode) => { 616 if (releaseCode === 1) { 617 this.restartUECMessage += 1; 618 } 619 }); 620 UIExtensionComponent.onError(() => { 621 this.restartUECMessage += 1; 622 }); 623 UIExtensionComponent.accessibilityLevel('yes'); 624 UIExtensionComponent.accessibilityText(this.__accessibilityAudioControlStr); 625 }, UIExtensionComponent); 626 } 627 628 hasExtDevice(a) { 629 for (let b = 0; b < a.length; b++) { 630 if (a[b].deviceType !== 1 && // 1 is audio.DeviceType.EARPIECE 631 a[b].deviceType !== 2) { // 2 is audio.DeviceType.SPEAKER 632 return true; 633 } 634 } 635 return false; 636 } 637 638 menuShowStateCallback(k) { 639 if (this.onStateChange != null && (this.pickerStyle === AVCastPickerStyle.STYLE_MENU || 640 this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_MENU)) { 641 let l = k ? AVCastPickerState.STATE_APPEARING : AVCastPickerState.STATE_DISAPPEARING; 642 this.onStateChange(l); 643 } 644 } 645 646 buildCustomPicker(s7 = null) { 647 this.observeComponentCreation2((a8, b8) => { 648 Stack.create({ alignContent: Alignment.Center}); 649 Stack.size({ width: '100%', height: '100%' }); 650 }, Stack); 651 this.observeComponentCreation2((y7, z7) => { 652 Column.create(); 653 Column.alignItems(HorizontalAlign.Center); 654 Column.justifyContent(FlexAlign.Center); 655 Column.size({ width: '100%', height: '100%' }); 656 Column.zIndex(0); 657 }, Column); 658 this.customPicker.bind(this)(); 659 Column.pop(); 660 this.observeComponentCreation2((w7, x7) => { 661 Column.create(); 662 Column.alignItems(HorizontalAlign.Center); 663 Column.justifyContent(FlexAlign.Center); 664 Column.size({ width: '100%', height: '100%' }); 665 Column.zIndex(1); 666 }, Column); 667 this.buildDefaultPicker.bind(this)(true); 668 Column.pop(); 669 Stack.pop(); 670 } 671 672 rerender() { 673 this.updateDirtyElements(); 674 } 675 676 static getEntryName() { 677 return 'AVCastPicker'; 678 } 679} 680 681export default AVCastPicker;