Commit b8cd936c authored by Alan McNatty's avatar Alan McNatty
Browse files

Bug fix: try/ catch added to RestClient for issue 15

Upgrades:
1) Added string for file upload only supported (shouldn't be seen but a boundary case - better to see something if this occurs).
Adjusted the send/receiver accordingly
2) Added Catalan strings.xml

Updated version details in the Manifest to match
parent a66bc0df
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="nz.net.catalyst.MaharaDroid"
android:versionCode="5"
android:versionName="1.6">
android:versionCode="6"
android:versionName="1.7">
<application android:icon="@drawable/icon" android:label="@string/app_name" android:debuggable="false">
<activity android:name=".MaharaDroid"
......@@ -47,29 +47,14 @@
<action android:name="android.intent.action.SEND" />
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
<data android:mimeType="video/*" />
<data android:mimeType="audio/*" />
<data android:mimeType="application/pdf" />
<data android:mimeType="application/postscript" />
<data android:mimeType="application/zip" />
<data android:mimeType="application/x-tar" />
<data android:mimeType="application/msword" />
<data android:mimeType="application/vnd.ms-excel" />
<data android:mimeType="application/vnd.ms-powerpoint" />
<data android:mimeType="application/vnd.oasis.opendocument.text" />
<data android:mimeType="application/vnd.oasis.opendocument.presentation" />
<data android:mimeType="application/vnd.oasis.opendocument.graphics" />
<data android:mimeType="application/vnd.oasis.opendocument.image" />
<data android:mimeType="application/vnd.oasis.opendocument.spreadsheet" />
<data android:mimeType="application/vnd.openxmlformats-officedocument.wordprocessingml.document" />
<data android:mimeType="application/vnd.visio" />
<data android:mimeType="application/x-debian-package" />
<data android:mimeType="application/vnd.android.package-archive" />
<data android:mimeType="application/*" />
<data android:mimeType="text/csv" />
<data android:mimeType="text/plain" />
<data android:mimeType="text/rtf" />
</intent-filter>
<data android:mimeType="text/html" />
<data android:mimeType="text/xml" />
</intent-filter>
</activity>
<activity android:name=".EditPreferences"
android:label="@string/prefs_app_name" />
......
......@@ -49,6 +49,7 @@
<string name="uploadstarting">Your Upload is Starting</string>
<string name="uploadfinished">Your Upload is Finished</string>
<string name="uploadfailed">Upload failed</string>
<string name="uploadnotavailable">Sorry you can only uploaded files as artefacts.</string>
<string name="uploadingartifact">Uploading Artefact</string>
<string name="uploading">Uploading</string>
<string name="filetransfers">File Transfers</string>
......
......@@ -27,6 +27,8 @@ import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.widget.Toast;
/*
* The ArtifactSendReceiver class is taken from the PictureSendReceiver class
......@@ -49,25 +51,35 @@ public class ArtifactSendReceiver extends Activity {
super.onCreate(savedInstanceState);
Intent intent = getIntent();
String [] uris = new String[]{};
Bundle extras = intent.getExtras();
String [] uris = null;
if ( DEBUG )
Log.d(TAG, "Type: " + intent.getType() +
", Stream: " + intent.hasExtra("android.intent.extra.STREAM") +
", Data: " + intent.getDataString() +
", Flag(s): " + intent.getFlags());
if (intent.getAction().equals(Intent.ACTION_SEND)) {
Bundle extras = intent.getExtras();
if (extras.containsKey("android.intent.extra.STREAM")) {
Uri uri = (Uri)extras.get("android.intent.extra.STREAM");
Intent i = new Intent(this, ArtifactSettings.class);
Uri uri = (Uri) extras.get("android.intent.extra.STREAM");
uris = new String[] { uri.toString() };
i.putExtra("uri", uris);
startActivity(i);
}
} else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
ArrayList<Parcelable> list = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);
int c = 0;
uris = new String[list.size()];
for (Parcelable p : list) {
Uri uri = (Uri) p;
uris[c++] = uri.toString();
} else if (intent.getAction().equals(Intent.ACTION_SEND_MULTIPLE)) {
if (extras.containsKey("android.intent.extra.STREAM")) {
ArrayList<Parcelable> list = extras.getParcelableArrayList(Intent.EXTRA_STREAM);
int c = 0;
uris = new String[list.size()];
for (Parcelable p : list) {
Uri uri = (Uri) p;
uris[c++] = uri.toString();
}
}
}
if ( uris == null ) {
Toast.makeText(getApplicationContext(), R.string.uploadnotavailable, Toast.LENGTH_SHORT).show();
} else {
Intent i = new Intent(this, ArtifactSettings.class);
i.putExtra("uri", uris);
startActivity(i);
......
......@@ -215,7 +215,7 @@ public class RestClient {
}
httppost.setEntity(mp_entity);
response = httpclient.execute(httppost);
response = httpclient.execute(httppost);
HttpEntity resEntity = response.getEntity();
if (resEntity != null) {
......@@ -245,6 +245,11 @@ public class RestClient {
json.put("fail", e.getMessage());
} catch (JSONException e1) { }
e.printStackTrace();
} catch (IllegalArgumentException e) {
try {
json.put("fail", e.getMessage());
} catch (JSONException e1) { }
e.printStackTrace();
} catch (JSONException e) { }
httpclient.getConnectionManager().shutdown();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment