1/** 2 * Copyright (c) 2021-2022 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 16import { 17 Log, 18 AppItemInfo, 19 CardItemInfo, 20 FolderData, 21 CheckEmptyUtils 22} from '@ohos/common'; 23import { Trace } from '@ohos/common'; 24import { EventConstants } from '@ohos/common'; 25import { StyleConstants } from '@ohos/common'; 26import { CommonConstants } from '@ohos/common'; 27import { PresetStyleConstants } from '@ohos/common'; 28import { AppName } from '@ohos/common/component'; 29import { AppBubble } from '@ohos/common/component'; 30import { UninstallDialog } from '@ohos/common/component'; 31import { FormManagerDialog } from '@ohos/common/component'; 32import { ResourceManager } from '@ohos/common'; 33import { localEventManager } from '@ohos/common'; 34import { InputMethodManager } from '@ohos/common'; 35import { BigFolderModel } from '../model/BigFolderModel'; 36import { BigFolderViewModel } from '../viewmodel/BigFolderViewModel'; 37import { BigFolderStyleConfig } from '../common/BigFolderStyleConfig'; 38import { BigFolderConstants } from '../common/constants/BigFolderConstants'; 39import { BigFolderStyleConstants } from '../common/constants/BigFolderStyleConstants'; 40import FolderAppListDialog from '../common/uicomponents/FolderAppListDialog'; 41import BigFolderStartAppHandler from '../common/BigFolderStartAppHandler'; 42import { PageDesktopViewModel } from '../../../../../../pagedesktop/src/main/ets/default/viewmodel/PageDesktopViewModel'; 43 44const TAG = 'FolderOpenComponent'; 45const DOUBLE_CLICK_COUNT = 2; 46 47interface FolderOpenLayoutTable { 48 id: number; 49 layout: string; 50 name: string; 51 row: number; 52 column: number; 53 checked: boolean; 54} 55 56const FOLDER_CLOSE_DELAY = 500; 57let mBigFolderViewModel: BigFolderViewModel; 58let mBigFolderStyleConfig: BigFolderStyleConfig; 59let mFolderModel: BigFolderModel; 60let mAppNameHeight = BigFolderStyleConstants.DEFAULT_APP_NAME_HEIGHT; 61let mAppItemWidth = BigFolderStyleConstants.DEFAULT_APP_ITEM_WIDTH; 62let mAppNameSize = BigFolderStyleConstants.DEFAULT_APP_NAME_SIZE; 63let mAppIconSize = BigFolderStyleConstants.DEFAULT_APP_ITEM_WIDTH; 64let mAddIconSize = BigFolderStyleConstants.DEFAULT_ADD_APP_SIZE; 65let mNameLines = PresetStyleConstants.DEFAULT_APP_NAME_LINES; 66let mIconNameMargin = PresetStyleConstants.DEFAULT_ICON_NAME_GAP; 67let mSwiperHeight = 0; 68let mGridWidth = 0; 69let mGridHeight = 0; 70let mGridPadding = 0; 71let mGridMarginTop = 0; 72let mFolderOpenTitle = 0; 73let mGridIconTopPadding = 0; 74let isPad = false; 75let mBigFolderStartAppHandler: BigFolderStartAppHandler; 76 77@Component 78export struct FolderOpenComponent { 79 @State withBlur: boolean = true; 80 @StorageLink('openFolderPageIndex') pageIndex: number = 0; 81 @StorageLink('openFolderStatus') @Watch('updateFolderData') openFolderStatus: number = BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE; 82 @State overLayAlpha: number = 0.3; 83 @State isRenaming: boolean = false; 84 @StorageLink('openFolderData') mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' }; 85 @State newFolderName: string = ''; 86 87 aboutToAppear(): void { 88 Log.showInfo(TAG, 'aboutToAppear start'); 89 mBigFolderViewModel = BigFolderViewModel.getInstance(); 90 mBigFolderStartAppHandler = BigFolderStartAppHandler.getInstance(); 91 this.updateStyle(); 92 // Folder dialog data preloading 93 mBigFolderViewModel.getFolderAddAppList(this.mFolderInfo.folderId); 94 mBigFolderViewModel.getFolderAppList(this.mFolderInfo.folderId); 95 this.newFolderName = this.mFolderInfo.folderName; 96 Log.showInfo(TAG, 'aboutToAppear end'); 97 } 98 99 private updateStyle() { 100 isPad = mBigFolderViewModel.getIsPad(); 101 mBigFolderStyleConfig = mBigFolderViewModel.getFolderStyleConfig(); 102 if (mBigFolderStyleConfig == null) { 103 return 104 } 105 mAppItemWidth = mBigFolderStyleConfig.mOpenFolderAppSize; 106 mAppIconSize = mBigFolderStyleConfig.mOpenFolderIconSize; 107 mAddIconSize = mBigFolderStyleConfig.mOpenFolderAddIconSize; 108 mAppNameSize = mBigFolderStyleConfig.mOpenFolderAppNameSize; 109 mAppNameHeight = mBigFolderStyleConfig.mOpenFolderAppNameHeight; 110 mGridWidth = mBigFolderStyleConfig.mOpenFolderGridWidth; 111 mGridHeight = mBigFolderStyleConfig.mOpenFolderGridHeight; 112 mSwiperHeight = mBigFolderStyleConfig.mOpenFolderSwiperHeight; 113 mGridPadding = mBigFolderStyleConfig.mOpenFolderGridPadding; 114 mNameLines = mBigFolderStyleConfig.mNameLines; 115 mIconNameMargin = mBigFolderStyleConfig.mIconNameMargin; 116 mGridMarginTop = mBigFolderStyleConfig.mFolderOpenMargin; 117 mFolderOpenTitle = mBigFolderStyleConfig.mFolderOpenTitle; 118 mGridIconTopPadding = mBigFolderStyleConfig.mOpenFolderGridIconTopPadding; 119 } 120 121 private updateFolderData() { 122 Log.showDebug(TAG, 'updateFolderData start'); 123 if (this.openFolderStatus == BigFolderConstants.OPEN_FOLDER_STATUS_STATIC) { 124 return; 125 } 126 if (this.openFolderStatus == BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE) { 127 this.hideOpenFolder(); 128 mBigFolderViewModel.delAddIcon(this.mFolderInfo); 129 PageDesktopViewModel.getInstance().pagingFiltering(); 130 this.newFolderName = ''; 131 return; 132 } else { 133 this.isRenaming = this.mFolderInfo.enterEditing; 134 this.newFolderName = this.mFolderInfo.folderName; 135 this.mFolderInfo = mBigFolderViewModel.addAddIcon(this.mFolderInfo); 136 this.showOpenFolder(); 137 } 138 AppStorage.setOrCreate('openFolderStatus', BigFolderConstants.OPEN_FOLDER_STATUS_STATIC); 139 AppStorage.setOrCreate('isDraging', false); 140 Log.showDebug(TAG, 'updateFolderData end'); 141 } 142 143 private hideOpenFolder() { 144 Log.showDebug(TAG, 'hideOpenFolder start'); 145 this.isRenaming = false; 146 this.withBlur = false; 147 this.openFolderStatus = BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE; 148 this.showAnimate(0.3, Curve.EaseOut); 149 Log.showDebug(TAG, 'hideOpenFolder end'); 150 } 151 152 private showOpenFolder() { 153 this.updateStyle(); 154 this.withBlur = true; 155 this.showAnimate(1, Curve.EaseIn); 156 } 157 158 private showAnimate(overLayAlpha: number, curveValue: Curve) { 159 animateTo({ 160 duration: 250, 161 tempo: 0.5, 162 curve: curveValue, 163 delay: 0, 164 iterations: 1, 165 playMode: PlayMode.Normal, 166 }, () => { 167 this.overLayAlpha = overLayAlpha; 168 Trace.end(Trace.CORE_METHOD_OPEN_FOLDER); 169 }) 170 } 171 172 build() { 173 Stack() { 174 if (this.withBlur) { 175 Column() 176 .blur(CommonConstants.OVERLAY_BLUR_RADIUS) 177 .width(BigFolderStyleConstants.PERCENTAGE_100) 178 .height(BigFolderStyleConstants.PERCENTAGE_100) 179 } 180 181 Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center }) { 182 Stack({ alignContent: Alignment.Center }) { 183 if (this.isRenaming) { 184 Row() { 185 TextInput({ text: this.newFolderName }) 186 .maxLength(CommonConstants.FOLDER_NAME_MAX_LENGTH) 187 .caretColor(Color.White) 188 .fontColor(Color.White) 189 .fontSize(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_NAME_SIZE) 190 .fontWeight(FontWeight.Normal) 191 .layoutWeight(1) 192 .backgroundColor('rgba(255,255,255,0)') 193 .enterKeyType(EnterKeyType.Done) 194 .onSubmit((enterKey: EnterKeyType) => { 195 Log.showDebug(TAG, `textinput done: ${enterKey} `) 196 this.isRenaming = true; 197 this.saveText(); 198 }) 199 .onChange((text: string) => { 200 Log.showDebug(TAG, 'textInput: ' + text); 201 let allSpace = new RegExp('/^\s+$/g'); 202 if (!allSpace.test(text)) { 203 this.newFolderName = text; 204 } 205 }) 206 Image(BigFolderStyleConstants.DEFAULT_CANCEL_APP_IMAGE) 207 .width(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_CANCEL_SIZE) 208 .height(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_CANCEL_SIZE) 209 .onClick(() => { 210 this.newFolderName = '' 211 }) 212 } 213 .height(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_TEXTAREA_HEIGHT) 214 .width(BigFolderStyleConstants.PERCENTAGE_100) 215 .borderRadius(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_CANCEL_SIZE) 216 .padding({ 217 left: BigFolderStyleConstants.DEFAULT_BUTTON_HEIGHT, 218 right: BigFolderStyleConstants.DEFAULT_DIALOG_BOTTOM_MARGIN 219 }) 220 .backgroundColor('rgba(255,255,255,0.3)') 221 } else { 222 Text(this.mFolderInfo.folderName) { 223 } 224 .fontSize(BigFolderStyleConstants.DEFAULT_OPEN_FOLDER_NAME_SIZE) 225 .fontColor(Color.White) 226 .textAlign(TextAlign.Center) 227 .maxLines(1) 228 .width(BigFolderStyleConstants.PERCENTAGE_100) 229 .onClick(() => { 230 Log.showDebug(TAG, 'title click'); 231 this.isRenaming = true; 232 this.newFolderName = this.mFolderInfo.folderName 233 }) 234 } 235 } 236 .margin({ top: mFolderOpenTitle }) 237 .width(mGridWidth) 238 .height(mGridMarginTop) 239 240 Stack() { 241 Swiper() { 242 ForEach(this.mFolderInfo.layoutInfo, (item: AppItemInfo[]) => { 243 FolderSwiperPage({ 244 mAppInfo: item, 245 isRenaming: $isRenaming, 246 newFolderName: this.newFolderName, 247 mFolderInfo: this.mFolderInfo 248 }) 249 }, (item: AppItemInfo[]) => JSON.stringify(item)) 250 } 251 .indicator(Indicator.dot().selectedColor(StyleConstants.DEFAULT_FONT_COLOR)) 252 .onClick(() => { 253 Log.showDebug(TAG, 'Swiper click'); 254 this.saveText(); 255 }) 256 .height(mSwiperHeight) 257 .width(mGridWidth) 258 .duration(80) 259 .index(this.pageIndex) 260 .loop(false) 261 .onChange((index) => { 262 Log.showDebug(TAG, `onChange :${index}`); 263 if (this.pageIndex !== index) { 264 this.mFolderInfo = mBigFolderViewModel.addAddIcon(this.mFolderInfo); 265 this.pageIndex = index; 266 } 267 }) 268 } 269 } 270 .width(mGridWidth) 271 } 272 .width(BigFolderStyleConstants.PERCENTAGE_100) 273 .height(BigFolderStyleConstants.PERCENTAGE_100) 274 .visibility(this.openFolderStatus == 275 BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE ? Visibility.Hidden : Visibility.Visible) 276 .opacity(this.overLayAlpha) 277 .backgroundColor('rgba(0,0,0,0.25)') 278 .onClick(() => { 279 Log.showDebug(TAG, 'blank click'); 280 this.saveText(); 281 }) 282 .onMouse((event: MouseEvent) => { 283 if (event.button == MouseButton.Right) { 284 event.stopPropagation(); 285 Log.showDebug(TAG, 'onMouse MouseButton Right'); 286 } 287 }) 288 } 289 290 private saveText() { 291 if (this.isRenaming) { 292 this.isRenaming = false; 293 if (this.newFolderName.trim().length != 0 && this.newFolderName) { 294 this.mFolderInfo.folderName = this.newFolderName; 295 mBigFolderViewModel.modifyFolderName(this.mFolderInfo) 296 } 297 } else { 298 const contextFlag: boolean = AppStorage.get('contextMenuState') as boolean; 299 Log.showInfo(TAG, 'saveText contextFlag: ' + contextFlag); 300 if (contextFlag) { 301 AppStorage.setOrCreate('contextMenuState', false); 302 } else { 303 mBigFolderViewModel.closeFolder(); 304 } 305 } 306 InputMethodManager.getInstance().stopInput(); 307 } 308} 309 310@Component 311struct FolderSwiperPage { 312 @StorageLink('isDraging') isDraging: boolean = false; 313 @Link isRenaming: boolean; 314 @Prop newFolderName: string; 315 private mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' }; 316 private mAppInfo: AppItemInfo[] = []; 317 private columnsTemplate: string = ''; 318 private RowsTemplate: string = ''; 319 private mGridGap = BigFolderStyleConfig.getInstance().mOpenFolderGridGap; 320 @State mBigFolderViewModel: BigFolderViewModel = mBigFolderViewModel; 321 @State appNameAdd: string = ''; 322 323 aboutToAppear(): void { 324 mFolderModel = BigFolderModel.getInstance(); 325 ResourceManager.getInstance().getStringByResource($r('app.string.add')).then((resName) => { 326 this.appNameAdd = resName; 327 }); 328 this.updateConfig(); 329 } 330 331 aboutToDisappear(): void { 332 this.folderDialogController = null; 333 } 334 335 private updateConfig() { 336 let styleConfig = mBigFolderViewModel.getFolderStyleConfig(); 337 this.mGridGap = styleConfig.mOpenFolderGridGap; 338 let openFolderConfig = mFolderModel.getFolderOpenLayout() as FolderOpenLayoutTable; 339 340 let column = openFolderConfig.column as number; 341 let row = openFolderConfig.row as number; 342 this.columnsTemplate = ''; 343 this.RowsTemplate = ''; 344 for (let i = 0; i < column; i++) { 345 this.columnsTemplate += '1fr ' 346 } 347 for (let i = 0; i < row; i++) { 348 this.RowsTemplate += '1fr ' 349 } 350 } 351 352 folderDialogController: CustomDialogController | null = new CustomDialogController({ 353 builder: FolderAppListDialog({ 354 cancel: () => { 355 }, 356 confirm: (isDestory: boolean) => { 357 if (isDestory) { 358 mBigFolderViewModel.closeFolder(); 359 } 360 }, 361 folderItem: AppStorage.get('openFolderData'), 362 mBigFolderViewModel: $mBigFolderViewModel 363 }), 364 customStyle: true, 365 alignment: DialogAlignment.Center, 366 cancel: () => { 367 }, 368 autoCancel: true 369 }) 370 371 build() { 372 Column() { 373 Grid() { 374 ForEach(this.mAppInfo, (item: AppItemInfo) => { 375 GridItem() { 376 if (item.typeId === CommonConstants.TYPE_ADD) { 377 Column() { 378 Stack({ alignContent: Alignment.Center }) { 379 Column() 380 .width(mAddIconSize) 381 .height(mAddIconSize) 382 .opacity(0.5) 383 .borderRadius(10) 384 .backgroundColor(Color.White) 385 386 Image(BigFolderStyleConstants.DEFAULT_ADD_FOLDER_APP_IMAGE) 387 .width(BigFolderStyleConstants.DEFAULT_ADD_APP_ICON_SIZE) 388 .height(BigFolderStyleConstants.DEFAULT_ADD_APP_ICON_SIZE) 389 }.margin({ top: mGridIconTopPadding }) 390 391 if (this.appNameAdd) { 392 AppName({ 393 nameHeight: mAppNameHeight, 394 nameSize: mAppNameSize, 395 nameFontColor: BigFolderStyleConstants.DEFAULT_FONT_COLOR, 396 appName: this.appNameAdd, 397 useCache: false, 398 nameLines: mNameLines, 399 marginTop: mIconNameMargin 400 }) 401 } 402 } 403 .width(BigFolderStyleConstants.PERCENTAGE_100) 404 .height(BigFolderStyleConstants.PERCENTAGE_100) 405 .onClick(() => { 406 Log.showDebug(TAG, 'add app to this folder'); 407 this.folderDialogController?.open(); 408 }) 409 } else { 410 FolderAppItem({ 411 item: item, 412 }) 413 } 414 } 415 }, (item: AppItemInfo) => JSON.stringify(item)) 416 } 417 .margin(mGridPadding) 418 .width(mGridWidth - 2 * mGridPadding) 419 .height(mGridHeight - 2 * mGridPadding) 420 .columnsGap(this.mGridGap) 421 .rowsGap(this.mGridGap) 422 .onClick(() => { 423 Log.showDebug(TAG, 'Grid click'); 424 this.saveText(); 425 }) 426 .columnsTemplate(this.columnsTemplate) 427 .rowsTemplate(this.RowsTemplate) 428 } 429 .width(mGridWidth) 430 .height(mGridHeight) 431 .borderRadius(32) 432 .borderColor(this.isDraging ? 'rgba(255,255,255,0.25)' : 'rgba(0,0,0,0)') 433 .borderWidth(2) 434 .onMouse((event: MouseEvent) => { 435 if (event.button == MouseButton.Right) { 436 event.stopPropagation(); 437 Log.showDebug(TAG, 'Grid onMouse MouseButton Right'); 438 } 439 }) 440 } 441 442 private saveText() { 443 if (this.isRenaming) { 444 this.isRenaming = false; 445 if (this.newFolderName && this.newFolderName != this.mFolderInfo.folderName) { 446 this.mFolderInfo.folderName = this.newFolderName; 447 mBigFolderViewModel.modifyFolderName(this.mFolderInfo); 448 } 449 } else { 450 const contextFlag: boolean = AppStorage.get('contextMenuState') as boolean; 451 Log.showInfo(TAG, 'saveText contextFlag: ' + contextFlag); 452 if (contextFlag) { 453 AppStorage.setOrCreate('contextMenuState', false); 454 } else { 455 mBigFolderViewModel.closeFolder(); 456 } 457 } 458 InputMethodManager.getInstance().stopInput(); 459 } 460} 461 462@Component 463struct FolderAppItem { 464 @StorageLink('uninstallAppInfo') appInfo: AppItemInfo = new AppItemInfo(); 465 @StorageLink('selectDesktopAppItem') selectDesktopAppItem: string = ''; 466 @State item: AppItemInfo = new AppItemInfo(); 467 private columnsTemplate: string = ''; 468 private rowsTemplate: string = ''; 469 private isSwappingPage = false; 470 private willCloseFolder: boolean = false; 471 private mFolderInfo: FolderData = { layoutInfo: [], enterEditing: false, folderName: '', folderId: '' }; 472 private mouseClick: number = 0; 473 private dialogName: string = ''; 474 private clearForm: Function = () => {}; 475 476 aboutToAppear(): void { 477 mFolderModel = BigFolderModel.getInstance(); 478 ResourceManager.getInstance().getStringByResource(isPad 479 ? $r('app.string.is_delete_form') : $r('app.string.isUninstall')).then((resName) => { 480 this.dialogName = resName; 481 }); 482 } 483 484 aboutToDisappear(): void { 485 this.uninstallDialogController = null; 486 this.formManagerDialogController = null; 487 } 488 489 uninstallDialogController: CustomDialogController | null = new CustomDialogController({ 490 builder: UninstallDialog({ 491 cancel: () => { 492 }, 493 confirm: () => { 494 if (isPad) { 495 this.mFolderInfo = mBigFolderViewModel.deleteAppFromOpenFolder(this.appInfo); 496 } else { 497 mBigFolderViewModel.uninstallApp(this.appInfo.bundleName, this.appInfo.isUninstallAble); 498 if (!this.appInfo.isUninstallAble) { 499 return; 500 } 501 this.mFolderInfo = mBigFolderViewModel.deleteAppFromOpenFolder(this.appInfo); 502 } 503 mBigFolderViewModel.refreshFolder(this.mFolderInfo); 504 localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_ITEM_UPDATE, null); 505 }, 506 dialogName: this.dialogName, 507 dialogContent: this.appInfo.appName + ' ?', 508 }), 509 cancel: () => { 510 }, 511 autoCancel: false, 512 customStyle: true 513 }); 514 515 concatCacheKey(item: AppItemInfo): string { 516 if (item.appLabelId && item.bundleName && item.moduleName) { 517 return `${item.appLabelId}${item.bundleName}${item.moduleName}`; 518 } 519 return ''; 520 } 521 522 formManagerDialogController: CustomDialogController | null = new CustomDialogController({ 523 builder: FormManagerDialog({ 524 cancel: (callback?: () => void) => { 525 // delete all form 526 if (callback != undefined) { 527 this.clearForm = callback; 528 } 529 }, 530 confirm: (formCardItem: CardItemInfo) => { 531 // add form to desktop 532 Log.showDebug(TAG, `createCardToDeskTop formCardItem: ${JSON.stringify(formCardItem)}`); 533 localEventManager.sendLocalEventSticky(EventConstants.EVENT_REQUEST_PAGEDESK_FORM_ITEM_ADD, formCardItem); 534 }, 535 bundleName: this.item.bundleName as string, 536 appName: PageDesktopViewModel.getInstance().getAppName(this.concatCacheKey(this.item)), 537 appLabelId: this.item.appLabelId as number 538 }), 539 cancel: this.cancelFormDialog, 540 autoCancel: false, 541 customStyle: true 542 }); 543 544 cancelFormDialog() { 545 Log.showDebug(TAG, 'form manager cancel dialog'); 546 this.clearForm(); 547 } 548 549 closeFolderDelay() { 550 this.willCloseFolder = false; 551 setTimeout(() => { 552 this.willCloseFolder = true; 553 }, FOLDER_CLOSE_DELAY); 554 } 555 556 removeAppOutOfFolder = (appInfo: AppItemInfo) => { 557 mBigFolderViewModel.removeAppOutOfFolder(appInfo); 558 } 559 560 private launchApp() { 561 Trace.start(Trace.CORE_METHOD_START_APP_ANIMATION); 562 this.setStartAppInfo(); 563 PageDesktopViewModel.getInstance().onAppDoubleClick( 564 this.item.abilityName, this.item.bundleName, this.item.moduleName 565 ); 566 } 567 568 build() { 569 Column() { 570 Column() { 571 AppBubble({ 572 iconSize: mAppIconSize, 573 nameSize: mAppNameSize, 574 nameHeight: mAppNameHeight, 575 nameFontColor: BigFolderStyleConstants.DEFAULT_FONT_COLOR, 576 appName: this.item.appName, 577 bundleName: this.item.bundleName, 578 abilityName: this.item.abilityName, 579 moduleName: this.item.moduleName, 580 appIconId: this.item.appIconId, 581 appLabelId: this.item.appLabelId, 582 badgeNumber: this.item.badgeNumber, 583 isSelect: this.selectDesktopAppItem == this.item.keyName, 584 mPaddingTop: mGridIconTopPadding, 585 menuInfo: PageDesktopViewModel.getInstance().buildMenuInfoList(this.item, this.uninstallDialogController, 586 this.formManagerDialogController, this.removeAppOutOfFolder, () => { 587 this.setStartAppInfo(); 588 }), 589 nameLines: mNameLines, 590 mIconNameMargin: mIconNameMargin, 591 dragStart: () => {} 592 }) 593 } 594 .width(mAppItemWidth) 595 .height(mAppItemWidth) 596 .onClick(() => { 597 Log.showDebug(TAG, 'App click'); 598 this.setStartAppInfo(); 599 PageDesktopViewModel.getInstance().openApplication( 600 this.item.abilityName, this.item.bundleName, this.item.moduleName 601 ); 602 }) 603 .onMouse((event: MouseEvent) => { 604 if (event.button == MouseButton.Right) { 605 event.stopPropagation(); 606 Log.showDebug(TAG, `FolderAppItem onMouse MouseButton Right keyName: ${this.item.keyName}`); 607 AppStorage.setOrCreate('selectDesktopAppItem', this.item.keyName); 608 } 609 }) 610 .gesture( 611 GestureGroup(GestureMode.Exclusive, 612 TapGesture() 613 .onAction((event: GestureEvent) => { 614 Log.showDebug(TAG, `tap action ${JSON.stringify(event)}`) 615 if (event.source == SourceType.Mouse) { 616 this.mouseClick++; 617 if (this.mouseClick == DOUBLE_CLICK_COUNT) { 618 Log.showDebug(TAG, 'mouse double click'); 619 this.mouseClick = 0; 620 this.launchApp(); 621 } else { 622 this.setStartAppInfo(); 623 PageDesktopViewModel.getInstance().onAppClick( 624 this.item.abilityName, this.item.bundleName, this.item.moduleName 625 ); 626 setTimeout(() => { 627 this.mouseClick = 0; 628 }, 300) 629 } 630 } else { 631 Log.showDebug(TAG, 'tap click'); 632 this.launchApp(); 633 } 634 }) 635 ) 636 ) 637 } 638 .width(mAppItemWidth) 639 .height(mAppItemWidth) 640 } 641 642 /** 643 * set start app info 644 */ 645 setStartAppInfo() { 646 if (CheckEmptyUtils.isEmpty(this.item)) { 647 Log.showError(TAG, 'setStartAppInfo with item') 648 return; 649 } 650 Log.showInfo(TAG, 'app setStartAppInfo'); 651 if (AppStorage.get('deviceType') === CommonConstants.PAD_DEVICE_TYPE) { 652 AppStorage.setOrCreate('openFolderStatus', BigFolderConstants.OPEN_FOLDER_STATUS_CLOSE); 653 } 654 AppStorage.setOrCreate('startAppItemInfo', this.item); 655 mBigFolderStartAppHandler.setAppIconSize(mBigFolderStyleConfig.mOpenFolderIconSize); 656 mBigFolderStartAppHandler.setAppIconInfo(); 657 } 658} 659