2 * Notification interface glue for Dumload.
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.
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.
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/>.
17 package com.joshuawise.dumload;
19 import android.app.Activity;
20 import android.app.AlertDialog;
21 import android.app.Dialog;
22 import android.content.DialogInterface;
23 import android.content.Intent;
24 import android.os.Bundle;
25 import android.os.Message;
26 import android.os.Messenger;
27 import android.util.Log;
28 import android.view.View;
29 import android.widget.Button;
30 import android.widget.TextView;
31 import android.widget.Toast;
33 public class NotifSlave extends Activity {
34 /** Called when the activity is first created. */
36 public void onCreate(Bundle savedInstanceState) {
37 super.onCreate(savedInstanceState);
38 // setContentView(R.layout.main);
39 // TextView tv = (TextView)findViewById(R.id.suckit);
40 // tv.setText("Suck it.");
43 private void say(String s) {
44 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
47 private int _nextdialog = 0;
48 private Dialog _hell_ass_balls = null;
51 protected Dialog onCreateDialog(int id)
53 Log.e("DumLoad.NotifSlave", "Create for dialog "+(Integer.toString(id)));
54 if (id != _nextdialog)
56 return _hell_ass_balls;
59 private void showDialog(Dialog d)
63 Log.e("DumLoad.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
64 showDialog(_nextdialog);
67 public void onStart() {
70 Intent i = getIntent(); /* i *am* not an intent! */
71 final Activity thisact = this;
73 final Messenger m = (Messenger)i.getParcelableExtra("com.joshuawise.dumload.returnmessenger");
74 String reqtype = i.getStringExtra("com.joshuawise.dumload.reqtype");
75 String prompt = i.getStringExtra("com.joshuawise.dumload.prompt");
77 if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
83 if (reqtype.equals("yesno")) {
84 AlertDialog.Builder builder = new AlertDialog.Builder(this);
85 builder.setTitle("Dumload");
86 builder.setMessage(prompt);
87 builder.setCancelable(false);
88 builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
89 public void onClick(DialogInterface dialog, int id) {
90 Log.e("Dumload.NotifSlave", "Responding with a 1.");
92 Message me = Message.obtain();
95 } catch (Exception e) {
96 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
102 builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
103 public void onClick(DialogInterface dialog, int id) {
104 Log.e("Dumload.NotifSlave", "Responding with a 1.");
106 Message me = Message.obtain();
109 } catch (Exception e) {
110 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
116 AlertDialog alert = builder.create();
118 } else if (reqtype.equals("message")) {
119 AlertDialog.Builder builder = new AlertDialog.Builder(this);
120 builder.setTitle("Dumload");
121 builder.setMessage(prompt);
122 builder.setCancelable(false);
123 builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
124 public void onClick(DialogInterface dialog, int id) {
126 Message me = Message.obtain();
128 } catch (Exception e) {
129 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
135 AlertDialog alert = builder.create();
137 } else if (reqtype.equals("password")) {
138 final Dialog d = new Dialog(this);
140 d.setContentView(R.layout.passwd);
141 d.setTitle("Dumload");
142 d.setCancelable(false);
144 TextView text = (TextView) d.findViewById(R.id.prompt);
145 text.setText(prompt);
147 Button ok = (Button) d.findViewById(R.id.ok);
148 ok.setOnClickListener(new View.OnClickListener() {
149 public void onClick(View v) {
151 Message me = Message.obtain();
153 TextView entry = (TextView) d.findViewById(R.id.entry);
154 Bundle b = new Bundle(1);
155 b.putString("response", entry.getText().toString());
158 } catch (Exception e) {
159 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
166 Button cancel = (Button) d.findViewById(R.id.cancel);
167 cancel.setOnClickListener(new View.OnClickListener() {
168 public void onClick(View v) {
170 Message me = Message.obtain();
173 } catch (Exception e) {
174 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
184 Log.e("Dumload.NotifSlave", "What's a "+reqtype+"?");