package com.stackallocated.imageupload;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.Toast;

public class UploadActivity extends Activity {
    private final static String TAG = "UploadActivity";

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        final Intent intent = getIntent();
        // We have an image to upload.
        if (Intent.ACTION_SEND.equals(intent.getAction())) {
            Log.i(TAG, "Got send action");
            Toast toast = Toast.makeText(getApplicationContext(), "Uploading image!", Toast.LENGTH_SHORT);
            toast.show();
        } else if (Intent.ACTION_SEND_MULTIPLE.equals(intent.getAction())) {
            Log.i(TAG, "Got multiple send action");
            Toast toast = Toast.makeText(getApplicationContext(), "Multiple images unsupported!", Toast.LENGTH_SHORT);
            toast.show();
        }

        // This activity never needs to show the UI.
        finish();
        return;
    }
}

@@ -34,16 +34,69 @@
 pload;%0A%0A
+import java.util.ArrayList;%0Aimport java.util.Arrays;%0A
 import a
@@ -147,16 +147,40 @@
 Intent;%0A
+import android.net.Uri;%0A
 import a
@@ -356,16 +356,166 @@
 vity%22;%0A%0A
+    void makeToast(String msg) %7B%0A        Toast toast = Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT);%0A        toast.show();%0A    %7D%0A%0A
     @Ove
@@ -622,16 +622,57 @@
 tate);%0A%0A
+        ArrayList%3CUri%3E imageUris = null;%0A
         
@@ -743,16 +743,36 @@
 o upload
+, get list of images
 .%0A      
@@ -861,32 +861,33 @@
  send action%22);%0A
+%0A
             Toas
@@ -886,128 +886,279 @@
     
-Toast toast = Toast.makeText(getApplicationContext(), %22Uploading image!%22, Toast.LENGTH_SHORT);%0A            toast.show();
+Uri imageUri = (Uri) intent.getParcelableExtra(Intent.EXTRA_STREAM);%0A            if (imageUri != null) %7B%0A                imageUris = new ArrayList%3CUri%3E(Arrays.asList(imageUri));%0A            %7D else %7B%0A                makeToast(%22No image provided to upload!%22);%0A            %7D
 %0A   
@@ -1279,24 +1279,25 @@
 d action%22);%0A
+%0A
             
@@ -1300,112 +1300,353 @@
     
-Toast toast = Toast.makeText(getApplicationContext(), %22Multiple images unsupported!%22, Toast.LENGTH_SHORT
+imageUris = intent.getParcelableArrayListExtra(Intent.EXTRA_STREAM);%0A        %7D%0A%0A        // Trigger the upload.%0A        if (imageUris != null && imageUris.size() %3E 0) %7B%0A            if (imageUris.size() %3E 1) %7B%0A                makeToast(%22Uploading %22 + imageUris.size() + %22 images!%22);%0A            %7D else%7B%0A                makeToast(%22Uploading image!%22
 );%0A 
@@ -1650,39 +1650,152 @@
 ;%0A          
+  
-  toast.show();
+%7D%0A            for (Uri imageUri : imageUris) %7B%0A                Log.i(TAG, %22Uploading image '%22 + imageUri + %22'%22);%0A            %7D
 %0A        %7D%0A%0A

Add extraction of URIs from ACTION_SEND