2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 // Licensed under the Flora License, Version 1.1 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
8 // http://floralicense.org/license/
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an AS IS BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
18 * @file StLanguageAndRegionForm.cpp
19 * @brief This is the implementation file for LocaleForm class.
23 #include "StLanguageAndRegionForm.h"
24 #include "StResourceManager.h"
25 #include "StSettingScenesList.h"
28 using namespace Tizen::App;
29 using namespace Tizen::Base;
30 using namespace Tizen::Base::Collection;
31 using namespace Tizen::Base::Utility;
32 using namespace Tizen::Graphics;
33 using namespace Tizen::Locales;
34 using namespace Tizen::System;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37 using namespace Tizen::Ui::Scenes;
39 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN = 0;
40 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT = 2;
41 static const int ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE = 0;
42 static const int ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION = 1;
44 static const int ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT = 1;
46 static const int ID_GROUP_KEYBOARD = 2;
47 static const int ID_ITEM_KEYBOARD = 0;
48 static const int ID_GROUP_KEYBOARD_ITEM_COUNT = 1;
50 static const int ID_GROUP_COUNT = 3;
51 static const int ID_GROUP_MAX_ITEM_COUNT = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
52 static const int H_HELP_TEXT_GAP = 4;
54 static const int ID_GROUP_LANGUAGE_ITEM_COUNT = 51;
55 static const int DEFAULT_COUNT = 1;
56 static const int FIRST_CONTROL = 0;
57 static const int SECOND_CONTROL = 1;
58 static const int REFRESH_GROUP_ITEM_INDEX = -1;
59 static const int MAIN_TEXT_WIDTH_GAP = 32;
61 static const int NUMBER_TEXT_HEIGHT_GAP = 5;
63 static const long DEFAULT_INPUT_NUMBER = 123456789;
65 static const wchar_t* languageCode[ID_GROUP_LANGUAGE_ITEM_COUNT] =
123 LocaleForm::LocaleForm(void)
124 : __languageDataList(null)
125 , __isRunningAppControl(false)
129 LocaleForm::~LocaleForm(void)
135 LocaleForm::InitLanguageList(void)
142 if (__languageDataList != null)
144 delete __languageDataList;
145 __languageDataList = null;
148 __languageDataList = new (std::nothrow) ArrayList(SingleObjectDeleter);
149 __languageDataList->Construct();
153 key = languageCode[i++];
154 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARABIC");
155 data.Append(displayName + L"/" + key);
156 __languageDataList->Add(*(new (std::nothrow) String(data)));
160 key = languageCode[i++];
161 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_AZERBAIJANI");
162 data.Append(displayName + L"/" + key);
163 __languageDataList->Add(*(new (std::nothrow) String(data)));
167 key = languageCode[i++];
168 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BULGARIAN");
169 data.Append(displayName + L"/" + key);
170 __languageDataList->Add(*(new (std::nothrow) String(data)));
174 key = languageCode[i++];
175 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_CATALAN");
176 data.Append(displayName + L"/" + key);
177 __languageDataList->Add(*(new (std::nothrow) String(data)));
181 key = languageCode[i++];
182 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CZECH");
183 data.Append(displayName + L"/" + key);
184 __languageDataList->Add(*(new (std::nothrow) String(data)));
188 key = languageCode[i++];
189 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DANISH");
190 data.Append(displayName + L"/" + key);
191 __languageDataList->Add(*(new (std::nothrow) String(data)));
195 key = languageCode[i++];
196 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GERMAN");
197 data.Append(displayName + L"/" + key);
198 __languageDataList->Add(*(new (std::nothrow) String(data)));
202 key = languageCode[i++];
203 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_GREEK");
204 data.Append(displayName + L"/" + key);
205 __languageDataList->Add(*(new (std::nothrow) String(data)));
209 key = languageCode[i++];
210 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_KINGDOM");
211 data.Append(displayName + L"/" + key);
212 __languageDataList->Add(*(new (std::nothrow) String(data)));
216 key = languageCode[i++];
217 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_ENGLISH");
218 displayName.Append(L" (");
219 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_PHILIPPINES"));
220 displayName.Append(L")");
221 data.Append(displayName + L"/" + key);
222 __languageDataList->Add(*(new (std::nothrow) String(data)));
226 key = languageCode[i++];
227 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ENGLISH_HUNITED_STATES");
228 data.Append(displayName + L"/" + key);
229 __languageDataList->Add(*(new (std::nothrow) String(data)));
233 key = languageCode[i++];
234 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ESTONIAN");
235 data.Append(displayName + L"/" + key);
236 __languageDataList->Add(*(new (std::nothrow) String(data)));
240 key = languageCode[i++];
241 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_BASQUE");
242 data.Append(displayName + L"/" + key);
243 __languageDataList->Add(*(new (std::nothrow) String(data)));
247 key = languageCode[i++];
248 displayName = ResourceManager::GetString(L"IDS_IME_BODY_FARSI");
249 data.Append(displayName + L"/" + key);
250 __languageDataList->Add(*(new (std::nothrow) String(data)));
254 key = languageCode[i++];
255 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FINNISH");
256 data.Append(displayName + L"/" + key);
257 __languageDataList->Add(*(new (std::nothrow) String(data)));
261 key = languageCode[i++];
262 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
263 displayName.Append(L" (");
264 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_CANADA"));
265 displayName.Append(L")");
266 data.Append(displayName + L"/" + key);
267 __languageDataList->Add(*(new (std::nothrow) String(data)));
271 key = languageCode[i++];
272 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_FRENCH");
273 data.Append(displayName + L"/" + key);
274 __languageDataList->Add(*(new (std::nothrow) String(data)));
278 key = languageCode[i++];
279 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_IRISH");
280 data.Append(displayName + L"/" + key);
281 __languageDataList->Add(*(new (std::nothrow) String(data)));
285 key = languageCode[i++];
286 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GALICIAN");
287 data.Append(displayName + L"/" + key);
288 __languageDataList->Add(*(new (std::nothrow) String(data)));
292 key = languageCode[i++];
293 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_HINDI");
294 data.Append(displayName + L"/" + key);
295 __languageDataList->Add(*(new (std::nothrow) String(data)));
299 key = languageCode[i++];
300 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_CROATIAN");
301 data.Append(displayName + L"/" + key);
302 __languageDataList->Add(*(new (std::nothrow) String(data)));
306 key = languageCode[i++];
307 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_HUNGARIAN");
308 data.Append(displayName + L"/" + key);
309 __languageDataList->Add(*(new (std::nothrow) String(data)));
313 key = languageCode[i++];
314 displayName = ResourceManager::GetString(L"IDS_IME_BODY_ARMENIAN");
315 data.Append(displayName + L"/" + key);
316 __languageDataList->Add(*(new (std::nothrow) String(data)));
320 key = languageCode[i++];
321 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ICELANDIC");
322 data.Append(displayName + L"/" + key);
323 __languageDataList->Add(*(new (std::nothrow) String(data)));
327 key = languageCode[i++];
328 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_ITALIAN");
329 data.Append(displayName + L"/" + key);
330 __languageDataList->Add(*(new (std::nothrow) String(data)));
334 key = languageCode[i++];
335 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_JAPANESE");
336 data.Append(displayName + L"/" + key);
337 __languageDataList->Add(*(new (std::nothrow) String(data)));
341 key = languageCode[i++];
342 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_GEORGIAN");
343 data.Append(displayName + L"/" + key);
344 __languageDataList->Add(*(new (std::nothrow) String(data)));
348 key = languageCode[i++];
349 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KAZAKH");
350 data.Append(displayName + L"/" + key);
351 __languageDataList->Add(*(new (std::nothrow) String(data)));
355 key = languageCode[i++];
356 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_KOREAN");
357 data.Append(displayName + L"/" + key);
358 __languageDataList->Add(*(new (std::nothrow) String(data)));
362 key = languageCode[i++];
363 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LATVIAN");
364 data.Append(displayName + L"/" + key);
365 __languageDataList->Add(*(new (std::nothrow) String(data)));
369 key = languageCode[i++];
370 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_LITHUANIAN");
371 data.Append(displayName + L"/" + key);
372 __languageDataList->Add(*(new (std::nothrow) String(data)));
376 key = languageCode[i++];
377 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_MACEDONIAN");
378 data.Append(displayName + L"/" + key);
379 __languageDataList->Add(*(new (std::nothrow) String(data)));
383 key = languageCode[i++];
384 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_DUTCH");
385 data.Append(displayName + L"/" + key);
386 __languageDataList->Add(*(new (std::nothrow) String(data)));
390 key = languageCode[i++];
391 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_NORWEGIAN");
392 data.Append(displayName + L"/" + key);
393 __languageDataList->Add(*(new (std::nothrow) String(data)));
397 key = languageCode[i++];
398 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_POLISH");
399 data.Append(displayName + L"/" + key);
400 __languageDataList->Add(*(new (std::nothrow) String(data)));
404 key = languageCode[i++];
405 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
406 displayName.Append(L" (");
407 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_BRAZIL"));
408 displayName.Append(L")");
409 data.Append(displayName + L"/" + key);
410 __languageDataList->Add(*(new (std::nothrow) String(data)));
414 key = languageCode[i++];
415 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_PORTUGUESE");
416 data.Append(displayName + L"/" + key);
417 __languageDataList->Add(*(new (std::nothrow) String(data)));
421 key = languageCode[i++];
422 displayName = ResourceManager::GetString(L"IDS_IME_BODY_LANG_ROMANIAN");
423 data.Append(displayName + L"/" + key);
424 __languageDataList->Add(*(new (std::nothrow) String(data)));
428 key = languageCode[i++];
429 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_RUSSIAN");
430 data.Append(displayName + L"/" + key);
431 __languageDataList->Add(*(new (std::nothrow) String(data)));
435 key = languageCode[i++];
436 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SLOVAK");
437 data.Append(displayName + L"/" + key);
438 __languageDataList->Add(*(new (std::nothrow) String(data)));
442 key = languageCode[i++];
443 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SLOVENIAN");
444 data.Append(displayName + L"/" + key);
445 __languageDataList->Add(*(new (std::nothrow) String(data)));
449 key = languageCode[i++];
450 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
451 data.Append(displayName + L"/" + key);
452 __languageDataList->Add(*(new (std::nothrow) String(data)));
456 key = languageCode[i++];
457 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_SPANISH");
458 displayName.Append(L" (");
459 displayName.Append(ResourceManager::GetString(L"IDS_WCL_BODY_MEXICO"));
460 displayName.Append(L")");
461 data.Append(displayName + L"/" + key);
462 __languageDataList->Add(*(new (std::nothrow) String(data)));
466 key = languageCode[i++];
467 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SERBIAN");
468 data.Append(displayName + L"/" + key);
469 __languageDataList->Add(*(new (std::nothrow) String(data)));
473 key = languageCode[i++];
474 displayName = ResourceManager::GetString(L"IDS_IME_POP_LANG_SWEDISH");
475 data.Append(displayName + L"/" + key);
476 __languageDataList->Add(*(new (std::nothrow) String(data)));
480 key = languageCode[i++];
481 displayName = ResourceManager::GetString(L"IDS_IME_BODY_THAI");
482 data.Append(displayName + L"/" + key);
483 __languageDataList->Add(*(new (std::nothrow) String(data)));
487 key = languageCode[i++];
488 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_TURKISH");
489 data.Append(displayName + L"/" + key);
490 __languageDataList->Add(*(new (std::nothrow) String(data)));
494 key = languageCode[i++];
495 displayName = ResourceManager::GetString(L"IDS_IME_OPT_LANG_UKRAINIAN");
496 data.Append(displayName + L"/" + key);
497 __languageDataList->Add(*(new (std::nothrow) String(data)));
501 key = languageCode[i++];
502 displayName = ResourceManager::GetString(L"IDS_IME_BODY_URDU");
503 data.Append(displayName + L"/" + key);
504 __languageDataList->Add(*(new (std::nothrow) String(data)));
508 key = languageCode[i++];
509 displayName = ResourceManager::GetString(L"IDS_IME_BODY_UZBEK");
510 data.Append(displayName + L"/" + key);
511 __languageDataList->Add(*(new (std::nothrow) String(data)));
515 key = languageCode[i++];
516 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SIMPLIFIED");
517 data.Append(displayName + L"/" + key);
518 __languageDataList->Add(*(new (std::nothrow) String(data)));
522 key = languageCode[i++];
523 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_HONGKONG");
524 data.Append(displayName + L"/" + key);
525 __languageDataList->Add(*(new (std::nothrow) String(data)));
529 key = languageCode[i++];
530 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_SINGAPORE");
531 data.Append(displayName + L"/" + key);
532 __languageDataList->Add(*(new (std::nothrow) String(data)));
536 key = languageCode[i++];
537 displayName = ResourceManager::GetString(L"IDS_IME_BODY_CHINESE_TRADITIONAL_TAIWAN");
538 data.Append(displayName + L"/" + key);
539 __languageDataList->Add(*(new (std::nothrow) String(data)));
543 LocaleForm::CreateFooter(void)
545 Footer* pFooter = GetFooter();
548 pFooter->SetStyle(FOOTER_STYLE_BUTTON_TEXT);
549 pFooter->AddActionEventListener(*this);
551 SetFormBackEventListener(this);
555 LocaleForm::OnInitializing(void)
558 CreateHeader(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
561 AppLogDebug("ENTER");
567 LocaleForm::OnTerminating(void)
571 SetFormBackEventListener(null);
576 LocaleForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
579 Header* pHeader = GetHeader();
580 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
582 if (previousSceneId.Equals(IDSCN_LOCALE_LANGUAGE, false))
586 __pTableView->Draw();
587 RefreshTableViewItem();
591 LocaleForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
596 LocaleForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
598 if (__isRunningAppControl)
600 AppLogDebug("busy status");
603 SceneManager* pSceneManager = SceneManager::GetInstance();
604 AppAssert(pSceneManager);
606 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
610 LocaleForm::GetGroupCount(void)
612 AppLogDebug("ENTER");
613 return ID_GROUP_COUNT;
617 LocaleForm::GetItemCount(int groupIndex)
623 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
625 itemCount = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
629 case ID_GROUP_KEYBOARD:
631 itemCount = ID_GROUP_KEYBOARD_ITEM_COUNT;
638 AppLogDebug("GetItemCount %d", itemCount);
644 LocaleForm::CreateGroupItem(int groupIndex, int itemWidth)
646 AppLogDebug("ENTER");
648 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
649 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
650 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
651 Rectangle itemMainRectangle;
656 Label* pLabel = null;
657 int fontSize = GetFontSize();
660 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
664 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
666 String formattedString;
668 long inputNumber = DEFAULT_INPUT_NUMBER;
670 LocaleManager localeManager;
671 localeManager.Construct();
673 Locale systemLocale = localeManager.GetSystemLocale();
674 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
675 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
678 SystemTime::GetCurrentTime(TIME_MODE_WALL, dateTime);
680 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
681 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
682 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
683 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
687 tmpHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
688 itemHeight += tmpHeight;
691 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
693 pDateFormatter->ApplyPattern(localPattern);
697 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
699 pDateFormatter->Format(dateTime, formattedString);
700 formattedString = dateText + L" : " + formattedString;
701 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
703 tmpText.Insert(formattedString, tmpText.GetLength());
704 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
705 tmpText.Remove(0, tmpText.GetLength());
706 itemHeight += tmpHeight;
708 formattedString.Remove(0, formattedString.GetLength());
709 bool timeFormat = false;
710 pDateFormatter->ApplyPattern("hh:mm aa");
711 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
713 if (timeFormat == true)
715 pDateFormatter->ApplyPattern("HH:mm");
718 pDateFormatter->Format(dateTime, formattedString);
719 formattedString = timeText + L" : " + formattedString;
720 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
722 tmpText.Insert(formattedString, tmpText.GetLength());
723 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
724 tmpText.Remove(0, tmpText.GetLength());
725 itemHeight += tmpHeight;
727 formattedString.Remove(0, formattedString.GetLength());
728 pNumberFormatter->Format(inputNumber, formattedString);
729 groupText.Insert(L"\n" + numberText + L" : " + formattedString, groupText.GetLength());
731 tmpText.Insert(formattedString, tmpText.GetLength());
734 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
735 tmpText.Remove(0, tmpText.GetLength());
738 tmpHeight = (lineCount + 1) * lineHeight;
742 formattedString = numberText + L" : " + formattedString;
743 tmpText.Remove(0, tmpText.GetLength());
744 tmpText.Insert(formattedString, tmpText.GetLength());
745 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
747 itemHeight += tmpHeight;
749 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
761 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
762 itemMainRectangle.y = yItemOffset;
763 itemMainRectangle.width = itemWidth;
764 itemMainRectangle.height = itemHeight;
766 RelativeLayout relativeLayout;
767 relativeLayout.Construct();
769 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
770 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
772 pLabel = new (std::nothrow) Label();
773 pLabel->Construct(itemMainRectangle, groupText);
774 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
775 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
776 pLabel->SetTextConfig(fontSize, style);
777 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
779 pItem->AddControl(pLabel);
780 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
781 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
782 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
783 pItem->SetEnabled(false);
789 LocaleForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
791 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
792 bool isItemSubText = false;
793 Rectangle itemMainRectangle;
794 Rectangle itemSubRectangle;
795 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
798 String systemLocaleString;
799 Label* pLabel = null;
800 int fontSize = GetFontSize();
801 LocaleManager localeManager;
802 localeManager.Construct();
803 Locale locale = localeManager.GetSystemLocale();
804 int itemHeight = H_GROUP_ITEM_DEFAULT;
808 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
810 isItemSubText = true;
814 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
816 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
817 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
819 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
823 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
825 if (itemSubText.Equals(languageCode[i], false))
827 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
829 StringTokenizer stringTokenizer(*pKey, L"/");
830 stringTokenizer.GetNextToken(itemSubText);
838 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
840 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
841 String localeLanguage;
842 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
844 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
845 localeLanguage = L"eng_GB";
848 LanguageCode langCode = LANGUAGE_INVALID;
849 CountryCode countryCode = COUNTRY_INVALID;
850 StringTokenizer strTok(localeLanguage, L"_");
853 if (strTok.HasMoreTokens())
855 strTok.GetNextToken(token);
856 langCode = Locale::StringToLanguageCode(token);
859 if (strTok.HasMoreTokens())
861 strTok.GetNextToken(token);
862 countryCode = Locale::StringToCountryCode(token);
865 Locale currentLocale(langCode, countryCode);
867 locale.GetLanguageName(currentLocale, systemLocaleString);
868 itemSubText.Append(systemLocaleString + L" (");
869 systemLocaleString.Remove(0, systemLocaleString.GetLength());
871 locale.GetCountryName(currentLocale, systemLocaleString);
872 itemSubText.Append(systemLocaleString + L")");
873 systemLocaleString.Remove(0, systemLocaleString.GetLength());
883 case ID_GROUP_KEYBOARD:
885 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
893 ItemTypeOneLine(itemMainRectangle);
895 TableViewItem* pItem = new (std::nothrow) TableViewItem();
897 if (isItemSubText == true)
899 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
900 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
901 RelativeLayout relativeLayout;
902 relativeLayout.Construct();
904 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
905 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
907 pLabel = new (std::nothrow) Label();
908 pLabel->Construct(itemMainRectangle, itemMainText);
909 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
910 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
911 pLabel->SetTextColor(COLOR_MAIN_TEXT);
913 pItem->AddControl(pLabel);
914 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
915 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
916 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
918 pLabel = new (std::nothrow) Label();
919 pLabel->Construct(itemSubRectangle, itemSubText);
920 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
921 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
922 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
923 pLabel->SetTextColor(COLOR_SUB_TEXT);
925 pItem->AddControl(pLabel);
926 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
927 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
928 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
932 RelativeLayout relativeLayout;
933 relativeLayout.Construct();
935 pItem->Construct(relativeLayout, Dimension(W_GROUP_ITEM_DEFAULT, H_GROUP_ITEM_DEFAULT), style);
936 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
938 pLabel = new (std::nothrow) Label();
939 pLabel->Construct(itemMainRectangle, itemMainText);
940 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
941 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
942 pLabel->SetTextColor(COLOR_MAIN_TEXT);
944 pItem->AddControl(pLabel);
945 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
946 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
947 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
954 LocaleForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
956 AppLogDebug("ENTER");
965 LocaleForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
967 AppLogDebug("ENTER");
976 LocaleForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
978 if (__isRunningAppControl == true)
983 SceneManager* pSceneManager = SceneManager::GetInstance();
984 AppAssert(pSceneManager);
986 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
990 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
992 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
994 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
996 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
998 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1003 case ID_GROUP_KEYBOARD:
1006 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1008 if (AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/setting/ime", null, null, null, null, null) == E_SUCCESS)
1010 __isRunningAppControl = true;
1022 LocaleForm::GetDefaultGroupItemHeight(void)
1024 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1028 LocaleForm::GetDefaultItemHeight(void)
1030 return H_GROUP_ITEM_DEFAULT;
1034 LocaleForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1038 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
1040 Rectangle pItemBounds = pItem->GetBounds();
1041 Rectangle pBounds = GetClientAreaBounds();
1042 Label* pGroupLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1043 int labelWidth = pItemBounds.width - MAIN_TEXT_WIDTH_GAP;
1049 String formattedString;
1050 String numberFormat;
1052 long inputNumber = DEFAULT_INPUT_NUMBER;
1055 int fontSize = GetFontSize();
1057 LocaleManager localeManager;
1058 localeManager.Construct();
1060 Locale systemLocale = localeManager.GetSystemLocale();
1061 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
1062 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
1065 SystemTime::GetCurrentTime(TIME_MODE_WALL, dateTime);
1067 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
1068 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
1069 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
1070 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
1076 tempHeight = GetLineheight(groupText, labelWidth, fontSize, lineCount, lineHeight);
1077 itemHeight += tempHeight;
1079 String localPattern;
1080 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
1082 pDateFormatter->ApplyPattern(localPattern);
1086 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
1088 pDateFormatter->Format(dateTime, formattedString);
1089 formattedString = dateText + L" : " + formattedString;
1090 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1092 tmpText.Remove(0, tmpText.GetLength());
1093 tmpText.Insert(formattedString, tmpText.GetLength());
1094 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1095 itemHeight += tempHeight;
1097 formattedString.Remove(0, formattedString.GetLength());
1098 bool timeFormat = false;
1099 pDateFormatter->ApplyPattern("hh:mm aa");
1100 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
1102 if (timeFormat == true)
1104 pDateFormatter->ApplyPattern("HH:mm");
1107 const wchar_t LRO = 0x202D; //Done changes for Nabi issue 48837 suggested by platform team
1108 const wchar_t LRE = 0x202A;
1109 const wchar_t PDF = 0x202C;
1110 pDateFormatter->Format(dateTime, formattedString);
1111 formattedString = timeText + L" : " + LRE + formattedString + PDF;
1112 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1114 tmpText.Remove(0, tmpText.GetLength());
1115 tmpText.Insert(formattedString, tmpText.GetLength());
1117 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1118 itemHeight += tempHeight;
1120 formattedString.Remove(0, formattedString.GetLength());
1121 pNumberFormatter->Format(inputNumber, formattedString);
1122 groupText.Insert(L"\n" + numberText + L" : " + LRE + formattedString + PDF, groupText.GetLength());
1124 tmpText.Remove(0, tmpText.GetLength());
1125 tmpText.Insert(formattedString, tmpText.GetLength());
1126 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1129 tempHeight = (lineCount + 1) * lineHeight;
1133 formattedString = numberText + L" : " + LRE + formattedString + PDF;
1134 tmpText.Remove(0, tmpText.GetLength());
1135 tmpText.Insert(formattedString, tmpText.GetLength());
1136 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1138 itemHeight += tempHeight;
1140 tmpText.Remove(0, tmpText.GetLength());
1142 pItemBounds.height = itemHeight + NUMBER_TEXT_HEIGHT_GAP;
1143 pItem->SetBounds(pItemBounds);
1144 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1145 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1146 pGroupLabel->SetText(groupText);
1147 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1148 pGroupLabel->Invalidate(false);
1149 pItem->Invalidate(false);
1159 LocaleForm::GetLineheight(Tizen::Base::String& src, int labelWidth, int fontSize, int& lineCount, int& lineHeight)
1164 font.Construct(FONT_STYLE_PLAIN, fontSize);
1165 font.GetTextExtent(src, src.GetLength(), dim);
1167 lineHeight = dim.height;
1168 if (dim.width > labelWidth)
1170 lineCount = (dim.width / labelWidth);
1172 if (dim.width % labelWidth)
1174 lineCount += DEFAULT_COUNT;
1179 lineCount = DEFAULT_COUNT;
1181 return (lineCount* dim.height);
1185 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1187 String firstLineText;
1190 Rectangle pItemBounds = pItem->GetBounds();
1191 Rectangle firstLineRect;
1192 Rectangle secondLineRect;
1194 Label* pFirstLabel = null;
1195 Label* pSecondLabel = null;
1197 int fontSize = GetFontSize();
1201 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1203 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1204 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1206 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1207 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1211 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1213 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1215 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1217 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1221 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1223 if (itemSubText.Equals(languageCode[i], false))
1225 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1227 StringTokenizer stringTokenizer(*pKey, L"/");
1228 stringTokenizer.GetNextToken(itemSubText);
1233 pItem->SetBounds(pItemBounds);
1234 pFirstLabel->SetText(firstLineText);
1235 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1237 pSecondLabel->SetText(itemSubText);
1238 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1240 pFirstLabel->Invalidate(false);
1241 pSecondLabel->Invalidate(false);
1242 pItem->Invalidate(false);
1246 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1248 LocaleManager localeManager;
1249 localeManager.Construct();
1250 Locale locale = localeManager.GetSystemLocale();
1251 String systemLocaleString;
1253 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1255 String localeLanguage;
1256 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1258 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1259 localeLanguage = L"eng_GB";
1262 LanguageCode langCode = LANGUAGE_INVALID;
1263 CountryCode countryCode = COUNTRY_INVALID;
1264 StringTokenizer strTok(localeLanguage, L"_");
1267 if (strTok.HasMoreTokens())
1269 strTok.GetNextToken(token);
1270 langCode = Locale::StringToLanguageCode(token);
1273 if (strTok.HasMoreTokens())
1275 strTok.GetNextToken(token);
1276 countryCode = Locale::StringToCountryCode(token);
1279 Locale currentLocale(langCode, countryCode);
1281 locale.GetLanguageName(currentLocale, systemLocaleString);
1282 itemSubText.Append(systemLocaleString + L" (");
1283 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1285 locale.GetCountryName(currentLocale, systemLocaleString);
1286 itemSubText.Append(systemLocaleString + L")");
1287 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1289 pItem->SetBounds(pItemBounds);
1290 pFirstLabel->SetText(firstLineText);
1291 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1293 pSecondLabel->SetText(itemSubText);
1294 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1296 pFirstLabel->Invalidate(false);
1297 pSecondLabel->Invalidate(false);
1298 pItem->Invalidate(false);
1308 case ID_GROUP_KEYBOARD:
1310 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1312 ItemTypeOneLine(firstLineRect);
1313 pItemBounds.height = firstLineRect.height;
1315 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1316 pItem->SetBounds(pItemBounds);
1317 pFirstLabel->SetText(firstLineText);
1318 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1319 pFirstLabel->Invalidate(false);
1320 pItem->Invalidate(false);
1330 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1335 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1340 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1342 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1344 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1346 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1351 LocaleForm::RefreshTableViewItem(void)
1353 if (__pTableView == null)
1358 int groupCount = __pTableView->GetGroupCount();
1360 for (int index = 0; index < groupCount; index++)
1362 RefreshTableViewGroupItem(index);
1367 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1369 RefreshTableViewItem();
1374 LocaleForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1376 if (requestId == REFRESH_REQUEST_EVENT)
1379 __isRunningAppControl = false;