]> Joshua Wise's Git repositories - dumload.git/blame - src/com/joshuawise/dumload/Dumload.java
GPLv3
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
CommitLineData
184c5221
JW
1/* Dumload.java
2 * Main front-end glue for Dumload.
3 *
4 * This program is free software: you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License, version 3, as
6 * published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16
0763e16d
JW
17package com.joshuawise.dumload;
18
19import java.io.InputStream;
20
21import android.app.Activity;
22import android.app.Service;
23import android.content.Intent;
24import android.net.Uri;
25import android.os.Bundle;
26import android.os.IBinder;
27import android.widget.TextView;
28import android.widget.Toast;
bb6544e9
JW
29import android.widget.TextView;
30import android.widget.Button;
31import android.view.View;
0763e16d
JW
32import android.util.Log;
33
34public class Dumload extends Activity {
35 /** Called when the activity is first created. */
36 @Override
37 public void onCreate(Bundle savedInstanceState) {
38 super.onCreate(savedInstanceState);
39 setContentView(R.layout.main);
40 TextView tv = (TextView)findViewById(R.id.suckit);
41 tv.setText("Suck it.");
42 }
43
44 private void say(String s) {
45 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
46 }
47
48 public void onStart() {
49 super.onStart();
bb6544e9 50 final Dumload thisact = this;
0763e16d
JW
51
52 Intent i = getIntent(); /* i *am* not an intent! */
bb6544e9
JW
53
54 if (!i.getAction().equals(Intent.ACTION_SEND))
0763e16d 55 {
bb6544e9
JW
56 say("Unknown intent for dumload");
57 this.finish();
58 return;
0763e16d 59 }
bb6544e9
JW
60
61 Bundle extras = i.getExtras();
62 final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
63
64 Log.e("Dumload", "Got a send -- starting service.");
65
66 Button go = (Button)findViewById(R.id.go);
67 go.setOnClickListener(new View.OnClickListener() {
68 public void onClick(View v) {
69 String s = ((TextView) findViewById(R.id.entry)).getText().toString();
70 android.content.ComponentName cn = getApplicationContext()
71 .startService(new Intent()
72 .setClass(getApplicationContext(), Uploader.class)
73 .setData(uri)
74 .putExtra("com.joshuawise.dumload.dest", s));
75 if (cn == null)
76 say("Failed to start uploader.");
77 else
78 Log.e("Dumload", "Started service " + cn.toString() + ".");
79 finish();
80 }
81 });
82
83 String uribase = uri.toString();
84
85
86 ((TextView) findViewById(R.id.suckit)).setText("Where to?");
87 ((TextView) findViewById(R.id.entry)).setText("/var/www/" + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");
88
0763e16d
JW
89 }
90}
This page took 0.030032 seconds and 4 git commands to generate.