Fixed jira issue and fixed prevent issue
[apps/osp/MusicPlayer.git] / src / MpCommonUtil.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Flora License, Version 1.0 (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                MpCommonUtil.cpp
19  * @brief               This is the implementation file for CommonUtil class.
20  */
21
22 #include <unique_ptr.h>
23 #include "MpCommonUtil.h"
24
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Utility;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::Ui;
33 using namespace Tizen::Ui::Controls;
34 using namespace Tizen::Ui::Scenes;
35
36 static const int H_CREATE_TABLE_VIEW_ITEM = 70;
37 static const int Y_CREATE_TABLE_VIEW_ITEM = 29;
38 static const int W_CREATE_TABLE_VIEW_ITEM_COUNT_LABEL_ITEM = 170;
39 static const int DEPTH = 3;
40
41 const wchar_t* SECTION_MUSIC_SETTING = L"MUSIC_SETTING";
42 const wchar_t* INITIAL_TAB = L"INITIAL_TAB";      // 0 - 7
43 const wchar_t* SONGS_TAB = L"SONGS_TAB";        // 0 - 1 (UNCHECKED, CHECKED)
44 const wchar_t* ALBUMS_TAB = L"ALBUMS_TAB";       // 0 - 1 (UNCHECKED, CHECKED)
45 const wchar_t* ARTISTS_TAB = L"ARTISTS_TAB";      // 0 - 1 (UNCHECKED, CHECKED)
46 const wchar_t* GENRES_TAB = L"GENRES_TAB";       // 0 - 1 (UNCHECKED, CHECKED)
47 const wchar_t* COMPOSERS_TAB = L"COMPOSERS_TAB";    // 0 - 1 (UNCHECKED, CHECKED)
48 const wchar_t* YEARS_TAB = L"YEARS_TAB";        // 0 - 1 (UNCHECKED, CHECKED)
49 const wchar_t* FOLDERS_TAB = L"FOLDERS_TAB";      // 0 - 1 (UNCHECKED, CHECKED)
50 const wchar_t* PLAYERLISTS_TAB = L"PLAYERLISTS_TAB";  // 0 - 1 (UNCHECKED, CHECKED)
51 const wchar_t* AUTO_OFF_LEVEL = L"AUTO_OFF_LEVEL";   // 0 - 5 (OFF, 15 MIN, 30 MIN, 1 HOUR, 1 HOUR 30 MIN, 2 HOURS)
52 const wchar_t* MOST_PLAYED = L"MOST_PLAYED";            // 0 - 1 (UNCHECKED, CHECKED)
53 const wchar_t* RECENTLY_PLAYED = L"RECENTLY_PLAYED";    // 0 - 1 (UNCHECKED, CHECKED)
54 const wchar_t* RECENTLY_ADD = L"RECENTLY_ADD";          // 0 - 1 (UNCHECKED, CHECKED)
55 const wchar_t* REPEAT_MODE = L"REPEAT_MODE";      // 0 - 2 (OFF, ONE, ALL)
56 const wchar_t* SHUFFLE_MODE = L"SHUFFLE_MODE";     // 0 - 1 (OFF, ON)
57 const wchar_t* VOLUME_LEVEL = L"VOLUME_LEVEL";     // 0 - 15
58
59 static const wchar_t* IDS_ORIGINAL_QUOTATION = L"'";
60 static const wchar_t* IDS_REPLACE_QUOTATION = L"\\'";
61 static const wchar_t* STRING_QUERY_PREFIX = L" ='";
62 static const wchar_t* STRING_QUERY_SUFFIX = L"'";
63
64 static bool __addToPlaylistState = false;
65 static Tizen::Base::String __AddToPlaylistName = null;
66
67 static const int Y_GAP_CONTENT_PIKER_ITEM = 16;
68 static const int W_SONG_TITLE_CONTENT_PIKER_ITEM = 440;
69 static const int H_SONG_TITLE_CONTENT_PIKER_ITEM = 88;
70 static const int W_SONG_TIME_CONTENT_PIKER_ITEM = 155;
71
72 Tizen::Graphics::Bitmap*
73 CommonUtil::GetContentAlbumArtN(Tizen::Base::String& path)
74 {
75         AppLogDebug("ENTER");
76         Tizen::Graphics::Bitmap* pBitmap = null;
77
78         AppLogDebug("path(%ls)", path.GetPointer());
79         Tizen::Content::AudioMetadata* pAudioMeta = Tizen::Content::ContentManagerUtil::GetAudioMetaN(path);
80         if (pAudioMeta == null)
81         {
82                 AppLogDebug("EXIT");
83                 return null;
84         }
85
86         pBitmap = pAudioMeta->GetAlbumArtN();
87         delete pAudioMeta;
88
89         AppLogDebug("EXIT");
90         return pBitmap;
91 }
92
93 Tizen::Content::AudioContentInfo*
94 CommonUtil::GetAudioContentInfoN(const Tizen::Base::String& filePath)
95 {
96         AppLogDebug("ENTER");
97         ContentId contentId = GetContentId(filePath);
98
99         if (IsFailed(GetLastResult()))
100         {
101                 AppLogDebug("filePath(%ls) failed", filePath.GetPointer());
102                 SetLastResult(E_FAILURE);
103                 return null;
104         }
105
106         ContentInfo* pContentInfo = GetContentInfoN(contentId);
107         if (pContentInfo == null || pContentInfo->GetContentType() != CONTENT_TYPE_AUDIO)
108         {
109                 AppLogDebug("GetContentInfoN(%ls) failed", contentId.ToString().GetPointer());
110                 delete pContentInfo;
111                 SetLastResult(E_FAILURE);
112                 return null;
113         }
114
115         AppLogDebug("EXIT");
116         return static_cast<AudioContentInfo*>(pContentInfo);
117 }
118
119 Tizen::Base::Collection::IList*
120 CommonUtil::ContentSearchResultListN(const Tizen::Base::String& contentFileName,
121                                                                          const Tizen::Base::String& ColumnName,
122                                                                          const Tizen::Base::String& sortColumn,
123                                                                          Tizen::Base::SortOrder sortOrder)
124 {
125         AppLogDebug("ENTER");
126         String WhereExpr = null;
127         WhereExpr = CommonUtil::SpecialReplaceChange(contentFileName);
128         WhereExpr = CommonUtil::MakeQuery(ColumnName, WhereExpr);
129
130         Tizen::Base::Collection::IList* pSearchList = CommonUtil::SearchContentList(WhereExpr, sortColumn);
131         if (pSearchList == null)
132         {
133                 SetLastResult(E_FAILURE);
134                 AppLogDebug("CommonUtil::SearchContentList failed");
135                 return null;
136         }
137         AppLogDebug("EXIT");
138         return pSearchList;
139 }
140
141 Tizen::Base::String
142 CommonUtil::FilePathToContentFileName(const Tizen::Base::String& filePath)
143 {
144         AppLogDebug("ENTER");
145         String tempWhereClause = filePath;
146         int indexOf = -1;
147         String contentFileName = null;
148
149         tempWhereClause.LastIndexOf(L"/", tempWhereClause.GetLength() - 1,  indexOf);
150         tempWhereClause.SubString(indexOf + 1, contentFileName);
151         
152         AppLogDebug("EXIT");
153         return contentFileName;
154 }
155
156 Tizen::Content::ContentId
157 CommonUtil::GetContentId(const Tizen::Base::String& filePath)
158 {
159         AppLogDebug("ENTER");
160         String contentFileName = FilePathToContentFileName(filePath);
161         IList* pContentSearchResultList = ContentSearchResultListN(contentFileName, STRING_SORT_FILE_NAME, STRING_SORT_TITLE);
162         if (pContentSearchResultList == null || pContentSearchResultList->GetCount() == 0)
163         {
164                 SetLastResult(E_FAILURE);
165                 delete pContentSearchResultList;
166                 AppLogDebug("CommonUtil::ContentSearchResultListN(%ls) failed", filePath.GetPointer());
167                 return ContentId();
168         }
169
170         ContentSearchResult* pResult = static_cast<ContentSearchResult*>(pContentSearchResultList->GetAt(INIT_VALUE));
171         if (pResult == null)
172         {
173                 pContentSearchResultList->RemoveAll(true);
174                 delete pContentSearchResultList;
175                 SetLastResult(E_FAILURE);
176
177                 AppLogDebug("pSearchList->GetAt(0) failed");
178                 return ContentId();
179         }
180
181         ContentId contentId;
182         if (pResult->GetContentType() == CONTENT_TYPE_AUDIO)
183         {
184                 ContentInfo* pContentInfo = pResult->GetContentInfo();
185                 contentId = pContentInfo->GetContentId();
186         }
187         else
188         {
189                 SetLastResult(E_FAILURE);
190         }
191
192         pContentSearchResultList->RemoveAll(true);
193         delete pContentSearchResultList;
194
195         AppLogDebug("EXIT");
196         return contentId;
197 }
198
199 Tizen::Content::ContentInfo*
200 CommonUtil::GetContentInfoN(const Tizen::Content::ContentId& contentId)
201 {
202         AppLogDebug("ENTER");
203         ContentManager contentManager;
204         result r = contentManager.Construct();
205         if (IsFailed(r))
206         {
207                 AppLogDebug("contentManager.Construct() failed(%s)", GetErrorMessage(r));
208                 return null;
209         }
210
211         ContentInfo* pContentInfo = contentManager.GetContentInfoN(contentId);
212         AppLogDebug("EXIT");
213         return pContentInfo;
214 }
215
216 result
217 CommonUtil::StringToContentId(const Tizen::Base::String& contentIdString, Tizen::Content::ContentId& outContentId)
218 {
219         AppLogDebug("ENTER");
220         ContentId pcontentId;
221         UuId uuId;
222         result r = pcontentId.Parse(contentIdString, uuId);
223         if (IsFailed(r))
224         {
225                 AppLogDebug("pcontentId.Parse(%s, outContentId) failed", contentIdString.GetPointer());
226                 return r;
227         }
228
229         outContentId = uuId;
230         AppLogDebug("EXIT");
231         return E_SUCCESS;
232 }
233
234 Tizen::Base::String
235 CommonUtil::GetFormatDate(long dateValue)
236 {
237         AppLogDebug("ENTER");
238         String fTime;
239         if (dateValue < 0)
240         {
241 //              fTime.Format(20, L"%02d:%02d:%02d", 0, 0, 0);
242                 fTime.Format(20, L"%02d:%02d", 0, 0);
243         }
244         else
245         {
246                 DateTime dateTime;
247                 dateTime.AddSeconds(dateValue / 1000);
248 //              fTime.Format(20, L"%02d:%02d:%02d", dateTime.GetHour(), dateTime.GetMinute(), dateTime.GetSecond());
249                 fTime.Format(20, L"%02d:%02d",dateTime.GetMinute(), dateTime.GetSecond());
250         }
251         AppLogDebug("EXIT");
252         return fTime;
253 }
254
255 Tizen::Base::String
256 CommonUtil::SpecialReplaceChange(const Tizen::Base::String& text)
257 {
258         AppLogDebug("ENTER");
259         String retStr = text;
260         retStr.Replace(IDS_ORIGINAL_QUOTATION, IDS_REPLACE_QUOTATION);
261         AppLogDebug("EXIT");
262         return retStr;
263 }
264
265 Tizen::Base::Collection::IList*
266 CommonUtil::SearchContentList(const Tizen::Base::String& whereExpr,
267                                         const Tizen::Base::String& sortColumn,
268                                         Tizen::Base::SortOrder sortOrder)
269 {
270         AppLogDebug("ENTER");
271         AppLogDebug("%ls, %ls", whereExpr.GetPointer(), sortColumn.GetPointer());
272         int totalPage = 0;
273         int totalCount = 0;
274
275         ContentSearch search;
276         search.Construct(CONTENT_TYPE_AUDIO);
277         IList* pSearchList = search.SearchN(SEARCH_PAGE_NO, SEARCH_COUNT_PER_PAGE, totalPage, totalCount, whereExpr, sortColumn, sortOrder);
278         if (pSearchList == null)
279         {
280                 AppLogDebug("pSearchList is null");
281                 return null;
282         }
283
284         AppLogDebug("%d", pSearchList->GetCount());
285         AppLogDebug("EXIT");
286         return pSearchList;
287 }
288
289 Tizen::Base::Collection::IList*
290 CommonUtil::SearchContentList(const Tizen::Base::String& columnName)
291 {
292         AppLogDebug("ENTER");
293         int totalPage = 0;
294         int totalCount = 0;
295
296         ContentSearch search;
297         search.Construct(CONTENT_TYPE_AUDIO);
298
299         IList* pSearchList = search.GetValueListN(SEARCH_PAGE_NO, SEARCH_COUNT_PER_PAGE, totalPage, totalCount, columnName, SORT_ORDER_ASCENDING);
300         if (pSearchList == null)
301         {
302                 AppLogDebug("pSearchList is null");
303                 return null;
304         }
305
306         AppLogDebug("EXIT");
307         return pSearchList;
308 }
309
310 Tizen::Base::String
311 CommonUtil::MakeQuery(const Tizen::Base::String& ColumnName,
312                                 const Tizen::Base::String& SerachName)
313 {
314         AppLogDebug("ENTER");
315         String MakeQueryName = null;
316         result r = E_SUCCESS;
317
318         r = MakeQueryName.Append(ColumnName);
319         TryCatch(r == E_SUCCESS, , "String::MakeQuery() fail[%s]", GetErrorMessage(r));
320
321         r = MakeQueryName.Append(STRING_QUERY_PREFIX);
322         TryCatch(r == E_SUCCESS, , "String::MakeQuery() fail[%s]", GetErrorMessage(r));
323
324         r = MakeQueryName.Append(SerachName);
325         TryCatch(r == E_SUCCESS, , "String::MakeQuery() fail[%s]", GetErrorMessage(r));
326
327         r = MakeQueryName.Append(STRING_QUERY_SUFFIX);
328         TryCatch(r == E_SUCCESS, , "String::MakeQuery() fail[%s]", GetErrorMessage(r));
329
330         AppLogDebug("EXIT");
331         return MakeQueryName;
332
333 CATCH:
334         MakeQueryName.Clear();
335         return MakeQueryName;
336 }
337
338 int
339 CommonUtil::GetValue(const Tizen::Base::String& entryName)
340 {
341         AppLogDebug("ENTER");
342         result r = E_SUCCESS;
343         int value = 0;
344         AppRegistry* pAppRegistry = null;
345         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
346         TryCatch(pAppRegistry != null, , "Failed to Find AppRegistry!");
347         r = pAppRegistry->Get(entryName, value);
348         if (r == E_KEY_NOT_FOUND)
349         {
350                 AppLogDebug("registry initialize.");
351                 r = pAppRegistry->Add(MOST_PLAYED, 1);
352                 r = pAppRegistry->Add(RECENTLY_PLAYED, 1);
353                 r = pAppRegistry->Add(RECENTLY_ADD, 1);
354                 r = pAppRegistry->Add(AUTO_OFF_LEVEL, 0);
355                 r = pAppRegistry->Add(REPEAT_MODE, 2);
356                 r = pAppRegistry->Add(SHUFFLE_MODE, 0);
357                 r = pAppRegistry->Add(VOLUME_LEVEL, 5);
358                 r = pAppRegistry->Save();
359
360                 pAppRegistry->Get(entryName, value);
361         }
362         AppLogDebug("EXIT");
363         return value;
364
365 CATCH:
366         //AppLogDebug("CATCH : %s", GetErrorMessage(r));
367         return r;
368 }
369
370 result
371 CommonUtil::SetValue(const Tizen::Base::String& entryName, const int value)
372 {
373         AppLogDebug("ENTER");
374         result r = E_SUCCESS;
375         AppRegistry* pAppRegistry = null;
376         pAppRegistry = UiApp::App::GetInstance()->GetAppRegistry();
377         TryCatch(pAppRegistry != null, , "Failed to Find AppRegistry!");
378         r = pAppRegistry->Set(entryName, value);
379         if (r == E_KEY_NOT_FOUND)
380         {
381                 AppLogDebug("registry initialize.");
382                 r = pAppRegistry->Add(MOST_PLAYED, 1);
383                 r = pAppRegistry->Add(RECENTLY_PLAYED, 1);
384                 r = pAppRegistry->Add(RECENTLY_ADD, 1);
385                 r = pAppRegistry->Add(AUTO_OFF_LEVEL, 0);
386                 r = pAppRegistry->Add(REPEAT_MODE, 2);
387                 r = pAppRegistry->Add(SHUFFLE_MODE, 0);
388                 r = pAppRegistry->Add(VOLUME_LEVEL, 5);
389                 r = pAppRegistry->Set(entryName, value);
390                 r = pAppRegistry->Save();
391         }
392         else
393         {
394                 pAppRegistry->Save();
395         }
396         AppLogDebug("EXIT");
397         return r;
398
399 CATCH:
400         //AppLogDebug("CATCH : %s", GetErrorMessage(r));
401         return r;
402 }
403
404 void
405 CommonUtil::ShowNowPlayPanel(Tizen::Ui::Controls::TableView& tableView,
406                                                         const bool playStatus,
407                                                         Tizen::Graphics::Rectangle clientBounds)
408 {
409         AppLogDebug("ENTER");
410         if (playStatus == true)
411         {
412                 tableView.SetBounds(Rectangle(0, H_NOW_PLAY_BAR, clientBounds.width, clientBounds.height - H_NOW_PLAY_BAR));
413                 tableView.Invalidate(true);
414         }
415         else
416         {
417                 tableView.SetBounds(Rectangle(0, 0, clientBounds.width, clientBounds.height));
418                 tableView.Invalidate(true);
419         }
420         AppLogDebug("EXIT");
421 }
422
423 Tizen::Base::String
424 CommonUtil::GetContentInfo(const ContentInformation& contentInfoStruct,
425                                                         const Tizen::Base::String& SceneId)
426 {
427         AppLogDebug("ENTER");
428         String retString = null;
429
430         if (SceneId.Equals(IDSCN_ALBUM_LIST, true) || SceneId.Equals(IDSCN_SEARCH, true))
431         {
432                 retString = contentInfoStruct.AlbumName;
433         }
434         else if (SceneId.Equals(IDSCN_ARTIST_ALBUM_LIST, true))
435         {
436                 retString = contentInfoStruct.AlbumName;
437         }
438         else if (SceneId.Equals(IDSCN_GENRE_LIST, true))
439         {
440                 retString = contentInfoStruct.GenreName;
441         }
442         else if (SceneId.Equals(IDSCN_COMPOSER_LIST, true))
443         {
444                 retString = contentInfoStruct.ComposerName;
445         }
446         else if (SceneId.Equals(IDSCN_YEAR_LIST, true))
447         {
448                 retString = Integer::ToString(contentInfoStruct.ReleaseYear);;
449                 if (retString.Equals(L"0", true))
450                 {
451                         retString = STRING_UNKNOWN;
452                 }
453         }
454         else if (SceneId.Equals(IDSCN_FOLDER_LIST, true))
455         {
456                 retString = contentInfoStruct.ContentFilePath;
457         }
458         else if (SceneId.Equals(IDSCN_PLAYLIST_LIST, true))
459         {
460                 retString = contentInfoStruct.TitleName;
461         }
462         AppLogDebug("EXIT");
463         return retString;
464 }
465
466 Tizen::Base::String
467 CommonUtil::SetSongsString(const int temp)
468 {
469         AppLogDebug("ENTER");
470         String StrSongs = null;
471         String StrFormat = null;
472
473         StrSongs.Append(L"%d ");
474         StrSongs.Append(ResourceManager::GetString("IDS_MUSIC_HEADER_SONGS"));
475         StrFormat.Format(STRING_LENGTH, StrSongs.GetPointer(), temp);
476         AppLogDebug("EXIT");
477         return StrFormat;
478 }
479
480 void
481 CommonUtil::ShowCheckedCountLabel(Tizen::Ui::Controls::Label& checkCountLabel, int itemCount, Tizen::Ui::Controls::TableView& tableView, const Tizen::Ui::Controls::Form& form)
482 {
483         AppLogDebug("ENTER");
484         int width = form.GetClientAreaBounds().width;
485         int height = form.GetClientAreaBounds().height;
486         if (itemCount == INIT_VALUE)
487         {
488                 checkCountLabel.SetShowState(false);
489                 checkCountLabel.Invalidate(true);
490                 tableView.SetBounds(Rectangle(INIT_VALUE, H_SELECT_ALL_BUTTON, width, height - H_SELECT_ALL_BUTTON));
491                 AppLogDebug("EXIT");
492                 return;
493         }
494
495         String StrSelectStr = null;
496         String ResSelect = ResourceManager::GetString("IDS_COM_BODY_SELECTED");
497         ResSelect.Append(L"(%d)");
498
499         StrSelectStr.Format(STRING_LENGTH, ResSelect.GetPointer(), itemCount);
500
501         checkCountLabel.SetText(StrSelectStr);
502         checkCountLabel.SetShowState(true);
503         checkCountLabel.Invalidate(true);
504
505 //      tableView.SetBounds(Rectangle(INIT_VALUE, H_SELECT_ALL_BUTTON, width, height - H_SELECT_ALL_BUTTON - checkCountLabel.GetBounds().height));
506         tableView.Invalidate(true);
507         AppLogDebug("EXIT");
508 }
509
510 void
511 CommonUtil::ShowSelectAllCheckButton(Tizen::Ui::Controls::CheckButton& checkButton)
512 {
513         AppLogDebug("ENTER");
514         if (checkButton.IsEnabled() == true)
515         {
516                 checkButton.SetSelected(false);
517                 checkButton.Invalidate(true);
518         }
519         AppLogDebug("EXIT");
520 }
521
522 void
523 CommonUtil::SetAllCheckState(bool state,
524                                         Tizen::Ui::Controls::TableView& tableView,
525                                         int totalCount)
526 {
527         AppLogDebug("ENTER");
528
529         for (int iCount = INIT_VALUE; iCount < totalCount; iCount++)
530         {
531                 tableView.SetItemChecked(iCount, state);
532         }
533         tableView.Invalidate(true);
534         AppLogDebug("EXIT");
535 }
536
537 result
538 CommonUtil::SetFastScrollIndex(Tizen::Ui::Controls::TableView& tableview)
539 {
540         AppLogDebug("ENTER");
541         String retCountry = null;
542         Tizen::System::SettingInfo::GetValue("http://tizen.org/setting/locale.country", retCountry);
543
544         String indexText = null;
545         if (retCountry.CompareTo("eng_GB") == 0)
546         {
547                 indexText.Append(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
548         }
549         else if(retCountry.CompareTo("kor_KR") == 0)
550         {
551 //              indexText.Append(L"ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ");
552                 indexText.Append(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ#0");
553         }
554
555         indexText.Append(L"#");
556         indexText.Append(L"0");
557
558         tableview.SetFastScrollIndex(indexText, false);
559
560         AppLogDebug("EXIT");
561         return E_SUCCESS;
562 }
563
564 void
565 CommonUtil::SetLayoutFitToContainer(const Tizen::Ui::Container& container, Tizen::Ui::Control& childControl)
566 {
567         AppLogDebug("ENTER");
568         RelativeLayout* pLayout = dynamic_cast<RelativeLayout*>(container.GetPortraitLayoutN());
569         if (pLayout != null)
570         {
571                 pLayout->SetHorizontalFitPolicy(childControl, FIT_POLICY_PARENT);
572                 pLayout->SetVerticalFitPolicy(childControl, FIT_POLICY_PARENT);
573                 pLayout->Update();
574                 delete pLayout;
575         }
576         pLayout = dynamic_cast<RelativeLayout*>(container.GetLandscapeLayoutN());
577         if (pLayout != null)
578         {
579                 pLayout->SetHorizontalFitPolicy(childControl, FIT_POLICY_PARENT);
580                 pLayout->SetVerticalFitPolicy(childControl, FIT_POLICY_PARENT);
581                 pLayout->Update();
582                 delete pLayout;
583         }
584         AppLogDebug("EXIT");
585 }
586
587 void
588 CommonUtil::SetFooterItemEnabled(Tizen::Ui::Controls::Footer& pFooter, bool enable)
589 {
590         AppLogDebug("ENTER");
591         for (int iCount = 0; iCount < pFooter.GetItemCount(); iCount++)
592         {
593                 pFooter.SetItemEnabled(iCount, enable);
594         }
595         pFooter.Invalidate(true);
596         AppLogDebug("EXIT");
597 }
598
599 void
600 CommonUtil::SetTabHeaderStyle(Tizen::Ui::Controls::Header& pHeader)
601 {
602         AppLogDebug("ENTER");
603         pHeader.RemoveAllButtons();
604         pHeader.RemoveAllItems();
605
606         pHeader.SetStyle(HEADER_STYLE_TAB);
607         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
608
609         for (int iCount = 0; iCount < HEAD_ITEM_COUNT; iCount++)
610         {
611                 HeaderItem pTabHeaderItem;
612                 pTabHeaderItem.Construct(IDA_HEADER_BUTTON_SONG + iCount);
613                 pTabHeaderItem.SetText(ResourceManager::GetString(TabNameId[iCount]));
614
615                 pHeader.AddItem(pTabHeaderItem);
616         }
617         AppLogDebug("EXIT");
618 }
619
620 void
621 CommonUtil::SetEditHeaderStyle(Tizen::Ui::Controls::Header& pHeader, const Tizen::Base::String& titleText)
622 {
623         AppLogDebug("ENTER");
624         pHeader.RemoveAllButtons();
625         pHeader.RemoveAllItems();
626
627         pHeader.SetStyle(HEADER_STYLE_TITLE);
628         pHeader.SetTitleText(titleText);
629
630         ButtonItem buttonItem;
631         buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_HEADER_BUTTON_SELECTE_ALL);
632
633         Bitmap* normal = ResourceManager::GetBitmapN(L"00_icon_select_all_web.png");
634         buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, normal);
635
636         Bitmap* pressed = ResourceManager::GetBitmapN(L"00_icon_select_all_press_web.png");
637         buttonItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pressed);
638
639         Bitmap* disable = ResourceManager::GetBitmapN(L"00_icon_select_all_dim_web.png");
640         buttonItem.SetIcon(BUTTON_ITEM_STATUS_DISABLED, disable);
641
642         pHeader.SetButton(BUTTON_POSITION_RIGHT, buttonItem);
643         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
644
645         delete normal;
646         delete pressed;
647         delete disable;
648         AppLogDebug("EXIT");
649 }
650
651 void
652 CommonUtil::SetButtonItemUnCheckedIcon(Tizen::Ui::Controls::Header& header)
653 {
654         AppLogDebug("ENTER");
655         header.RemoveAllButtons();
656         ButtonItem buttonItem;
657         buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_HEADER_BUTTON_CHECK_BOX_CHECKED_ICON);
658
659         Bitmap* pBgNormal = ResourceManager::GetBitmapN(L"00_check_bg.png");
660         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBgNormal);
661
662         Bitmap* pBgPressed = ResourceManager::GetBitmapN(L"00_check_bg_press.png");
663         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBgPressed);
664
665         Bitmap* pBgDisabled = ResourceManager::GetBitmapN(L"00_check_bg_press.png");
666         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED, pBgDisabled);
667
668         header.SetButton(BUTTON_POSITION_RIGHT, buttonItem);
669         header.Invalidate(true);
670
671         delete pBgNormal;
672         delete pBgPressed;
673         delete pBgDisabled;
674         AppLogDebug("EXIT");
675 }
676
677 void
678 CommonUtil::SetItemCheckedAll(bool isChecked, Tizen::Ui::Controls::TableView& tableView)
679 {
680         AppLogDebug("ENTER");
681         int totalCount = tableView.GetItemCount();
682         for (int iCount = INIT_VALUE; iCount < totalCount; iCount++)
683         {
684                 tableView.SetItemChecked(iCount, isChecked);
685         }
686         tableView.Invalidate(true);
687         AppLogDebug("EXIT");
688 }
689
690 void
691 CommonUtil::SetButtonItemCheckedIcon(Tizen::Ui::Controls::Header& header)
692 {
693         AppLogDebug("ENTER");
694         header.RemoveAllButtons();
695         ButtonItem buttonItem;
696         buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_HEADER_BUTTON_CHECK_BOX_UNCHECKED_ICON);
697
698         Bitmap* pBgNormal = ResourceManager::GetBitmapN(L"00_check_bg.png");
699         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_NORMAL, pBgNormal);
700
701         Bitmap* pBgPressed = ResourceManager::GetBitmapN(L"00_check_bg_press.png");
702         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_PRESSED, pBgPressed);
703
704         Bitmap* pBgDisabled = ResourceManager::GetBitmapN(L"00_check_bg_press.png");
705         buttonItem.SetBackgroundBitmap(BUTTON_ITEM_STATUS_DISABLED, pBgDisabled);
706
707         Bitmap* pIconChecked = ResourceManager::GetBitmapN(L"00_check_checking.png");
708         buttonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pIconChecked);
709         buttonItem.SetIcon(BUTTON_ITEM_STATUS_PRESSED, pIconChecked);
710         buttonItem.SetIcon(BUTTON_ITEM_STATUS_DISABLED, pIconChecked);
711
712         header.SetButton(BUTTON_POSITION_RIGHT, buttonItem);
713         header.Invalidate(true);
714
715         delete pBgNormal;
716         delete pBgPressed;
717         delete pBgDisabled;
718         delete pIconChecked;
719         AppLogDebug("EXIT");
720 }
721
722 Tizen::Ui::Controls::Popup*
723 CommonUtil::CreateContentDeletePopup(Tizen::Ui::IActionEventListener& listener, int deleteActionId, int cancelActionId)
724 {
725         AppLogDebug("ENTER");
726         Popup* pDeletePopup = new (std::nothrow) Popup();
727         if (IsFailed(pDeletePopup->Construct(IDL_CONTENTS_DELETE_POPUP)))
728         {
729                 delete pDeletePopup;
730                 AppLogDebug("Construct(IDL_CONTENTS_DELETE_POPUP))) failed(%s)", GetErrorMessage(GetLastResult()));
731                 return null;
732         }
733
734         Button* pDeleteButton = static_cast<Button*>(pDeletePopup->GetControl(IDC_DELETE_BUTTON));
735         pDeleteButton->SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_DELETE"));
736         pDeleteButton->SetActionId(deleteActionId);
737         pDeleteButton->AddActionEventListener(listener);
738
739         Button* CancelButton = static_cast<Button*>(pDeletePopup->GetControl(IDC_CANCEL_BUTTON));
740         CancelButton->SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT_CANCEL"));
741         CancelButton->SetActionId(cancelActionId);
742         CancelButton->AddActionEventListener(listener);
743
744         Label* pDeleteQustionLabel = static_cast<Label*>(pDeletePopup->GetControl(IDC_LABEL_DELETE_Q));
745         pDeleteQustionLabel->SetText(ResourceManager::GetString(L"IDS_MUSIC_POP_DELETE_Q"));
746
747         AppLogDebug("EXIT");
748         return pDeletePopup;
749 }
750
751 Tizen::Ui::Controls::TableViewContextItem*
752 CommonUtil::CreateTableViewContextItemN(Tizen::Ui::IActionEventListener& listener, int itemWidth, FlickMenuStyle menuStyle)
753 {
754         AppLogDebug("ENTER");
755         Panel* pItem = CommonUtil::CreateFlickMenuN(listener, menuStyle);
756         if (pItem == null)
757         {
758                 AppLogDebug("CommonUtil::CreateSweepMenuItemN failed");
759                 return null;
760         }
761
762         TableViewContextItem* pTableViewContextItem = new (std::nothrow) TableViewContextItem();
763         if (IsFailed(pTableViewContextItem->Construct(Dimension(itemWidth, ITEM_HEIGHT))))
764         {
765                 AppLogDebug("Construct(Dimension(GetWidth(), ITEM_HEIGHT) failed(%s)", GetErrorMessage(GetLastResult()));
766                 delete pItem;
767                 delete pTableViewContextItem;
768                 return null;
769         }
770
771         pTableViewContextItem->AddControl(*pItem);
772         pTableViewContextItem->SetIndividualSelectionEnabled(pItem, true);
773
774         AppLogDebug("EXIT");
775         return pTableViewContextItem;
776 }
777
778 Tizen::Ui::Controls::Panel*
779 CommonUtil::CreateFlickMenuN(Tizen::Ui::IActionEventListener& listener, FlickMenuStyle menuStyle)
780 {
781         AppLogDebug("ENTER");
782         Panel* pFlickMenuPanel = new (std::nothrow) Panel();
783         if (menuStyle ==FLICK_MENU_STYLE_TYPE_01)
784         {
785                 if (IsFailed(pFlickMenuPanel->Construct(IDL_SWEEP_QUICK_MENU_ITEM_PANEL)))
786                 {
787                         AppLogDebug("Construct(IDL_SWEEP_QUICK_MENU_ITEM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
788                         delete pFlickMenuPanel;
789                         return null;
790                 }
791         }
792         else if (menuStyle == FLICK_MENU_STYLE_TYPE_02)
793         {
794                 if (IsFailed(pFlickMenuPanel->Construct(IDL_SWEEP_QUICK_ALBUM_PANEL)))
795                 {
796                         AppLogDebug("Construct(IDL_SWEEP_QUICK_ALBUM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
797                         delete pFlickMenuPanel;
798                         return null;
799                 }
800         }
801         else if (menuStyle == FLICK_MENU_STYLE_TYPE_03)
802         {
803                 if (IsFailed(pFlickMenuPanel->Construct(IDL_SWEEP_QUICK_PLAYALL_ITEM_PANEL)))
804                 {
805                         AppLogDebug("Construct(IDL_SWEEP_QUICK_ALBUM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
806                         delete pFlickMenuPanel;
807                         return null;
808                 }
809         }
810         else if (menuStyle == FLICK_MENU_STYLE_TYPE_04)
811         {
812                 if (IsFailed(pFlickMenuPanel->Construct(IDL_SWEEP_QUICK_ITEM2_PANEL)))
813                 {
814                         AppLogDebug("Construct(IDL_SWEEP_QUICK_ALBUM_PANEL) failed(%s)", GetErrorMessage(GetLastResult()));
815                         delete pFlickMenuPanel;
816                         return null;
817                 }
818         }
819         else
820         {
821                 AppLogDebug("EXIT");
822                 delete pFlickMenuPanel;
823                 return null;
824         }
825
826         if (menuStyle & FLICK_MENU_ITEM_SHARE)
827         {
828                 Button* pShareButton = static_cast<Button*>(pFlickMenuPanel->GetControl(IDC_SHARE_BUTTON));
829                 pShareButton->SetText(ResourceManager::GetString(L"IDS_MUSIC_BUTTON_SHARE"));
830                 pShareButton->SetActionId(IDA_FLICK_MENU_ITEM_SHARE);
831                 pShareButton->AddActionEventListener(listener);
832         }
833
834         if (menuStyle & FLICK_MENU_ITEM_SET_AS)
835         {
836                 Button* pSetButton = static_cast<Button*>(pFlickMenuPanel->GetControl(IDC_SET_AS_BUTTON));
837                 pSetButton->SetText(ResourceManager::GetString(L"IDS_COM_SK_SET_AS"));
838                 pSetButton->SetActionId(IDA_FLICK_MENU_ITEM_SET_AS);
839                 pSetButton->AddActionEventListener(listener);
840         }
841
842         if (menuStyle & FLICK_MENU_ITEM_ADDTO)
843         {
844                 Button* pAddToPlaylistButton = static_cast<Button*>(pFlickMenuPanel->GetControl(IDC_ADD_TO_BUTTON));
845                 pAddToPlaylistButton->SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_ADD_TO"));
846                 pAddToPlaylistButton->SetActionId(IDA_FLICK_MENU_ITEM_ADDTO);
847                 pAddToPlaylistButton->AddActionEventListener(listener);
848         }
849
850         if (menuStyle & FLICK_MENU_ITEM_DELETE)
851         {
852                 Button* pDeleteButton = static_cast<Button*>(pFlickMenuPanel->GetControl(IDC_BUTTON_DELETE));
853                 pDeleteButton->SetText(ResourceManager::GetString("IDS_MUSIC_SK3_DELETE"));
854                 pDeleteButton->SetActionId(IDA_FLICK_MENU_ITEM_DELETE);
855                 pDeleteButton->AddActionEventListener(listener);
856         }
857
858         if (menuStyle & FLICK_MENU_ITEM_PLAYALL)
859         {
860                 Button* pDeleteButton = static_cast<Button*>(pFlickMenuPanel->GetControl(IDC_PLAY_ALL_BUTTON));
861                 pDeleteButton->SetText(ResourceManager::GetString("IDS_MUSIC_OPT_MOREMENU_PLAY_ALL"));
862                 pDeleteButton->SetActionId(IDA_FLICK_MENU_ITEM_PLAYALL);
863                 pDeleteButton->AddActionEventListener(listener);
864         }
865
866         AppLogDebug("EXIT");
867         return pFlickMenuPanel;
868 }
869
870 Tizen::Base::String
871 CommonUtil::GetStringItemSelected(int itemCount)
872 {
873         AppLogDebug("ENTER");
874         String StrSelectStr = null;
875
876         if (itemCount > INIT_VALUE)
877         {
878                 if (itemCount == 1)
879                 {
880                         String ResSelect = ResourceManager::GetString("IDS_VR_POP_1_ITEM_SELECTED");
881                         StrSelectStr.Format(STRING_LENGTH, ResSelect.GetPointer());
882                 }
883                 else
884                 {
885                         String ResSelect = ResourceManager::GetString("IDS_VR_POP_PD_ITEMS_SELECTED");
886                         StrSelectStr.Format(STRING_LENGTH, ResSelect.GetPointer(), itemCount);
887                 }
888         }
889 //      else
890 //      {
891 //              StrSelectStr.Format(STRING_LENGTH, L"Select <Noun>s");//NEED STRING
892 //      }
893         AppLogDebug("EXIT");
894         return StrSelectStr;
895 }
896
897 result
898 CommonUtil::SetShowStateVariableHeightSizeControl(Tizen::Ui::Control& control, int controlHeight, bool isShow)
899 {
900         AppLogDebug("ENTER");
901         CommonUtil::SetShowStateControl(control, isShow);
902         CommonUtil::SetVariableHeightSizeControl(control, controlHeight);
903         control.Invalidate(true);
904         AppLogDebug("EXIT");
905         return E_SUCCESS;
906 }
907
908 void
909 CommonUtil::SetVariableHeightSizeControl(Tizen::Ui::Control& control, int controlHeight)
910 {
911         AppLogDebug("ENTER");
912         if (control.GetHeight() != controlHeight)
913         {
914                 control.SetSize(control.GetWidth(), controlHeight);
915         }
916         AppLogDebug("EXIT");
917 }
918
919 Tizen::Ui::Controls::ContextMenu*
920 CommonUtil::CreateContextMenuN(const Tizen::Ui::Control& source, Tizen::Ui::IActionEventListener& listener)
921 {
922         AppLogDebug("ENTER");
923         SceneManager* pSceneManager = SceneManager::GetInstance();
924         AppAssert(pSceneManager);
925
926         Scene* pScene = pSceneManager->GetCurrentScene();
927         AppAssert(pScene);
928         Form *pForm = pScene->GetForm();
929         AppAssert(pForm);
930
931         int screenHeight = pForm->GetHeight();
932         Point convertPosition = source.ConvertToScreenPosition(Point(source.GetWidth() / 2, 0));
933         Point itemPoint(convertPosition.x, convertPosition.y + source.GetHeight());
934
935         ContextMenuAnchorDirection direction = CONTEXT_MENU_ANCHOR_DIRECTION_DOWNWARD;
936         if (itemPoint.y > screenHeight / 2)
937         {
938                 itemPoint.y = itemPoint.y - source.GetHeight();
939                 direction = CONTEXT_MENU_ANCHOR_DIRECTION_UPWARD;
940         }
941
942         ContextMenu* pContextMenu = new (std::nothrow) ContextMenu();
943         pContextMenu->Construct(Point(INIT_VALUE, INIT_VALUE), CONTEXT_MENU_STYLE_LIST, direction);
944         pContextMenu->SetName(L"IDC_CONTEXT_MENU");
945         pContextMenu->AddActionEventListener(listener);
946         pContextMenu->SetAnchorPosition(itemPoint);
947         pContextMenu->SetMaxVisibleItemsCount(5);
948         pContextMenu->SetShowState(true);
949
950         AppLogDebug("EXIT");
951         return pContextMenu;
952 }
953
954 void
955 CommonUtil::AddContextMenuItem(Tizen::Ui::Controls::ContextMenu& contextMenu, unsigned int contextMenuItemStyle)
956 {
957         AppLogDebug("ENTER");
958         if (CONTEXT_MENU_ITEM_STYLE_CALL & contextMenuItemStyle)
959         {
960 //              IDA_CONTEXT_MENU_ITEM_CALL
961                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_CALL_RINGTONE"), IDA_CONTEXT_MENU_ITEM_CALL);
962         }
963
964         if (CONTEXT_MENU_ITEM_STYLE_SEARCH & contextMenuItemStyle)
965         {
966 //              IDA_CONTEXT_MENU_ITEM_SEARCH
967                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"), IDA_CONTEXT_MENU_ITEM_SEARCH);
968         }
969
970         if (CONTEXT_MENU_ITEM_STYLE_BLUETOOTH & contextMenuItemStyle)
971         {
972 //              IDA_CONTEXT_MENU_ITEM_BLUETOOTH
973                 contextMenu.AddItem(L"Bluetooth", IDA_CONTEXT_MENU_ITEM_BLUETOOTH);//NEED STRING
974         }
975
976         if (CONTEXT_MENU_ITEM_STYLE_MESSAGE & contextMenuItemStyle)
977         {
978 //              IDA_CONTEXT_MENU_ITEM_MESSAGE
979                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_MESSAGE"), IDA_CONTEXT_MENU_ITEM_MESSAGE);
980         }
981
982         if (CONTEXT_MENU_ITEM_STYLE_ALARM & contextMenuItemStyle)
983         {
984 //              IDA_CONTEXT_MENU_ITEM_ALARM
985                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_SETAS_ALARM_TONE"), IDA_CONTEXT_MENU_ITEM_ALARM);
986         }
987
988         if (CONTEXT_MENU_ITEM_STYLE_EMAIL & contextMenuItemStyle)
989         {
990 //              IDA_CONTEXT_MENU_ITEM_EMAIL
991                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EMAIL"), IDA_CONTEXT_MENU_ITEM_EMAIL);
992         }
993
994         if (CONTEXT_MENU_ITEM_STYLE_SETTINGS & contextMenuItemStyle)
995         {
996 //              IDA_CONTEXT_MENU_ITEM_SETTINGS
997                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_SETTINGS"), IDA_CONTEXT_MENU_ITEM_SETTINGS);
998         }
999
1000         if (CONTEXT_MENU_ITEM_STYLE_FOLDER_VIEW & contextMenuItemStyle)
1001         {
1002 //              IDA_CONTEXT_MENU_ITEM_FOLDER_VIEW
1003                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MSGF_SK3_FOLDER_VIEW"), IDA_CONTEXT_MENU_ITEM_FOLDER_VIEW);
1004         }
1005
1006         if (CONTEXT_MENU_ITEM_STYLE_CREATE_PLAYLIST & contextMenuItemStyle)
1007         {
1008 //              IDA_CONTEXT_MENU_ITEM_CREATE_PLAYLIST
1009                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_CREATE_PLAYLIST"), IDA_CONTEXT_MENU_ITEM_CREATE_PLAYLIST);
1010         }
1011
1012         if (CONTEXT_MENU_ITEM_STYLE_SHARE_VIA & contextMenuItemStyle)
1013         {
1014 //              IDA_CONTEXT_MENU_ITEM_SHARE_VIA
1015                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_IV_BODY_SHARE_VIA"), IDA_CONTEXT_MENU_ITEM_SHARE_VIA);
1016         }
1017
1018         if (CONTEXT_MENU_ITEM_STYLE_EDIT & contextMenuItemStyle)
1019         {
1020 //              IDA_CONTEXT_MENU_ITEM_EDIT
1021                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"), IDA_CONTEXT_MENU_ITEM_EDIT);
1022         }
1023
1024         if (CONTEXT_MENU_ITEM_STYLE_CALLER & contextMenuItemStyle)
1025         {
1026 //              IDA_CONTEXT_MENU_ITEM_CALLER
1027                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_SETAS_CALLER_RINGTONE"), IDA_CONTEXT_MENU_ITEM_CALLER);
1028         }
1029
1030         if (CONTEXT_MENU_ITEM_STYLE_GO_TO_LIBARY & contextMenuItemStyle)
1031         {
1032 //              IDA_CONTEXT_MENU_ITEM_GO_TO_LIBARY
1033                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_GO_TO_LIBRARY"), IDA_CONTEXT_MENU_ITEM_GO_TO_LIBARY);
1034         }
1035
1036         if (CONTEXT_MENU_ITEM_STYLE_ADD & contextMenuItemStyle)
1037         {
1038 //              IDA_CONTEXT_MENU_ITEM_STYLE_ADD
1039                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_OPT_ADD"), IDA_CONTEXT_MENU_ITEM_STYLE_ADD);
1040         }
1041
1042         if (CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST & contextMenuItemStyle)
1043         {
1044 //              IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST
1045                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_BODY_ADD_TO_PLAYLIST"), IDA_CONTEXT_MENU_ITEM_STYLE_ADD_TO_PLAYLIST);
1046         }
1047
1048         if (CONTEXT_MENU_ITEM_STYLE_SET_AS & contextMenuItemStyle)
1049         {
1050 //              IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS
1051                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_MUSIC_SK3_SET_AS"), IDA_CONTEXT_MENU_ITEM_STYLE_SET_AS);
1052         }
1053
1054         if (CONTEXT_MENU_ITEM_STYLE_DETAILS & contextMenuItemStyle)
1055         {
1056 //              IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS
1057                 contextMenu.AddItem(ResourceManager::GetString(L"IDS_COM_BODY_DETAILS"), IDA_CONTEXT_MENU_ITEM_STYLE_DETAILS);
1058         }
1059
1060         if (CONTEXT_MENU_ITEM_STYLE_SOUND_PATH & contextMenuItemStyle)
1061         {
1062 //              IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH
1063                 contextMenu.AddItem(L"Sound Path", IDA_CONTEXT_MENU_ITEM_STYLE_SOUND_PATH);//NEED STRING
1064         }
1065         AppLogDebug("EXIT");
1066 }
1067
1068 bool
1069 CommonUtil::IsVaildContextMenuItemActionId(int actionId)
1070 {
1071         AppLogDebug("ENTER");
1072         if (actionId >= IDA_CONTEXT_MENU_ITEM_BASE && actionId < IDA_CONTEXT_MENU_ITEM_MAX)
1073         {
1074                 return true;
1075         }
1076         AppLogDebug("EXIT");
1077         return false;
1078 }
1079
1080 bool
1081 CommonUtil::IsVaildCommonPopupActionId(int actionId)
1082 {
1083         AppLogDebug("ENTER");
1084         if (actionId >= IDA_COMMON_POPUP_BASE && actionId < IDA_COMMON_POPUP_MAX)
1085         {
1086                 return true;
1087         }
1088         AppLogDebug("EXIT");
1089         return false;
1090 }
1091
1092 void
1093 CommonUtil::ShowContextMenu(Tizen::Ui::Controls::ContextMenu& contextMenu, bool isShow)
1094 {
1095         AppLogDebug("ENTER");
1096         CommonUtil::SetShowStateControl(contextMenu, isShow);
1097         if (isShow)
1098         {
1099                 contextMenu.Show();
1100         }
1101         AppLogDebug("EXIT");
1102 }
1103
1104 result
1105 CommonUtil::SetShowStateControl(Tizen::Ui::Control& control, bool isShow)
1106 {
1107         AppLogDebug("ENTER");
1108         if (control.GetShowState() != isShow)
1109         {
1110                 control.SetShowState(isShow);
1111                 control.Invalidate(true);
1112                 return E_SUCCESS;
1113         }
1114
1115         AppLogDebug("EXIT");
1116         return E_FAILURE;
1117 }
1118
1119 void
1120 CommonUtil::SetSimpleTitleStyle(Tizen::Ui::Controls::Header& pHeader, const Tizen::Base::String& titleText)
1121 {
1122         AppLogDebug("ENTER");
1123         pHeader.RemoveAllButtons();
1124         pHeader.RemoveAllItems();
1125
1126         pHeader.SetStyle(HEADER_STYLE_TITLE);
1127         pHeader.SetTitleText(titleText);
1128         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
1129         pHeader.Invalidate(true);
1130         AppLogDebug("EXIT");
1131 }
1132
1133 void
1134 CommonUtil::SetTitleWithSearchIconStyle(Tizen::Ui::Controls::Header& pHeader, const Tizen::Base::String& titleText,
1135                                                                                                                                         const Tizen::Base::String& descriptionText, int actionId)
1136 {
1137         AppLogDebug("ENTER");
1138         pHeader.RemoveAllButtons();
1139         pHeader.RemoveAllItems();
1140
1141         pHeader.SetStyle(HEADER_STYLE_TITLE);
1142         pHeader.SetTitleText(titleText);
1143
1144         ButtonItem buttonItem;
1145         buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, actionId);
1146
1147 //      CommonUtil::SetButtonItemIcon(buttonItem, L"T02_icon_search.png", L"T02_icon_search.png", L"T02_icon_search.png");
1148         pHeader.SetButton(BUTTON_POSITION_RIGHT, buttonItem);
1149         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
1150         AppLogDebug("EXIT");
1151 }
1152
1153 void
1154 CommonUtil::SetTitleDescriptionWithIconStyle(Tizen::Ui::Controls::Header& pHeader, const Tizen::Base::String& titleText,
1155                                                                                         Tizen::Base::String& descriptionText, int actionId, Tizen::Graphics::Bitmap* icon)
1156 {
1157         AppLogDebug("ENTER");
1158         pHeader.RemoveAllButtons();
1159         pHeader.RemoveAllItems();
1160
1161         pHeader.SetStyle(HEADER_STYLE_TITLE);
1162         pHeader.SetTitleText(titleText);
1163         pHeader.SetDescriptionText(descriptionText);
1164
1165         ButtonItem buttonItem;
1166         buttonItem.Construct(BUTTON_ITEM_STYLE_ICON, actionId);
1167
1168 //      CommonUtil::SetIconButtonItem(buttonItem, icon, icon, null);
1169 //      CommonUtil::SetButtonItemIcon(buttonItem, L"T02_icon_search.png", L"T02_icon_search.png", L"T02_icon_search.png");
1170         pHeader.SetButton(BUTTON_POSITION_RIGHT, buttonItem);
1171
1172         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
1173         pHeader.SetDescriptionTextColor(COLOR_HEADER_DESCRIPTION_TEXT);
1174         AppLogDebug("EXIT");
1175 }
1176
1177 void
1178 CommonUtil::SetTitleDescriptionStyle(Tizen::Ui::Controls::Header& pHeader, const Tizen::Base::String& titleText, const Tizen::Base::String& descriptionText)
1179 {
1180         AppLogDebug("ENTER");
1181         pHeader.RemoveAllButtons();
1182         pHeader.RemoveAllItems();
1183
1184         pHeader.SetStyle(HEADER_STYLE_TITLE);
1185         pHeader.SetTitleText(titleText);
1186         pHeader.SetDescriptionText(descriptionText);
1187
1188         pHeader.SetTitleTextColor(COLOR_HEADER_TITLE_TEXT);
1189         pHeader.SetDescriptionTextColor(COLOR_HEADER_DESCRIPTION_TEXT);
1190         AppLogDebug("EXIT");
1191 }
1192
1193 Tizen::Ui::Controls::Footer*
1194 CommonUtil::CreateContentListFooter(const Tizen::Ui::Controls::Form& form)
1195 {
1196         AppLogDebug("ENTER");
1197         Footer* pFooter = form.GetFooter();
1198         if (pFooter == null)
1199         {
1200                 AppLogDebug("EXIT");
1201                 return null;
1202         }
1203
1204 #if 0
1205         ButtonItem AddButtonItem;
1206         ButtonItem backButtonItem;
1207         FooterItem searchButtonItem;
1208
1209         AddButtonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1210         AddButtonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pAddButtonImage);
1211
1212         backButtonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_BACK);
1213         backButtonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pBackButtonImage);
1214
1215         searchButtonItem.Construct(IDA_FOOTER_BUTTON_SEARCH);
1216         searchButtonItem.SetIcon(FOOTER_ITEM_STATUS_NORMAL, pSearchButtonImage);
1217
1218         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_ICON);
1219
1220         pFooter->SetButton(BUTTON_POSITION_LEFT, AddButtonItem);
1221         pFooter->SetButton(BUTTON_POSITION_RIGHT, backButtonItem);
1222         pFooter->AddItem(searchButtonItem);
1223 #else
1224         FooterItem AddButtonItem;
1225         FooterItem searchButtonItem;
1226
1227         AddButtonItem.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1228         AddButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_ADD_TO_PLAYLIST"));
1229
1230         searchButtonItem.Construct(IDA_FOOTER_BUTTON_SEARCH);
1231         searchButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
1232
1233         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1234
1235         pFooter->AddItem(AddButtonItem);
1236         pFooter->AddItem(searchButtonItem);
1237 #endif
1238
1239         AppLogDebug("EXIT");
1240         return pFooter;
1241 }
1242
1243 Tizen::Ui::Controls::Footer*
1244 CommonUtil::CreatePlaylistEditFooter(const Tizen::Ui::Controls::Form& form)
1245 {
1246         AppLogDebug("ENTER");
1247         Footer* pFooter = form.GetFooter();
1248         if (pFooter == null)
1249         {
1250                 AppLogDebug("EXIT");
1251                 return null;
1252         }
1253
1254         FooterItem deleteButtonItem;
1255         FooterItem cancelButtonItem;
1256
1257         deleteButtonItem.Construct(IDA_FOOTER_BUTTON_DELETE);
1258         deleteButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_DELETE"));
1259
1260         cancelButtonItem.Construct(IDA_FOOTER_BUTTON_CANCEL);
1261         cancelButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT_CANCEL"));
1262
1263         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1264
1265         pFooter->AddItem(deleteButtonItem);
1266         pFooter->AddItem(cancelButtonItem);
1267
1268         AppLogDebug("EXIT");
1269         return pFooter;
1270 }
1271
1272 Tizen::Ui::Controls::Footer*
1273 CommonUtil::CreateDefaultPlaylistContentListFooter(const Tizen::Ui::Controls::Form& form)
1274 {
1275         AppLogDebug("ENTER");
1276         Footer* pFooter = form.GetFooter();
1277         if (pFooter == null)
1278         {
1279                 AppLogDebug("EXIT");
1280                 return null;
1281         }
1282
1283         FooterItem editButtonItem;
1284         FooterItem createPlaylistButtonItem;
1285         FooterItem searchButtonItem;
1286
1287         editButtonItem.Construct(IDA_FOOTER_BUTTON_EDIT);
1288         editButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
1289         createPlaylistButtonItem.Construct(IDA_FOOTER_BUTTON_CREATE_PLAYLIST);
1290         createPlaylistButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_CREATE_PLAYLIST"));
1291
1292         searchButtonItem.Construct(IDA_FOOTER_BUTTON_SEARCH);
1293         searchButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
1294
1295         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1296
1297         pFooter->AddItem(editButtonItem);
1298         pFooter->AddItem(createPlaylistButtonItem);
1299         pFooter->AddItem(searchButtonItem);
1300
1301         AppLogDebug("EXIT");
1302         return pFooter;
1303 }
1304
1305 Tizen::Ui::Controls::Footer*
1306 CommonUtil::CreateUserPlaylistContentListFooter(const Tizen::Ui::Controls::Form& form)
1307 {
1308         AppLogDebug("ENTER");
1309         Footer* pFooter = form.GetFooter();
1310         if (pFooter == null)
1311         {
1312                 AppLogDebug("EXIT");
1313                 return null;
1314         }
1315
1316         FooterItem editButtonItem;
1317         FooterItem AddButtonItem;
1318 //      FooterItem searchButtonItem;
1319
1320         editButtonItem.Construct(IDA_FOOTER_BUTTON_EDIT);
1321         editButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
1322
1323         AddButtonItem.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1324         AddButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_ADD_TO_PLAYLIST"));
1325
1326 //      searchButtonItem.Construct(IDA_FOOTER_BUTTON_SEARCH);
1327 //      searchButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
1328
1329         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1330
1331         pFooter->AddItem(editButtonItem);
1332         pFooter->AddItem(AddButtonItem);
1333 //      pFooter->AddItem(searchButtonItem);
1334
1335         AppLogDebug("EXIT");
1336         return pFooter;
1337 }
1338
1339 Tizen::Ui::Controls::Footer*
1340 CommonUtil::CreateAddtoPlaylistPickerFooter(const Tizen::Ui::Controls::Form& form)
1341 {
1342         AppLogDebug("ENTER");
1343         Footer* pFooter = form.GetFooter();
1344         if (pFooter == null)
1345         {
1346                 AppLogDebug("EXIT");
1347                 return null;
1348         }
1349
1350 #if 0
1351         ButtonItem AddButtonItem;
1352         ButtonItem CancelButtonItem;
1353
1354         AddButtonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1355         AddButtonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pAddButtonImage);
1356
1357         CancelButtonItem.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_CANCEL);
1358         CancelButtonItem.SetIcon(BUTTON_ITEM_STATUS_NORMAL, pCancelButtonImage);
1359
1360         pFooter->SetStyle(FOOTER_STYLE_SEGMENTED_ICON);
1361
1362         pFooter->SetButton(BUTTON_POSITION_LEFT,  AddButtonItem);
1363         pFooter->SetButton(BUTTON_POSITION_RIGHT, CancelButtonItem);
1364 #else
1365         FooterItem AddButtonItem;
1366         FooterItem CancelButtonItem;
1367
1368         AddButtonItem.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1369         AddButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_ADD_TO_PLAYLIST"));
1370
1371         CancelButtonItem.Construct(IDA_FOOTER_BUTTON_CANCEL);
1372         CancelButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT_CANCEL"));
1373
1374         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1375
1376         pFooter->AddItem(AddButtonItem);
1377         pFooter->AddItem(CancelButtonItem);
1378 #endif
1379
1380         AppLogDebug("EXIT");
1381         return pFooter;
1382 }
1383
1384 Tizen::Ui::Controls::Footer*
1385 CommonUtil::CreateAddtoPlaylistFooter(const Tizen::Ui::Controls::Form& form)
1386 {
1387         AppLogDebug("ENTER");
1388         Footer* pFooter = form.GetFooter();
1389         if (pFooter == null)
1390         {
1391                 AppLogDebug("EXIT");
1392                 return null;
1393         }
1394
1395         FooterItem AddButtonItem;
1396
1397         AddButtonItem.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1398         AddButtonItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BODY_ADD_TO_PLAYLIST"));
1399         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1400         pFooter->AddItem(AddButtonItem);
1401
1402         AppLogDebug("EXIT");
1403         return pFooter;
1404 }
1405
1406 Tizen::Ui::Controls::Footer*
1407 CommonUtil::CreateEditContentListFooter(const Tizen::Ui::Controls::Form& form)
1408 {
1409         AppLogDebug("ENTER");
1410         Footer* pFooter = form.GetFooter();
1411         if (pFooter == null)
1412         {
1413                 AppLogDebug("EXIT");
1414                 return null;
1415         }
1416         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1417
1418         FooterItem editButtonItem;
1419         FooterItem searchButtonItem;
1420
1421         editButtonItem.Construct(IDA_FOOTER_BUTTON_EDIT);
1422         editButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
1423
1424         searchButtonItem.Construct(IDA_FOOTER_BUTTON_SEARCH);
1425         searchButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_SEARCH"));
1426
1427         pFooter->AddItem(editButtonItem);
1428         pFooter->AddItem(searchButtonItem);
1429
1430         AppLogDebug("EXIT");
1431         return pFooter;
1432 }
1433
1434 Tizen::Ui::Controls::Footer*
1435 CommonUtil::CreateEditFooter(const Tizen::Ui::Controls::Form& form)
1436 {
1437         AppLogDebug("ENTER");
1438         Footer* pFooter = form.GetFooter();
1439         if (pFooter == null)
1440         {
1441                 AppLogDebug("EXIT");
1442                 return null;
1443         }
1444         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1445
1446         FooterItem editButtonItem;
1447         editButtonItem.Construct(IDA_FOOTER_BUTTON_EDIT);
1448         editButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
1449         pFooter->AddItem(editButtonItem);
1450
1451         AppLogDebug("EXIT");
1452         return pFooter;
1453 }
1454
1455 Tizen::Ui::Controls::Footer*
1456 CommonUtil::CreateDeleteFooter(const Tizen::Ui::Controls::Form& form)
1457 {
1458         AppLogDebug("ENTER");
1459         Footer* pFooter = form.GetFooter();
1460         if (pFooter == null)
1461         {
1462                 AppLogDebug("EXIT");
1463                 return null;
1464         }
1465         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1466
1467         FooterItem deleteFooterItem;
1468         deleteFooterItem.Construct(IDA_FOOTER_BUTTON_DELETE);
1469         deleteFooterItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_SK3_DELETE"));
1470
1471         FooterItem shareFooterItem;
1472         shareFooterItem.Construct(IDA_FOOTER_BUTTON_SHARE);
1473         shareFooterItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BUTTON_SHARE"));
1474
1475         FooterItem addToPlaylistFooterItem;
1476         addToPlaylistFooterItem.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1477         addToPlaylistFooterItem.SetText(ResourceManager::GetString(L"IDS_MUSIC_BUTTON2_ADD_TO_PLAYLIST"));
1478
1479         FooterItem cancelFooterItem;
1480         cancelFooterItem.Construct(IDA_FOOTER_BUTTON_CANCEL);
1481         cancelFooterItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT_CANCEL"));
1482
1483         pFooter->AddItem(deleteFooterItem);
1484         pFooter->AddItem(shareFooterItem);
1485         pFooter->AddItem(addToPlaylistFooterItem);
1486         pFooter->AddItem(cancelFooterItem);
1487
1488         pFooter->SetItemEnabled(INDEX_FOOTER_DELETE, false);
1489         pFooter->SetItemEnabled(INDEX_FOOTER_SHARE, false);
1490         pFooter->SetItemEnabled(INDEX_FOOTER_ADDTOPLATLIST, false);
1491
1492         AppLogDebug("EXIT");
1493         return pFooter;
1494 }
1495
1496 Tizen::Ui::Controls::Footer*
1497 CommonUtil::CreateCancelFooter(const Tizen::Ui::Controls::Form& form)
1498 {
1499         AppLogDebug("ENTER");
1500         Footer* pFooter = form.GetFooter();
1501         if (pFooter == null)
1502         {
1503                 AppLogDebug("EXIT");
1504                 return null;
1505         }
1506
1507         pFooter->SetBackButton();
1508         AppLogDebug("EXIT");
1509         return pFooter;
1510 }
1511
1512 Tizen::Ui::Controls::Footer*
1513 CommonUtil::CreateBackButtonStyleFooter(const Tizen::Ui::Controls::Form& form, FooterButtonStyle style)
1514 {
1515         AppLogDebug("ENTER");
1516         Footer* pFooter = form.GetFooter();
1517         if (pFooter == null)
1518         {
1519                 AppLogDebug("EXIT");
1520                 return null;
1521         }
1522         pFooter->SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1523
1524         switch (style)
1525         {
1526         case STYLE_MORE_ADD:
1527                 {
1528                         Bitmap* bitmapMore = ResourceManager::GetBitmapN(L"00_icon_more_ef.png");
1529                         Bitmap* bitmapMorePress = ResourceManager::GetBitmapN(L"00_icon_more.png");
1530
1531                         ButtonItem buttonItemMore;
1532                         buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_MORE);
1533                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, bitmapMore);
1534                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, bitmapMorePress);
1535                         pFooter->SetButton(BUTTON_POSITION_LEFT,buttonItemMore);
1536
1537                         delete bitmapMore;
1538                         delete bitmapMorePress;
1539                 }
1540                 break;
1541
1542         case STYLE_ADDTO_DELETE_ADD:
1543                 {
1544                         FooterItem footerItemAddto;
1545                         footerItemAddto.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1546                         footerItemAddto.SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_ADD_TO"));
1547
1548                         FooterItem footerItemDelete;
1549                         footerItemDelete.Construct(IDA_FOOTER_BUTTON_DELETE);
1550                         footerItemDelete.SetText(ResourceManager::GetString(L"IDS_MUSIC_SK3_DELETE"));
1551
1552                         pFooter->AddItem(footerItemAddto);
1553                         pFooter->AddItem(footerItemDelete);
1554                 }
1555                 break;
1556
1557         case STYLE_SHARE_ADD:
1558                 {
1559                         FooterItem footerItemShare;
1560                         footerItemShare.Construct(IDA_FOOTER_BUTTON_SHARE);
1561                         footerItemShare.SetText(ResourceManager::GetString(L"IDS_MUSIC_BUTTON_SHARE"));
1562
1563                         pFooter->AddItem(footerItemShare);
1564                 }
1565                 break;
1566
1567         case STYLE_DELETE_ADD:
1568                 {
1569                         FooterItem footerItemDelete;
1570                         footerItemDelete.Construct(IDA_FOOTER_BUTTON_DELETE);
1571                         footerItemDelete.SetText(ResourceManager::GetString(L"IDS_MUSIC_SK3_DELETE"));
1572
1573                         pFooter->AddItem(footerItemDelete);
1574                 }
1575                 break;
1576
1577         case STYLE_ADD_ADD:
1578                 {
1579                         FooterItem footerItemAdd;
1580                         footerItemAdd.Construct(IDA_FOOTER_BUTTON_ADD);
1581                         footerItemAdd.SetText(ResourceManager::GetString(L"IDS_MUSIC_SK_ADD_LITE"));
1582
1583                         pFooter->AddItem(footerItemAdd);
1584                 }
1585                 break;
1586
1587         default:
1588                 break;
1589         }
1590         pFooter->SetBackButton();
1591         AppLogDebug("EXIT");
1592         return pFooter;
1593 }
1594
1595 void
1596 CommonUtil::SetBackButtonStyleFooter(Tizen::Ui::Controls::Footer& footer, FooterButtonStyle style)
1597 {
1598         AppLogDebug("ENTER");
1599         footer.RemoveAllButtons();
1600         footer.RemoveAllItems();
1601         footer.SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1602         switch(style)
1603         {
1604         case STYLE_MORE_ADD:
1605                 {
1606                         Bitmap* bitmapMore = ResourceManager::GetBitmapN(L"00_icon_more_web.png");
1607                         Bitmap* bitmapMorePress = ResourceManager::GetBitmapN(L"00_icon_more_press_web.png");
1608                         ButtonItem buttonItemMore;
1609                         buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_MORE);
1610                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, bitmapMore);
1611                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, bitmapMorePress);
1612                         footer.SetButton(BUTTON_POSITION_LEFT,buttonItemMore);
1613                         delete bitmapMore;
1614                         delete bitmapMorePress;
1615                 }
1616                 break;
1617
1618         case STYLE_ADDTO_DELETE_ADD:
1619                 {
1620                         FooterItem footerItemAddto;
1621                         footerItemAddto.Construct(IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST);
1622                         footerItemAddto.SetText(ResourceManager::GetString(L"IDS_MUSIC_OPT_ADD_TO"));
1623                         FooterItem footerItemDelete;
1624                         footerItemDelete.Construct(IDA_FOOTER_BUTTON_DELETE);
1625                         footerItemDelete.SetText(ResourceManager::GetString(L"IDS_MUSIC_SK3_DELETE"));
1626                         footer.AddItem(footerItemAddto);
1627                         footer.AddItem(footerItemDelete);
1628                 }
1629                 break;
1630
1631         case STYLE_SHARE_ADD:
1632                 {
1633                         FooterItem footerItemShare;
1634                         footerItemShare.Construct(IDA_FOOTER_BUTTON_SHARE);
1635                         footerItemShare.SetText(ResourceManager::GetString(L"IDS_MUSIC_BUTTON_SHARE"));
1636                         footer.AddItem(footerItemShare);
1637                 }
1638                 break;
1639
1640         case STYLE_MORE_EDIT_ADD:
1641                 {
1642                         footer.SetStyle(FOOTER_STYLE_BUTTON_ICON_TEXT);
1643
1644                         Bitmap* bitmapMore = ResourceManager::GetBitmapN(L"00_icon_more_web.png");
1645                         Bitmap* bitmapMorePress = ResourceManager::GetBitmapN(L"00_icon_more_press_web.png");
1646
1647                         ButtonItem buttonItemMore;
1648                         buttonItemMore.Construct(BUTTON_ITEM_STYLE_ICON, IDA_FOOTER_BUTTON_MORE);
1649                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_NORMAL, bitmapMore);
1650                         buttonItemMore.SetIcon(BUTTON_ITEM_STATUS_PRESSED, bitmapMorePress);
1651                         footer.SetButton(BUTTON_POSITION_LEFT,buttonItemMore);
1652
1653                         delete bitmapMore;
1654                         delete bitmapMorePress;
1655
1656                         FooterItem editButtonItem;
1657                         editButtonItem.Construct(IDA_FOOTER_BUTTON_EDIT);
1658                         editButtonItem.SetText(ResourceManager::GetString(L"IDS_COM_BODY_EDIT"));
1659                         footer.AddItem(editButtonItem);
1660                 }
1661                 break;
1662
1663         default:
1664                 break;
1665         }
1666         footer.SetBackButton();
1667         AppLogDebug("EXIT");
1668 }
1669
1670 ContentInformation*
1671 CommonUtil::GetContentInformationN(const Tizen::Content::AudioContentInfo& audioContentInfo)
1672 {
1673         AppLogDebug("ENTER");
1674         ContentInformation* pContentInfoStruct = new (std::nothrow) ContentInformation();
1675
1676         pContentInfoStruct->contentId = audioContentInfo.GetContentId();
1677         pContentInfoStruct->GenreName = audioContentInfo.GetGenre();
1678         pContentInfoStruct->ArtistName = audioContentInfo.GetArtist();
1679         pContentInfoStruct->ComposerName = audioContentInfo.GetComposer();
1680         pContentInfoStruct->AlbumName = audioContentInfo.GetAlbumName();
1681         pContentInfoStruct->TitleName = audioContentInfo.GetTitle();
1682         pContentInfoStruct->ContentFilePath = audioContentInfo.GetContentPath();
1683
1684         pContentInfoStruct->ReleaseYear = audioContentInfo.GetReleaseYear();
1685         pContentInfoStruct->Duration = audioContentInfo.GetDuration();
1686         pContentInfoStruct->contentId = audioContentInfo.GetContentId();
1687
1688         AppLogDebug("EXIT");
1689         return pContentInfoStruct;
1690 }
1691
1692 void
1693 CommonUtil::CreateTableViewItem(Tizen::Ui::Container& parent,
1694                                         const Tizen::Graphics::Bitmap& thumbnail,
1695                                         const Tizen::Base::String& itemName,
1696                                         int itemCount)
1697 {
1698         AppLogDebug("ENTER");
1699
1700         int X_Gap = W_THUMBNAIL + (X_GAP_THUMBNAIL * 2);
1701         int W_Label = W_CLIENT_AREA - (X_Gap + W_CREATE_TABLE_VIEW_ITEM_COUNT_LABEL_ITEM);
1702
1703         Label* pSongThumbnailLabel = new (std::nothrow) Label();
1704         pSongThumbnailLabel->Construct(Rectangle(X_GAP_THUMBNAIL, Y_GAP_THUMBNAIL, W_THUMBNAIL, H_THUMBNAIL), L"");
1705         pSongThumbnailLabel->SetBackgroundBitmap(thumbnail);
1706         pSongThumbnailLabel->SetName(L"pSongThumbnailLabel");
1707
1708         parent.AddControl(*pSongThumbnailLabel);
1709
1710         Label* pSongNameLabel = new (std::nothrow) Label();
1711         pSongNameLabel->Construct(Rectangle(X_Gap, Y_CREATE_TABLE_VIEW_ITEM, W_Label, H_CREATE_TABLE_VIEW_ITEM), L"");
1712         pSongNameLabel->SetTextConfig(FONT_SIZE, LABEL_TEXT_STYLE_NORMAL);
1713         pSongNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1714         pSongNameLabel->SetText(itemName);
1715
1716         parent.AddControl(*pSongNameLabel);
1717
1718         Label* pSongTimeLabel = new (std::nothrow) Label();
1719         pSongTimeLabel->Construct(Rectangle(pSongNameLabel->GetWidth() + X_Gap, pSongNameLabel->GetY(), W_CREATE_TABLE_VIEW_ITEM_COUNT_LABEL_ITEM, H_CREATE_TABLE_VIEW_ITEM), L"");
1720         pSongTimeLabel->SetTextConfig(FONT_SIZE - 2, LABEL_TEXT_STYLE_NORMAL);
1721         pSongTimeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1722         pSongTimeLabel->SetText(CommonUtil::SetSongsString(itemCount));
1723
1724         parent.AddControl(*pSongTimeLabel);
1725         AppLogDebug("EXIT");
1726 }
1727
1728 result
1729 CommonUtil::CreateEditListTableViewItem(Tizen::Ui::Container& parent,
1730                                                 const Tizen::Graphics::Bitmap& thumbnail,
1731                                                 const Tizen::Base::String& itemName,
1732                                                 int itemCount)
1733 {
1734         AppLogDebug("ENTER");
1735         result r = E_SUCCESS;
1736
1737         int W_Label = W_CLIENT_AREA - (W_TABLE_VIEW_MARK + W_THUMBNAIL + W_CREATE_TABLE_VIEW_ITEM_COUNT_LABEL_ITEM);
1738
1739         Label* pSongThumbnailLabel = new (std::nothrow) Label();
1740         pSongThumbnailLabel->Construct(Rectangle(0, Y_GAP_THUMBNAIL, W_THUMBNAIL, H_THUMBNAIL), L"");
1741         pSongThumbnailLabel->SetBackgroundBitmap(thumbnail);
1742         pSongThumbnailLabel->SetName(L"pSongThumbnailLabel");
1743
1744         Label* pSongNameLabel = new (std::nothrow) Label();
1745         pSongNameLabel->Construct(Rectangle(pSongThumbnailLabel->GetWidth(), Y_CREATE_TABLE_VIEW_ITEM, W_Label, H_CREATE_TABLE_VIEW_ITEM), L"");
1746         pSongNameLabel->SetTextConfig(FONT_SIZE + 2, LABEL_TEXT_STYLE_NORMAL);
1747         pSongNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1748         pSongNameLabel->SetText(itemName);
1749
1750         Label* pSongCountLabel = new (std::nothrow) Label();
1751         pSongCountLabel->Construct(Rectangle(pSongNameLabel->GetWidth() + W_THUMBNAIL, pSongNameLabel->GetY(), W_CREATE_TABLE_VIEW_ITEM_COUNT_LABEL_ITEM, H_CREATE_TABLE_VIEW_ITEM), L"");
1752         pSongCountLabel->SetTextConfig(FONT_SIZE - 2, LABEL_TEXT_STYLE_NORMAL);
1753         pSongCountLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1754         pSongCountLabel->SetText(CommonUtil::SetSongsString(itemCount));
1755
1756         parent.AddControl(*pSongThumbnailLabel);
1757         parent.AddControl(*pSongNameLabel);
1758         parent.AddControl(*pSongCountLabel);
1759         AppLogDebug("EXIT");
1760         return r;
1761 }
1762
1763 result
1764 CommonUtil::CreateTableViewContextItem(Tizen::Ui::Controls::TableViewContextItem& parent, Tizen::Ui::IActionEventListener& listener)
1765 {
1766         AppLogDebug("ENTER");
1767         Button* pAddToPlaylistButton = new (std::nothrow) Button();
1768         pAddToPlaylistButton->Construct(Rectangle(X_GAP_CONTEXT_ITME, Y_GAP_CONTEXT_ITEM, parent.GetWidth() - (X_GAP_CONTEXT_ITME * 2), parent.GetHeight() - (Y_GAP_CONTEXT_ITEM * 2)));
1769         pAddToPlaylistButton->SetText(ResourceManager::GetString("IDS_MUSIC_BODY_ADD_TO_PLAYLIST"));
1770         pAddToPlaylistButton->SetTextSize(FONT_SIZE);
1771         pAddToPlaylistButton->SetActionId(IDA_FLICK_BUTTON_ADD_TO_PALYLIST);
1772         pAddToPlaylistButton->AddActionEventListener(listener);
1773
1774         parent.SetIndividualSelectionEnabled(pAddToPlaylistButton, true);
1775         parent.AddControl(*pAddToPlaylistButton);
1776
1777         AppLogDebug("EXIT");
1778         return E_SUCCESS;
1779 }
1780
1781 Tizen::Ui::Controls::TableView*
1782 CommonUtil::CreateEditorTableView(int width, int height)
1783 {
1784         AppLogDebug("ENTER");
1785         TableView* pTableView = new (std::nothrow) TableView();
1786         pTableView->Construct(Rectangle(INIT_VALUE, H_SELECT_ALL_BUTTON, width, height - H_SELECT_ALL_BUTTON),
1787                                         true,
1788                                         TABLE_VIEW_SCROLL_BAR_STYLE_FADE_OUT);
1789         AppLogDebug("EXIT");
1790         return pTableView;
1791 }
1792
1793 Tizen::Ui::Controls::TableView*
1794 CommonUtil::CreateTableView(int width, int height)
1795 {
1796         AppLogDebug("ENTER");
1797         TableView* pTableView = new (std::nothrow) TableView();
1798         pTableView->Construct(Rectangle(0, 0, width, height), true, TABLE_VIEW_SCROLL_BAR_STYLE_FAST_SCROLL);
1799
1800         String retCountry = null;
1801         String indexText = null;
1802
1803         Tizen::System::SettingInfo::GetValue("http://tizen.org/setting/locale.country", retCountry);
1804         if (retCountry.CompareTo("eng_GB") == 0)
1805         {
1806                 indexText.Append(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
1807         }
1808         else if(retCountry.CompareTo("kor_KR") == 0)
1809         {
1810 //              indexText.Append(L"ㄱㄲㄴㄷㄸㄹㅁㅂㅃㅅㅆㅇㅈㅉㅊㅋㅌㅍㅎ");
1811                 indexText.Append(L"ABCDEFGHIJKLMNOPQRSTUVWXYZ");
1812         }
1813
1814         indexText.Append(L"#");
1815         indexText.Append(L"0");
1816
1817         pTableView->SetFastScrollIndex(indexText, false);
1818         AppLogDebug("EXIT");
1819         return pTableView;
1820 }
1821
1822 result
1823 CommonUtil::CreateContentPikerTableViewItem(Tizen::Ui::Controls::TableViewItem& parent, const Tizen::Base::String& songName, const Tizen::Base::String& songTime)
1824 {
1825         AppLogDebug("ENTER");
1826         Label* pSongNameLabel = new (std::nothrow) Label();
1827         pSongNameLabel->Construct(Rectangle(0, Y_GAP_CONTENT_PIKER_ITEM, W_SONG_TITLE_CONTENT_PIKER_ITEM, H_SONG_TITLE_CONTENT_PIKER_ITEM), songName);
1828         pSongNameLabel->SetTextConfig(FONT_SIZE, LABEL_TEXT_STYLE_NORMAL);
1829         pSongNameLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
1830
1831         Label* pSongTimeLabel = new (std::nothrow) Label();
1832         pSongTimeLabel->Construct(Rectangle(pSongNameLabel->GetWidth(), Y_GAP_CONTENT_PIKER_ITEM, W_SONG_TIME_CONTENT_PIKER_ITEM, pSongNameLabel->GetHeight()), songTime);
1833         pSongTimeLabel->SetTextConfig(FONT_SIZE, LABEL_TEXT_STYLE_NORMAL);
1834         pSongTimeLabel->SetTextHorizontalAlignment(ALIGNMENT_RIGHT);
1835
1836         parent.AddControl(*pSongNameLabel);
1837         parent.AddControl(*pSongTimeLabel);
1838
1839         AppLogDebug("EXIT");
1840         return E_SUCCESS;
1841 }
1842
1843 Tizen::Ui::Controls::CheckButton*
1844 CommonUtil::CreateSelectAllCheckedButton(int width)
1845 {
1846         AppLogDebug("ENTER");
1847         CheckButton* pCheckButton = new (std::nothrow) CheckButton();
1848         pCheckButton->Construct(Rectangle(INIT_VALUE, INIT_VALUE, width, H_SELECT_ALL_BUTTON),
1849                                                         CHECK_BUTTON_STYLE_MARK,
1850                                                         BACKGROUND_STYLE_DEFAULT,
1851                                                         false,
1852                                                         ResourceManager::GetString("IDS_COM_BODY_SELECT_ALL"),
1853                                                         GROUP_STYLE_BOTTOM);
1854         pCheckButton->SetActionId(IDA_CHECK_BUTTON, IDA_UNCHECK_BUTTON, INIT_VALUE);
1855         pCheckButton->SetColor(CHECK_BUTTON_STATUS_NORMAL, COLOR_SELECT_ALL);
1856         AppLogDebug("EXIT");
1857         return pCheckButton;
1858 }
1859
1860 Tizen::Ui::Controls::Label*
1861 CommonUtil::CreateCheckedCountLabel(int width, int height)
1862 {
1863         AppLogDebug("ENTER");
1864         Label* pLabel = new (std::nothrow) Label();
1865         pLabel->Construct(Rectangle(INIT_VALUE, height - H_CHECKED_COUNT_LABEL, width, H_CHECKED_COUNT_LABEL), L"");
1866         pLabel->SetBackgroundColor(COLOR_SMALL_POPUP);
1867         pLabel->SetTextHorizontalAlignment(ALIGNMENT_CENTER);
1868         pLabel->SetText(FONT_SIZE);
1869         AppLogDebug("EXIT");
1870         return pLabel;
1871 }
1872
1873 void
1874 CommonUtil::SetAddtoPlaylistState(bool state)
1875 {
1876         AppLogDebug("ENTER");
1877         __addToPlaylistState = state;
1878         AppLogDebug("EXIT");
1879 }
1880
1881 bool
1882 CommonUtil::GetAddtoPlaylistState(void)
1883 {
1884         AppLogDebug("ENTER");
1885         AppLogDebug("EXIT");
1886         return __addToPlaylistState;
1887 }
1888
1889 void
1890 CommonUtil::SetAddtoPlaylistName(const Tizen::Base::String& addToPlayName)
1891 {
1892         AppLogDebug("ENTER");
1893         __AddToPlaylistName = addToPlayName;
1894         AppLogDebug("EXIT");
1895 }
1896
1897 Tizen::Base::String
1898 CommonUtil::GetAddtoPlaylistName(void)
1899 {
1900         AppLogDebug("ENTER");
1901         AppLogDebug("EXIT");
1902         return __AddToPlaylistName;
1903 }
1904
1905 void
1906 CommonUtil::SetButtonEnabled(const Tizen::Ui::Controls::Form& form, int checkedItemCount, int actionId)
1907 {
1908         AppLogDebug("ENTER");
1909         Footer* pFooter = form.GetFooter();
1910         if (pFooter == null)
1911         {
1912                 return;
1913         }
1914
1915         if (actionId == IDA_CHECK_BUTTON
1916                 || actionId == IDA_UNCHECK_BUTTON
1917                 || actionId == IDA_FOOTER_BUTTON_ADD_TO_PLAYLIST
1918                 || actionId == IDA_FOOTER_BUTTON_DELETE)
1919         {
1920                 bool buttonState = checkedItemCount == 0 ? false : true;
1921                 for (int iCount = 0; iCount < pFooter->GetItemCount() - 1; iCount++)
1922                 {
1923                         pFooter->SetItemEnabled(iCount, buttonState);
1924                         pFooter->Invalidate(true);
1925                 }
1926         }
1927         else if (actionId == IDA_FOOTER_BUTTON_CANCEL)
1928         {
1929                 for (int iCount = 0; iCount < pFooter->GetItemCount() - 1; iCount++)
1930                 {
1931                         pFooter->SetItemEnabled(iCount, true);
1932                         pFooter->Invalidate(true);
1933                 }
1934         }
1935         AppLogDebug("EXIT");
1936 }
1937
1938 void
1939 CommonUtil::SetButtonEnabled(const Tizen::Ui::Controls::Form& form, int checkedItemCount)
1940 {
1941         AppLogDebug("ENTER");
1942         Footer* pFooter = form.GetFooter();
1943         if (pFooter == null)
1944         {
1945                 return;
1946         }
1947
1948         bool buttonState = checkedItemCount == 0 ? false : true;
1949         for (int iCount = 0; iCount < pFooter->GetItemCount() - 1; iCount++)
1950         {
1951                 pFooter->SetItemEnabled(iCount, buttonState);
1952                 pFooter->Invalidate(true);
1953         }
1954         AppLogDebug("EXIT");
1955 }
1956
1957 Bitmap*
1958 CommonUtil::GetColorizedBitmapN(const Tizen::Graphics::Bitmap& bitmap, const Tizen::Graphics::Color& color)
1959 {
1960         AppLogDebug("ENTER");
1961         if (bitmap.GetPixelColorFormat() != BITMAP_PIXEL_FORMAT_ARGB8888)
1962         {
1963                 return null;
1964         }
1965         std::unique_ptr<Bitmap>pRet(new (std::nothrow) Bitmap());
1966         if (pRet == null)
1967         {
1968                 return null;
1969         }
1970         result r = pRet->Construct(bitmap, Rectangle(0, 0, bitmap.GetWidth(), bitmap.GetHeight()));
1971         if (r != E_SUCCESS)
1972         {
1973                 return null;
1974         }
1975         BufferInfo bi;
1976         pRet->Lock(bi);
1977         {
1978                 typedef unsigned long Pixel;
1979                 Pixel* pDst = static_cast<Pixel*>(bi.pPixels);
1980                 int dstPadding = bi.pitch / sizeof(Pixel) - bi.width;
1981                 Pixel replacing = color.GetRGB32() & 0x00FFFFFF;
1982                 for (int y = 0; y < bi.height; y++)
1983                 {
1984                         for (int x = 0; x < bi.width; x++)
1985                         {
1986                                 *pDst = (*pDst & 0xFF000000) | replacing;
1987                                 pDst++;
1988                         }
1989                         pDst += dstPadding;
1990                 }
1991         }
1992         pRet->Unlock();
1993         AppLogDebug("EXIT");
1994         return pRet.release();
1995 }
1996
1997 void
1998 CommonUtil::SetNoContentImage(Tizen::Ui::Controls::Label& source, Tizen::Base::String& resourceName, Tizen::Base::String& text)
1999 {
2000         AppLogDebug("ENTER");
2001         Bitmap* pNoContentImage = ResourceManager::GetBitmapN(resourceName);
2002         source.SetBackgroundBitmap(*pNoContentImage);
2003         delete pNoContentImage;
2004         source.SetText(text);
2005         source.Invalidate(false);
2006         AppLogDebug("EXIT");
2007 }
2008
2009 Tizen::Base::String
2010 CommonUtil::SetHighDepthToEllipsisPath(const Tizen::Base::String& fullFilePath)
2011 {
2012         AppLogDebug("ENTER");
2013         StringTokenizer stringTokenizer(fullFilePath, IDS_SEPARATOR_SLASH);
2014         int depthCount = stringTokenizer.GetTokenCount() - DEPTH;
2015         if (depthCount <= INIT_VALUE)
2016         {
2017                 AppLogDebug("EXIT");
2018                 return fullFilePath;
2019         }
2020
2021         String folderPath(L".");
2022         int iLoopCount = 0;
2023         while (stringTokenizer.HasMoreTokens())
2024         {
2025                 String token;
2026                 stringTokenizer.GetNextToken(token);
2027                 if (iLoopCount >= depthCount)
2028                 {
2029                         folderPath.Append(IDS_SEPARATOR_SLASH);
2030                         folderPath.Append(token);
2031                 }
2032                 iLoopCount++;
2033         }
2034
2035         AppLogDebug("EXIT");
2036         return folderPath;
2037 }