]> Joshua Wise's Git repositories - dumload.git/blob - 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
1 package com.joshuawise.dumload;
2
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;
14
15 public 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.027955 seconds and 4 git commands to generate.