f0919b78d4ec22fdc467b18e5e1c3f5dafd37758
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
1 package com.joshuawise.dumload;
2
3 import java.io.InputStream;
4
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;
17
18 public class Dumload extends Activity {
19         /** Called when the activity is first created. */
20         @Override
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.");
26         }
27         
28         private void say(String s) {
29                 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
30         }
31         
32         public void onStart() {
33                 super.onStart();
34                 final Dumload thisact = this;
35                 
36                 Intent i = getIntent(); /* i *am* not an intent! */
37                 
38                 if (!i.getAction().equals(Intent.ACTION_SEND))
39                 {
40                         say("Unknown intent for dumload");
41                         this.finish();
42                         return;
43                 }
44                 
45                 Bundle extras = i.getExtras();
46                 final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
47                 
48                 Log.e("Dumload", "Got a send -- starting service.");
49                 
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)
57                                                                                      .setData(uri)
58                                                                                      .putExtra("com.joshuawise.dumload.dest", s));
59                                 if (cn == null)
60                                         say("Failed to start uploader.");
61                                 else
62                                         Log.e("Dumload", "Started service " + cn.toString() + ".");
63                                 finish();
64                         }
65                 });
66                 
67                 String uribase = uri.toString();
68                 
69                 
70                 ((TextView) findViewById(R.id.suckit)).setText("Where to?");
71                 ((TextView) findViewById(R.id.entry)).setText("/var/www/" + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");
72                 
73         }
74 }
This page took 0.01478 seconds and 2 git commands to generate.