1 package com.joshuawise.dumload;
3 import android.app.Activity;
4 import android.content.Intent;
5 import android.content.SharedPreferences;
6 import android.net.Uri;
7 import android.os.Bundle;
8 import android.preference.PreferenceManager;
9 import android.util.Log;
10 import android.view.View;
11 import android.widget.Button;
12 import android.widget.TextView;
13 import android.widget.Toast;
15 public class Dumload extends Activity {
17 private SharedPreferences prefs;
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 prefs = PreferenceManager.getDefaultSharedPreferences(this);
38 Intent i = getIntent(); /* i *am* not an intent! */
40 if (!i.getAction().equals(Intent.ACTION_SEND))
42 // say("Unknown intent for dumload");
44 Intent pi = new Intent(this, Preferences.class);
49 Bundle extras = i.getExtras();
50 final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
52 Log.e("Dumload", "Got a send -- starting service.");
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)
62 .putExtra("com.joshuawise.dumload.dest", s));
64 say("Failed to start uploader.");
66 Log.e("Dumload", "Started service " + cn.toString() + ".");
71 String uribase = uri.toString();
74 ((TextView) findViewById(R.id.suckit)).setText("Where to?");
75 ((TextView) findViewById(R.id.entry)).setText(prefs.getString("defaultUploadPath", "/var/www/") + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");