1 package com.joshuawise.dumload;
3 import android.app.Activity;
4 import android.app.AlertDialog;
5 import android.app.Dialog;
6 import android.content.DialogInterface;
7 import android.content.Intent;
8 import android.os.Bundle;
9 import android.os.Message;
10 import android.os.Messenger;
11 import android.util.Log;
12 import android.view.View;
13 import android.widget.Button;
14 import android.widget.TextView;
15 import android.widget.Toast;
17 public class NotifSlave extends Activity {
18 /** Called when the activity is first created. */
20 public void onCreate(Bundle savedInstanceState) {
21 super.onCreate(savedInstanceState);
22 // setContentView(R.layout.main);
23 // TextView tv = (TextView)findViewById(R.id.suckit);
24 // tv.setText("Suck it.");
27 private void say(String s) {
28 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
31 private int _nextdialog = 0;
32 private Dialog _hell_ass_balls = null;
35 protected Dialog onCreateDialog(int id)
37 Log.e("DumLoad.NotifSlave", "Create for dialog "+(Integer.toString(id)));
38 if (id != _nextdialog)
40 return _hell_ass_balls;
43 private void showDialog(Dialog d)
47 Log.e("DumLoad.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
48 showDialog(_nextdialog);
51 public void onStart() {
54 Intent i = getIntent(); /* i *am* not an intent! */
55 final Activity thisact = this;
57 final Messenger m = (Messenger)i.getParcelableExtra("com.joshuawise.dumload.returnmessenger");
58 String reqtype = i.getStringExtra("com.joshuawise.dumload.reqtype");
59 String prompt = i.getStringExtra("com.joshuawise.dumload.prompt");
61 if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
67 if (reqtype.equals("yesno")) {
68 AlertDialog.Builder builder = new AlertDialog.Builder(this);
69 builder.setTitle("Dumload");
70 builder.setMessage(prompt);
71 builder.setCancelable(false);
72 builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
73 public void onClick(DialogInterface dialog, int id) {
74 Log.e("Dumload.NotifSlave", "Responding with a 1.");
76 Message me = Message.obtain();
79 } catch (Exception e) {
80 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
86 builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
87 public void onClick(DialogInterface dialog, int id) {
88 Log.e("Dumload.NotifSlave", "Responding with a 1.");
90 Message me = Message.obtain();
93 } catch (Exception e) {
94 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
100 AlertDialog alert = builder.create();
102 } else if (reqtype.equals("message")) {
103 AlertDialog.Builder builder = new AlertDialog.Builder(this);
104 builder.setTitle("Dumload");
105 builder.setMessage(prompt);
106 builder.setCancelable(false);
107 builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
108 public void onClick(DialogInterface dialog, int id) {
110 Message me = Message.obtain();
112 } catch (Exception e) {
113 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
119 AlertDialog alert = builder.create();
121 } else if (reqtype.equals("password")) {
122 final Dialog d = new Dialog(this);
124 d.setContentView(R.layout.passwd);
125 d.setTitle("Dumload");
126 d.setCancelable(false);
128 TextView text = (TextView) d.findViewById(R.id.prompt);
129 text.setText(prompt);
131 Button ok = (Button) d.findViewById(R.id.ok);
132 ok.setOnClickListener(new View.OnClickListener() {
133 public void onClick(View v) {
135 Message me = Message.obtain();
137 TextView entry = (TextView) d.findViewById(R.id.entry);
138 Bundle b = new Bundle(1);
139 b.putString("response", entry.getText().toString());
142 } catch (Exception e) {
143 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
150 Button cancel = (Button) d.findViewById(R.id.cancel);
151 cancel.setOnClickListener(new View.OnClickListener() {
152 public void onClick(View v) {
154 Message me = Message.obtain();
157 } catch (Exception e) {
158 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
168 Log.e("Dumload.NotifSlave", "What's a "+reqtype+"?");