]> Joshua Wise's Git repositories - dumload.git/blame_incremental - src/com/joshuawise/dumload/Dumload.java
Revert "Remove generated/IDE files"
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
... / ...
CommitLineData
1package com.joshuawise.dumload;
2
3import android.app.Activity;
4import android.content.Intent;
5import android.content.SharedPreferences;
6import android.net.Uri;
7import android.os.Bundle;
8import android.preference.PreferenceManager;
9import android.util.Log;
10import android.view.View;
11import android.widget.Button;
12import android.widget.TextView;
13import android.widget.Toast;
14
15public class Dumload extends Activity {
16
17 private SharedPreferences prefs;
18
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 prefs = PreferenceManager.getDefaultSharedPreferences(this);
37
38 Intent i = getIntent(); /* i *am* not an intent! */
39
40 if (!i.getAction().equals(Intent.ACTION_SEND))
41 {
42// say("Unknown intent for dumload");
43// this.finish();
44 Intent pi = new Intent(this, Preferences.class);
45 startActivity(pi);
46 return;
47 }
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?");
75 ((TextView) findViewById(R.id.entry)).setText(prefs.getString("defaultUploadPath", "/var/www/") + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");
76
77 }
78}
This page took 0.02773 seconds and 4 git commands to generate.