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 AddFocusEventListener(*this);
563 AppLogDebug("ENTER");
569 LocaleForm::OnTerminating(void)
573 SetFormBackEventListener(null);
578 LocaleForm::OnSceneActivatedN(const Tizen::Ui::Scenes::SceneId& previousSceneId, const Tizen::Ui::Scenes::SceneId& currentSceneId, Tizen::Base::Collection::IList* pArgs)
580 Header* pHeader = GetHeader();
581 pHeader->SetTitleText(ResourceManager::GetString(L"IDS_ST_BODY_LANGUAGE_AND_KEYBOARD"));
583 if (previousSceneId.Equals(IDSCN_LOCALE_LANGUAGE, false))
587 __pTableView->Draw();
588 RefreshTableViewItem();
592 LocaleForm::OnSceneDeactivated(const Tizen::Ui::Scenes::SceneId& currentSceneId, const Tizen::Ui::Scenes::SceneId& nextSceneId)
597 LocaleForm::OnFormBackRequested(Tizen::Ui::Controls::Form& source)
599 SceneManager* pSceneManager = SceneManager::GetInstance();
600 AppAssert(pSceneManager);
602 pSceneManager->GoBackward(BackwardSceneTransition(SCENE_TRANSITION_ANIMATION_TYPE_RIGHT), null);
606 LocaleForm::GetGroupCount(void)
608 AppLogDebug("ENTER");
609 return ID_GROUP_COUNT;
613 LocaleForm::GetItemCount(int groupIndex)
619 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
621 itemCount = ID_GROUP_LANGUAGE_AND_REGION_MAIN_ITEM_COUNT;
625 case ID_GROUP_KEYBOARD:
627 itemCount = ID_GROUP_KEYBOARD_ITEM_COUNT;
634 AppLogDebug("GetItemCount %d", itemCount);
640 LocaleForm::CreateGroupItem(int groupIndex, int itemWidth)
642 AppLogDebug("ENTER");
644 int itemHeight = H_GROUP_INDEX_NO_TITLE_DEFAULT;
645 int yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
646 LabelTextStyle style = LABEL_TEXT_STYLE_NORMAL;
647 Rectangle itemMainRectangle;
652 Label* pLabel = null;
653 int fontSize = GetFontSize();
656 TableViewGroupItem* pItem = new (std::nothrow) TableViewGroupItem();
660 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
662 String formattedString;
664 long inputNumber = DEFAULT_INPUT_NUMBER;
666 LocaleManager localeManager;
667 localeManager.Construct();
669 Locale systemLocale = localeManager.GetSystemLocale();
670 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
671 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
674 SystemTime::GetCurrentTime(dateTime);
676 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
677 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
678 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
679 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
683 tmpHeight = GetHeightForStringArea(groupText, itemWidth, fontSize);
684 itemHeight += tmpHeight;
687 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
689 pDateFormatter->ApplyPattern(localPattern);
693 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
695 pDateFormatter->Format(dateTime, formattedString);
696 formattedString = dateText + L" : " + formattedString;
697 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
699 tmpText.Insert(formattedString, tmpText.GetLength());
700 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
701 tmpText.Remove(0, tmpText.GetLength());
702 itemHeight += tmpHeight;
704 formattedString.Remove(0, formattedString.GetLength());
705 bool timeFormat = false;
706 pDateFormatter->ApplyPattern("hh : mm aa");
707 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
709 if (timeFormat == true)
711 pDateFormatter->ApplyPattern("HH : mm");
714 pDateFormatter->Format(dateTime, formattedString);
715 formattedString = timeText + L" : " + formattedString;
716 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
718 tmpText.Insert(formattedString, tmpText.GetLength());
719 tmpHeight = GetHeightForStringArea(tmpText, itemWidth, fontSize);
720 tmpText.Remove(0, tmpText.GetLength());
721 itemHeight += tmpHeight;
723 formattedString.Remove(0, formattedString.GetLength());
724 pNumberFormatter->Format(inputNumber, formattedString);
725 groupText.Insert(L"\n" + numberText + L" : " + formattedString, groupText.GetLength());
727 tmpText.Insert(formattedString, tmpText.GetLength());
730 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
731 tmpText.Remove(0, tmpText.GetLength());
734 tmpHeight = (lineCount + 1) * lineHeight;
738 formattedString = numberText + L" : " + formattedString;
739 tmpText.Remove(0, tmpText.GetLength());
740 tmpText.Insert(formattedString, tmpText.GetLength());
741 tmpHeight = GetLineheight(tmpText, itemWidth, fontSize, lineCount, lineHeight);
743 itemHeight += tmpHeight;
745 yItemOffset = H_GROUP_INDEX_HELP_TEXT_TOP_GAP / DIVIDE_BY_TWO;
757 itemMainRectangle.x = X_GROUP_ITEM_DEFAULT_LABEL;
758 itemMainRectangle.y = yItemOffset;
759 itemMainRectangle.width = itemWidth;
760 itemMainRectangle.height = itemHeight;
762 RelativeLayout relativeLayout;
763 relativeLayout.Construct();
765 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight));
766 pItem->SetBackgroundColor(COLOR_BG_GROUP_INDEX_DEFAULT);
768 pLabel = new (std::nothrow) Label();
769 pLabel->Construct(itemMainRectangle, groupText);
770 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
771 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
772 pLabel->SetTextConfig(fontSize, style);
773 pLabel->SetTextColor(COLOR_HELP_TEXT_TYPE_01);
775 pItem->AddControl(pLabel);
776 relativeLayout.SetMargin(*pLabel, itemMainRectangle.x, 0, 0, 0);
777 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
778 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
779 pItem->SetEnabled(false);
785 LocaleForm::CreateItem(int groupIndex, int itemIndex, int itemWidth)
787 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
788 bool isItemSubText = false;
789 Rectangle itemMainRectangle;
790 Rectangle itemSubRectangle;
791 TableViewAnnexStyle style = TABLE_VIEW_ANNEX_STYLE_NORMAL;
794 String systemLocaleString;
795 Label* pLabel = null;
796 int fontSize = GetFontSize();
797 LocaleManager localeManager;
798 localeManager.Construct();
799 Locale locale = localeManager.GetSystemLocale();
800 int itemHeight = H_GROUP_ITEM_DEFAULT;
804 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
806 isItemSubText = true;
810 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
812 itemMainText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
813 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
815 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
819 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
821 if (itemSubText.Equals(languageCode[i], false))
823 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
825 StringTokenizer stringTokenizer(*pKey, L"/");
826 stringTokenizer.GetNextToken(itemSubText);
834 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
836 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
837 String localeLanguage;
838 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
840 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
841 localeLanguage = L"eng_GB";
844 LanguageCode langCode = LANGUAGE_INVALID;
845 CountryCode countryCode = COUNTRY_INVALID;
846 StringTokenizer strTok(localeLanguage, L"_");
849 if (strTok.HasMoreTokens())
851 strTok.GetNextToken(token);
852 langCode = Locale::StringToLanguageCode(token);
855 if (strTok.HasMoreTokens())
857 strTok.GetNextToken(token);
858 countryCode = Locale::StringToCountryCode(token);
861 Locale currentLocale(langCode, countryCode);
863 locale.GetLanguageName(currentLocale, systemLocaleString);
864 itemSubText.Append(systemLocaleString + L" (");
865 systemLocaleString.Remove(0, systemLocaleString.GetLength());
867 locale.GetCountryName(currentLocale, systemLocaleString);
868 itemSubText.Append(systemLocaleString + L")");
869 systemLocaleString.Remove(0, systemLocaleString.GetLength());
879 case ID_GROUP_KEYBOARD:
881 itemMainText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
889 ItemTypeOneLine(itemMainRectangle);
891 TableViewItem* pItem = new (std::nothrow) TableViewItem();
893 if (isItemSubText == true)
895 ItemTypeTwoLine(itemMainRectangle, itemSubRectangle, fontSize);
896 itemHeight = (itemMainRectangle.height + itemSubRectangle.height);
897 RelativeLayout relativeLayout;
898 relativeLayout.Construct();
900 pItem->Construct(relativeLayout, Dimension(itemWidth, itemHeight), style);
901 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
903 pLabel = new (std::nothrow) Label();
904 pLabel->Construct(itemMainRectangle, itemMainText);
905 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
906 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
907 pLabel->SetTextColor(COLOR_MAIN_TEXT);
909 pItem->AddControl(pLabel);
910 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
911 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
912 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
914 pLabel = new (std::nothrow) Label();
915 pLabel->Construct(itemSubRectangle, itemSubText);
916 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
917 pLabel->SetTextVerticalAlignment(ALIGNMENT_TOP);
918 pLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
919 pLabel->SetTextColor(COLOR_SUB_TEXT);
921 pItem->AddControl(pLabel);
922 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
923 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
924 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
928 RelativeLayout relativeLayout;
929 relativeLayout.Construct();
931 pItem->Construct(relativeLayout, Dimension(W_GROUP_ITEM_DEFAULT, H_GROUP_ITEM_DEFAULT), style);
932 pItem->SetBackgroundColor(COLOR_BG_GROUP_ITEM_DEFAULT);
934 pLabel = new (std::nothrow) Label();
935 pLabel->Construct(itemMainRectangle, itemMainText);
936 pLabel->SetTextHorizontalAlignment(ALIGNMENT_LEFT);
937 pLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_BOLD);
938 pLabel->SetTextColor(COLOR_MAIN_TEXT);
940 pItem->AddControl(pLabel);
941 relativeLayout.SetMargin(*pLabel, 0, RELATIVE_LAYOUT_RIGHT_MARGIN, 0, 0);
942 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_LEFT_TO_LEFT);
943 relativeLayout.SetRelation(*pLabel, pItem, RECT_EDGE_RELATION_RIGHT_TO_RIGHT);
950 LocaleForm::DeleteGroupItem(int groupIndex, TableViewGroupItem* pItem)
952 AppLogDebug("ENTER");
961 LocaleForm::DeleteItem(int groupIndex, int itemIndex, TableViewItem* pItem)
963 AppLogDebug("ENTER");
972 LocaleForm::OnGroupedTableViewItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
974 if (__isRunningAppControl == true)
979 SceneManager* pSceneManager = SceneManager::GetInstance();
980 AppAssert(pSceneManager);
982 AppLogDebug("group[%d] index[%d]", groupIndex, itemIndex);
986 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
988 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE)
990 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_LANGUAGE, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), __languageDataList);
992 if (itemIndex == ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION)
994 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_LOCALE_REGION, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
999 case ID_GROUP_KEYBOARD:
1002 pSceneManager->GoForward(ForwardSceneTransition(IDSCN_KEYBOARD, SCENE_TRANSITION_ANIMATION_TYPE_LEFT), null);
1004 if (AppControl::FindAndStart(L"http://tizen.org/appcontrol/operation/setting/ime", null, null, null, null, null) == E_SUCCESS)
1006 __isRunningAppControl = true;
1018 LocaleForm::GetDefaultGroupItemHeight(void)
1020 return H_GROUP_INDEX_NO_TITLE_DEFAULT;
1024 LocaleForm::GetDefaultItemHeight(void)
1026 return H_GROUP_ITEM_DEFAULT;
1030 LocaleForm::UpdateGroupItem(int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem)
1034 case ID_GROUP_LANGUAGE_AND_REGION_MAIN_TEXT:
1036 Rectangle pItemBounds = pItem->GetBounds();
1037 Rectangle pBounds = GetClientAreaBounds();
1038 Label* pGroupLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1039 int labelWidth = pItemBounds.width - MAIN_TEXT_WIDTH_GAP;
1045 String formattedString;
1046 String numberFormat;
1048 long inputNumber = DEFAULT_INPUT_NUMBER;
1051 int fontSize = GetFontSize();
1053 LocaleManager localeManager;
1054 localeManager.Construct();
1056 Locale systemLocale = localeManager.GetSystemLocale();
1057 NumberFormatter* pNumberFormatter = NumberFormatter::CreateCurrencyFormatterN(systemLocale);
1058 DateTimeFormatter* pDateFormatter = DateTimeFormatter::CreateDateFormatterN(systemLocale);
1061 SystemTime::GetCurrentTime(dateTime);
1063 groupText = ResourceManager::GetString(L"IDS_ST_BODY_REGIONAL_EXAMPLE");
1064 dateText = ResourceManager::GetString(L"IDS_ST_BODY_DATE");
1065 numberText = ResourceManager::GetString(L"IDS_ST_BODY_NUMBER");
1066 timeText = ResourceManager::GetString(L"IDS_COM_BODY_TIME");
1072 tempHeight = GetLineheight(groupText, labelWidth, fontSize, lineCount, lineHeight);
1073 itemHeight += tempHeight;
1075 String localPattern;
1076 if (SettingInfo::GetValue(L"http://tizen.org/setting/locale.date.format",localPattern) == E_SUCCESS)
1078 pDateFormatter->ApplyPattern(localPattern);
1082 pDateFormatter->ApplyPattern("EEE, MMM dd, yyyy");
1084 pDateFormatter->Format(dateTime, formattedString);
1085 formattedString = dateText + L" : " + formattedString;
1086 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1088 tmpText.Remove(0, tmpText.GetLength());
1089 tmpText.Insert(formattedString, tmpText.GetLength());
1090 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1091 itemHeight += tempHeight;
1093 formattedString.Remove(0, formattedString.GetLength());
1094 bool timeFormat = false;
1095 pDateFormatter->ApplyPattern("hh : mm aa");
1096 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_TIME_FORMAT_24HOUR, timeFormat) == E_SUCCESS)
1098 if (timeFormat == true)
1100 pDateFormatter->ApplyPattern("HH : mm");
1103 pDateFormatter->Format(dateTime, formattedString);
1104 formattedString = timeText + L" : " + formattedString;
1105 groupText.Insert(L"\n" + formattedString, groupText.GetLength());
1107 tmpText.Remove(0, tmpText.GetLength());
1108 tmpText.Insert(formattedString, tmpText.GetLength());
1110 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1111 itemHeight += tempHeight;
1113 formattedString.Remove(0, formattedString.GetLength());
1114 pNumberFormatter->Format(inputNumber, formattedString);
1115 groupText.Insert(L"\n" + numberText + L" : " + formattedString, groupText.GetLength());
1117 tmpText.Remove(0, tmpText.GetLength());
1118 tmpText.Insert(formattedString, tmpText.GetLength());
1119 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1122 tempHeight = (lineCount + 1) * lineHeight;
1126 formattedString = numberText + L" : " + formattedString;
1127 tmpText.Remove(0, tmpText.GetLength());
1128 tmpText.Insert(formattedString, tmpText.GetLength());
1129 tempHeight = GetLineheight(tmpText, labelWidth, fontSize, lineCount, lineHeight);
1131 itemHeight += tempHeight;
1133 tmpText.Remove(0, tmpText.GetLength());
1135 pItemBounds.height = itemHeight + NUMBER_TEXT_HEIGHT_GAP;
1136 pItem->SetBounds(pItemBounds);
1137 AppLogDebug("%d %d %d %d", pItemBounds.x, pItemBounds.y, pItemBounds.width, pItemBounds.height);
1138 pItemBounds.y = H_GROUP_INDEX_HELP_TEXT_TOP_GAP;
1139 pGroupLabel->SetBounds(pItemBounds);
1140 pGroupLabel->SetText(groupText);
1141 pGroupLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1142 pGroupLabel->Invalidate(false);
1143 pItem->Invalidate(false);
1153 LocaleForm::GetLineheight(Tizen::Base::String& src, int labelWidth, int fontSize, int& lineCount, int& lineHeight)
1158 font.Construct(FONT_STYLE_PLAIN, fontSize);
1159 font.GetTextExtent(src, src.GetLength(), dim);
1161 lineHeight = dim.height;
1162 if (dim.width > labelWidth)
1164 lineCount = (dim.width / labelWidth);
1166 if (dim.width % labelWidth)
1168 lineCount += DEFAULT_COUNT;
1173 lineCount = DEFAULT_COUNT;
1175 return (lineCount* dim.height);
1179 LocaleForm::UpdateItem(int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewItem* pItem)
1181 String firstLineText;
1184 Rectangle pItemBounds = pItem->GetBounds();
1185 Rectangle firstLineRect;
1186 Rectangle secondLineRect;
1188 Label* pFirstLabel = null;
1189 Label* pSecondLabel = null;
1191 int fontSize = GetFontSize();
1195 case ID_GROUP_LANGUAGE_AND_REGION_MAIN:
1197 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1198 pSecondLabel = static_cast<Label*>(pItem->GetControl(SECOND_CONTROL));
1200 ItemTypeTwoLine(firstLineRect, secondLineRect, fontSize);
1201 pItemBounds.height = (firstLineRect.height + secondLineRect.height);
1205 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_DISPLAY_LANGUAGE:
1207 firstLineText = ResourceManager::GetString(L"IDS_ST_HEADER_DISPLAY_LANGUAGE");
1209 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, itemSubText) != E_SUCCESS)
1211 AppLogDebug("SettingInfo::GetValue() fail(%s)", GetErrorMessage(GetLastResult()));
1215 for (int i = 0; i< ID_GROUP_LANGUAGE_ITEM_COUNT; i++)
1217 if (itemSubText.Equals(languageCode[i], false))
1219 String* pKey = static_cast<String*>(__languageDataList->GetAt(i));
1221 StringTokenizer stringTokenizer(*pKey, L"/");
1222 stringTokenizer.GetNextToken(itemSubText);
1227 pItem->SetBounds(pItemBounds);
1228 pFirstLabel->SetText(firstLineText);
1229 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1231 pSecondLabel->SetText(itemSubText);
1232 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1234 pFirstLabel->Invalidate(false);
1235 pSecondLabel->Invalidate(false);
1236 pItem->Invalidate(false);
1240 case ID_ITEM_LANGUAGE_AND_REGION_MAIN_REGION:
1242 LocaleManager localeManager;
1243 localeManager.Construct();
1244 Locale locale = localeManager.GetSystemLocale();
1245 String systemLocaleString;
1247 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_REGION");
1249 String localeLanguage;
1250 if (SettingInfo::GetValue(SETTING_INFO_KEY_LOCALE_LANGUAGE, localeLanguage) != E_SUCCESS)
1252 AppLogDebug("GetValue: SETTING_INFO_KEY_LOCALE_LANGUAGE failed [%s]", GetErrorMessage(GetLastResult()));
1253 localeLanguage = L"eng_GB";
1256 LanguageCode langCode = LANGUAGE_INVALID;
1257 CountryCode countryCode = COUNTRY_INVALID;
1258 StringTokenizer strTok(localeLanguage, L"_");
1261 if (strTok.HasMoreTokens())
1263 strTok.GetNextToken(token);
1264 langCode = Locale::StringToLanguageCode(token);
1267 if (strTok.HasMoreTokens())
1269 strTok.GetNextToken(token);
1270 countryCode = Locale::StringToCountryCode(token);
1273 Locale currentLocale(langCode, countryCode);
1275 locale.GetLanguageName(currentLocale, systemLocaleString);
1276 itemSubText.Append(systemLocaleString + L" (");
1277 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1279 locale.GetCountryName(currentLocale, systemLocaleString);
1280 itemSubText.Append(systemLocaleString + L")");
1281 systemLocaleString.Remove(0, systemLocaleString.GetLength());
1283 pItem->SetBounds(pItemBounds);
1284 pFirstLabel->SetText(firstLineText);
1285 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1287 pSecondLabel->SetText(itemSubText);
1288 pSecondLabel->SetTextConfig(FONT_SIZE_SUB_TEXT, LABEL_TEXT_STYLE_NORMAL);
1290 pFirstLabel->Invalidate(false);
1291 pSecondLabel->Invalidate(false);
1292 pItem->Invalidate(false);
1302 case ID_GROUP_KEYBOARD:
1304 pFirstLabel = static_cast<Label*>(pItem->GetControl(FIRST_CONTROL));
1306 ItemTypeOneLine(firstLineRect);
1307 pItemBounds.height = firstLineRect.height;
1309 firstLineText = ResourceManager::GetString(L"IDS_ST_BODY_KEYBOARD");
1310 pItem->SetBounds(pItemBounds);
1311 pFirstLabel->SetText(firstLineText);
1312 pFirstLabel->SetTextConfig(fontSize, LABEL_TEXT_STYLE_NORMAL);
1313 pFirstLabel->Invalidate(false);
1314 pItem->Invalidate(false);
1324 LocaleForm::OnGroupedTableViewContextItemActivationStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, int itemIndex, Tizen::Ui::Controls::TableViewContextItem* pContextItem, bool activated)
1329 LocaleForm::OnGroupedTableViewGroupItemStateChanged(Tizen::Ui::Controls::GroupedTableView& tableView, int groupIndex, Tizen::Ui::Controls::TableViewGroupItem* pItem, Tizen::Ui::Controls::TableViewItemStatus status)
1334 LocaleForm::RefreshTableViewGroupItem(int groupIndex)
1336 int itemCount = __pTableView->GetItemCountAt(groupIndex);
1338 for (int index = REFRESH_GROUP_ITEM_INDEX; index < itemCount; index++)
1340 __pTableView->RefreshItem(groupIndex, index, TABLE_VIEW_REFRESH_TYPE_ITEM_MODIFY);
1345 LocaleForm::RefreshTableViewItem(void)
1347 if (__pTableView == null)
1352 int groupCount = __pTableView->GetGroupCount();
1354 for (int index = 0; index < groupCount; index++)
1356 RefreshTableViewGroupItem(index);
1361 LocaleForm::OnOrientationChanged(const Tizen::Ui::Control& source, Tizen::Ui::OrientationStatus orientationStatus)
1363 RefreshTableViewItem();
1368 LocaleForm::OnFocusGained(const Tizen::Ui::Control& source)
1370 __isRunningAppControl = false;
1374 LocaleForm::OnFocusLost(const Tizen::Ui::Control& source)