257 TBool disable = GetVariety(variety); |
257 TBool disable = GetVariety(variety); |
258 if ( disable ) |
258 if ( disable ) |
259 { |
259 { |
260 TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
260 TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
261 } |
261 } |
|
262 variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic |
|
263 |
262 TAknLayoutScalableParameterLimits gridParams = |
264 TAknLayoutScalableParameterLimits gridParams = |
263 AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety ); |
265 AknLayoutScalable_Apps::cell_tport_appsw_pane_ParamLimits( variety ); |
264 TPoint empty( ELayoutEmpty, ELayoutEmpty ); |
266 TPoint empty( ELayoutEmpty, ELayoutEmpty ); |
265 |
267 |
266 // Setup bitmap layout |
268 // Setup bitmap layout |
320 } |
322 } |
321 } |
323 } |
322 |
324 |
323 |
325 |
324 // -------------------------------------------------------------------------- |
326 // -------------------------------------------------------------------------- |
|
327 // CTsFastSwapArea::LayoutGridView |
|
328 // -------------------------------------------------------------------------- |
|
329 // |
|
330 void CTsFastSwapArea::LayoutGridViewL( TInt aItemCount ) |
|
331 { |
|
332 RArray<TAknLayoutRect> rects; |
|
333 CleanupClosePushL(rects); |
|
334 rects.ReserveL(KLayoutItemCount); |
|
335 GetFastSwapAreaRects(rects); |
|
336 TAknLayoutRect gridItem = rects[1]; |
|
337 CleanupStack::PopAndDestroy(&rects); |
|
338 if ( aItemCount ) |
|
339 { |
|
340 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); |
|
341 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(ETrue); |
|
342 if ( AknLayoutUtils::LayoutMirrored() ) |
|
343 { |
|
344 iGrid->SetLayoutL( EFalse, EFalse, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); |
|
345 } |
|
346 else |
|
347 { |
|
348 iGrid->SetLayoutL( EFalse, ETrue, ETrue, aItemCount, 1, gridItem.Rect().Size(), iGridItemGap ); |
|
349 } |
|
350 } |
|
351 else |
|
352 { |
|
353 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
|
354 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
|
355 } |
|
356 } |
|
357 |
|
358 |
|
359 // -------------------------------------------------------------------------- |
325 // CTsFastSwapArea::GetFastSwapAreaRects |
360 // CTsFastSwapArea::GetFastSwapAreaRects |
326 // -------------------------------------------------------------------------- |
361 // -------------------------------------------------------------------------- |
327 // |
362 // |
328 void CTsFastSwapArea::GetFastSwapAreaRects( RArray<TAknLayoutRect>& aRects ) |
363 void CTsFastSwapArea::GetFastSwapAreaRects( RArray<TAknLayoutRect>& aRects ) |
329 { |
364 { |
336 TBool disable = GetVariety(variety); |
371 TBool disable = GetVariety(variety); |
337 if ( disable ) |
372 if ( disable ) |
338 { |
373 { |
339 TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
374 TRAP_IGNORE(static_cast<CTsAppUi*>(iEikonEnv->AppUi())->RequestPopUpL()); |
340 } |
375 } |
|
376 variety = Layout_Meta_Data::IsLandscapeOrientation() ? 1 : 0; // double check to avoid layout panic |
341 |
377 |
342 gridAppPane.LayoutRect( Rect(), |
378 gridAppPane.LayoutRect( Rect(), |
343 AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
379 AknLayoutScalable_Apps::tport_appsw_pane( variety ) ); |
344 aRects.Append(gridAppPane); |
380 aRects.Append(gridAppPane); |
345 |
381 |
379 TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL ); |
415 TSLOG_CONTEXT( CTsFastSwapArea::SizeChanged, TSLOG_LOCAL ); |
380 TSLOG_IN(); |
416 TSLOG_IN(); |
381 |
417 |
382 if ( iGrid && !iIgnoreLayoutSwitch ) |
418 if ( iGrid && !iIgnoreLayoutSwitch ) |
383 { |
419 { |
|
420 // Cancel ongoing pointer event |
|
421 iHandlePointerCandidate = EFalse; |
384 // Grid needs to be recreated to proper reinitilize |
422 // Grid needs to be recreated to proper reinitilize |
385 // data with new layout values |
423 // data with new layout values |
386 TInt selIdx = SelectedIndex(); |
424 TInt selIdx = SelectedIndex(); |
387 TRAPD(err, |
425 TRAPD(err, |
388 /*ReCreateGridL()*/ |
426 LayoutGridL(); |
389 LayoutGridL() ); |
427 LayoutGridViewL( iArray.Count() ) |
|
428 ); |
|
429 |
390 if ( err != KErrNone ) |
430 if ( err != KErrNone ) |
391 { |
431 { |
392 TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
432 TSLOG1( TSLOG_INFO, "LayoutGridL leaves with %d", err ); |
393 } |
433 } |
394 HandleFswContentChanged(); |
434 |
|
435 // Update grid view |
395 iGrid->SetCurrentDataIndex(selIdx); |
436 iGrid->SetCurrentDataIndex(selIdx); |
396 UpdateGrid(ETrue, EFalse); |
437 UpdateGrid(ETrue, EFalse); |
397 iGrid->DrawDeferred(); |
438 iGrid->DrawDeferred(); |
398 |
439 |
399 // Order full redraw after switch |
440 // Order full redraw after switch |
495 TSLOG_CONTEXT( TryCloseAppL, TSLOG_LOCAL ); |
536 TSLOG_CONTEXT( TryCloseAppL, TSLOG_LOCAL ); |
496 TSLOG2_IN( "%d %d", aIndex, aSuppressRendering ); |
537 TSLOG2_IN( "%d %d", aIndex, aSuppressRendering ); |
497 |
538 |
498 if ( aIndex >= 0 && aIndex < iArray.Count() && CanClose( aIndex ) ) |
539 if ( aIndex >= 0 && aIndex < iArray.Count() && CanClose( aIndex ) ) |
499 { |
540 { |
500 TInt selIdx = SelectedIndex(); |
|
501 if ( selIdx > aIndex && selIdx > 0 ) |
|
502 { |
|
503 selIdx--; |
|
504 } |
|
505 TInt wgId = iArray[aIndex]->WgId(); |
541 TInt wgId = iArray[aIndex]->WgId(); |
506 iFSClient->CloseApp( wgId ); |
542 iFSClient->CloseApp( wgId ); |
507 iIsClosing.Append(wgId); |
543 iIsClosing.Append(wgId); |
508 if ( iArray[aIndex]->Widget() ) |
544 if ( iArray[aIndex]->Widget() ) |
509 { |
545 { |
510 iWidgetClosingCount++; |
546 iWidgetClosingCount++; |
511 } |
|
512 // The fsw content will change sooner or later |
|
513 // but the updated content (without the closed app) will not |
|
514 // come very fast. It looks better to the user if the item |
|
515 // in the grid is removed right here, right now. |
|
516 // If the app does not close for some reason then this is |
|
517 // not fully correct but the app will then reappear on the next |
|
518 // content-changed notification anyway. |
|
519 delete iArray[aIndex]; |
|
520 iArray.Remove( aIndex ); |
|
521 NotifyChange(); |
|
522 |
|
523 // Hide highlight |
|
524 if ( iGrid->GridBehaviour() == CTsFastSwapGrid::ETouchOnly ) |
|
525 { |
|
526 iGrid->HideHighlight(); |
|
527 } |
|
528 // Update selection |
|
529 TInt newItemCount = GridItemCount() - 1; |
|
530 if ( aIndex == newItemCount ) |
|
531 { |
|
532 newItemCount--; |
|
533 iGrid->SetCurrentDataIndex(newItemCount); |
|
534 } |
|
535 else |
|
536 { |
|
537 iGrid->SetCurrentDataIndex(selIdx); |
|
538 } |
|
539 // Render contect |
|
540 if ( !aSuppressRendering ) |
|
541 { |
|
542 RenderContentL( ETrue ); |
|
543 } |
547 } |
544 |
548 |
545 // Orientation update |
549 // Orientation update |
546 iPrevScreenOrientation = GetCurrentScreenOrientation(); |
550 iPrevScreenOrientation = GetCurrentScreenOrientation(); |
547 iOrientationSignalTimer->Cancel(); |
551 iOrientationSignalTimer->Cancel(); |
548 iOrientationSignalTimer->After(KOrientationSwitchTime); |
552 iOrientationSignalTimer->After(KOrientationSwitchTime); |
549 |
|
550 iPrevAppCount = iArray.Count(); |
|
551 } |
553 } |
552 |
554 |
553 TSLOG_OUT(); |
555 TSLOG_OUT(); |
554 } |
556 } |
555 |
557 |
557 // CTsFastSwapArea::TryCloseAllL |
559 // CTsFastSwapArea::TryCloseAllL |
558 // -------------------------------------------------------------------------- |
560 // -------------------------------------------------------------------------- |
559 // |
561 // |
560 void CTsFastSwapArea::TryCloseAllL() |
562 void CTsFastSwapArea::TryCloseAllL() |
561 { |
563 { |
562 // note the direction of the loop, this is needed because |
|
563 // TryCloseAppL may modify the array |
|
564 TBool changed = EFalse; |
|
565 for ( TInt i = iArray.Count() - 1; i >= 0; --i ) |
564 for ( TInt i = iArray.Count() - 1; i >= 0; --i ) |
566 { |
565 { |
567 if ( CanClose( i ) ) |
566 if ( CanClose( i ) ) |
568 { |
567 { |
569 TryCloseAppL( i, ETrue ); |
568 TryCloseAppL( i, ETrue ); |
570 changed = ETrue; |
569 } |
571 } |
|
572 } |
|
573 if ( changed ) |
|
574 { |
|
575 RenderContentL(); |
|
576 RestoreSelectedIndex(); |
|
577 UpdateGrid( ETrue, EFalse ); |
|
578 } |
570 } |
579 } |
571 } |
580 |
572 |
581 // -------------------------------------------------------------------------- |
573 // -------------------------------------------------------------------------- |
582 // CTsFastSwapArea::CanClose |
574 // CTsFastSwapArea::CanClose |
583 // -------------------------------------------------------------------------- |
575 // -------------------------------------------------------------------------- |
584 // |
576 // |
585 TBool CTsFastSwapArea::CanClose( TInt aIndex ) const |
577 TBool CTsFastSwapArea::CanClose( TInt aIndex ) const |
586 { |
578 { |
587 CTsFswEntry* e = iArray[aIndex]; |
579 TBool canClose(EFalse); |
588 TBool canClose = !e->AlwaysShown() && !e->SystemApp(); |
580 if ( aIndex >= 0 && aIndex < iArray.Count() ) |
589 // Special cases: Menu |
581 { |
590 canClose |= e->AppUid() == KTsMenuUid; |
582 CTsFswEntry* e = iArray[aIndex]; |
|
583 canClose = !e->AlwaysShown() && !e->SystemApp(); |
|
584 // Special cases: Menu |
|
585 canClose |= e->AppUid() == KTsMenuUid; |
|
586 } |
591 return canClose; |
587 return canClose; |
592 } |
588 } |
593 |
589 |
594 // -------------------------------------------------------------------------- |
590 // -------------------------------------------------------------------------- |
595 // CTsFastSwapArea::CanCloseOthers |
591 // CTsFastSwapArea::CanCloseOthers |
693 RArray<TInt> closeItemArray; |
689 RArray<TInt> closeItemArray; |
694 CleanupClosePushL(closeItemArray); |
690 CleanupClosePushL(closeItemArray); |
695 RArray<TInt> strokeItemArray; |
691 RArray<TInt> strokeItemArray; |
696 CleanupClosePushL(strokeItemArray); |
692 CleanupClosePushL(strokeItemArray); |
697 |
693 |
698 RArray<TAknLayoutRect> rects; |
694 // Update view based on number of items |
699 CleanupClosePushL(rects); |
695 LayoutGridViewL( iArray.Count() ); |
700 rects.ReserveL(KLayoutItemCount); |
696 |
701 GetFastSwapAreaRects(rects); |
|
702 TAknLayoutRect gridItem = rects[1]; |
|
703 CleanupStack::PopAndDestroy(&rects); |
|
704 if ( iArray.Count() ) |
|
705 { |
|
706 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(EFalse); |
|
707 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(ETrue); |
|
708 if ( AknLayoutUtils::LayoutMirrored() ) |
|
709 { |
|
710 iGrid->SetLayoutL( EFalse, EFalse, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
|
711 } |
|
712 else |
|
713 { |
|
714 iGrid->SetLayoutL( EFalse, ETrue, ETrue, iArray.Count(), 1, gridItem.Rect().Size(), iGridItemGap ); |
|
715 } |
|
716 } |
|
717 else |
|
718 { |
|
719 iGrid->ItemDrawer()->ColumnData()->SetDrawBackground(ETrue); |
|
720 static_cast<CTsAppView*>(&iParent)->EnableDragEvents(EFalse); |
|
721 } |
|
722 |
|
723 for ( TInt i = 0; i < iArray.Count(); ++i ) |
697 for ( TInt i = 0; i < iArray.Count(); ++i ) |
724 { |
698 { |
725 const TDesC& appName( iArray[i]->AppName() ); |
699 const TDesC& appName( iArray[i]->AppName() ); |
726 const TInt formatLen = 3 + 2; |
700 const TInt formatLen = 3 + 2; |
727 RBuf formAppName; |
701 RBuf formAppName; |
796 CleanupStack::PopAndDestroy(&closeItemArray); |
770 CleanupStack::PopAndDestroy(&closeItemArray); |
797 CleanupStack::Pop(textArray); |
771 CleanupStack::Pop(textArray); |
798 CleanupStack::Pop(iconArray); |
772 CleanupStack::Pop(iconArray); |
799 |
773 |
800 // refresh the items in the grid |
774 // refresh the items in the grid |
|
775 iGrid->HandleItemAdditionL(); |
801 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
776 iEvtHandler.ReInitPhysicsL( GridWorldSize(), ViewSize(), ETrue ); |
|
777 if ( SelectedIndex() >= GridItemCount() && GridItemCount() ) |
|
778 { |
|
779 iGrid->SetCurrentDataIndex( GridItemCount() - 1 ); |
|
780 } |
802 UpdateGrid( ETrue, !aSuppressAnimation ); |
781 UpdateGrid( ETrue, !aSuppressAnimation ); |
803 iGrid->HandleItemAdditionL(); |
|
804 |
782 |
805 TSLOG_OUT(); |
783 TSLOG_OUT(); |
806 } |
784 } |
807 |
785 |
808 // -------------------------------------------------------------------------- |
786 // -------------------------------------------------------------------------- |
1501 { |
1479 { |
1502 if ( iArray.Count() ) |
1480 if ( iArray.Count() ) |
1503 { |
1481 { |
1504 if( aType == KAppKeyTypeShort ) |
1482 if( aType == KAppKeyTypeShort ) |
1505 { |
1483 { |
1506 // Switch to homescreen |
1484 //SwitchToApp( KTsHomescreenUid ); |
1507 SwitchToApp( KTsHomescreenUid ); |
1485 TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
1508 } |
1486 } |
1509 else if( aType == KAppKeyTypeLong ) |
1487 else if( aType == KAppKeyTypeLong ) |
1510 { |
1488 { |
1511 // Dismiss task switcher |
1489 // Dismiss task switcher |
1512 TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |
1490 TRAP_IGNORE( iEikonEnv->EikAppUi()->HandleCommandL(EAknSoftkeyExit) ); |