]> Joshua Wise's Git repositories - dumload.git/blame - src/com/joshuawise/dumload/Dumload.java
Fix port usage and always try to add the generated key
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
CommitLineData
0763e16d
JW
1package com.joshuawise.dumload;
2
0763e16d 3import android.app.Activity;
0763e16d 4import android.content.Intent;
42aa7dfd 5import android.content.SharedPreferences;
0763e16d
JW
6import android.net.Uri;
7import android.os.Bundle;
42aa7dfd 8import android.preference.PreferenceManager;
9import android.util.Log;
10import android.view.View;
11import android.widget.Button;
0763e16d
JW
12import android.widget.TextView;
13import android.widget.Toast;
0763e16d
JW
14
15public class Dumload extends Activity {
42aa7dfd 16
17 private SharedPreferences prefs;
18
0763e16d
JW
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 35
42aa7dfd 36 prefs = PreferenceManager.getDefaultSharedPreferences(this);
37
0763e16d 38 Intent i = getIntent(); /* i *am* not an intent! */
bb6544e9
JW
39
40 if (!i.getAction().equals(Intent.ACTION_SEND))
0763e16d 41 {
42aa7dfd 42// say("Unknown intent for dumload");
43// this.finish();
44 Intent pi = new Intent(this, Preferences.class);
45 startActivity(pi);
bb6544e9 46 return;
0763e16d 47 }
bb6544e9
JW
48
49 Bundle extras = i.getExtras();
50 final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
51
52 Log.e("Dumload", "Got a send -- starting service.");
53
54 Button go = (Button)findViewById(R.id.go);
55 go.setOnClickListener(new View.OnClickListener() {
56 public void onClick(View v) {
57 String s = ((TextView) findViewById(R.id.entry)).getText().toString();
58 android.content.ComponentName cn = getApplicationContext()
59 .startService(new Intent()
60 .setClass(getApplicationContext(), Uploader.class)
61 .setData(uri)
62 .putExtra("com.joshuawise.dumload.dest", s));
63 if (cn == null)
64 say("Failed to start uploader.");
65 else
66 Log.e("Dumload", "Started service " + cn.toString() + ".");
67 finish();
68 }
69 });
70
71 String uribase = uri.toString();
72
73
74 ((TextView) findViewById(R.id.suckit)).setText("Where to?");
42aa7dfd 75 ((TextView) findViewById(R.id.entry)).setText(prefs.getString("defaultUploadPath", "/var/www/") + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");
bb6544e9 76
0763e16d
JW
77 }
78}
This page took 0.027062 seconds and 4 git commands to generate.