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 InstalledPopup.cpp
19 * @brief This is the implementation file for InstalledPopup class.
25 #include "AppResourceId.h"
26 #include "IstInstalledPopup.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Ui;
32 using namespace Tizen::Ui::Controls;
34 InstalledPopup::InstalledPopup()
36 , __isLaunchable(true)
40 InstalledPopup::~InstalledPopup()
45 InstalledPopup::Initialize(Tizen::Ui::Control* pTarget)
47 result r = Construct(IDL_INSTALLED_POPUP);
50 AppLogException("[%s] Failed to construct popup.", GetErrorMessage(r));
60 InstalledPopup::RequestPopup(const Tizen::Base::String& appName, const Tizen::Base::String& installedVersion,
61 const Tizen::Base::String& downloadedVersion, bool isLaunchable)
63 AppResource* pAppResource = AppResource::GetInstance();
64 int compare = downloadedVersion.CompareTo(installedVersion);
67 pAppResource->GetString(IDS_APINST_POP_AN_OLDER_VERSION_IS_ALREADY_INSTALLED_ON_YOUR_DEVICE_IT_WILL_BE_UPDATED, __installMessage);
70 pAppResource->GetString(IDS_APINST_BUTTON_UPDATE, buttonString);
71 static_cast<Button*>(GetControl(IDC_BUTTON_REINSTALL, true))->SetText(buttonString);
75 pAppResource->GetString(IDS_APINST_POP_A_NEWER_VERSION_IS_ALREADY_INSTALLED_ON_YOUR_DEVICE_IT_WILL_BE_REPLACED_WITH_THE_OLDER_VERSION, __installMessage);
79 pAppResource->GetString(IDS_APINST_POP_THIS_VERSION_IS_ALREADY_INSTALLED_ON_YOUR_DEVICE_IT_WILL_BE_REINSTALLED, __installMessage);
83 pAppResource->GetString(IDS_APINST_BODY_INSTALLED_VERSION_C_ABB, version);
84 version.Format(version.GetLength() + installedVersion.GetLength(), version.GetPointer(), installedVersion.GetPointer());
85 __versionMessage = version;
86 __versionMessage.Append(L"\n");
88 pAppResource->GetString(IDS_APINST_BODY_DOWNLOADED_VERSION_C_ABB, version);
89 version.Format(version.GetLength() + downloadedVersion.GetLength(), version.GetPointer(), downloadedVersion.GetPointer());
90 __versionMessage.Append(version);
92 __isLaunchable = isLaunchable;
99 InstalledPopup::OnInitializing(void)
101 AppLogDebug("Enter");
102 SetPropagatedKeyEventListener(this);
104 Label* pMessage = static_cast<Label*>(GetControl(IDC_LABEL_MESSAGE));
105 pMessage->SetText(__installMessage);
107 Label* pVersionInfo = static_cast<Label*>(GetControl(IDC_LABEL_VERSION));
108 pVersionInfo->SetText(__versionMessage);
110 Button* pReInstallButton = static_cast<Button*>(GetControl(IDC_BUTTON_REINSTALL, true));
111 pReInstallButton->SetActionId(IDA_BUTTON_REINSTALL);
112 pReInstallButton->AddActionEventListener(*this);
114 Button* pLaunchButton = static_cast<Button*>(GetControl(IDC_BUTTON_LAUNCH, true));
115 pLaunchButton->SetActionId(IDA_BUTTON_LAUNCH);
116 pLaunchButton->AddActionEventListener(*this);
118 Button* pCancelButton = static_cast<Button*>(GetControl(IDC_BUTTON_CANCEL, true));
119 pCancelButton->SetActionId(IDA_BUTTON_CANCEL);
120 pCancelButton->AddActionEventListener(*this);
124 GridLayout* pLayout = static_cast<GridLayout*>(static_cast<Panel*>(GetControl(IDC_PANEL))->GetLandscapeLayoutN());
125 pLayout->SetColumnCollapsed(2, true);
128 pLayout = static_cast<GridLayout*>(static_cast<Panel*>(GetControl(IDC_PANEL))->GetPortraitLayoutN());
129 pLayout->SetColumnCollapsed(2, true);
138 InstalledPopup::OnTerminating(void)
140 AppLogDebug("Enter");
141 SetPropagatedKeyEventListener(null);
146 InstalledPopup::OnActionPerformed(const Control& source, int actionId)
152 __pTarget->SendUserEvent(actionId, null);
157 InstalledPopup::OnKeyReleased(Tizen::Ui::Control &source, const Tizen::Ui::KeyEventInfo &keyEventInfo)
159 AppLogDebug("%d", keyEventInfo.GetKeyCode());
160 if (keyEventInfo.GetKeyCode() == KEY_BACK || keyEventInfo.GetKeyCode() == KEY_ESC)
165 __pTarget->SendUserEvent(IDA_BUTTON_CANCEL, null);