• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 = new ObservedPropertySimplePU(1, this, 'maxFontSizeScale');
78        this.__accessibilityConnectedStr = new ObservedPropertySimplePU('已连接', this, 'accessibilityConnectedStr');
79        this.__accessibilityAudioControlStr = new ObservedPropertySimplePU('音视频投播', this, 'accessibilityAudioControlStr');
80        this.__isPc = new ObservedPropertySimplePU(false, this, 'isPc');
81        this.__isRTL = new ObservedPropertySimplePU(false, this, 'isRTL');
82        this.__restartUECMessage = new ObservedPropertySimplePU(1, this, 'restartUECMessage');
83        this.needToRestart = false;
84        this.__isShowLoadingProgress = new ObservedPropertySimplePU(false, this, 'isShowLoadingProgress');
85        this.setInitiallyProvidedValue(e11);
86        this.declareWatch('isMenuShow', this.MenuStateChange);
87        this.finalizeConstruction();
88    }
89
90    setInitiallyProvidedValue(c11) {
91        if (c11.normalColor !== undefined) {
92            this.normalColor = c11.normalColor;
93        }
94        if (c11.activeColor !== undefined) {
95            this.activeColor = c11.activeColor;
96        }
97        if (c11.colorMode !== undefined) {
98            this.colorMode = c11.colorMode;
99        }
100        if (c11.deviceList !== undefined) {
101            this.deviceList = c11.deviceList;
102        }
103        if (c11.sessionType !== undefined) {
104            this.sessionType = c11.sessionType;
105        }
106        if (c11.pickerStyle !== undefined) {
107            this.pickerStyle = c11.pickerStyle;
108        }
109        if (c11.pickerStyleFromMediaController !== undefined) {
110            this.pickerStyleFromMediaController = c11.pickerStyleFromMediaController;
111        }
112        if (c11.isMenuShow !== undefined) {
113            this.isMenuShow = c11.isMenuShow;
114        }
115        if (c11.touchMenuItemIndex !== undefined) {
116            this.touchMenuItemIndex = c11.touchMenuItemIndex;
117        }
118        if (c11.onStateChange !== undefined) {
119            this.onStateChange = c11.onStateChange;
120        }
121        if (c11.extensionProxy !== undefined) {
122            this.extensionProxy = c11.extensionProxy;
123        }
124        if (c11.pickerClickTime !== undefined) {
125            this.pickerClickTime = c11.pickerClickTime;
126        }
127        if (c11.customPicker !== undefined) {
128            this.customPicker = c11.customPicker;
129        }
130        if (c11.configurationColorMode !== undefined) {
131            this.configurationColorMode = c11.configurationColorMode;
132        }
133        if (c11.deviceInfoType !== undefined) {
134            this.deviceInfoType = c11.deviceInfoType;
135        }
136        if (c11.maxFontSizeScale !== undefined) {
137            this.maxFontSizeScale = c11.maxFontSizeScale;
138        }
139        if (c11.accessibilityConnectedStr !== undefined) {
140            this.accessibilityConnectedStr = c11.accessibilityConnectedStr;
141        }
142        if (c11.accessibilityAudioControlStr !== undefined) {
143            this.accessibilityAudioControlStr = c11.accessibilityAudioControlStr;
144        }
145        if (c11.isPc !== undefined) {
146            this.isPc = c11.isPc;
147        }
148        if (c11.isRTL !== undefined) {
149            this.isRTL = c11.isRTL;
150        }
151        if (c11.restartUECMessage !== undefined) {
152            this.restartUECMessage = c11.restartUECMessage;
153        }
154        if (c11.needToRestart !== undefined) {
155            this.needToRestart = c11.needToRestart;
156        }
157        if (c11.isShowLoadingProgress !== undefined) {
158            this.isShowLoadingProgress = c11.isShowLoadingProgress;
159        }
160    }
161
162    updateStateVars(b11) {
163    }
164
165    purgeVariableDependenciesOnElmtId(a11) {
166        this.__normalColor.purgeDependencyOnElmtId(a11);
167        this.__activeColor.purgeDependencyOnElmtId(a11);
168        this.__colorMode.purgeDependencyOnElmtId(a11);
169        this.__deviceList.purgeDependencyOnElmtId(a11);
170        this.__sessionType.purgeDependencyOnElmtId(a11);
171        this.__pickerStyle.purgeDependencyOnElmtId(a11);
172        this.__pickerStyleFromMediaController.purgeDependencyOnElmtId(a11);
173        this.__isMenuShow.purgeDependencyOnElmtId(a11);
174        this.__touchMenuItemIndex.purgeDependencyOnElmtId(a11);
175        this.__configurationColorMode.purgeDependencyOnElmtId(a11);
176        this.__deviceInfoType.purgeDependencyOnElmtId(a11);
177        this.__maxFontSizeScale.purgeDependencyOnElmtId(a11);
178        this.__accessibilityConnectedStr.purgeDependencyOnElmtId(a11);
179        this.__accessibilityAudioControlStr.purgeDependencyOnElmtId(a11);
180        this.__isPc.purgeDependencyOnElmtId(a11);
181        this.__isRTL.purgeDependencyOnElmtId(a11);
182        this.__restartUECMessage.purgeDependencyOnElmtId(a11);
183        this.__isShowLoadingProgress.purgeDependencyOnElmtId(a11);
184    }
185
186    aboutToBeDeleted() {
187        this.__normalColor.aboutToBeDeleted();
188        this.__activeColor.aboutToBeDeleted();
189        this.__colorMode.aboutToBeDeleted();
190        this.__deviceList.aboutToBeDeleted();
191        this.__sessionType.aboutToBeDeleted();
192        this.__pickerStyle.aboutToBeDeleted();
193        this.__pickerStyleFromMediaController.aboutToBeDeleted();
194        this.__isMenuShow.aboutToBeDeleted();
195        this.__touchMenuItemIndex.aboutToBeDeleted();
196        this.__configurationColorMode.aboutToBeDeleted();
197        this.__deviceInfoType.aboutToBeDeleted();
198        this.__maxFontSizeScale.aboutToBeDeleted();
199        this.__accessibilityConnectedStr.aboutToBeDeleted();
200        this.__accessibilityAudioControlStr.aboutToBeDeleted();
201        this.__isPc.aboutToBeDeleted();
202        this.__isRTL.aboutToBeDeleted();
203        this.__restartUECMessage.aboutToBeDeleted();
204        this.__isShowLoadingProgress.aboutToBeDeleted();
205        SubscriberManager.Get().delete(this.id__());
206        this.aboutToBeDeletedInternal();
207    }
208
209    get normalColor() {
210        return this.__normalColor.get();
211    }
212
213    set normalColor(z10) {
214        this.__normalColor.set(z10);
215    }
216
217    get activeColor() {
218        return this.__activeColor.get();
219    }
220
221    set activeColor(y10) {
222        this.__activeColor.set(y10);
223    }
224
225    get colorMode() {
226        return this.__colorMode.get();
227    }
228
229    set colorMode(b1) {
230        this.__colorMode.set(b1);
231    }
232
233    get deviceList() {
234        return this.__deviceList.get();
235    }
236
237    set deviceList(x10) {
238        this.__deviceList.set(x10);
239    }
240
241    get sessionType() {
242        return this.__sessionType.get();
243    }
244
245    set sessionType(w10) {
246        this.__sessionType.set(w10);
247    }
248
249    get pickerStyle() {
250        return this.__pickerStyle.get();
251    }
252
253    set pickerStyle(v10) {
254        this.__pickerStyle.set(v10);
255    }
256
257    get pickerStyleFromMediaController() {
258        return this.__pickerStyleFromMediaController.get();
259    }
260
261    set pickerStyleFromMediaController(b1) {
262        this.__pickerStyleFromMediaController.set(b1);
263    }
264
265    get isMenuShow() {
266        return this.__isMenuShow.get();
267    }
268
269    set isMenuShow(u10) {
270        this.__isMenuShow.set(u10);
271    }
272
273    get touchMenuItemIndex() {
274        return this.__touchMenuItemIndex.get();
275    }
276
277    set touchMenuItemIndex(t10) {
278        this.__touchMenuItemIndex.set(t10);
279    }
280
281    get configurationColorMode() {
282        return this.__configurationColorMode.get();
283    }
284
285    set configurationColorMode(a1) {
286        this.__configurationColorMode.set(a1);
287    }
288
289    get deviceInfoType() {
290        return this.__deviceInfoType.get();
291    }
292
293    set deviceInfoType(b1) {
294        this.__deviceInfoType.set(b1);
295    }
296
297    get maxFontSizeScale() {
298        return this.__maxFontSizeScale.get();
299    }
300
301    set maxFontSizeScale(e1) {
302        this.__maxFontSizeScale.set(e1);
303    }
304
305    get accessibilityConnectedStr() {
306        return this.__accessibilityConnectedStr.get();
307    }
308
309    set accessibilityConnectedStr(c1) {
310        this.__accessibilityConnectedStr.set(c1);
311    }
312
313    get accessibilityAudioControlStr() {
314        return this.__accessibilityAudioControlStr.get();
315    }
316
317    set accessibilityAudioControlStr(d1) {
318        this.__accessibilityAudioControlStr.set(d1);
319    }
320
321    get isPc() {
322        return this.__isPc.get();
323    }
324
325    set isPc(e1) {
326        this.__isPc.set(e1);
327    }
328
329    get isRTL() {
330        return this.__isRTL.get();
331    }
332
333    set isRTL(f1) {
334        this.__isRTL.set(f1);
335    }
336
337    get restartUECMessage() {
338        return this.__restartUECMessage.get();
339    }
340
341    set restartUECMessage(f1) {
342        this.__restartUECMessage.set(f1);
343    }
344
345    get isShowLoadingProgress() {
346        return this.__isShowLoadingProgress.get();
347    }
348
349    set isShowLoadingProgress(g1) {
350        this.__isShowLoadingProgress.set(g1);
351    }
352
353    MenuStateChange() {
354        if (this.extensionProxy != null) {
355            this.extensionProxy.send({ 'isMenuShow': this.isMenuShow });
356        }
357    }
358
359    initialRender() {
360        this.observeComponentCreation2((r10, s10) => {
361            Column.create();
362            Column.size({ width: '100%', height: '100%'});
363        }, Column);
364        this.observeComponentCreation2((n10, o10) => {
365            If.create();
366            if (this.customPicker === undefined) {
367                this.ifElseBranchUpdateFunction(0, () => {
368                    this.buildDefaultPicker.bind(this)(false);
369                });
370            } else {
371                this.ifElseBranchUpdateFunction(1, () => {
372                    this.buildCustomPicker.bind(this)();
373                });
374            }
375        }, If);
376        If.pop();
377        Column.pop();
378    }
379
380    iconBuilder(b3, c3, d3 = null) {
381        this.observeComponentCreation2((f3, g3) => {
382            If.create();
383            if (this.deviceInfoType === 'true') {
384                this.ifElseBranchUpdateFunction(0, () => {
385                    this.observeComponentCreation2((n3, o3) => {
386                        SymbolGlyph.create(!c3 ? { 'id': -1, 'type': -1, params: [b3.deviceIconName],
387                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } :
388                            { 'id': -1, 'type': -1, params: [b3.selectedIconName],
389                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' });
390                        SymbolGlyph.fontSize('24vp');
391                        SymbolGlyph.fontColor((c3 && this.configurationColorMode !==
392                            ConfigurationColorMode.COLOR_MODE_DARK) ?
393                            [{ 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'],
394                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }] :
395                            [{ 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'],
396                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }]);
397                        SymbolGlyph.renderingStrategy(2);
398                    }, SymbolGlyph);
399                });
400            } else {
401                this.ifElseBranchUpdateFunction(1, () => {
402                    this.observeComponentCreation2((j3, k3) => {
403                        Image.create(!c3 ? { 'id': -1, 'type': -1,
404                            params: [b3.deviceIconName], 'bundleName': '__harDefaultBundleName__',
405                            'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': -1, params: [b3.selectedIconName],
406                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' });
407                        Image.width(24);
408                        Image.height(24);
409                        Image.fillColor((c3 && this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK) ?
410                            { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'],
411                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } :
412                            { 'id': -1, 'type': 10001, params: ['sys.color.icon_primary'],
413                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' });
414                    }, Image);
415                });
416            }
417        }, If);
418        If.pop();
419    }
420
421    textBuilder(u1, v1 = null) {
422        this.observeComponentCreation2((x1, y1) => {
423            Text.create(u1.deviceName);
424            Text.fontSize({ 'id': -1, 'type': 10002,
425                params: ['sys.float.ohos_id_text_size_body2'], 'bundleName': '__harDefaultBundleName__',
426                'moduleName': '__harDefaultModuleName__' });
427            Text.fontColor(u1.isConnected ?
428                (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ?
429                { 'id': -1, 'type': 10001, params: ['sys.color.comp_background_emphasize'],
430                'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } :
431                { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'],
432                'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }) :
433                (this.configurationColorMode !== ConfigurationColorMode.COLOR_MODE_DARK ?
434                { 'id': -1, 'type': 10001, params: ['sys.color.font_primary'],
435                'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' } :
436                { 'id': -1, 'type': 10001, params: ['sys.color.font_secondary'],
437                'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' }));
438            Text.width(this.isPc ? 254 : 144);
439            Text.padding({
440                left: 8,
441                top: this.isPc ? 11 : 17,
442                right: 8,
443                bottom: this.isPc ? 11 : 17
444            });
445            Text.textOverflow({ overflow: TextOverflow.Ellipsis });
446            Text.maxLines(2);
447            Text.wordBreak(WordBreak.BREAK_ALL);
448            Text.maxFontScale(this.maxFontSizeScale);
449            Text.direction(this.isRTL ? Direction.Rtl : Direction.Ltr);
450        }, Text);
451        Text.pop();
452    }
453
454    deviceMenu(o8 = null) {
455        this.observeComponentCreation2((j10, k10) => {
456            Column.create();
457            Column.width(this.isPc ? 326 : 216);
458            Column.borderRadius(this.isPc ? 8 : 20);
459        }, Column);
460        this.observeComponentCreation2((r8, s8) => {
461            ForEach.create();
462            const t8 = (v8, w8) => {
463                const x8 = v8;
464                this.observeComponentCreation2((g10, h10) => {
465                    Flex.create({
466                        direction: FlexDirection.Column,
467                        justifyContent: FlexAlign.SpaceBetween,
468                        alignItems: ItemAlign.End
469                    });
470                    Flex.width('100%');
471                    Flex.onClick(() => {
472                        if (this.extensionProxy != null && !x8.isConnected) {
473                            this.extensionProxy.send({ 'selectedDeviceInfo': x8 });
474                        }
475                    });
476                }, Flex);
477                this.observeComponentCreation2((c10, d10) => {
478                    Flex.create({
479                        direction: FlexDirection.Row,
480                        justifyContent: FlexAlign.SpaceBetween,
481                        alignItems: ItemAlign.Center
482                    });
483                    Flex.constraintSize({ minHeight: this.isPc ? 40 : 48 });
484                    Flex.padding({ left: 12, right: 12 });
485                    Flex.onTouch((f10) => {
486                        if (f10.type === TouchType.Down) {
487                            this.touchMenuItemIndex = w8;
488                        }
489                        else if (f10.type === TouchType.Up) {
490                            this.touchMenuItemIndex = -1;
491                        }
492                    });
493                    Flex.backgroundColor(this.touchMenuItemIndex === w8 ? { 'id': -1, 'type': 10001,
494                        params: ['sys.color.interactive_click'], 'bundleName': '__harDefaultBundleName__',
495                        'moduleName': '__harDefaultModuleName__' } : '#00FFFFFF');
496                    Flex.borderRadius(this.touchMenuItemIndex === w8 ? (this.isPc ? { 'id': -1, 'type': 10002,
497                        params: ['sys.float.corner_radius_level2'], 'bundleName': '__harDefaultBundleName__',
498                        'moduleName': '__harDefaultModuleName__' } : { 'id': -1, 'type': 10002,
499                        params: ['sys.float.corner_radius_level8'], 'bundleName': '__harDefaultBundleName__',
500                        'moduleName': '__harDefaultModuleName__' }) : 0);
501                }, Flex);
502                this.observeComponentCreation2((a10, b10) => {
503                    Row.create();
504                    Row.alignItems(VerticalAlign.Center);
505                }, Row);
506                this.iconBuilder.bind(this)(x8, false);
507                this.textBuilder.bind(this)(x8);
508                Row.pop();
509                this.observeComponentCreation2((m9, n9) => {
510                    If.create();
511                    if (x8.isConnected && x8.selectedIconName !== null && x8.selectedIconName !== undefined) {
512                        this.ifElseBranchUpdateFunction(0, () => {
513                            this.observeComponentCreation2((u9, v9) => {
514                                Row.create();
515                                Row.alignItems(VerticalAlign.Center);
516                                Row.accessibilityLevel('yes');
517                                Row.accessibilityText(this.accessibilityConnectedStr);
518                            }, Row);
519                            this.iconBuilder.bind(this)(x8, true);
520                            Row.pop();
521                        });
522                    } else {
523                        this.ifElseBranchUpdateFunction(1, () => {
524                        });
525                    }
526                }, If);
527                If.pop();
528                Flex.pop();
529                this.observeComponentCreation2((f9, g9) => {
530                    If.create();
531                    if (!this.isPc && (w8 !== this.deviceList.length - 1)) {
532                        this.ifElseBranchUpdateFunction(0, () => {
533                            this.observeComponentCreation2((k9, l9) => {
534                                Divider.create();
535                                Divider.height(1);
536                                Divider.color({ 'id': -1, 'type': 10001, params: ['sys.color.comp_divider'],
537                                    'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__' });
538                                Divider.padding({ right: (this.isRTL ? 44 : 12), left: (this.isRTL ? 12 : 44) });
539                            }, Divider);
540                        });
541                    } else if (this.isPc && (w8 !== this.deviceList.length - 1)) {
542                        this.ifElseBranchUpdateFunction(1, () => {
543                            this.observeComponentCreation2((c2, d2) => {
544                                Row.create();
545                                Row.width('100%');
546                                Row.height(2);
547                            }, Row);
548                            Row.pop();
549                        });
550                    } else {
551                        this.ifElseBranchUpdateFunction(2, () => {
552                        });
553                    }
554                }, If);
555                If.pop();
556                Flex.pop();
557            };
558            this.forEachUpdateFunction(r8, this.deviceList, t8, undefined, true, false);
559        }, ForEach);
560        ForEach.pop();
561        Column.pop();
562    }
563
564    buildDefaultPicker(c8, d8 = null) {
565        this.observeComponentCreation2((f8, g8) => {
566            Button.createWithChild();
567            Button.size({ width: '100%', height: '100%' });
568            Button.backgroundColor('#00000000');
569            Button.accessibilityLevel('yes');
570            Button.accessibilityText(this.accessibilityAudioControlStr);
571            Button.onClick(() => {
572                if (this.needToRestart) {
573                    this.needToRestart = false;
574                    this.restartUECMessage += 1;
575                    return;
576                }
577                let u = this.deviceList.length === 2 &&
578                    !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList));
579                let v = this.deviceList === null || this.deviceList.length === 0;
580                let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call';
581                let x = w && (v || u);
582                let y = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL &&
583                    this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL);
584                if (x || y) {
585                    this.isMenuShow = false;
586                    this.touchMenuItemIndex = -1;
587                    if (this.extensionProxy != null) {
588                        this.extensionProxy.send({'clickEvent': true});
589                    }
590                } else {
591                    this.isMenuShow = !this.isMenuShow;
592                    if (this.isMenuShow) {
593                        this.pickerClickTime = new Date().getTime();
594                    } else {
595                        this.touchMenuItemIndex = -1;
596                    }
597                }
598            });
599        }, Button);
600        this.observeComponentCreation2((f8, g8) => {
601            UIExtensionComponent.create({
602                abilityName: 'UIExtAbility',
603                bundleName: 'com.hmos.mediacontroller',
604                parameters: {
605                    'normalColor': this.normalColor,
606                    'activeColor': this.activeColor,
607                    'pickerColorMode': this.colorMode,
608                    'avCastPickerStyle': this.pickerStyle,
609                    'ability.want.params.uiExtensionType': 'sysPicker/mediaControl',
610                    'isCustomPicker': c8,
611                    'message': this.restartUECMessage,
612                }
613            });
614            UIExtensionComponent.onRemoteReady((n8) => {
615                console.info(TAG, 'onRemoteReady');
616                this.extensionProxy = n8;
617            });
618            UIExtensionComponent.onReceive((l8) => {
619                if (JSON.stringify(l8.deviceInfoType) !== undefined) {
620                    console.info(TAG, `deviceInfoType : ${JSON.stringify(l8.deviceInfoType)}`);
621                    this.deviceInfoType = l8.deviceInfoType;
622                }
623
624                if (JSON.stringify(l8.pickerStyle) !== undefined) {
625                    console.info(TAG, `picker style : ${JSON.stringify(l8.pickerStyle)}`);
626                    this.pickerStyleFromMediaController = l8.pickerStyle;
627                }
628
629                if (JSON.stringify(l8.deviceList) !== undefined) {
630                    console.info(TAG, `picker device list : ${JSON.stringify(l8.deviceList)}`);
631                    this.deviceList = JSON.parse(JSON.stringify(l8.deviceList));
632                    let u = this.deviceList.length === 2 && !this.hasExtDevice(ObservedObject.GetRawObject(this.deviceList));
633                    let v = this.deviceList === null || this.deviceList.length === 0;
634                    let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call';
635                    let x = w && (v || u);
636                    let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL &&
637                        this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL);
638                    if (x || b21) {
639                        this.isMenuShow = false;
640                        this.touchMenuItemIndex = -1;
641                    }
642                }
643
644                if (JSON.stringify(l8.state) !== undefined) {
645                    console.info(TAG, `picker state change : ${JSON.stringify(l8.state)}`);
646                    let w = this.sessionType === 'voice_call' || this.sessionType === 'video_call';
647                    let b21 = !w && (this.pickerStyle === AVCastPickerStyle.STYLE_PANEL &&
648                        this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_PANEL);
649                    if (this.onStateChange != null && b21) {
650                        if (parseInt(JSON.stringify(l8.state)) === AVCastPickerState.STATE_APPEARING) {
651                            this.onStateChange(AVCastPickerState.STATE_APPEARING);
652                        }
653                        else {
654                            this.onStateChange(AVCastPickerState.STATE_DISAPPEARING);
655                        }
656                    }
657                }
658
659                if (JSON.stringify(l8.sessionType) !== undefined) {
660                    console.info(TAG, `session type : ${JSON.stringify(l8.sessionType)}`);
661                    this.sessionType = l8.sessionType;
662                }
663
664                if (JSON.stringify(l8.isShowMenu) !== undefined) {
665                    console.info(TAG, `isShowMenu : ${l8.isShowMenu}`);
666                    this.isMenuShow = l8.isShowMenu;
667                    if (!this.isMenuShow) {
668                        this.touchMenuItemIndex = -1;
669                    }
670                }
671
672                if (JSON.stringify(l8.configurationColorMode) !== undefined) {
673                    console.info(TAG, `configurationColorMode : ${l8.configurationColorMode}`);
674                    this.configurationColorMode = l8.configurationColorMode;
675                }
676
677                if (JSON.stringify(l8.accessConnected) !== undefined) {
678                    console.info(TAG, `accessibilityConnectedStr : ${l8.accessConnected}`);
679                    this.accessibilityConnectedStr = l8.accessConnected;
680                }
681
682                if (JSON.stringify(l8.accessAudioControl) !== undefined) {
683                    console.info(TAG, `accessibilityAudioControlStr : ${l8.accessAudioControl}`);
684                    this.accessibilityAudioControlStr = l8.accessAudioControl;
685                }
686
687                if (JSON.stringify(l8.isPc) !== undefined) {
688                    console.info(TAG, `isPc : ${l8.isPc}`);
689                    this.isPc = l8.isPc;
690                }
691
692                if (JSON.stringify(l8.isRTL) !== undefined) {
693                    console.info(TAG, `isRTL : ${l8.isRTL}`);
694                    this.isRTL = l8.isRTL;
695                }
696
697                if (JSON.stringify(l8.maxFontSizeScale) !== undefined) {
698                    console.info(TAG, `maxFontSizeScale : ${l8.maxFontSizeScale}`);
699                    this.maxFontSizeScale = l8.maxFontSizeScale;
700                }
701
702                if (JSON.stringify(l8.isShowLoadingProgress) !== undefined) {
703                    console.info(TAG, `isShowLoadingProgress : ${l8.isShowLoadingProgress}`);
704                    this.isShowLoadingProgress = l8.isShowLoadingProgress;
705                }
706            });
707            UIExtensionComponent.size({ width: '100%', height: '100%' });
708            UIExtensionComponent.bindMenu(this.isMenuShow, { builder: () => { this.deviceMenu.call(this); }}, {
709                placement: Placement.BottomRight,
710                onDisappear: () => {
711                  this.isMenuShow = false;
712                  this.touchMenuItemIndex = -1;
713                  this.menuShowStateCallback(this.isMenuShow);
714                },
715                onAppear: () => {
716                    if (this.extensionProxy != null && this.pickerClickTime !== -1) {
717                        this.extensionProxy.send({ 'timeCost': new Date().getTime() - this.pickerClickTime });
718                        this.pickerClickTime = -1;
719                    }
720                    this.menuShowStateCallback(this.isMenuShow);
721                }
722            });
723            UIExtensionComponent.onRelease((releaseCode) => {
724                if (releaseCode === 1) {
725                    this.needToRestart = true;
726                }
727            });
728            UIExtensionComponent.onError(() => {
729                this.needToRestart = true;
730            });
731            UIExtensionComponent.accessibilityLevel('yes');
732            UIExtensionComponent.accessibilityText(this.__accessibilityAudioControlStr);
733            UIExtensionComponent.accessibilityUseSamePage(AccessibilitySamePageMode.FULL_SILENT);
734        }, UIExtensionComponent);
735        Button.pop();
736    }
737
738    hasExtDevice(a) {
739        for (let b = 0; b < a.length; b++) {
740            if (a[b].deviceType !== 1 && // 1 is audio.DeviceType.EARPIECE
741                a[b].deviceType !== 2) { // 2 is audio.DeviceType.SPEAKER
742                return true;
743            }
744        }
745        return false;
746    }
747
748    menuShowStateCallback(k) {
749        if (this.onStateChange != null && (this.pickerStyle === AVCastPickerStyle.STYLE_MENU ||
750            this.pickerStyleFromMediaController === AVCastPickerStyle.STYLE_MENU)) {
751            let l = k ? AVCastPickerState.STATE_APPEARING : AVCastPickerState.STATE_DISAPPEARING;
752            this.onStateChange(l);
753        }
754    }
755
756    buildCustomPicker(s7 = null) {
757        this.observeComponentCreation2((a8, b8) => {
758            Stack.create({ alignContent: Alignment.Center});
759            Stack.size({ width: '100%', height: '100%' });
760        }, Stack);
761        this.observeComponentCreation2((y7, z7) => {
762            Column.create();
763            Column.alignItems(HorizontalAlign.Center);
764            Column.justifyContent(FlexAlign.Center);
765            Column.size({ width: '100%', height: '100%' });
766            Column.zIndex(0);
767        }, Column);
768        this.observeComponentCreation2((c7, s7) => {
769            If.create();
770            if (this.isShowLoadingProgress) {
771                this.ifElseBranchUpdateFunction(0, () => {
772                    this.observeComponentCreation2((c7, s7) => {
773                        LoadingProgress.create();
774                        LoadingProgress.color({'id': -1, 'type': 10001, params: ['sys.color.icon_secondary'],
775                            'bundleName': '__harDefaultBundleName__', 'moduleName': '__harDefaultModuleName__'});
776                        LoadingProgress.width('20vp');
777                        LoadingProgress.height('20vp');
778                    }, LoadingProgress);
779                });
780            } else {
781                this.ifElseBranchUpdateFunction(1, () => {
782                    this.customPicker.bind(this)();
783                });
784            }
785        }, If);
786        If.pop();
787        Column.pop();
788        this.observeComponentCreation2((w7, x7) => {
789            Column.create();
790            Column.alignItems(HorizontalAlign.Center);
791            Column.justifyContent(FlexAlign.Center);
792            Column.size({ width: '100%', height: '100%' });
793            Column.zIndex(1);
794        }, Column);
795        this.buildDefaultPicker.bind(this)(true);
796        Column.pop();
797        Stack.pop();
798    }
799
800    rerender() {
801        this.updateDirtyElements();
802    }
803
804    static getEntryName() {
805        return 'AVCastPicker';
806    }
807}
808
809export default AVCastPicker;