Memory leaks fixed. Fix for 44222 44125 44118
[apps/osp/Dial.git] / src / PhnTabLogs.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://floralicense.org/license/
9 //
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.
15 //
16
17 /**
18  * @file        PhnTabLogs.cpp
19  * @brief       The Logs Tab
20  */
21
22 #include <FApp.h>
23 #include <FBase.h>
24 #include <FMedia.h>
25 #include <FGraphics.h>
26 #include "PhnPhoneApp.h"
27 #include "PhnAppUtility.h"
28 #include "PhnTypes.h"
29 #include "PhnCommonUtils.h"
30 #include "PhnTabLogs.h"
31 #include "PhnSceneRegister.h"
32 #include "PhnCalllogManager.h"
33 #include "PhnTypes.h"
34
35 using namespace Tizen::App;
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Base::Utility;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Graphics;
41 using namespace Tizen::Media;
42 using namespace Tizen::Ui;
43 using namespace Tizen::Ui::Scenes;
44
45 const int W_NOCONTENTS_IMAGE = 280;
46 const int H_NOCONTENTS_IMAGE = 280;
47 //List view height
48 const int H_TOAST_MSG = 48;
49 const int H_SELECTALL_CHK_BOX = 112;
50
51 const wchar_t* IDL_PANEL_LOGS = L"IDL_PANEL_LOGS";
52 const wchar_t* IDC_LABEL_SELECTED_POPUP = L"IDC_LABEL_SELECTED_POPUP";
53 const unsigned int COLOR_LABEL_SELECTED = Color32<215, 225, 232, 255>::Value;
54 static const unsigned int COLOR_ITEM_DELETE_TEXT = Color32<255, 255, 255>::Value;
55 static const unsigned int COLOR_ITEM_DELETE_BACKGROUND = Color32<208, 82, 82>::Value;
56 static const unsigned int COLOR_ITEM_DELETE_PRESSED_BACKGROUND = Color32<194, 71, 71>::Value;
57
58 static const int W_DELETE_POPUP = 720;
59 static const int H_DELETE_POPUP = 308;
60 static const int Y_DELETE_POPUP_TITLE = 20;
61 static const int H_DELETE_POPUP_ELEMENT = 60;
62 static const int H_DELETE_POPUP_PROGRESS = 60;
63 static const int Y_DELETE_POPUP_CANCEL_BUTTON = 214;
64 static const int H_DELETE_POPUP_CANCEL_BUTTON = 74;
65 static const int W_DELETE_POPUP_CANCEL_BUTTON = 394;
66
67 static const int FONT_SIZE_DELETE_POPUP_TEXT = 36;
68 //static const int X_MORE = 55;
69
70 static const unsigned int COLOR_DELETE_POPUP_TEXT = Color32<128, 128, 128>::Value;
71 DialTabLogs::DialTabLogs(void)
72 {
73         __pDataProvider = new CustomDataProvider();
74         __pFormFooter = null;
75         __plogsListView = null;
76         __isEditMode = false;
77         __pButtonSelectAll = null;
78         __groupCount = 0;
79         __itemCount = 0;
80         __isSelectAll = false;
81         __selectedItemCount = 0;
82         __pLogPresentor = null;
83         __pArgs = null;
84         __deleteLogsTimer.Construct(*this);
85         __deleteGroupIndex = 0;
86         __deleteItemIndex = 0;
87         __pDeletePopup = null;
88         __pGroupContextDeletePopup = null;
89         __pCallLogId = null;
90         __isSceneVisible = false;
91         __pLogsViewbyPopup = null;
92         __isMsgAppControlLaunched = false;
93         __isCallAppControlLaunched = false;
94         __pOptionMenu = null;
95         __isDeleteInProgress = false;
96 }
97
98 DialTabLogs::~DialTabLogs(void)
99 {
100         AppLogDebug("Enter");
101         if (__pDataProvider != null)
102         {
103                 delete __pDataProvider;
104                 __pDataProvider = null;
105         }
106         if (__pLogPresentor != null)
107         {
108                 __pLogPresentor->RemoveCalllogChangeListner(*this);
109                 __pLogPresentor = null;
110         }
111         if (__pCallLogId != null)
112         {
113                 __pCallLogId->RemoveAll();
114                 delete __pCallLogId;
115                 __pCallLogId = null;
116         }
117         if(__pLogsViewbyPopup != null)
118         {
119                 delete __pLogsViewbyPopup;
120                 __pLogsViewbyPopup = null;
121         }
122 }
123
124 bool
125 DialTabLogs::Initialize(void)
126 {
127         result r = Construct(IDL_PANEL_LOGS);
128         TryCatch(r == E_SUCCESS, , "DialTabLogs::Initialise() - Fail to initialise Call log panel");
129         return true;
130
131         CATCH:
132         return false;
133 }
134
135 result
136 DialTabLogs::OnInitializing(void)
137 {
138         result r = E_SUCCESS;
139         // Layout setting
140         Form* pForm = dynamic_cast<Form*>(GetParent());
141         if(pForm == null)
142         {
143                 return E_FAILURE;
144         }
145
146         pForm->AddOrientationEventListener(*this);
147
148         RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
149         if (pRelativeLayout != null)
150         {
151                 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
152                 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
153                 delete pRelativeLayout;
154         }
155
156         pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
157         if (pRelativeLayout != null)
158         {
159                 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
160                 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
161                 delete pRelativeLayout;
162         }
163
164         __pFormFooter = pForm->GetFooter();
165         if (__pFormFooter != null)
166         {
167                 __pFormFooter->SetShowState(true);
168                 __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
169                 __pFormFooter->AddActionEventListener(*this);
170
171                 __footerItemDelete.Construct(IDA_FOOTER_LOG_DELETE);
172                 String delStr = AppUtility::GetResourceString(IDS_DELETE_BTN_STRING);
173                 __footerItemDelete.SetText(delStr);
174                 __pFormFooter->AddItem(__footerItemDelete);
175
176                 String cancelStr = AppUtility::GetResourceString(IDS_CANCEL_BTN_STRING);
177                 __footerItemCancel.Construct(IDA_FOOTER_LOG_CANCEL);
178                 __footerItemCancel.SetText(cancelStr);
179         }
180
181         __pButtonSelectAll = static_cast<CheckButton*>(GetControl("IDC_CHECKBUTTON_SELECTALL"));
182         if (__pButtonSelectAll != null)
183         {
184                 __pButtonSelectAll->SetShowState(false);
185                 __pButtonSelectAll->SetActionId(IDA_CHECKBUTTON_SELECT_ALL, IDA_CHECKBUTTON_UNSELECT_ALL);
186                 __pButtonSelectAll->AddActionEventListener(*this);
187                 __pButtonSelectAll->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
188         }
189
190         //create a list view
191         __plogsListView = new (std::nothrow) GroupedListView();
192         if (__plogsListView != null)
193         {
194                 __plogsListView->Construct(Rectangle(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT);
195                 __plogsListView->AddGroupedListViewItemEventListener(*this);
196                 Bitmap* pNoContentBitmap = AppUtility::GetBitmapFromResourcesN(IDB_LOG_NO_CONTENT,W_NOCONTENTS_IMAGE,H_NOCONTENTS_IMAGE);
197                 if(pNoContentBitmap != null)
198                 {
199                         __plogsListView->SetBitmapOfEmptyList(pNoContentBitmap);
200
201                 }
202                 __plogsListView->SetTextOfEmptyList(AppUtility::GetResourceString(IDS_NO_LOGS));
203                 __plogsListView->SetTextColorOfEmptyList(Color(128,128,128));
204                 r = AddControl(__plogsListView);
205                 TryCatch(r == E_SUCCESS, , "Calllog list control not added");
206         }
207
208         __pSelectedLabel = static_cast<Label*>(GetControl(IDC_LABEL_SELECTED_POPUP));
209         if(__pSelectedLabel != null)
210         {
211                 SetControlAlwaysOnTop(*__pSelectedLabel,true);
212                 __pSelectedLabel->SetBackgroundColor(COLOR_LABEL_SELECTED);
213                 __pSelectedLabel->SetShowState(false);
214         }
215
216         __pCallLogId = new(std::nothrow) ArrayList();
217         r = __pCallLogId->Construct();
218
219         CATCH:
220         return r;
221 }
222
223 result
224 DialTabLogs::OnTerminating(void)
225 {
226         result r = E_SUCCESS;
227         delete __pDeletePopup;
228         __pDeletePopup = null;
229         delete __pGroupContextDeletePopup;
230         __pGroupContextDeletePopup = null;
231         __plogsListView = null;
232         delete __pOptionMenu;
233         return r;
234 }
235
236 void
237 DialTabLogs::DeleteSelectedCalllog(void)
238 {
239         ShowDeletePopup();
240 }
241
242 void
243 DialTabLogs::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
244 {
245         AppUtility::GetGlobalFontAndItemHeight(&__fontSize, &__itemHeight);
246         __pLogPresentor = CalLogPresentationModel::GetInstance();
247         __pLogPresentor->AddCalllogChangeListener(*this);
248
249         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
250         pPhoneApp->AddAppStateChangeListener(*this);
251         Tizen::System::SettingInfo::AddSettingEventListener(*this);
252
253         __plogsListView->SetItemProvider(*__pDataProvider);
254         __isMsgAppControlLaunched = false;
255         __isCallAppControlLaunched = false;
256
257         if (__pFormFooter != null)
258         {
259                 __pFormFooter->SetShowState(true);
260                 if(__pLogPresentor->GetAllCallLogCount() > 0)\r
261                 {
262                         __pFormFooter->SetItemEnabled(0, true);
263                 }
264                 else
265                 {
266                         __pFormFooter->SetItemEnabled(0, false);
267                 }
268         }
269         //Check if opened in edit mode
270         if(__isEditMode == true)
271         {
272                 //Check if "select all" is already selected
273                 if (__pButtonSelectAll->IsSelected() == true)
274                 {
275                         //HandleAllItemSelection();
276                 }
277                 //If there is no items selected the reset the display mode
278                 else if(__selectedItemCount == 0)
279                 {
280                         SetCallLogDisplayMode(false);
281                 }
282         }
283         UpdateCallLogList();
284         SetSceneVisible(true);
285         ManageItemSelection();
286         const Form* pForm = dynamic_cast<Form*>(GetParent());
287         if(pForm != null)
288         {
289                 if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
290                 {
291                         Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
292                         __plogsListView->SetBounds(newRect);
293                 }
294                 else if(__isEditMode == true)
295                 {
296                         Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
297                         __plogsListView->SetBounds(newRect);
298                 }
299                 else
300                 {
301                         __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
302                 }
303         }
304 }
305
306 void
307 DialTabLogs::HandleAllItemSelection(void)
308 {
309         SetListItemSelectStatus(true);
310         __itemCount = __pLogPresentor->GetCallLogsViewedCount();\r
311         __selectedItemCount = __itemCount;
312         String text;
313         String selItemStr = L"";
314         if(__selectedItemCount > 1)
315         {
316                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
317         }
318         else
319         {
320                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
321         }
322         text.Format(100, selItemStr.GetPointer(), __itemCount);
323         __pSelectedLabel->SetText(text);
324         __pSelectedLabel->Invalidate(false);
325 }
326
327 void
328 DialTabLogs::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
329 {
330         AppLogDebug("Enter");
331         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
332         pPhoneApp->RemoveAppStateChangeListener(*this);
333         Tizen::System::SettingInfo::RemoveSettingEventListener(*this);
334         SetSceneVisible(false);
335         __pLogPresentor->RemoveCalllogChangeListner(*this);
336         __pLogPresentor = null;
337 }
338
339 void
340 DialTabLogs::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus state)
341 {
342         if (__isMsgAppControlLaunched == true || __isCallAppControlLaunched == true)
343         {
344                 //AppControl already launched.
345                 return;
346         }
347
348         if (__isEditMode == false)
349         {
350                 __pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
351                 __pArgs->Construct();
352                 CallLogDetails* pCalllogInfo = null;
353                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
354                 if(pCalllogInfo != null && pCalllogInfo->GetPhoneNumber() == null)
355                 {
356                         //handling hidden call
357                         return;
358                 }
359                 if(pCalllogInfo != null)
360                 {
361                         __pArgs->Add((new String(pCalllogInfo->GetPhoneNumber())));
362                 }
363                 SceneManager* pSceneManager = SceneManager::GetInstance();
364                 pSceneManager->GoForward( ForwardSceneTransition(IDSCN_CALL_LOG_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
365                                 SCENE_HISTORY_OPTION_NO_HISTORY), __pArgs);
366                 __pArgs = null;
367         }
368         else
369         {
370                 String text;
371                 if (state == LIST_ITEM_STATUS_CHECKED)
372                 {
373                         __selectedItemCount++;
374                         StoreItemselection(groupIndex, itemIndex, elementId, state);
375                 }
376                 else if (state == LIST_ITEM_STATUS_UNCHECKED)
377                 {
378                         __selectedItemCount--;
379                         StoreItemselection(groupIndex, itemIndex, elementId, state);
380                 }
381                 if (__selectedItemCount == __itemCount)
382                 {
383                         __pButtonSelectAll->SetSelected(true);
384                 }
385                 else
386                 {
387                         __pButtonSelectAll->SetSelected(false);
388                 }
389                 if (__selectedItemCount == 0)
390                 {
391                         __pFormFooter->SetItemEnabled(0, false);
392                         String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
393                         __pSelectedLabel->SetText(selStr);
394                 }
395                 else
396                 {
397                         __pFormFooter->SetItemEnabled(0, true);
398                         String selItemStr = L"";
399                         if(__selectedItemCount > 1)
400                         {
401                                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
402                         }
403                         else
404                         {
405                                 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
406                         }
407                         text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
408                         __pSelectedLabel->SetText(text);
409                 }
410                 __pFormFooter->Invalidate(true);
411                 __pButtonSelectAll->Invalidate(false);
412                 __pSelectedLabel->Invalidate(false);
413         }
414 }
415
416 void
417 DialTabLogs::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus state)
418 {
419         //Empty implementation
420         CallLogDetails* pCalllogInfo = null;
421         __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
422         __deleteGroupIndex = groupIndex;
423         __deleteItemIndex = itemIndex;
424         if(pCalllogInfo != null)
425         {
426
427                 switch (elementId)
428                 {
429                 case IDA_LIST_ELEMENT_DELETE:
430                 {
431                         if(__pGroupContextDeletePopup != null)
432                         {
433                                 delete __pGroupContextDeletePopup;
434                                 __pGroupContextDeletePopup = null;
435                         }
436
437                         __pGroupContextDeletePopup = new (std::nothrow) Popup();
438                         __pGroupContextDeletePopup->Construct(false, Dimension(688,230));
439                         __pGroupContextDeletePopup->SetPropagatedKeyEventListener(this);
440                         Label *pDeleteTitle = new Label();
441                         pDeleteTitle->Construct(Rectangle(16,32,656,80), AppUtility::GetResourceString(IDS_DELETE_CONFORMATION_STRING));
442                         pDeleteTitle->SetTextConfig(38, LABEL_TEXT_STYLE_BOLD);
443                         pDeleteTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
444                         pDeleteTitle->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
445                         __pGroupContextDeletePopup->AddControl(pDeleteTitle);
446
447                         //Yes button
448                         Rectangle yesRect(16, 132, 318, 74);
449                         Button* pYesButton = new Button();
450                         pYesButton->Construct(yesRect, AppUtility::GetResourceString(IDS_DELETE_YES));
451                         pYesButton->SetActionId(IDA_POPUP_DELETE_YES);
452                         pYesButton->AddActionEventListener(*this);
453                         pYesButton->SetColor(BUTTON_STATUS_NORMAL, Color(COLOR_ITEM_DELETE_BACKGROUND));
454                         pYesButton->SetColor(BUTTON_STATUS_PRESSED, Color(COLOR_ITEM_DELETE_PRESSED_BACKGROUND));
455                         __pGroupContextDeletePopup->AddControl(pYesButton);
456
457                         //No button
458                         Rectangle noRect(354, 132, 318, 74);
459                         Button* pNoButton = new Button();
460                         pNoButton->Construct(noRect, AppUtility::GetResourceString(IDS_DELETE_NO));
461                         pNoButton->SetActionId(IDA_POPUP_DELETE_NO);
462                         pNoButton->AddActionEventListener(*this);
463                         __pGroupContextDeletePopup->AddControl(pNoButton);
464                         __pGroupContextDeletePopup->SetShowState(true);
465                         __pGroupContextDeletePopup->Show();
466
467                 }
468                 break;
469                 case IDA_LIST_ELEMENT_CALL:
470                 {
471                         __isCallAppControlLaunched = true;
472                         char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
473                         if(pPhoneNumber == null)
474                         {
475                                 __isCallAppControlLaunched = false;
476                                 break;
477                         }
478                         PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
479                         if (pPhoneApp->IsOpenAsAppControl() == false)
480                         {
481                         __pLogPresentor->DialCall(String(pPhoneNumber));
482                         }
483                         else
484                         {
485                                 //launched as AppControl
486                                 HashMap resultData;
487                                 resultData.Construct();
488                                 resultData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(pPhoneNumber));
489                                 //send "APP_CTRL_RESULT_SUCCEEDED" and 'contactNumber' as result.
490                                 pPhoneApp->SendAppControlResponseMessage(APP_CTRL_RESULT_SUCCEEDED, &resultData);
491                                 resultData.RemoveAll(true);
492                                 pPhoneApp->Terminate();
493                         }
494                 }
495                         break;
496
497                 case IDA_LIST_ELEMENT_MESSAGE:
498                 {
499                         result r = E_SUCCESS;
500                         char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
501                         if(pPhoneNumber == null)
502                         {
503                                 break;
504                         }
505                         //launch message AppControl
506                         __isMsgAppControlLaunched = true;
507                         String phoneNumber=L"";
508                         phoneNumber.Append(pPhoneNumber);
509
510                         HashMap extraData;
511                         extraData.Construct();
512
513                         extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
514                         extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(phoneNumber));
515
516                         AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
517                         if (pAc != null)
518                         {
519                                 r = pAc->Start(null, null, &extraData, null);
520                                 if(r != E_SUCCESS)
521                                 {
522                                         //AppControl request failed, reset flag.
523                                         __isMsgAppControlLaunched = false;
524                                 }
525
526                                 delete pAc;
527                         }
528
529                         extraData.RemoveAll(true);
530
531                 }
532                         break;
533                 case IDA_LIST_ELEMENT_VIDEO_CALL:
534                 {
535                         //todo: call once video call implemented
536                         return;
537                 }
538                         break;
539                 default:
540                         break;
541                 }
542         }
543         listView.UpdateList();
544 }
545
546 void
547 DialTabLogs::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
548 {
549         //Empty implementation
550 }
551
552 void
553 DialTabLogs::OnActionPerformed(const Control& source, int actionId)
554 {
555         CallLogDetails* pCalllogInfo = null;
556         __pDataProvider->GetItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex, &pCalllogInfo);
557         switch (actionId)
558         {
559         case IDA_CONTEXTMENU_VIEWBY:
560         {
561                 ShowLogsViewByPopup();
562         }
563         break;
564
565         case IDA_FOOTER_LOG_DELETE:
566         {
567                 if (__isEditMode == false)
568                 {
569                         SetCallLogDisplayMode(true);
570                 }
571                 else
572                 {
573                         DeleteSelectedCalllog();
574                 }
575         }
576         break;
577
578         case IDA_FOOTER_LOG_CANCEL:
579         {
580                 __pCallLogId->RemoveAll();
581                 SetCallLogDisplayMode(false);
582         }
583         break;
584
585         case IDA_CHECKBUTTON_SELECT_ALL:
586         {
587                 __pCallLogId->RemoveAll();
588                 HandleAllItemSelection();
589         }
590         break;
591
592         case IDA_CHECKBUTTON_UNSELECT_ALL:
593         {
594                 SetListItemSelectStatus(false);
595                 __pCallLogId->RemoveAll();
596                 __selectedItemCount = 0;
597                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
598                 __pSelectedLabel->SetText(selStr);
599                 __pSelectedLabel->Invalidate(false);
600         }
601         break;
602
603         case IDA_POPUP_DELETE_CANCEL:
604         {
605                 __deleteLogsTimer.Cancel();
606                 HideDeletePopup();
607         }
608         break;
609
610         case IDA_POPUP_DELETE_YES:
611         {
612                 if(pCalllogInfo != null)
613                 {
614                         if(pCalllogInfo->GetConsecutiveNoCounter() > 1)\r
615                         {\r
616                                 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();\r
617                                 for(int i=0; i < dbIds->GetCount(); ++i)\r
618                                 {\r
619                                         Integer* in = (Integer*)dbIds->GetAt(i);\r
620                                         int p = in->ToInt();\r
621                                         __pLogPresentor->DeleteCalllogByDbId(p);\r
622                                 }\r
623                         }\r
624                         else\r
625                         {\r
626                                 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());\r
627                         }\r
628                         __pLogPresentor->DeleteItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex);\r
629                         if(__pLogPresentor->GetAllCallLogCount() > 0)\r
630                         {
631                                 __pFormFooter->SetItemEnabled(0, true);
632                         }
633                         else
634                         {
635                                 __pFormFooter->SetItemEnabled(0, false);
636                         }
637                         __pFormFooter->Invalidate(true);
638                         if(__pGroupContextDeletePopup != null)
639                         {
640                                 __pGroupContextDeletePopup->SetShowState(false);
641                         }
642                         __deleteGroupIndex = 0;
643                         __deleteItemIndex = 0;
644                 }
645         }
646         break;
647
648         case IDA_POPUP_DELETE_NO:
649         {
650                 if(__pGroupContextDeletePopup != null)
651                 {
652                         __pGroupContextDeletePopup->SetShowState(false);
653                 }
654         }
655         break;
656
657         default:
658                 break;
659         }
660 }
661
662 void
663 DialTabLogs::SetListItemSelectStatus(bool status)
664 {
665         int groupIndex = 0;
666         int itemIndex = 0;
667         int itemCount = 0;
668
669         __isSelectAll = status;
670         CallLogDetails* pCalllogInfo = null;
671         for (; groupIndex < __groupCount; groupIndex++)
672         {
673                 itemCount = __plogsListView->GetItemCountAt(groupIndex);
674                 for (itemIndex = 0; itemIndex < itemCount; itemIndex++)
675                 {
676                         __plogsListView->SetItemChecked(groupIndex, itemIndex, status);
677                         if(status == true)
678                         {
679                                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
680                                 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
681                         }
682                 }
683         }
684         __pFormFooter->SetItemEnabled(0, status);
685         __pFormFooter->Invalidate(true);
686         __plogsListView->Invalidate(true);
687 }
688
689 void
690 DialTabLogs::SetCallLogDisplayMode(bool isEdit)
691 {
692         AppLogDebug("Enter %d",isEdit);
693         if(isEdit == __isEditMode)
694         {
695                 AppLog("Delete process return");
696                 return;
697         }
698         if( __pFormFooter == null)
699         {
700                 AppLog("__pFormFooter == null");
701                 return;
702         }
703
704         __itemCount = __pLogPresentor->GetCallLogsViewedCount();\r
705         __groupCount = __plogsListView->GetGroupCount();
706         __pButtonSelectAll->SetSelected(false);
707         if (isEdit == false)
708         {
709                 __isEditMode = false;
710                 __pDataProvider->SetListItemStyle(false);
711                 __plogsListView->SetSweepEnabled(true);
712                 const Form* pForm = dynamic_cast<Form*>(GetParent());
713                 if(pForm == null)
714                 {
715                         return;
716                 }
717                 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
718                 __plogsListView->UpdateList();
719                 __pFormFooter->RemoveItemAt(1);
720
721                 if(__pLogPresentor->GetCallLogsViewedCount() > 0)\r
722                 {
723                         __pFormFooter->SetItemEnabled(0, true);
724                 }
725                 else
726                 {
727                         __pFormFooter->SetItemEnabled(0, false);
728                 }
729                 __pButtonSelectAll->SetShowState(false);
730                 __pSelectedLabel->SetShowState(false);
731                 __pSelectedLabel->Invalidate(false);
732                 __pFormFooter->Invalidate(true);
733         }
734         else
735         {
736                 __isEditMode = true;
737                 const Form* pForm = dynamic_cast<Form*>(GetParent());
738                 if(pForm == null)
739                 {
740                         return;
741                 }
742                 __pDataProvider->SetListItemStyle(isEdit);
743                 __plogsListView->SetSweepEnabled(false);
744
745                 //reset size to allow "SELECT ALL" & "TOAST MSG"
746                 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
747                 {
748                         Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
749                         __plogsListView->SetBounds(newRect);
750                 }
751                 else
752                 {
753                         Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
754                         __plogsListView->SetBounds(newRect);
755                 }
756                 UnCheckAllItems();
757                 __plogsListView->UpdateList();
758                 __pFormFooter->AddItem(__footerItemCancel);
759                 __pButtonSelectAll->SetShowState(true);
760                 __pFormFooter->SetItemEnabled(0, false);
761                 __selectedItemCount = 0;
762                 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
763                 __pSelectedLabel->SetText(selStr);
764                 __pSelectedLabel->SetShowState(true);
765                 __pSelectedLabel->Invalidate(false);
766                 __pFormFooter->Invalidate(true);
767         }
768         Draw();
769 }
770
771 void
772 DialTabLogs::UnCheckAllItems(void)
773 {
774         int itemCount = 0;
775         __groupCount = __plogsListView->GetGroupCount();\r
776         for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
777         {
778                 itemCount = __plogsListView->GetItemCountAt(groupIndex);
779                 for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
780                 {
781                         bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
782                         if(isSelected == true)
783                         {
784                                 __plogsListView->SetItemChecked(groupIndex,itemIndex,false);
785                         }
786                 }
787         }
788         __plogsListView->Invalidate(true);
789         __selectedItemCount = 0;
790 }
791
792 void DialTabLogs::OnCalllogChanged(void)
793 {
794         // If select all was selected before and some new calls are added (Auto rejeted call)
795         //Then we will not update the call log list.
796         if(__isEditMode == false)
797         {
798                 if(__pGroupContextDeletePopup != null)
799                 {
800                         delete __pGroupContextDeletePopup;
801                         __pGroupContextDeletePopup = null;
802                 }
803                 UpdateCallLogList();
804         }
805         //It won't update the log list when delete is on progress.
806         /*else if(__isEditMode == true && __isDeleteInProgress == false)
807         {
808                 __plogsListView->UpdateList();
809                 __plogsListView->Invalidate(false);
810         }*/
811         //Update the log list for all MO/MT/MSG if the log list is in edit mode and delete is not on progress
812         else if(__isEditMode == true && __isDeleteInProgress == false)
813         {
814                 if(__plogsListView != null)
815                 {
816                         __pLogPresentor->UpdateCallLogList();
817                         __plogsListView->UpdateList();
818                         __plogsListView->Invalidate(false);
819                 }
820         }
821         if(IsScecneVisible() == true && __isDeleteInProgress == false)
822         {
823                 ManageItemSelection();
824         }
825 }
826
827 void
828 DialTabLogs::UpdateCallLogList()
829 {
830         AppLogDebug("Enter");
831
832         __pLogPresentor->UpdateCallLogList();\r
833         __plogsListView->UpdateList();\r
834         if (__pFormFooter != null)\r
835         {\r
836                 if(__pLogPresentor->GetAllCallLogCount() > 0)\r
837                 {\r
838                         __pFormFooter->SetShowState(true);\r
839                         __pFormFooter->SetItemEnabled(0,true);
840                 }\r
841                 if(__pLogPresentor->GetCallLogsViewedCount() > 0)\r
842                 {\r
843                         __pFormFooter->SetItemEnabled(0, true);\r
844                 }\r
845                 else\r
846                 {\r
847                         __pFormFooter->SetItemEnabled(0, false);\r
848                 }
849                 __pFormFooter->Invalidate(true);\r
850         }\r
851 }
852
853 void
854 DialTabLogs::ShowDeletePopup(void)
855 {
856         __isDeleteInProgress = true;
857         if (__pDeletePopup != null)
858         {
859                 delete __pDeletePopup;
860                 __pDeletePopup = null;
861         }
862         if(__selectedItemCount == 0)
863         {
864                 AppLogDebug("Wrong state");
865                 return;
866         }
867         __deleteGroupIndex = 0;
868         __deleteItemIndex = 0;
869
870         __pDeletePopup = new (std::nothrow) Popup();
871         __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
872         __pDeletePopup->AddWindowEventListener(*this);
873         __pDeletePopup->SetPropagatedKeyEventListener(this);
874
875         Rectangle clientBounds = __pDeletePopup->GetClientAreaBounds();
876
877         Label* pLabelTitle = new (std::nothrow) Label();
878         pLabelTitle->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE, clientBounds.width, H_DELETE_POPUP_ELEMENT), AppUtility::GetResourceString(IDS_DELETING_CALL_LOGS));
879         pLabelTitle->SetTextColor(COLOR_DELETE_POPUP_TEXT);
880         pLabelTitle->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
881         pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
882
883         __pDeletePopup->AddControl(*pLabelTitle);
884
885         Progress* pProgress = new (std::nothrow) Progress();
886         pProgress->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE + H_DELETE_POPUP_ELEMENT, clientBounds.width, H_DELETE_POPUP_PROGRESS), 0, __selectedItemCount);
887
888         __pDeletePopup->AddControl(*pProgress);
889
890         Label* pLabelPercentage = new (std::nothrow) Label();
891         pLabelPercentage->Construct(Rectangle(0, pProgress->GetY() + pProgress->GetHeight(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), Integer::ToString(pProgress->GetPercentComplete()) + L"%");
892         pLabelPercentage->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
893         pLabelPercentage->SetTextColor(COLOR_DELETE_POPUP_TEXT);
894         pLabelPercentage->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
895
896         __pDeletePopup->AddControl(*pLabelPercentage);
897
898         String currentOfTotal(Integer::ToString(pProgress->GetValue()) + L" / " + Integer::ToString(__selectedItemCount));
899         Label* pLabelTotal = new (std::nothrow) Label();
900         pLabelTotal->Construct(Rectangle(clientBounds.width / 2, pLabelPercentage->GetY(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), currentOfTotal);
901         pLabelTotal->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
902         pLabelTotal->SetTextColor(COLOR_DELETE_POPUP_TEXT);
903         pLabelTotal->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
904
905         __pDeletePopup->AddControl(*pLabelTotal);
906
907         Button* pCancelButton = new (std::nothrow) Button();
908         pCancelButton->Construct(Rectangle((clientBounds.width - W_DELETE_POPUP_CANCEL_BUTTON) / 2, Y_DELETE_POPUP_CANCEL_BUTTON, W_DELETE_POPUP_CANCEL_BUTTON, H_DELETE_POPUP_CANCEL_BUTTON));
909         pCancelButton->SetText(AppUtility::GetResourceString(IDS_CANCEL_DELETING_CALL_LOGS));
910         pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
911         pCancelButton->AddActionEventListener(*this);
912
913         __pDeletePopup->AddControl(pCancelButton);
914         __pDeletePopup->Show();
915
916 }
917
918 void
919 DialTabLogs::OnWindowActivated (const Tizen::Ui::Window &source)
920 {
921         __deleteLogsTimer.Start(1);
922 }
923
924 void
925 DialTabLogs::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
926 {
927         Progress* pProgress = static_cast<Progress *>(__pDeletePopup->GetControl(1));
928
929         pProgress->SetValue(pProgress->GetValue() + 1);
930         pProgress->Invalidate(false);
931
932         Label* pLabelPercentage = static_cast<Label *>(__pDeletePopup->GetControl(2));
933
934         pLabelPercentage->SetText(Integer::ToString(pProgress->GetPercentComplete()) + L"%");
935         pLabelPercentage->Invalidate(false);
936
937         Label* pLabelTotal = static_cast<Label *>(__pDeletePopup->GetControl(3));
938
939         String currentOfTotal = pLabelTotal->GetText();
940         currentOfTotal.Remove(0, Integer::ToString(pProgress->GetValue() - 1).GetLength());
941         currentOfTotal.Insert(Integer::ToString(pProgress->GetValue()), 0);
942         pLabelTotal->SetText(currentOfTotal);
943         pLabelTotal->Invalidate(false);
944
945         if (RemoveLogsList() == E_SUCCESS)
946         {
947                 __deleteLogsTimer.Start(1);
948         }
949         else
950         {
951                 HideDeletePopup();
952         }
953 }
954
955 result
956 DialTabLogs::RemoveLogsList(void)
957 {
958         result r = E_FAILURE;
959
960         CallLogDetails* pCalllogInfo = null;
961         for(int groupIndex = __deleteGroupIndex; groupIndex < __plogsListView->GetGroupCount(); groupIndex++)
962         {
963                 int itemCount = __plogsListView->GetItemCountAt(groupIndex);
964                 for(int itemIndex = __deleteItemIndex; itemIndex < itemCount ; itemIndex++)
965                 {
966                         bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
967                         if(isSelected == true)
968                         {
969                                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
970                                 if(pCalllogInfo != null)
971                                 {
972                                         if(pCalllogInfo->GetConsecutiveNoCounter() > 1)\r
973                                         {\r
974                                                 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();\r
975                                                 for(int i=0; i < dbIds->GetCount(); ++i)\r
976                                                 {\r
977                                                         Integer* in = (Integer*)dbIds->GetAt(i);\r
978                                                         int p = in->ToInt();\r
979                                                         __pLogPresentor->DeleteCalllogByDbId(p);\r
980                                                 }\r
981                                         }\r
982                                         else\r
983                                         {\r
984                                                 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());\r
985                                         }\r
986 \r
987                                         r = E_SUCCESS;
988                                         __deleteGroupIndex = groupIndex;
989                                         __deleteItemIndex = ++itemIndex;
990                                         __pCallLogId->Remove(Integer(pCalllogInfo->GetCalllogDbId()));
991                                         return r;
992                                 }
993                         }
994                 }
995                 __deleteItemIndex = 0;
996         }
997         __deleteGroupIndex = 0;
998         __deleteItemIndex = 0;
999
1000         return r;
1001 }
1002
1003 void
1004 DialTabLogs::HideDeletePopup(void)
1005 {
1006         __isDeleteInProgress = false;
1007         if (__pDeletePopup != null)
1008         {
1009                 __pDeletePopup->SetShowState(false);
1010                 __pDeletePopup->Invalidate(true);
1011                 SendUserEvent(REQUEST_CHANGE_EDIT_MODE,null);
1012         }
1013         if(__pLogPresentor->GetCallLogsViewedCount() > 0)\r
1014         {
1015                 __pFormFooter->SetItemEnabled(0, true);
1016         }
1017         else
1018         {
1019                 __pFormFooter->SetItemEnabled(0, false);
1020         }
1021         __pFormFooter->Invalidate(true);
1022 }
1023
1024 void
1025 DialTabLogs::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1026 {
1027         switch(requestId)
1028         {
1029                 case REQUEST_CHANGE_EDIT_MODE:
1030                 {
1031                         //CustomDataProvider::setCallLogViewbyID(CALL_LOG_TYPE_ALL);
1032                         UpdateCallLogList();
1033                         SetCallLogDisplayMode(false);
1034                 }
1035                 break;
1036
1037                 case REQUEST_CHANGE_VIEWBY:
1038                 {
1039                         UpdateCallLogList();
1040                         if(__pLogPresentor->GetCallLogsViewedCount() > 0)\r
1041                         {
1042                                 __pFormFooter->SetItemEnabled(0, true);
1043                         }
1044                         else
1045                         {
1046                                 __pFormFooter->SetItemEnabled(0, false);
1047                         }
1048                 }
1049                 break;
1050         }
1051
1052 }
1053
1054 void
1055 DialTabLogs::OnForeground(void)
1056 {
1057         AppLogDebug("Enter");
1058         if (__isMsgAppControlLaunched == true)
1059         {
1060                 //Message AppControl request completed.
1061                 __isMsgAppControlLaunched = false;
1062         }
1063         if (__isCallAppControlLaunched == true)
1064         {
1065                 //Call AppControl request completed.
1066                 __isCallAppControlLaunched = false;
1067         }
1068         if(__pLogsViewbyPopup != null && __pLogPresentor->GetAllCallLogCount() == 0)
1069         {
1070                 delete __pLogsViewbyPopup;
1071                 __pLogsViewbyPopup = null;
1072         }
1073         SetSceneVisible(true);
1074         ManageItemSelection();
1075
1076         //change the font, if font has been changed from backgroung
1077         float fontSize = 0.0;
1078         float itemHeight = 0.0;
1079         AppUtility::GetGlobalFontAndItemHeight(&fontSize, &itemHeight);
1080         if(__fontSize != fontSize)
1081         {
1082                 __fontSize = fontSize;
1083                 __itemHeight = itemHeight;
1084                 __plogsListView->UpdateList();
1085                 if(__pLogsViewbyPopup != null && __pLogsViewbyPopup->GetShowState() == true)
1086                 {
1087                         __pLogsViewbyPopup->UpdateViewByPopupList();
1088                 }
1089         }
1090 }
1091
1092 void
1093 DialTabLogs::OnBackground(void)
1094 {
1095         SetSceneVisible(false);\r
1096 }
1097
1098 void
1099 DialTabLogs::StoreItemselection(int groupIndex, int itemIndex, int elementId, ListItemStatus state)
1100 {
1101         CallLogDetails* pCalllogInfo = null;
1102         if (state == LIST_ITEM_STATUS_CHECKED)
1103         {
1104                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1105                 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
1106         }
1107         else if (state == LIST_ITEM_STATUS_UNCHECKED)
1108         {
1109                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1110                 __pCallLogId->Remove(Integer(pCalllogInfo->GetCalllogDbId()));
1111         }
1112 }
1113 void
1114 DialTabLogs:: ManageItemSelection(void)
1115 {
1116         if(__isEditMode == true && __selectedItemCount > 0 && __pLogPresentor->GetCallLogsViewedCount() != __itemCount)
1117         {
1118                 UnCheckAllItems();
1119                 int itemCount = 0;
1120                 CallLogDetails* pCalllogInfo = null;
1121                 for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
1122                 {
1123                         itemCount = __plogsListView->GetItemCountAt(groupIndex);
1124                         for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
1125                         {
1126                                 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1127 \r
1128                                 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)\r
1129                                 {
1130                                         Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();\r
1131                                         for(int i=0; i < dbIds->GetCount(); ++i)\r
1132                                         {\r
1133                                                 Integer* in = (Integer*)dbIds->GetAt(i);\r
1134                                                 if(__pCallLogId->Contains(*in))\r
1135                                                 {\r
1136                                                         __plogsListView->SetItemChecked(groupIndex,itemIndex,true);\r
1137                                                         ++__selectedItemCount;\r
1138                                                         break;\r
1139                                                 }\r
1140                                         }\r
1141                                 }\r
1142                                 else\r
1143                                 {\r
1144                                         if(__pCallLogId->Contains(Integer(pCalllogInfo->GetCalllogDbId())))\r
1145                                         {\r
1146                                                 __plogsListView->SetItemChecked(groupIndex,itemIndex,true);\r
1147                                                 ++__selectedItemCount;\r
1148                                         }\r
1149                                 }
1150                         }
1151                 }
1152                 __itemCount = __pLogPresentor->GetCallLogsViewedCount();\r
1153                 if(__selectedItemCount == __itemCount)
1154                 {
1155                         __pButtonSelectAll->SetSelected(true);
1156                 }
1157                 else
1158                 {
1159                         __pButtonSelectAll->SetSelected(false);
1160                 }
1161                 String selItemStr = L"";
1162                 String text;
1163                 if(__selectedItemCount == 0)
1164                 {
1165                         selItemStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1166                 }
1167                 else if(__selectedItemCount > 1)
1168                 {
1169                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1170                 }
1171                 else
1172                 {
1173                         selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1174                 }
1175                 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
1176                 __pSelectedLabel->SetText(text);
1177                 __pSelectedLabel->Invalidate(false);
1178         }
1179 }
1180
1181 bool
1182 DialTabLogs::IsScecneVisible()
1183 {
1184         return __isSceneVisible;
1185 }
1186
1187
1188 void
1189 DialTabLogs::SetSceneVisible(bool sceneMode)
1190 {
1191         __isSceneVisible = sceneMode;
1192 }
1193
1194 void
1195 DialTabLogs::ShowLogsViewByPopup(void)
1196 {
1197         if(__pLogsViewbyPopup != null)
1198         {
1199                 delete __pLogsViewbyPopup;
1200                 __pLogsViewbyPopup = null;
1201         }
1202
1203         __pLogsViewbyPopup = new (std::nothrow) CallLogViewByPopup(*this);
1204         __pLogsViewbyPopup->ConstructViewbyPopup();
1205         __pLogsViewbyPopup->SetShowState(true);
1206         __pLogsViewbyPopup->Draw();
1207         __pLogsViewbyPopup->Show();
1208 }
1209
1210 void
1211 DialTabLogs::OnItemSelected()
1212 {
1213         SendUserEvent(REQUEST_CHANGE_VIEWBY, null);
1214 }
1215
1216 void
1217 DialTabLogs::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1218 {
1219         const Form* pForm = dynamic_cast<Form*>(GetParent());
1220         if(pForm == null)
1221         {
1222                 return;
1223         }
1224         if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
1225         {
1226                 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
1227                 __plogsListView->SetBounds(newRect);
1228         }
1229         else if(__isEditMode == true)
1230         {
1231                 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
1232                 __plogsListView->SetBounds(newRect);
1233         }
1234         else
1235         {
1236                 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
1237         }
1238 }
1239
1240 void
1241 DialTabLogs::OnSettingChanged(Tizen::Base::String& key)
1242 {
1243         AppLog("Enter");
1244         if(key.Equals(String(SETTING_INFO_KEY_TIME_FORMAT)) == true)
1245         {
1246                 __plogsListView->UpdateList();
1247         }
1248         AppLog("Exit");
1249 }
1250
1251 void
1252 DialTabLogs::ShowOptionsMenu()
1253 {
1254         if(__isEditMode == false && __pLogPresentor->GetAllCallLogCount() > 0)
1255         {
1256                 if(__pOptionMenu != null)
1257                 {
1258                         delete __pOptionMenu;
1259                         __pOptionMenu = null;
1260                 }
1261                 __pOptionMenu = new (std::nothrow) OptionMenu();
1262                 __pOptionMenu->Construct();
1263                 __pOptionMenu->RemoveAllItems();
1264                 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_VIEWBY), IDA_CONTEXTMENU_VIEWBY);
1265                 __pOptionMenu->AddActionEventListener(*this);
1266                 __pOptionMenu->SetShowState(true);
1267                 __pOptionMenu->Show();
1268         }
1269 }
1270
1271 bool
1272 DialTabLogs::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1273 {
1274         AppLogDebug("Enter");
1275         if(keyEventInfo.GetKeyCode() == KEY_BACK)
1276         {
1277                 if(__pGroupContextDeletePopup != null && __pGroupContextDeletePopup->GetShowState() == true)
1278                 {
1279                         __pGroupContextDeletePopup->SetShowState(false);
1280                 }
1281                 else if(__pDeletePopup != null && __pDeletePopup->GetShowState() == true)
1282                 {
1283                         HideDeletePopup();
1284                 }
1285         }
1286         return false;
1287 }