1 package com.joshuawise.dumload;
3 import java.io.InputStream;
5 import android.app.Activity;
6 import android.app.Service;
7 import android.content.Intent;
8 import android.net.Uri;
9 import android.os.Bundle;
10 import android.os.IBinder;
11 import android.widget.TextView;
12 import android.widget.Button;
13 import android.view.View;
14 import android.widget.Toast;
15 import android.util.Log;
16 import android.os.Messenger;
17 import android.os.Message;
18 import android.app.AlertDialog;
19 import android.app.Dialog;
20 import android.content.DialogInterface;
22 public class NotifSlave extends Activity {
23 /** Called when the activity is first created. */
25 public void onCreate(Bundle savedInstanceState) {
26 super.onCreate(savedInstanceState);
27 // setContentView(R.layout.main);
28 // TextView tv = (TextView)findViewById(R.id.suckit);
29 // tv.setText("Suck it.");
32 private void say(String s) {
33 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
36 private int _nextdialog = 0;
37 private Dialog _hell_ass_balls = null;
40 protected Dialog onCreateDialog(int id)
42 Log.e("DumLoad.NotifSlave", "Create for dialog "+(Integer.toString(id)));
43 if (id != _nextdialog)
45 return _hell_ass_balls;
48 private void showDialog(Dialog d)
52 Log.e("DumLoad.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
53 showDialog(_nextdialog);
56 public void onStart() {
59 Intent i = getIntent(); /* i *am* not an intent! */
60 final Activity thisact = this;
62 final Messenger m = (Messenger)i.getParcelableExtra("com.joshuawise.dumload.returnmessenger");
63 String reqtype = i.getStringExtra("com.joshuawise.dumload.reqtype");
64 String prompt = i.getStringExtra("com.joshuawise.dumload.prompt");
66 if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
72 if (reqtype.equals("yesno")) {
73 AlertDialog.Builder builder = new AlertDialog.Builder(this);
74 builder.setTitle("Dumload");
75 builder.setMessage(prompt);
76 builder.setCancelable(false);
77 builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
78 public void onClick(DialogInterface dialog, int id) {
79 Log.e("Dumload.NotifSlave", "Responding with a 1.");
81 Message me = Message.obtain();
84 } catch (Exception e) {
85 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
91 builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
92 public void onClick(DialogInterface dialog, int id) {
93 Log.e("Dumload.NotifSlave", "Responding with a 1.");
95 Message me = Message.obtain();
98 } catch (Exception e) {
99 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
105 AlertDialog alert = builder.create();
107 } else if (reqtype.equals("message")) {
108 AlertDialog.Builder builder = new AlertDialog.Builder(this);
109 builder.setTitle("Dumload");
110 builder.setMessage(prompt);
111 builder.setCancelable(false);
112 builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
113 public void onClick(DialogInterface dialog, int id) {
115 Message me = Message.obtain();
117 } catch (Exception e) {
118 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
124 AlertDialog alert = builder.create();
126 } else if (reqtype.equals("password")) {
127 final Dialog d = new Dialog(this);
129 d.setContentView(R.layout.passwd);
130 d.setTitle("Dumload");
131 d.setCancelable(false);
133 TextView text = (TextView) d.findViewById(R.id.prompt);
134 text.setText(prompt);
136 Button ok = (Button) d.findViewById(R.id.ok);
137 ok.setOnClickListener(new View.OnClickListener() {
138 public void onClick(View v) {
140 Message me = Message.obtain();
142 TextView entry = (TextView) d.findViewById(R.id.entry);
143 Bundle b = new Bundle(1);
144 b.putString("response", entry.getText().toString());
147 } catch (Exception e) {
148 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
155 Button cancel = (Button) d.findViewById(R.id.cancel);
156 cancel.setOnClickListener(new View.OnClickListener() {
157 public void onClick(View v) {
159 Message me = Message.obtain();
162 } catch (Exception e) {
163 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
173 Log.e("Dumload.NotifSlave", "What's a "+reqtype+"?");