1 package ubc.midp.mobilephoto.sms;
2
3 import javax.microedition.lcdui.Command;
4 import javax.microedition.lcdui.Image;
5
6 import ubc.midp.mobilephoto.core.ui.MainUIMidlet;
7 import ubc.midp.mobilephoto.core.ui.controller.AbstractController;
8 import ubc.midp.mobilephoto.core.ui.controller.PhotoViewController;
9 import ubc.midp.mobilephoto.core.ui.controller.ScreenSingleton;
10 import ubc.midp.mobilephoto.core.ui.datamodel.AlbumData;
11 import ubc.midp.mobilephoto.core.ui.screens.AlbumListScreen;
12 import ubc.midp.mobilephoto.core.ui.screens.PhotoViewScreen;
13 import ubc.midp.mobilephoto.core.util.Constants;
14
15 public class SmsReceiverController extends AbstractController {
16 byte[] incomingImageData;
17
18 public SmsReceiverController(MainUIMidlet midlet, AlbumData albumData, AlbumListScreen albumListScreen) {
19 super(midlet, albumData, albumListScreen);
20 }
21
22 /**
23 * Handle SMS specific events.
24 * If we are given a standard command that is handled by the BaseController, pass
25 * the handling off to our super class with the else clause
26 */
27
28 public boolean handleCommand(Command c) {
29
30 String label = c.getLabel();
31 System.out.println("SmsReceiverController::handleCommand: " + label);
32
33 /** Case: ... **/
34 if (label.equals("Accept Photo")) {
35
36
37 Image image = Image.createImage(incomingImageData, 0, incomingImageData.length);
38 Image copy = Image.createImage(image.getWidth(), image.getHeight());
39 PhotoViewScreen canv = new PhotoViewScreen(copy);
40 canv.setFromSMS(true);
41 canv.setCommandListener(new PhotoViewController(this.midlet, getAlbumData(), getAlbumListScreen(), "NoName"));
42 this.setCurrentScreen(canv);
43 return true;
44
45 } else if (label.equals("Reject Photo")) {
46
47 //TODO: Go back to whatever screen they were previously on?
48 System.out.println("Reject Photo command");
49 getAlbumListScreen().repaintListAlbum(getAlbumData().getAlbumNames());
50 setCurrentScreen( getAlbumListScreen() );
51 ScreenSingleton.getInstance().setCurrentScreenName(Constants.ALBUMLIST_SCREEN);
52 return true;
53
54 /* For All commands not handled here, send them to the super class */
55 } else if (label.equals("Ok"))
56 {
57 getAlbumListScreen().repaintListAlbum(getAlbumData().getAlbumNames());
58 setCurrentScreen( getAlbumListScreen() );
59 ScreenSingleton.getInstance().setCurrentScreenName(Constants.ALBUMLIST_SCREEN);
60 return true;
61 }
62
63 return false;
64 }
65 public void setIncommingData(byte[] incomingImageData){
66 this.incomingImageData = incomingImageData;
67 }
68 }
|