1 package com.joshuawise.dumload;
3 import java.io.InputStream;
5 import android.app.Activity;
6 import android.app.Service;
7 import android.content.Intent;
8 import android.net.Uri;
9 import android.os.Bundle;
10 import android.os.IBinder;
11 import android.widget.TextView;
12 import android.widget.Toast;
13 import android.widget.TextView;
14 import android.widget.Button;
15 import android.view.View;
16 import android.util.Log;
18 public class Dumload extends Activity {
19 /** Called when the activity is first created. */
21 public void onCreate(Bundle savedInstanceState) {
22 super.onCreate(savedInstanceState);
23 setContentView(R.layout.main);
24 TextView tv = (TextView)findViewById(R.id.suckit);
25 tv.setText("Suck it.");
28 private void say(String s) {
29 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
32 public void onStart() {
34 final Dumload thisact = this;
36 Intent i = getIntent(); /* i *am* not an intent! */
38 if (!i.getAction().equals(Intent.ACTION_SEND))
40 say("Unknown intent for dumload");
45 Bundle extras = i.getExtras();
46 final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
48 Log.e("Dumload", "Got a send -- starting service.");
50 Button go = (Button)findViewById(R.id.go);
51 go.setOnClickListener(new View.OnClickListener() {
52 public void onClick(View v) {
53 String s = ((TextView) findViewById(R.id.entry)).getText().toString();
54 android.content.ComponentName cn = getApplicationContext()
55 .startService(new Intent()
56 .setClass(getApplicationContext(), Uploader.class)
58 .putExtra("com.joshuawise.dumload.dest", s));
60 say("Failed to start uploader.");
62 Log.e("Dumload", "Started service " + cn.toString() + ".");
67 String uribase = uri.toString();
70 ((TextView) findViewById(R.id.suckit)).setText("Where to?");
71 ((TextView) findViewById(R.id.entry)).setText("/var/www/" + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");