Fixed Nabi Issues 49466,55718,55225,52332
[apps/osp/Internet.git] / src / IntBrightnessForm.cpp
index b3dd537..fdf88d4 100644 (file)
@@ -2,7 +2,7 @@
 
 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
 //
-// Licensed under the Flora License, Version 1.0 (the License);
+// Licensed under the Flora License, Version 1.1 (the License);
 // you may not use this file except in compliance with the License.
 // You may obtain a copy of the License at
 //
@@ -137,6 +137,7 @@ BrightnessForm::OnInitializing(void)
        __pBrightnessSlider->SetRange(1,10);
        __pBrightnessSlider->SetValue(sliderValue);
        __pBrightnessSlider->AddSliderEventListener(*this);
+       __pBrightnessSlider->AddAdjustmentEventListener(*this);
 
        GetFooter()->AddActionEventListener(*this);
        return r;
@@ -149,7 +150,7 @@ BrightnessForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        AppRegistry* pAppRegistry = App::GetInstance()->GetAppRegistry();
        String sliderKey("SliderValue");
        String tabKey("TabButton");
-       int sliderValue = 0;
+       int sliderValue = 10;
        int tabValue = 0;
 
        r = pAppRegistry->Get(sliderKey, sliderValue);
@@ -172,7 +173,7 @@ BrightnessForm::OnSceneActivatedN(const SceneId& previousSceneId, const SceneId&
        {
                __pBrightnessSlider->SetEnabled(true);
                AppLog("BatteryLvl %d",PowerManager::GetScreenBrightness());
-               __pBrightnessSlider->SetValue(PowerManager::GetScreenBrightness());
+               __pBrightnessSlider->SetValue(sliderValue);
                __pBrightnessSlider->Invalidate(true);
        }
 
@@ -203,6 +204,30 @@ BrightnessForm::OnSliderBarMoved(Slider& source, int value)
        if (__manualBrightness == true)
        {
                PowerManager::SetScreenBrightness(value);
+               AppRegistry* pAppRegistry = App::GetInstance()->GetAppRegistry();
+               String sliderKey("SliderValue");
+               if (pAppRegistry)
+               {
+                       pAppRegistry->Set(sliderKey,value);
+               }
+       }
+}
+void
+BrightnessForm::OnAdjustmentValueChanged(const Tizen::Ui::Control& source, int adjustment)
+{
+       if(source.Equals(*__pBrightnessSlider) == true)
+       {
+               AppLog("coming to OnSliderBarMoved");
+               if (__manualBrightness == true)
+               {
+                       PowerManager::SetScreenBrightness(adjustment);
+                       AppRegistry* pAppRegistry = App::GetInstance()->GetAppRegistry();
+                       String sliderKey("SliderValue");
+                       if (pAppRegistry)
+                       {
+                               pAppRegistry->Set(sliderKey,adjustment);
+                       }
+               }
        }
 }
 
@@ -223,7 +248,7 @@ BrightnessForm::OnFormBackRequested(Form& source)
                r = pAppRegistry->Set(sliderKey,sliderValue);
                FooterItemStatus footerStatus;
                GetFooter()->GetItemStatus(0,footerStatus);
-               if (footerStatus == FOOTER_ITEM_STATUS_SELECTED)
+               if (footerStatus == FOOTER_ITEM_STATUS_SELECTED || footerStatus == FOOTER_ITEM_STATUS_HIGHLIGHTED)
                {
                        r = pAppRegistry->Set(tabKey,0);
                }
@@ -244,11 +269,12 @@ BrightnessForm::OnFormBackRequested(Form& source)
 void
 BrightnessForm::OnActionPerformed(const Control& source, int actionId)
 {
+       result r = E_SUCCESS;
        switch (actionId)
        {
        case IDA_AUTOBTN_CLICKED:
                __manualBrightness = false;
-//             __pBrightnessSlider->SetValue(6);
+               __pBrightnessSlider->SetValue(6);
 //             __pBrightnessSlider->SetShowState(false);
                PowerManager::SetScreenBrightness(6);
                __pBrightnessSlider->SetEnabled(false);
@@ -266,6 +292,24 @@ BrightnessForm::OnActionPerformed(const Control& source, int actionId)
        default:
                break;
        }
+       // save the slider value
+       // save the tab button
+       AppRegistry* pAppRegistry = App::GetInstance()->GetAppRegistry();
+       String sliderKey("SliderValue");
+       String tabKey("TabButton");
+       int sliderValue = __pBrightnessSlider->GetValue();
+       r = pAppRegistry->Set(sliderKey,sliderValue);
+       FooterItemStatus footerStatus;
+       GetFooter()->GetItemStatus(0,footerStatus);
+       if (footerStatus == FOOTER_ITEM_STATUS_SELECTED || footerStatus == FOOTER_ITEM_STATUS_HIGHLIGHTED)
+       {
+               r = pAppRegistry->Set(tabKey,0);
+       }
+       else
+       {
+               r = pAppRegistry->Set(tabKey,1);
+       }
+       pAppRegistry->Save();
 }
 
 void