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;
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;
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;
67 static const int FONT_SIZE_DELETE_POPUP_TEXT = 36;
68 //static const int X_MORE = 55;
70 static const unsigned int COLOR_DELETE_POPUP_TEXT = Color32<128, 128, 128>::Value;
71 DialTabLogs::DialTabLogs(void)
73 __pDataProvider = new CustomDataProvider();
75 __plogsListView = null;
77 __pButtonSelectAll = null;
80 __isSelectAll = false;
81 __selectedItemCount = 0;
82 __pLogPresentor = null;
84 __deleteLogsTimer.Construct(*this);
85 __deleteGroupIndex = 0;
86 __deleteItemIndex = 0;
87 __pDeletePopup = null;
88 __pGroupContextDeletePopup = null;
90 __isSceneVisible = false;
91 __pLogsViewbyPopup = null;
92 __isMsgAppControlLaunched = false;
93 __isCallAppControlLaunched = false;
95 __isDeleteInProgress = false;
98 DialTabLogs::~DialTabLogs(void)
100 AppLogDebug("Enter");
101 if (__pDataProvider != null)
103 delete __pDataProvider;
104 __pDataProvider = null;
106 if (__pLogPresentor != null)
108 __pLogPresentor->RemoveCalllogChangeListner(*this);
109 __pLogPresentor = null;
111 if (__pCallLogId != null)
113 __pCallLogId->RemoveAll();
117 if(__pLogsViewbyPopup != null)
119 delete __pLogsViewbyPopup;
120 __pLogsViewbyPopup = null;
125 DialTabLogs::Initialize(void)
127 result r = Construct(IDL_PANEL_LOGS);
128 TryCatch(r == E_SUCCESS, , "DialTabLogs::Initialise() - Fail to initialise Call log panel");
136 DialTabLogs::OnInitializing(void)
138 result r = E_SUCCESS;
140 Form* pForm = dynamic_cast<Form*>(GetParent());
146 pForm->AddOrientationEventListener(*this);
148 RelativeLayout* pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetLandscapeLayoutN());
149 if (pRelativeLayout != null)
151 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
152 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
153 delete pRelativeLayout;
156 pRelativeLayout = dynamic_cast<RelativeLayout*>(pForm->GetPortraitLayoutN());
157 if (pRelativeLayout != null)
159 pRelativeLayout->SetHorizontalFitPolicy(*this, FIT_POLICY_PARENT);
160 pRelativeLayout->SetVerticalFitPolicy(*this, FIT_POLICY_PARENT);
161 delete pRelativeLayout;
164 __pFormFooter = pForm->GetFooter();
165 if (__pFormFooter != null)
167 __pFormFooter->SetShowState(true);
168 __pFormFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
169 __pFormFooter->AddActionEventListener(*this);
171 __footerItemDelete.Construct(IDA_FOOTER_LOG_DELETE);
172 String delStr = AppUtility::GetResourceString(IDS_DELETE_BTN_STRING);
173 __footerItemDelete.SetText(delStr);
174 __pFormFooter->AddItem(__footerItemDelete);
176 String cancelStr = AppUtility::GetResourceString(IDS_CANCEL_BTN_STRING);
177 __footerItemCancel.Construct(IDA_FOOTER_LOG_CANCEL);
178 __footerItemCancel.SetText(cancelStr);
181 __pButtonSelectAll = static_cast<CheckButton*>(GetControl("IDC_CHECKBUTTON_SELECTALL"));
182 if (__pButtonSelectAll != null)
184 __pButtonSelectAll->SetShowState(false);
185 __pButtonSelectAll->SetActionId(IDA_CHECKBUTTON_SELECT_ALL, IDA_CHECKBUTTON_UNSELECT_ALL);
186 __pButtonSelectAll->AddActionEventListener(*this);
187 __pButtonSelectAll->SetTextVerticalAlignment(ALIGNMENT_MIDDLE);
191 __plogsListView = new (std::nothrow) GroupedListView();
192 if (__plogsListView != null)
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)
199 __plogsListView->SetBitmapOfEmptyList(pNoContentBitmap);
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");
208 __pSelectedLabel = static_cast<Label*>(GetControl(IDC_LABEL_SELECTED_POPUP));
209 if(__pSelectedLabel != null)
211 SetControlAlwaysOnTop(*__pSelectedLabel,true);
212 __pSelectedLabel->SetBackgroundColor(COLOR_LABEL_SELECTED);
213 __pSelectedLabel->SetShowState(false);
216 __pCallLogId = new(std::nothrow) ArrayList();
217 r = __pCallLogId->Construct();
224 DialTabLogs::OnTerminating(void)
226 result r = E_SUCCESS;
227 delete __pDeletePopup;
228 __pDeletePopup = null;
229 delete __pGroupContextDeletePopup;
230 __pGroupContextDeletePopup = null;
231 __plogsListView = null;
232 delete __pOptionMenu;
237 DialTabLogs::DeleteSelectedCalllog(void)
243 DialTabLogs::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId& currentSceneId, IList* pArgs)
245 AppUtility::GetGlobalFontAndItemHeight(&__fontSize, &__itemHeight);
246 __pLogPresentor = CalLogPresentationModel::GetInstance();
247 __pLogPresentor->AddCalllogChangeListener(*this);
249 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(PhoneApp::GetInstance());
250 pPhoneApp->AddAppStateChangeListener(*this);
251 Tizen::System::SettingInfo::AddSettingEventListener(*this);
253 __plogsListView->SetItemProvider(*__pDataProvider);
254 __isMsgAppControlLaunched = false;
255 __isCallAppControlLaunched = false;
257 if (__pFormFooter != null)
259 __pFormFooter->SetShowState(true);
260 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
262 __pFormFooter->SetItemEnabled(0, true);
266 __pFormFooter->SetItemEnabled(0, false);
269 //Check if opened in edit mode
270 if(__isEditMode == true)
272 //Check if "select all" is already selected
273 if (__pButtonSelectAll->IsSelected() == true)
275 //HandleAllItemSelection();
277 //If there is no items selected the reset the display mode
278 else if(__selectedItemCount == 0)
280 SetCallLogDisplayMode(false);
284 SetSceneVisible(true);
285 ManageItemSelection();
286 const Form* pForm = dynamic_cast<Form*>(GetParent());
289 if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
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);
294 else if(__isEditMode == true)
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);
301 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
307 DialTabLogs::HandleAllItemSelection(void)
309 SetListItemSelectStatus(true);
310 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
311 __selectedItemCount = __itemCount;
313 String selItemStr = L"";
314 if(__selectedItemCount > 1)
316 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
320 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
322 text.Format(100, selItemStr.GetPointer(), __itemCount);
323 __pSelectedLabel->SetText(text);
324 __pSelectedLabel->Invalidate(false);
328 DialTabLogs::OnSceneDeactivated(const SceneId& currentSceneId, const SceneId& nextSceneId)
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;
340 DialTabLogs::OnGroupedListViewItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListItemStatus state)
342 if (__isMsgAppControlLaunched == true || __isCallAppControlLaunched == true)
344 //AppControl already launched.
348 if (__isEditMode == false)
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)
356 //handling hidden call
359 if(pCalllogInfo != null)
361 __pArgs->Add((new String(pCalllogInfo->GetPhoneNumber())));
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);
371 if (state == LIST_ITEM_STATUS_CHECKED)
373 __selectedItemCount++;
374 StoreItemselection(groupIndex, itemIndex, elementId, state);
376 else if (state == LIST_ITEM_STATUS_UNCHECKED)
378 __selectedItemCount--;
379 StoreItemselection(groupIndex, itemIndex, elementId, state);
381 if (__selectedItemCount == __itemCount)
383 __pButtonSelectAll->SetSelected(true);
387 __pButtonSelectAll->SetSelected(false);
389 if (__selectedItemCount == 0)
391 __pFormFooter->SetItemEnabled(0, false);
392 String selStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
393 __pSelectedLabel->SetText(selStr);
397 __pFormFooter->SetItemEnabled(0, true);
398 String selItemStr = L"";
399 if(__selectedItemCount > 1)
401 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
405 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
407 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
408 __pSelectedLabel->SetText(text);
410 __pFormFooter->Invalidate(true);
411 __pButtonSelectAll->Invalidate(false);
412 __pSelectedLabel->Invalidate(false);
417 DialTabLogs::OnGroupedListViewContextItemStateChanged(GroupedListView& listView, int groupIndex, int itemIndex, int elementId, ListContextItemStatus state)
419 //Empty implementation
420 CallLogDetails* pCalllogInfo = null;
421 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
422 __deleteGroupIndex = groupIndex;
423 __deleteItemIndex = itemIndex;
424 if(pCalllogInfo != null)
429 case IDA_LIST_ELEMENT_DELETE:
431 if(__pGroupContextDeletePopup != null)
433 delete __pGroupContextDeletePopup;
434 __pGroupContextDeletePopup = null;
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);
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);
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();
469 case IDA_LIST_ELEMENT_CALL:
471 __isCallAppControlLaunched = true;
472 char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
473 if(pPhoneNumber == null)
475 __isCallAppControlLaunched = false;
478 PhoneApp* pPhoneApp = static_cast<PhoneApp*>(UiApp::GetInstance());
479 if (pPhoneApp->IsOpenAsAppControl() == false)
481 __pLogPresentor->DialCall(String(pPhoneNumber));
485 //launched as AppControl
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();
497 case IDA_LIST_ELEMENT_MESSAGE:
499 result r = E_SUCCESS;
500 char* pPhoneNumber = pCalllogInfo->GetPhoneNumber();
501 if(pPhoneNumber == null)
505 //launch message AppControl
506 __isMsgAppControlLaunched = true;
507 String phoneNumber=L"";
508 phoneNumber.Append(pPhoneNumber);
511 extraData.Construct();
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));
516 AppControl* pAc = AppManager::FindAppControlN(PROVIDER_ID_MESSAGE, OPERATION_ID_COMPOSE);
519 r = pAc->Start(null, null, &extraData, null);
522 //AppControl request failed, reset flag.
523 __isMsgAppControlLaunched = false;
529 extraData.RemoveAll(true);
533 case IDA_LIST_ELEMENT_VIDEO_CALL:
535 //todo: call once video call implemented
543 listView.UpdateList();
547 DialTabLogs::OnGroupedListViewItemSwept(GroupedListView& listView, int groupIndex, int itemIndex, SweepDirection direction)
549 //Empty implementation
553 DialTabLogs::OnActionPerformed(const Control& source, int actionId)
555 CallLogDetails* pCalllogInfo = null;
556 __pDataProvider->GetItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex, &pCalllogInfo);
559 case IDA_CONTEXTMENU_VIEWBY:
561 ShowLogsViewByPopup();
565 case IDA_FOOTER_LOG_DELETE:
567 if (__isEditMode == false)
569 SetCallLogDisplayMode(true);
573 DeleteSelectedCalllog();
578 case IDA_FOOTER_LOG_CANCEL:
580 __pCallLogId->RemoveAll();
581 SetCallLogDisplayMode(false);
585 case IDA_CHECKBUTTON_SELECT_ALL:
587 __pCallLogId->RemoveAll();
588 HandleAllItemSelection();
592 case IDA_CHECKBUTTON_UNSELECT_ALL:
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);
603 case IDA_POPUP_DELETE_CANCEL:
605 __deleteLogsTimer.Cancel();
610 case IDA_POPUP_DELETE_YES:
612 if(pCalllogInfo != null)
614 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
616 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
617 for(int i=0; i < dbIds->GetCount(); ++i)
\r
619 Integer* in = (Integer*)dbIds->GetAt(i);
\r
620 int p = in->ToInt();
\r
621 __pLogPresentor->DeleteCalllogByDbId(p);
\r
626 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());
\r
628 __pLogPresentor->DeleteItemAtGroupIndex(__deleteGroupIndex, __deleteItemIndex);
\r
629 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
631 __pFormFooter->SetItemEnabled(0, true);
635 __pFormFooter->SetItemEnabled(0, false);
637 __pFormFooter->Invalidate(true);
638 if(__pGroupContextDeletePopup != null)
640 __pGroupContextDeletePopup->SetShowState(false);
642 __deleteGroupIndex = 0;
643 __deleteItemIndex = 0;
648 case IDA_POPUP_DELETE_NO:
650 if(__pGroupContextDeletePopup != null)
652 __pGroupContextDeletePopup->SetShowState(false);
663 DialTabLogs::SetListItemSelectStatus(bool status)
669 __isSelectAll = status;
670 CallLogDetails* pCalllogInfo = null;
671 for (; groupIndex < __groupCount; groupIndex++)
673 itemCount = __plogsListView->GetItemCountAt(groupIndex);
674 for (itemIndex = 0; itemIndex < itemCount; itemIndex++)
676 __plogsListView->SetItemChecked(groupIndex, itemIndex, status);
679 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
680 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
684 __pFormFooter->SetItemEnabled(0, status);
685 __pFormFooter->Invalidate(true);
686 __plogsListView->Invalidate(true);
690 DialTabLogs::SetCallLogDisplayMode(bool isEdit)
692 AppLogDebug("Enter %d",isEdit);
693 if(isEdit == __isEditMode)
695 AppLog("Delete process return");
698 if( __pFormFooter == null)
700 AppLog("__pFormFooter == null");
704 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
705 __groupCount = __plogsListView->GetGroupCount();
706 __pButtonSelectAll->SetSelected(false);
709 __isEditMode = false;
710 __pDataProvider->SetListItemStyle(false);
711 __plogsListView->SetSweepEnabled(true);
712 const Form* pForm = dynamic_cast<Form*>(GetParent());
717 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
718 __plogsListView->UpdateList();
719 __pFormFooter->RemoveItemAt(1);
721 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
723 __pFormFooter->SetItemEnabled(0, true);
727 __pFormFooter->SetItemEnabled(0, false);
729 __pButtonSelectAll->SetShowState(false);
730 __pSelectedLabel->SetShowState(false);
731 __pSelectedLabel->Invalidate(false);
732 __pFormFooter->Invalidate(true);
737 const Form* pForm = dynamic_cast<Form*>(GetParent());
742 __pDataProvider->SetListItemStyle(isEdit);
743 __plogsListView->SetSweepEnabled(false);
745 //reset size to allow "SELECT ALL" & "TOAST MSG"
746 if(pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE)
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);
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);
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);
772 DialTabLogs::UnCheckAllItems(void)
775 __groupCount = __plogsListView->GetGroupCount();
\r
776 for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
778 itemCount = __plogsListView->GetItemCountAt(groupIndex);
779 for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
781 bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
782 if(isSelected == true)
784 __plogsListView->SetItemChecked(groupIndex,itemIndex,false);
788 __plogsListView->Invalidate(true);
789 __selectedItemCount = 0;
792 void DialTabLogs::OnCalllogChanged(void)
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)
798 if(__pGroupContextDeletePopup != null)
800 delete __pGroupContextDeletePopup;
801 __pGroupContextDeletePopup = null;
805 //It won't update the log list when delete is on progress.
806 /*else if(__isEditMode == true && __isDeleteInProgress == false)
808 __plogsListView->UpdateList();
809 __plogsListView->Invalidate(false);
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)
814 if(__plogsListView != null)
816 __pLogPresentor->UpdateCallLogList();
817 __plogsListView->UpdateList();
818 __plogsListView->Invalidate(false);
821 if(IsScecneVisible() == true && __isDeleteInProgress == false)
823 ManageItemSelection();
828 DialTabLogs::UpdateCallLogList()
830 AppLogDebug("Enter");
832 __pLogPresentor->UpdateCallLogList();
\r
833 __plogsListView->UpdateList();
\r
834 if (__pFormFooter != null)
\r
836 if(__pLogPresentor->GetAllCallLogCount() > 0)
\r
838 __pFormFooter->SetShowState(true);
\r
839 __pFormFooter->SetItemEnabled(0,true);
841 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
843 __pFormFooter->SetItemEnabled(0, true);
\r
847 __pFormFooter->SetItemEnabled(0, false);
\r
849 __pFormFooter->Invalidate(true);
\r
854 DialTabLogs::ShowDeletePopup(void)
856 __isDeleteInProgress = true;
857 if (__pDeletePopup != null)
859 delete __pDeletePopup;
860 __pDeletePopup = null;
862 if(__selectedItemCount == 0)
864 AppLogDebug("Wrong state");
867 __deleteGroupIndex = 0;
868 __deleteItemIndex = 0;
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);
875 Rectangle clientBounds = __pDeletePopup->GetClientAreaBounds();
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);
883 __pDeletePopup->AddControl(*pLabelTitle);
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);
888 __pDeletePopup->AddControl(*pProgress);
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);
896 __pDeletePopup->AddControl(*pLabelPercentage);
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);
905 __pDeletePopup->AddControl(*pLabelTotal);
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);
913 __pDeletePopup->AddControl(pCancelButton);
914 __pDeletePopup->Show();
919 DialTabLogs::OnWindowActivated (const Tizen::Ui::Window &source)
921 __deleteLogsTimer.Start(1);
925 DialTabLogs::OnTimerExpired(Tizen::Base::Runtime::Timer &timer)
927 Progress* pProgress = static_cast<Progress *>(__pDeletePopup->GetControl(1));
929 pProgress->SetValue(pProgress->GetValue() + 1);
930 pProgress->Invalidate(false);
932 Label* pLabelPercentage = static_cast<Label *>(__pDeletePopup->GetControl(2));
934 pLabelPercentage->SetText(Integer::ToString(pProgress->GetPercentComplete()) + L"%");
935 pLabelPercentage->Invalidate(false);
937 Label* pLabelTotal = static_cast<Label *>(__pDeletePopup->GetControl(3));
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);
945 if (RemoveLogsList() == E_SUCCESS)
947 __deleteLogsTimer.Start(1);
956 DialTabLogs::RemoveLogsList(void)
958 result r = E_FAILURE;
960 CallLogDetails* pCalllogInfo = null;
961 for(int groupIndex = __deleteGroupIndex; groupIndex < __plogsListView->GetGroupCount(); groupIndex++)
963 int itemCount = __plogsListView->GetItemCountAt(groupIndex);
964 for(int itemIndex = __deleteItemIndex; itemIndex < itemCount ; itemIndex++)
966 bool isSelected = __plogsListView->IsItemChecked(groupIndex, itemIndex);
967 if(isSelected == true)
969 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
970 if(pCalllogInfo != null)
972 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
974 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
975 for(int i=0; i < dbIds->GetCount(); ++i)
\r
977 Integer* in = (Integer*)dbIds->GetAt(i);
\r
978 int p = in->ToInt();
\r
979 __pLogPresentor->DeleteCalllogByDbId(p);
\r
984 __pLogPresentor->DeleteCalllogByDbId(pCalllogInfo->GetCalllogDbId());
\r
988 __deleteGroupIndex = groupIndex;
989 __deleteItemIndex = ++itemIndex;
990 __pCallLogId->Remove(Integer(pCalllogInfo->GetCalllogDbId()));
995 __deleteItemIndex = 0;
997 __deleteGroupIndex = 0;
998 __deleteItemIndex = 0;
1004 DialTabLogs::HideDeletePopup(void)
1006 __isDeleteInProgress = false;
1007 if (__pDeletePopup != null)
1009 __pDeletePopup->SetShowState(false);
1010 __pDeletePopup->Invalidate(true);
1011 SendUserEvent(REQUEST_CHANGE_EDIT_MODE,null);
1013 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
1015 __pFormFooter->SetItemEnabled(0, true);
1019 __pFormFooter->SetItemEnabled(0, false);
1021 __pFormFooter->Invalidate(true);
1025 DialTabLogs::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1029 case REQUEST_CHANGE_EDIT_MODE:
1031 //CustomDataProvider::setCallLogViewbyID(CALL_LOG_TYPE_ALL);
1032 UpdateCallLogList();
1033 SetCallLogDisplayMode(false);
1037 case REQUEST_CHANGE_VIEWBY:
1039 UpdateCallLogList();
1040 if(__pLogPresentor->GetCallLogsViewedCount() > 0)
\r
1042 __pFormFooter->SetItemEnabled(0, true);
1046 __pFormFooter->SetItemEnabled(0, false);
1055 DialTabLogs::OnForeground(void)
1057 AppLogDebug("Enter");
1058 if (__isMsgAppControlLaunched == true)
1060 //Message AppControl request completed.
1061 __isMsgAppControlLaunched = false;
1063 if (__isCallAppControlLaunched == true)
1065 //Call AppControl request completed.
1066 __isCallAppControlLaunched = false;
1068 if(__pLogsViewbyPopup != null && __pLogPresentor->GetAllCallLogCount() == 0)
1070 delete __pLogsViewbyPopup;
1071 __pLogsViewbyPopup = null;
1073 SetSceneVisible(true);
1074 ManageItemSelection();
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)
1082 __fontSize = fontSize;
1083 __itemHeight = itemHeight;
1084 __plogsListView->UpdateList();
1085 if(__pLogsViewbyPopup != null && __pLogsViewbyPopup->GetShowState() == true)
1087 __pLogsViewbyPopup->UpdateViewByPopupList();
1093 DialTabLogs::OnBackground(void)
1095 SetSceneVisible(false);
\r
1099 DialTabLogs::StoreItemselection(int groupIndex, int itemIndex, int elementId, ListItemStatus state)
1101 CallLogDetails* pCalllogInfo = null;
1102 if (state == LIST_ITEM_STATUS_CHECKED)
1104 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1105 __pCallLogId->Add(new Integer(pCalllogInfo->GetCalllogDbId()));
1107 else if (state == LIST_ITEM_STATUS_UNCHECKED)
1109 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1110 __pCallLogId->Remove(Integer(pCalllogInfo->GetCalllogDbId()));
1114 DialTabLogs:: ManageItemSelection(void)
1116 if(__isEditMode == true && __selectedItemCount > 0 && __pLogPresentor->GetCallLogsViewedCount() != __itemCount)
1120 CallLogDetails* pCalllogInfo = null;
1121 for(int groupIndex = 0; groupIndex < __groupCount; groupIndex++)
1123 itemCount = __plogsListView->GetItemCountAt(groupIndex);
1124 for(int itemIndex = itemCount-1; itemIndex >=0 ; itemIndex--)
1126 __pDataProvider->GetItemAtGroupIndex(groupIndex, itemIndex, &pCalllogInfo);
1128 if(pCalllogInfo->GetConsecutiveNoCounter() > 1)
\r
1130 Tizen::Base::Collection::ArrayList* dbIds = pCalllogInfo->GetCallLogDbIds();
\r
1131 for(int i=0; i < dbIds->GetCount(); ++i)
\r
1133 Integer* in = (Integer*)dbIds->GetAt(i);
\r
1134 if(__pCallLogId->Contains(*in))
\r
1136 __plogsListView->SetItemChecked(groupIndex,itemIndex,true);
\r
1137 ++__selectedItemCount;
\r
1144 if(__pCallLogId->Contains(Integer(pCalllogInfo->GetCalllogDbId())))
\r
1146 __plogsListView->SetItemChecked(groupIndex,itemIndex,true);
\r
1147 ++__selectedItemCount;
\r
1152 __itemCount = __pLogPresentor->GetCallLogsViewedCount();
\r
1153 if(__selectedItemCount == __itemCount)
1155 __pButtonSelectAll->SetSelected(true);
1159 __pButtonSelectAll->SetSelected(false);
1161 String selItemStr = L"";
1163 if(__selectedItemCount == 0)
1165 selItemStr = AppUtility::GetResourceString(IDS_SELECT_CALL_LOG);
1167 else if(__selectedItemCount > 1)
1169 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEMS_STRING);
1173 selItemStr = AppUtility::GetResourceString(IDS_SELECTED_ITEM_STRING);
1175 text.Format(100, selItemStr.GetPointer(), __selectedItemCount);
1176 __pSelectedLabel->SetText(text);
1177 __pSelectedLabel->Invalidate(false);
1182 DialTabLogs::IsScecneVisible()
1184 return __isSceneVisible;
1189 DialTabLogs::SetSceneVisible(bool sceneMode)
1191 __isSceneVisible = sceneMode;
1195 DialTabLogs::ShowLogsViewByPopup(void)
1197 if(__pLogsViewbyPopup != null)
1199 delete __pLogsViewbyPopup;
1200 __pLogsViewbyPopup = null;
1203 __pLogsViewbyPopup = new (std::nothrow) CallLogViewByPopup(*this);
1204 __pLogsViewbyPopup->ConstructViewbyPopup();
1205 __pLogsViewbyPopup->SetShowState(true);
1206 __pLogsViewbyPopup->Draw();
1207 __pLogsViewbyPopup->Show();
1211 DialTabLogs::OnItemSelected()
1213 SendUserEvent(REQUEST_CHANGE_VIEWBY, null);
1217 DialTabLogs::OnOrientationChanged(const Control& source, OrientationStatus orientationStatus)
1219 const Form* pForm = dynamic_cast<Form*>(GetParent());
1224 if((pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE || pForm->GetOrientationStatus() == ORIENTATION_STATUS_LANDSCAPE_REVERSE) && __isEditMode == true)
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);
1229 else if(__isEditMode == true)
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);
1236 __plogsListView->SetBounds(pForm->GetX(), pForm->GetY(), pForm->GetWidth(), pForm->GetClientAreaBounds().height);
1241 DialTabLogs::OnSettingChanged(Tizen::Base::String& key)
1244 if(key.Equals(String(SETTING_INFO_KEY_TIME_FORMAT)) == true)
1246 __plogsListView->UpdateList();
1252 DialTabLogs::ShowOptionsMenu()
1254 if(__isEditMode == false && __pLogPresentor->GetAllCallLogCount() > 0)
1256 if(__pOptionMenu != null)
1258 delete __pOptionMenu;
1259 __pOptionMenu = null;
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();
1272 DialTabLogs::OnKeyPressed(Control& source, const KeyEventInfo& keyEventInfo)
1274 AppLogDebug("Enter");
1275 if(keyEventInfo.GetKeyCode() == KEY_BACK)
1277 if(__pGroupContextDeletePopup != null && __pGroupContextDeletePopup->GetShowState() == true)
1279 __pGroupContextDeletePopup->SetShowState(false);
1281 else if(__pDeletePopup != null && __pDeletePopup->GetShowState() == true)