Add AppRegistry
This commit is contained in:
@@ -11,12 +11,13 @@
|
||||
#include <FUiIme.h>
|
||||
#include <FGraphics.h>
|
||||
#include <FGraphicsOpengl2.h>
|
||||
//#include <FUix.h>
|
||||
|
||||
|
||||
namespace lime {
|
||||
|
||||
|
||||
class TizenApplication : public Tizen::App::UiApp, public Tizen::System::IScreenEventListener, public Tizen::Ui::IKeyEventListener, public Tizen::Base::Runtime::ITimerEventListener, public Tizen::Ui::ITouchEventListener {
|
||||
class TizenApplication : public Tizen::App::UiApp, public Tizen::System::IScreenEventListener, public Tizen::Ui::IKeyEventListener, public Tizen::Base::Runtime::ITimerEventListener, public Tizen::Ui::ITouchEventListener /*, public Tizen::Uix::Sensor::ISensorEventListener*/ {
|
||||
|
||||
public:
|
||||
|
||||
@@ -31,6 +32,7 @@ namespace lime {
|
||||
//virtual bool OnAppWillTerminate (void);
|
||||
virtual void OnBackground (void);
|
||||
virtual void OnBatteryLevelChanged (Tizen::System::BatteryLevel batteryLevel);
|
||||
//virtual void OnDataReceived (Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r);
|
||||
virtual void OnForeground (void);
|
||||
virtual void OnLowMemory (void);
|
||||
virtual void OnKeyLongPressed (const Tizen::Ui::Control& source, Tizen::Ui::KeyCode keyCode);
|
||||
@@ -55,6 +57,7 @@ namespace lime {
|
||||
Tizen::Graphics::Opengl::EGLConfig mEGLConfig;
|
||||
Tizen::Graphics::Opengl::EGLContext mEGLContext;
|
||||
Tizen::Ui::Controls::Form* mForm;
|
||||
//Tizen::Uix::Sensor::SensorManager* mSensorManager;
|
||||
Tizen::Base::Runtime::Timer* mTimer;
|
||||
|
||||
};
|
||||
|
||||
@@ -72,23 +72,6 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool ClearUserPreference (const char *inId) {
|
||||
|
||||
return true;
|
||||
|
||||
/*JNIEnv *env = GetEnv();
|
||||
jclass cls = FindClass("org/haxe/lime/GameActivity");
|
||||
jmethodID mid = env->GetStaticMethodID(cls, "clearUserPreference", "(Ljava/lang/String;)V");
|
||||
if (mid == 0)
|
||||
return false;
|
||||
|
||||
jstring jInId = env->NewStringUTF( inId );
|
||||
env->CallStaticVoidMethod(cls, mid, jInId );
|
||||
return true;*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string FileDialogFolder (const std::string &title, const std::string &text) {
|
||||
|
||||
return "";
|
||||
@@ -110,60 +93,10 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool GetAcceleration (double &outX, double &outY, double &outZ) {
|
||||
|
||||
//if (gFixedOrientation == 3 || gFixedOrientation == 4) {
|
||||
|
||||
outX = 0;
|
||||
outY = 0;
|
||||
outZ = 1;
|
||||
|
||||
//}
|
||||
|
||||
/*int result = accelerometer_read_forces (&outX, &outY, &outZ);
|
||||
|
||||
if (getenv ("FORCE_PORTRAIT") != NULL) {
|
||||
|
||||
int cache = outX;
|
||||
outX = outY;
|
||||
outY = -cache;
|
||||
|
||||
}
|
||||
|
||||
outZ = -outZ;*/
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string GetUserPreference (const char *inId) {
|
||||
|
||||
return "";
|
||||
|
||||
/*JNIEnv *env = GetEnv();
|
||||
jclass cls = FindClass("org/haxe/lime/GameActivity");
|
||||
jmethodID mid = env->GetStaticMethodID(cls, "getUserPreference", "(Ljava/lang/String;)Ljava/lang/String;");
|
||||
if (mid == 0)
|
||||
{
|
||||
return std::string("");
|
||||
}
|
||||
|
||||
jstring jInId = env->NewStringUTF(inId);
|
||||
jstring jPref = (jstring) env->CallStaticObjectMethod(cls, mid, jInId);
|
||||
env->DeleteLocalRef(jInId);
|
||||
const char *nativePref = env->GetStringUTFChars(jPref, 0);
|
||||
std::string result(nativePref);
|
||||
env->ReleaseStringUTFChars(jPref, nativePref);
|
||||
return result;*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
void HapticVibrate (int period, int duration) {
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -174,26 +107,6 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool SetUserPreference (const char *inId, const char *inPreference) {
|
||||
|
||||
/*JNIEnv *env = GetEnv();
|
||||
jclass cls = FindClass("org/haxe/lime/GameActivity");
|
||||
jmethodID mid = env->GetStaticMethodID(cls, "setUserPreference", "(Ljava/lang/String;Ljava/lang/String;)V");
|
||||
if (mid == 0)
|
||||
return false;
|
||||
|
||||
jstring jInId = env->NewStringUTF( inId );
|
||||
jstring jPref = env->NewStringUTF ( inPreference );
|
||||
env->CallStaticVoidMethod(cls, mid, jInId, jPref );
|
||||
env->DeleteLocalRef(jInId);
|
||||
env->DeleteLocalRef(jPref);
|
||||
return true;*/
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,9 @@ namespace lime {
|
||||
|
||||
|
||||
int gFixedOrientation = -1;
|
||||
//double mAccelX;
|
||||
//double mAccelY;
|
||||
//double mAccelZ;
|
||||
int mSingleTouchID;
|
||||
FrameCreationCallback sgCallback;
|
||||
unsigned int sgFlags;
|
||||
@@ -63,6 +66,9 @@ namespace lime {
|
||||
|
||||
TizenApplication::TizenApplication (void) {
|
||||
|
||||
//mAccelX = 0;
|
||||
//mAccelY = 0;
|
||||
//mAccelZ = 0;
|
||||
mEGLDisplay = EGL_NO_DISPLAY;
|
||||
mEGLSurface = EGL_NO_SURFACE;
|
||||
mEGLConfig = null;
|
||||
@@ -86,6 +92,14 @@ namespace lime {
|
||||
|
||||
}
|
||||
|
||||
/*if (mSensorManager) {
|
||||
|
||||
mSensorManager->RemoveSensorListener (*this);
|
||||
delete mSensorManager;
|
||||
mSensorManager = null;
|
||||
|
||||
}*/
|
||||
|
||||
Event close (etQuit);
|
||||
sgTizenFrame->HandleEvent (close);
|
||||
|
||||
@@ -129,6 +143,19 @@ namespace lime {
|
||||
mForm->AddTouchEventListener (*this);
|
||||
mForm->SetMultipointTouchEnabled (true);
|
||||
|
||||
/*long interval = 0L;
|
||||
mSensorManager = new Tizen::Uix::Sensor::SensorManager ();
|
||||
mSensorManager->Construct ();
|
||||
mSensorManager->GetMinInterval (Tizen::Uix::Sensor::SENSOR_TYPE_ACCELERATION, interval);
|
||||
|
||||
if (interval < 50) {
|
||||
|
||||
interval = 50;
|
||||
|
||||
}
|
||||
|
||||
mSensorManager->AddSensorListener (*this, Tizen::Uix::Sensor::SENSOR_TYPE_ACCELERATION, interval, true);*/
|
||||
|
||||
bool ok = limeEGLCreate (mForm, sgWidth, sgHeight, 2, (sgFlags & wfDepthBuffer) ? 16 : 0, (sgFlags & wfStencilBuffer) ? 8 : 0, 0);
|
||||
|
||||
mTimer = new (std::nothrow) Tizen::Base::Runtime::Timer;
|
||||
@@ -147,7 +174,7 @@ namespace lime {
|
||||
bool TizenApplication::OnAppTerminating (Tizen::App::AppRegistry& appRegistry, bool forcedTermination) {
|
||||
|
||||
Cleanup ();
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
@@ -173,6 +200,17 @@ namespace lime {
|
||||
void TizenApplication::OnBatteryLevelChanged (Tizen::System::BatteryLevel batteryLevel) {}
|
||||
|
||||
|
||||
//void OnDataReceived (Tizen::Uix::Sensor::SensorType sensorType, Tizen::Uix::Sensor::SensorData& sensorData, result r) {
|
||||
|
||||
//Tizen::Uix::Sensor::AccelerationSensorData& data = static_cast<Tizen::Uix::Sensor::AccelerationSensorData&>(sensorData);
|
||||
|
||||
//mAccelX = -data.x;
|
||||
//mAccelY = -data.y;
|
||||
//mAccelZ = -data.z;
|
||||
|
||||
//}
|
||||
|
||||
|
||||
void TizenApplication::OnForeground (void) {
|
||||
|
||||
Event activate (etActivate);
|
||||
@@ -314,4 +352,83 @@ namespace lime {
|
||||
}
|
||||
|
||||
|
||||
bool ClearUserPreference (const char *inId) {
|
||||
|
||||
result r = E_SUCCESS;
|
||||
|
||||
Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance ();
|
||||
r = appRegistry->Remove (inId);
|
||||
|
||||
return (r == E_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool GetAcceleration (double &outX, double &outY, double &outZ) {
|
||||
|
||||
//if (gFixedOrientation == 3 || gFixedOrientation == 4) {
|
||||
|
||||
//outX = mAccelX;
|
||||
//outY = mAccelY;
|
||||
//outZ = mAccelZ;
|
||||
outX = 0;
|
||||
outY = 0;
|
||||
outZ = 1;
|
||||
return true;
|
||||
|
||||
//}
|
||||
|
||||
/*int result = accelerometer_read_forces (&outX, &outY, &outZ);
|
||||
|
||||
if (getenv ("FORCE_PORTRAIT") != NULL) {
|
||||
|
||||
int cache = outX;
|
||||
outX = outY;
|
||||
outY = -cache;
|
||||
|
||||
}
|
||||
|
||||
outZ = -outZ;*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
std::string GetUserPreference (const char *inId) {
|
||||
|
||||
Tizen::Base::String value;
|
||||
result r = E_SUCCESS;
|
||||
|
||||
Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance ();
|
||||
r = appRegistry->Get (inId, value);
|
||||
|
||||
if (r == E_SUCCESS) {
|
||||
|
||||
std::wstring dir = std::wstring (value.GetPointer ());
|
||||
return std::string (dir.begin (), dir.end ());
|
||||
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool SetUserPreference (const char *inId, const char *inPreference) {
|
||||
|
||||
result r = E_SUCCESS;
|
||||
|
||||
Tizen::App::AppRegistry* appRegistry = Tizen::App::AppRegistry::GetInstance ();
|
||||
r = appRegistry->Set (inId, inPreference);
|
||||
|
||||
if (r != E_SUCCESS) {
|
||||
|
||||
r = appRegistry->Add (inId, inPreference);
|
||||
|
||||
}
|
||||
|
||||
return (r == E_SUCCESS);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user