From 8004e0d459cefd76f94493a7cb104efc1fd86ae2 Mon Sep 17 00:00:00 2001 From: Syed Khaja Moinuddin Date: Fri, 29 Mar 2013 18:41:18 +0900 Subject: [PATCH] Implemented changes to show Date / time format strings in regional language. Signed-off-by: Syed Khaja Moinuddin Change-Id: I6dcd64128fb2424ba3d6443c93c0760594297dd8 --- src/ui/controls/FUiCtrl_DateTimePicker.cpp | 16 ++++-- src/ui/controls/FUiCtrl_DateTimePresenter.cpp | 10 ++-- src/ui/controls/FUiCtrl_DateTimeUtils.cpp | 81 +++++++++++---------------- src/ui/controls/FUiCtrl_EditTime.cpp | 12 ++-- src/ui/controls/FUiCtrl_EditTimePresenter.cpp | 5 +- src/ui/inc/FUiCtrl_DateTimeUtils.h | 8 +++ 6 files changed, 69 insertions(+), 63 deletions(-) diff --git a/src/ui/controls/FUiCtrl_DateTimePicker.cpp b/src/ui/controls/FUiCtrl_DateTimePicker.cpp index ce95a61..69f3e91 100644 --- a/src/ui/controls/FUiCtrl_DateTimePicker.cpp +++ b/src/ui/controls/FUiCtrl_DateTimePicker.cpp @@ -36,6 +36,7 @@ #include "FUiCtrl_Toolbar.h" #include "FUiCtrl_DateTimeChangeEvent.h" #include "FUiCtrl_IDateTimeChangeEventListener.h" +#include "FUiCtrl_DateTimeUtils.h" #include "FUi_AccessibilityContainer.h" #include "FUi_AccessibilityElement.h" #include "FUi_AccessibilityManager.h" @@ -840,15 +841,19 @@ _DateTimePicker::SetAccessibilityElementText(int index, const String& text, bool if (isAmPm) { String amText; - GET_STRING_CONFIG(IDS_COM_BODY_AM, amText); + String pmText; + + _DateTimeUtils dateTimeUtils; + dateTimeUtils.GetAmPm(amText, AM_TYPE); + dateTimeUtils.GetAmPm(pmText, PM_TYPE); if (text == amText) { - hintAmPmText.Append(L"PM"); + hintAmPmText.Append(pmText); } else { - hintAmPmText.Append(L"AM"); + hintAmPmText.Append(amText); } pElement->SetHint(hintAmPmText); @@ -1075,8 +1080,9 @@ _DateTimePicker::OnAccessibilityActionPerformed(const _AccessibilityContainer& c label = element.GetLabel(); - GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); - GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + _DateTimeUtils dateTimeUtils; + dateTimeUtils.GetAmPm(amString, AM_TYPE); + dateTimeUtils.GetAmPm(pmString, PM_TYPE); if (label == amString || label == pmString) { diff --git a/src/ui/controls/FUiCtrl_DateTimePresenter.cpp b/src/ui/controls/FUiCtrl_DateTimePresenter.cpp index 7aec176..73551e9 100755 --- a/src/ui/controls/FUiCtrl_DateTimePresenter.cpp +++ b/src/ui/controls/FUiCtrl_DateTimePresenter.cpp @@ -1310,13 +1310,17 @@ _DateTimePresenter::DrawPm(Canvas& canvas) return; } + _DateTimeUtils dateTimeUtils; + + + if (__isPm == false) { - GET_STRING_CONFIG(IDS_COM_BODY_AM, text); + dateTimeUtils.GetAmPm(text, AM_TYPE); } else { - GET_STRING_CONFIG(IDS_COM_POP_PM, text); + dateTimeUtils.GetAmPm(text, PM_TYPE); } __pPmBox->SetText(text); @@ -1465,8 +1469,6 @@ _DateTimePresenter::GetOutputArea(void) FloatRectangle outputArea(0.0f, 0.0f, 0.0f, 0.0f); FloatRectangle headerBounds = __pView->GetHeaderBounds(); - float xMargin = 0.0f; - float yMargin = 0.0f; GET_SHAPE_CONFIG(DATETIMEPICKER::LEFT_MARGIN, orientation, outputArea.x); GET_SHAPE_CONFIG(DATETIMEPICKER::TOP_MARGIN, orientation, outputArea.y); diff --git a/src/ui/controls/FUiCtrl_DateTimeUtils.cpp b/src/ui/controls/FUiCtrl_DateTimeUtils.cpp index 958fdf1..f034ff0 100644 --- a/src/ui/controls/FUiCtrl_DateTimeUtils.cpp +++ b/src/ui/controls/FUiCtrl_DateTimeUtils.cpp @@ -21,10 +21,13 @@ */ #include +#include #include "FUiCtrl_DateTimeUtils.h" #include "FUi_ResourceManager.h" using namespace Tizen::Base; +using namespace Tizen::Locales; +using namespace Tizen::Base::Collection; namespace Tizen { namespace Ui { namespace Controls { @@ -42,59 +45,21 @@ _DateTimeUtils::GetMonthString(int month) const { String text; text.Clear(); - switch (month) - { - case 1: - GET_STRING_CONFIG(IDS_COM_BODY_JAN, text); - break; - - case 2: - GET_STRING_CONFIG(IDS_COM_BODY_FEB, text); - break; - - case 3: - GET_STRING_CONFIG(IDS_COM_BODY_MAR, text); - break; - - case 4: - GET_STRING_CONFIG(IDS_COM_BODY_APR, text); - break; - case 5: - GET_STRING_CONFIG(IDS_COM_BODY_MAY, text); - break; + DateTimeSymbols dateSymbols; + dateSymbols.Construct(CALENDAR_GREGORIAN); - case 6: - GET_STRING_CONFIG(IDS_COM_BODY_JUN, text); - break; + const IList* pListOfShortMonths = dateSymbols.GetShortMonths(); + SysTryReturn(NID_LCL, (pListOfShortMonths != null), text, E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfShortMonths is null."); - case 7: - GET_STRING_CONFIG(IDS_COM_BODY_JUL, text); - break; - - case 8: - GET_STRING_CONFIG(IDS_COM_BODY_AUG, text); - break; - - case 9: - GET_STRING_CONFIG(IDS_COM_BODY_SEP, text); - break; + String* pObj = null; + pObj = static_cast(const_cast(pListOfShortMonths->GetAt(month - 1))); - case 10: - GET_STRING_CONFIG(IDS_COM_BODY_OCT, text); - break; - - case 11: - GET_STRING_CONFIG(IDS_COM_BODY_NOV, text); - break; - - case 12: - GET_STRING_CONFIG(IDS_COM_BODY_DEC, text); - break; - - default: - break; + if (pObj) + { + text.Append(*pObj); } + return text; } @@ -144,4 +109,24 @@ _DateTimeUtils::IsLeapYear(int year) const return DateTime::IsLeapYear(year); } +void +_DateTimeUtils::GetAmPm(String& timeFormat, _AmPmType amPmType) const +{ + DateTimeSymbols dateSymbols; + dateSymbols.Construct(CALENDAR_GREGORIAN); + + const IList* pListOfAmPm = dateSymbols.GetAmPm(); + SysTryReturnVoidResult(NID_LCL, (pListOfAmPm != null), E_SYSTEM, "[E_SYSTEM] A system error has occurred. pListOfAmPm is null."); + + String* pObj = null; + pObj = static_cast(const_cast(pListOfAmPm->GetAt(amPmType))); + + if (pObj) + { + timeFormat.Append(*pObj); + } + + return; +} + }}} // Tizen::Ui::Controls diff --git a/src/ui/controls/FUiCtrl_EditTime.cpp b/src/ui/controls/FUiCtrl_EditTime.cpp index b8af3e4..08d3d75 100644 --- a/src/ui/controls/FUiCtrl_EditTime.cpp +++ b/src/ui/controls/FUiCtrl_EditTime.cpp @@ -30,6 +30,7 @@ #include "FUiCtrl_EditTimePresenter.h" #include "FUiCtrl_Form.h" #include "FUiCtrl_Frame.h" +#include "FUiCtrl_DateTimeUtils.h" #include "FUiCtrl_DateTimeDefine.h" using namespace Tizen::Graphics; @@ -805,10 +806,12 @@ _EditTime::UpdateAccessibilityElement(void) if (Is24HourNotationEnabled() == false) { String hintAmPmText(L"Double tap to change to "); + String amString; String pmString; - GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); - GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + _DateTimeUtils dateTimeUtils; + dateTimeUtils.GetAmPm(amString, AM_TYPE); + dateTimeUtils.GetAmPm(pmString, PM_TYPE); if (__pEditTimePresenter->GetAmEnabled() == true) { @@ -883,8 +886,9 @@ _EditTime::OnAccessibilityActionPerformed(const _AccessibilityContainer& control labelText = element.GetLabel(); - GET_STRING_CONFIG(IDS_COM_BODY_AM, amString); - GET_STRING_CONFIG(IDS_COM_POP_PM, pmString); + _DateTimeUtils dateTimeUtils; + dateTimeUtils.GetAmPm(amString, AM_TYPE); + dateTimeUtils.GetAmPm(pmString, PM_TYPE); if (labelText == amString || labelText == pmString) { diff --git a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp index f114d9c..050d247 100755 --- a/src/ui/controls/FUiCtrl_EditTimePresenter.cpp +++ b/src/ui/controls/FUiCtrl_EditTimePresenter.cpp @@ -244,8 +244,9 @@ _EditTimePresenter::SetAmEnabled(bool amEnable) String textAm; String textPm; - GET_STRING_CONFIG(IDS_COM_BODY_AM, textAm); - GET_STRING_CONFIG(IDS_COM_POP_PM, textPm); + _DateTimeUtils dateTimeUtils; + dateTimeUtils.GetAmPm(textAm, AM_TYPE); + dateTimeUtils.GetAmPm(textPm, PM_TYPE); __amEnable = amEnable; int hour = GetHour(); diff --git a/src/ui/inc/FUiCtrl_DateTimeUtils.h b/src/ui/inc/FUiCtrl_DateTimeUtils.h index a554214..b384cd5 100644 --- a/src/ui/inc/FUiCtrl_DateTimeUtils.h +++ b/src/ui/inc/FUiCtrl_DateTimeUtils.h @@ -27,6 +27,13 @@ namespace Tizen { namespace Ui { namespace Controls { + +enum _AmPmType +{ + AM_TYPE, + PM_TYPE +}; + class _DateTimeUtils : public Tizen::Base::Object { @@ -41,6 +48,7 @@ public: const Tizen::Base::String GetMonthString(int month) const; int CalculateMaxDay(int displayYear, int month) const ; bool IsLeapYear(int year) const; + void GetAmPm(Tizen::Base::String& timeFormat, _AmPmType amPmType) const; private: _DateTimeUtils(const _DateTimeUtils&); -- 2.7.4