Permalink
Browse files

Merge pull request #372 from MoSync/ThreeTwoOne

Three two one
  • Loading branch information...
Ali Sarrafi
Ali Sarrafi committed Feb 20, 2013
2 parents ad11d1b + 1ba399c commit ae479392201f772e28469e3e6b0fe7e790c14d6e
Showing with 1,556 additions and 790 deletions.
  1. +1 −2 examples/cpp/CameraDemo/ImageScreen.cpp
  2. +3 −2 examples/cpp/CameraDemo/SettingsScreen.cpp
  3. +2 −1 examples/cpp/CameraDemo/main.cpp
  4. +7 −1 examples/cpp/Graphun/UIFramework/ListSelectionScreen.cpp
  5. +1 −0 examples/cpp/Graphun/UIFramework/ListSelectionScreen.h
  6. +18 −1 examples/cpp/Graphun/main.cpp
  7. +2 −2 intlibs/bluetooth/darwin/interface.mm
  8. +1 −0 libs/NativeUI/Screen.cpp
  9. +1 −0 libs/NativeUI/Screen.h
  10. +3 −2 libs/Notification/LocalNotification.cpp
  11. +1 −0 libs/Notification/LocalNotification.h
  12. +3 −0 libs/Notification/LocalNotificationListener.h
  13. +1 −3 libs/Notification/NotificationManager.cpp
  14. +1 −3 libs/Notification/NotificationManager.h
  15. +17 −14 libs/Wormhole/Encoder.cpp
  16. +5 −0 libs/Wormhole/Libs/JSNativeUI/ResourceMessageHandler.cpp
  17. +11 −10 libs/Wormhole/Libs/PhoneGap/PhoneGapMessageHandler.cpp
  18. +7 −0 libs/Wormhole/MessageHandler.cpp
  19. +21 −5 libs/Wormhole/jslib/mosync-bridge.js
  20. +6 −3 libs/Wormhole/jslib/phonegap-1.2.0.js
  21. +1 −0 platforms/Android/AndroidManifest.template
  22. +2 −0 runtimes/cpp/platforms/android/MoSyncBridge.cpp
  23. +1 −1 runtimes/cpp/platforms/iphone/Classes/Expanded/NSDataExpanded.mm
  24. +4 −0 runtimes/cpp/platforms/iphone/Classes/NativeUI/Layouts/HorizontalLayoutWidget.mm
  25. +6 −0 runtimes/cpp/platforms/iphone/Classes/NativeUI/Layouts/LayoutWidgets.mm
  26. +1 −1 runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm
  27. +4 −4 runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm
  28. +1 −1 runtimes/cpp/platforms/iphone/Classes/ads/Ads.mm
  29. +3 −3 runtimes/cpp/platforms/iphone/Classes/audio/AudioSyscall.mm
  30. +2 −2 runtimes/cpp/platforms/iphone/Classes/capture/Capture.mm
  31. +16 −16 runtimes/cpp/platforms/iphone/Classes/impl/SyscallImpl.mm
  32. +4 −4 runtimes/cpp/platforms/iphone/Classes/notifications/NotificationManager.mm
  33. +2 −2 runtimes/cpp/platforms/iphone/Classes/purchase/PurchaseProduct.mm
  34. +2 −2 runtimes/cpp/platforms/sdl/MacDialogs.mm
  35. +2 −2 ...dowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/ListView/ListViewWidgets/MoSyncListView.cs
  36. +8 −1 ...phone/mosync/mosyncRuntime/Source/Modules/NativeUI/ListView/ListViewWidgets/MoSyncListViewItem.cs
  37. +3 −0 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncActivityIndicator.cs
  38. +0 −3 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncButton.cs
  39. +168 −95 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncHorizontalLayout.cs
  40. +0 −3 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncImageButton.cs
  41. +252 −106 ...es/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncNativeUIWindowsPhone.cs
  42. +160 −90 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncVerticalLayout.cs
  43. +0 −3 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncWebView.cs
  44. +1 −0 runtimes/java/platforms/androidJNI/AndroidProject/AndroidManifest.xml
  45. +11 −0 runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/EventQueue.java
  46. +65 −91 ...a/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/MoSyncCameraController.java
  47. +10 −2 runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/MoSyncThread.java
  48. +93 −0 ...tforms/androidJNI/AndroidProject/src/com/mosync/internal/android/notifications/AlarmReceiver.java
  49. +123 −4 ...roidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationObject.java
  50. +115 −85 ...idJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java
  51. +124 −120 ...idJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsService.java
  52. +163 −0 ...droidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsUtil.java
  53. +28 −12 runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/java/android/MoSync.java
  54. +32 −51 ...a/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/MoSyncCameraPreview.java
  55. +2 −2 testPrograms/JSNativeUICloneTest/LocalFiles/index.html
  56. +2 −0 testPrograms/JSNativeUICloneTest/main.cpp
  57. +1 −1 testPrograms/native_ui/iphone/Classes/MoSyncUISyscalls.mm
  58. +2 −17 testPrograms/notification/LocalNotificationSender/CreateNotificationScreen.cpp
  59. +0 −10 testPrograms/notification/LocalNotificationSender/CreateNotificationScreen.h
  60. +17 −1 testPrograms/orientationNativeUI/TestOrientationForNativeUI/FirstScreen.cpp
  61. +4 −0 testPrograms/orientationNativeUI/TestOrientationForNativeUI/FirstScreen.h
  62. +3 −3 tests/Benchmarks/database_libs/ios/benchdb/BenchDB.m
  63. +2 −2 tools/idl2/NativeUI/WidgetEvent.idl
  64. +4 −1 tools/idl2/maapi.idl
@@ -116,12 +116,11 @@ void ImageScreen::setImageDataHandle(MAHandle dataHandle)
dataHandle,
0,
maGetDataSize(dataHandle));
- if(res != RES_OK)
+ if(res != RES_OK)
{
maPanic(res, "failed to create the image");
}
//Set the image to the image widget
mImageWidget->setScaleMode(IMAGE_SCALE_PRESERVE_ASPECT);
mImageWidget->setImage(mImageHandle);
-
}
@@ -54,6 +54,7 @@ void SettingsScreen::buttonClicked(Widget* button)
}
else if(mSwapCameraButton == button)
{
+ printf("currentCamera = %d; numCameras = %d", currentCamera, numCameras);
if(currentCamera < numCameras-1)
{
currentCamera++;
@@ -84,7 +85,7 @@ void SettingsScreen::buttonClicked(Widget* button)
void SettingsScreen::initialize(StackScreen* stackScreen)
{
mStackScreen = stackScreen;
- numCameras = maCameraNumber();
+ //numCameras = maCameraNumber();
createUI();
}
@@ -168,7 +169,7 @@ void SettingsScreen::pushSettingsScreen()
/**
* A wrapper for iterating over flash modes
*/
-const char* SettingsScreen::getModeForIndex( int index)
+const char* SettingsScreen::getModeForIndex(int index)
{
switch(index)
{
@@ -257,8 +257,8 @@ class AppScreen : public ButtonListener, public StackScreenListener
*/
void setupCameraProperties()
{
- setupCameraSize();
maCameraSelect(mSettingsScreen->getCurrentCamera());
+ setupCameraSize();
mCameraPreview->bindToCurrentCamera();
maCameraSetProperty(
MA_CAMERA_FLASH_MODE,
@@ -383,6 +383,7 @@ class AppScreen : public ButtonListener, public StackScreenListener
maDestroyPlaceholder(mLastEnc);
mLastEnc = 0;
}
+ maCameraStop();
setupCameraProperties();
maCameraStart();
}
@@ -15,7 +15,8 @@ along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
MA 02110-1301, USA.
*/
-
+#include <ma.h>
+#include <IX_WIDGET.h>
#include "ListSelectionScreen.h"
namespace MoSync {
@@ -43,5 +44,10 @@ namespace UI {
void ListSelectionScreen::listboxItemSelected(UIItem* item, int index) {
}
+
+ void ListSelectionScreen::requestListFocus()
+ {
+ maWidgetSetProperty(mListView->getHandle(), MAW_LIST_VIEW_REQUEST_FOCUS, "true");
+ }
}
}
@@ -33,6 +33,7 @@ class ListSelectionScreen : public Screen {
void addStrings(Vector<String>& items);
virtual void listboxItemSelected(UIItem* item, int index);
+ void requestListFocus();
protected:
Widget* mListView;
};
@@ -126,6 +126,10 @@ class SettingsScreen: public Screen {
void checkboxStateChanged(UIItem* item, bool checked);
void listboxItemSelected(UIItem* item, int index);
+ /**
+ * Enforce list focus on items. (Android 4.x bug).
+ */
+ virtual void requestListFocus();
protected:
Widget* mListView;
@@ -207,8 +211,8 @@ class HelpScreen: public TextScreen {
virtual void buttonClicked(UIItem* item) {
const String& exp = mExpressions[item];
sMainScreen->setExpression(exp);
+ sSettingsScreen->requestListFocus();
sStackScreen->pop();
- //sStackScreen->pop();
}
protected:
@@ -363,6 +367,7 @@ void MainScreen::pointerReleaseEvent(MAPoint2d p) {
void MainScreen::buttonClicked(UIItem* item) {
if (item == mSettingsButton) {
+ sSettingsScreen->requestListFocus();
sStackScreen->pushScreen(sSettingsScreen);
}
}
@@ -447,15 +452,26 @@ void SettingsScreen::checkboxStateChanged(UIItem* item, bool checked) {
void SettingsScreen::listboxItemSelected(UIItem* item, int index) {
if (item == mListView && index == 1) {
+ Graphun::sResolutionSelector->requestListFocus();
Graphun::sStackScreen->pushScreen(Graphun::sResolutionSelector);
} else if (item == mListView && index == 2) {
+ requestListFocus();
Graphun::sStackScreen->pushScreen(Graphun::sHelpScreen);
} else if (item == mListView && index == 3) {
+ requestListFocus();
Graphun::sStackScreen->pushScreen(Graphun::sAboutScreen);
}
}
+/**
+ * Enforce list focus on items. (Android 4.x bug).
+ */
+void SettingsScreen::requestListFocus()
+{
+ maWidgetSetProperty(mListView->getHandle(), MAW_LIST_VIEW_REQUEST_FOCUS, "true");
+}
+
class ResolutionSelector: public ListSelectionScreen {
public:
@@ -479,6 +495,7 @@ class ResolutionSelector: public ListSelectionScreen {
else if (index == 2)
sMainScreen->getGrid()->initGrid(32, 32);
+ sSettingsScreen->requestListFocus();
Graphun::sStackScreen->pop();
}
}
@@ -198,7 +198,7 @@ int maBtGetNewDevice ( MABtDeviceNative* d )
NSString* deviceNameString = [dev getNameOrAddress];
d->actualNameLength=deviceNameString.length;
const char *cstr = new char[deviceNameString.length+1];
- cstr = [deviceNameString cStringUsingEncoding:NSASCIIStringEncoding];
+ cstr = [deviceNameString cStringUsingEncoding:NSUTF8StringEncoding];
if (cstr == NULL) cstr = "NO NAME";
strcpy(d->name, cstr);
}
@@ -259,7 +259,7 @@ int maBtGetNewService ( MABtServiceNative* d )
// Fill the name field of the NABtDevice structure
NSString *serviceName = [record getServiceName];
const char *cstr = new char[serviceName.length+1];
- cstr = [serviceName cStringUsingEncoding:NSASCIIStringEncoding];
+ cstr = [serviceName cStringUsingEncoding:NSUTF8StringEncoding];
if (cstr == NULL) cstr = "NO NAME";
strcpy(d->name, cstr);
View
@@ -118,6 +118,7 @@ namespace NativeUI
* Called just before the screen begins rotating.
* Subclasses may override this method to perform additional actions
* immediately prior to the rotation.
+ * Note: available only on iOS.
*/
void Screen::orientationWillChange()
{
View
@@ -106,6 +106,7 @@ namespace NativeUI
* Called just before the screen begins rotating.
* Subclasses may override this method to perform additional actions
* immediately prior to the rotation.
+ * Note: available only on iOS.
*/
virtual void orientationWillChange();
@@ -363,14 +363,15 @@ namespace Notification
}
/**
+ * @deprecated. The local notification is displayed now regardless of the applications's state.
* Set the display flags applied to the local notification.
* Note that regardless of this setting, the didReceiveLocalNotification
* callback will be made for each incoming notification.
- * #NOTIFICATION_DISPLAY_ONLY_IF_IN_BACKGROUND is enabled by default.
+ * #NOTIFICATION_DISPLAY_DEFAULT is enabled by default.
* Platform: Android.
* @param displayFlag is the required state of the application for
* a notification to be displayed. One of the constants:
- * - #NOTIFICATION_DISPLAY_ONLY_IF_IN_BACKGROUND
+ * - #NOTIFICATION_DISPLAY_DEFAULT
* - #NOTIFICATION_DISPLAY_ANYTIME.
* @return Any of the following result codes:
* - #MA_NOTIFICATION_RES_OK if the property could be set.
@@ -338,6 +338,7 @@ namespace Notification
int setFlag(const NotificationFlag flag);
/**
+ * @deprecated. The local notification is displayed now regardless of the applications's state.
* Set the display flags applied to the local notification.
* Note that regardless of this setting, the didReceiveLocalNotification
* callback will be made for each incoming notification.
@@ -53,6 +53,9 @@ namespace Notification
public:
/**
* Called when the application receives a local notification.
+ * Note: this event will be received only if the application
+ * was not stopped in the interval from when the notification
+ * is scheduled until it's actually triggered.
* @param localNotification The received local notification.
*/
virtual void didReceiveLocalNotification(
@@ -186,9 +186,7 @@ namespace Notification
/**
* Schedules a local notification for delivery at its encapsulated
* date and time.
- * By default, the notifications are displayed to the user only if the application
- * is in background. But on Android you can configure this via the
- * #MA_NOTIFICATION_LOCAL_DISPLAY_FLAG property by calling setDisplayFlag().
+ * The local notification is displayed regardless of the applications's state.
* @param localNotification Handle to a local notification object.
* @return One of the constants:
* - #MA_NOTIFICATION_RES_OK if no error occurred.
@@ -177,9 +177,7 @@ namespace Notification
/**
* Schedules a local notification for delivery at its encapsulated
* date and time.
- * By default, the notifications are displayed to the user only if the application
- * is in background. But on Android you can configure this via the
- * #MA_NOTIFICATION_LOCAL_DISPLAY_FLAG property by calling setDisplayFlag().
+ * The local notification is displayed regardless of the applications's state.
* @param localNotification Handle to a local notification object.
* @return One of the constants:
* - #MA_NOTIFICATION_RES_OK if no error occurred.
View
@@ -121,35 +121,38 @@ namespace Wormhole
String Encoder::JSONStringify(const char* str)
{
String jsonString = "\"";
- int length = strlen(str);
+
char hexBuf[8];
hexBuf[0] = '\\';
- hexBuf[1] = '\\';
- hexBuf[2] = 'u';
+ hexBuf[1] = 'u';
+ hexBuf[2] = '0';
hexBuf[3] = '0';
- hexBuf[4] = '0';
- hexBuf[7] = 0;
+ hexBuf[6] = 0;
+
char strBuf[2];
strBuf[1] = 0;
+ int length = strlen(str);
+
for (int i = 0; i < length; ++i)
{
strBuf[0] = str[i];
String escaped = strBuf;
switch (str[i])
{
- case '\r': escaped = "\\\\r"; break;
- case '\n': escaped = "\\\\n"; break;
- case '\\': escaped = "\\\\\\\\"; break;
- case '/': escaped = "\\\\/"; break;
- case '"': escaped = "\\\\\""; break;
- case '\f': escaped = "\\\\f"; break;
- case '\b': escaped = "\\\\b"; break;
- case '\t': escaped = "\\\\t"; break;
+ case '\r': escaped = "\\r"; break;
+ case '\n': escaped = "\\n"; break;
+ case '\\': escaped = "\\\\"; break;
+ case '/': escaped = "\\/"; break;
+ case '"': escaped = "\\\""; break;
+ case '\'': escaped = "\\'"; break;
+ case '\f': escaped = "\\f"; break;
+ case '\b': escaped = "\\b"; break;
+ case '\t': escaped = "\\t"; break;
default:
if ((unsigned char) str[i] < 32)
{
- CharToHex(str[i], hexBuf + 5);
+ CharToHex(str[i], hexBuf + 4);
escaped = hexBuf;
}
break;
@@ -144,6 +144,11 @@ namespace Wormhole
*/
MAHandle ResourceMessageHandler::loadImageResource(const char* imagePath)
{
+ if (!getFileUtil())
+ {
+ return 0;
+ }
+
// Get the current apllication directory path.
String appPath = getFileUtil()->getAppPath();
@@ -26,6 +26,7 @@ MA 02110-1301, USA.
#include <maapi.h>
#include <mastdlib.h> // C string conversion functions
#include <conprint.h>
+#include "../../Encoder.h"
#include "PhoneGapMessageHandler.h"
namespace Wormhole
@@ -332,17 +333,17 @@ namespace Wormhole
// Send the result back to PhoneGap.
sprintf(buffer,
- "\\'{"
- "\"platform\":\"%s\","
- "\"name\":\"%s\","
- "\"uuid\":\"%s\","
- "\"version\":\"%s\","
+ "{"
+ "\"platform\":%s,"
+ "\"name\":%s,"
+ "\"uuid\":%s,"
+ "\"version\":%s,"
"\"phonegap\":\"1.2.0\""
- "}\\'",
- deviceOS,
- deviceName,
- deviceUUID,
- deviceOSVersion
+ "}",
+ Encoder::JSONStringify(deviceOS).c_str(),
+ Encoder::JSONStringify(deviceName).c_str(),
+ Encoder::JSONStringify(deviceUUID).c_str(),
+ Encoder::JSONStringify(deviceOSVersion).c_str()
);
callSuccess(
@@ -24,6 +24,7 @@ MA 02110-1301, USA.
* messages from Wormhole (JavaScript).
*/
+#include <mastring.h>
#include "CustomMoblet.h"
#include "MessageHandler.h"
#include "HybridMoblet.h"
@@ -335,6 +336,7 @@ void MessageHandler::handleMoSyncMessage(
Wormhole::HybridMoblet* moblet)
{
const char* p = message.getNext();
+ const char* logMessage;
if (0 == strcmp(p, "ExitApplication"))
{
@@ -345,6 +347,11 @@ void MessageHandler::handleMoSyncMessage(
{
maSendToBackground();
}
+ else if (0 == strcmp(p, "SysLog"))
+ {
+ logMessage = message.getNext();
+ maWriteLog(logMessage, strlen(logMessage));
+ }
else if (0 == strcmp(p, "ScreenSetOrientation"))
{
screenSetOrientation(message.getNext());
Oops, something went wrong.

0 comments on commit ae47939

Please sign in to comment.