Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

correct utf8 handling in http post

  • Loading branch information...
commit 329f06fbe01bfb506c1db9cdbbafa02e0502f42c 1 parent 76ad2f2
@else else authored
View
25 src/org/raumzeitlabor/cashpoint/activities/CreateProductActivity.java
@@ -14,6 +14,7 @@
import com.google.zxing.integration.android.IntentResult;
import android.app.Activity;
+import android.app.Dialog;
import android.app.ProgressDialog;
import android.content.Intent;
import android.os.Bundle;
@@ -30,7 +31,8 @@
import android.widget.Toast;
public class CreateProductActivity extends Activity {
-
+ private final int DIALOG_PRODUCT_LOOKUP_WAIT = 0;
+
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
@@ -127,7 +129,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@Override
public <Product> void onTaskComplete(Product product) {
- dialog.dismiss();
+ CreateProductActivity.this.removeDialog(DIALOG_PRODUCT_LOOKUP_WAIT);
if (product != null) {
Toast.makeText(CreateProductActivity.this, "product found", Toast.LENGTH_LONG).show();
@@ -140,7 +142,7 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
@Override
public void onTaskError(Exception error) {
- dialog.dismiss();
+ CreateProductActivity.this.removeDialog(DIALOG_PRODUCT_LOOKUP_WAIT);
String msg = error.getLocalizedMessage();
if (error instanceof HttpStatusException) {
@@ -160,8 +162,7 @@ public void onTaskError(Exception error) {
@Override
public void onTaskStart() {
- dialog = ProgressDialog.show(CreateProductActivity.this, "",
- CreateProductActivity.this.getString(R.string.product_lookup_wait), true);
+ CreateProductActivity.this.showDialog(DIALOG_PRODUCT_LOOKUP_WAIT);
}
});
@@ -170,4 +171,18 @@ public void onTaskStart() {
Toast.makeText(this, getString(R.string.scan_canceled), Toast.LENGTH_SHORT).show();
}
}
+
+ @Override
+ protected Dialog onCreateDialog(int id) {
+ Dialog dialog = null;
+
+ switch(id) {
+ case DIALOG_PRODUCT_LOOKUP_WAIT:
+ dialog = ProgressDialog.show(CreateProductActivity.this, "",
+ CreateProductActivity.this.getString(R.string.product_lookup_wait), true);
+ break;
+ }
+
+ return dialog;
+ }
}
View
8 src/org/raumzeitlabor/cashpoint/activities/GroupActivity.java
@@ -85,10 +85,10 @@ public void onClick(DialogInterface dialog, int whichButton) {
}
});
- alert.setNegativeButton(getString(R.string.group_add_btn_cancel),
- new DialogInterface.OnClickListener() {
- public void onClick(DialogInterface dialog, int whichButton) {}
- });
+// alert.setNegativeButton(getString(R.string.group_add_btn_cancel),
+// new DialogInterface.OnClickListener() {
+// public void onClick(DialogInterface dialog, int whichButton) {}
+// });
alert.create().show();
}
View
13 src/org/raumzeitlabor/cashpoint/client/tasks/CreateGroupTask.java
@@ -1,22 +1,13 @@
package org.raumzeitlabor.cashpoint.client.tasks;
import java.io.IOException;
-import java.util.ArrayList;
import java.util.Comparator;
import org.apache.http.HttpResponse;
-import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.BasicHttpEntity;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
-import org.json.JSONArray;
+import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;
-import org.json.JSONTokener;
import org.raumzeitlabor.cashpoint.R;
import org.raumzeitlabor.cashpoint.activities.LoginActivity;
import org.raumzeitlabor.cashpoint.client.Cashpoint;
@@ -98,7 +89,7 @@ protected Group doInBackground(String... params) {
try {
JSONObject json = new JSONObject();
json.put("name", params[0]);
- request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
+ request.setEntity(new StringEntity(json.toString(), "UTF-8"));
HttpResponse response = Cashpoint.getHttpClient().execute(request);
int statusCode = response.getStatusLine().getStatusCode();
View
8 src/org/raumzeitlabor/cashpoint/client/tasks/CreateProductTask.java
@@ -4,11 +4,7 @@
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
-import org.apache.http.entity.ByteArrayEntity;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpConnectionParams;
-import org.apache.http.params.HttpParams;
+import org.apache.http.entity.StringEntity;
import org.json.JSONException;
import org.json.JSONObject;
import org.raumzeitlabor.cashpoint.R;
@@ -81,7 +77,7 @@ protected Boolean doInBackground(String... params) {
json.put("name", params[1]);
json.put("threshold", params[2]);
- request.setEntity(new ByteArrayEntity(json.toString().getBytes("UTF8")));
+ request.setEntity(new StringEntity(json.toString(), "UTF-8"));
HttpResponse response = Cashpoint.getHttpClient().execute(request);
int statusCode = response.getStatusLine().getStatusCode();
Please sign in to comment.
Something went wrong with that request. Please try again.