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)
578 Header* pHeader = GetHeader();
579 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
581 if (previousSceneId.Equals(IDSCN_LOCALE_LANGUAGE, false))
585 __pTableView->Draw();
586 RefreshTableViewItem();
590 LocaleForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
595 LocaleForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
597 if (__isRunningAppControl)
599 AppLogDebug("busy status");
602 SceneManager* pSceneManager = SceneManager::GetInstance();
603 AppAssert(pSceneManager);
605 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
609 LocaleForm::GetGroupCount(void)
611 AppLogDebug("ENTER");
612 return ID_GROUP_COUNT;
616 LocaleForm::GetItemCount(int groupIndex)
622 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
624 itemCount = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
628 case ID_GROUP_KEYBOARD:
630 itemCount = ID_GROUP_KEYBOARD_ITEM_COUNT;
637 AppLogDebug("GetItemCount %d", itemCount);
643 LocaleForm::CreateGroupItem(int groupIndex, int itemWidth)
645 AppLogDebug("ENTER");
647 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
648 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
649 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
650 Rectangle itemMainRectangle;
655 Label* pLabel = null;
656 int fontSize = GetFontSize();
659 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
663 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
665 String formattedString;
667 long inputNumber = DEFAULT_INPUT_NUMBER;
669 LocaleManager localeManager;
670 localeManager.Construct();
672 Locale systemLocale = localeManager.GetSystemLocale();
673 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
674 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
677 SystemTime::GetCurrentTime(TIME_MODE_WALL, dateTime);
679 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
680 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
681 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
682 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
686 tmpHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
687 itemHeight += tmpHeight;
690 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
692 pDateFormatter->ApplyPattern(localPattern);
696 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
698 pDateFormatter->Format(dateTime, formattedString);
699 formattedString = dateText + L" : " + formattedString;
700 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
702 tmpText.Insert(formattedString, tmpText.GetLength());
703 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
704 tmpText.Remove(0, tmpText.GetLength());
705 itemHeight += tmpHeight;
707 formattedString.Remove(0, formattedString.GetLength());
708 bool timeFormat = false;
709 pDateFormatter->ApplyPattern("hh:mm aa");
710 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
712 if (timeFormat == true)
714 pDateFormatter->ApplyPattern("HH:mm");
717 pDateFormatter->Format(dateTime, formattedString);
718 formattedString = timeText + L" : " + formattedString;
719 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
721 tmpText.Insert(formattedString, tmpText.GetLength());
722 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
723 tmpText.Remove(0, tmpText.GetLength());
724 itemHeight += tmpHeight;
726 formattedString.Remove(0, formattedString.GetLength());
727 pNumberFormatter->Format(inputNumber, formattedString);
728 groupText.Insert(L"\n" + numberText + L" : " + formattedString, groupText.GetLength());
730 tmpText.Insert(formattedString, tmpText.GetLength());
733 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
734 tmpText.Remove(0, tmpText.GetLength());
737 tmpHeight = (lineCount + 1) * lineHeight;
741 formattedString = numberText + L" : " + formattedString;
742 tmpText.Remove(0, tmpText.GetLength());
743 tmpText.Insert(formattedString, tmpText.GetLength());
744 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
746 itemHeight += tmpHeight;
748 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
760 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
761 itemMainRectangle.y = yItemOffset;
762 itemMainRectangle.width = itemWidth;
763 itemMainRectangle.height = itemHeight;
765 RelativeLayout relativeLayout;
766 relativeLayout.Construct();
768 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
769 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
771 pLabel = new (std::nothrow) Label();
772 pLabel->Construct(itemMainRectangle, groupText);
773 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
774 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
775 pLabel->SetTextConfig(fontSize, style);
776 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
778 pItem->AddControl(pLabel);
779 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
780 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
781 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
782 pItem->SetEnabled(false);
788 LocaleForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
790 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
791 bool isItemSubText = false;
792 Rectangle itemMainRectangle;
793 Rectangle itemSubRectangle;
794 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
797 String systemLocaleString;
798 Label* pLabel = null;
799 int fontSize = GetFontSize();
800 LocaleManager localeManager;
801 localeManager.Construct();
802 Locale locale = localeManager.GetSystemLocale();
803 int itemHeight = H_GROUP_ITEM_DEFAULT;
807 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
809 isItemSubText = true;
813 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
815 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
816 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
818 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
822 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
824 if (itemSubText.Equals(languageCode[i], false))
826 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
828 StringTokenizer stringTokenizer(*pKey, L"/");
829 stringTokenizer.GetNextToken(itemSubText);
837 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
839 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
840 String localeLanguage;
841 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
843 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
844 localeLanguage = L"eng_GB";
847 LanguageCode langCode = LANGUAGE_INVALID;
848 CountryCode countryCode = COUNTRY_INVALID;
849 StringTokenizer strTok(localeLanguage, L"_");
852 if (strTok.HasMoreTokens())
854 strTok.GetNextToken(token);
855 langCode = Locale::StringToLanguageCode(token);
858 if (strTok.HasMoreTokens())
860 strTok.GetNextToken(token);
861 countryCode = Locale::StringToCountryCode(token);
864 Locale currentLocale(langCode, countryCode);
866 locale.GetLanguageName(currentLocale, systemLocaleString);
867 itemSubText.Append(systemLocaleString + L" (");
868 systemLocaleString.Remove(0, systemLocaleString.GetLength());
870 locale.GetCountryName(currentLocale, systemLocaleString);
871 itemSubText.Append(systemLocaleString + L")");
872 systemLocaleString.Remove(0, systemLocaleString.GetLength());
882 case ID_GROUP_KEYBOARD:
884 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
892 ItemTypeOneLine(itemMainRectangle);
894 TableViewItem* pItem = new (std::nothrow) TableViewItem();
896 if (isItemSubText == true)
898 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
899 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
900 RelativeLayout relativeLayout;
901 relativeLayout.Construct();
903 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
904 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
906 pLabel = new (std::nothrow) Label();
907 pLabel->Construct(itemMainRectangle, itemMainText);
908 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
909 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
910 pLabel->SetTextColor(COLOR_MAIN_TEXT);
912 pItem->AddControl(pLabel);
913 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
914 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
915 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
917 pLabel = new (std::nothrow) Label();
918 pLabel->Construct(itemSubRectangle, itemSubText);
919 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
920 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
921 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
922 pLabel->SetTextColor(COLOR_SUB_TEXT);
924 pItem->AddControl(pLabel);
925 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
926 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
927 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
931 RelativeLayout relativeLayout;
932 relativeLayout.Construct();
934 pItem->Construct(relativeLayout, Dimension(W_GROUP_ITEM_DEFAULT, H_GROUP_ITEM_DEFAULT), style);
935 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
937 pLabel = new (std::nothrow) Label();
938 pLabel->Construct(itemMainRectangle, itemMainText);
939 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
940 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
941 pLabel->SetTextColor(COLOR_MAIN_TEXT);
943 pItem->AddControl(pLabel);
944 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
945 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
946 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
953 LocaleForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
955 AppLogDebug("ENTER");
964 LocaleForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
966 AppLogDebug("ENTER");
975 LocaleForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
977 if (__isRunningAppControl == true)
982 SceneManager* pSceneManager = SceneManager::GetInstance();
983 AppAssert(pSceneManager);
985 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
989 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
991 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
993 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
995 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
997 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1002 case ID_GROUP_KEYBOARD:
1005 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1007 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 pDateFormatter->Format(dateTime, formattedString);
1108 formattedString = timeText + L" : " + formattedString;
1109 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1111 tmpText.Remove(0, tmpText.GetLength());
1112 tmpText.Insert(formattedString, tmpText.GetLength());
1114 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1115 itemHeight += tempHeight;
1117 formattedString.Remove(0, formattedString.GetLength());
1118 pNumberFormatter->Format(inputNumber, formattedString);
1119 groupText.Insert(L"\n" + numberText + L" : " + formattedString, groupText.GetLength());
1121 tmpText.Remove(0, tmpText.GetLength());
1122 tmpText.Insert(formattedString, tmpText.GetLength());
1123 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1126 tempHeight = (lineCount + 1) * lineHeight;
1130 formattedString = numberText + L" : " + formattedString;
1131 tmpText.Remove(0, tmpText.GetLength());
1132 tmpText.Insert(formattedString, tmpText.GetLength());
1133 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1135 itemHeight += tempHeight;
1137 tmpText.Remove(0, tmpText.GetLength());
1139 pItemBounds.height = itemHeight + NUMBER_TEXT_HEIGHT_GAP;
1140 pItem->SetBounds(pItemBounds);
1141 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1142 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1143 pGroupLabel->SetText(groupText);
1144 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1145 pGroupLabel->Invalidate(false);
1146 pItem->Invalidate(false);
1156 LocaleForm::GetLineheight(Tizen::Base::String& src, int labelWidth, int fontSize, int& lineCount, int& lineHeight)
1161 font.Construct(FONT_STYLE_PLAIN, fontSize);
1162 font.GetTextExtent(src, src.GetLength(), dim);
1164 lineHeight = dim.height;
1165 if (dim.width > labelWidth)
1167 lineCount = (dim.width / labelWidth);
1169 if (dim.width % labelWidth)
1171 lineCount += DEFAULT_COUNT;
1176 lineCount = DEFAULT_COUNT;
1178 return (lineCount* dim.height);
1182 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1184 String firstLineText;
1187 Rectangle pItemBounds = pItem->GetBounds();
1188 Rectangle firstLineRect;
1189 Rectangle secondLineRect;
1191 Label* pFirstLabel = null;
1192 Label* pSecondLabel = null;
1194 int fontSize = GetFontSize();
1198 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1200 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1201 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1203 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1204 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1208 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1210 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1212 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1214 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1218 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1220 if (itemSubText.Equals(languageCode[i], false))
1222 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1224 StringTokenizer stringTokenizer(*pKey, L"/");
1225 stringTokenizer.GetNextToken(itemSubText);
1230 pItem->SetBounds(pItemBounds);
1231 pFirstLabel->SetText(firstLineText);
1232 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1234 pSecondLabel->SetText(itemSubText);
1235 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1237 pFirstLabel->Invalidate(false);
1238 pSecondLabel->Invalidate(false);
1239 pItem->Invalidate(false);
1243 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1245 LocaleManager localeManager;
1246 localeManager.Construct();
1247 Locale locale = localeManager.GetSystemLocale();
1248 String systemLocaleString;
1250 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1252 String localeLanguage;
1253 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1255 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1256 localeLanguage = L"eng_GB";
1259 LanguageCode langCode = LANGUAGE_INVALID;
1260 CountryCode countryCode = COUNTRY_INVALID;
1261 StringTokenizer strTok(localeLanguage, L"_");
1264 if (strTok.HasMoreTokens())
1266 strTok.GetNextToken(token);
1267 langCode = Locale::StringToLanguageCode(token);
1270 if (strTok.HasMoreTokens())
1272 strTok.GetNextToken(token);
1273 countryCode = Locale::StringToCountryCode(token);
1276 Locale currentLocale(langCode, countryCode);
1278 locale.GetLanguageName(currentLocale, systemLocaleString);
1279 itemSubText.Append(systemLocaleString + L" (");
1280 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1282 locale.GetCountryName(currentLocale, systemLocaleString);
1283 itemSubText.Append(systemLocaleString + L")");
1284 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1286 pItem->SetBounds(pItemBounds);
1287 pFirstLabel->SetText(firstLineText);
1288 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1290 pSecondLabel->SetText(itemSubText);
1291 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1293 pFirstLabel->Invalidate(false);
1294 pSecondLabel->Invalidate(false);
1295 pItem->Invalidate(false);
1305 case ID_GROUP_KEYBOARD:
1307 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1309 ItemTypeOneLine(firstLineRect);
1310 pItemBounds.height = firstLineRect.height;
1312 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1313 pItem->SetBounds(pItemBounds);
1314 pFirstLabel->SetText(firstLineText);
1315 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1316 pFirstLabel->Invalidate(false);
1317 pItem->Invalidate(false);
1327 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1332 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1337 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1339 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1341 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1343 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1348 LocaleForm::RefreshTableViewItem(void)
1350 if (__pTableView == null)
1355 int groupCount = __pTableView->GetGroupCount();
1357 for (int index = 0; index < groupCount; index++)
1359 RefreshTableViewGroupItem(index);
1364 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1366 RefreshTableViewItem();
1371 LocaleForm::OnUserEventReceivedN(RequestId requestId, Tizen::Base::Collection::IList* pArgs)
1373 if (requestId == REFRESH_REQUEST_EVENT)
1376 __isRunningAppControl = false;