Dynamic updation of Button's text with Language Changes
authorAyush <ayush.sriv@samsung.com>
Thu, 30 May 2013 12:21:45 +0000 (17:51 +0530)
committerAyush <ayush.sriv@samsung.com>
Fri, 31 May 2013 13:31:26 +0000 (19:01 +0530)
Change-Id: I50af2436bec0b1e0f4ef8c976158b4f7b6ff241a
Signed-off-by: Ayush <ayush.sriv@samsung.com>
src/ui/controls/FUiCtrl_SearchBar.cpp
src/ui/inc/FUiCtrl_SearchBar.h

index 624d43f..6434ec0 100644 (file)
@@ -43,6 +43,8 @@
 #include "FUiCtrl_SearchBarImpl.h"
 #include "FUiCtrl_EditFieldImpl.h"
 #include "FUiCtrl_ButtonImpl.h"
+#include <FSys_SettingInfoImpl.h>
+
 
 using namespace Tizen::Graphics;
 using namespace Tizen::Ui;
@@ -50,6 +52,7 @@ using namespace Tizen::Ui::Animations;
 using namespace Tizen::Base;
 using namespace Tizen::Base::Runtime;
 using namespace Tizen::Locales;
+using namespace Tizen::System;
 
 namespace Tizen { namespace Ui { namespace Controls
 {
@@ -74,6 +77,7 @@ _SearchBar::_SearchBar(void)
        , __isupdateContentBounds(false)
        , __isKeyPressed(false)
        , __isFocusCallbackToBeFired(true)
+       , __isButtonTextChangedByApp(false)
        , __keypadAction(CORE_KEYPAD_ACTION_SEARCH)
        , __pBackgroundBitmap(null)
        , __backgroundColor(Color())
@@ -108,6 +112,8 @@ _SearchBar::_SearchBar(void)
 
 _SearchBar::~_SearchBar(void)
 {
+       SettingInfo::RemoveSettingEventListener(*this);
+
        delete __pSearchBarPresenter;
        __pSearchBarPresenter = null;
 
@@ -258,6 +264,10 @@ _SearchBar::Initialize(bool enableSearchBarButton, CoreKeypadAction keypadAction
        __pSearchBarPresenter = pPresenter;
 
        CreateAccessibilityElement();
+
+       r = _SettingInfoImpl::AddSettingEventListener(*this);
+       SysTryCatch(NID_UI, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
+
        return r;
 
 CATCH:
@@ -661,6 +671,7 @@ _SearchBar::GetButtonStatus(void) const
 result
 _SearchBar::SetButtonText(const String& text)
 {
+       __isButtonTextChangedByApp = true;
        SysTryReturn(NID_UI_CTRL, __pCancelButton, E_SYSTEM, E_SYSTEM,
                     "[E_SYSTEM] A system error has occurred. The cancel button instance is null.");
 
@@ -1846,6 +1857,25 @@ _SearchBar::OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo)
        return false;
 }
 
+void
+_SearchBar::OnSettingChanged(Tizen::Base::String& key)
+{
+       if (__isButtonTextChangedByApp || !__isUsableCancelButton)
+       {
+               return;
+       }
+
+       if (key.Equals(L"http://tizen.org/setting/locale.language", false))
+       {
+               String cancelText;
+               GET_STRING_CONFIG(IDS_COM_SK_CANCEL, cancelText);
+               __pCancelButton->SetText(cancelText);
+               __pCancelButton->Invalidate();
+       }
+
+       return;
+}
+
 _Control*
 _SearchBar::GetParentForm(void) const
 {
index 27d3382..5761771 100644 (file)
@@ -72,6 +72,7 @@ class _SearchBar
        , virtual public Tizen::Base::Runtime::IEventListener
        , virtual public Tizen::Ui::_IUiEventListener
        , virtual public Tizen::Ui::_IUiEventPreviewer
+       , virtual public Tizen::System::ISettingEventListener
 {
        DECLARE_CLASS_BEGIN(_SearchBar, _Control);
        DECLARE_PROPERTY("buttonActionId", GetPropertyButtonActionId, SetPropertyButtonActionId);
@@ -258,6 +259,8 @@ public:
 
        virtual bool OnKeyPressed(const _Control& source, const _KeyInfo& keyInfo);
 
+       virtual void OnSettingChanged(Tizen::Base::String& key);
+
 protected:
        virtual void OnDraw(void);
 
@@ -298,6 +301,7 @@ private:
        bool __isupdateContentBounds;
        bool __isKeyPressed;
        bool __isFocusCallbackToBeFired;
+       bool __isButtonTextChangedByApp;
 
        CoreKeypadAction __keypadAction;