16e80583aSopenharmony_ci/** 26e80583aSopenharmony_ci * Copyright (c) 2022-2022 Huawei Device Co., Ltd. 36e80583aSopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 46e80583aSopenharmony_ci * you may not use this file except in compliance with the License. 56e80583aSopenharmony_ci * You may obtain a copy of the License at 66e80583aSopenharmony_ci * 76e80583aSopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 86e80583aSopenharmony_ci * 96e80583aSopenharmony_ci * Unless required by applicable law or agreed to in writing, software 106e80583aSopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 116e80583aSopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 126e80583aSopenharmony_ci * See the License for the specific language governing permissions and 136e80583aSopenharmony_ci * limitations under the License. 146e80583aSopenharmony_ci */ 156e80583aSopenharmony_ci 166e80583aSopenharmony_ciimport windowAnimationManager from '@ohos.animation.windowAnimationManager'; 176e80583aSopenharmony_ciimport curves from '@ohos.curves'; 186e80583aSopenharmony_ciimport { Log } from '../utils/Log'; 196e80583aSopenharmony_ciimport { Trace } from '../utils/Trace'; 206e80583aSopenharmony_ciimport { StyleConstants } from '../constants/StyleConstants'; 216e80583aSopenharmony_ciimport { CommonConstants } from '../constants/CommonConstants'; 226e80583aSopenharmony_ciimport OverlayAppIcon from './OverlayAppIcon'; 236e80583aSopenharmony_ciimport RemoteConstants from '../constants/RemoteConstants'; 246e80583aSopenharmony_ciimport { localEventManager } from '../manager/LocalEventManager'; 256e80583aSopenharmony_ciimport { EventConstants } from '../constants/EventConstants'; 266e80583aSopenharmony_ciimport { CloseAppManager } from '../manager/CloseAppManager'; 276e80583aSopenharmony_ciimport WindowAnimationControllerImpl from '../animation/remoteanimation/WindowAnimationControllerImpl'; 286e80583aSopenharmony_ciimport { LauncherDragItemInfo } from '../bean/LauncherDragItemInfo'; 296e80583aSopenharmony_ci 306e80583aSopenharmony_ciconst TAG = 'RemoteWindowWrapper'; 316e80583aSopenharmony_ci 326e80583aSopenharmony_ciclass StartAppCalculate { 336e80583aSopenharmony_ci public startAppCalculateScaleX: number = 0; 346e80583aSopenharmony_ci public startAppCalculateScaleY: number = 0; 356e80583aSopenharmony_ci public startAppCalculateTranslateX: number = 0; 366e80583aSopenharmony_ci public startAppCalculateTranslateY: number = 0; 376e80583aSopenharmony_ci} 386e80583aSopenharmony_ci 396e80583aSopenharmony_ciclass CloseAppCalculate { 406e80583aSopenharmony_ci public closeAppCalculateScaleX: number = 0; 416e80583aSopenharmony_ci public closeAppCalculateScaleY: number = 0; 426e80583aSopenharmony_ci public closeAppCalculateTranslateX: number = 0; 436e80583aSopenharmony_ci public closeAppCalculateTranslateY: number = 0; 446e80583aSopenharmony_ci} 456e80583aSopenharmony_ci 466e80583aSopenharmony_ci@Observed 476e80583aSopenharmony_ciclass RemoteVo { 486e80583aSopenharmony_ci public remoteAnimationType: number; 496e80583aSopenharmony_ci public finishCallback: windowAnimationManager.WindowAnimationFinishedCallback; 506e80583aSopenharmony_ci public target: windowAnimationManager.WindowAnimationTarget; 516e80583aSopenharmony_ci public fromWindowTarget: windowAnimationManager.WindowAnimationTarget; 526e80583aSopenharmony_ci public remoteWindowKey: string; 536e80583aSopenharmony_ci public iconInfo: StartAppIconInfo; 546e80583aSopenharmony_ci public appItemInfo: StartAppItemInfo; 556e80583aSopenharmony_ci public count: number = 0; 566e80583aSopenharmony_ci 576e80583aSopenharmony_ci public mScreenWidth: number; 586e80583aSopenharmony_ci public mScreenHeight: number; 596e80583aSopenharmony_ci 606e80583aSopenharmony_ci public startAppTypeFromPageDesktop: number; 616e80583aSopenharmony_ci 626e80583aSopenharmony_ci public remoteWindowScaleX: number = 0; 636e80583aSopenharmony_ci public remoteWindowScaleY: number = 0; 646e80583aSopenharmony_ci public remoteWindowTranslateX: number = 0; 656e80583aSopenharmony_ci public remoteWindowTranslateY: number = 0; 666e80583aSopenharmony_ci public remoteWindowWindowAlpha: number = 0; 676e80583aSopenharmony_ci public remoteWindowRadius: number = 0; 686e80583aSopenharmony_ci 696e80583aSopenharmony_ci public fromRemoteWindowScaleX: number = 1.0; 706e80583aSopenharmony_ci public fromRemoteWindowScaleY: number = 1.0; 716e80583aSopenharmony_ci public fromRemoteWindowTranslateX: number = 0; 726e80583aSopenharmony_ci public fromRemoteWindowTranslateY: number = 0; 736e80583aSopenharmony_ci public fromRemoteWindowWindowAlpha: number = 1.0; 746e80583aSopenharmony_ci 756e80583aSopenharmony_ci public startAppIconScaleX: number = 0; 766e80583aSopenharmony_ci public startAppIconScaleY: number = 0; 776e80583aSopenharmony_ci public startAppIconTranslateX: number = 0; 786e80583aSopenharmony_ci public startAppIconTranslateY: number = 0; 796e80583aSopenharmony_ci public startAppIconWindowAlpha: number = 0; 806e80583aSopenharmony_ci 816e80583aSopenharmony_ci constructor( 826e80583aSopenharmony_ci remoteAnimationType: number, 836e80583aSopenharmony_ci startAppTypeFromPageDesktop: number, 846e80583aSopenharmony_ci target: windowAnimationManager.WindowAnimationTarget, 856e80583aSopenharmony_ci iconInfo: StartAppIconInfo = {} as StartAppIconInfo, 866e80583aSopenharmony_ci appItemInfo: StartAppItemInfo = {} as StartAppItemInfo, 876e80583aSopenharmony_ci fromWindowTarget: windowAnimationManager.WindowAnimationTarget | undefined = undefined, 886e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback 896e80583aSopenharmony_ci ) { 906e80583aSopenharmony_ci this.remoteAnimationType = remoteAnimationType; 916e80583aSopenharmony_ci this.target = target; 926e80583aSopenharmony_ci this.fromWindowTarget = fromWindowTarget as WindowAnimationTarget; 936e80583aSopenharmony_ci this.mScreenWidth = px2vp(this.target.windowBounds.width); 946e80583aSopenharmony_ci this.mScreenHeight = px2vp(this.target.windowBounds.height); 956e80583aSopenharmony_ci this.iconInfo = iconInfo; 966e80583aSopenharmony_ci this.appItemInfo = appItemInfo; 976e80583aSopenharmony_ci this.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 986e80583aSopenharmony_ci this.finishCallback = finishCallback; 996e80583aSopenharmony_ci this.remoteWindowKey = this.target.bundleName + this.target.abilityName + this.target.missionId; 1006e80583aSopenharmony_ci this.initRemoteWindowProperty(); 1016e80583aSopenharmony_ci } 1026e80583aSopenharmony_ci 1036e80583aSopenharmony_ci initRemoteWindowProperty() { 1046e80583aSopenharmony_ci if (this.remoteAnimationType == RemoteConstants.TYPE_START_APP_FROM_LAUNCHER) { 1056e80583aSopenharmony_ci const res = this.calculateStartAppProperty(); 1066e80583aSopenharmony_ci Log.showInfo(TAG, `initRemoteWindowProperty res: ${JSON.stringify(res)}, mScreenWidth: ${this.mScreenWidth}, mScreenHeight: ${this.mScreenHeight}, startAppTypeFromPageDesktop: ${this.startAppTypeFromPageDesktop}`); 1076e80583aSopenharmony_ci this.remoteWindowScaleX = res.startAppCalculateScaleX; 1086e80583aSopenharmony_ci this.remoteWindowScaleY = res.startAppCalculateScaleY; 1096e80583aSopenharmony_ci this.remoteWindowTranslateX = res.startAppCalculateTranslateX; 1106e80583aSopenharmony_ci this.remoteWindowTranslateY = res.startAppCalculateTranslateY; 1116e80583aSopenharmony_ci this.remoteWindowWindowAlpha = 0.0; 1126e80583aSopenharmony_ci this.remoteWindowRadius = 96; 1136e80583aSopenharmony_ci 1146e80583aSopenharmony_ci this.startAppIconWindowAlpha = 1.0; 1156e80583aSopenharmony_ci this.startAppIconScaleX = 1.0; 1166e80583aSopenharmony_ci this.startAppIconScaleY = 1.0; 1176e80583aSopenharmony_ci this.startAppIconTranslateX = 0.0; 1186e80583aSopenharmony_ci this.startAppIconTranslateY = 0.0; 1196e80583aSopenharmony_ci this.count = 1; 1206e80583aSopenharmony_ci } else if (this.remoteAnimationType == RemoteConstants.TYPE_START_APP_FROM_RECENT) { 1216e80583aSopenharmony_ci } else if (this.remoteAnimationType == RemoteConstants.TYPE_START_APP_FROM_OTHER) { 1226e80583aSopenharmony_ci } else if (this.remoteAnimationType == RemoteConstants.TYPE_APP_TRANSITION) { 1236e80583aSopenharmony_ci this.remoteWindowScaleX = 1.0; 1246e80583aSopenharmony_ci this.remoteWindowScaleY = 1.0; 1256e80583aSopenharmony_ci this.remoteWindowTranslateX = px2vp(this.target?.windowBounds.width - this.target?.windowBounds.left); 1266e80583aSopenharmony_ci this.remoteWindowTranslateY = 0.0; 1276e80583aSopenharmony_ci this.remoteWindowWindowAlpha = 1.0; 1286e80583aSopenharmony_ci this.remoteWindowRadius = 12; 1296e80583aSopenharmony_ci 1306e80583aSopenharmony_ci this.startAppIconScaleX = 1.0; 1316e80583aSopenharmony_ci this.startAppIconScaleY = 1.0; 1326e80583aSopenharmony_ci this.startAppIconTranslateX = 0.0; 1336e80583aSopenharmony_ci this.startAppIconTranslateY = 0.0; 1346e80583aSopenharmony_ci this.startAppIconWindowAlpha = 1.0; 1356e80583aSopenharmony_ci } else if (this.remoteAnimationType == RemoteConstants.TYPE_MINIMIZE_WINDOW) { 1366e80583aSopenharmony_ci this.remoteWindowScaleX = 1.0; 1376e80583aSopenharmony_ci this.remoteWindowScaleY = 1.0; 1386e80583aSopenharmony_ci this.remoteWindowTranslateX = 0.0; 1396e80583aSopenharmony_ci this.remoteWindowTranslateY = 0.0; 1406e80583aSopenharmony_ci this.remoteWindowWindowAlpha = 1.0; 1416e80583aSopenharmony_ci this.remoteWindowRadius = 12; 1426e80583aSopenharmony_ci 1436e80583aSopenharmony_ci const res = this.calculateCloseAppProperty(); 1446e80583aSopenharmony_ci this.startAppIconScaleX = res.closeAppCalculateScaleX; 1456e80583aSopenharmony_ci this.startAppIconScaleY = res.closeAppCalculateScaleY; 1466e80583aSopenharmony_ci this.startAppIconTranslateX = -res.closeAppCalculateTranslateX; 1476e80583aSopenharmony_ci this.startAppIconTranslateY = -res.closeAppCalculateTranslateY; 1486e80583aSopenharmony_ci this.startAppIconWindowAlpha = 0.0; 1496e80583aSopenharmony_ci } else if (this.remoteAnimationType == RemoteConstants.TYPE_CLOSE_WINDOW) { 1506e80583aSopenharmony_ci this.remoteWindowScaleX = 1.0; 1516e80583aSopenharmony_ci this.remoteWindowScaleY = 1.0; 1526e80583aSopenharmony_ci this.remoteWindowTranslateX = 0.0; 1536e80583aSopenharmony_ci this.remoteWindowTranslateY = 0.0; 1546e80583aSopenharmony_ci this.remoteWindowRadius = 12; 1556e80583aSopenharmony_ci this.remoteWindowWindowAlpha = 1.0; 1566e80583aSopenharmony_ci 1576e80583aSopenharmony_ci this.startAppIconScaleX = 1.0; 1586e80583aSopenharmony_ci this.startAppIconScaleY = 1.0; 1596e80583aSopenharmony_ci this.startAppIconTranslateX = 0.0; 1606e80583aSopenharmony_ci this.startAppIconTranslateY = 0.0; 1616e80583aSopenharmony_ci this.startAppIconWindowAlpha = 0.0; 1626e80583aSopenharmony_ci } 1636e80583aSopenharmony_ci } 1646e80583aSopenharmony_ci 1656e80583aSopenharmony_ci calculateStartAppProperty() { 1666e80583aSopenharmony_ci let startAppCalculate = new StartAppCalculate(); 1676e80583aSopenharmony_ci Log.showInfo(TAG, `calculateStartAppProperty appIconSize: ${this.iconInfo?.appIconSize}, windowBounds: ${JSON.stringify(this.target?.windowBounds)}, 1686e80583aSopenharmony_ci appIconPosition: [${this.iconInfo?.appIconPositionX}, ${this.iconInfo?.appIconPositionY}], appIconPositionY: ${this.startAppTypeFromPageDesktop}`); 1696e80583aSopenharmony_ci startAppCalculate.startAppCalculateScaleX = this.iconInfo?.appIconSize / px2vp(this.target?.windowBounds.width); 1706e80583aSopenharmony_ci startAppCalculate.startAppCalculateTranslateX = 1716e80583aSopenharmony_ci this.iconInfo?.appIconPositionX + this.iconInfo?.appIconSize / 2 - 1726e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.left) + px2vp(this.target?.windowBounds.width) / 2); 1736e80583aSopenharmony_ci 1746e80583aSopenharmony_ci if (this.startAppTypeFromPageDesktop === CommonConstants.OVERLAY_TYPE_CARD) { 1756e80583aSopenharmony_ci startAppCalculate.startAppCalculateScaleY = 1766e80583aSopenharmony_ci this.iconInfo?.appIconHeight / px2vp(this.target?.windowBounds.height); 1776e80583aSopenharmony_ci startAppCalculate.startAppCalculateTranslateY = 1786e80583aSopenharmony_ci this.iconInfo?.appIconPositionY + this.iconInfo?.appIconHeight / 2 - 1796e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.top) + px2vp(this.target?.windowBounds.height) / 2); 1806e80583aSopenharmony_ci } else { 1816e80583aSopenharmony_ci startAppCalculate.startAppCalculateScaleY = this.iconInfo?.appIconSize / px2vp(this.target?.windowBounds.height); 1826e80583aSopenharmony_ci startAppCalculate.startAppCalculateTranslateY = 1836e80583aSopenharmony_ci this.iconInfo?.appIconPositionY + this.iconInfo?.appIconSize / 2 - 1846e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.top) + px2vp(this.target?.windowBounds.height) / 2); 1856e80583aSopenharmony_ci } 1866e80583aSopenharmony_ci return startAppCalculate; 1876e80583aSopenharmony_ci } 1886e80583aSopenharmony_ci 1896e80583aSopenharmony_ci calculateCloseAppProperty() { 1906e80583aSopenharmony_ci let closeAppCalculate = new CloseAppCalculate(); 1916e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateScaleX = px2vp(this.target?.windowBounds.width) / this.iconInfo?.appIconSize; 1926e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateTranslateX = 1936e80583aSopenharmony_ci this.iconInfo?.appIconPositionX + this.iconInfo?.appIconSize / 2 - 1946e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.left) + px2vp(this.target?.windowBounds.width) / 2); 1956e80583aSopenharmony_ci if (this.startAppTypeFromPageDesktop === CommonConstants.OVERLAY_TYPE_CARD) { 1966e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateScaleY = 1976e80583aSopenharmony_ci px2vp(this.target?.windowBounds.height) / this.iconInfo?.appIconHeight; 1986e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateTranslateY = 1996e80583aSopenharmony_ci this.iconInfo?.appIconPositionY + this.iconInfo?.appIconHeight / 2 - 2006e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.top) + px2vp(this.target?.windowBounds.height) / 2); 2016e80583aSopenharmony_ci } else { 2026e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateScaleY = px2vp(this.target?.windowBounds.height) / this.iconInfo?.appIconSize; 2036e80583aSopenharmony_ci closeAppCalculate.closeAppCalculateTranslateY = 2046e80583aSopenharmony_ci this.iconInfo?.appIconPositionY + this.iconInfo?.appIconSize / 2 - 2056e80583aSopenharmony_ci (px2vp(this.target?.windowBounds.top) + px2vp(this.target?.windowBounds.height) / 2); 2066e80583aSopenharmony_ci } 2076e80583aSopenharmony_ci return closeAppCalculate; 2086e80583aSopenharmony_ci } 2096e80583aSopenharmony_ci} 2106e80583aSopenharmony_ci 2116e80583aSopenharmony_ciclass SelfWindowAnimationController extends WindowAnimationControllerImpl { 2126e80583aSopenharmony_ci public mCloseAppManager: CloseAppManager; 2136e80583aSopenharmony_ci public mLastRemoteVo: RemoteVo; 2146e80583aSopenharmony_ci public calculateAppProperty: ( 2156e80583aSopenharmony_ci remoteVo: RemoteVo, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback 2166e80583aSopenharmony_ci ) => void 2176e80583aSopenharmony_ci public getRemoteWindowVo: (remoteWindowKey: string) => RemoteVo | null; 2186e80583aSopenharmony_ci public pushRemoteVoIntoList: (remoteVo: RemoteVo) => void; 2196e80583aSopenharmony_ci 2206e80583aSopenharmony_ci constructor(mCloseAppManager: CloseAppManager, mLastRemoteVo: RemoteVo, 2216e80583aSopenharmony_ci getRemoteWindowVo: (remoteWindowKey: string) => RemoteVo | null, 2226e80583aSopenharmony_ci pushRemoteVoIntoList: (remoteVo: RemoteVo) => void, 2236e80583aSopenharmony_ci calculateAppProperty: (remoteVo: RemoteVo, 2246e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) => void) { 2256e80583aSopenharmony_ci super(); 2266e80583aSopenharmony_ci this.mCloseAppManager = mCloseAppManager; 2276e80583aSopenharmony_ci this.mLastRemoteVo = mLastRemoteVo; 2286e80583aSopenharmony_ci this.calculateAppProperty = calculateAppProperty; 2296e80583aSopenharmony_ci this.getRemoteWindowVo = getRemoteWindowVo; 2306e80583aSopenharmony_ci this.pushRemoteVoIntoList = pushRemoteVoIntoList; 2316e80583aSopenharmony_ci } 2326e80583aSopenharmony_ci onStartAppFromLauncher(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, 2336e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 2346e80583aSopenharmony_ci Log.showInfo(TAG, 'remote window animaion onStartAppFromLauncher'); 2356e80583aSopenharmony_ci const remoteWindowKey = 2366e80583aSopenharmony_ci startingWindowTarget.bundleName + startingWindowTarget.abilityName + startingWindowTarget.missionId; 2376e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 2386e80583aSopenharmony_ci const appItemInfo: StartAppItemInfo = AppStorage.get('startAppItemInfo') as StartAppItemInfo; 2396e80583aSopenharmony_ci const startAppIconInfo: StartAppIconInfo = AppStorage.get('startAppIconInfo') as StartAppIconInfo; 2406e80583aSopenharmony_ci let remoteVo: RemoteVo | null = this.getRemoteWindowVo(remoteWindowKey); 2416e80583aSopenharmony_ci if (remoteVo) { 2426e80583aSopenharmony_ci remoteVo.remoteAnimationType = RemoteConstants.TYPE_START_APP_FROM_LAUNCHER; 2436e80583aSopenharmony_ci remoteVo.target = startingWindowTarget; 2446e80583aSopenharmony_ci remoteVo.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 2456e80583aSopenharmony_ci remoteVo.iconInfo = startAppIconInfo; 2466e80583aSopenharmony_ci remoteVo.appItemInfo = appItemInfo; 2476e80583aSopenharmony_ci remoteVo.count = remoteVo.count + 1; 2486e80583aSopenharmony_ci } else { 2496e80583aSopenharmony_ci remoteVo = new RemoteVo( 2506e80583aSopenharmony_ci RemoteConstants.TYPE_START_APP_FROM_LAUNCHER, 2516e80583aSopenharmony_ci startAppTypeFromPageDesktop, 2526e80583aSopenharmony_ci startingWindowTarget, 2536e80583aSopenharmony_ci startAppIconInfo, 2546e80583aSopenharmony_ci appItemInfo, 2556e80583aSopenharmony_ci undefined, 2566e80583aSopenharmony_ci finishCallback 2576e80583aSopenharmony_ci ); 2586e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 2596e80583aSopenharmony_ci } 2606e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 2616e80583aSopenharmony_ci AppStorage.setOrCreate(remoteWindowKey, remoteVo.count); 2626e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 2636e80583aSopenharmony_ci super.onStartAppFromLauncher(startingWindowTarget, finishCallback); 2646e80583aSopenharmony_ci } 2656e80583aSopenharmony_ci 2666e80583aSopenharmony_ci onStartAppFromRecent(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, 2676e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 2686e80583aSopenharmony_ci Log.showInfo(TAG, 'remote window animaion onStartAppFromRecent'); 2696e80583aSopenharmony_ci const remoteWindowKey = 2706e80583aSopenharmony_ci startingWindowTarget.bundleName + startingWindowTarget.abilityName + startingWindowTarget.missionId; 2716e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 2726e80583aSopenharmony_ci const appItemInfo: StartAppItemInfo = AppStorage.get('startAppItemInfo') as StartAppItemInfo; 2736e80583aSopenharmony_ci const startAppIconInfo: StartAppIconInfo = AppStorage.get('startAppIconInfo') as StartAppIconInfo; 2746e80583aSopenharmony_ci let remoteVo: RemoteVo | null = this.getRemoteWindowVo(remoteWindowKey); 2756e80583aSopenharmony_ci if (remoteVo) { 2766e80583aSopenharmony_ci remoteVo.remoteAnimationType = RemoteConstants.TYPE_START_APP_FROM_LAUNCHER; 2776e80583aSopenharmony_ci remoteVo.target = startingWindowTarget; 2786e80583aSopenharmony_ci remoteVo.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 2796e80583aSopenharmony_ci remoteVo.iconInfo = startAppIconInfo; 2806e80583aSopenharmony_ci remoteVo.appItemInfo = appItemInfo; 2816e80583aSopenharmony_ci remoteVo.count = remoteVo.count + 1; 2826e80583aSopenharmony_ci } else { 2836e80583aSopenharmony_ci remoteVo = new RemoteVo( 2846e80583aSopenharmony_ci RemoteConstants.TYPE_START_APP_FROM_LAUNCHER, 2856e80583aSopenharmony_ci startAppTypeFromPageDesktop, 2866e80583aSopenharmony_ci startingWindowTarget, 2876e80583aSopenharmony_ci startAppIconInfo, 2886e80583aSopenharmony_ci appItemInfo, 2896e80583aSopenharmony_ci undefined, 2906e80583aSopenharmony_ci finishCallback 2916e80583aSopenharmony_ci ); 2926e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 2936e80583aSopenharmony_ci } 2946e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 2956e80583aSopenharmony_ci AppStorage.setOrCreate(remoteWindowKey, remoteVo.count); 2966e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 2976e80583aSopenharmony_ci super.onStartAppFromRecent(startingWindowTarget, finishCallback); 2986e80583aSopenharmony_ci } 2996e80583aSopenharmony_ci 3006e80583aSopenharmony_ci onStartAppFromOther(startingWindowTarget: windowAnimationManager.WindowAnimationTarget, 3016e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 3026e80583aSopenharmony_ci Log.showInfo(TAG, 'remote window animaion onStartAppFromOther'); 3036e80583aSopenharmony_ci const remoteWindowKey = 3046e80583aSopenharmony_ci startingWindowTarget.bundleName + startingWindowTarget.abilityName + startingWindowTarget.missionId; 3056e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 3066e80583aSopenharmony_ci AppStorage.setOrCreate('startAppItemInfo', {} as StartAppItemInfo); 3076e80583aSopenharmony_ci AppStorage.setOrCreate('startAppIconInfo', {} as StartAppIconInfo); 3086e80583aSopenharmony_ci const appItemInfo: StartAppItemInfo = AppStorage.get('startAppItemInfo') as StartAppItemInfo; 3096e80583aSopenharmony_ci const startAppIconInfo: StartAppIconInfo = AppStorage.get('startAppIconInfo') as StartAppIconInfo; 3106e80583aSopenharmony_ci let remoteVo: RemoteVo | null = this.getRemoteWindowVo(remoteWindowKey); 3116e80583aSopenharmony_ci if (remoteVo) { 3126e80583aSopenharmony_ci remoteVo.remoteAnimationType = RemoteConstants.TYPE_START_APP_FROM_LAUNCHER; 3136e80583aSopenharmony_ci remoteVo.target = startingWindowTarget; 3146e80583aSopenharmony_ci remoteVo.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 3156e80583aSopenharmony_ci remoteVo.iconInfo = startAppIconInfo; 3166e80583aSopenharmony_ci remoteVo.appItemInfo = appItemInfo; 3176e80583aSopenharmony_ci remoteVo.count = remoteVo.count + 1; 3186e80583aSopenharmony_ci } else { 3196e80583aSopenharmony_ci remoteVo = new RemoteVo( 3206e80583aSopenharmony_ci RemoteConstants.TYPE_START_APP_FROM_LAUNCHER, 3216e80583aSopenharmony_ci startAppTypeFromPageDesktop, 3226e80583aSopenharmony_ci startingWindowTarget, 3236e80583aSopenharmony_ci startAppIconInfo, 3246e80583aSopenharmony_ci appItemInfo, 3256e80583aSopenharmony_ci undefined, 3266e80583aSopenharmony_ci finishCallback 3276e80583aSopenharmony_ci ); 3286e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 3296e80583aSopenharmony_ci } 3306e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 3316e80583aSopenharmony_ci AppStorage.setOrCreate(remoteWindowKey, remoteVo.count); 3326e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 3336e80583aSopenharmony_ci super.onStartAppFromOther(startingWindowTarget, finishCallback); 3346e80583aSopenharmony_ci } 3356e80583aSopenharmony_ci 3366e80583aSopenharmony_ci onAppTransition(fromWindowTarget: windowAnimationManager.WindowAnimationTarget, 3376e80583aSopenharmony_ci toWindowTarget: windowAnimationManager.WindowAnimationTarget, 3386e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 3396e80583aSopenharmony_ci Log.showInfo(TAG, 'remote window animaion onAppTransition'); 3406e80583aSopenharmony_ci const remoteWindowKey = toWindowTarget.bundleName + toWindowTarget.abilityName + toWindowTarget.missionId; 3416e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 3426e80583aSopenharmony_ci const remoteVo = new RemoteVo( 3436e80583aSopenharmony_ci RemoteConstants.TYPE_APP_TRANSITION, 3446e80583aSopenharmony_ci startAppTypeFromPageDesktop, 3456e80583aSopenharmony_ci toWindowTarget, 3466e80583aSopenharmony_ci {} as StartAppIconInfo, 3476e80583aSopenharmony_ci {} as StartAppItemInfo, 3486e80583aSopenharmony_ci fromWindowTarget, 3496e80583aSopenharmony_ci finishCallback 3506e80583aSopenharmony_ci ); 3516e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 3526e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 3536e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 3546e80583aSopenharmony_ci super.onAppTransition(fromWindowTarget, toWindowTarget, finishCallback); 3556e80583aSopenharmony_ci } 3566e80583aSopenharmony_ci 3576e80583aSopenharmony_ci onMinimizeWindow(minimizingWindowTarget: windowAnimationManager.WindowAnimationTarget, 3586e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 3596e80583aSopenharmony_ci Log.showInfo(TAG, `remote window animaion onMinimizeWindow`); 3606e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 3616e80583aSopenharmony_ci const appInfo: StartAppInfo = this.mCloseAppManager.getAppInfo(minimizingWindowTarget); 3626e80583aSopenharmony_ci const remoteWindowKey = 3636e80583aSopenharmony_ci minimizingWindowTarget.bundleName + minimizingWindowTarget.abilityName + minimizingWindowTarget.missionId; 3646e80583aSopenharmony_ci let remoteVo: RemoteVo | null = this.getRemoteWindowVo(remoteWindowKey); 3656e80583aSopenharmony_ci if (appInfo.appItemInfo?.page) { 3666e80583aSopenharmony_ci AppStorage.setOrCreate('pageIndex', appInfo.appItemInfo?.page); 3676e80583aSopenharmony_ci } 3686e80583aSopenharmony_ci if (remoteVo) { 3696e80583aSopenharmony_ci remoteVo.remoteAnimationType = RemoteConstants.TYPE_MINIMIZE_WINDOW; 3706e80583aSopenharmony_ci remoteVo.target = minimizingWindowTarget; 3716e80583aSopenharmony_ci remoteVo.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 3726e80583aSopenharmony_ci remoteVo.iconInfo = appInfo.iconInfo; 3736e80583aSopenharmony_ci remoteVo.appItemInfo = appInfo.appItemInfo; 3746e80583aSopenharmony_ci remoteVo.count = remoteVo.count + 1; 3756e80583aSopenharmony_ci } else { 3766e80583aSopenharmony_ci remoteVo = new RemoteVo( 3776e80583aSopenharmony_ci RemoteConstants.TYPE_MINIMIZE_WINDOW, 3786e80583aSopenharmony_ci startAppTypeFromPageDesktop, 3796e80583aSopenharmony_ci minimizingWindowTarget, 3806e80583aSopenharmony_ci appInfo.iconInfo, 3816e80583aSopenharmony_ci appInfo.appItemInfo, 3826e80583aSopenharmony_ci undefined, 3836e80583aSopenharmony_ci finishCallback 3846e80583aSopenharmony_ci ); 3856e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 3866e80583aSopenharmony_ci } 3876e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 3886e80583aSopenharmony_ci AppStorage.setOrCreate(remoteWindowKey, remoteVo.count); 3896e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 3906e80583aSopenharmony_ci super.onMinimizeWindow(minimizingWindowTarget, finishCallback); 3916e80583aSopenharmony_ci } 3926e80583aSopenharmony_ci 3936e80583aSopenharmony_ci onCloseWindow(closingWindowTarget: windowAnimationManager.WindowAnimationTarget, 3946e80583aSopenharmony_ci finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 3956e80583aSopenharmony_ci Log.showInfo(TAG, 'remote window animaion onCloseWindow'); 3966e80583aSopenharmony_ci const startAppTypeFromPageDesktop: number = AppStorage.get('startAppTypeFromPageDesktop') as number; 3976e80583aSopenharmony_ci const appInfo: StartAppInfo = this.mCloseAppManager.getAppInfo(closingWindowTarget); 3986e80583aSopenharmony_ci const remoteWindowKey = 3996e80583aSopenharmony_ci closingWindowTarget.bundleName + closingWindowTarget.abilityName + closingWindowTarget.missionId; 4006e80583aSopenharmony_ci let remoteVo: RemoteVo | null = this.getRemoteWindowVo(remoteWindowKey); 4016e80583aSopenharmony_ci if (remoteVo) { 4026e80583aSopenharmony_ci remoteVo.remoteAnimationType = RemoteConstants.TYPE_MINIMIZE_WINDOW; 4036e80583aSopenharmony_ci remoteVo.target = closingWindowTarget; 4046e80583aSopenharmony_ci remoteVo.startAppTypeFromPageDesktop = startAppTypeFromPageDesktop; 4056e80583aSopenharmony_ci remoteVo.iconInfo = appInfo.iconInfo; 4066e80583aSopenharmony_ci remoteVo.appItemInfo = appInfo.appItemInfo; 4076e80583aSopenharmony_ci } else { 4086e80583aSopenharmony_ci remoteVo = new RemoteVo( 4096e80583aSopenharmony_ci RemoteConstants.TYPE_MINIMIZE_WINDOW, 4106e80583aSopenharmony_ci startAppTypeFromPageDesktop, 4116e80583aSopenharmony_ci closingWindowTarget, 4126e80583aSopenharmony_ci appInfo.iconInfo, 4136e80583aSopenharmony_ci appInfo.appItemInfo, 4146e80583aSopenharmony_ci undefined, 4156e80583aSopenharmony_ci finishCallback 4166e80583aSopenharmony_ci ); 4176e80583aSopenharmony_ci this.mLastRemoteVo = remoteVo; 4186e80583aSopenharmony_ci } 4196e80583aSopenharmony_ci this.pushRemoteVoIntoList(remoteVo); 4206e80583aSopenharmony_ci AppStorage.setOrCreate(remoteWindowKey, remoteVo.count); 4216e80583aSopenharmony_ci this.calculateAppProperty(remoteVo, finishCallback); 4226e80583aSopenharmony_ci super.onCloseWindow(closingWindowTarget, finishCallback); 4236e80583aSopenharmony_ci } 4246e80583aSopenharmony_ci} 4256e80583aSopenharmony_ci 4266e80583aSopenharmony_ci@Component 4276e80583aSopenharmony_ciexport struct RemoteWindowWrapper { 4286e80583aSopenharmony_ci private mCloseAppManager?: CloseAppManager; 4296e80583aSopenharmony_ci private mLastRemoteVo?: RemoteVo; 4306e80583aSopenharmony_ci @StorageLink('remoteWindowList') remoteWindowList: RemoteVo[] = []; 4316e80583aSopenharmony_ci 4326e80583aSopenharmony_ci getRemoteWindowVo(remoteWindowKey: string): RemoteVo | null { 4336e80583aSopenharmony_ci const remoteVoIndex = this.remoteWindowList.findIndex(item => { 4346e80583aSopenharmony_ci return (item.remoteWindowKey) == remoteWindowKey; 4356e80583aSopenharmony_ci }) 4366e80583aSopenharmony_ci if (remoteVoIndex != -1) { 4376e80583aSopenharmony_ci return this.remoteWindowList[remoteVoIndex]; 4386e80583aSopenharmony_ci } else if (this.mLastRemoteVo && this.mLastRemoteVo.remoteWindowKey === remoteWindowKey) { 4396e80583aSopenharmony_ci return this.mLastRemoteVo; 4406e80583aSopenharmony_ci } else { 4416e80583aSopenharmony_ci return null; 4426e80583aSopenharmony_ci } 4436e80583aSopenharmony_ci } 4446e80583aSopenharmony_ci 4456e80583aSopenharmony_ci private pushRemoteVoIntoList(remoteVo: RemoteVo): void { 4466e80583aSopenharmony_ci const remoteVoIndex = this.remoteWindowList.findIndex(item => { 4476e80583aSopenharmony_ci return (item.remoteWindowKey) == remoteVo.remoteWindowKey; 4486e80583aSopenharmony_ci }) 4496e80583aSopenharmony_ci if (remoteVoIndex == -1) { 4506e80583aSopenharmony_ci this.remoteWindowList.push(remoteVo); 4516e80583aSopenharmony_ci } 4526e80583aSopenharmony_ci } 4536e80583aSopenharmony_ci 4546e80583aSopenharmony_ci aboutToAppear(): void { 4556e80583aSopenharmony_ci this.mCloseAppManager = CloseAppManager.getInstance(); 4566e80583aSopenharmony_ci let control = new SelfWindowAnimationController(this.mCloseAppManager, this.mLastRemoteVo as RemoteVo, 4576e80583aSopenharmony_ci this.getRemoteWindowVo, this.pushRemoteVoIntoList, this.calculateAppProperty); 4586e80583aSopenharmony_ci 4596e80583aSopenharmony_ci windowAnimationManager.setController(control); 4606e80583aSopenharmony_ci } 4616e80583aSopenharmony_ci 4626e80583aSopenharmony_ci removeRemoteWindowFromList(remoteWindowKey: string): void { 4636e80583aSopenharmony_ci const remoteWindowIndex = this.remoteWindowList.findIndex(item => { 4646e80583aSopenharmony_ci return item.remoteWindowKey === remoteWindowKey; 4656e80583aSopenharmony_ci }); 4666e80583aSopenharmony_ci if (remoteWindowIndex != CommonConstants.INVALID_VALUE) { 4676e80583aSopenharmony_ci this.remoteWindowList.splice(remoteWindowIndex, 1); 4686e80583aSopenharmony_ci Log.showDebug(TAG, `removeRemoteWindowFromList remoteWindowList length: ${this.remoteWindowList.length}`); 4696e80583aSopenharmony_ci } 4706e80583aSopenharmony_ci } 4716e80583aSopenharmony_ci 4726e80583aSopenharmony_ci calculateAppProperty(remoteVo: RemoteVo, finishCallback: windowAnimationManager.WindowAnimationFinishedCallback) { 4736e80583aSopenharmony_ci Log.showDebug(TAG, `calculateAppProperty ${remoteVo.remoteAnimationType}`); 4746e80583aSopenharmony_ci if (remoteVo.remoteAnimationType == RemoteConstants.TYPE_START_APP_FROM_LAUNCHER) { 4756e80583aSopenharmony_ci Trace.start(Trace.CORE_METHOD_START_APP_ANIMATION); 4766e80583aSopenharmony_ci const callback = finishCallback; 4776e80583aSopenharmony_ci const count = remoteVo.count; 4786e80583aSopenharmony_ci localEventManager.sendLocalEventSticky(EventConstants.EVENT_ANIMATION_START_APPLICATION, null); 4796e80583aSopenharmony_ci animateTo({ 4806e80583aSopenharmony_ci duration: 50, 4816e80583aSopenharmony_ci delay: 50, 4826e80583aSopenharmony_ci curve: Curve.Friction, 4836e80583aSopenharmony_ci onFinish: () => { 4846e80583aSopenharmony_ci } 4856e80583aSopenharmony_ci }, () => { 4866e80583aSopenharmony_ci remoteVo.startAppIconWindowAlpha = 0.0; 4876e80583aSopenharmony_ci remoteVo.remoteWindowWindowAlpha = 1.0; 4886e80583aSopenharmony_ci }) 4896e80583aSopenharmony_ci 4906e80583aSopenharmony_ci animateTo({ 4916e80583aSopenharmony_ci duration: 370, 4926e80583aSopenharmony_ci curve: curves.springMotion(0.25, 0.99, 0), 4936e80583aSopenharmony_ci onFinish: () => { 4946e80583aSopenharmony_ci callback.onAnimationFinish(); 4956e80583aSopenharmony_ci Trace.end(Trace.CORE_METHOD_START_APP_ANIMATION); 4966e80583aSopenharmony_ci const startCount: number = AppStorage.get(remoteVo.remoteWindowKey); 4976e80583aSopenharmony_ci Log.showDebug(TAG, `calculateAppProperty ${remoteVo.remoteAnimationType}, count: ${count}, startCount: ${startCount}`); 4986e80583aSopenharmony_ci if (startCount === count) { 4996e80583aSopenharmony_ci this.removeRemoteWindowFromList(remoteVo.remoteWindowKey); 5006e80583aSopenharmony_ci AppStorage.setOrCreate(remoteVo.remoteWindowKey, 0); 5016e80583aSopenharmony_ci } 5026e80583aSopenharmony_ci } 5036e80583aSopenharmony_ci }, () => { 5046e80583aSopenharmony_ci remoteVo.remoteWindowScaleX = 1.0; 5056e80583aSopenharmony_ci remoteVo.remoteWindowScaleY = 1.0; 5066e80583aSopenharmony_ci remoteVo.remoteWindowTranslateX = 0.0; 5076e80583aSopenharmony_ci remoteVo.remoteWindowTranslateY = 0.0; 5086e80583aSopenharmony_ci remoteVo.startAppIconScaleX = remoteVo.mScreenWidth / remoteVo.iconInfo?.appIconSize; 5096e80583aSopenharmony_ci remoteVo.startAppIconTranslateX = 5106e80583aSopenharmony_ci remoteVo.mScreenWidth / 2 - remoteVo.iconInfo?.appIconPositionX - remoteVo.iconInfo?.appIconSize / 2; 5116e80583aSopenharmony_ci remoteVo.remoteWindowRadius = 0; 5126e80583aSopenharmony_ci if (remoteVo.startAppTypeFromPageDesktop === CommonConstants.OVERLAY_TYPE_CARD) { 5136e80583aSopenharmony_ci remoteVo.startAppIconScaleY = remoteVo.mScreenHeight / remoteVo.iconInfo?.appIconHeight; 5146e80583aSopenharmony_ci remoteVo.startAppIconTranslateY = 5156e80583aSopenharmony_ci remoteVo.mScreenHeight / 2 + px2vp(remoteVo.target.windowBounds.top) - 5166e80583aSopenharmony_ci remoteVo.iconInfo?.appIconPositionY - remoteVo.iconInfo?.appIconHeight / 2; 5176e80583aSopenharmony_ci } else { 5186e80583aSopenharmony_ci remoteVo.startAppIconScaleY = remoteVo.mScreenHeight / remoteVo.iconInfo?.appIconSize; 5196e80583aSopenharmony_ci remoteVo.startAppIconTranslateY = 5206e80583aSopenharmony_ci remoteVo.mScreenHeight / 2 + px2vp(remoteVo.target.windowBounds.top) - 5216e80583aSopenharmony_ci remoteVo.iconInfo?.appIconPositionY - remoteVo.iconInfo?.appIconSize / 2; 5226e80583aSopenharmony_ci } 5236e80583aSopenharmony_ci }) 5246e80583aSopenharmony_ci } else if (remoteVo.remoteAnimationType == RemoteConstants.TYPE_MINIMIZE_WINDOW) { 5256e80583aSopenharmony_ci Trace.start(Trace.CORE_METHOD_CLOSE_APP_ANIMATION); 5266e80583aSopenharmony_ci const res = remoteVo.calculateCloseAppProperty(); 5276e80583aSopenharmony_ci const callback = finishCallback; 5286e80583aSopenharmony_ci const count = remoteVo.count; 5296e80583aSopenharmony_ci localEventManager.sendLocalEventSticky(EventConstants.EVENT_ANIMATION_CLOSE_APPLICATION, null); 5306e80583aSopenharmony_ci animateTo({ 5316e80583aSopenharmony_ci duration: 370, 5326e80583aSopenharmony_ci curve: curves.springMotion(0.25, 0.99, 0), 5336e80583aSopenharmony_ci onFinish: () => { 5346e80583aSopenharmony_ci callback.onAnimationFinish(); 5356e80583aSopenharmony_ci Trace.end(Trace.CORE_METHOD_CLOSE_APP_ANIMATION); 5366e80583aSopenharmony_ci const startCount: number = AppStorage.get(remoteVo.remoteWindowKey); 5376e80583aSopenharmony_ci Log.showDebug(TAG, `calculateAppProperty ${remoteVo.remoteAnimationType}, count: ${count}, startCount: ${startCount}`); 5386e80583aSopenharmony_ci if (startCount === count) { 5396e80583aSopenharmony_ci this.removeRemoteWindowFromList(remoteVo.remoteWindowKey); 5406e80583aSopenharmony_ci AppStorage.setOrCreate(remoteVo.remoteWindowKey, 0); 5416e80583aSopenharmony_ci } 5426e80583aSopenharmony_ci } 5436e80583aSopenharmony_ci }, () => { 5446e80583aSopenharmony_ci remoteVo.remoteWindowScaleX = 1 / res.closeAppCalculateScaleX; 5456e80583aSopenharmony_ci remoteVo.remoteWindowScaleY = 1 / res.closeAppCalculateScaleY; 5466e80583aSopenharmony_ci remoteVo.remoteWindowTranslateX = res.closeAppCalculateTranslateX; 5476e80583aSopenharmony_ci remoteVo.remoteWindowTranslateY = res.closeAppCalculateTranslateY; 5486e80583aSopenharmony_ci 5496e80583aSopenharmony_ci remoteVo.startAppIconScaleX = 1.0; 5506e80583aSopenharmony_ci remoteVo.startAppIconScaleY = 1.0; 5516e80583aSopenharmony_ci remoteVo.startAppIconTranslateX = 0.0; 5526e80583aSopenharmony_ci remoteVo.startAppIconTranslateY = 0.0; 5536e80583aSopenharmony_ci remoteVo.remoteWindowRadius = 96; 5546e80583aSopenharmony_ci }) 5556e80583aSopenharmony_ci 5566e80583aSopenharmony_ci animateTo({ 5576e80583aSopenharmony_ci duration: 50, 5586e80583aSopenharmony_ci delay: 50, 5596e80583aSopenharmony_ci curve: Curve.Friction, 5606e80583aSopenharmony_ci onFinish: () => { 5616e80583aSopenharmony_ci } 5626e80583aSopenharmony_ci }, () => { 5636e80583aSopenharmony_ci remoteVo.startAppIconWindowAlpha = 1.0; 5646e80583aSopenharmony_ci remoteVo.remoteWindowWindowAlpha = 0; 5656e80583aSopenharmony_ci }) 5666e80583aSopenharmony_ci } else if (remoteVo.remoteAnimationType == RemoteConstants.TYPE_CLOSE_WINDOW) { 5676e80583aSopenharmony_ci } else if (remoteVo.remoteAnimationType == RemoteConstants.TYPE_APP_TRANSITION) { 5686e80583aSopenharmony_ci const callback = finishCallback; 5696e80583aSopenharmony_ci animateTo({ 5706e80583aSopenharmony_ci duration: 300, 5716e80583aSopenharmony_ci curve: Curve.Friction, 5726e80583aSopenharmony_ci onFinish: () => { 5736e80583aSopenharmony_ci this.removeRemoteWindowFromList(remoteVo.remoteWindowKey); 5746e80583aSopenharmony_ci } 5756e80583aSopenharmony_ci }, () => { 5766e80583aSopenharmony_ci remoteVo.remoteWindowRadius = 0; 5776e80583aSopenharmony_ci remoteVo.remoteWindowTranslateX = 0; 5786e80583aSopenharmony_ci remoteVo.fromRemoteWindowTranslateX = 5796e80583aSopenharmony_ci px2vp(remoteVo.fromWindowTarget?.windowBounds.left - remoteVo.fromWindowTarget?.windowBounds.width); 5806e80583aSopenharmony_ci }) 5816e80583aSopenharmony_ci 5826e80583aSopenharmony_ci animateTo({ 5836e80583aSopenharmony_ci duration: 150, 5846e80583aSopenharmony_ci curve: Curve.Friction, 5856e80583aSopenharmony_ci onFinish: () => { 5866e80583aSopenharmony_ci this.removeRemoteWindowFromList(remoteVo.remoteWindowKey); 5876e80583aSopenharmony_ci } 5886e80583aSopenharmony_ci }, () => { 5896e80583aSopenharmony_ci remoteVo.remoteWindowScaleX = 0.9 5906e80583aSopenharmony_ci remoteVo.remoteWindowScaleY = 0.9 5916e80583aSopenharmony_ci remoteVo.fromRemoteWindowScaleX = 0.9 5926e80583aSopenharmony_ci remoteVo.fromRemoteWindowScaleY = 0.9 5936e80583aSopenharmony_ci }) 5946e80583aSopenharmony_ci 5956e80583aSopenharmony_ci animateTo({ 5966e80583aSopenharmony_ci duration: 350, 5976e80583aSopenharmony_ci delay: 150, 5986e80583aSopenharmony_ci curve: Curve.Friction, 5996e80583aSopenharmony_ci onFinish: () => { 6006e80583aSopenharmony_ci callback.onAnimationFinish(); 6016e80583aSopenharmony_ci this.removeRemoteWindowFromList(remoteVo.remoteWindowKey); 6026e80583aSopenharmony_ci } 6036e80583aSopenharmony_ci }, () => { 6046e80583aSopenharmony_ci remoteVo.remoteWindowScaleX = 1.0 6056e80583aSopenharmony_ci remoteVo.remoteWindowScaleY = 1.0 6066e80583aSopenharmony_ci remoteVo.fromRemoteWindowScaleX = 1.0 6076e80583aSopenharmony_ci remoteVo.fromRemoteWindowScaleY = 1.0 6086e80583aSopenharmony_ci }) 6096e80583aSopenharmony_ci } 6106e80583aSopenharmony_ci } 6116e80583aSopenharmony_ci 6126e80583aSopenharmony_ci build() { 6136e80583aSopenharmony_ci Stack() { 6146e80583aSopenharmony_ci ForEach(this.remoteWindowList, (item: RemoteVo) => { 6156e80583aSopenharmony_ci if (item.remoteAnimationType == RemoteConstants.TYPE_APP_TRANSITION) { 6166e80583aSopenharmony_ci StartAppTransitionRemoteWindow({ 6176e80583aSopenharmony_ci targetInfo: item 6186e80583aSopenharmony_ci }) 6196e80583aSopenharmony_ci } else { 6206e80583aSopenharmony_ci StartAppFromLauncherRemoteWindow({ 6216e80583aSopenharmony_ci targetInfo: item 6226e80583aSopenharmony_ci }) 6236e80583aSopenharmony_ci } 6246e80583aSopenharmony_ci }, (item: RemoteVo) => item.remoteWindowKey) 6256e80583aSopenharmony_ci } 6266e80583aSopenharmony_ci .width(StyleConstants.PERCENTAGE_100) 6276e80583aSopenharmony_ci .height(StyleConstants.PERCENTAGE_100) 6286e80583aSopenharmony_ci .focusable(false) 6296e80583aSopenharmony_ci .enabled(false) 6306e80583aSopenharmony_ci } 6316e80583aSopenharmony_ci} 6326e80583aSopenharmony_ci 6336e80583aSopenharmony_ci@Component 6346e80583aSopenharmony_ciexport struct StartAppFromLauncherRemoteWindow { 6356e80583aSopenharmony_ci @ObjectLink targetInfo: RemoteVo; 6366e80583aSopenharmony_ci 6376e80583aSopenharmony_ci aboutToAppear(): void { 6386e80583aSopenharmony_ci } 6396e80583aSopenharmony_ci 6406e80583aSopenharmony_ci aboutToDisappear(): void { 6416e80583aSopenharmony_ci } 6426e80583aSopenharmony_ci 6436e80583aSopenharmony_ci build() { 6446e80583aSopenharmony_ci Stack() { 6456e80583aSopenharmony_ci Column() { 6466e80583aSopenharmony_ci if (this.targetInfo.startAppTypeFromPageDesktop === CommonConstants.OVERLAY_TYPE_CARD) { 6476e80583aSopenharmony_ci FormComponent({ 6486e80583aSopenharmony_ci id: this.targetInfo.appItemInfo?.cardId as number, 6496e80583aSopenharmony_ci name: this.targetInfo.appItemInfo?.cardName as string, 6506e80583aSopenharmony_ci bundle: this.targetInfo.appItemInfo?.bundleName as string, 6516e80583aSopenharmony_ci ability: this.targetInfo.appItemInfo?.abilityName as string, 6526e80583aSopenharmony_ci module: this.targetInfo.appItemInfo?.moduleName as string, 6536e80583aSopenharmony_ci dimension: this.targetInfo.appItemInfo?.cardDimension 6546e80583aSopenharmony_ci }) 6556e80583aSopenharmony_ci .clip(new Rect({ 6566e80583aSopenharmony_ci width: this.targetInfo.iconInfo?.appIconSize as number, 6576e80583aSopenharmony_ci height: this.targetInfo.iconInfo?.appIconHeight as number, 6586e80583aSopenharmony_ci radius: 24 6596e80583aSopenharmony_ci })) 6606e80583aSopenharmony_ci .size({ 6616e80583aSopenharmony_ci width: this.targetInfo.iconInfo?.appIconSize as number, 6626e80583aSopenharmony_ci height: this.targetInfo.iconInfo?.appIconHeight as number 6636e80583aSopenharmony_ci }) 6646e80583aSopenharmony_ci } else { 6656e80583aSopenharmony_ci OverlayAppIcon({ 6666e80583aSopenharmony_ci iconSize: this.targetInfo.iconInfo?.appIconSize as number, 6676e80583aSopenharmony_ci icon: this.targetInfo.appItemInfo?.icon as ResourceStr 6686e80583aSopenharmony_ci }) 6696e80583aSopenharmony_ci } 6706e80583aSopenharmony_ci } 6716e80583aSopenharmony_ci .translate({ x: this.targetInfo.startAppIconTranslateX as number, 6726e80583aSopenharmony_ci y: this.targetInfo.startAppIconTranslateY as number }) 6736e80583aSopenharmony_ci .scale({ x: this.targetInfo.startAppIconScaleX as number, 6746e80583aSopenharmony_ci y: this.targetInfo.startAppIconScaleY as number }) 6756e80583aSopenharmony_ci .opacity(this.targetInfo.startAppIconWindowAlpha as number) 6766e80583aSopenharmony_ci .position({ 6776e80583aSopenharmony_ci x: this.targetInfo.iconInfo?.appIconPositionX as number, 6786e80583aSopenharmony_ci y: this.targetInfo.iconInfo?.appIconPositionY as number, 6796e80583aSopenharmony_ci }) 6806e80583aSopenharmony_ci 6816e80583aSopenharmony_ci RemoteWindow(this.targetInfo.target) 6826e80583aSopenharmony_ci .translate({ x: this.targetInfo.remoteWindowTranslateX, y: this.targetInfo.remoteWindowTranslateY }) 6836e80583aSopenharmony_ci .scale({ x: this.targetInfo.remoteWindowScaleX, y: this.targetInfo.remoteWindowScaleY }) 6846e80583aSopenharmony_ci .opacity(this.targetInfo.remoteWindowWindowAlpha) 6856e80583aSopenharmony_ci .position({ 6866e80583aSopenharmony_ci x: px2vp(this.targetInfo.target?.windowBounds.left), y: px2vp(this.targetInfo.target?.windowBounds.top) 6876e80583aSopenharmony_ci }) 6886e80583aSopenharmony_ci .width(px2vp(this.targetInfo.target?.windowBounds.width)) 6896e80583aSopenharmony_ci .height(px2vp(this.targetInfo.target?.windowBounds.height)) 6906e80583aSopenharmony_ci .borderRadius(this.targetInfo.remoteWindowRadius) 6916e80583aSopenharmony_ci } 6926e80583aSopenharmony_ci .width(StyleConstants.PERCENTAGE_100) 6936e80583aSopenharmony_ci .height(StyleConstants.PERCENTAGE_100) 6946e80583aSopenharmony_ci .focusable(false) 6956e80583aSopenharmony_ci .enabled(false) 6966e80583aSopenharmony_ci } 6976e80583aSopenharmony_ci} 6986e80583aSopenharmony_ci 6996e80583aSopenharmony_ciclass StartAppItemInfo extends LauncherDragItemInfo { 7006e80583aSopenharmony_ci public icon?: ResourceStr; 7016e80583aSopenharmony_ci} 7026e80583aSopenharmony_ci 7036e80583aSopenharmony_ciinterface StartAppIconInfo { 7046e80583aSopenharmony_ci appIconSize: number; 7056e80583aSopenharmony_ci appIconHeight: number; 7066e80583aSopenharmony_ci appIconPositionX: number; 7076e80583aSopenharmony_ci appIconPositionY: number; 7086e80583aSopenharmony_ci} 7096e80583aSopenharmony_ci 7106e80583aSopenharmony_ciinterface StartAppInfo { 7116e80583aSopenharmony_ci iconInfo: StartAppIconInfo; 7126e80583aSopenharmony_ci appItemInfo: StartAppItemInfo; 7136e80583aSopenharmony_ci} 7146e80583aSopenharmony_ci 7156e80583aSopenharmony_ci@Component 7166e80583aSopenharmony_ciexport struct StartAppTransitionRemoteWindow { 7176e80583aSopenharmony_ci @ObjectLink targetInfo: RemoteVo; 7186e80583aSopenharmony_ci private target?: windowAnimationManager.WindowAnimationTarget; 7196e80583aSopenharmony_ci private mFromWindowTarget?: windowAnimationManager.WindowAnimationTarget = undefined; 7206e80583aSopenharmony_ci private remoteAnimationType: number = 0; 7216e80583aSopenharmony_ci private startAppTypeFromPageDesktop: number = 1; 7226e80583aSopenharmony_ci private mScreenWidth: number = 0; 7236e80583aSopenharmony_ci private mScreenHeight: number = 0; 7246e80583aSopenharmony_ci private startAppIconInfo: StartAppIconInfo = 7256e80583aSopenharmony_ci { appIconSize: 0, 7266e80583aSopenharmony_ci appIconHeight: 0, 7276e80583aSopenharmony_ci appIconPositionX: 0, 7286e80583aSopenharmony_ci appIconPositionY: 0 }; 7296e80583aSopenharmony_ci private mStartAppItemInfo: StartAppItemInfo = new StartAppItemInfo(); 7306e80583aSopenharmony_ci private mFinishCallback?: windowAnimationManager.WindowAnimationFinishedCallback; 7316e80583aSopenharmony_ci private remoteWindowKey?: string; 7326e80583aSopenharmony_ci 7336e80583aSopenharmony_ci aboutToAppear(): void { 7346e80583aSopenharmony_ci this.target = this.targetInfo.target; 7356e80583aSopenharmony_ci this.mFromWindowTarget = this.targetInfo.fromWindowTarget; 7366e80583aSopenharmony_ci this.mFinishCallback = this.targetInfo.finishCallback; 7376e80583aSopenharmony_ci this.remoteWindowKey = this.targetInfo.remoteWindowKey; 7386e80583aSopenharmony_ci this.mStartAppItemInfo = this.targetInfo.appItemInfo; 7396e80583aSopenharmony_ci this.mScreenWidth = px2vp(this.target.windowBounds.width); 7406e80583aSopenharmony_ci this.mScreenHeight = px2vp(this.target.windowBounds.height); 7416e80583aSopenharmony_ci } 7426e80583aSopenharmony_ci 7436e80583aSopenharmony_ci aboutToDisappear() { 7446e80583aSopenharmony_ci } 7456e80583aSopenharmony_ci 7466e80583aSopenharmony_ci build() { 7476e80583aSopenharmony_ci Stack() { 7486e80583aSopenharmony_ci Column() { 7496e80583aSopenharmony_ci RemoteWindow(this.targetInfo.target) 7506e80583aSopenharmony_ci .position({ x: px2vp(this.target?.windowBounds.left as number), 7516e80583aSopenharmony_ci y: px2vp(this.target?.windowBounds.top as number) }) 7526e80583aSopenharmony_ci .width(px2vp(this.target?.windowBounds.width as number)) 7536e80583aSopenharmony_ci .height(px2vp(this.target?.windowBounds.height as number)) 7546e80583aSopenharmony_ci .translate({ x: this.targetInfo.remoteWindowTranslateX, y: this.targetInfo.remoteWindowTranslateY }) 7556e80583aSopenharmony_ci .scale({ x: this.targetInfo.remoteWindowScaleX, y: this.targetInfo.remoteWindowScaleY }) 7566e80583aSopenharmony_ci .opacity(this.targetInfo.remoteWindowWindowAlpha) 7576e80583aSopenharmony_ci .borderRadius(this.targetInfo.remoteWindowRadius) 7586e80583aSopenharmony_ci 7596e80583aSopenharmony_ci RemoteWindow(this.mFromWindowTarget) 7606e80583aSopenharmony_ci .translate({ x: this.targetInfo.fromRemoteWindowTranslateX, y: this.targetInfo.fromRemoteWindowTranslateY }) 7616e80583aSopenharmony_ci .scale({ x: this.targetInfo.fromRemoteWindowScaleX, y: this.targetInfo.fromRemoteWindowScaleY }) 7626e80583aSopenharmony_ci .opacity(this.targetInfo.fromRemoteWindowWindowAlpha) 7636e80583aSopenharmony_ci .position({ 7646e80583aSopenharmony_ci x: px2vp(this.mFromWindowTarget?.windowBounds.left as number), 7656e80583aSopenharmony_ci y: px2vp(this.mFromWindowTarget?.windowBounds.top as number) 7666e80583aSopenharmony_ci }) 7676e80583aSopenharmony_ci .width(px2vp(this.mFromWindowTarget?.windowBounds.width as number)) 7686e80583aSopenharmony_ci .height(px2vp(this.mFromWindowTarget?.windowBounds.height as number)) 7696e80583aSopenharmony_ci .borderRadius(this.targetInfo.remoteWindowRadius) 7706e80583aSopenharmony_ci } 7716e80583aSopenharmony_ci .width(StyleConstants.PERCENTAGE_100) 7726e80583aSopenharmony_ci .height(StyleConstants.PERCENTAGE_100) 7736e80583aSopenharmony_ci .focusable(false) 7746e80583aSopenharmony_ci .enabled(false) 7756e80583aSopenharmony_ci } 7766e80583aSopenharmony_ci } 7776e80583aSopenharmony_ci}