Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/ThreeTwoOne' into ThreeTwoOne
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikael Kindborg committed Mar 11, 2013
2 parents e634d9c + e17b192 commit 62ae5b0
Show file tree
Hide file tree
Showing 12 changed files with 96 additions and 62 deletions.
13 changes: 13 additions & 0 deletions examples/cpp/NativeUIMap/Readme.txt
Original file line number Diff line number Diff line change
@@ -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");
14 changes: 14 additions & 0 deletions examples/cpp/WikiSearchNativeUI/Util.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
17 changes: 11 additions & 6 deletions examples/cpp/WikiSearchNativeUI/WikiEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
Expand All @@ -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;
Expand Down
23 changes: 15 additions & 8 deletions libs/Wormhole/Libs/Notification/PushNotificationManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
using System.Text.RegularExpressions;
using System.Reflection;
using System.Windows.Media;
using System.Globalization;

namespace MoSync
{
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down Expand Up @@ -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());
Expand Down
2 changes: 1 addition & 1 deletion testPrograms/native_ui_lib/MapTest/MainScreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
13 changes: 13 additions & 0 deletions testPrograms/native_ui_lib/MapTest/Readme.txt
Original file line number Diff line number Diff line change
@@ -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");
9 changes: 4 additions & 5 deletions testPrograms/notification/LocalNotificationSender/ReadMe.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,24 @@ 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.
- the Flash LED settings( that are available only on Android): By checking the Flashing check box, the default flashing
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.

Expand Down

0 comments on commit 62ae5b0

Please sign in to comment.