Permalink
Browse files

Merge pull request #399 from MoSync/ThreeTwoOne

Three two one
  • Loading branch information...
Ali Sarrafi
Ali Sarrafi committed Mar 12, 2013
2 parents 23b1563 + 7befd7b commit f4a9b180645e9da562faa067fc3c8080ab98daae
Showing with 195 additions and 102 deletions.
  1. +13 −0 examples/cpp/NativeUIMap/Readme.txt
  2. +1 −1 examples/cpp/SensorTest/consts.h
  3. +14 −0 examples/cpp/WikiSearchNativeUI/Util.h
  4. +11 −6 examples/cpp/WikiSearchNativeUI/WikiEngine.cpp
  5. +2 −1 examples/html5/PhotoGallery/LocalFiles/index.html
  6. +10 −2 examples/html5/PhotoGallery/LocalFiles/page-about.html
  7. +5 −2 examples/html5/PhotoGallery/LocalFiles/page-camera.html
  8. +2 −3 examples/html5/PhotoGallery/LocalFiles/page-gallery.html
  9. +18 −14 examples/html5/PhotoGallery/Server/upload.php
  10. +9 −0 examples/html5/PhotoGallery/readme.txt
  11. +1 −1 examples/html5/WebViewLoveSMS/LocalFiles/index.html
  12. +6 −6 examples/html5/WebViewTwitter/LocalFiles/index.html
  13. +2 −2 examples/html5/WormholeNativeUI/LocalFiles/index.html
  14. +2 −0 libs/Notification/LocalNotification.cpp
  15. +2 −0 libs/Notification/LocalNotification.h
  16. +15 −8 libs/Wormhole/Libs/Notification/PushNotificationManager.cpp
  17. +6 −0 libs/Wormhole/Libs/PhoneGap/PhoneGapFile.cpp
  18. +18 −4 runtimes/cpp/platforms/iphone/Classes/MoSyncView.mm
  19. +12 −8 runtimes/cpp/platforms/iphone/Classes/NativeUI/Syscalls/MoSyncUISyscalls.mm
  20. +3 −0 runtimes/cpp/platforms/iphone/Classes/NativeUI/WidgetUtils/WidgetUtils.h
  21. +2 −0 runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/ButtonWidget.mm
  22. +6 −1 runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/ListViewItemWidget.mm
  23. +3 −1 runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/VideoViewWidget.mm
  24. +4 −3 runtimes/cpp/platforms/iphone/Classes/NativeUI/Widgets/WebViewWidget.mm
  25. +0 −3 runtimes/cpp/platforms/iphone/Classes/notifications/NotificationManager.mm
  26. +4 −1 runtimes/csharp/windowsphone/mosync/mosyncRuntime/Source/Modules/NativeUI/MoSyncLabel.cs
  27. +1 −29 ...idJNI/AndroidProject/src/com/mosync/internal/android/notifications/LocalNotificationsManager.java
  28. +2 −0 .../java/platforms/androidJNI/AndroidProject/src/com/mosync/nativeui/ui/widgets/ListViewSection.java
  29. +1 −1 testPrograms/native_ui_lib/MapTest/MainScreen.cpp
  30. +13 −0 testPrograms/native_ui_lib/MapTest/Readme.txt
  31. +4 −5 testPrograms/notification/LocalNotificationSender/ReadMe.txt
  32. +3 −0 tools/idl2/maapi.idl
@@ -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");
@@ -37,7 +37,7 @@ MA 02110-1301, USA.
#define SCALE_FACTOR (gScreenWidth / BASE_SCREEN_WIDTH)
#define TEXT_SIZE (10 * SCALE_FACTOR)
#define OFFSET_X (10 * SCALE_FACTOR)
-#define OFFSET_Y 20
+#define OFFSET_Y TEXT_SIZE
// useful texts
#define TXT_NONE ""
@@ -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.
*/
@@ -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;
@@ -19,7 +19,8 @@
<html>
<head>
<title>Photo Gallery</title>
- <script src="js/wormhole.js"></script>
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
+ <script src="js/wormhole.js" charset="utf-8"></script>
<script type="text/javascript">
var app = (function()
{
@@ -8,6 +8,7 @@
<html>
<head>
<meta name="viewport" content="width=device-width">
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>About</title>
<link rel="stylesheet" href="style.css">
<style type="text/css">
@@ -21,9 +22,16 @@
<div id="screen">
<div id="heading">About</div>
<div class="pane button">
- <p>PhotoGallery is a demo app created with the MoSync Mobile SDK (mosync.com)</p>
- <p>Author: Mikael Kindborg, MoSync AB</p>
+ <p>PhotoGallery is an example application created
+ with the MoSync Mobile SDK (mosync.com)</p>
<p>Tab icons by Glyphish (glyphish.com)</p>
+ <p>DISCLAIMER</p>
+ <p>This application can be used to upload photos
+ to the Internet, which will make them publicly
+ available.</p>
+ <p>MoSync AB takes no responsibility for uploaded
+ photos or any damage the use of this application
+ may cause.</p>
</div>
</div>
</body>
@@ -12,9 +12,10 @@
<html>
<head>
<meta name="viewport" content="width=device-width">
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Camera</title>
<link rel="stylesheet" href="style.css">
- <script src="js/wormhole.js"></script>
+ <script src="js/wormhole.js" charset="utf-8"></script>
<script type="text/javascript">
var camera = (function()
{
@@ -66,7 +67,9 @@
<div class="pane view">
<img id="photo" src="img/MoSyncLogo.png" style="width:100%"/>
</div>
- <div class="pane button" onclick="camera.uploadPhoto()">Upload Photo</div>
+ <div class="pane button" onclick="camera.uploadPhoto()">
+ Upload Photo<br/>(makes your photo publicly available)
+ </div>
</div>
</body>
</html>
@@ -11,10 +11,10 @@
<html>
<head>
<meta name="viewport" content="width=device-width">
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Gallery</title>
<link rel="stylesheet" href="style.css">
- <script src="js/wormhole.js"></script>
- <script src="mosync-extensions.js"></script>
+ <script src="js/wormhole.js" charset="utf-8"></script>
<script>
var gallery = (function()
{
@@ -64,7 +64,6 @@
// Build new list (populate DOM).
var urls = JSON.parse(json);
- var limit = Math.min(20, urls.length);
for (var i = 0; i < urls.length; ++i)
{
var image = document.createElement('img');
@@ -3,18 +3,21 @@
ini_set("log_errors", "1");
error_reporting(-1);
+function mylog($message)
+{
+ $file = 'mylog.txt';
+ // Open the file to get existing content
+ $current = file_get_contents($file);
+ // Append a line to the file
+ $current .= "$message\n";
+ // Write the contents back to the file
+ file_put_contents($file, $current);
+}
+
function uploadPhoto()
{
$targetPath = "photos/" . basename($_FILES["file"]["name"]);
- echo "Target file: " . $targetPath;
- echo "<br/>";
-
- print_r($_FILES);
- echo "<br/>";
-
- echo fileIsImage($_FILES["file"]["name"]);
-
if (fileIsOK($_FILES["file"]))
{
$success = move_uploaded_file($_FILES["file"]["tmp_name"], $targetPath);
@@ -55,9 +58,8 @@ function endsWith($haystack, $needle)
function getPhotoURLs()
{
- $urls = getLast100PhotoURLs();
-
/*// For debugging.
+ $urls = getLastTenPhotoURLs();
foreach ($urls as $url)
{
echo "<a href='$url'>$url</a><br/>\n";
@@ -68,12 +70,13 @@ function getPhotoURLs()
function getPhotoURLsAsJSON()
{
- $urls = getLast100PhotoURLs();
+ $urls = getLastTenPhotoURLs();
return json_encode($urls);
}
-function getLast100PhotoURLs()
+// Gets last TEN photo urls.
+function getLastTenPhotoURLs()
{
$baseURL = "http://dev.mosync.com/mobilelua/PhotoGallery/photos/";
$baseDir = "photos/";
@@ -103,12 +106,13 @@ function getLast100PhotoURLs()
// List if URLs.
$urls = array();
- // Create a list of URLs to the most recent 100 files.
+ // Create a list of URLs to the most recent files.
$fileCounter = 0;
foreach ($files as $file)
{
++$fileCounter;
- if ($fileCounter > 100)
+ // We only get TEN recent files (100 is too many!).
+ if ($fileCounter > 10)
{
// TODO: Move excessive files to an archive directory?
break;
@@ -0,0 +1,9 @@
+DISCLAIMER
+
+This application can be used to upload photos
+to the Internet, which will make them publicly
+available.
+
+MoSync AB takes no responsibility for uploaded
+photos or any damage the use of this application
+may cause.
@@ -96,7 +96,7 @@
</style>
<!-- Import the Wormhole JavaScript Library. -->
-<script src="js/wormhole.js"></script>
+<script src="js/wormhole.js" charset="utf-8"></script>
<script>
// Global variables that hold message content.
@@ -8,20 +8,20 @@
-->
<html>
<head>
- <meta name="viewport" content="width=devicewidth; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
+ <meta name="viewport" content="width=devicewidth, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
+ <meta http-equiv="Content-type" content="text/html; charset=utf-8">
<title>Twitter Reader</title>
<link rel="stylesheet" href="jquery.mobile/jquery.mobile-1.2.0.min.css" />
<script src="jquery.mobile/jquery-1.8.2.min.js"></script>
<script src="jquery.mobile/jquery.mobile-1.2.0.min.js"></script>
- <script src="js/wormhole.js"></script>
- <script src="js/mosync.file.js"></script>
+ <script src="js/wormhole.js" charset="utf-8"></script>
+ <script src="js/mosync.file.js" charset="utf-8"></script>
- <script src="js/mosync.mock.js"></script>
- <script src="js/app.js"></script>
- <script src="js/app.ui.js"></script>
+ <script src="js/app.js" charset="utf-8"></script>
+ <script src="js/app.ui.js" charset="utf-8"></script>
<script>
/**
@@ -9,8 +9,8 @@
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
- <script src="js/wormhole.js"></script>
- <script src="main.js"></script>
+ <script src="js/wormhole.js" charset="utf-8"></script>
+ <script src="main.js" charset="utf-8"></script>
<script>
/**
* Called by the NativeUI library when the UI is ready to
@@ -540,6 +540,8 @@ namespace Notification
/**
* Set the date and time when the system should deliver the notification.
+ * The notification will be fired when the system time is equal to the
+ * given param time value.
* @param tm A date and time struct that specifies when the system
* should deliver the notification.
* @return Any of the following result codes:
@@ -491,6 +491,8 @@ namespace Notification
/**
* Set the date and time when the system should deliver the notification.
+ * The notification will be fired when the system time is equal to the
+ * given param time value.
* @param time A date and time struct that specifies when the system
* should deliver the notification.
* @return Any of the following result codes:
@@ -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);
}
/**
@@ -1689,6 +1689,12 @@ namespace Wormhole
);
}
+ // Deallocate the data object.
+ if (NULL != data)
+ {
+ maDestroyPlaceholder(data);
+ }
+
// Delete the body of the request.
delete mRequestBody;
Oops, something went wrong.

0 comments on commit f4a9b18

Please sign in to comment.