diff --git a/examples/cpp/NativeUIMap/Readme.txt b/examples/cpp/NativeUIMap/Readme.txt new file mode 100644 index 000000000..07df877f2 --- /dev/null +++ b/examples/cpp/NativeUIMap/Readme.txt @@ -0,0 +1,13 @@ +Purpose: +The test program shows the native ui map functionality and provides UI elements for doing +the following: + - add/remove multiple random map pins + - set/get visible area + - set zoom level + - center the map + - a map control is visible and available for interraction to the user + +IMPORTANT: + ADD YOU OWN MAP CREDENTIALS INSIDE THE MAP CONSTRUCTOR: + MainScreen.cpp: + mMap = new Map("google maps test credentials", "bing maps test credentials"); \ No newline at end of file diff --git a/examples/cpp/WikiSearchNativeUI/Util.h b/examples/cpp/WikiSearchNativeUI/Util.h index 99f2db82d..106f90fb4 100644 --- a/examples/cpp/WikiSearchNativeUI/Util.h +++ b/examples/cpp/WikiSearchNativeUI/Util.h @@ -122,6 +122,20 @@ const MAUtil::String ERROR_NO_RESULTS = "There are no results."; /** The results cannot be parsed. **/ const MAUtil::String ERROR_INVALID_DATA = "Invalid results.Error:"; +// Some Http request and response field names. +/** +* Field name that can be used for #maHttpSetRequestHeader. +*/ +const String HTTP_REQUEST_HEADER_USER_AGENT = "User-Agent"; +/** +* Field name that can be used for #maHttpSetRequestHeader. +*/ +const String HTTP_REQUEST_HEADER_ACCEPT_ENCODING = "Accept-Encoding"; +/** +* Field name that can be used for @maHttpGetResponseHeader. +*/ +const String HTTP_RESPONSE_HEADER_CONTENT_LENGTH = "Content-Length"; + /** * Utility functions for creating NativeUI widgets. */ diff --git a/examples/cpp/WikiSearchNativeUI/WikiEngine.cpp b/examples/cpp/WikiSearchNativeUI/WikiEngine.cpp index 0988c051e..6c528b520 100644 --- a/examples/cpp/WikiSearchNativeUI/WikiEngine.cpp +++ b/examples/cpp/WikiSearchNativeUI/WikiEngine.cpp @@ -224,12 +224,18 @@ void MediaWiki::search(MAUtil::String searchTerm, int resultsLimit) constructApiUrl(); int res = mHttp.create(mWiki->apiUrl.c_str(), HTTP_GET); + + // Enforce compress disabling, so we can count on a real content length value. + mHttp.setRequestHeader(HTTP_REQUEST_HEADER_ACCEPT_ENCODING.c_str(),"identity"); + mHttp.setRequestHeader(HTTP_REQUEST_HEADER_USER_AGENT.c_str(),"WikipediaSearchNativeUI"); + if(res < 0) { // It have failed for some reason. - mHomeScreen->engineError(ERROR_NO_CONNECTION); + mHomeScreen->engineError("The error is " + MAUtil::integerToString(res));//ERROR_NO_CONNECTION); + mHttp.close(); + mIsConnected = false; } else { - mHttp.setRequestHeader("User-Agent","WikipediaSearchNativeUI"); mHttp.finish(); mIsConnected = true; } @@ -248,14 +254,13 @@ void MediaWiki::httpFinished(MAUtil::HttpConnection *conn, int result) if ( result >= 0) { MAUtil::String contentLengthStr; - // todo: check return value. - mHttp.getResponseHeader("Content-Length", + mHttp.getResponseHeader(HTTP_RESPONSE_HEADER_CONTENT_LENGTH.c_str(), &contentLengthStr); int contentLength = 0; contentLength = atoi(contentLengthStr.c_str()); - if (contentLength >= CONNECTION_BUFFER_SIZE || contentLength == 0) { + if (contentLength >= CONNECTION_BUFFER_SIZE || contentLength != 0) { // Receive in chunks. // Calculate how many chunks we receive, so that we can increment // a progress bar for this action. @@ -282,7 +287,7 @@ void MediaWiki::httpFinished(MAUtil::HttpConnection *conn, int result) else { // Notify UI on the error. - mHomeScreen->engineError( ERROR_NO_CONNECTION ); + mHomeScreen->engineError( MAUtil::integerToString(result));//ERROR_NO_CONNECTION ); mHttp.close(); mIsConnected = false; diff --git a/libs/Wormhole/Libs/Notification/PushNotificationManager.cpp b/libs/Wormhole/Libs/Notification/PushNotificationManager.cpp index 1666ceaa9..b1c69365d 100644 --- a/libs/Wormhole/Libs/Notification/PushNotificationManager.cpp +++ b/libs/Wormhole/Libs/Notification/PushNotificationManager.cpp @@ -144,18 +144,25 @@ namespace Wormhole sprintf( data, - "\\'{\"message\": \"%s\"," + "{\"message\": %s," "\"sound\": \"%s\"," - "\"iconBadge\":\"%d\"}\\'", - message.c_str(), + "\"iconBadge\":\"%d\"}", + Encoder::JSONStringify(message.c_str()).c_str(), sound.c_str(), iconBadge); - mMessageHandler->callSuccess( - mListenerCallBack, - PHONEGAP_CALLBACK_STATUS_OK, - data, - true); + String args = ""; + args += "{"; + args += "\"status\":" + ((MAUtil::String) PHONEGAP_CALLBACK_STATUS_OK); + args += ",\"message\":" + Encoder::JSONStringify(data); + args += ",\"keepCallback\":true"; + args += "}"; + + String script = "PhoneGap.CallbackSuccess("; + script += "'" + mListenerCallBack + "',"; + script += Encoder::JSONStringify(args.c_str()) + ")"; + + mMessageHandler->callJS(script); } /** diff --git a/runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm b/runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm index cb3cc6a11..9f5baad5e 100644 --- a/runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm +++ b/runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm @@ -382,25 +382,29 @@ int maWidgetSetProperty(MAWidgetHandle handle, const char *property, const char* IWidget* widget = [mosyncUI getWidget:handle]; if(widget == NULL) return MAW_RES_INVALID_HANDLE; + if(property == NULL) + return MAW_RES_INVALID_PROPERTY_NAME; + + if(value == NULL) + return MAW_RES_INVALID_PROPERTY_VALUE; + NSString* propertyString = stringFromChar(property); if([widget class] == [GLViewWidget class] || [widget class] == [GL2ViewWidget class] ) { // do this from the MoSync thread. Maybe do a generic system for this later. - if([propertyString isEqualToString:@"bind"]) { + if([propertyString isEqualToString:@"bind"]) + { + [propertyString release]; return [widget setPropertyWithKey:@"bind" toValue:@""]; } - if([propertyString isEqualToString:@"invalidate"]) { + if([propertyString isEqualToString:@"invalidate"]) + { + [propertyString release]; return [widget setPropertyWithKey:@"invalidate" toValue:@""]; } } - if(property == NULL) - return MAW_RES_INVALID_PROPERTY_NAME; - - if(value == NULL) - return MAW_RES_INVALID_PROPERTY_VALUE; - int returnValue; NSString *valueString = stringFromChar(value); diff --git a/runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm b/runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm index 261902178..ff8d71f59 100644 --- a/runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm +++ b/runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm @@ -76,15 +76,17 @@ - (int)setPropertyWithKey: (NSString*)key toValue: (NSString*)value { { NSURL *url; //Process a normal URL + //URLs can only be sent over the Internet using the ASCII character-set. if (schemaLocation.location == NSNotFound) { NSString *urlString = [NSString stringWithFormat:@"%@%@", baseUrl, value]; - NSString* webURLString = [urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]; + NSString* webURLString = [urlString stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]; url = [[NSURL URLWithString: webURLString] filePathURL]; } else { // Convert the string URL into ascii encoding. - NSData* data = [value dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:YES]; - NSString* formattedURL = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; - url = [NSURL URLWithString:formattedURL]; + NSData* data = [value dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]; + NSString* formattedURL = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]; + // Used stringByAddingPercentEscapesUsingEncoding in order to replace spaces with speficit percent characters. + url = [NSURL URLWithString:[formattedURL stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding]]; [formattedURL release]; } diff --git a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncLabel.cs b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncLabel.cs index dc114801d..2831a7cb2 100644 --- a/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncLabel.cs +++ b/runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncLabel.cs @@ -16,6 +16,7 @@ using System.Text.RegularExpressions; using System.Reflection; using System.Windows.Media; +using System.Globalization; namespace MoSync { @@ -207,7 +208,9 @@ public String fontSize set { double size = 0; - if (double.TryParse(value, out size)) + NumberStyles style = NumberStyles.AllowDecimalPoint; + IFormatProvider provider = CultureInfo.InvariantCulture; + if (Double.TryParse(value, style, provider, out size)) { // for some values better use the default size of the platform mLabel.FontSize = size <= 0 ? 11 : size; diff --git a/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java b/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java index 8bbd3d59d..e0fc3c877 100644 --- a/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java +++ b/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java @@ -100,35 +100,6 @@ public int destroy(int handle) LocalNotificationObject notification = m_NotificationTable.get(handle); if ( null != notification ) { - // Remove the service notification if it is pending. - if ( notification.isActive() ) - { - LocalNotificationsService.removeServiceNotification( - m_NotificationTable.get(handle).getId(), - mMoSyncThread.getActivity()); - - // Stop the service, even when the application is in background. - LocalNotificationsService.stopService(); - } - // Cancel the intent assigned to the notification if scheduled. - if ( null != m_Intents.get(handle) ) - { - AlarmManager alarmManager = - (AlarmManager) mMoSyncThread.getActivity().getSystemService(Context.ALARM_SERVICE); - - // Set the unique request code as the handle. - PendingIntent pendingIntent = PendingIntent.getBroadcast( - mMoSyncThread.getActivity(), - notification.getRequestCode(), - m_Intents.get(handle), - PendingIntent.FLAG_NO_CREATE); - if ( pendingIntent != null ) - { - alarmManager.cancel(pendingIntent); - } - m_Intents.remove(handle); - } - // Remove the internal notification object. m_NotificationTable.remove(handle); @@ -296,6 +267,7 @@ public int schedule(final int handle, final Context appContext) alarmManager.set(AlarmManager.RTC_WAKEUP, notification.getFireDate(), pendingIntent); m_Intents.put(handle, intent); + return MA_NOTIFICATION_RES_OK; } } diff --git a/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/ListViewSection.java b/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/ListViewSection.java index 44f18946d..c1594a419 100644 --- a/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/ListViewSection.java +++ b/runtimes/java/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/ListViewSection.java @@ -185,6 +185,7 @@ public boolean setProperty(String property, String value) createSegmentedSectionDefaultUI(); break; case IX_WIDGET.MAW_LIST_VIEW_SECTION_TYPE_ALPHABETICAL: + mHasFooter = false; break; default: Log.e("@@MoSync","maWidgetSetProperty invalid List View Section type"); @@ -516,6 +517,7 @@ public void setAlphaSectionFooter(String text) { // Create and add the footer after the last item - if that exists. addSectionFooter(); + mHasFooter = true; setFooterText(text); if (mAdapterListener != null) mAdapterListener.itemAdded(mItems.get(mItems.size()), this, mItems.size()); diff --git a/testPrograms/native_ui_lib/MapTest/MainScreen.cpp b/testPrograms/native_ui_lib/MapTest/MainScreen.cpp index 271aa33ff..4df847187 100644 --- a/testPrograms/native_ui_lib/MapTest/MainScreen.cpp +++ b/testPrograms/native_ui_lib/MapTest/MainScreen.cpp @@ -97,7 +97,7 @@ void MainScreen::createMainLayout() { mMainLayout->addChild(mSetCenterButton); // create the main map and add it to the main layout - mMap = new Map("google test credentials", "AsIe6nHOHjIuf9MQS4fW7up92BO6HuCwspKJqYwffZiqUJsgXuLIXeBdCf9EM4yz"); + mMap = new Map("google test credentials", "AuQ7GMB3AJPFp5GPHbuQ2WVyhQUd9DjYJ6u5aR6a_uXZZdX5KuHJ7XMU4GNvO6mh"); mMap->fillSpaceHorizontally(); mMap->fillSpaceVertically(); diff --git a/testPrograms/native_ui_lib/MapTest/Readme.txt b/testPrograms/native_ui_lib/MapTest/Readme.txt new file mode 100644 index 000000000..07df877f2 --- /dev/null +++ b/testPrograms/native_ui_lib/MapTest/Readme.txt @@ -0,0 +1,13 @@ +Purpose: +The test program shows the native ui map functionality and provides UI elements for doing +the following: + - add/remove multiple random map pins + - set/get visible area + - set zoom level + - center the map + - a map control is visible and available for interraction to the user + +IMPORTANT: + ADD YOU OWN MAP CREDENTIALS INSIDE THE MAP CONSTRUCTOR: + MainScreen.cpp: + mMap = new Map("google maps test credentials", "bing maps test credentials"); \ No newline at end of file diff --git a/testPrograms/notification/LocalNotificationSender/ReadMe.txt b/testPrograms/notification/LocalNotificationSender/ReadMe.txt index 1f11c307e..040da0a0d 100644 --- a/testPrograms/notification/LocalNotificationSender/ReadMe.txt +++ b/testPrograms/notification/LocalNotificationSender/ReadMe.txt @@ -4,10 +4,12 @@ On Android only there are two more texts to set: - content body title and - the ticker text. (Ticker text: the text that flows by in the status bar when the notification first activates.) + Next, you can set for iOS only: - the badge number, -the alert action (the title of the action button or slider). - Next the Default Sound can be enabled/disabled. + +Next the Default Sound can be enabled/disabled. Below, settings available only on Android: - the Vibration settings ( that are available only on Android): By checking the Vibration check box, the default vibration pattern is applied. If the vibration duration is set, it will be used instead. @@ -15,14 +17,11 @@ vibration pattern is applied. If the vibration duration is set, it will be used pattern is applied to the notification. If the pattern is set(by filling the next 3 edit boxes), it will be used instead. If the flashing is not supported on the device you will get the message "Not available" inside the edit boxes for this settings. Note that you need to enable the Notification LED lights from device's Settings. + The Flashing pattern is consisted of: - a color, in the format 0xRRGGBB, for instance red: 0xFF0000. - led on = length of time, in seconds, to keep the light on. - led off = length of time, in seconds, to keep the light off. -- The "Show only when in background" setting. This is available only on Android. On iOS the user sees the notification only -if the application is running in background. On Android this can be configured: by checking this setting the notification -will be displayed only if the app is running in background. By un-checking it you will get the notification regardless of the -focus state. The last setting is the fire date: number of seconds for scheduling.