diff --git a/.classpath b/.classpath index 489cae3..8e23cd2 100644 --- a/.classpath +++ b/.classpath @@ -1,10 +1,16 @@ - - + + - - - + + + + + + + + + diff --git a/.project b/.project index 1d6079a..ef1db04 100644 --- a/.project +++ b/.project @@ -10,8 +10,20 @@ + + com.appcelerator.titanium.core.builder + + + + + com.aptana.ide.core.unifiedBuilder + + + org.eclipse.jdt.core.javanature + com.appcelerator.titanium.mobile.module.nature + com.aptana.projects.webnature diff --git a/README.md b/README.md index 77365b0..ef2ceeb 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,8 @@ In order to access the module from JavaScript, you should do the following: alert('Message sending result: ' + result); } ); +In version 1.0.1 a message can fire more than one "complete" event. If you rely on the this event in your code, please note this change. More information in the Change Log below. + ### Sending a message Sending a message is as simple as: @@ -80,6 +82,13 @@ Sending a message is as simple as: The result of the operation can be tracked through the `complete` event previously registered. +### Change Log +1.0.1 Added support for messages with over 140 characters, in which case the message will be sent using multiple SMSs, depending on the length of the message. Those messages will appear as one SMS on modern phones (all smart phones) regardless. +This applies also to some message of 140 characters and less which include characters in non-Latin script (e.g. Russian, Hebrew, Arabic), which, due to character encoding may actually contain more than 140 characters in the SMS itself. +For example, a message using Latin script which consists of 150 characters will be sent using two SMSs. A message which consists of 140 characters, but which has one or more characters in non-Latin script will also be sent using two SMSs. + +Due to this change, a message sent using this version will fire the complete event once for every SMS sent. Please take that into consideration if your application relies on this event to run a function, since this code may now run more than once. + ## License Copyright (c) 2011 Olivier Morandi diff --git a/LICENSE b/android/LICENSE similarity index 100% rename from LICENSE rename to android/LICENSE diff --git a/assets/README b/android/assets/README similarity index 100% rename from assets/README rename to android/assets/README diff --git a/android/build.properties b/android/build.properties new file mode 100644 index 0000000..dd24c96 --- /dev/null +++ b/android/build.properties @@ -0,0 +1,4 @@ +titanium.platform=/Users/InGrowth/Library/Application Support/Titanium/mobilesdk/osx/6.0.0.GA/android +android.platform=/Users/InGrowth/Library/android-sdk-macosx/platforms/android-23 +google.apis=/Users/InGrowth/Library/android-sdk-macosx/add-ons/addon-google_apis-google-23 +android.ndk=/Users/InGrowth/Library/android-sdk-macosx/ndk-bundle \ No newline at end of file diff --git a/android/build.xml b/android/build.xml new file mode 100644 index 0000000..e0ada70 --- /dev/null +++ b/android/build.xml @@ -0,0 +1,28 @@ + + + Ant build script for Titanium Android module sms + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/android/dist/sms.jar b/android/dist/sms.jar new file mode 100644 index 0000000..754e2d7 Binary files /dev/null and b/android/dist/sms.jar differ diff --git a/documentation/index.md b/android/documentation/index.md similarity index 100% rename from documentation/index.md rename to android/documentation/index.md diff --git a/example/app.js b/android/example/app.js similarity index 100% rename from example/app.js rename to android/example/app.js diff --git a/android/java-sources.txt b/android/java-sources.txt new file mode 100644 index 0000000..0c0f18a --- /dev/null +++ b/android/java-sources.txt @@ -0,0 +1,2 @@ +"/Users/InGrowth/Documents/Projects/Ti-Android-SMS/android/build/generated/java/ti/android/sms/SmsBootstrap.java" +"/Users/InGrowth/Documents/Projects/Ti-Android-SMS/android/src/ti/android/sms/SmsModule.java" \ No newline at end of file diff --git a/lib/README b/android/lib/README similarity index 100% rename from lib/README rename to android/lib/README diff --git a/manifest b/android/manifest similarity index 82% rename from manifest rename to android/manifest index a79dbd6..d3b0651 100644 --- a/manifest +++ b/android/manifest @@ -2,8 +2,9 @@ # this is your module manifest and used by Titanium # during compilation, packaging, distribution, etc. # -version: 1.0.0 -apiversion: 2 +version: 1.1.2 +apiversion: 3 +architectures: armeabi-v7a x86 description: Sms module for Titanium Android author: Olivier Morandi license: MIT @@ -15,4 +16,4 @@ name: sms moduleid: ti.android.sms guid: d86a1f51-1abf-4392-b453-a99a20392890 platform: android -minsdk: 3.0.0.GA +minsdk: 6.0.0.GA diff --git a/platform/README b/android/platform/README similarity index 100% rename from platform/README rename to android/platform/README diff --git a/src/ti/android/sms/SmsModule.java b/android/src/ti/android/sms/SmsModule.java similarity index 90% rename from src/ti/android/sms/SmsModule.java rename to android/src/ti/android/sms/SmsModule.java index 72adb65..4192771 100644 --- a/src/ti/android/sms/SmsModule.java +++ b/android/src/ti/android/sms/SmsModule.java @@ -16,7 +16,6 @@ import org.appcelerator.kroll.common.Log; import org.appcelerator.kroll.common.TiConfig; - import android.app.Activity; import android.app.PendingIntent; import android.content.BroadcastReceiver; @@ -25,6 +24,8 @@ import android.content.IntentFilter; import android.telephony.SmsManager; +import java.util.ArrayList; + @Kroll.module(name="Sms", id="ti.android.sms") public class SmsModule extends KrollModule { @@ -133,7 +134,6 @@ public KrollDict createEventObject (boolean success, int result, String resultMe @Kroll.method public void sendSMS(String recipient, String messageBody) { - Activity currentActivity = this.getActivity(); Intent sentIntent = new Intent(MESSAGE_SENT); @@ -145,10 +145,21 @@ public void sendSMS(String recipient, String messageBody) PendingIntent deliveredPI = PendingIntent.getBroadcast(currentActivity, 0, deliveredIntent, 0); + ArrayList sentIntents = new ArrayList(); + + ArrayList deliveryIntents = new ArrayList(); + SmsManager sms = SmsManager.getDefault(); - sms.sendTextMessage(recipient, null, messageBody, sentPI, deliveredPI); + ArrayList parts = sms.divideMessage(messageBody); + + for (int i = 0; i < parts.size(); i++) { + sentIntents.add(i, sentPI); + deliveryIntents.add(i, deliveredPI); + } + + sms.sendMultipartTextMessage(recipient, null, parts, sentIntents, deliveryIntents); } diff --git a/timodule.xml b/android/timodule.xml similarity index 100% rename from timodule.xml rename to android/timodule.xml diff --git a/build.properties b/build.properties deleted file mode 100644 index 1ec830b..0000000 --- a/build.properties +++ /dev/null @@ -1,3 +0,0 @@ -titanium.platform=/Users/olivier/Library/Application Support/Titanium/mobilesdk/osx/3.0.0.GA/android -android.platform=/Users/olivier/android-sdk-macosx/platforms/android-8 -google.apis=/Users/olivier/android-sdk-macosx/add-ons/addon-google_apis-google-8 \ No newline at end of file diff --git a/build.xml b/build.xml deleted file mode 100644 index ee8fec8..0000000 --- a/build.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - Ant build script for Titanium Android module sms - - - - - - - \ No newline at end of file diff --git a/dist/sms.jar b/dist/sms.jar deleted file mode 100644 index 0a444a6..0000000 Binary files a/dist/sms.jar and /dev/null differ diff --git a/dist/ti.android.sms-android-1.0.0.zip b/dist/ti.android.sms-android-1.0.0.zip deleted file mode 100644 index 658ad05..0000000 Binary files a/dist/ti.android.sms-android-1.0.0.zip and /dev/null differ diff --git a/dist/ti.android.sms-android-1.0.2.zip b/dist/ti.android.sms-android-1.0.2.zip new file mode 100644 index 0000000..3ea44d4 Binary files /dev/null and b/dist/ti.android.sms-android-1.0.2.zip differ diff --git a/dist/ti.android.sms-android-1.1.2.zip b/dist/ti.android.sms-android-1.1.2.zip new file mode 100644 index 0000000..2e29b06 Binary files /dev/null and b/dist/ti.android.sms-android-1.1.2.zip differ