diff --git a/.classpath b/.classpath
new file mode 100644
index 0000000..6efcbb7
--- /dev/null
+++ b/.classpath
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/.project b/.project
new file mode 100644
index 0000000..d9516df
--- /dev/null
+++ b/.project
@@ -0,0 +1,33 @@
+
+
+ Send2URL
+
+
+
+
+
+ com.android.ide.eclipse.adt.ResourceManagerBuilder
+
+
+
+
+ com.android.ide.eclipse.adt.PreCompilerBuilder
+
+
+
+
+ org.eclipse.jdt.core.javabuilder
+
+
+
+
+ com.android.ide.eclipse.adt.ApkBuilder
+
+
+
+
+
+ com.android.ide.eclipse.adt.AndroidNature
+ org.eclipse.jdt.core.javanature
+
+
diff --git a/AndroidManifest.xml b/AndroidManifest.xml
new file mode 100644
index 0000000..e4e6a9d
--- /dev/null
+++ b/AndroidManifest.xml
@@ -0,0 +1,21 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/README.md b/README.md
index 46a1c1b..14a8657 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,6 @@
-# Send2URL
-This app adds an entry to the android share menu. When you share any content (e.g. a picture from the gallery) with "Send2URL" it will be uploaded to the configured server URL using a HTTP POST request.
+Send2URL
+========
+
+This app adds an entry to the android share menu.
+When you share any content (e.g. a picture from the gallery) with "Send2URL"
+it will be uploaded to the configured server URL using a HTTP POST request.
diff --git a/build.xml b/build.xml
new file mode 100644
index 0000000..195bf8b
--- /dev/null
+++ b/build.xml
@@ -0,0 +1,84 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/default.properties b/default.properties
new file mode 100644
index 0000000..0b9250e
--- /dev/null
+++ b/default.properties
@@ -0,0 +1,11 @@
+# This file is automatically generated by Android Tools.
+# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
+#
+# This file must be checked in Version Control Systems.
+#
+# To customize properties used by the Ant build system use,
+# "build.properties", and override values to adapt the script to your
+# project structure.
+
+# Project target.
+target=android-8
diff --git a/icon.xcf b/icon.xcf
new file mode 100644
index 0000000..f55b6ef
Binary files /dev/null and b/icon.xcf differ
diff --git a/res/drawable-mdpi/icon.png b/res/drawable-mdpi/icon.png
new file mode 100644
index 0000000..30b10cb
Binary files /dev/null and b/res/drawable-mdpi/icon.png differ
diff --git a/res/layout/prefs.xml b/res/layout/prefs.xml
new file mode 100644
index 0000000..d7032a0
--- /dev/null
+++ b/res/layout/prefs.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
diff --git a/res/values/strings.xml b/res/values/strings.xml
new file mode 100644
index 0000000..6aaae06
--- /dev/null
+++ b/res/values/strings.xml
@@ -0,0 +1,16 @@
+
+
+ Send2URL
+ Send2URL Settings
+ Sending to URL...
+ Enter the server URL
+ Set server URL
+ https://user:pass@server.example.com:1234/path/
+ Successfully sent to URL
+ Error sending to URL
+ About
+
+ This app adds an entry to the android share menu.
+ When you share any content (e.g. a picture from the gallery) with "Send2URL" it will be uploaded to the configured server URL using a HTTP POST request.
+
+
diff --git a/src/com/github/matgoebl/send2url/PrefsActivity.java b/src/com/github/matgoebl/send2url/PrefsActivity.java
new file mode 100644
index 0000000..53eca18
--- /dev/null
+++ b/src/com/github/matgoebl/send2url/PrefsActivity.java
@@ -0,0 +1,15 @@
+package com.github.matgoebl.send2url;
+
+import com.github.matgoebl.send2url.R;
+import android.os.Bundle;
+import android.preference.PreferenceActivity;
+
+public class PrefsActivity extends PreferenceActivity
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState)
+ {
+ super.onCreate(savedInstanceState);
+ addPreferencesFromResource(R.layout.prefs);
+ }
+}
diff --git a/src/com/github/matgoebl/send2url/SendActivity.java b/src/com/github/matgoebl/send2url/SendActivity.java
new file mode 100644
index 0000000..118b541
--- /dev/null
+++ b/src/com/github/matgoebl/send2url/SendActivity.java
@@ -0,0 +1,79 @@
+package com.github.matgoebl.send2url;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+
+import org.apache.http.HttpResponse;
+import org.apache.http.client.ClientProtocolException;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.InputStreamEntity;
+import org.apache.http.impl.client.DefaultHttpClient;
+
+import android.app.Activity;
+import android.content.ContentResolver;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.net.Uri;
+import android.os.Bundle;
+import android.preference.PreferenceManager;
+import android.util.Base64;
+import android.widget.Toast;
+
+public class SendActivity extends Activity
+{
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
+ String serverUrl = prefs.getString("serverurl", "");
+
+ Intent intent = getIntent();
+ if (intent != null && intent.getAction().equals(Intent.ACTION_SEND)) {
+ Bundle extras = intent.getExtras();
+ if(extras != null && extras.containsKey(Intent.EXTRA_STREAM)) {
+ Uri uri = (Uri) extras.getParcelable(Intent.EXTRA_STREAM);
+ ContentResolver contentResolver = getContentResolver();
+ try {
+ InputStream stream = contentResolver.openInputStream(uri);
+ httpPost( serverUrl,stream);
+ Toast.makeText(getBaseContext(), getString(R.string.SendSuccess),
+ Toast.LENGTH_LONG).show();
+ setResult(Activity.RESULT_OK);
+ } catch (Exception e) {
+ Toast.makeText(getBaseContext(), getString(R.string.SendFailed) + ":\n" + e.toString(),
+ Toast.LENGTH_LONG).show();
+ setResult(Activity.RESULT_CANCELED);
+ }
+ }
+ }
+ finish();
+ }
+
+ public static void httpPost(String serverUrl, InputStream dataStream) throws ClientProtocolException, IOException, Exception {
+ DefaultHttpClient httpclient = new DefaultHttpClient();
+ HttpPost httppost = new HttpPost(serverUrl);
+
+ URL url = new URL(serverUrl);
+ String userInfo = url.getUserInfo();
+ if( userInfo != null ) {
+ httppost.addHeader("Authorization", "Basic " + Base64.encodeToString(userInfo.getBytes(), Base64.NO_WRAP));
+ }
+
+ InputStreamEntity requestEntity = new InputStreamEntity(dataStream,-1);
+ requestEntity.setContentType("binary/octet-stream");
+ requestEntity.setChunked(true);
+ httppost.setEntity(requestEntity);
+
+ HttpResponse response = httpclient.execute(httppost);
+ response.getEntity().getContent().close();
+ httpclient.getConnectionManager().shutdown();
+
+ int status = response.getStatusLine().getStatusCode();
+ if ( status < 200 || status > 299 ) {
+ throw new Exception(response.getStatusLine().toString());
+ }
+ }
+}
+