Applied latest source code
[apps/native/preloaded/Settings.git] / src / StHomeAndLockScreenForm.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                StHomeAndLockScreenForm.cpp
19  * @brief               This is the implementation file for HomeAndLockScreenForm class.
20  */
21
22 #include "StHomeAndLockScreenForm.h"
23 #include "StResourceManager.h"
24 #include "StSettingScenesList.h"
25 #include "StTypes.h"
26
27 using namespace Tizen::App;
28 using namespace Tizen::App::Package;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Graphics;
32 using namespace Tizen::Io;
33 using namespace Tizen::Media;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
38
39 static const wchar_t* APPCONTROL_PROVIDER_ID_GALLERY = L"tizen.gallery";
40 static const wchar_t* APPCONTROL_OPERATION_ID_GALLERY = L"http://tizen.org/appcontrol/operation/pick";
41
42 static const wchar_t* APPCONTROL_PROVIDER_ID_IMAGE_VIEWER = L"tizen.imageviewer";
43 static const wchar_t* APPCONTROL_OPERATION_ID_IMAGE_VIEWER = L"http://tizen.org/appcontrol/operation/image/crop";
44
45 static const wchar_t* APPCONTROL_SELECT_KEY_GALLERY = L"http://tizen.org/appcontrol/data/selection_mode";
46 static const wchar_t* APPCONTROL_SELECT_VALUE_GALLERY = L"single";
47
48 static const wchar_t* APPCONTROL_SELECT_KEY_IMAGE = L"http://tizen.org/appcontrol/data/image/crop_mode";
49 static const wchar_t* APPCONTROL_SELECT_VALUE_IMAGE = L"fit_to_screen";
50
51 static const wchar_t* APPCONTROL_DATA_SELECT_KEY_GALLERY = L"http://tizen.org/appcontrol/data/selected";
52
53 static const int ID_INDEX_HOME_SCREEN_WALLPAPER = 0;
54 static const int ID_INDEX_LOCK_SCREEN_WALLPAPER = 1;
55
56 static const int ID_GROUP_SCREEN_TYPE = 0;
57
58 static const int ID_GROUP_SCREEN_WALLPAPER = 1;
59
60 static const int ID_GROUP_COUNT = 2;
61 static const int ID_GROUP_MAX_ITEM_COUNT = 1;
62
63 HomeAndLockScreenForm::HomeAndLockScreenForm(void)
64         : __isRunningAppControl(false)
65         , __pLabel(null)
66 {
67 }
68
69 HomeAndLockScreenForm::~HomeAndLockScreenForm(void)
70 {
71 }
72
73 void
74 HomeAndLockScreenForm::CreateFooter(void)
75 {
76         Footer* pFooter = GetFooter();
77         AppAssert(pFooter);
78
79         pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
80         pFooter->AddActionEventListener(*this);
81
82         SetFormBackEventListener(this);
83 }
84
85 result
86 HomeAndLockScreenForm::OnInitializing(void)
87 {
88         return E_SUCCESS;
89 }
90
91 result
92 HomeAndLockScreenForm::OnTerminating(void)
93 {
94         if (__pTableView)
95         {
96                 __pTableView = null;
97                 SetFormBackEventListener(null);
98         }
99
100         return E_SUCCESS;
101 }
102
103 void
104 HomeAndLockScreenForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
105 {
106         if (pArgs != null)
107         {
108                 SetWallpaperIndex(*static_cast<String*>(pArgs->GetAt(0)));
109                 delete pArgs;
110                 AppLogDebug("Screen Mode[%d] ( home::0 / Lock::1 )", GetWallpaperIndex());
111
112                 CreateHeader(GetTitleText());
113                 CreateTableView();
114                 AppLogDebug("ENTER");
115
116                 __pTableView->UpdateTableView();
117         }
118         else if (previousSceneId.Equals(IDSCN_SCREEN_TYPE, false))
119         {
120                 __pTableView->RefreshItem(0,0,TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
121         }
122         else
123         {
124                 AppLogDebug("pArgs Null");
125         }
126 }
127
128 void
129 HomeAndLockScreenForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
130 {
131 }
132
133 void
134 HomeAndLockScreenForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
135 {
136         if (__isRunningAppControl)
137         {
138                 AppLogDebug("busy status");
139                 return;
140         }
141
142         SceneManager* pSceneManager = SceneManager::GetInstance();
143         AppAssert(pSceneManager);
144
145         pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
146 }
147
148 int
149 HomeAndLockScreenForm::GetGroupCount(void)
150 {
151         AppLogDebug("ENTER");
152         return ID_GROUP_COUNT;
153 }
154
155 int
156 HomeAndLockScreenForm::GetItemCount(int groupIndex)
157 {
158         int itemCount = ID_GROUP_MAX_ITEM_COUNT;
159
160         AppLogDebug("GetItemCount %d", itemCount);
161
162         return itemCount;
163 }
164
165 TableViewGroupItem*
166 HomeAndLockScreenForm::CreateGroupItem(int groupIndex, int itemWidth)
167 {
168         AppLogDebug("ENTER");
169
170         int itemHeight = H_GROUP_INDEX_DEFAULT;;
171         int yItemOffset = 0;
172         Rectangle itemMainRectangle;
173         String groupText;
174         Label* pLabel = null;
175
176         groupText = GetGroupText(groupIndex);
177
178         itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
179         itemMainRectangle.y = yItemOffset;
180         itemMainRectangle.width = itemWidth;
181         itemMainRectangle.height = itemHeight;
182
183         TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
184
185         RelativeLayout relativeLayout;
186         relativeLayout.Construct();
187
188         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
189         pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
190
191         pLabel = new (std::nothrow) Label();
192         pLabel->Construct(itemMainRectangle, groupText);
193         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
194         pLabel->SetTextVerticalAlignment(ALIGNMENT_BOTTOM);
195         pLabel->SetTextConfig(FONT_SIZE_GROUP_TITLE_TEXT, LABEL_TEXT_STYLE_BOLD);
196         pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
197
198         pItem->AddControl(pLabel);
199         relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
200         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
201         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
202         pItem->SetEnabled(false);
203
204         return pItem;
205 }
206
207 TableViewItem*
208 HomeAndLockScreenForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
209 {
210         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
211
212         Rectangle itemMainRectangle;
213         Rectangle itemSubRectangle;
214         TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
215         String itemMainText;
216         String itemSubText;
217         String fontReturnValue;
218         Label* pLabel = null;
219         int itemHeight = 0;
220         int fontSize = GetFontSize();
221
222         itemMainText = GetGroupItemText(groupIndex);
223
224         ItemTypeOneLine(itemMainRectangle);
225         itemHeight = itemMainRectangle.height;
226
227         if (groupIndex == ID_GROUP_SCREEN_TYPE)
228         {
229                 itemSubText = GetGroupItemSelectedText();
230                 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
231                 itemHeight = itemMainRectangle.height + itemSubRectangle.height;
232         }
233
234         TableViewItem* pItem = new (std::nothrow) TableViewItem();
235
236         RelativeLayout relativeLayout;
237         relativeLayout.Construct();
238
239         pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
240         pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
241
242         pLabel = new (std::nothrow) Label();
243         pLabel->Construct(itemMainRectangle, itemMainText);
244         pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
245         pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
246         pLabel->SetTextColor(COLOR_MAIN_TEXT);
247
248         if (groupIndex == ID_GROUP_SCREEN_TYPE)
249         {
250                 pLabel->AddTouchEventListener(*this);
251                 pItem->AddKeyEventListener(*this);
252                 pItem->AddFocusEventListener(*this);
253         }
254
255         pItem->AddControl(pLabel);
256
257         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
258         relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
259
260         if (groupIndex == ID_GROUP_SCREEN_TYPE)
261         {
262                 __pLabel = new (std::nothrow) Label();
263                 __pLabel->Construct(itemSubRectangle, itemSubText);
264                 __pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
265                 __pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
266                 __pLabel->SetTextColor(COLOR_SUB_TEXT);
267                 __pLabel->AddTouchEventListener(*this);
268
269                 pItem->AddControl(__pLabel);
270
271                 relativeLayout.SetRelation(*__pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
272                 relativeLayout.SetRelation(*__pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
273         }
274         return pItem;
275 }
276
277 bool
278 HomeAndLockScreenForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
279 {
280         AppLogDebug("ENTER");
281
282         delete pItem;
283         pItem = null;
284
285         return true;
286 }
287
288 bool
289 HomeAndLockScreenForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
290 {
291         AppLogDebug("ENTER");
292
293         delete pItem;
294         pItem = null;
295
296         return true;
297 }
298
299 void
300 HomeAndLockScreenForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
301 {
302         AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
303
304         if (__isRunningAppControl)
305         {
306                 AppLogDebug("busy status");
307                 return;
308         }
309
310         SceneManager* pSceneManager = SceneManager::GetInstance();
311         AppAssert(pSceneManager);
312
313         ArrayList* pArgs = new (std::nothrow) ArrayList(SingleObjectDeleter);
314         if (pArgs == null)
315         {
316                 AppLogDebug("pArgs is null");
317         }
318
319         result r = pArgs->Construct();
320         if (IsFailed(r))
321         {
322                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
323         }
324         pArgs->Add(new (std::nothrow) String(Integer::ToString(GetWallpaperIndex())));
325
326         if (groupIndex == ID_GROUP_SCREEN_WALLPAPER)
327         {
328                 // to launch gallery app control
329                 LaunchGalleryAppControl();
330         }
331         else
332         {
333                 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_SCREEN_TYPE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), pArgs);
334         }
335 }
336
337 int
338 HomeAndLockScreenForm::GetDefaultGroupItemHeight(void)
339 {
340         return H_GROUP_INDEX_NO_TITLE_DEFAULT;
341 }
342
343 int
344 HomeAndLockScreenForm::GetDefaultItemHeight(void)
345 {
346         return H_GROUP_ITEM_DEFAULT;
347 }
348
349 void
350 HomeAndLockScreenForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
351 {
352 }
353
354 void
355 HomeAndLockScreenForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
356 {
357         switch (groupIndex)
358         {
359         case ID_GROUP_SCREEN_TYPE:
360                 {
361                         String itemSubText;
362                         Label* pSecondLabel = static_cast<Label*>(pItem->GetControl(1));
363                         itemSubText = GetGroupItemSelectedText();
364                         pSecondLabel->SetText(itemSubText);
365                         pSecondLabel->Invalidate(false);
366                 }
367                 break;
368
369         default:
370                 break;
371         }
372         Invalidate(true);
373 }
374
375 void
376 HomeAndLockScreenForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
377 {
378 }
379
380 void
381 HomeAndLockScreenForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
382 {
383 }
384
385 void
386 HomeAndLockScreenForm::SetWallpaperIndex(Tizen::Base::String& whitchOne)
387 {
388         Integer::Parse(whitchOne, __wallpaperIndex);
389 }
390
391 int
392 HomeAndLockScreenForm::GetWallpaperIndex(void)
393 {
394         return __wallpaperIndex;
395 }
396
397 Tizen::Base::String
398 HomeAndLockScreenForm::GetTitleText(void)
399 {
400         String headerText;
401
402         switch (GetWallpaperIndex())
403         {
404         case ID_INDEX_HOME_SCREEN_WALLPAPER:
405                 {
406                         headerText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
407                 }
408                 break;
409
410         case ID_INDEX_LOCK_SCREEN_WALLPAPER:
411                 {
412                         headerText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
413                 }
414                 break;
415         }
416
417         return headerText;
418 }
419
420 Tizen::Base::String
421 HomeAndLockScreenForm::GetGroupText(int groupIndex)
422 {
423         String groupText;
424
425         switch (groupIndex)
426         {
427         case ID_GROUP_SCREEN_TYPE:
428                 {
429                         if (GetWallpaperIndex())
430                         {
431                                 groupText = ResourceManager::GetString(L"IDS_ST_BODY_LOCK_SCREEN");
432                         }
433                         else
434                         {
435                                 groupText = ResourceManager::GetString(L"IDS_ST_HEADER_HOME_SCREEN");
436                         }
437                 }
438                 break;
439
440         case ID_GROUP_SCREEN_WALLPAPER:
441                 {
442                         groupText = ResourceManager::GetString(L"IDS_ST_BODY_MAINDISPLAY_WALLPAPER");
443                 }
444                 break;
445         }
446
447         return groupText;
448 }
449
450 Tizen::Base::String
451 HomeAndLockScreenForm::GetGroupItemText(int groupIndex)
452 {
453         String itemMainText;
454
455         switch (groupIndex)
456         {
457         case ID_GROUP_SCREEN_TYPE:
458                 {
459                         if (GetWallpaperIndex())
460                         {
461                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_SCREEN_LOCK_TYPE");
462                         }
463                         else
464                         {
465                                 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_HOME_SCREEN_TYPE");
466                         }
467                 }
468                 break;
469
470         case ID_GROUP_SCREEN_WALLPAPER:
471                 {
472                         if (GetWallpaperIndex())
473                         {
474                                 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_LOCK_SCREEN_WALLPAPER_M_NOUN");
475                         }
476                         else
477                         {
478                                 itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_HOME_SCREEN_WALLPAPER");
479                         }
480                 }
481                 break;
482         }
483
484         return itemMainText;
485 }
486
487 Tizen::Base::String
488 HomeAndLockScreenForm::GetGroupItemSelectedText(void)
489 {
490         String itemMainText;
491         String screenType;
492         String applicationId;
493
494         if (GetWallpaperIndex() == 0)
495         {
496                 screenType = SETTING_INFO_KEY_SCREEN_TYPE_HOME;
497         }
498         else
499         {
500                 screenType = SETTING_INFO_KEY_SCREEN_TYPE_LOCK;
501         }
502
503         result r = SettingInfo::GetValue(screenType, applicationId);
504         AppLogDebug("GetValue(%ls, ..) result=[%s]", screenType.GetPointer(), GetErrorMessage(r));
505
506         if (!IsFailed(r))
507         {
508                 AppLog("AppId=[%ls]", applicationId.GetPointer());
509
510                 if (applicationId.Equals(L"org.tizen.menu-screen", false))
511                 {
512                         // Preloaded home
513                         itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_DEFAULT_HOME_SCREEN");
514                 }
515                 else if (applicationId.Equals(L"org.tizen.lockscreen", false))
516                 {
517                         // Preloaded lock
518                         itemMainText = ResourceManager::GetString(L"IDS_ST_MBODY_SWIPE");
519                 }
520                 else
521                 {
522                         // Downloaded home/lock
523                         PackageManager* pMgr = PackageManager::GetInstance();
524                         PackageAppInfo* pPackageAppInfo = pMgr->GetPackageAppInfoN(applicationId);
525                         if(pPackageAppInfo)
526                         {
527                                 itemMainText = pPackageAppInfo->GetAppDisplayName();
528                                 delete pPackageAppInfo;
529                         }
530                 }
531         }
532
533         return itemMainText;
534 }
535
536 void
537 HomeAndLockScreenForm::OnAppControlCompleteResponseReceived(const Tizen::App::AppId& appId, const Tizen::Base::String& operationId, Tizen::App::AppCtrlResult appControlResult, const Tizen::Base::Collection::IMap* pExtraData)
538 {
539         __isRunningAppControl = false;
540
541         AppLogDebug("appControlResult = %d", appControlResult);
542
543         if (appId.Equals(String(APPCONTROL_PROVIDER_ID_GALLERY)) &&
544                 operationId.Equals(String(APPCONTROL_OPERATION_ID_GALLERY)))
545         {
546                 if (appControlResult  == APP_CTRL_RESULT_SUCCEEDED)
547                 {
548                         AppLog("Image crop succeeded.");
549                         // use cropped image.
550                         if (pExtraData)
551                         {
552                                 IMapEnumerator* pEnum = pExtraData->GetMapEnumeratorN();
553                                 if (pEnum->MoveNext() == E_SUCCESS)
554                                 {
555                                         String* pKey = dynamic_cast<String*>(pEnum->GetKey());
556                                         if (pKey && pKey->Equals(String(APPCONTROL_DATA_SELECT_KEY_GALLERY)))
557                                         {
558                                                 // The value is IList
559                                                 IList* pValueList = dynamic_cast<IList*>(pEnum->GetValue());
560                                                 if (pValueList)
561                                                 {
562                                                         String* pSrcPath = dynamic_cast<String*>(pValueList->GetAt(0));
563
564                                                         if (pSrcPath != null && pSrcPath->GetLength() > 0)
565                                                         {
566                                                                 int width = 0;
567                                                                 int height = 0;
568                                                                 ImageFormat imageFormat;
569                                                                 result r = ImageBuffer::GetImageInfo(*pSrcPath, imageFormat, width, height);
570                                                                 if (r != E_SUCCESS)
571                                                                 {
572                                                                         int modalResult = 0;
573                                                                         MessageBox unsupportedMessageBox;
574                                                                         unsupportedMessageBox.Construct(L"", ResourceManager::GetString(L"IDS_RSSR_BODY_INVALID_FORMAT"), MSGBOX_STYLE_NONE, 3000);
575                                                                         unsupportedMessageBox.ShowAndWait(modalResult);
576                                                                         return;
577                                                                  }
578                                                         String dstPath = Application::GetInstance()->GetAppSharedPath() + PATH_DATA_DIRECTORY;
579                                                         ImageBuffer imgBuf;
580                                                         r = imgBuf.Construct(*pSrcPath);
581
582                                                         if (IsFailed(r))
583                                                         {
584                                                                 AppLogDebug("Construct fail [%s]", GetErrorMessage(r));
585                                                         }
586
587                                                         if (__wallpaperIndex == 0)
588                                                         {
589                                                                 dstPath.Append(L"home.jpg");
590                                                                 r = imgBuf.EncodeToFile(dstPath, IMG_FORMAT_JPG, true, 100);
591                                                                 if (r != E_SUCCESS)
592                                                                 {
593                                                                         AppLogDebug("Wallpaper EncodeToFile Failed [%s]", GetErrorMessage(r));
594                                                                         ShowMessageBox(L"", L"System error occured.");
595                                                                         return;
596                                                                 }
597                                                                 AppLogDebug("FilePath = %S", dstPath.GetPointer());
598
599                                                                 r = SettingInfo::SetValue(RUNTIME_INFO_KEY_WALLPAPER_SCREEN, dstPath);
600                                                                 if (r != E_SUCCESS)
601                                                                 {
602                                                                         AppLogDebug("Wallpaper Screen SetValue is Fail [%s]", GetErrorMessage(r));
603                                                                 }
604                                                         }
605                                                         else if (__wallpaperIndex == 1)
606                                                         {
607                                                                 dstPath.Append(L"lock.jpg");
608                                                                 imgBuf.EncodeToFile(dstPath, IMG_FORMAT_JPG, true, 100);
609                                                                 if (r != E_SUCCESS)
610                                                                 {
611                                                                         AppLogDebug("Wallpaper EncodeToFile Failed [%s]", GetErrorMessage(r));
612                                                                         ShowMessageBox(L"", L"System error occured.");
613                                                                         return;
614                                                                 }
615                                                                 AppLogDebug("FilePath = %S", dstPath.GetPointer());
616
617                                                                 r = SettingInfo::SetValue(RUNTIME_INFO_KEY_WALLPAPER_SCREEN_LOCK, dstPath);
618                                                                 if (r != E_SUCCESS)
619                                                                 {
620                                                                         AppLogDebug("Wallpaper Lock Screen SetValue is Fail [%s]", GetErrorMessage(r));
621                                                                 }
622                                                                 }
623                                                         }
624                                                 }
625                                         }
626                                 }
627                                 delete pEnum;
628                         }
629                 }
630                 else if (appControlResult == APP_CTRL_RESULT_FAILED)
631                 {
632                         AppLog("Image crop failed.");
633                         return;
634                 }
635                 else if (appControlResult == APP_CTRL_RESULT_CANCELED)
636                 {
637                         AppLog("Image crop was canceled.");
638                         return;
639                 }
640                 else if (appControlResult == APP_CTRL_RESULT_TERMINATED)
641                 {
642                         AppLog("Image crop was terminated.");
643                         return;
644                 }
645                 else if (appControlResult == APP_CTRL_RESULT_ABORTED)
646                 {
647                         AppLog("Image crop was aborted.");
648                         return;
649                 }
650         }
651
652 }
653
654 void
655 HomeAndLockScreenForm::LaunchGalleryAppControl()
656 {
657         String mime = L"*/*";
658         HashMap extraData;
659         extraData.Construct();
660         String selectKey = APPCONTROL_SELECT_KEY_GALLERY;
661         String selectVal = APPCONTROL_SELECT_VALUE_GALLERY;
662         String selectKeyImage = APPCONTROL_SELECT_KEY_IMAGE;
663         String selectValImage = APPCONTROL_SELECT_VALUE_IMAGE;
664
665         extraData.Add(&selectKey, &selectVal);
666         extraData.Add(&selectKeyImage, &selectValImage);
667
668         AppControl* pAc = AppManager::FindAppControlN(APPCONTROL_PROVIDER_ID_GALLERY,
669                         APPCONTROL_OPERATION_ID_GALLERY);
670         if (pAc)
671         {
672                 if (pAc->Start(null, &mime, &extraData, this) == E_SUCCESS)
673                 {
674                         __isRunningAppControl = true;
675                 }
676
677                 delete pAc;
678         }
679 }
680
681 void
682 HomeAndLockScreenForm::OnTouchMoved(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
683 {
684         __pLabel->SetTextColor(COLOR_SUB_TEXT);
685         __pLabel->Invalidate(false);
686 }
687
688 void
689 HomeAndLockScreenForm::OnTouchPressed(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
690 {
691         __pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
692         __pLabel->Invalidate(false);
693 }
694
695 void
696 HomeAndLockScreenForm::OnTouchReleased(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
697 {
698         __pLabel->SetTextColor(COLOR_SUB_TEXT);
699         __pLabel->Invalidate(false);
700 }
701
702 void
703 HomeAndLockScreenForm::OnTouchCanceled(const Tizen::Ui::Control& source, const Tizen::Graphics::Point& currentPosition, const Tizen::Ui::TouchEventInfo& touchInfo)
704 {
705         __pLabel->SetTextColor(COLOR_SUB_TEXT);
706         __pLabel->Invalidate(false);
707 }
708
709 void
710 HomeAndLockScreenForm::OnKeyPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
711 {
712         AppLog("Enter");
713         if(keyCode == KEY_ENTER)
714         {
715                 AppLog("Enter");
716                 __pLabel->SetTextColor(Color::GetColor(COLOR_ID_WHITE));
717                 __pLabel->Invalidate(false);
718         }
719 }
720
721 void
722 HomeAndLockScreenForm::OnKeyReleased(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
723 {
724         AppLog("Enter");
725         if(keyCode == KEY_ENTER)
726         {
727                 AppLog("Enter");
728                 __pLabel->SetTextColor(COLOR_SUB_TEXT);
729                 __pLabel->Invalidate(false);
730         }
731 }
732
733 void
734 HomeAndLockScreenForm::OnKeyLongPressed(const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode)
735 {
736 }
737
738 void
739 HomeAndLockScreenForm::OnFocusLost(const Tizen::Ui::Control& source)
740 {
741         AppLog("Enter");
742         __pLabel->SetTextColor(COLOR_SUB_TEXT);
743         __pLabel->Invalidate(false);
744 }
745
746 void
747 HomeAndLockScreenForm::OnFocusGained(const Tizen::Ui::Control& source)
748 {
749         AppLog("Enter");
750 }