2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StManageApplicationInfoForm.cpp
19 * @brief This is the implementation file for ManageApplicationInfoForm class.
22 #include "StManageApplicationInfoForm.h"
23 #include "StResourceManager.h"
26 using namespace Tizen::App;
27 using namespace Tizen::App::Package;
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::System;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
36 static const int ID_GROUP_APPLICATION_NAME = 0;
37 static const int ID_GROUP_APPLICATION_NAME_ITEM_COUNT = 2;
38 static const int ID_ITEM_APPLICATION_NAME = 0;
39 static const int ID_ITEM_APPLICATION_COMMAND_BUTTON = 1;
41 static const int ID_GROUP_APPLICATION_SIZE = 1;
42 static const int ID_GROUP_APPLICATION_SIZE_ITEM_COUNT = 3;
43 static const int ID_ITEM_APPLICATION_SIZE = 1;
44 static const int ID_ITEM_APPLICATION_DATA_SIZE = 2;
46 static const int ID_GROUP_APPLICATION_CLEAR_DEFAULT = 2;
47 static const int ID_GROUP_APPLICATION_CLEAR_DEFAULT_ITEM_COUNT = 1;
49 static const int ID_GROUP_APPLICATION_CLEAR_DEFAULT_HELP = 3;
51 static const int ID_GROUP_APPLICATION_DETAIL = 4;
53 static const int ID_TOTAL_GROUP_COUNT = 2;
55 static const int IDA_FORCE_STOP = 300;
56 static const int IDA_UNINSTALL = 310;
57 static const int IDA_UNINSTALL_CONFIRM_OK = 320;
58 static const int IDA_UNINSTALL_CONFIRM_CANCEL = 330;
60 static const int Y_ALERT_POPUP_CLIENT_RECT_DEFAULT = 160;
61 static const int X_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 20;
62 static const int Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 20;
63 static const int H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 340;
64 static const int W_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT = 690;
65 static const int X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 12;
66 static const int Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 360;
67 static const int W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 310;
68 static const int H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT = 80;
69 static const int X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE = 20;
70 static const int ALERT_POPUP_LABEL_FONT_SIZE = 40;
72 static const int W_ALERT_POPUP_CLIENT_RECT_DEFAULT = 700;
73 static const int H_ALERT_POPUP_CLIENT_RECT_DEFAULT = 550;
75 static const int COMMAND_BUTTON_GAP = 20;
76 static const int APPLICATION_NAME_MARGIN_GAP = 100;
77 static const int APPLICATION_NAME_SECOND_CONTROL = 1;
79 static const int KILOBYTE_TO_MEGABYTE = 1024;
80 static const int MEGABYTE_TO_GIGABYTE = 1024;
84 DATA_TYPE_APPLICATION_NAME = 0,
85 DATA_TYPE_APPLICATION_ICON_PATH,
86 DATA_TYPE_APPLICATION_UNINSTALLABLE,
87 DATA_TYPE_APPLICATION_SIZE,
88 DATA_TYPE_APPLICATION_DATA_SIZE,
89 DATA_TYPE_APPLICATION_ID,
90 DATA_TYPE_APPLICATION_PACKAGE_ID,
95 UNINSTALL_POPUP_OKCANCEL = 0,
96 UNINSTALL_POPUP_PROGRESS,
99 ManageApplicationInfoForm::ManageApplicationInfoForm(void)
100 : __applicationData(null)
101 , __pPackageManager(null)
102 , __uninstallConfirmPopup(null)
103 , __pProgressPopup(null)
107 ManageApplicationInfoForm::~ManageApplicationInfoForm(void)
112 ManageApplicationInfoForm::CreateFooter(void)
114 Footer* pFooter = GetFooter();
117 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
118 pFooter->SetBackButton();
119 pFooter->AddActionEventListener(*this);
121 SetFormBackEventListener(this);
125 ManageApplicationInfoForm::OnInitializing(void)
127 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_APPLICATION_INFO"));
131 __pPackageManager = PackageManager::GetInstance();
133 if (__pPackageManager)
135 __pPackageManager->AddPackageInstallationEventListener(*this);
138 AppLogDebug("ENTER");
144 ManageApplicationInfoForm::OnTerminating(void)
146 if (__pPackageManager)
148 __pPackageManager->RemovePackageInstallationEventListener(*this);
150 delete __applicationData;
152 DeleteUninstallPopup();
155 SetFormBackEventListener(null);
156 RemoveOrientationEventListener(*this);
161 ManageApplicationInfoForm::GroupItemEnable(int groupIndex, bool setEnableStatus)
163 int itemCount = __pTableView->GetItemCountAt(groupIndex);
165 for (int i = 0; i< itemCount; i++)
167 __pTableView->SetItemEnabled(groupIndex, i, setEnableStatus);
172 ManageApplicationInfoForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
176 __applicationData = static_cast<ArrayList*>(pArgs->GetItemsN(0, pArgs->GetCount()));
178 __pTableView->UpdateTableView();
180 GroupItemEnable(ID_GROUP_APPLICATION_SIZE, false);
181 GroupItemEnable(ID_GROUP_APPLICATION_CLEAR_DEFAULT, false);
182 GroupItemEnable(ID_GROUP_APPLICATION_DETAIL, false);
187 ManageApplicationInfoForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
192 ManageApplicationInfoForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
194 SceneManager* pSceneManager = SceneManager::GetInstance();
195 AppAssert(pSceneManager);
197 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
201 ManageApplicationInfoForm::GetGroupCount(void)
203 // Temporary code due to the UI Framework defect
204 if (!__applicationData)
209 AppLogDebug("ENTER");
210 return ID_TOTAL_GROUP_COUNT;
214 ManageApplicationInfoForm::GetItemCount(int groupIndex)
216 // Temporary code due to the UI Framework defect
217 if (!__applicationData)
226 case ID_GROUP_APPLICATION_NAME:
228 itemCount = ID_GROUP_APPLICATION_NAME_ITEM_COUNT;
232 case ID_GROUP_APPLICATION_SIZE:
234 itemCount = ID_GROUP_APPLICATION_SIZE_ITEM_COUNT;
238 case ID_GROUP_APPLICATION_CLEAR_DEFAULT:
240 case ID_GROUP_APPLICATION_DETAIL:
242 itemCount = ID_GROUP_APPLICATION_CLEAR_DEFAULT_ITEM_COUNT;
250 AppLogDebug("GetItemCount %d", itemCount);
256 ManageApplicationInfoForm::CreateGroupItem(int groupIndex, int itemWidth)
258 AppLogDebug("ENTER");
260 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
261 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
262 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
263 Rectangle itemRectangle;
265 Label* pLabel = null;
267 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
269 itemRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
270 itemRectangle.y = yItemOffset;
271 itemRectangle.width = itemWidth;
272 itemRectangle.height = itemHeight;
274 if (groupIndex == ID_GROUP_APPLICATION_CLEAR_DEFAULT_HELP)
277 itemRectangle.height = itemHeight = H_GROUP_ITEM_DEFAULT;
278 groupText = ResourceManager::GetString(L"IDS_ST_BODY_YOU_HAVE_SELECTED_TO_LAUNCH_THIS_APPLICATION_BY_DEFAULT_FOR_SOME_ACTIONS");
281 RelativeLayout relativeLayout;
282 relativeLayout.Construct();
284 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
285 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
287 pLabel = new (std::nothrow) Label();
288 pLabel->Construct(itemRectangle, groupText);
289 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
290 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
291 pLabel->SetTextConfig(FONT_MAIN_TEXT_SIZE_SMALL, style);
292 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
294 pItem->AddControl(pLabel);
295 pItem->SetEnabled(false);
296 relativeLayout.SetMargin(*pLabel, itemRectangle.x, 0, 0, 0);
297 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
298 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
304 ManageApplicationInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
306 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
308 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
310 bool isItemSubText = false;
311 bool isBitmapSet = false;
312 bool isCommandButton = false;
313 Rectangle itemIconRectangle;
314 Rectangle itemMainRectangle;
315 Rectangle itemSubRectangle;
317 int itemHeight = H_ITEM_TYPE_1_LABEL;
319 Bitmap* pBitmap = null;
320 Button* pStopButton = null;
321 Button* pUninstallButton = null;
322 Label* pLabel = null;
323 Label* pBitmapLabel = null;
328 int fontSize = GetFontSize();
329 TableViewItem* pItem = new (std::nothrow) TableViewItem();
331 ItemTypeOneLine(itemMainRectangle);
332 itemHeight = itemMainRectangle.height;
336 case ID_GROUP_APPLICATION_NAME:
340 case ID_ITEM_APPLICATION_NAME:
342 isItemSubText = true;
347 String bitmapPath = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_ICON_PATH)));
348 pBitmap = ResourceManager::GetApplicationBitmapN(bitmapPath);
352 pBitmap = ResourceManager::GetBitmapN(IDB_DEFAULT_ICON);
356 ItemTypeIconAndTwoLine(itemIconRectangle, itemMainRectangle, itemSubRectangle, fontSize);
357 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
358 itemMainText = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_NAME)));
359 sizeData = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_SIZE)));
360 Double::Parse(sizeData, appSize);
361 sizeData = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_DATA_SIZE)));
362 Double::Parse(sizeData, dataSize);
364 if (((appSize+dataSize) / KILOBYTE_TO_MEGABYTE) >= 1)
366 itemSubText = Double::ToString(((appSize+dataSize) / KILOBYTE_TO_MEGABYTE));
367 itemSubText.Append(L" MB");
371 itemSubText = Double::ToString(((appSize+dataSize)));
372 itemSubText.Append(L" KB");
379 isCommandButton = true;
386 case ID_GROUP_APPLICATION_SIZE:
390 double totalSize = 0;
393 isItemSubText = true;
395 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
396 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
400 case ID_ITEM_APPLICATION_SIZE:
402 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_APPLICATION");
403 tmpDataSize = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_SIZE)));
405 Double::Parse(tmpDataSize, appSize);
410 case ID_ITEM_APPLICATION_DATA_SIZE:
412 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DATA");
413 tmpDataSize = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_DATA_SIZE)));
415 Double::Parse(tmpDataSize, dataSize);
416 totalSize = dataSize;
422 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_TOTAL");
423 tmpDataSize = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_SIZE)));
424 Double::Parse(tmpDataSize, appSize);
425 tmpDataSize = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_DATA_SIZE)));
426 Double::Parse(tmpDataSize, dataSize);
428 totalSize = (appSize + dataSize);
433 if ((totalSize / KILOBYTE_TO_MEGABYTE) >= 1)
435 itemSubText = Double::ToString((totalSize / KILOBYTE_TO_MEGABYTE));
436 itemSubText.Append(L" MB");
440 itemSubText = Double::ToString((totalSize));
441 itemSubText.Append(L" KB");
446 case ID_GROUP_APPLICATION_CLEAR_DEFAULT:
448 ItemTypeOneLine(itemMainRectangle);
449 itemHeight = itemMainRectangle.height;
451 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CLEAR_DEFAULTS");
455 case ID_GROUP_APPLICATION_DETAIL:
457 ItemTypeOneLine(itemMainRectangle);
458 itemHeight = itemMainRectangle.height;
460 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MORE_DETAILS");
468 RelativeLayout relativeLayout;
469 relativeLayout.Construct();
471 if (isCommandButton == true)
476 itemMainRectangle.height -= (H_ITEM_TYPE_1_LABEL / DIVIDE_BY_TWO);
478 pItem->Construct(Dimension(itemWidth, itemMainRectangle.height), style);
479 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
481 Rectangle stopButtonRect;
482 Rectangle uninstallButtonRect;
484 stopButtonRect = itemMainRectangle;
485 stopButtonRect.width = (itemWidth / DIVIDE_BY_TWO) - COMMAND_BUTTON_GAP;
487 uninstallButtonRect = itemMainRectangle;
488 uninstallButtonRect.x = (itemWidth / DIVIDE_BY_TWO);
489 uninstallButtonRect.width = (itemWidth / DIVIDE_BY_TWO) - COMMAND_BUTTON_GAP;
491 pStopButton = new (std::nothrow) Button();
492 pStopButton->Construct(stopButtonRect, ResourceManager::GetString(L"IDS_ST_BUTTON_FORCE_STOP"));
493 pStopButton->SetActionId(IDA_FORCE_STOP);
495 SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_TYPE_HOME, homeAppId);
496 SettingInfo::GetValue(SETTING_INFO_KEY_SCREEN_TYPE_LOCK, lockAppId);
498 appId = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_ID)));
499 AppManager* pAppManager = AppManager::GetInstance();
501 if (pAppManager->IsRunning(appId) == false || appId == homeAppId || appId == lockAppId)
503 pStopButton->SetEnabled(false);
506 pStopButton->AddActionEventListener(*this);
508 String uninstallable = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_UNINSTALLABLE)));
510 pUninstallButton = new (std::nothrow) Button();
511 pUninstallButton->Construct(uninstallButtonRect, ResourceManager::GetString(L"IDS_ST_BUTTON_UNINSTALL"));
513 if (uninstallable.Equals(L"0", true) || appId == homeAppId || appId == lockAppId)
515 pUninstallButton->SetEnabled(false);
517 pUninstallButton->SetActionId(IDA_UNINSTALL);
518 pUninstallButton->AddActionEventListener(*this);
520 pItem->AddControl(pStopButton);
521 pItem->AddControl(pUninstallButton);
522 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
526 pItem->Construct(Dimension(itemWidth, itemHeight), style);
527 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
529 if (isBitmapSet == true)
531 pBitmapLabel = new (std::nothrow) Label();
532 pBitmapLabel->Construct(itemIconRectangle, L"");
533 pBitmapLabel->SetBackgroundBitmap(*pBitmap);
534 pItem->AddControl(pBitmapLabel);
537 pLabel = new (std::nothrow) Label();
538 pLabel->Construct(itemMainRectangle, itemMainText);
539 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
540 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
541 pLabel->SetTextColor(COLOR_MAIN_TEXT);
543 pItem->AddControl(pLabel);
544 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
546 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
547 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
549 if (isItemSubText == true)
551 pLabel = new (std::nothrow) Label();
552 pLabel->Construct(itemSubRectangle, itemSubText);
553 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
554 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
555 pLabel->SetTextColor(COLOR_SUB_TEXT);
557 pItem->AddControl(pLabel);
559 relativeLayout.SetMargin(*pLabel, itemSubRectangle.x, 0, 0, 0);
560 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
561 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
568 ManageApplicationInfoForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
570 AppLogDebug("ENTER");
579 ManageApplicationInfoForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
581 AppLogDebug("ENTER");
590 ManageApplicationInfoForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
592 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
596 ManageApplicationInfoForm::GetDefaultGroupItemHeight(void)
598 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
602 ManageApplicationInfoForm::GetDefaultItemHeight(void)
604 return H_GROUP_ITEM_DEFAULT;
608 ManageApplicationInfoForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
613 ManageApplicationInfoForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
617 case ID_GROUP_APPLICATION_NAME:
619 if (itemIndex == ID_ITEM_APPLICATION_NAME)
621 Label* pLabel = static_cast<Label*>(pItem->GetControl(APPLICATION_NAME_SECOND_CONTROL));
622 Rectangle rect = pLabel->GetBounds();
623 Rectangle clientRect = GetClientAreaBounds();
624 rect.width = clientRect.width - APPLICATION_NAME_MARGIN_GAP;
625 pLabel->SetBounds(rect);
627 pItem->Invalidate(false);
629 else if (itemIndex == ID_ITEM_APPLICATION_COMMAND_BUTTON)
631 Rectangle pItemRect = pItem->GetBounds();
632 Rectangle clientRect = GetClientAreaBounds();
634 Button* pStopButton = static_cast<Button*>(pItem->GetControl(0));
635 Button* pUninstallButton = static_cast<Button*>(pItem->GetControl(1));
637 pStopButton->SetBounds(0, 0, (clientRect.width / DIVIDE_BY_TWO - COMMAND_BUTTON_GAP), pItemRect.height);
638 pUninstallButton->SetBounds((clientRect.width / DIVIDE_BY_TWO), 0, (clientRect.width / DIVIDE_BY_TWO - COMMAND_BUTTON_GAP), pItemRect.height);
640 String appId = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_ID)));
641 AppManager* pAppManager = AppManager::GetInstance();
643 if (pAppManager->IsRunning(appId) == false)
645 pStopButton->SetEnabled(false);
649 pStopButton->SetEnabled(true);
652 pStopButton->Invalidate(false);
653 pUninstallButton->Invalidate(false);
664 ManageApplicationInfoForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
669 ManageApplicationInfoForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
674 ManageApplicationInfoForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
676 if (__pTableView == null)
678 AppLogDebug("__pTableView is null");
681 __pTableView->RefreshItem(ID_GROUP_APPLICATION_NAME, ID_ITEM_APPLICATION_NAME, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
682 __pTableView->RefreshItem(ID_GROUP_APPLICATION_NAME, ID_ITEM_APPLICATION_COMMAND_BUTTON, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
687 ManageApplicationInfoForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
693 String appId = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_ID)));
694 AppManager* pAppManager = AppManager::GetInstance();
696 if (pAppManager->IsRunning(appId) == true)
698 if (pAppManager->TerminateApplication(appId) == E_SUCCESS)
700 Button* pStopButton = static_cast<Button*>(&const_cast<Control&>(source));
701 pStopButton->SetEnabled(false);
703 AppLogDebug("TerminateApplication Result [%s]", GetErrorMessage(GetLastResult()));
707 AppLogDebug("[%ls] is not running", appId.GetPointer());
714 CreateUninstallPopup();
715 ShowUninstallPopup(UNINSTALL_POPUP_OKCANCEL);
719 case IDA_UNINSTALL_CONFIRM_OK:
721 String packageId = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_PACKAGE_ID)));
722 __pPackageManager->UninstallPackage (packageId, null);
724 HideUninstallPopup(UNINSTALL_POPUP_OKCANCEL);
725 ShowUninstallPopup(UNINSTALL_POPUP_PROGRESS);
729 case IDA_UNINSTALL_CONFIRM_CANCEL:
731 HideUninstallPopup(UNINSTALL_POPUP_OKCANCEL);
741 ManageApplicationInfoForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
745 __pTableView->RefreshItem(ID_GROUP_APPLICATION_NAME, ID_ITEM_APPLICATION_COMMAND_BUTTON, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
750 ManageApplicationInfoForm::OnPackageUninstallationCompleted(const Tizen::App::PackageId& packageId, bool uninstallationResult)
752 HideUninstallPopup(UNINSTALL_POPUP_PROGRESS);
754 SceneManager* pSceneManager = SceneManager::GetInstance();
755 AppAssert(pSceneManager);
757 ArrayList* pUninstallationResult = new (std::nothrow) ArrayList(SingleObjectDeleter);
758 pUninstallationResult->Construct();
760 String applicationName = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_NAME)));
761 pUninstallationResult->Add(new (std::nothrow) String(applicationName));
762 pUninstallationResult->Add(new (std::nothrow) String(Boolean::ToString(uninstallationResult)));
764 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pUninstallationResult);
768 ManageApplicationInfoForm::CreateUninstallPopup(void)
771 Label* pLabel = null;
772 Button* pOkButton = null;
773 Button* pCancelButton = null;
774 String applicationName = *(static_cast<String*>(__applicationData->GetAt(DATA_TYPE_APPLICATION_NAME)));
776 Rectangle clientRect = GetClientAreaBounds();
777 Rectangle itemRectLabel;
778 Rectangle itemRectLhsButton;
779 Rectangle itemRectRhsButton;
782 clientRect.y = Y_ALERT_POPUP_CLIENT_RECT_DEFAULT;
783 clientRect.width = W_ALERT_POPUP_CLIENT_RECT_DEFAULT;
784 clientRect.height = H_ALERT_POPUP_CLIENT_RECT_DEFAULT;
786 itemRectLabel.x = X_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
787 itemRectLabel.y = Y_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
788 itemRectLabel.width = W_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
789 itemRectLabel.height = H_ALERT_POPUP_ITEM_RECT_LABEL_DEFAULT;
791 itemRectLhsButton.x = X_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT + itemRectLabel.x;
792 itemRectLhsButton.y = Y_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
793 itemRectLhsButton.width = W_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
794 itemRectLhsButton.height = H_ALERT_POPUP_ITEM_RECT_LHS_BUTTON_DEFAULT;
796 itemRectRhsButton = itemRectLhsButton;
797 itemRectRhsButton.x = itemRectLhsButton.x + itemRectLhsButton.width + X_ALERT_POPUP_ITEM_RECT_RHS_BUTTON_RESIZE;
799 Dimension bounds = Dimension(clientRect.width, clientRect.height);
801 __uninstallConfirmPopup = new (std::nothrow) Popup();
802 __uninstallConfirmPopup->Construct(true, bounds);
803 __uninstallConfirmPopup->SetTitleText(applicationName);
804 __uninstallConfirmPopup->SetTitleTextColor(COLOR_SUB_TEXT);
806 String descriptionText = ResourceManager::GetString(L"IDS_SAPPS_POP_ARE_YOU_SURE_Q");
808 pLabel = new (std::nothrow) Label();
809 pLabel->Construct(itemRectLabel, descriptionText);
810 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
811 pLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
812 pLabel->SetTextConfig(ALERT_POPUP_LABEL_FONT_SIZE, LABEL_TEXT_STYLE_BOLD);
814 __uninstallConfirmPopup->AddControl(pLabel);
816 buttonText = ResourceManager::GetString(L"IDS_ST_BUTTON_UNINSTALL");
817 pOkButton = new (std::nothrow) Button();
818 pOkButton->Construct(itemRectLhsButton, buttonText);
819 pOkButton->SetActionId(IDA_UNINSTALL_CONFIRM_OK);
821 __uninstallConfirmPopup->AddControl(pOkButton);
823 buttonText = ResourceManager::GetString(L"IDS_COM_SK_NO");
825 pCancelButton = new (std::nothrow) Button();
826 pCancelButton->Construct(itemRectRhsButton, buttonText);
827 pCancelButton->SetActionId(IDA_UNINSTALL_CONFIRM_CANCEL);
829 __uninstallConfirmPopup->AddControl(pCancelButton);
831 pOkButton->AddActionEventListener(*this);
832 pCancelButton->AddActionEventListener(*this);
834 __pProgressPopup = new (std::nothrow) ProgressPopup();
835 __pProgressPopup->Construct(false, false);
836 __pProgressPopup->SetTitleText(applicationName);
837 __pProgressPopup->SetBounds(clientRect);
839 descriptionText = ResourceManager::GetString(L"IDS_ST_BUTTON_UNINSTALL");
840 descriptionText.Append(L"....");
841 __pProgressPopup->SetText(descriptionText);
847 ManageApplicationInfoForm::ShowUninstallPopup(int popupType)
851 case UNINSTALL_POPUP_OKCANCEL:
853 __uninstallConfirmPopup->SetShowState(true);
854 __uninstallConfirmPopup->Show();
858 case UNINSTALL_POPUP_PROGRESS:
860 __pProgressPopup->SetShowState(true);
861 __pProgressPopup->Show();
871 ManageApplicationInfoForm::HideUninstallPopup(int popupType)
875 case UNINSTALL_POPUP_OKCANCEL:
877 __uninstallConfirmPopup->SetShowState(false);
878 __uninstallConfirmPopup->Invalidate(true);
882 case UNINSTALL_POPUP_PROGRESS:
884 __pProgressPopup->SetShowState(false);
885 __pProgressPopup->Invalidate(true);
895 ManageApplicationInfoForm::DeleteUninstallPopup(void)
897 if (__uninstallConfirmPopup)
899 delete __uninstallConfirmPopup;
900 __uninstallConfirmPopup = null;
903 if (__pProgressPopup)
905 delete __pProgressPopup;
906 __pProgressPopup = null;