mAppControlSignal.Emit( application , data );
}
-void Application::OnLanguageChanged()
+void Application::OnLanguageChanged( const std::string& language )
{
+ mLanguage = language;
DoLanguageChange();
Dali::Application application(this);
mLanguageChangedSignal.Emit( application );
}
-void Application::OnRegionChanged()
+void Application::OnRegionChanged( const std::string& region )
{
+ mRegion = region;
Dali::Application application(this);
mRegionChangedSignal.Emit( application );
}
-void Application::OnBatteryLow()
+void Application::OnBatteryLow( Dali::DevelApplication::BatteryStatus::Type status )
{
Dali::Application application(this);
mBatteryLowSignal.Emit( application );
+ mLowBatterySignal.Emit( status );
}
-void Application::OnMemoryLow()
+void Application::OnMemoryLow( Dali::DevelApplication::MemoryStatus::Type status )
{
Dali::Application application(this);
mMemoryLowSignal.Emit( application );
+ mLowMemorySignal.Emit( status );
}
-
void Application::OnResize(Dali::Adaptor& adaptor)
{
Dali::Application application(this);
return mAdaptor->AddIdle( callback );
}
+std::string Application::GetRegion()
+{
+ return mRegion;
+}
+
+std::string Application::GetLanguage()
+{
+ return mLanguage;
+}
+
Dali::Adaptor& Application::GetAdaptor()
{
return *mAdaptor;
// INTERNAL INCLUDES
#include <application.h>
+#include <application-devel.h>
#include <singleton-service.h>
#include <framework.h>
Dali::Window GetWindow();
/**
+ * @copydoc Dali::DevelApplication::GetRegion();
+ */
+ std::string GetRegion();
+
+ /**
+ * @copydoc Dali::DevelApplication::GetLanguage();
+ */
+ std::string GetLanguage();
+
+ /**
* @copydoc Dali::Application::ReplaceWindow();
*/
void ReplaceWindow( const PositionSize& positionSize, const std::string& name);
/**
* Called when the framework informs the application that the language of the device has changed.
*/
- virtual void OnLanguageChanged();
+ virtual void OnLanguageChanged( const std::string& language );
/**
* Called when the framework informs the application that the region of the device has changed.
*/
- virtual void OnRegionChanged();
+ virtual void OnRegionChanged( const std::string& region );
/**
* Called when the framework informs the application that the battery level of the device is low.
*/
- virtual void OnBatteryLow();
+ virtual void OnBatteryLow( Dali::DevelApplication::BatteryStatus::Type status );
/**
* Called when the framework informs the application that the memory level of the device is low.
*/
- virtual void OnMemoryLow();
+ virtual void OnMemoryLow( Dali::DevelApplication::MemoryStatus::Type status );
public:
*/
Dali::Application::AppSignalType& MemoryLowSignal() { return mMemoryLowSignal; }
+ /**
+ * @copydoc Dali::DevelApplication::LowBatterySignal()
+ */
+ Dali::DevelApplication::LowBatterySignalType& LowBatterySignal() { return mLowBatterySignal; }
+
+ /**
+ * @copydoc Dali::DevelApplication:::LowMemorySignal()
+ */
+ Dali::DevelApplication::LowMemorySignalType& LowMemorySignal() { return mLowMemorySignal; }
+
protected:
/**
private:
- AppSignalType mInitSignal;
- AppSignalType mTerminateSignal;
- AppSignalType mPauseSignal;
- AppSignalType mResumeSignal;
- AppSignalType mResetSignal;
- AppSignalType mResizeSignal;
- AppControlSignalType mAppControlSignal;
- AppSignalType mLanguageChangedSignal;
- AppSignalType mRegionChangedSignal;
- AppSignalType mBatteryLowSignal;
- AppSignalType mMemoryLowSignal;
+ AppSignalType mInitSignal;
+ AppSignalType mTerminateSignal;
+ AppSignalType mPauseSignal;
+ AppSignalType mResumeSignal;
+ AppSignalType mResetSignal;
+ AppSignalType mResizeSignal;
+ AppControlSignalType mAppControlSignal;
+ AppSignalType mLanguageChangedSignal;
+ AppSignalType mRegionChangedSignal;
+ AppSignalType mBatteryLowSignal;
+ AppSignalType mMemoryLowSignal;
+ Dali::DevelApplication::LowBatterySignalType mLowBatterySignal;
+ Dali::DevelApplication::LowMemorySignalType mLowMemorySignal;
EventLoop* mEventLoop;
Framework* mFramework;
Dali::Configuration::ContextLoss mContextLossConfiguration;
CommandLineOptions* mCommandLineOptions;
- Dali::SingletonService mSingletonService;
- Dali::Adaptor* mAdaptor;
- Dali::Window mWindow;
- Dali::Application::WINDOW_MODE mWindowMode;
- std::string mName;
- std::string mStylesheet;
- EnvironmentOptions mEnvironmentOptions;
- PositionSize mWindowPositionSize;
- Launchpad::State mLaunchpadState;
- bool mUseRemoteSurface;
+ Dali::SingletonService mSingletonService;
+ Dali::Adaptor* mAdaptor;
+ Dali::Window mWindow;
+ Dali::Application::WINDOW_MODE mWindowMode;
+ std::string mName;
+ std::string mStylesheet;
+ std::string mLanguage;
+ std::string mRegion;
+ EnvironmentOptions mEnvironmentOptions;
+ PositionSize mWindowPositionSize;
+ Launchpad::State mLaunchpadState;
+ bool mUseRemoteSurface;
SlotDelegate< Application > mSlotDelegate;
// EXTERNAL INCLUDES
#include <string>
+#include <application-devel.h>
#include <dali/public-api/signals/callback.h>
#ifdef APPCORE_WATCH_AVAILABLE
#include "wearable/watch/watch-application.h"
/**
* Invoked when the language of the device is changed.
*/
- virtual void OnLanguageChanged() {}
+ virtual void OnLanguageChanged( const std::string& language ) {}
/**
* Invoked when the region is changed.
*/
- virtual void OnRegionChanged() {}
+ virtual void OnRegionChanged( const std::string& region ) {}
/**
* Invoked when the battery level of the device is low.
*/
- virtual void OnBatteryLow() {}
+ virtual void OnBatteryLow( Dali::DevelApplication::BatteryStatus::Type status ) {}
/**
* Invoked when the memory level of the device is low.
*/
- virtual void OnMemoryLow() {}
+ virtual void OnMemoryLow( Dali::DevelApplication::MemoryStatus::Type status ) {}
};
public:
Internal::Adaptor::Application::PreInitialize( argc, argv );
}
+std::string GetRegion( Application application )
+{
+ return Internal::Adaptor::GetImplementation( application ).GetRegion();
+}
+
+std::string GetLanguage( Application application )
+{
+ return Internal::Adaptor::GetImplementation( application ).GetLanguage();
+}
+
+LowBatterySignalType& LowBatterySignal( Application application )
+{
+ return Internal::Adaptor::GetImplementation( application ).LowBatterySignal();
+}
+
+LowMemorySignalType& LowMemorySignal( Application application )
+{
+ return Internal::Adaptor::GetImplementation( application ).LowMemorySignal();
+}
+
} // namespace DevelApplication
} // namespace Dali
namespace DevelApplication
{
+/*
+ * @brief An enum of memory status.
+ */
+struct MemoryStatus
+{
+ enum Type
+ {
+ /*
+ * Normal status.
+ */
+ NORMAL,
+
+ /*
+ * Soft warning status.
+ */
+ SOFT_WARNING,
+
+ /*
+ * Hard warning status.
+ */
+ HARD_WARNING
+ };
+};
+
+/*
+ * @brief An enum of battery status.
+ */
+struct BatteryStatus
+{
+ enum Type
+ {
+ /*
+ * Normal status.
+ * Battery status is over 5%.
+ */
+ NORMAL,
+
+ /*
+ * Battery status is under 5%.
+ */
+ CRITICAL_LOW,
+
+ /*
+ * Device can be turned off anytime.
+ * Battery status is under 1%.
+ */
+ POWER_OFF
+ };
+};
+
+typedef Signal< void (BatteryStatus::Type) > LowBatterySignalType;
+typedef Signal< void (MemoryStatus::Type) > LowMemorySignalType;
+
/**
* @brief This is the constructor for applications.
*
*/
DALI_IMPORT_API void PreInitialize( int* argc, char** argv[] );
+/**
+ * @brief This is used to get region information from device.
+ *
+ * @return Region information
+ */
+DALI_IMPORT_API std::string GetRegion( Application application );
+
+/**
+ * @brief This is used to get language information from device.
+ *
+ * @return Language information
+ */
+DALI_IMPORT_API std::string GetLanguage( Application application );
+
+/**
+ * @brief This signal is emitted when the battery level of the device is low.
+ * @SINCE_1_0.0
+ * @return The signal to connect to
+ */
+DALI_IMPORT_API LowBatterySignalType& LowBatterySignal( Application application );
+
+/**
+ * @brief This signal is emitted when the memory level of the device is low.
+ * @SINCE_1_0.0
+ * @return The signal to connect to
+ */
+DALI_IMPORT_API LowMemorySignalType& LowMemorySignal( Application application );
+
+
} // namespace DevelApplication
} // namespace Dali
{
public:
+
typedef Signal< void (Application&) > AppSignalType; ///< Application lifecycle signal and system signal callback type @SINCE_1_0.0
typedef Signal< void (Application&, void *) > AppControlSignalType; ///< Application control signal callback type @SINCE_1_0.0
*/
static std::string GetResourcePath();
-
public: // Stereoscopy
/**
AppSignalType& RegionChangedSignal();
/**
+ * @DEPRECATED_1_2.58 Use LowBatterySignal() instead.
* @brief This signal is emitted when the battery level of the device is low.
* @SINCE_1_0.0
* @return The signal to connect to
*/
- AppSignalType& BatteryLowSignal();
+ AppSignalType& BatteryLowSignal() DALI_DEPRECATED_API;
/**
+ * @DEPRECATED_1_2.58 Use LowMemorySignal() instead.
* @brief This signal is emitted when the memory level of the device is low.
* @SINCE_1_0.0
* @return The signal to connect to
*/
- AppSignalType& MemoryLowSignal();
+ AppSignalType& MemoryLowSignal() DALI_DEPRECATED_API;
public: // Not intended for application developers
/// @cond internal
static void AppLanguageChanged(app_event_info_h event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnLanguageChanged();
+ observer->OnLanguageChanged("");
}
static void AppDeviceRotated(app_event_info_h event_info, void *data)
static void AppRegionChanged(app_event_info_h event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnRegionChanged();
+ observer->OnRegionChanged("");
}
static void AppBatteryLow(app_event_info_h event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnBatteryLow();
+ observer->OnBatteryLow(Dali::DevelApplication::BatteryStatus::NORMAL);
}
static void AppMemoryLow(app_event_info_h event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnMemoryLow();
+ observer->OnMemoryLow(Dali::DevelApplication::MemoryStatus::NORMAL);
}
private:
static void AppLanguageChanged(AppCore::AppEventInfoPtr event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnLanguageChanged();
+ std::string language( static_cast<const char *>(event->value) );
+ observer->OnLanguageChanged(language);
}
static void AppDeviceRotated(AppCore::AppEventInfoPtr event_info, void *data)
static void AppRegionChanged(AppCore::AppEventInfoPtr event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnRegionChanged();
+ std::string region( static_cast<const char *>(event->value) );
+ observer->OnRegionChanged(region);
}
static void AppBatteryLow(AppCore::AppEventInfoPtr event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
+ int status = *static_cast<int *>(event->value);
+ Dali::DevelApplication::BatteryStatus::Type result = Dali::DevelApplication::BatteryStatus::NORMAL;
- observer->OnBatteryLow();
+ // convert to dali battery status
+ switch( status )
+ {
+ case 1:
+ {
+ result = Dali::DevelApplication::BatteryStatus::POWER_OFF;
+ break;
+ }
+ case 2:
+ {
+ result = Dali::DevelApplication::BatteryStatus::CRITICAL_LOW;
+ break;
+ }
+ default :
+ break;
+ }
+ observer->OnBatteryLow(result);
}
static void AppMemoryLow(AppCore::AppEventInfoPtr event, void *data)
{
Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnMemoryLow();
+ int status = *static_cast<int *>(event->value);
+ Dali::DevelApplication::MemoryStatus::Type result = Dali::DevelApplication::MemoryStatus::NORMAL;
+ // convert to dali memmory status
+ switch( status )
+ {
+ case 1:
+ {
+ result = Dali::DevelApplication::MemoryStatus::NORMAL;
+ break;
+ }
+ case 2:
+ {
+ result = Dali::DevelApplication::MemoryStatus::SOFT_WARNING;
+ break;
+ }
+ case 4:
+ {
+ result = Dali::DevelApplication::MemoryStatus::HARD_WARNING;
+ break;
+ }
+ default :
+ break;
+ }
+ observer->OnMemoryLow(result);
}
observer->OnAmbientChanged(ambient);
}
- static void WatchAppLanguageChanged(app_event_info_h event, void *data)
- {
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnLanguageChanged();
- }
-
- static void WatchAppRegionChanged(app_event_info_h event, void *data)
- {
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnRegionChanged();
- }
-
- static void WatchAppBatteryLow(app_event_info_h event, void *data)
- {
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnBatteryLow();
- }
-
- static void WatchAppMemoryLow(app_event_info_h event, void *data)
- {
- Observer *observer = &static_cast<Framework*>(data)->mObserver;
-
- observer->OnMemoryLow();
- }
-
static void WatchAppControl(app_control_h app_control, void *data)
{
Framework* framework = static_cast<Framework*>(data);
mWatchCallback.ambient_tick = WatchAppAmbientTick;
mWatchCallback.ambient_changed = WatchAppAmbientChanged;
- watch_app_add_event_handler(&watchHandlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, WatchAppBatteryLow, mFramework);
- watch_app_add_event_handler(&watchHandlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, WatchAppMemoryLow, mFramework);
- watch_app_add_event_handler(&watchHandlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, WatchAppLanguageChanged, mFramework);
- watch_app_add_event_handler(&watchHandlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, WatchAppRegionChanged, mFramework);
+ AppCore::AppAddEventHandler(&handlers[AppCore::LOW_BATTERY], AppCore::LOW_BATTERY, AppBatteryLow, mFramework);
+ AppCore::AppAddEventHandler(&handlers[AppCore::LOW_MEMORY], AppCore::LOW_MEMORY, AppMemoryLow, mFramework);
+ AppCore::AppAddEventHandler(&handlers[AppCore::LANGUAGE_CHANGED], AppCore::LANGUAGE_CHANGED, AppLanguageChanged, mFramework);
+ AppCore::AppAddEventHandler(&handlers[AppCore::REGION_FORMAT_CHANGED], AppCore::REGION_FORMAT_CHANGED, AppRegionChanged, mFramework);
ret = watch_app_main(*mFramework->mArgc, *mFramework->mArgv, &mWatchCallback, mFramework);
#endif
break;
case APP_LANGUAGE_CHANGE:
- mObserver.OnLanguageChanged();
+ mObserver.OnLanguageChanged("");
break;
default: