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 java.io.InputStream;
21 import android.app.Activity;
22 import android.app.Service;
23 import android.content.Intent;
24 import android.net.Uri;
25 import android.os.Bundle;
26 import android.os.IBinder;
27 import android.widget.TextView;
28 import android.widget.Button;
29 import android.view.View;
30 import android.widget.Toast;
31 import android.util.Log;
32 import android.os.Messenger;
33 import android.os.Message;
34 import android.app.AlertDialog;
35 import android.app.Dialog;
36 import android.content.DialogInterface;
38 public class NotifSlave extends Activity {
39 /** Called when the activity is first created. */
41 public void onCreate(Bundle savedInstanceState) {
42 super.onCreate(savedInstanceState);
43 // setContentView(R.layout.main);
44 // TextView tv = (TextView)findViewById(R.id.suckit);
45 // tv.setText("Suck it.");
48 private void say(String s) {
49 Toast.makeText(getApplicationContext(), s, Toast.LENGTH_SHORT).show();
52 private int _nextdialog = 0;
53 private Dialog _hell_ass_balls = null;
56 protected Dialog onCreateDialog(int id)
58 Log.e("DumLoad.NotifSlave", "Create for dialog "+(Integer.toString(id)));
59 if (id != _nextdialog)
61 return _hell_ass_balls;
64 private void showDialog(Dialog d)
68 Log.e("DumLoad.NotifSlave", "Attempting to show dialog "+(Integer.toString(_nextdialog)));
69 showDialog(_nextdialog);
72 public void onStart() {
75 Intent i = getIntent(); /* i *am* not an intent! */
76 final Activity thisact = this;
78 final Messenger m = (Messenger)i.getParcelableExtra("com.joshuawise.dumload.returnmessenger");
79 String reqtype = i.getStringExtra("com.joshuawise.dumload.reqtype");
80 String prompt = i.getStringExtra("com.joshuawise.dumload.prompt");
82 if (prompt == null || reqtype == null || m == null) /* i.e., we got called by a dummy notification */
88 if (reqtype.equals("yesno")) {
89 AlertDialog.Builder builder = new AlertDialog.Builder(this);
90 builder.setTitle("Dumload");
91 builder.setMessage(prompt);
92 builder.setCancelable(false);
93 builder.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
94 public void onClick(DialogInterface dialog, int id) {
95 Log.e("Dumload.NotifSlave", "Responding with a 1.");
97 Message me = Message.obtain();
100 } catch (Exception e) {
101 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
107 builder.setNegativeButton("No", new DialogInterface.OnClickListener() {
108 public void onClick(DialogInterface dialog, int id) {
109 Log.e("Dumload.NotifSlave", "Responding with a 1.");
111 Message me = Message.obtain();
114 } catch (Exception e) {
115 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
121 AlertDialog alert = builder.create();
123 } else if (reqtype.equals("message")) {
124 AlertDialog.Builder builder = new AlertDialog.Builder(this);
125 builder.setTitle("Dumload");
126 builder.setMessage(prompt);
127 builder.setCancelable(false);
128 builder.setNeutralButton("OK", new DialogInterface.OnClickListener() {
129 public void onClick(DialogInterface dialog, int id) {
131 Message me = Message.obtain();
133 } catch (Exception e) {
134 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
140 AlertDialog alert = builder.create();
142 } else if (reqtype.equals("password")) {
143 final Dialog d = new Dialog(this);
145 d.setContentView(R.layout.passwd);
146 d.setTitle("Dumload");
147 d.setCancelable(false);
149 TextView text = (TextView) d.findViewById(R.id.prompt);
150 text.setText(prompt);
152 Button ok = (Button) d.findViewById(R.id.ok);
153 ok.setOnClickListener(new View.OnClickListener() {
154 public void onClick(View v) {
156 Message me = Message.obtain();
158 TextView entry = (TextView) d.findViewById(R.id.entry);
159 Bundle b = new Bundle(1);
160 b.putString("response", entry.getText().toString());
163 } catch (Exception e) {
164 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
171 Button cancel = (Button) d.findViewById(R.id.cancel);
172 cancel.setOnClickListener(new View.OnClickListener() {
173 public void onClick(View v) {
175 Message me = Message.obtain();
178 } catch (Exception e) {
179 Log.e("Dumload.NotifSlave", "Failed to send a message back to my buddy.");
189 Log.e("Dumload.NotifSlave", "What's a "+reqtype+"?");