From bf14f23fe5f8c11093983f789e542660cc353164 Mon Sep 17 00:00:00 2001 From: Jesse Young Date: Tue, 27 Sep 2011 11:20:10 -0700 Subject: [PATCH] fix encoding problem for post requests, make test a separate action --- AndroidManifest.xml | 4 ++-- src/org/envaya/sms/App.java | 1 + src/org/envaya/sms/IncomingSms.java | 1 + src/org/envaya/sms/OutgoingMessage.java | 6 ++++++ src/org/envaya/sms/task/HttpTask.java | 2 +- src/org/envaya/sms/ui/Main.java | 2 +- 6 files changed, 12 insertions(+), 4 deletions(-) diff --git a/AndroidManifest.xml b/AndroidManifest.xml index e047faa..e4bb042 100755 --- a/AndroidManifest.xml +++ b/AndroidManifest.xml @@ -1,8 +1,8 @@ + android:versionCode="9" + android:versionName="2.0-beta7"> diff --git a/src/org/envaya/sms/App.java b/src/org/envaya/sms/App.java index 15bcfc6..e9aa26a 100755 --- a/src/org/envaya/sms/App.java +++ b/src/org/envaya/sms/App.java @@ -47,6 +47,7 @@ public final class App extends Application { public static final String ACTION_OUTGOING = "outgoing"; public static final String ACTION_INCOMING = "incoming"; public static final String ACTION_SEND_STATUS = "send_status"; + public static final String ACTION_TEST = "test"; public static final String STATUS_QUEUED = "queued"; public static final String STATUS_FAILED = "failed"; diff --git a/src/org/envaya/sms/IncomingSms.java b/src/org/envaya/sms/IncomingSms.java index bcf9e17..7eb26f1 100755 --- a/src/org/envaya/sms/IncomingSms.java +++ b/src/org/envaya/sms/IncomingSms.java @@ -65,6 +65,7 @@ public class IncomingSms extends IncomingMessage { } public void tryForwardToServer() { + new ForwarderTask(this, new BasicNameValuePair("from", getFrom()), new BasicNameValuePair("message_type", App.MESSAGE_TYPE_SMS), diff --git a/src/org/envaya/sms/OutgoingMessage.java b/src/org/envaya/sms/OutgoingMessage.java index adf2e88..5ad7468 100755 --- a/src/org/envaya/sms/OutgoingMessage.java +++ b/src/org/envaya/sms/OutgoingMessage.java @@ -90,6 +90,12 @@ public class OutgoingMessage extends QueuedMessage { SmsManager smgr = SmsManager.getDefault(); ArrayList bodyParts = smgr.divideMessage(getMessageBody()); + int numParts = bodyParts.size(); + if (numParts > 1) + { + app.log("(Multipart message with "+numParts+" parts)"); + } + String packageName = app.chooseOutgoingSmsPackage(bodyParts.size()); if (packageName == null) diff --git a/src/org/envaya/sms/task/HttpTask.java b/src/org/envaya/sms/task/HttpTask.java index 32681d6..e1f6527 100755 --- a/src/org/envaya/sms/task/HttpTask.java +++ b/src/org/envaya/sms/task/HttpTask.java @@ -125,7 +125,7 @@ public class HttpTask extends AsyncTask { } else { - post.setEntity(new UrlEncodedFormEntity(params)); + post.setEntity(new UrlEncodedFormEntity(params, "UTF-8")); } HttpClient client = app.getHttpClient(); diff --git a/src/org/envaya/sms/ui/Main.java b/src/org/envaya/sms/ui/Main.java index b245d06..39b0c35 100755 --- a/src/org/envaya/sms/ui/Main.java +++ b/src/org/envaya/sms/ui/Main.java @@ -37,7 +37,7 @@ public class Main extends Activity { private class TestTask extends HttpTask { public TestTask() { - super(Main.this.app, new BasicNameValuePair("action", App.ACTION_OUTGOING)); + super(Main.this.app, new BasicNameValuePair("action", App.ACTION_TEST)); } @Override