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 EmRecipientField.cpp
19 * @brief Provides the implementation for the custom control, which is used for viewing sender/recipient addresses.
22 #include "EmEmailApp.h"
23 #include "EmRecipientField.h"
26 using namespace Tizen::App;
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29 using namespace Tizen::Graphics;
30 using namespace Tizen::Ui;
31 using namespace Tizen::Ui::Controls;
33 RecipientField::RecipientField(void)
34 : __mode(READ_WRITE_MODE)
35 , __isWindowDeactived(false)
37 , __width(W_RECIPIENT_AREA)
38 , __expandedHeight(H_RECIPIENT_AREA)
39 , __alreadyValidated(false)
41 , __sendUserEvent(true)
42 , __pRecipientList(null)
43 , __pAddContactButton(null)
44 , __pCountButton(null)
45 , __pRecipientArea(null)
46 , __pTokenChangedEventListener(null)
48 // Empty Implementation
51 RecipientField::~RecipientField(void)
55 if (__pRecipientList != null)
57 __pRecipientList->RemoveAll(true);
58 delete __pRecipientList;
61 Frame* pFrame = EmailApp::GetInstance()->GetFrame(IDS_EMAIL_TEXT);
62 pFrame->RemoveWindowEventListener(*this);
68 RecipientField::Construct(const FloatRectangle& bounds, MODE mode)
70 AppLogDebug("Email::ENTER");
72 Bitmap* pContactBitmap = null;
73 Bitmap* pContactCircleBitmap = null;
74 Bitmap* pContactCirclePressedBitmap = null;
75 AppResource* pAppResource = UiApp::GetInstance()->GetAppResource();
79 Color bgColor = Color(0,0,0,0);
80 RelativeLayout relLayout;
81 relLayout.Construct();
83 Panel::Construct(relLayout, bounds, GROUP_STYLE_NONE);
85 Frame* pFrame = EmailApp::GetInstance()->GetFrame(IDS_EMAIL_TEXT);
86 pFrame->AddWindowEventListener(*this);
90 pContactBitmap = pAppResource->GetBitmapN(IDB_ADDCONTACT, BITMAP_PIXEL_FORMAT_ARGB8888);
91 pContactCircleBitmap = pAppResource->GetBitmapN(IDB_CIRCLE, BITMAP_PIXEL_FORMAT_ARGB8888);
92 pContactCirclePressedBitmap = pAppResource->GetBitmapN(IDB_ADD_CONTACT_CIRCLE_PRESSED, BITMAP_PIXEL_FORMAT_ARGB8888);
95 __pRecipientArea = new (std::nothrow) ExpandableEditArea();
97 if (__mode == READ_WRITE_MODE)
99 __pRecipientArea->Construct(FloatRectangle(X_COMMON_CUSTOM_ITEM, Y_RECIPIENT_AREA, bounds.width-(2*X_COMMON_CUSTOM_ITEM)-W_ADD_CONTACT_BUTTON-GENERIC_OFFSET_16, H_RECIPIENT_AREA), EXPANDABLE_EDIT_AREA_STYLE_TOKEN, EXPANDABLE_EDIT_AREA_TITLE_STYLE_INNER, 5);
100 __pRecipientArea->SetAutoShrinkModeEnabled(true);
101 __pRecipientArea->AddFocusEventListener(*this);
102 __pRecipientArea->AddExpandableEditAreaEventListener(*this);
103 __pRecipientArea->SetTokenFilter(this);
104 __pRecipientArea->SetMinimumSize(Dimension(W_CONTRACTED_RECIPIENT_AREA, H_RECIPIENT_AREA));
105 __pRecipientArea->SetKeypadEnabled(true);
106 __pRecipientArea->SetKeypadStyle(KEYPAD_STYLE_EMAIL);
107 __pRecipientArea->SetLowerCaseModeEnabled(true);
108 __pRecipientArea->SetTokenEditModeEnabled(true);
112 __pRecipientArea->Construct(FloatRectangle(X_COMMON_CUSTOM_ITEM, Y_RECIPIENT_AREA, GetWidth()-(2*X_COMMON_CUSTOM_ITEM), H_RECIPIENT_AREA), EXPANDABLE_EDIT_AREA_STYLE_TOKEN, EXPANDABLE_EDIT_AREA_TITLE_STYLE_INNER, COUNT_LINE);
113 __pRecipientArea->SetAutoShrinkModeEnabled(false);
114 __pRecipientArea->AddExpandableEditAreaEventListener(*this);
115 __pRecipientArea->HideKeypad();
116 __pRecipientArea->SetKeypadEnabled(false);
117 __pRecipientArea->SetFocusable(false);
118 __pRecipientArea->SetEnabled(false);
119 __pRecipientArea->SetTokenEditModeEnabled(false);
122 __pRecipientArea->SetColor(EDIT_STATUS_NORMAL, bgColor);
123 //__pRecipientArea->SetColor(EDIT_STATUS_HIGHLIGHTED, bgColor);
124 __pRecipientArea->SetColor(EDIT_STATUS_PRESSED, bgColor);
125 __pRecipientArea->SetColor(EDIT_STATUS_DISABLED, bgColor);
126 __pRecipientArea->AddKeyEventListener(*this);
128 AddControl(__pRecipientArea);
129 SetControlAlwaysOnTop(*__pRecipientArea, true);
131 __pAddContactButton = new (std::nothrow) Button();
132 __pAddContactButton->Construct(Rectangle(bounds.width-X_COMMON_CUSTOM_ITEM-W_ADDCONTACT_BUTTON, Y_ADD_CONTACT_BUTTON, W_ADD_CONTACT_BUTTON, H_ADD_CONTACT_BUTTON), L"");
134 if (__mode == READ_WRITE_MODE)
136 __pAddContactButton->AddFocusEventListener(*this);
139 __pAddContactButton->SetColor(BUTTON_STATUS_NORMAL, Color::GetColor(COLOR_ID_WHITE));
140 __pAddContactButton->SetNormalBitmap(Point(14, 14), *pContactBitmap);
141 __pAddContactButton->SetNormalBackgroundBitmap(*pContactCircleBitmap);
142 __pAddContactButton->SetPressedBackgroundBitmap(*pContactCirclePressedBitmap);
143 __pAddContactButton->SetActionId(IDA_TOFIELDPANEL_ADD_CONTACT_BUTTON);
144 __pAddContactButton->SetShowState(false);
145 AddControl(__pAddContactButton);
147 __pCountButton = new (std::nothrow) Button();
148 __pCountButton->Construct(Rectangle(__pAddContactButton->GetX()-GENERIC_OFFSET_16-W_COUNT_LABEL, Y_COUNT_LABEL, W_COUNT_LABEL, H_COUNT_LABEL), L"");
149 __pCountButton->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
150 __pCountButton->SetDisabledTextColor(Color::GetColor(COLOR_ID_WHITE));
151 __pCountButton->SetHighlightedTextColor(Color::GetColor(COLOR_ID_WHITE));
152 __pCountButton->SetNormalBackgroundBitmap(*pContactCircleBitmap);
153 __pCountButton->SetPressedBackgroundBitmap(*pContactCircleBitmap);
154 __pCountButton->SetTextSize(26);
155 __pCountButton->SetShowState(false);
156 AddControl(__pCountButton);
158 relLayout.SetRelation(*__pAddContactButton, this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
159 relLayout.SetMargin(*__pAddContactButton, 16, 12, 24, 24);
161 relLayout.SetRelation(*__pCountButton, this, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
162 relLayout.SetMargin(*__pCountButton, 16, 12, 24, 24);
164 __pRecipientList = new (std::nothrow) ArrayList();
165 __pRecipientList->Construct();
167 delete pContactBitmap;
168 delete pContactCircleBitmap;
169 delete pContactCirclePressedBitmap;
171 AppLogDebug("Email::EXIT: r = %s", GetErrorMessage(r));
176 RecipientField::AddNewToken(const String& emailIds, bool showMsgBox)
178 AppLogDebug("ENTER, emailIds:(%ls)", emailIds.GetPointer());
181 bool alreadyExists=false, invalidAddress=false;
182 result r = E_SUCCESS;
183 HashMap* pDuplicateMap = null;
186 Utility::StringTokenizer addressTokenizer(emailIds, IDS_DELIM_SEMICOLON);
188 pDuplicateMap = new (std::nothrow) HashMap();
189 TryCatch(pDuplicateMap != null, ,"Failed to allocate memory for duplicate map");
191 r = pDuplicateMap->Construct();
192 TryCatch(r == E_SUCCESS, delete pDuplicateMap, "Failed to construct duplicate map");
194 count = __pRecipientList->GetCount();
195 for (int i=0; i<count; i++)
197 emailAddress.Clear();
198 emailAddress.Append(*static_cast<String*>(__pRecipientList->GetAt(i)));
200 pDuplicateMap->Add(new (std::nothrow) String(emailAddress), new (std::nothrow) Integer(1));
203 while (addressTokenizer.HasMoreTokens())
205 addressTokenizer.GetNextToken(token);
207 if (__mode == READ_MODE)
209 __alreadyValidated = true;
211 __pRecipientArea->AppendToken(token);
212 __pRecipientList->Add(new (std::nothrow) String(token));
214 __alreadyValidated = false;
218 if (Utils::ValidateEmailAddress(token) == true)
220 r = pDuplicateMap->Add(new (std::nothrow) String(token), new (std::nothrow) Integer(1));
222 if (r == E_OBJ_ALREADY_EXIST)
224 alreadyExists = true;
226 else if (r == E_SUCCESS)
228 __alreadyValidated = true;
230 __pRecipientArea->AppendToken(token);
231 __pRecipientList->Add(new (std::nothrow) String(token));
233 __alreadyValidated = false;
238 invalidAddress = true;
243 if (showMsgBox == true)
245 if (invalidAddress == true)
249 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
250 msgBox.ShowAndWait(modRes);
253 if (alreadyExists == true)
255 FloatDimension convertedSize = FloatDimension(__pRecipientArea->GetWidthF(), H_RECIPIENT_AREA * 1.0);
256 r = __pRecipientArea->SetSize(convertedSize);
260 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
261 msgBox.ShowAndWait(modRes);
265 count = __pRecipientArea->GetTokenCount();
268 __pCountButton->SetText(token);
270 pDuplicateMap->RemoveAll(true);
271 delete pDuplicateMap;
281 RecipientField::GetAddressFieldHeight(void)
283 AppLogDebug("returning height:(%d)", __pRecipientArea->GetHeight());
284 return __pRecipientArea->GetHeight();
288 RecipientField::GetAddressFieldWidth(void)
290 AppLogDebug("returning width:(%d)", __pRecipientArea->GetWidth());
291 return __pRecipientArea->GetWidth();
295 RecipientField::GetTokenCount(void)
297 AppLogDebug("returning token count:(%d)", __pRecipientArea->GetTokenCount());
298 return __pRecipientArea->GetTokenCount();
302 RecipientField::HideKeypad(void)
304 __pRecipientArea->HideKeypad();
308 RecipientField::IsDuplicate(const String& emailAddress)
310 AppLogDebug("ENTER, got emailAddress:(%ls)", emailAddress.GetPointer());
315 for (int i=0; i<__pRecipientList->GetCount(); i++)
317 pTmpAddress = dynamic_cast<String*>(__pRecipientList->GetAt(i));
319 AppLogDebug("Got pTmpAddress:(%x)", pTmpAddress);
320 AppLogDebugIf(pTmpAddress != null, "pTmpAddress:(%ls)", pTmpAddress->GetPointer());
322 if (pTmpAddress != null && pTmpAddress->Equals(emailAddress, false) == true)
329 AppLogDebug("EXIT, returning:(%d)", retVal);
334 RecipientField::SetExpandableEditAreaTitle(const String& titleText)
336 AppLogDebug("ENTER");
338 __pRecipientArea->SetTitleText(titleText);
344 RecipientField::SetTokenChangedEventListener(ITokenChangedEventListener& listener)
346 __pTokenChangedEventListener = &listener;
350 RecipientField::SetAddContactButtonEventListener(IActionEventListener& listener)
352 __pAddContactButton->AddActionEventListener(listener);
356 RecipientField::SetKeyPadEventListener(Tizen::Ui::IKeypadEventListener& listener)
358 __pRecipientArea->AddKeypadEventListener(listener);
362 RecipientField::SetFocus(void)
364 return __pRecipientArea->SetFocus();
368 RecipientField::GetRecipientList(void)
370 return __pRecipientList;
374 RecipientField::GetRecipientArea(void)
376 return __pRecipientArea;
380 RecipientField::OnBoundsChanged(const Rectangle& oldRect, const Rectangle& newRect)
382 AppLogDebug("ENTER newrect bounds (%d) (%d) (%d) (%d)", newRect.x, newRect.y, newRect.width, newRect.height);
384 result r = E_SUCCESS;
386 if (__pRecipientArea != null)
388 float width = (newRect.width*1.0)-(2.0*X_COMMON_CUSTOM_ITEM)-W_ADD_CONTACT_BUTTON-GENERIC_OFFSET_16;
394 if (__hasFocus == true || __mode == READ_MODE)
396 // FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(width, __pRecipientArea->GetHeightF()));
397 FloatDimension convertedSize = FloatDimension(width, H_RECIPIENT_AREA * 1.0);
398 r = __pRecipientArea->SetSize(convertedSize);
399 AppLogDebug("Result of SetSize:(%s)", GetErrorMessage(r));
403 // FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(width, H_RECIPIENT_AREA*1.0));
404 FloatDimension convertedSize = FloatDimension(width, H_RECIPIENT_AREA*1.0);
405 r = __pRecipientArea->SetSize(convertedSize);
406 AppLogDebug("Result of SetSize:(%s)", GetErrorMessage(r));
409 AppLogDebug("recipient area bounds:(%f, %f, %f, %f)", __pRecipientArea->GetBoundsF().x, __pRecipientArea->GetBoundsF().y, __pRecipientArea->GetBoundsF().width, __pRecipientArea->GetBoundsF().height);
411 __pRecipientArea->Invalidate(true);
418 RecipientField::OnExpandableEditAreaLineAdded(ExpandableEditArea& source, int newLineCount)
420 AppLogDebug("ENTER");
422 result r = E_SUCCESS;
424 if (__hasFocus == true)
426 AppLogDebug("Has focus");
427 __expandedHeight = __pRecipientArea->GetHeightF();
429 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), __expandedHeight+(2.0*Y_RECIPIENT_AREA)));
430 r = SetSize(convertedSize);
432 else if (__hasFocus == false && __mode == READ_WRITE_MODE)
434 AppLogDebug("No focus");
435 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), H_RECIPIENT_AREA+(2.0*Y_RECIPIENT_AREA)));
436 r = SetSize(convertedSize);
438 else if (__mode == READ_MODE)
440 AppLogDebug("Read mode");
441 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), __pRecipientArea->GetHeight()+(2.0*Y_RECIPIENT_AREA)));
442 r = SetSize(convertedSize);
445 AppLogDebug("Result of setsize:(%s)", GetErrorMessage(r));
446 AppLogDebug("To Field Panel dimensions:(%f,%f)", GetWidthF(), GetHeightF());
448 if (__pTokenChangedEventListener)
450 __pTokenChangedEventListener->LineCountChanged(*this);
458 RecipientField::OnExpandableEditAreaLineRemoved(ExpandableEditArea& source, int newLineCount)
460 AppLogDebug("ENTER");
462 if (__pRecipientArea->HasFocus() == true)
464 AppLogDebug("Has focus");
465 __expandedHeight = __pRecipientArea->GetHeightF();
467 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), __expandedHeight+(2.0*Y_RECIPIENT_AREA)));
468 SetSize(convertedSize);
472 AppLogDebug("No focus");
473 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), H_RECIPIENT_AREA+(2.0*Y_RECIPIENT_AREA)));
474 SetSize(convertedSize);
477 AppLogDebug("To Field Panel dimensions:(%f,%f)", __pRecipientArea->GetWidthF(), __pRecipientArea->GetHeightF());
479 if (__pTokenChangedEventListener)
481 __pTokenChangedEventListener->LineCountChanged(*this);
489 RecipientField::AdjustHeight(void)
491 AppLogDebug("ENTER");
493 // We insert and remove a char so that the control automatically resizes and gives us the correct expanded height after resizing.
494 // OnEEALineAdded is called automatically..
495 __pRecipientArea->InsertCharacterAt(0, ' ');
496 __pRecipientArea->DeleteCharacterAt(0);
503 RecipientField::OnFocusGained(const Control& source)
505 AppLogDebug("ENTER");
509 if (source.GetHashCode() == __pRecipientArea->GetHashCode())
513 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), __pRecipientArea->GetHeightF()+(2.0*Y_RECIPIENT_AREA)));
514 SetSize(convertedSize);
516 AppLogDebug("recipient area bounds:(%f, %f, %f, %f)", __pRecipientArea->GetBoundsF().x, __pRecipientArea->GetBoundsF().y, __pRecipientArea->GetBoundsF().width, __pRecipientArea->GetBoundsF().height);
518 __pAddContactButton->SetShowState(true);
519 __pCountButton->SetShowState(false);
523 if (__pTokenChangedEventListener)
525 __pTokenChangedEventListener->LineCountChanged(*this);
528 else if (source.GetHashCode() == __pAddContactButton->GetHashCode())
530 __pAddContactButton->SetShowState(true);
531 __pCountButton->SetShowState(false);
539 RecipientField::OnFocusLost(const Control& source)
541 AppLogDebug("ENTER");
546 if (source.GetHashCode() == __pRecipientArea->GetHashCode())
548 FloatDimension convertedSize = CoordinateSystem::AlignToDevice(FloatDimension(GetWidthF(), H_RECIPIENT_AREA+(2.0*Y_RECIPIENT_AREA)));
549 SetSize(convertedSize);
551 AppLogDebug("recipient area bounds:(%f, %f, %f, %f)", __pRecipientArea->GetBoundsF().x, __pRecipientArea->GetBoundsF().y, __pRecipientArea->GetBoundsF().width, __pRecipientArea->GetBoundsF().height);
553 __pAddContactButton->SetShowState(false);
555 SendUserEvent(IDA_UPDATE_TOKEN_COUNT, null);
557 else if (source.GetHashCode() == __pAddContactButton->GetHashCode())
559 __pAddContactButton->SetShowState(false);
561 if (__pRecipientArea->GetTokenCount() > 1)
563 __pCountButton->SetShowState(true);
567 __pCountButton->SetShowState(false);
578 RecipientField::SetMode(MODE newMode)
580 AppLogDebug("ENTER");
587 RecipientField::SetUserEventFlagValue(bool value)
589 AppLogDebug("ENTER");
591 __sendUserEvent = value;
597 RecipientField::ReplaceToken(const String& token, String& replacement)
599 AppLogDebug("ENTER");
600 AppLogDebug("Got token: (%ls)", token.GetPointer());
603 replacement.Append(token);
606 if (replacement.IsEmpty() == false)
608 if (__alreadyValidated == false)
610 int selectedTokenIndex = __pRecipientArea->GetSelectedTokenIndex();
611 AppLogDebug("selectedTokenIndex: (%d)", selectedTokenIndex);
613 if (selectedTokenIndex == -1)
615 if (Utils::ValidateEmailAddress(replacement) == false)
618 __pRecipientArea->Clear();
619 __pRecipientArea->HideKeypad();
621 if (__sendUserEvent == false)
625 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
626 msgBox.ShowAndWait(modRes);
627 __sendUserEvent = true;
631 SendUserEvent(IDA_SHOW_INVALID_ADDRESS_MESSAGE_BOX, null);
634 // __pRecipientArea->SetFocus();
636 else if (IsDuplicate(replacement) == true)
639 __pRecipientArea->Clear();
640 __pRecipientArea->HideKeypad();
642 if (__sendUserEvent == false)
646 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
647 msgBox.ShowAndWait(modRes);
648 __sendUserEvent = true;
652 SendUserEvent(IDA_SHOW_DUPLICATE_ADDRESS_MESSAGE_BOX, null);
655 // __pRecipientArea->SetFocus();
659 __pRecipientList->Add(new (std::nothrow) String(replacement));
664 __pRecipientList->RemoveAt(selectedTokenIndex);
666 if (Utils::ValidateEmailAddress(replacement) == false)
669 __pRecipientArea->Clear();
670 __pRecipientArea->HideKeypad();
672 if (__sendUserEvent == false)
676 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
677 msgBox.ShowAndWait(modRes);
678 __sendUserEvent = true;
682 SendUserEvent(IDA_SHOW_INVALID_ADDRESS_MESSAGE_BOX, null);
685 // __pRecipientArea->SetFocus();
687 else if (IsDuplicate(replacement) == true)
690 __pRecipientArea->Clear();
691 __pRecipientArea->HideKeypad();
693 if (__sendUserEvent == false)
697 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
698 msgBox.ShowAndWait(modRes);
699 __sendUserEvent = true;
703 SendUserEvent(IDA_SHOW_DUPLICATE_ADDRESS_MESSAGE_BOX, null);
706 // __pRecipientArea->SetFocus();
710 __pRecipientList->InsertAt(new (std::nothrow) String(replacement), selectedTokenIndex);
717 if (__alreadyValidated == false)
719 int selectedTokenIndex = __pRecipientArea->GetSelectedTokenIndex();
720 AppLogDebug("selectedTokenIndex: (%d)", selectedTokenIndex);
722 if (selectedTokenIndex != -1)
724 __pRecipientList->RemoveAt(selectedTokenIndex);
729 AppLogDebug("Got replacement: (%ls)", replacement.GetPointer());
735 RecipientField::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
737 AppLogDebug("ENTER, keyCode:(%d)", keyCode);
741 if ((keyCode == KEY_BACKSPACE || keyCode == KEY_DELETE) && source.GetHashCode() == __pRecipientArea->GetHashCode())
743 int index = __pRecipientArea->GetSelectedTokenIndex();
747 AppLogDebug("No token selected");
748 index = __pRecipientArea->GetTokenCount()-1;
751 AppLogDebug("Got index:(%d)", index);
753 if (__pRecipientArea->GetText().IsEmpty() == true && index >= 0) // User deleted a token
755 AppLogDebug("Removing token at index:(%d)", index);
756 __pRecipientList->RemoveAt(index, true);
759 else if (keyCode == KEY_INVALID)
761 String token = __pRecipientArea->GetText();
762 if (token.IsEmpty() == false)
764 int selectedTokenIndex = __pRecipientArea->GetSelectedTokenIndex();
766 if (Utils::ValidateEmailAddress(token) == false)
768 __pRecipientArea->Clear();
770 if (selectedTokenIndex != -1)
772 __pRecipientList->RemoveAt(selectedTokenIndex, true);
773 __pRecipientArea->RemoveTokenAt(selectedTokenIndex);
777 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
778 msgBox.ShowAndWait(modRes);
780 else if (IsDuplicate(token) == true)
782 __pRecipientArea->Clear();
784 if (selectedTokenIndex != -1)
786 __pRecipientList->RemoveAt(selectedTokenIndex, true);
787 __pRecipientArea->RemoveTokenAt(selectedTokenIndex);
791 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
792 msgBox.ShowAndWait(modRes);
798 AppLogDebug("Recipient list so far:");
799 for (int i=0; i<__pRecipientList->GetCount(); i++)
801 AppLogDebug("%ls,",static_cast<String*>(__pRecipientList->GetAt(i))->GetPointer());
809 RecipientField::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
811 // Empty Implementation
815 RecipientField::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
817 // Empty Implementation
821 RecipientField::OnUserEventReceivedN(RequestId requestId, IList* pArgs)
823 AppLogDebug("ENTER");
825 if (requestId == IDA_UPDATE_TOKEN_COUNT)
827 if (__pRecipientArea->GetTokenCount() > 1)
829 int count = __pRecipientArea->GetTokenCount();
830 AppLogDebug("recipient count %d, str:(%ls)", count, Integer::ToString(count).GetPointer());
831 __pCountButton->SetText(Integer::ToString(count));
832 __pCountButton->SetShowState(true);
833 __pCountButton->Invalidate(true);
835 if (__pAddContactButton->GetShowState() == true)
837 __pCountButton->SetShowState(false);
842 int count = __pRecipientArea->GetTokenCount();
843 AppLogDebug("recipient count %d, str:(%ls)", count, Integer::ToString(count).GetPointer());
844 __pCountButton->SetText(Integer::ToString(count));
845 __pCountButton->SetShowState(true);
846 __pCountButton->Invalidate(true);
847 __pCountButton->SetShowState(false);
852 if (__pTokenChangedEventListener)
854 __pTokenChangedEventListener->LineCountChanged(*this);
857 else if (requestId == IDA_SHOW_INVALID_ADDRESS_MESSAGE_BOX)
859 if (__isWindowDeactived == true)
861 __showMessageBox = IDA_SHOW_INVALID_ADDRESS_MESSAGE_BOX;
867 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
868 msgBox.ShowAndWait(modRes);
871 else if (requestId == IDA_SHOW_DUPLICATE_ADDRESS_MESSAGE_BOX)
873 if (__isWindowDeactived == true)
875 __showMessageBox = IDA_SHOW_DUPLICATE_ADDRESS_MESSAGE_BOX;
881 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
882 msgBox.ShowAndWait(modRes);
890 RecipientField::OnWindowActivated (const Tizen::Ui::Window &source)
892 AppLogDebug("ENTER");
894 __isWindowDeactived = false;
896 if (__showMessageBox == IDA_SHOW_INVALID_ADDRESS_MESSAGE_BOX)
898 __showMessageBox = 0;
901 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_EMAIL_POP_INVALID_EMAIL_ADDRESS"), MSGBOX_STYLE_OK, 300000);
902 msgBox.ShowAndWait(modRes);
904 else if (__showMessageBox == IDA_SHOW_DUPLICATE_ADDRESS_MESSAGE_BOX)
906 __showMessageBox = 0;
909 msgBox.Construct(Utils::GetResourceString(L"IDS_COM_POP_ERROR"), Utils::GetResourceString(L"IDS_MSGC_BODY_DUPLICATED_RECIPIENT"), MSGBOX_STYLE_OK, 300000);
910 msgBox.ShowAndWait(modRes);
917 RecipientField::OnWindowDeactivated (const Tizen::Ui::Window &source)
919 AppLogDebug("ENTER");
921 __isWindowDeactived = true;