Android Open Source - sms-smap-gateway Text Message






From Project

Back to project page sms-smap-gateway.

License

The source code is released under:

GNU General Public License

If you think the Android project sms-smap-gateway listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.android.smap.models;
/*from   www .  j a va2  s . co  m*/
import java.util.Date;

/**
 * Possible model for text messages. Nothing set in stone. Borrowed from another
 * Implementation.
 * 
 * 
 */
public class TextMessage {

  /** the message is incoming */
  public static final char  INCOMING  = 'I';

  /** the message is outgoing */
  public static final char  OUTGOING  = 'O';

  /** indicates the message is received, but needs to be handled */
  public static final char  RECEIVED  = 'R';

  /** the message has been handled, that is delivered to the server */
  public static final char  HANDLED    = 'H';

  /** we ignored this message */
  public static final char  IGNORED    = 'I';

  /**
   * we've told android to send it, but haven't got a confirmation that it has
   * happened yet
   */
  public static final char  QUEUED    = 'Q';

  /**
   * we tried to send it (either to the server or to android) but got an error
   */
  public static final char  ERRORED    = 'E';

  /** android told us it's on its way */
  public static final char  SENT    = 'S';

  /**
   * the handling for this message is complete, the server was notified it was
   * sent
   */
  public static final char  DONE    = 'D';

  public TextMessage() {}

  public TextMessage(String number, String text, long serverId) {
    this.number = number;
    this.text = text;
    this.created = new Date();
    this.direction = OUTGOING;
    this.status = QUEUED;
    this.serverId = serverId;
  }

  public TextMessage respond(String number, String text) {
    TextMessage msg = new TextMessage();
    msg.number = number;
    msg.text = text;
    msg.created = new Date();
    msg.direction = OUTGOING;
    msg.status = QUEUED;
    return msg;
  }

  public String getStatusText() {
    switch (status) {
    case RECEIVED:
      return "Received";
    case HANDLED:
      return "Complete";
    case IGNORED:
      return "Ignored";
    case QUEUED:
      return "Queued";
    case ERRORED:
      if (direction == OUTGOING) {
        return "Send Error";
      } else {
        return "Server Error";
      }
    case SENT:
      return "Sent";
    case DONE:
      return "Complete";
    default:
      return "--";
    }
  }

  public boolean equals(Object other) {
    if (other instanceof TextMessage) {
      return ((TextMessage) other).id == this.id;
    } else {
      return false;
    }
  }

  public long    id;
  public String  number;
  public String  text;
  public String  error;
  public Date    created;
  public char    direction;
  public char    status;
  public long    serverId;
}




Java Source Code List

com.android.smap.AppConfig.java
com.android.smap.GatewayApp.java
com.android.smap.PhoneStateWrapper.java
com.android.smap.activities.BaseActivity.java
com.android.smap.activities.FragmentWrapperActivity.java
com.android.smap.activities.MainActivity.java
com.android.smap.adapters.MenuDrawerAdapter.java
com.android.smap.api.ApiConstants.java
com.android.smap.api.models.Gojo.java
com.android.smap.api.models.Node.java
com.android.smap.api.models.SmapException.java
com.android.smap.api.models.Status.java
com.android.smap.api.models.validator.ModelValidator.java
com.android.smap.api.models.validator.Required.java
com.android.smap.api.requests.ApiRequest.java
com.android.smap.api.requests.GojoRequest.java
com.android.smap.api.requests.StatusRequest.java
com.android.smap.commonsware.wakefull.AlarmReceiver.java
com.android.smap.commonsware.wakefull.WakefulIntentService.java
com.android.smap.controllers.ControllerErrorListener.java
com.android.smap.controllers.ControllerError.java
com.android.smap.controllers.ControllerFactory.java
com.android.smap.controllers.ControllerListener.java
com.android.smap.controllers.Controller.java
com.android.smap.controllers.EmailController.java
com.android.smap.controllers.GojoController.java
com.android.smap.controllers.UIPagingController.java
com.android.smap.controllers.UIRequestController.java
com.android.smap.fragments.BaseFragment.java
com.android.smap.fragments.HomeFragment.java
com.android.smap.models.MenuDrawerItem.java
com.android.smap.models.TextMessage.java
com.android.smap.samuel.Samuel.java
com.android.smap.sms.CellularModem.java
com.android.smap.sms.GatewayService.java
com.android.smap.sms.MonitorService.java
com.android.smap.sms.ScheduleMonitoringListener.java
com.android.smap.sms.ServiceRebooter.java
com.android.smap.ui.ArrayVelocAdapter.java
com.android.smap.ui.OnErrorTouchedListener.java
com.android.smap.ui.Operation.java
com.android.smap.ui.VelocAdapter.java
com.android.smap.ui.ViewBinder.java
com.android.smap.ui.ViewQuery.java
com.android.smap.ui.views.AnimatedNetworkImageView.java
com.android.smap.ui.views.ErrorView.java
com.android.smap.ui.views.FontableTextView.java
com.android.smap.utils.BitmapLruCache.java
com.android.smap.utils.MWAPNUtils.java
com.android.smap.utils.MWAnimUtil.java
com.android.smap.utils.MWAssetsUtils.java
com.android.smap.utils.MWConnectionUtils.java
com.android.smap.utils.MWEmailUtils.java
com.android.smap.utils.MWUiUtils.java
com.android.smap.utils.PreferenceWrapper.java
com.android.smap.utils.Refresher.java
com.android.smap.utils.UriBuilder.java