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 PhnTabLogs.cpp
25 #include <FGraphics.h>
26 #include "PhnPhoneApp.h"
27 #include "PhnAppUtility.h"
29 #include "PhnCommonUtils.h"
30 #include "PhnTabLogs.h"
31 #include "PhnSceneRegister.h"
32 #include "PhnCalllogManager.h"
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;
45 const int W_NOCONTENTS_IMAGE = 280;
46 const int H_NOCONTENTS_IMAGE = 280;
48 const int H_TOAST_MSG = 48;
49 const int H_SELECTALL_CHK_BOX = 112;
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;
55 static const int W_DELETE_POPUP = 720;
56 static const int H_DELETE_POPUP = 308;
57 static const int Y_DELETE_POPUP_TITLE = 20;
58 static const int H_DELETE_POPUP_ELEMENT = 60;
59 static const int H_DELETE_POPUP_PROGRESS = 60;
60 static const int Y_DELETE_POPUP_CANCEL_BUTTON = 214;
61 static const int H_DELETE_POPUP_CANCEL_BUTTON = 74;
62 static const int W_DELETE_POPUP_CANCEL_BUTTON = 394;
64 static const int FONT_SIZE_DELETE_POPUP_TEXT = 36;
65 //static const int X_MORE = 55;
67 static const unsigned int COLOR_DELETE_POPUP_TEXT = Color32<128, 128, 128>::Value;
68 DialTabLogs::DialTabLogs(void)
70 __pDataProvider = new CustomDataProvider();
72 __plogsListView = null;
74 __pButtonSelectAll = null;
77 __isSelectAll = false;
78 __selectedItemCount = 0;
79 __pLogPresentor = null;
81 __deleteLogsTimer.Construct(*this);
82 __deleteGroupIndex = 0;
83 __deleteItemIndex = 0;
84 __pDeletePopup = null;
85 __pGroupContextDeletePopup = null;
87 __isSceneVisible = false;
88 __pLogsViewbyPopup = null;
89 __isMsgAppControlLaunched = false;
90 __isCallAppControlLaunched = false;
92 __isDeleteInProgress = false;
95 DialTabLogs::~DialTabLogs(void)
98 if (__pDataProvider != null)
100 delete __pDataProvider;
101 __pDataProvider = null;
103 if (__pLogPresentor != null)
105 __pLogPresentor->RemoveCalllogChangeListner(*this);
106 __pLogPresentor = null;
108 if (__pCallLogId != null)
110 __pCallLogId->RemoveAll();
114 if(__pLogsViewbyPopup != null)
116 delete __pLogsViewbyPopup;
117 __pLogsViewbyPopup = null;
122 DialTabLogs::Initialize(void)
124 result r = Construct(IDL_PANEL_LOGS);
125 TryCatch(r == E_SUCCESS, , "DialTabLogs::Initialise() - Fail to initialise Call log panel");
133 DialTabLogs::OnInitializing(void)
135 result r = E_SUCCESS;
137 Form* pForm = dynamic_cast<Form*>(GetParent());
143 pForm->AddOrientationEventListener(*this);
145 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
146 if (pRelativeLayout != null)
148 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
149 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
150 delete pRelativeLayout;
153 pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
154 if (pRelativeLayout != null)
156 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
157 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
158 delete pRelativeLayout;
161 __pFormFooter = pForm->GetFooter();
162 if (__pFormFooter != null)
164 __pFormFooter->SetShowState(true);
165 __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
166 __pFormFooter->AddActionEventListener(*this);
168 __footerItemDelete.Construct(IDA_FOOTER_LOG_DELETE);
169 String delStr = AppUtility::GetResourceString(IDS_DELETE_BTN_STRING);
170 __footerItemDelete.SetText(delStr);
171 __pFormFooter->AddItem(__footerItemDelete);
173 String cancelStr = AppUtility::GetResourceString(IDS_CANCEL_BTN_STRING);
174 __footerItemCancel.Construct(IDA_FOOTER_LOG_CANCEL);
175 __footerItemCancel.SetText(cancelStr);
178 __pButtonSelectAll = static_cast<CheckButton*>(GetControl("IDC_CHECKBUTTON_SELECTALL"));
179 if (__pButtonSelectAll != null)
181 __pButtonSelectAll->SetShowState(false);
182 __pButtonSelectAll->SetActionId(IDA_CHECKBUTTON_SELECT_ALL, IDA_CHECKBUTTON_UNSELECT_ALL);
183 __pButtonSelectAll->AddActionEventListener(*this);
184 __pButtonSelectAll->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
188 __plogsListView = new (std::nothrow) GroupedListView();
189 if (__plogsListView != null)
191 __plogsListView->Construct(Rectangle(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height), GROUPED_LIST_VIEW_STYLE_INDEXED, true, SCROLL_STYLE_FADE_OUT);
192 __plogsListView->AddGroupedListViewItemEventListener(*this);
193 Bitmap* pNoContentBitmap = AppUtility::GetBitmapFromResourcesN(IDB_LOG_NO_CONTENT,W_NOCONTENTS_IMAGE,H_NOCONTENTS_IMAGE);
194 if(pNoContentBitmap != null)
196 __plogsListView->SetBitmapOfEmptyList(pNoContentBitmap);
198 __plogsListView->SetTextOfEmptyList(AppUtility::GetResourceString(IDS_NO_LOGS));
199 __plogsListView->SetTextColorOfEmptyList(Color(128,128,128));
200 r = AddControl(__plogsListView);
201 TryCatch(r == E_SUCCESS, , "Calllog list control not added");
204 __pSelectedLabel = static_cast<Label*>(GetControl(IDC_LABEL_SELECTED_POPUP));
205 if(__pSelectedLabel != null)
207 SetControlAlwaysOnTop(*__pSelectedLabel,true);
208 __pSelectedLabel->SetBackgroundColor(COLOR_LABEL_SELECTED);
209 __pSelectedLabel->SetShowState(false);
212 __pCallLogId = new(std::nothrow) ArrayList();
213 r = __pCallLogId->Construct();
220 DialTabLogs::OnTerminating(void)
222 result r = E_SUCCESS;
223 delete __pDeletePopup;
224 __pDeletePopup = null;
225 delete __pGroupContextDeletePopup;
226 __pGroupContextDeletePopup = null;
227 __plogsListView = null;
228 delete __pOptionMenu;
233 DialTabLogs::DeleteSelectedCalllog(void)
239 DialTabLogs::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
241 AppUtility::GetGlobalFontAndItemHeight(&__fontSize, &__itemHeight);
242 __pLogPresentor = CalLogPresentationModel::GetInstance();
243 __pLogPresentor->AddCalllogChangeListener(*this);
245 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
246 pPhoneApp->AddAppStateChangeListener(*this);
247 Tizen::System::SettingInfo::AddSettingEventListener(*this);
249 __plogsListView->SetItemProvider(*__pDataProvider);
250 __isMsgAppControlLaunched = false;
251 __isCallAppControlLaunched = false;
253 if (__pFormFooter != null)
255 __pFormFooter->SetShowState(true);
256 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
258 __pFormFooter->SetItemEnabled(0, true);
262 __pFormFooter->SetItemEnabled(0, false);
265 //Check if opened in edit mode
266 if(__isEditMode == true)
268 //Check if "select all" is already selected
269 if (__pButtonSelectAll->IsSelected() == true)
271 //HandleAllItemSelection();
273 //If there is no items selected the reset the display mode
274 else if(__selectedItemCount == 0)
276 SetCallLogDisplayMode(false);
280 SetSceneVisible(true);
281 ManageItemSelection();
282 const Form* pForm = dynamic_cast<Form*>(GetParent());
285 if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
287 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
288 __plogsListView->SetBounds(newRect);
290 else if(__isEditMode == true)
292 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
293 __plogsListView->SetBounds(newRect);
297 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
303 DialTabLogs::HandleAllItemSelection(void)
305 SetListItemSelectStatus(true);
306 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
307 __selectedItemCount = __itemCount;
309 String selItemStr = L"";
310 if(__selectedItemCount > 1)
312 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
316 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
318 text.Format(100, selItemStr.GetPointer(), __itemCount);
319 __pSelectedLabel->SetText(text);
320 __pSelectedLabel->Invalidate(false);
324 DialTabLogs::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
326 AppLogDebug("Enter");
327 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
328 pPhoneApp->RemoveAppStateChangeListener(*this);
329 Tizen::System::SettingInfo::RemoveSettingEventListener(*this);
330 SetSceneVisible(false);
331 __pLogPresentor->RemoveCalllogChangeListner(*this);
332 __pLogPresentor = null;
336 DialTabLogs::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus state)
338 if (__isMsgAppControlLaunched == true || __isCallAppControlLaunched == true)
340 //AppControl already launched.
344 if (__isEditMode == false)
346 __pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
347 __pArgs->Construct();
348 CallLogDetails* pCalllogInfo = null;
349 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
350 if(pCalllogInfo != null && pCalllogInfo->GetPhoneNumber() == null)
352 //handling hidden call
355 if(pCalllogInfo != null)
357 __pArgs->Add((new String(pCalllogInfo->GetPhoneNumber())));
359 SceneManager* pSceneManager = SceneManager::GetInstance();
360 pSceneManager->GoForward( ForwardSceneTransition(IDSCN_CALL_LOG_DETAILS, SCENE_TRANSITION_ANIMATION_TYPE_NONE,
361 SCENE_HISTORY_OPTION_NO_HISTORY), __pArgs);
367 if (state == LIST_ITEM_STATUS_CHECKED)
369 __selectedItemCount++;
370 StoreItemselection(groupIndex, itemIndex, elementId, state);
372 else if (state == LIST_ITEM_STATUS_UNCHECKED)
374 __selectedItemCount--;
375 StoreItemselection(groupIndex, itemIndex, elementId, state);
377 if (__selectedItemCount == __itemCount)
379 __pButtonSelectAll->SetSelected(true);
383 __pButtonSelectAll->SetSelected(false);
385 if (__selectedItemCount == 0)
387 __pFormFooter->SetItemEnabled(0, false);
388 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
389 __pSelectedLabel->SetText(selStr);
393 __pFormFooter->SetItemEnabled(0, true);
394 String selItemStr = L"";
395 if(__selectedItemCount > 1)
397 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
401 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
403 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
404 __pSelectedLabel->SetText(text);
406 __pFormFooter->Invalidate(true);
407 __pButtonSelectAll->Invalidate(false);
408 __pSelectedLabel->Invalidate(false);
413 DialTabLogs::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus state)
415 //Empty implementation
416 CallLogDetails* pCalllogInfo = null;
417 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
418 __deleteGroupIndex = groupIndex;
419 __deleteItemIndex = itemIndex;
420 if(pCalllogInfo != null)
425 case IDA_LIST_ELEMENT_DELETE:
427 if(__pGroupContextDeletePopup != null)
429 delete __pGroupContextDeletePopup;
430 __pGroupContextDeletePopup = null;
433 __pGroupContextDeletePopup = new (std::nothrow) Popup();
434 __pGroupContextDeletePopup->Construct(true, Dimension(640,250));
435 __pGroupContextDeletePopup->SetPropagatedKeyEventListener(this);
436 __pGroupContextDeletePopup->SetTitleText(AppUtility::GetResourceString(IDS_DELETE_CONFORMATION_STRING));
439 Rectangle yesRect(10, 80, 300, 80);
440 Button* pYesButton = new Button();
441 pYesButton->Construct(yesRect, AppUtility::GetResourceString(IDS_DELETE_YES));
442 pYesButton->SetActionId(IDA_POPUP_DELETE_YES);
443 pYesButton->AddActionEventListener(*this);
444 __pGroupContextDeletePopup->AddControl(pYesButton);
447 yesRect.x = yesRect.x + yesRect.width + 10;
448 Button* pNoButton = new Button();
449 pNoButton->Construct(yesRect, AppUtility::GetResourceString(IDS_DELETE_NO));
450 pNoButton->SetActionId(IDA_POPUP_DELETE_NO);
451 pNoButton->AddActionEventListener(*this);
452 __pGroupContextDeletePopup->AddControl(pNoButton);
453 __pGroupContextDeletePopup->SetShowState(true);
454 __pGroupContextDeletePopup->Show();
458 case IDA_LIST_ELEMENT_CALL:
460 __isCallAppControlLaunched = true;
461 char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
462 if(pPhoneNumber == null)
464 __isCallAppControlLaunched = false;
467 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
468 if (pPhoneApp->IsOpenAsAppControl() == false)
470 __pLogPresentor->DialCall(String(pPhoneNumber));
474 //launched as AppControl
476 resultData.Construct();
477 resultData.Add(new (std::nothrow) String(PARAM_PHONE_NUMBER), new (std::nothrow) String(pPhoneNumber));
478 //send "APP_CTRL_RESULT_SUCCEEDED" and 'contactNumber' as result.
479 pPhoneApp->SendAppControlResponseMessage(APP_CTRL_RESULT_SUCCEEDED, &resultData);
480 resultData.RemoveAll(true);
481 pPhoneApp->Terminate();
486 case IDA_LIST_ELEMENT_MESSAGE:
488 result r = E_SUCCESS;
489 char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
490 if(pPhoneNumber == null)
494 //launch message AppControl
495 __isMsgAppControlLaunched = true;
496 String phoneNumber=L"";
497 phoneNumber.Append(pPhoneNumber);
500 extraData.Construct();
502 extraData.Add(new (std::nothrow) String(MESSAGE_TYPE), new (std::nothrow) String(MESSAGE_SMS_TYPE));
503 extraData.Add(new (std::nothrow) String(MESSAGE_TO), new (std::nothrow) String(phoneNumber));
505 AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
508 r = pAc->Start(null, null, &extraData, null);
511 //AppControl request failed, reset flag.
512 __isMsgAppControlLaunched = false;
518 extraData.RemoveAll(true);
522 case IDA_LIST_ELEMENT_VIDEO_CALL:
524 //todo: call once video call implemented
532 listView.UpdateList();
536 DialTabLogs::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
538 //Empty implementation
542 DialTabLogs::OnActionPerformed(const Control& source, int actionId)
544 CallLogDetails* pCalllogInfo = null;
545 __pDataProvider->GetItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex, &pCalllogInfo);
548 case IDA_CONTEXTMENU_VIEWBY:
550 ShowLogsViewByPopup();
554 case IDA_FOOTER_LOG_DELETE:
556 if (__isEditMode == false)
558 SetCallLogDisplayMode(true);
562 DeleteSelectedCalllog();
567 case IDA_FOOTER_LOG_CANCEL:
569 __pCallLogId->RemoveAll();
570 SetCallLogDisplayMode(false);
574 case IDA_CHECKBUTTON_SELECT_ALL:
576 __pCallLogId->RemoveAll();
577 HandleAllItemSelection();
581 case IDA_CHECKBUTTON_UNSELECT_ALL:
583 SetListItemSelectStatus(false);
584 __pCallLogId->RemoveAll();
585 __selectedItemCount = 0;
586 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
587 __pSelectedLabel->SetText(selStr);
588 __pSelectedLabel->Invalidate(false);
592 case IDA_POPUP_DELETE_CANCEL:
594 __deleteLogsTimer.Cancel();
599 case IDA_POPUP_DELETE_YES:
601 if(pCalllogInfo != null)
603 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
605 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
606 for(int i=0; i < dbIds->GetCount(); ++i)
\r
608 Integer* in = (Integer*)dbIds->GetAt(i);
\r
609 int p = in->ToInt();
\r
610 __pLogPresentor->DeleteCalllogByDbId(p);
\r
615 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());
\r
617 __pLogPresentor->DeleteItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex);
\r
618 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
620 __pFormFooter->SetItemEnabled(0, true);
624 __pFormFooter->SetItemEnabled(0, false);
626 __pFormFooter->Invalidate(true);
627 if(__pGroupContextDeletePopup != null)
629 __pGroupContextDeletePopup->SetShowState(false);
631 __deleteGroupIndex = 0;
632 __deleteItemIndex = 0;
637 case IDA_POPUP_DELETE_NO:
639 if(__pGroupContextDeletePopup != null)
641 __pGroupContextDeletePopup->SetShowState(false);
652 DialTabLogs::SetListItemSelectStatus(bool status)
658 __isSelectAll = status;
659 CallLogDetails* pCalllogInfo = null;
660 for (; groupIndex < __groupCount; groupIndex++)
662 itemCount = __plogsListView->GetItemCountAt(groupIndex);
663 for (itemIndex = 0; itemIndex < itemCount; itemIndex++)
665 __plogsListView->SetItemChecked(groupIndex, itemIndex, status);
668 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
669 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
673 __pFormFooter->SetItemEnabled(0, status);
674 __pFormFooter->Invalidate(true);
675 __plogsListView->Invalidate(true);
679 DialTabLogs::SetCallLogDisplayMode(bool isEdit)
681 AppLogDebug("Enter %d",isEdit);
682 if(isEdit == __isEditMode)
684 AppLog("Delete process return");
687 if( __pFormFooter == null)
689 AppLog("__pFormFooter == null");
693 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
694 __groupCount = __plogsListView->GetGroupCount();
695 __pButtonSelectAll->SetSelected(false);
698 __isEditMode = false;
699 __pDataProvider->SetListItemStyle(false);
700 __plogsListView->SetSweepEnabled(true);
701 const Form* pForm = dynamic_cast<Form*>(GetParent());
706 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
707 __plogsListView->UpdateList();
708 __pFormFooter->RemoveItemAt(1);
710 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
712 __pFormFooter->SetItemEnabled(0, true);
716 __pFormFooter->SetItemEnabled(0, false);
718 __pButtonSelectAll->SetShowState(false);
719 __pSelectedLabel->SetShowState(false);
720 __pSelectedLabel->Invalidate(false);
721 __pFormFooter->Invalidate(true);
726 const Form* pForm = dynamic_cast<Form*>(GetParent());
731 __pDataProvider->SetListItemStyle(isEdit);
732 __plogsListView->SetSweepEnabled(false);
734 //reset size to allow "SELECT ALL" & "TOAST MSG"
735 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
737 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
738 __plogsListView->SetBounds(newRect);
742 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
743 __plogsListView->SetBounds(newRect);
746 __plogsListView->UpdateList();
747 __pFormFooter->AddItem(__footerItemCancel);
748 __pButtonSelectAll->SetShowState(true);
749 __pFormFooter->SetItemEnabled(0, false);
750 __selectedItemCount = 0;
751 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
752 __pSelectedLabel->SetText(selStr);
753 __pSelectedLabel->SetShowState(true);
754 __pSelectedLabel->Invalidate(false);
755 __pFormFooter->Invalidate(true);
761 DialTabLogs::UnCheckAllItems(void)
764 __groupCount = __plogsListView->GetGroupCount();
\r
765 for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
767 itemCount = __plogsListView->GetItemCountAt(groupIndex);
768 for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
770 bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
771 if(isSelected == true)
773 __plogsListView->SetItemChecked(groupIndex,itemIndex,false);
777 __plogsListView->Invalidate(true);
778 __selectedItemCount = 0;
781 void DialTabLogs::OnCalllogChanged(void)
783 // If select all was selected before and some new calls are added (Auto rejeted call)
784 //Then we will not update the call log list.
785 if(__isEditMode == false)
787 if(__pGroupContextDeletePopup != null)
789 delete __pGroupContextDeletePopup;
790 __pGroupContextDeletePopup = null;
794 //It won't update the log list when delete is on progress.
795 /*else if(__isEditMode == true && __isDeleteInProgress == false)
797 __plogsListView->UpdateList();
798 __plogsListView->Invalidate(false);
800 //Update the log list for all MO/MT/MSG if the log list is in edit mode and delete is not on progress
801 else if(__isEditMode == true && __isDeleteInProgress == false)
803 if(__plogsListView != null)
805 __pLogPresentor->UpdateCallLogList();
806 __plogsListView->UpdateList();
807 __plogsListView->Invalidate(false);
810 if(IsScecneVisible() == true && __isDeleteInProgress == false)
812 ManageItemSelection();
817 DialTabLogs::UpdateCallLogList()
819 AppLogDebug("Enter");
821 __pLogPresentor->UpdateCallLogList();
\r
822 __plogsListView->UpdateList();
\r
823 if (__pFormFooter != null)
\r
825 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
827 __pFormFooter->SetShowState(true);
\r
828 __pFormFooter->SetItemEnabled(0,true);
830 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
832 __pFormFooter->SetItemEnabled(0, true);
\r
836 __pFormFooter->SetItemEnabled(0, false);
\r
838 __pFormFooter->Invalidate(true);
\r
843 DialTabLogs::ShowDeletePopup(void)
845 __isDeleteInProgress = true;
846 if (__pDeletePopup != null)
848 delete __pDeletePopup;
849 __pDeletePopup = null;
851 if(__selectedItemCount == 0)
853 AppLogDebug("Wrong state");
856 __deleteGroupIndex = 0;
857 __deleteItemIndex = 0;
859 __pDeletePopup = new (std::nothrow) Popup();
860 __pDeletePopup->Construct(false, Dimension(W_DELETE_POPUP, H_DELETE_POPUP));
861 __pDeletePopup->AddWindowEventListener(*this);
862 __pDeletePopup->SetPropagatedKeyEventListener(this);
864 Rectangle clientBounds = __pDeletePopup->GetClientAreaBounds();
866 Label* pLabelTitle = new (std::nothrow) Label();
867 pLabelTitle->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE, clientBounds.width, H_DELETE_POPUP_ELEMENT), AppUtility::GetResourceString(IDS_DELETING_CALL_LOGS));
868 pLabelTitle->SetTextColor(COLOR_DELETE_POPUP_TEXT);
869 pLabelTitle->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_BOLD);
870 pLabelTitle->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
872 __pDeletePopup->AddControl(*pLabelTitle);
874 Progress* pProgress = new (std::nothrow) Progress();
875 pProgress->Construct(Rectangle(0, Y_DELETE_POPUP_TITLE + H_DELETE_POPUP_ELEMENT, clientBounds.width, H_DELETE_POPUP_PROGRESS), 0, __selectedItemCount);
877 __pDeletePopup->AddControl(*pProgress);
879 Label* pLabelPercentage = new (std::nothrow) Label();
880 pLabelPercentage->Construct(Rectangle(0, pProgress->GetY() + pProgress->GetHeight(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), Integer::ToString(pProgress->GetPercentComplete()) + L"%");
881 pLabelPercentage->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
882 pLabelPercentage->SetTextColor(COLOR_DELETE_POPUP_TEXT);
883 pLabelPercentage->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
885 __pDeletePopup->AddControl(*pLabelPercentage);
887 String currentOfTotal(Integer::ToString(pProgress->GetValue()) + L" / " + Integer::ToString(__selectedItemCount));
888 Label* pLabelTotal = new (std::nothrow) Label();
889 pLabelTotal->Construct(Rectangle(clientBounds.width / 2, pLabelPercentage->GetY(), clientBounds.width / 2, H_DELETE_POPUP_ELEMENT), currentOfTotal);
890 pLabelTotal->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
891 pLabelTotal->SetTextColor(COLOR_DELETE_POPUP_TEXT);
892 pLabelTotal->SetTextConfig(FONT_SIZE_DELETE_POPUP_TEXT, LABEL_TEXT_STYLE_NORMAL);
894 __pDeletePopup->AddControl(*pLabelTotal);
896 Button* pCancelButton = new (std::nothrow) Button();
897 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));
898 pCancelButton->SetText(AppUtility::GetResourceString(IDS_CANCEL_DELETING_CALL_LOGS));
899 pCancelButton->SetActionId(IDA_POPUP_DELETE_CANCEL);
900 pCancelButton->AddActionEventListener(*this);
902 __pDeletePopup->AddControl(pCancelButton);
903 __pDeletePopup->Show();
908 DialTabLogs::OnWindowActivated (const Tizen::Ui::Window &source)
910 __deleteLogsTimer.Start(1);
914 DialTabLogs::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
916 Progress* pProgress = static_cast<Progress *>(__pDeletePopup->GetControl(1));
918 pProgress->SetValue(pProgress->GetValue() + 1);
919 pProgress->Invalidate(false);
921 Label* pLabelPercentage = static_cast<Label *>(__pDeletePopup->GetControl(2));
923 pLabelPercentage->SetText(Integer::ToString(pProgress->GetPercentComplete()) + L"%");
924 pLabelPercentage->Invalidate(false);
926 Label* pLabelTotal = static_cast<Label *>(__pDeletePopup->GetControl(3));
928 String currentOfTotal = pLabelTotal->GetText();
929 currentOfTotal.Remove(0, Integer::ToString(pProgress->GetValue() - 1).GetLength());
930 currentOfTotal.Insert(Integer::ToString(pProgress->GetValue()), 0);
931 pLabelTotal->SetText(currentOfTotal);
932 pLabelTotal->Invalidate(false);
934 if (RemoveLogsList() == E_SUCCESS)
936 __deleteLogsTimer.Start(1);
945 DialTabLogs::RemoveLogsList(void)
947 result r = E_FAILURE;
949 CallLogDetails* pCalllogInfo = null;
950 for(int groupIndex = __deleteGroupIndex; groupIndex < __plogsListView->GetGroupCount(); groupIndex++)
952 int itemCount = __plogsListView->GetItemCountAt(groupIndex);
953 for(int itemIndex = __deleteItemIndex; itemIndex < itemCount ; itemIndex++)
955 bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
956 if(isSelected == true)
958 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
959 if(pCalllogInfo != null)
961 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
963 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
964 for(int i=0; i < dbIds->GetCount(); ++i)
\r
966 Integer* in = (Integer*)dbIds->GetAt(i);
\r
967 int p = in->ToInt();
\r
968 __pLogPresentor->DeleteCalllogByDbId(p);
\r
973 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());
\r
977 __deleteGroupIndex = groupIndex;
978 __deleteItemIndex = ++itemIndex;
979 __pCallLogId->Remove(*(new Integer(pCalllogInfo->GetCalllogDbId())));
984 __deleteItemIndex = 0;
986 __deleteGroupIndex = 0;
987 __deleteItemIndex = 0;
993 DialTabLogs::HideDeletePopup(void)
995 __isDeleteInProgress = false;
996 if (__pDeletePopup != null)
998 __pDeletePopup->SetShowState(false);
999 __pDeletePopup->Invalidate(true);
1000 SendUserEvent(REQUEST_CHANGE_EDIT_MODE,null);
1002 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
1004 __pFormFooter->SetItemEnabled(0, true);
1008 __pFormFooter->SetItemEnabled(0, false);
1010 __pFormFooter->Invalidate(true);
1014 DialTabLogs::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1018 case REQUEST_CHANGE_EDIT_MODE:
1020 //CustomDataProvider::setCallLogViewbyID(CALL_LOG_TYPE_ALL);
1021 UpdateCallLogList();
1022 SetCallLogDisplayMode(false);
1026 case REQUEST_CHANGE_VIEWBY:
1028 UpdateCallLogList();
1029 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
1031 __pFormFooter->SetItemEnabled(0, true);
1035 __pFormFooter->SetItemEnabled(0, false);
1044 DialTabLogs::OnForeground(void)
1046 AppLogDebug("Enter");
1047 if (__isMsgAppControlLaunched == true)
1049 //Message AppControl request completed.
1050 __isMsgAppControlLaunched = false;
1052 if (__isCallAppControlLaunched == true)
1054 //Call AppControl request completed.
1055 __isCallAppControlLaunched = false;
1057 if(__pLogsViewbyPopup != null && __pLogPresentor->GetAllCallLogCount() == 0)
1059 delete __pLogsViewbyPopup;
1060 __pLogsViewbyPopup = null;
1062 SetSceneVisible(true);
1063 ManageItemSelection();
1065 //change the font, if font has been changed from backgroung
1066 float fontSize = 0.0;
1067 float itemHeight = 0.0;
1068 AppUtility::GetGlobalFontAndItemHeight(&fontSize, &itemHeight);
1069 if(__fontSize != fontSize)
1071 __fontSize = fontSize;
1072 __itemHeight = itemHeight;
1073 __plogsListView->UpdateList();
1074 if(__pLogsViewbyPopup != null && __pLogsViewbyPopup->GetShowState() == true)
1076 __pLogsViewbyPopup->UpdateViewByPopupList();
1082 DialTabLogs::OnBackground(void)
1084 SetSceneVisible(false);
\r
1088 DialTabLogs::StoreItemselection(int groupIndex, int itemIndex, int elementId, ListItemStatus state)
1090 CallLogDetails* pCalllogInfo = null;
1091 if (state == LIST_ITEM_STATUS_CHECKED)
1093 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1094 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
1096 else if (state == LIST_ITEM_STATUS_UNCHECKED)
1098 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1099 __pCallLogId->Remove(*(new Integer(pCalllogInfo->GetCalllogDbId())));
1103 DialTabLogs:: ManageItemSelection(void)
1105 if(__isEditMode == true && __selectedItemCount > 0 && __pLogPresentor->GetCallLogsViewedCount() != __itemCount)
1109 CallLogDetails* pCalllogInfo = null;
1110 for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
1112 itemCount = __plogsListView->GetItemCountAt(groupIndex);
1113 for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
1115 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1117 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
1119 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
1120 for(int i=0; i < dbIds->GetCount(); ++i)
\r
1122 Integer* in = (Integer*)dbIds->GetAt(i);
\r
1123 if(__pCallLogId->Contains(*in))
\r
1125 __plogsListView->SetItemChecked(groupIndex,itemIndex,true);
\r
1126 ++__selectedItemCount;
\r
1133 if(__pCallLogId->Contains(*(new Integer(pCalllogInfo->GetCalllogDbId()))))
\r
1135 __plogsListView->SetItemChecked(groupIndex,itemIndex,true);
\r
1136 ++__selectedItemCount;
\r
1141 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
1142 if(__selectedItemCount == __itemCount)
1144 __pButtonSelectAll->SetSelected(true);
1148 __pButtonSelectAll->SetSelected(false);
1150 String selItemStr = L"";
1152 if(__selectedItemCount == 0)
1154 selItemStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1156 else if(__selectedItemCount > 1)
1158 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1162 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1164 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
1165 __pSelectedLabel->SetText(text);
1166 __pSelectedLabel->Invalidate(false);
1171 DialTabLogs::IsScecneVisible()
1173 return __isSceneVisible;
1178 DialTabLogs::SetSceneVisible(bool sceneMode)
1180 __isSceneVisible = sceneMode;
1184 DialTabLogs::ShowLogsViewByPopup(void)
1186 if(__pLogsViewbyPopup != null)
1188 delete __pLogsViewbyPopup;
1189 __pLogsViewbyPopup = null;
1192 __pLogsViewbyPopup = new (std::nothrow) CallLogViewByPopup(*this);
1193 __pLogsViewbyPopup->ConstructViewbyPopup();
1194 __pLogsViewbyPopup->SetShowState(true);
1195 __pLogsViewbyPopup->Draw();
1196 __pLogsViewbyPopup->Show();
1200 DialTabLogs::OnItemSelected()
1202 SendUserEvent(REQUEST_CHANGE_VIEWBY, null);
1206 DialTabLogs::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1208 const Form* pForm = dynamic_cast<Form*>(GetParent());
1213 if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
1215 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX + 20, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
1216 __plogsListView->SetBounds(newRect);
1218 else if(__isEditMode == true)
1220 Rectangle newRect(pForm->GetX(), H_SELECTALL_CHK_BOX, pForm->GetWidth(), (pForm->GetClientAreaBounds().height - H_SELECTALL_CHK_BOX - H_TOAST_MSG));
1221 __plogsListView->SetBounds(newRect);
1225 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
1230 DialTabLogs::OnSettingChanged(Tizen::Base::String& key)
1233 if(key.Equals(String(SETTING_INFO_KEY_TIME_FORMAT)) == true)
1235 __plogsListView->UpdateList();
1241 DialTabLogs::ShowOptionsMenu()
1243 if(__isEditMode == false && __pLogPresentor->GetAllCallLogCount() > 0)
1245 if(__pOptionMenu != null)
1247 delete __pOptionMenu;
1248 __pOptionMenu = null;
1250 __pOptionMenu = new (std::nothrow) OptionMenu();
1251 __pOptionMenu->Construct();
1252 __pOptionMenu->RemoveAllItems();
1253 __pOptionMenu->AddItem(AppUtility::GetResourceString(IDS_CONTEXTMENU_ITEM_VIEWBY), IDA_CONTEXTMENU_VIEWBY);
1254 __pOptionMenu->AddActionEventListener(*this);
1255 __pOptionMenu->SetShowState(true);
1256 __pOptionMenu->Show();
1261 DialTabLogs::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1263 AppLogDebug("Enter");
1264 if(keyEventInfo.GetKeyCode() == KEY_BACK)
1266 if(__pGroupContextDeletePopup != null && __pGroupContextDeletePopup->GetShowState() == true)
1268 __pGroupContextDeletePopup->SetShowState(false);
1270 else if(__pDeletePopup != null && __pDeletePopup->GetShowState() == true)