]> Joshua Wise's Git repositories - dumload.git/blobdiff - src/com/joshuawise/dumload/Dumload.java
Revert "Remove generated/IDE files"
[dumload.git] / src / com / joshuawise / dumload / Dumload.java
index 0905ac99bfd080c78f4dbf01d6b7bcce17b146f0..f3317c43f2e93d8c410b0e1574cbd7ec280f05a0 100644 (file)
@@ -1,18 +1,21 @@
 package com.joshuawise.dumload;
 
 package com.joshuawise.dumload;
 
-import java.io.InputStream;
-
 import android.app.Activity;
 import android.app.Activity;
-import android.app.Service;
 import android.content.Intent;
 import android.content.Intent;
+import android.content.SharedPreferences;
 import android.net.Uri;
 import android.os.Bundle;
 import android.net.Uri;
 import android.os.Bundle;
-import android.os.IBinder;
+import android.preference.PreferenceManager;
+import android.util.Log;
+import android.view.View;
+import android.widget.Button;
 import android.widget.TextView;
 import android.widget.Toast;
 import android.widget.TextView;
 import android.widget.Toast;
-import android.util.Log;
 
 public class Dumload extends Activity {
 
 public class Dumload extends Activity {
+       
+       private SharedPreferences prefs;
+       
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
@@ -28,27 +31,48 @@ public class Dumload extends Activity {
        
        public void onStart() {
                super.onStart();
        
        public void onStart() {
                super.onStart();
+               final Dumload thisact = this;
+               
+               prefs = PreferenceManager.getDefaultSharedPreferences(this);
                
                Intent i = getIntent(); /* i *am* not an intent! */
                
                Intent i = getIntent(); /* i *am* not an intent! */
-               if (i.getAction().equals(Intent.ACTION_SEND))
+               
+               if (!i.getAction().equals(Intent.ACTION_SEND))
                {
                {
-                       Bundle extras = i.getExtras();
-                       Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
-                       
-                       Log.e("Dumload", "Got a send -- starting service.");
-                       // Never let an ML programmer touch Java.
-                       android.content.ComponentName cn = getApplicationContext().startService(new Intent().setClass(getApplicationContext(), Uploader.class).setData(uri));
-                       
-                       if (cn == null)
-                               say("Fuuuuuuuuuck.");
-                       else
-                               Log.e("Dumload", "Started service " + cn.toString() + ".");
-                       
-                       TextView tv = (TextView)findViewById(R.id.suckit);
-                       tv.setText("Action was send: "+uri.toString());
-               } else {
-                       TextView tv = (TextView)findViewById(R.id.suckit);
-                       tv.setText("Action was something else");
+//                     say("Unknown intent for dumload");
+//                     this.finish();
+                       Intent pi = new Intent(this, Preferences.class);
+                       startActivity(pi);
+                       return;
                }
                }
+               
+               Bundle extras = i.getExtras();
+               final Uri uri = (Uri)extras.getParcelable(Intent.EXTRA_STREAM);
+               
+               Log.e("Dumload", "Got a send -- starting service.");
+               
+               Button go = (Button)findViewById(R.id.go);
+               go.setOnClickListener(new View.OnClickListener() {
+                       public void onClick(View v) {
+                               String s = ((TextView) findViewById(R.id.entry)).getText().toString();
+                               android.content.ComponentName cn = getApplicationContext()
+                                                                    .startService(new Intent()
+                                                                                    .setClass(getApplicationContext(), Uploader.class)
+                                                                                    .setData(uri)
+                                                                                    .putExtra("com.joshuawise.dumload.dest", s));
+                               if (cn == null)
+                                       say("Failed to start uploader.");
+                               else
+                                       Log.e("Dumload", "Started service " + cn.toString() + ".");
+                               finish();
+                       }
+               });
+               
+               String uribase = uri.toString();
+               
+               
+               ((TextView) findViewById(R.id.suckit)).setText("Where to?");
+               ((TextView) findViewById(R.id.entry)).setText(prefs.getString("defaultUploadPath", "/var/www/") + uribase.substring(uribase.lastIndexOf("/") + 1) + ".jpg");
+               
        }
 }
\ No newline at end of file
        }
 }
\ No newline at end of file
This page took 0.028667 seconds and 4 git commands to generate.