Android Open Source - MySms Conversation






From Project

Back to project page MySms.

License

The source code is released under:

Apache License

If you think the Android project MySms 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.henningta.mysms;
/* w  w  w. j av a  2  s.com*/
import android.content.ContentResolver;

/**
 * Conversation information for one phone number
 */
public class Conversation {

  private String source;
  private String name;
  private boolean hasNewMessages;
  private long time;
  private boolean isContact;

  public Conversation(ContentResolver contentResolver, String source) {
    this(source, SmsTools.getContactDisplayNameByNumber(contentResolver, source), false);
  }

  public Conversation(String source, String name, boolean hasNewMessages) {
    this(source, name, hasNewMessages, Settings.NOT_SET);
  }

  public Conversation(String source, String name, boolean hasNewMessages, long time) {
    this.source = source;

    /* format name */
    if (name == null || name.equals("")) {
      // source not in contacts, use phone number for name
      this.name = Settings.formatSource(source);
      this.isContact = false;
    } else {
      // use name found in contacts list
      this.name = name;
      this.isContact = true;
    }

    this.hasNewMessages = hasNewMessages;
    this.time = time;
  }

  /**
   * Return source associated with this conversation
   */
  public String getSource() {
    return source;
  }

  /**
   * Return name associated with this conversation
   */
  public String getName() {
    return name;
  }

  /**
   * Return name with double apostrophes
   */
  public String getNameSql() {
    return name.replace("'", "''");
  }

  /**
   * Notify conversation it has new one or more new messages
   */
  public void setHasNewMessages(boolean hasNewMessages) {
    this.hasNewMessages = hasNewMessages;
  }

  /**
   * Return true if new messages are present, false otherwise
   */
  public boolean hasNewMessages() {
    return hasNewMessages;
  }

  /**
   * Return time of this conversation
   */
  public long getTime() {
    return time;
  }

  /**
   * Set time of this conversation
   */
  public void setTime(long time) {
    this.time = time;
  }

  /**
   * Return true if this phone number is in contact list, false otherwise
   */
  public boolean isContact() {
    return isContact;
  }

  /**
   * Set whether or not this conversation source is in contact list or not
   */
  public void setContact(boolean isContact) {
    this.isContact = isContact;
  }

}




Java Source Code List

com.henningta.mysms.ConversationAdapter.java
com.henningta.mysms.Conversation.java
com.henningta.mysms.ConversationsFragment.java
com.henningta.mysms.DatabaseHandler.java
com.henningta.mysms.MainActivity.java
com.henningta.mysms.MessageAdapter.java
com.henningta.mysms.Message.java
com.henningta.mysms.MessagesFragment.java
com.henningta.mysms.NotificationReceiver.java
com.henningta.mysms.SettingsActivity.java
com.henningta.mysms.Settings.java
com.henningta.mysms.SmsDeliveredReceiver.java
com.henningta.mysms.SmsReceiver.java
com.henningta.mysms.SmsSentReceiver.java
com.henningta.mysms.SmsTools.java
com.henningta.mysms.WakeLocker.java