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