]> Joshua Wise's Git repositories - dumload.git/blame - src/com/joshuawise/dumload/Dumload.java
Add location prompt and pubkey support
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
CommitLineData
0763e16d
JW
1package com.joshuawise.dumload;
2
3import java.io.InputStream;
4
5import android.app.Activity;
6import android.app.Service;
7import android.content.Intent;
8import android.net.Uri;
9import android.os.Bundle;
10import android.os.IBinder;
11import android.widget.TextView;
12import android.widget.Toast;
bb6544e9
JW
13import android.widget.TextView;
14import android.widget.Button;
15import android.view.View;
0763e16d
JW
16import android.util.Log;
17
18public 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();
bb6544e9 34 final Dumload thisact = this;
0763e16d
JW
35
36 Intent i = getIntent(); /* i *am* not an intent! */
bb6544e9
JW
37
38 if (!i.getAction().equals(Intent.ACTION_SEND))
0763e16d 39 {
bb6544e9
JW
40 say("Unknown intent for dumload");
41 this.finish();
42 return;
0763e16d 43 }
bb6544e9
JW
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
0763e16d
JW
73 }
74}
This page took 0.030112 seconds and 4 git commands to generate.