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 StAboutPhoneForm.cpp
19 * @brief This is the implementation file for PhoneInfoForm class.
22 #include <FTelephony.h>
23 #include "StAboutPhoneForm.h"
24 #include "StBluetoothPresentationModel.h"
25 #include "StResourceManager.h"
26 #include "StSettingScenesList.h"
28 #include "StWifiPresentationModel.h"
30 using namespace Tizen::App;
31 using namespace Tizen::Base;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Net::Wifi;
34 using namespace Tizen::System;
35 using namespace Tizen::Telephony;
36 using namespace Tizen::Ui;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
40 static const int ID_GROUP_ABOUT_PHONE_MAIN = 0;
41 static const int ID_GROUP_ABOUT_PHONE_MAIN_ITEM_COUNT = 8;
42 static const int ID_ITEM_ABOUT_PHONE_MAIN_NAME = 0;
43 static const int ID_ITEM_ABOUT_PHONE_MAIN_MY_NUMBER = 1;
44 static const int ID_ITEM_ABOUT_PHONE_MAIN_MODEL = 2;
45 static const int ID_ITEM_ABOUT_PHONE_MAIN_VERSION = 3;
46 static const int ID_ITEM_ABOUT_PHONE_MAIN_BLUETOOTH = 4;
47 static const int ID_ITEM_ABOUT_PHONE_MAIN_WIFI = 5;
48 static const int ID_ITEM_ABOUT_PHONE_MAIN_BATTERY = 6;
49 static const int ID_ITEM_ABOUT_PHONE_MAIN_CPU_USAGE = 7;
51 static const int ID_GROUP_ABOUT_PHONE_CERTIFICATE = 1;
52 static const int ID_GROUP_ABOUT_PHONE_CERTIFICATE_ITEM_COUNT = 1;
54 static const int ID_GROUP_COUNT = 2;
55 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_ABOUT_PHONE_MAIN_ITEM_COUNT;
56 static const int LIMIT_EDITFIELD = 100;
57 static const int DEFAULT_TEXT_SIZE = 10;
59 static const int ID_SECOND_CONTROL = 1;
60 static const int ID_RECEIVED_USER_EVENT_CPU_USAGE = 400;
62 static const char ISSPACE = 0x20;
65 CpuUsageGetIntAsyncResultListener::OnResultReceivedForGetValueAsync(int value, result r)
71 CpuUsageGetIntAsyncResultListener::SetSendEventForm(Tizen::Ui::Controls::Form* pForm, int requestId)
73 __pReceivedForm = pForm;
74 __requestId = requestId;
78 CpuUsageGetIntAsyncResultListener::SendEvent(result r, int value)
80 Collection::ArrayList* pData = new (std::nothrow) Collection::ArrayList(Collection::SingleObjectDeleter);
83 pData->Add(new (std::nothrow) String(GetErrorMessage(r)));
84 pData->Add(new (std::nothrow) String(Integer::ToString(value)));
86 __pReceivedForm->SendUserEvent( __requestId, pData);
89 PhoneInfoForm::PhoneInfoForm(void)
91 , __CpuUsageGetInfoResultListener(null)
92 , __pCpuUsageData(L"")
96 PhoneInfoForm::~PhoneInfoForm(void)
101 PhoneInfoForm::CreateFooter(void)
103 Footer* pFooter = GetFooter();
106 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
107 pFooter->SetBackButton();
109 SetFormBackEventListener(this);
113 PhoneInfoForm::OnInitializing(void)
115 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_ABOUT_PHONE"));
119 PowerManager::SetBatteryEventListener(this);
120 PowerManager::AddChargingEventListener(*this);
122 __pTableView->Draw(true);
123 RefreshTableViewItem(0);
129 PhoneInfoForm::OnTerminating(void)
131 if (__pTableView != null)
133 __pTableView->SetItemProvider(null);
136 PowerManager::SetBatteryEventListener(null);
137 PowerManager::RemoveChargingEventListener(*this);
139 SetFormBackEventListener(null);
144 PhoneInfoForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
146 if (previousSceneId.Equals(IDSCN_CERTIFICATE, false))
153 PhoneInfoForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
158 PhoneInfoForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
160 if (__pEditField == null)
165 if (__pEditField->GetText().IsEmpty() == true)
167 ShowMessageBox(L"", ResourceManager::GetString(L"IDS_ST_BODY_THE_NAME_FIELD_CANNOT_BE_EMPTY"));
168 __pEditField->SetFocus();
172 bool showEmptyMessageBox = true;
173 int textLength = __pEditField->GetText().GetLength();
175 for (int i = 0; i < textLength; i++)
178 __pEditField->GetText().GetCharAt(i, element);
180 if (element != ISSPACE)
182 showEmptyMessageBox = false;
187 if (showEmptyMessageBox == true)
189 ShowMessageBox(L"", L"The Name cannot be empty or composited by spaces");
190 __pEditField->SetFocus();
194 if (SettingInfo::SetValue(SETTING_INFO_KEY_DEVICE_NAME, __pEditField->GetText()) == E_SUCCESS)
196 SceneManager* pSceneManager = SceneManager::GetInstance();
197 AppAssert(pSceneManager);
199 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
206 PhoneInfoForm::GetGroupCount(void)
208 AppLogDebug("ENTER");
209 return ID_GROUP_COUNT;
213 PhoneInfoForm::GetItemCount(int groupIndex)
219 case ID_GROUP_ABOUT_PHONE_MAIN:
221 itemCount = ID_GROUP_MAX_ITEM_COUNT;
225 case ID_GROUP_ABOUT_PHONE_CERTIFICATE:
227 itemCount = ID_GROUP_ABOUT_PHONE_CERTIFICATE_ITEM_COUNT;
234 AppLogDebug("GetItemCount %d", itemCount);
240 PhoneInfoForm::CreateGroupItem(int groupIndex, int itemWidth)
242 AppLogDebug("ENTER");
244 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
245 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
246 LabelTextStyle style = LABEL_TEXT_STYLE_BOLD;
248 Label* pLabel = null;
252 case ID_GROUP_ABOUT_PHONE_MAIN:
254 yItemOffset = H_GROUP_INDEX_TITLE_TEXT;
255 itemHeight = H_GROUP_INDEX_DEFAULT;
256 groupText = ResourceManager::GetString(L"IDS_ST_BODY_DEVICE_INFO");
262 yItemOffset = Y_GROUP_INDEX_DEFAULT;
263 itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
268 Rectangle itemMainRectangle(X_GROUP_INDEX_DEFAULT_LABEL, yItemOffset, itemWidth, itemHeight);
270 RelativeLayout relativeLayout;
271 relativeLayout.Construct();
273 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
274 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
275 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
277 pLabel = new (std::nothrow) Label();
278 pLabel->Construct(itemMainRectangle, groupText);
279 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
280 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
281 pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, style);
282 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
284 pItem->AddControl(pLabel);
285 pItem->SetEnabled(false);
286 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
287 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
288 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
294 PhoneInfoForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
296 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
299 bool isItemSubText = false;
300 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
301 Rectangle itemMainRectangle;
302 Rectangle itemSubRectangle;
305 Label* pLabel = null;
306 int itemHeight = H_GROUP_ITEM_DEFAULT;
307 int fontSize = GetFontSize();
309 if (groupIndex == ID_GROUP_ABOUT_PHONE_MAIN)
311 isItemSubText = true;
312 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
313 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
317 case ID_ITEM_ABOUT_PHONE_MAIN_NAME:
319 itemMainRectangle.x = 0;
320 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_NAME");
323 if (SettingInfo::GetValue(SETTING_INFO_KEY_DEVICE_NAME, phoneName) != E_SUCCESS)
325 itemSubText = L"Tizen";
329 itemSubText.Append(phoneName);
331 ItemTypeOneLine(itemMainRectangle);
332 itemMainRectangle.height = itemHeight;
333 isItemSubText = false;
337 case ID_ITEM_ABOUT_PHONE_MAIN_MY_NUMBER:
339 SimStateManager* pSimStateManager = new (std::nothrow) SimStateManager();
342 if (pSimStateManager->Construct() == E_SUCCESS && pSimStateManager->GetSimInfo(simInfo) == E_SUCCESS)
344 itemSubText = simInfo.GetPhoneNumber();
346 if (itemSubText.IsEmpty() == true)
348 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
353 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
356 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_MY_NUMBER");
357 delete pSimStateManager;
361 case ID_ITEM_ABOUT_PHONE_MAIN_MODEL:
363 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_MODELNAME, itemSubText) != E_SUCCESS)
365 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
366 AppLogDebug("GetValue Fail.. - %s", GetErrorMessage(GetLastResult()));
369 itemMainText = ResourceManager::GetString(L"IDS_COM_BODY_MODEL");
373 case ID_ITEM_ABOUT_PHONE_MAIN_VERSION:
376 if (SystemInfo::GetPlatformVersion(getVersion) == E_SUCCESS)
378 itemSubText.Remove(0, itemSubText.GetLength());
379 itemSubText.Insert(getVersion, itemSubText.GetLength());
383 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
385 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_VERSION");
389 case ID_ITEM_ABOUT_PHONE_MAIN_BLUETOOTH:
391 bool EnableStatus = false;
392 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH");
394 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_BLUETOOTH, EnableStatus) == E_SUCCESS)
396 BluetoothPresentationModel* pInstance = BluetoothPresentationModel::GetInstance();
397 if (EnableStatus == true && pInstance != null)
399 itemSubText = pInstance->GetBluetoothLocalMacAddress();
403 if (itemSubText.IsEmpty() == true)
405 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
410 case ID_ITEM_ABOUT_PHONE_MAIN_WIFI:
412 bool EnableStatus = false;
413 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_WI_FI");
415 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_WIFI, EnableStatus) == E_SUCCESS)
417 WifiPresentationModel* pInstance = WifiPresentationModel::GetInstance();
418 if (EnableStatus == true && pInstance != null)
420 itemSubText = pInstance->GetWifiMacAddress();
424 if (itemSubText.IsEmpty() == true)
426 itemSubText = ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE");
431 case ID_ITEM_ABOUT_PHONE_MAIN_BATTERY:
433 int batteryLevel = 0;
435 Battery::GetCurrentLevelInPercentage(batteryLevel);
436 batteryText.Format(DEFAULT_TEXT_SIZE, L"%d%%", batteryLevel);
437 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_BATTERY");
441 case ID_ITEM_ABOUT_PHONE_MAIN_CPU_USAGE:
444 SetICpuUsageResultListener();
446 if (RuntimeInfo::GetValueAsync(RUNTIME_INFO_KEY_CPU_USAGE, __CpuUsageGetInfoResultListener))
448 itemSubText = Integer::ToString(cpuUsage);
449 itemSubText.Append(L"%");
453 AppLogDebug("Get Value Result [%s]", GetErrorMessage(GetLastResult()));
457 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CPU_USAGE");
467 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_CERTIFICATES");
468 ItemTypeOneLine(itemMainRectangle);
471 RelativeLayout relativeLayout;
472 relativeLayout.Construct();
474 TableViewItem* pItem = new (std::nothrow) TableViewItem();
475 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
476 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
478 if ((groupIndex == ID_GROUP_ABOUT_PHONE_MAIN) && (itemIndex == ID_ITEM_ABOUT_PHONE_MAIN_NAME))
480 __pEditField = new (std::nothrow) EditField();
481 __pEditField->Construct(itemMainRectangle, EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_TOP, true, LIMIT_EDITFIELD, GROUP_STYLE_NONE);
482 __pEditField->SetGuideText(ResourceManager::GetString(L"IDS_ST_HEADER_DEVICE_NAME_ABB"));
483 __pEditField->SetTitleText(itemMainText);
484 __pEditField->SetText(itemSubText);
485 __pEditField->SetTextSize(fontSize);
486 __pEditField->SetTitleTextColor(EDIT_STATUS_NORMAL, COLOR_HELP_TEXT_TYPE_01);
487 __pEditField->SetColor(EDIT_STATUS_NORMAL, COLOR_BG_GROUP_INDEX_DEFAULT);
488 __pEditField->SetColor(EDIT_STATUS_PRESSED, COLOR_BG_GROUP_INDEX_DEFAULT);
489 __pEditField->SetColor(EDIT_STATUS_HIGHLIGHTED, COLOR_BG_GROUP_INDEX_DEFAULT);
491 __pEditField->AddActionEventListener(*this);
492 __pEditField->AddKeypadEventListener(*this);
494 pItem->SetIndividualSelectionEnabled(__pEditField, true);
495 pItem->AddControl(__pEditField);
497 relativeLayout.SetMargin(*__pEditField, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
498 relativeLayout.SetRelation(*__pEditField, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
499 relativeLayout.SetRelation(*__pEditField, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
503 pLabel = new (std::nothrow) Label();
504 pLabel->Construct(itemMainRectangle, itemMainText);
505 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
506 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
507 pLabel->SetTextColor(COLOR_MAIN_TEXT);
509 if (groupIndex != ID_GROUP_ABOUT_PHONE_CERTIFICATE)
511 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
512 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
513 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
515 pItem->AddControl(pLabel);
517 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
518 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
519 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
520 if (isItemSubText == true)
522 if ((groupIndex == ID_GROUP_ABOUT_PHONE_MAIN) && (itemIndex == ID_ITEM_ABOUT_PHONE_MAIN_BATTERY))
524 itemSubText = batteryText;
526 pLabel = new (std::nothrow) Label();
527 pLabel->Construct(itemSubRectangle, itemSubText);
528 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
529 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
530 pLabel->SetTextColor(COLOR_SUB_TEXT);
531 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
532 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
533 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT, TABLE_VIEW_ITEM_DRAWING_STATUS_HIGHLIGHTED);
534 pItem->AddControl(pLabel);
535 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
536 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
537 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
545 PhoneInfoForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
547 AppLogDebug("ENTER");
556 PhoneInfoForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
558 AppLogDebug("ENTER");
567 PhoneInfoForm::OnBatteryLevelChangedInPercentage(int percentage)
569 if (__pTableView != null)
571 __pTableView->RefreshItem(ID_GROUP_ABOUT_PHONE_MAIN, ID_ITEM_ABOUT_PHONE_MAIN_BATTERY, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
576 PhoneInfoForm::OnChargingStateChanged(bool charging)
578 AppLogDebug("charging %d", charging);
582 PhoneInfoForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
584 if (__pEditField != null)
586 __pEditField->HideKeypad();
587 __pEditField->Invalidate(false);
592 case ID_GROUP_ABOUT_PHONE_CERTIFICATE:
594 SceneManager* pSceneManager = SceneManager::GetInstance();
595 AppAssert(pSceneManager);
597 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_CERTIFICATE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
610 PhoneInfoForm::GetDefaultGroupItemHeight(void)
612 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
616 PhoneInfoForm::GetDefaultItemHeight(void)
618 return H_GROUP_ITEM_DEFAULT;
622 PhoneInfoForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
627 PhoneInfoForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
629 AppLogDebug("update :: group[%d] item[%d]", groupIndex, itemIndex);
631 if ( groupIndex == ID_GROUP_ABOUT_PHONE_MAIN)
638 case ID_ITEM_ABOUT_PHONE_MAIN_NAME:
640 EditField* pEditField = static_cast<EditField*>(pItem->GetControl(0));
641 if (pEditField == null)
643 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_NAME Label is null");
649 if (SettingInfo::GetValue(SETTING_INFO_KEY_DEVICE_NAME, phoneName) == E_SUCCESS)
651 if (!pEditField->GetText().Equals(phoneName, false))
653 pEditField->SetText(phoneName);
654 pEditField->Invalidate(false);
660 case ID_ITEM_ABOUT_PHONE_MAIN_MY_NUMBER:
662 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
663 pSecondLine = static_cast<Label*>(pItem->GetControl(1));
664 if ((pFirstLine == null) || (pSecondLine == null))
666 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_MY_NUMBER Label is null");
672 pFirstLine->SetText(ResourceManager::GetString(L"IDS_ST_BODY_MY_NUMBER"));
673 pFirstLine->Invalidate(false);
675 SimStateManager* pSimStateManager = new (std::nothrow) SimStateManager();
678 if (pSimStateManager->Construct() == E_SUCCESS && pSimStateManager->GetSimInfo(simInfo) == E_SUCCESS)
680 tempValue.Remove(0, tempValue.GetLength());
681 tempValue = simInfo.GetPhoneNumber();
683 if (pSecondLine->GetText().Equals(tempValue, false) == false)
685 pSecondLine->Invalidate(false);
690 pSecondLine->SetText(ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE"));
691 pSecondLine->Invalidate(false);
693 delete pSimStateManager;
697 case ID_ITEM_ABOUT_PHONE_MAIN_MODEL:
699 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
700 pSecondLine = static_cast<Label*>(pItem->GetControl(1));
701 if ((pFirstLine == null) || (pSecondLine == null))
703 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_MODEL Label is null");
707 pFirstLine->SetText(ResourceManager::GetString(L"IDS_COM_BODY_MODEL"));
708 pFirstLine->Invalidate(false);
712 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_MODELNAME, modelName) != E_SUCCESS)
714 pSecondLine->SetText(ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE"));
718 pSecondLine->SetText(modelName);
720 pSecondLine->Invalidate(false);
724 case ID_ITEM_ABOUT_PHONE_MAIN_VERSION:
726 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
727 pSecondLine = static_cast<Label*>(pItem->GetControl(1));
728 if ((pFirstLine == null) || (pSecondLine == null))
730 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_VERSION Label is null");
734 pFirstLine->SetText(ResourceManager::GetString(L"IDS_ST_BODY_VERSION"));
735 pFirstLine->Invalidate(false);
738 if (SystemInfo::GetPlatformVersion(phoneVersion) != E_SUCCESS)
740 pSecondLine->SetText(ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE"));
744 pSecondLine->SetText(phoneVersion);
746 pSecondLine->Invalidate(false);
750 case ID_ITEM_ABOUT_PHONE_MAIN_BLUETOOTH:
752 bool enableStatus = false;
754 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
755 pSecondLine = static_cast<Label*>(pItem->GetControl(1));
756 if ((pFirstLine == null) || (pSecondLine == null))
758 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_BLUETOOTH Label is null");
762 pFirstLine->SetText(ResourceManager::GetString(L"IDS_ST_BODY_BLUETOOTH"));
763 pFirstLine->Invalidate(false);
765 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_BLUETOOTH, enableStatus) != E_SUCCESS)
767 pSecondLine->SetText(ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE"));
768 pSecondLine->Invalidate(false);
773 case ID_ITEM_ABOUT_PHONE_MAIN_WIFI:
775 bool enableStatus = false;
777 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
778 pSecondLine = static_cast<Label*>(pItem->GetControl(1));
779 if ((pFirstLine == null) || (pSecondLine == null))
781 AppLogDebug("ID_ITEM_ABOUT_PHONE_MAIN_WIFI Label is null");
785 pFirstLine->SetText(ResourceManager::GetString(L"IDS_ST_BODY_WI_FI"));
786 pFirstLine->Invalidate(false);
788 if (SystemInfo::GetValue(SYSTEM_INFO_KEY_WIFI, enableStatus) != E_SUCCESS)
790 pSecondLine->SetText(ResourceManager::GetString(L"IDS_ST_HEADER_UNAVAILABLE"));
791 pSecondLine->Invalidate(false);
796 case ID_ITEM_ABOUT_PHONE_MAIN_BATTERY:
798 int batteryLevel = 0;
799 pFirstLine = static_cast<Label*>(pItem->GetControl(0));
800 pSecondLine = static_cast<Label*>(pItem->GetControl(ID_SECOND_CONTROL));
801 if ((pFirstLine == null) || (pSecondLine == null))
806 pFirstLine->SetText(ResourceManager::GetString(L"IDS_ST_BODY_BATTERY"));
807 pFirstLine->Invalidate(false);
809 String batteryPercentage;
811 Battery::GetCurrentLevelInPercentage(batteryLevel);
812 batteryPercentage.Format(DEFAULT_TEXT_SIZE, L"%d%%", batteryLevel);
814 pSecondLine->SetText(batteryPercentage);
815 pSecondLine->Invalidate(false);
819 case ID_ITEM_ABOUT_PHONE_MAIN_CPU_USAGE:
821 Label* pLabel = static_cast<Label*>(pItem->GetControl(ID_SECOND_CONTROL));
822 pLabel->SetText(__pCpuUsageData + L"%");
823 pLabel->Invalidate(false);
834 PhoneInfoForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
839 PhoneInfoForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
844 PhoneInfoForm::OnKeypadClosed(Tizen::Ui::Control& source)
849 PhoneInfoForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
851 AppLogDebug("keypadAction Status[%d]", keypadAction);
853 switch (keypadAction)
855 case KEYPAD_ACTION_ENTER:
857 case KEYPAD_ACTION_DONE:
859 __pEditField->HideKeypad();
860 __pEditField->Invalidate(false);
870 PhoneInfoForm::SetICpuUsageResultListener(void)
872 __CpuUsageGetInfoResultListener = new (std::nothrow) CpuUsageGetIntAsyncResultListener();
873 __CpuUsageGetInfoResultListener->SetSendEventForm(this, ID_RECEIVED_USER_EVENT_CPU_USAGE);
877 PhoneInfoForm::RefreshTableViewItem(int groupIndex)
879 int itemCount = __pTableView->GetItemCountAt(groupIndex);
881 bool showEmptyMessageBox = true;
882 int textLength = __pEditField->GetText().GetLength();
884 for (int i = 0; i < textLength; i++)
887 __pEditField->GetText().GetCharAt(i, element);
889 if (element != ISSPACE)
891 showEmptyMessageBox = false;
896 for (int count = 0; count < itemCount; count++)
900 if ((showEmptyMessageBox == true) || (__pEditField->GetText().Equals(L"", false)))
902 AppLogDebug("__pEditField is empty");
906 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
911 __pTableView->RefreshItem(groupIndex, count, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
917 PhoneInfoForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
919 AppLogDebug("RequestFrom[%d]", requestId);
921 if (requestId == FRFRESH_REQUEST_EVENT)
923 RefreshTableViewItem(0);
925 else if (requestId == BACK_GROUND_EVENT)
928 if (SettingInfo::GetValue(SETTING_INFO_KEY_DEVICE_NAME, phoneName) != E_SUCCESS)
930 AppLogDebug("GetValue Fail ");
934 if (__pEditField->GetText().IsEmpty() == false)
936 bool showEmptyMessageBox = true;
937 int textLength = __pEditField->GetText().GetLength();
939 for (int i = 0; i < textLength; i++)
942 __pEditField->GetText().GetCharAt(i, element);
944 if (element != ISSPACE)
946 showEmptyMessageBox = false;
951 if (showEmptyMessageBox == false)
953 if (__pEditField->GetText().CompareTo(phoneName))
955 SettingInfo::SetValue(SETTING_INFO_KEY_DEVICE_NAME, __pEditField->GetText());
963 AppLogDebug("pArgs is null");
966 if (requestId == ID_RECEIVED_USER_EVENT_CPU_USAGE)
968 String* pResult = static_cast<String*>(pArgs->GetAt(0));
970 if (pResult->Equals(L"E_SUCCESS", false))
972 __pCpuUsageData = *(static_cast<String*>(pArgs->GetAt(1)));
973 __pTableView->RefreshItem(ID_GROUP_ABOUT_PHONE_MAIN, ID_ITEM_ABOUT_PHONE_MAIN_CPU_USAGE, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);