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 CtGroupEditorForm.cpp
19 * @brief This is the implementation file for the GroupEditorForm class.
24 #include "CtContactsApp.h"
25 #include "CtGroupEditorForm.h"
26 #include "CtGroupPresentationModel.h"
27 #include "CtResourceManager.h"
28 #include "CtSceneRegister.h"
31 using namespace Tizen::App;
32 using namespace Tizen::Base;
33 using namespace Tizen::Base::Collection;
34 using namespace Tizen::Graphics;
35 using namespace Tizen::Io;
36 using namespace Tizen::Media;
37 using namespace Tizen::Ui::Controls;
38 using namespace Tizen::Ui::Scenes;
39 using namespace Tizen::Social;
40 using namespace Tizen::System;
42 static const int IDA_HEADER_SAVE = 0;
43 static const int IDA_BUTTON_GALLERY = 10;
44 static const int IDA_BUTTON_TAKE_PHOTO = 11;
45 static const int IDA_BUTTON_REMOVE = 12;
46 static const int IDA_BUTTON_RINGTONE_CLEAR = 13;
48 static const wchar_t* IDB_ICON_ADD_NORMAL = L"C02_caller_id_icon_add.png";
49 static const wchar_t* IDB_ICON_ADD_PRESSED = L"C02_caller_id_icon_add_press.png";
50 static const wchar_t* IDB_ICON_CAMERA_NORMAL = L"C02_caller_id_icon_camera.png";
51 static const wchar_t* IDB_ICON_CAMERA_PRESSED = L"C02_caller_id_icon_camera_press.png";
52 static const wchar_t* IDB_ICON_REMOVE_NORMAL = L"00_button_expand_minus_press.png";
53 static const wchar_t* IDB_ICON_REMOVE_PRESSED = L"00_button_expand_minus_press.png";
54 static const wchar_t* IDB_REMOVE_BG_NORMAL = L"00_circle_button_delete.png";
55 static const wchar_t* IDB_REMOVE_BG_PRESSED = L"00_circle_button_delete_press.png";
56 static const wchar_t* IDB_DETAILS_RESET_NORMAL = L"00_button_refresh.png";
57 static const wchar_t* IDB_DETAILS_RESET_PRESSED = L"00_button_refresh_press.png";
59 static const int H_ITEM = 128;
60 static const int H_THUMBNAIL = 360;
61 static const int Y_THUMBNAIL = 57;
62 static const int H_ICON_BUTTON = 74;
63 static const int Y_REMOVE_BUTTON = 26;
64 static const int X_REMOVE_BUTTON_MARGIN = 40;
65 static const int X_REFRESH_BUTTON_MARGIN = 88;
67 static const int X_RINGTONE_TEXT = 3;
68 static const int Y_RINGTONE_TITLE = 10;
69 static const int Y_RINGTONE_NAME = 68;
70 static const int W_RINGTONE_TEXT = 600;
71 static const int H_RINGTONE_TITLE = 58;
72 static const int H_RINGTONE_NAME = 50;
74 static const unsigned int COLOR_GUIDE_TEXT = Color32<255, 0, 0>::Value;
75 static const unsigned int COLOR_RINGTONE = Color32<92, 151, 187>::Value;
76 static const unsigned int COLOR_RINGTONE_TITLE = Color32<128, 128, 128>::Value;
77 static const unsigned int COLOR_THUMBNAIL = Color32<239, 237, 229>::Value;
78 static const unsigned int COLOR_TABLE_BG = Color32<248, 246, 239>::Value;
80 static const int ITEM_COUNT = 3;
82 static const int FONT_SIZE_RINGTONE_TITLE = 40;
83 static const int FONT_SIZE_RINGTONE = 32;
85 static const wchar_t* INPUT_DATA_SELECTION_MODE_SINGLE = L"single";
86 static const wchar_t* INPUT_KEY_SELECTION_MODE = L"http://tizen.org/appcontrol/data/selection_mode";
87 static const wchar_t* INPUT_KEY_ALLOW_SWITCH = L"http://tizen.org/appcontrol/data/camera/allow_switch";
88 static const wchar_t* INPUT_MIME_TYPE_CAMERA = L"image/jpg";
89 static const wchar_t* INPUT_MIME_TYPE_GALLERY = L"image/*";
90 static const wchar_t* INPUT_MIME_TYPE_AUDIO = L"audio/*";
91 static const wchar_t* INPUT_VALUE_FALSE = L"false";
92 static const wchar_t* OUTPUT_KEY_SELECTED = L"http://tizen.org/appcontrol/data/selected";
93 static const wchar_t* THUMBNAIL_LABEL = L"thumbnail";
94 static const wchar_t* THUMBNAIL_EMPTY_LABEL = L"emptyThumbnail";
95 static const wchar_t* ADD_BUTTON = L"add";
96 static const wchar_t* CAMERA_BUTTON = L"camera";
97 static const wchar_t* REMOVE_BUTTON = L"remove";
98 static const wchar_t* SD_CARD_UNMOUNTED = L"Unmounted";
100 GroupEditorForm::GroupEditorForm(void)
101 : __pPresentationModel(null)
103 , __isEditMode(false)
108 GroupEditorForm::~GroupEditorForm(void)
113 GroupEditorForm::Initialize(void)
115 Construct(L"IDL_GROUP_EDITOR_FORM");
119 GroupEditorForm::OnInitializing(void)
121 Footer* pFooter = GetFooter();
122 pFooter->AddActionEventListener(*this);
123 SetFormBackEventListener(this);
124 DeviceManager::AddDeviceEventListener(DEVICE_TYPE_STORAGE_CARD, *this);
126 __pTableView = new (std::nothrow) TableView();
127 __pTableView->Construct(Rectangle(0, 0, GetClientAreaBounds().width, GetClientAreaBounds().height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
128 __pTableView->SetItemProvider(this);
129 __pTableView->AddTableViewItemEventListener(*this);
130 AddControl(__pTableView);
136 GroupEditorForm::OnTerminating(void)
138 __pTableView->SetItemProvider(null);
140 delete __pPresentationModel;
146 GroupEditorForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
148 SceneManager* pSceneManager = SceneManager::GetInstance();
152 result r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
153 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
157 GroupEditorForm::OnFileEventOccured(const unsigned long events, const Tizen::Base::String &path, const unsigned int eventId)
159 __pPresentationModel->SetThumbnailPath(L"");
160 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
164 GroupEditorForm::OnDeviceStateChanged(Tizen::System::DeviceType deviceType, const Tizen::Base::String &state)
166 if (deviceType != DEVICE_TYPE_STORAGE_CARD || __pPresentationModel->GetThumbnailPath().IsEmpty())
171 if (state.Equals(SD_CARD_UNMOUNTED, false) && File::IsFileExist(__pPresentationModel->GetThumbnailPath()) == false)
173 __pPresentationModel->SetThumbnailPath(L"");
174 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
180 GroupEditorForm::OnActionPerformed(const Tizen::Ui::Control& source, int actionId)
184 case IDA_HEADER_SAVE:
186 long long avialableMemory = 0;
187 result r = E_SUCCESS;
189 String key(RUNTIMEINFO_INTERNAL_MEMORY_KEY);
190 r = RuntimeInfo::GetValue(key, avialableMemory);
191 if(avialableMemory == 0)
194 MessageBox memoryFullMessageBox;
195 memoryFullMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_EMAIL_POP_DEVICE_STORAGE_FULL"), MSGBOX_STYLE_NONE, 1000);
196 memoryFullMessageBox.ShowAndWait(modalResult);
200 __pTableView->RefreshItem(1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
202 if (__pPresentationModel->IsDefaultCategory() == false && __pPresentationModel->IsDuplicatedCategory() == true)
204 Footer* pFooter = GetFooter();
205 pFooter->SetItemEnabled(0, false);
211 r = __pPresentationModel->UpdateCategory();
215 OnCategoriesChanged();
217 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to update category", GetErrorMessage(r));
221 r = __pPresentationModel->AddCategory();
222 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to add category", GetErrorMessage(r));
229 case IDA_BUTTON_GALLERY:
231 LaunchAppControl(PROVIDER_ID_GALLERY, OPERATION_ID_PICK);
234 case IDA_BUTTON_TAKE_PHOTO:
236 LaunchAppControl(PROVIDER_ID_CAMERA, OPERATION_ID_CREATE_CONTENT);
239 case IDA_BUTTON_REMOVE:
241 __pPresentationModel->SetThumbnailPath(String());
242 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
243 __pTableView->RefreshItem(1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
246 case IDA_BUTTON_RINGTONE_CLEAR:
248 __pPresentationModel->SetRingtone(String());
249 __pTableView->RefreshItem(2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
258 GroupEditorForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId,
259 const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
261 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
262 pContactsApp->AddContactsAppChangeEventListener(*this);
264 RecordId categoryId = INVALID_RECORD_ID;
268 IEnumerator* pEnum = pArgs->GetEnumeratorN();
269 if (pEnum->MoveNext() == E_SUCCESS)
271 Integer* pCategoryId = static_cast<Integer*>(pEnum->GetCurrent());
272 if (pCategoryId != null)
274 categoryId = pCategoryId->ToInt();
280 pArgs->RemoveAll(true);
284 __pPresentationModel = new (std::nothrow) GroupPresentationModel();
285 __pPresentationModel->Construct(categoryId);
286 __pPresentationModel->AddContactChangeListener(*this);
288 Header* pHeader = GetHeader();
291 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_PB_OPT2_EDIT_GROUPS"));
295 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_COM_BODY_CREATE"));
298 Footer* pFooter = GetFooter();
301 pFooter->SetItemEnabled(0, true);
305 pFooter->SetItemEnabled(0, false);
311 GroupEditorForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId,
312 const Tizen::Ui::Scenes::SceneId& nextSceneId)
314 ContactsApp* pContactsApp = static_cast<ContactsApp*>(ContactsApp::GetInstance());
315 pContactsApp->RemoveContactsAppChangeEventListener(*this);
317 __pPresentationModel->RemoveContactChangeListener(*this);
321 GroupEditorForm::GetItemCount(void)
326 Tizen::Ui::Controls::TableViewItem*
327 GroupEditorForm::CreateItem(int itemIndex, int itemWidth)
329 Label* pSubjectLabel = null;
330 Label* pContentLabel = null;
331 int itemHeight = H_ITEM;
335 itemHeight = Y_THUMBNAIL * 2 + H_THUMBNAIL;
338 TableViewItem* pItem = new (std::nothrow) TableViewItem();
339 pItem->Construct(Dimension(itemWidth, itemHeight), TABLE_VIEW_ANNEX_STYLE_NORMAL);
343 Label* pThumbnailLabel = new (std::nothrow) Label();
344 pThumbnailLabel->Construct(Rectangle((itemWidth - H_THUMBNAIL) / 2, Y_THUMBNAIL, H_THUMBNAIL, H_THUMBNAIL), L"");
345 pThumbnailLabel->SetName(THUMBNAIL_LABEL);
346 pItem->AddControl(pThumbnailLabel);
347 Label* pEmptyThumbnailLabel = new (std::nothrow) Label();
348 pEmptyThumbnailLabel->Construct(Rectangle((itemWidth - H_THUMBNAIL) / 2, Y_THUMBNAIL, H_THUMBNAIL, H_THUMBNAIL), L"");
349 pEmptyThumbnailLabel->SetName(THUMBNAIL_EMPTY_LABEL);
350 pEmptyThumbnailLabel->SetBackgroundColor(COLOR_THUMBNAIL);
351 pItem->AddControl(pEmptyThumbnailLabel);
353 if (__pPresentationModel->GetThumbnailPath().IsEmpty() == false)
355 Bitmap* pThumbnail = null;
356 ImageBuffer thumbnailImageBuffer;
357 result r = thumbnailImageBuffer.Construct(__pPresentationModel->GetThumbnailPath());
360 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_RGB565, BUFFER_SCALING_NONE);
362 pThumbnailLabel->SetBackgroundBitmap(*pThumbnail);
365 pEmptyThumbnailLabel->SetShowState(false);
368 Button* pButtonAdd = new (std::nothrow) Button();
369 pButtonAdd->Construct(Rectangle((itemWidth - H_ICON_BUTTON) / 2, (H_THUMBNAIL - H_ICON_BUTTON) / 2 + Y_THUMBNAIL, H_ICON_BUTTON, H_ICON_BUTTON), L"");
370 pButtonAdd->SetActionId(IDA_BUTTON_GALLERY);
371 pButtonAdd->AddActionEventListener(*this);
372 pButtonAdd->SetName(ADD_BUTTON);
373 Bitmap* pIconNormal = ResourceManager::GetBitmapN(IDB_ICON_ADD_NORMAL);
374 Bitmap* pIconPressed = ResourceManager::GetBitmapN(IDB_ICON_ADD_PRESSED);
375 if (pIconNormal != null)
377 pButtonAdd->SetNormalBackgroundBitmap(*pIconNormal);
380 if (pIconPressed != null)
382 pButtonAdd->SetPressedBackgroundBitmap(*pIconPressed);
385 pItem->AddControl(pButtonAdd);
387 Button* pButtonCamera = new (std::nothrow) Button();
388 pButtonCamera->Construct(Rectangle((itemWidth - H_THUMBNAIL) / 2 + H_THUMBNAIL, Y_THUMBNAIL + H_THUMBNAIL - H_ICON_BUTTON, H_ICON_BUTTON, H_ICON_BUTTON), L"");
389 pButtonCamera->SetActionId(IDA_BUTTON_TAKE_PHOTO);
390 pButtonCamera->AddActionEventListener(*this);
391 pButtonCamera->SetName(CAMERA_BUTTON);
392 pIconNormal = ResourceManager::GetBitmapN(IDB_ICON_CAMERA_NORMAL);
393 pIconPressed = ResourceManager::GetBitmapN(IDB_ICON_CAMERA_PRESSED);
394 if (pIconNormal != null)
396 pButtonCamera->SetNormalBackgroundBitmap(*pIconNormal);
399 if (pIconPressed != null)
401 pButtonCamera->SetPressedBackgroundBitmap(*pIconPressed);
404 pItem->AddControl(pButtonCamera);
406 Button* pButtonRemove = new (std::nothrow) Button();
407 pButtonRemove->Construct(Rectangle((itemWidth - H_THUMBNAIL) / 2 - X_REMOVE_BUTTON_MARGIN, Y_REMOVE_BUTTON, H_ICON_BUTTON, H_ICON_BUTTON), L"");
408 pButtonRemove->SetActionId(IDA_BUTTON_REMOVE);
409 pButtonRemove->AddActionEventListener(*this);
410 pButtonRemove->SetName(REMOVE_BUTTON);
411 pIconNormal = ResourceManager::GetBitmapN(IDB_ICON_REMOVE_NORMAL);
412 pIconPressed = ResourceManager::GetBitmapN(IDB_ICON_REMOVE_PRESSED);
413 if (pIconNormal != null)
415 pButtonRemove->SetNormalBitmap(Point(0, 0), *pIconNormal);
418 if (pIconPressed != null)
420 pButtonRemove->SetPressedBitmap(Point(0, 0), *pIconPressed);
424 pIconNormal = ResourceManager::GetBitmapN(IDB_REMOVE_BG_NORMAL);
425 pIconPressed = ResourceManager::GetBitmapN(IDB_REMOVE_BG_PRESSED);
426 if (pIconNormal != null)
428 pButtonRemove->SetNormalBackgroundBitmap(*pIconNormal);
431 if (pIconPressed != null)
433 pButtonRemove->SetPressedBackgroundBitmap(*pIconPressed);
436 pItem->AddControl(pButtonRemove);
438 if (__pPresentationModel->GetThumbnailPath().IsEmpty() == true)
440 pButtonRemove->SetShowState(false);
444 pButtonAdd->SetShowState(false);
446 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
447 pItem->SetBackgroundColor(COLOR_TABLE_BG, TABLE_VIEW_ITEM_DRAWING_STATUS_PRESSED);
449 else if (itemIndex == 1)
451 EditField* pEditField = new (std::nothrow) EditField();
452 pEditField->Construct(Rectangle(0, 0, itemWidth, H_ITEM), EDIT_FIELD_STYLE_NORMAL, INPUT_STYLE_OVERLAY, EDIT_FIELD_TITLE_STYLE_TOP, !__pPresentationModel->IsDefaultCategory());
453 pEditField->AddTextEventListener(*this);
454 pEditField->AddKeypadEventListener(*this);
455 pEditField->SetText(__pPresentationModel->GetCategoryName());
456 pEditField->SetTitleText(ResourceManager::GetString(L"IDS_PB_BODY_GROUP_NAME_ABB"));
457 pEditField->SetEnabled(!__pPresentationModel->IsDefaultCategory());
459 if (__isEditMode == true)
461 String categoryName = __pPresentationModel->GetCategoryName();
462 if (__pPresentationModel->IsDefaultCategory())
464 if (categoryName.Equals(DEFAULT_GROUP_FAMILY, false))
466 categoryName.Clear();
467 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT_GROUP_FAMILY");
469 else if (categoryName.Equals(DEFAULT_GROUP_FRIENDS, false))
471 categoryName.Clear();
472 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT_GROUP_FRIENDS");
474 else if (categoryName.Equals(DEFAULT_GROUP_COWORKERS, false))
476 categoryName.Clear();
477 categoryName = ResourceManager::GetString(L"IDS_PB_BODY_CO_WORKERS");
480 pEditField->SetText(categoryName);
482 pItem->AddControl(pEditField);
483 pItem->SetBackgroundColor(COLOR_THUMBNAIL, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
485 else if (itemIndex == 2)
487 pSubjectLabel = new (std::nothrow) Label();
488 pSubjectLabel->Construct(Rectangle(X_RINGTONE_TEXT, Y_RINGTONE_TITLE, W_RINGTONE_TEXT, H_RINGTONE_TITLE),
489 ResourceManager::GetString(L"IDS_PB_BODY_RINGTONE"));
490 pSubjectLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
491 pSubjectLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
492 pSubjectLabel->SetTextColor(Color(COLOR_RINGTONE_TITLE));
493 pSubjectLabel->SetTextConfig(FONT_SIZE_RINGTONE_TITLE, LABEL_TEXT_STYLE_NORMAL);
494 pItem->AddControl(pSubjectLabel);
497 String ringtonePath = __pPresentationModel->GetRingtone();
500 if (ringtonePath.IsEmpty() == true)
502 trimmedPath = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT");
506 ringtonePath.LastIndexOf(L"/", ringtonePath.GetLength() - 1, index);
509 ringtonePath.SubString(index + 1, trimmedPath);
513 pContentLabel = new (std::nothrow) Label();
514 pContentLabel->Construct(Rectangle(X_RINGTONE_TEXT, Y_RINGTONE_NAME, W_RINGTONE_TEXT, H_RINGTONE_NAME), trimmedPath);
515 pContentLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
516 pContentLabel->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
517 pContentLabel->SetTextColor(Color(COLOR_RINGTONE));
518 pContentLabel->SetTextConfig(FONT_SIZE_RINGTONE, LABEL_TEXT_STYLE_BOLD);
519 pItem->AddControl(pContentLabel);
521 Button* pClearButton = new (std::nothrow) Button();
522 pClearButton->Construct(Rectangle(itemWidth - X_REFRESH_BUTTON_MARGIN, (pItem->GetHeight() - H_ICON_BUTTON) / 2, H_ICON_BUTTON, H_ICON_BUTTON));
523 pClearButton->SetActionId(IDA_BUTTON_RINGTONE_CLEAR);
524 pClearButton->AddActionEventListener(*this);
526 Bitmap* pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_NORMAL);
529 pClearButton->SetNormalBitmap(Point(0, 0), *pReset);
532 pReset = ResourceManager::GetBitmapN(IDB_DETAILS_RESET_PRESSED);
535 pClearButton->SetPressedBitmap(Point(0, 0), *pReset);
539 pItem->AddControl(pClearButton);
540 pItem->SetIndividualSelectionEnabled(pClearButton, true);
542 pItem->SetBackgroundColor(COLOR_THUMBNAIL, TABLE_VIEW_ITEM_DRAWING_STATUS_NORMAL);
549 GroupEditorForm::DeleteItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
556 GroupEditorForm::UpdateItem(int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
565 Button* pRemoveButton = static_cast<Button*>(pItem->GetControl(REMOVE_BUTTON, false));
566 Button* pAddButton = static_cast<Button*>(pItem->GetControl(ADD_BUTTON, false));
567 Label* pThumbnailLabel = static_cast<Label*>(pItem->GetControl(THUMBNAIL_LABEL, false));
568 Label* pThumbnailEmptyLabel = static_cast<Label*>(pItem->GetControl(THUMBNAIL_EMPTY_LABEL, false));
569 if (pRemoveButton == null || pAddButton == null ||
570 pThumbnailLabel == null || pThumbnailEmptyLabel == null)
575 if (__pPresentationModel->GetThumbnailPath().IsEmpty() == true)
577 pRemoveButton->SetShowState(false);
578 pThumbnailLabel->SetShowState(false);
579 pThumbnailEmptyLabel->SetShowState(true);
580 pAddButton->SetShowState(true);
584 pAddButton->SetShowState(false);
585 pThumbnailEmptyLabel->SetShowState(false);
586 pThumbnailLabel->SetShowState(true);
587 pRemoveButton->SetShowState(true);
589 Bitmap* pThumbnail = null;
590 ImageBuffer thumbnailImageBuffer;
591 result r = thumbnailImageBuffer.Construct(__pPresentationModel->GetThumbnailPath());
594 pThumbnail = thumbnailImageBuffer.GetBitmapN(BITMAP_PIXEL_FORMAT_ARGB8888, BUFFER_SCALING_NONE);
596 pThumbnailLabel->SetBackgroundBitmap(*pThumbnail);
599 pThumbnailLabel->Invalidate(false);
602 else if (itemIndex == 1)
604 EditField* pEditField = static_cast<EditField*>(pItem->GetControl(0));
605 if (pEditField == null)
610 String groupName = pEditField->GetText();
613 if (groupName.GetLength() > 0)
615 Footer* pFooter = GetFooter();
616 pFooter->SetItemEnabled(0, true);
617 pFooter->Invalidate(true);
620 if (__pPresentationModel->IsDefaultCategory() == false && __pPresentationModel->IsDuplicatedCategory() == true)
622 pEditField->SetEnabled(true);
624 pEditField->SetGuideTextColor(Color(COLOR_GUIDE_TEXT));
625 pEditField->SetGuideText(ResourceManager::GetString(L"IDS_PB_POP_GROUP_ALREADY_IN_USE"));
626 pEditField->SetFocus();
627 pEditField->Invalidate(false);
630 else if (itemIndex == 2)
633 String ringtonePath = __pPresentationModel->GetRingtone();
636 if (ringtonePath.IsEmpty() == true)
638 trimmedPath = ResourceManager::GetString(L"IDS_PB_BODY_DEFAULT");
642 ringtonePath.LastIndexOf(L"/", ringtonePath.GetLength() - 1, index);
645 ringtonePath.SubString(index + 1, trimmedPath);
649 Label* pRingtoneName = static_cast<Label*>(pItem->GetControl(1));
650 if (pRingtoneName != null)
652 pRingtoneName->SetText(trimmedPath);
653 pRingtoneName->Invalidate(true);
659 GroupEditorForm::GetDefaultItemHeight(void)
665 GroupEditorForm::OnTableViewItemStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
667 if (status == TABLE_VIEW_ITEM_STATUS_SELECTED && itemIndex == 2)
669 LaunchAppControl(PROVIDER_ID_FILEMANAGER, OPERATION_ID_PICK);
674 GroupEditorForm::OnTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::TableView& tableView, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
679 GroupEditorForm::OnTableViewItemReordered(Tizen::Ui::Controls::TableView& tableView, int itemIndexFrom, int itemIndexTo)
684 GroupEditorForm::OnTextValueChanged(const Tizen::Ui::Control& source)
686 EditField* pEditField = const_cast<EditField *>(static_cast<const EditField *>(&source));
687 if (pEditField == null)
692 String existingCategoryName = __pPresentationModel->GetCategoryName();
693 String name = pEditField->GetText();
697 pEditField->SetGuideText(String(CHARACTER_SPACE));
698 pEditField->Invalidate(false);
700 Footer* pFooter = GetFooter();
701 pFooter->SetItemEnabled(0, false);
702 pFooter->Invalidate(true);
706 __pPresentationModel->SetCategoryName(name);
708 bool isSaveEnabled = false;
711 for (int index = 0; index < name.GetLength(); index++)
713 name.GetCharAt(index, ch);
717 isSaveEnabled = true;
722 Footer* pFooter = GetFooter();
724 pFooter->SetItemEnabled(0, isSaveEnabled);
725 pFooter->Invalidate(true);
729 GroupEditorForm::OnTextValueChangeCanceled(const Tizen::Ui::Control& source)
734 GroupEditorForm::OnKeypadWillOpen(Tizen::Ui::Control& source)
739 GroupEditorForm::OnKeypadOpened(Tizen::Ui::Control& source)
741 Rectangle clientBounds = GetClientAreaBounds();
743 __pTableView->SetSize(clientBounds.width, clientBounds.height);
747 GroupEditorForm::OnKeypadClosed(Tizen::Ui::Control& source)
752 GroupEditorForm::OnKeypadActionPerformed(Tizen::Ui::Control& source, Tizen::Ui::KeypadAction keypadAction)
757 GroupEditorForm::OnKeypadBoundsChanged(Tizen::Ui::Control& source)
759 Rectangle clientBounds = GetClientAreaBounds();
761 __pTableView->SetSize(clientBounds.width, clientBounds.height);
765 GroupEditorForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
767 AppLogDebug("ENTER");
772 TryReturnVoid(appControlResult == APP_CTRL_RESULT_SUCCEEDED, "[E_FAILURE] The result of an appcontrol is not succeeded.");
773 TryReturnVoid(pExtraData != null, "[E_FAILURE] The extra data is null.");
775 const String *pResultString = null;
776 const ArrayList* pResultList = dynamic_cast<const ArrayList*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
777 if (pResultList != null)
779 pResultString = static_cast<const String*>(pResultList->GetAt(0));
783 pResultString = static_cast<const String*>(pExtraData->GetValue(String(OUTPUT_KEY_SELECTED)));
785 TryReturnVoid(pResultString != null, "[E_FAILURE] Unable to get file path.");
787 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
789 __pPresentationModel->SetThumbnailPath(*pResultString);
790 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
792 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
794 __pPresentationModel->SetThumbnailPath(*pResultString);
795 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
797 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
799 __pPresentationModel->SetRingtone(*pResultString);
800 __pTableView->RefreshItem(2, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
803 __pTableView->RefreshItem(1, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
809 GroupEditorForm::LaunchAppControl(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId)
811 result r = E_SUCCESS;
818 extraData.Construct();
820 if (appId.Equals(String(PROVIDER_ID_CAMERA)) && operationId.Equals(String(OPERATION_ID_CREATE_CONTENT)))
822 mimeType.Append(INPUT_MIME_TYPE_CAMERA);
823 extraData.Add(new (std::nothrow) String(INPUT_KEY_ALLOW_SWITCH), new (std::nothrow) String(INPUT_VALUE_FALSE));
825 else if (appId.Equals(String(PROVIDER_ID_GALLERY)) && operationId.Equals(String(OPERATION_ID_PICK)))
827 mimeType.Append(INPUT_MIME_TYPE_GALLERY);
828 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
830 else if (appId.Equals(String(PROVIDER_ID_FILEMANAGER)) && operationId.Equals(String(OPERATION_ID_PICK)))
832 mimeType.Append(INPUT_MIME_TYPE_AUDIO);
833 extraData.Add(new (std::nothrow) String(INPUT_KEY_SELECTION_MODE), new (std::nothrow) String(INPUT_DATA_SELECTION_MODE_SINGLE));
836 AppControl* pAppControl = AppManager::FindAppControlN(appId, operationId);
838 if (pAppControl != null)
840 r = pAppControl->Start(&uri, &mimeType, &extraData, this);
841 TryCatch(r == E_SUCCESS, , "[%s] Unable to launch app control", GetErrorMessage(r));
848 extraData.RemoveAll(true);
855 GroupEditorForm::OnContactsChanged(void)
860 GroupEditorForm::OnCategoriesChanged(void)
862 result r = E_SUCCESS;
864 SceneManager* pSceneManager = SceneManager::GetInstance();
866 SceneId previousSceneId;
867 IListT<SceneId>* pHistoryList = pSceneManager->GetSceneHistoryN();
868 if (pHistoryList != null)
870 int count = pHistoryList->GetCount();
871 r = pHistoryList->GetAt(count - 1, previousSceneId);
873 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to get previous scene id", GetErrorMessage(r));
876 if (previousSceneId.Equals(IDSCN_CONTACT_DETAILS, true) || previousSceneId.Equals(IDSCN_CONTACT_EDITOR, true))
878 if (__pPresentationModel->GetCategoryCount() > 0)
880 ArrayList* pArg = new (std::nothrow) ArrayList();
882 pArg->Add(new (std::nothrow) Integer(__pPresentationModel->GetCategoryId()));
884 r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), pArg);
885 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
893 r = pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT));
894 TryReturnVoid(r == E_SUCCESS, "[%s] Unable to go backward", GetErrorMessage(r));
899 GroupEditorForm::OnForeground(void)
901 if ( File::IsFileExist(__pPresentationModel->GetThumbnailPath()) == false)
903 __pPresentationModel->SetThumbnailPath(L"");
904 __pTableView->RefreshItem(0, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
906 if (IsEnabled() == false)
914 GroupEditorForm::OnBackground(void)