Android Open Source - LheidoSMS Lheido Contact






From Project

Back to project page LheidoSMS.

License

The source code is released under:

GNU General Public License

If you think the Android project LheidoSMS 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.lheidosms.utils;
/*  w w  w. j av  a  2s . com*/
import android.content.ContentUris;
import android.content.Context;
import android.database.Cursor;
import android.net.Uri;
import android.provider.ContactsContract;
import android.telephony.PhoneNumberUtils;

public class LheidoContact {
    private String name_ = null;
    private String lastsms_ = null;
    private long nb_sms_ = -1;
    private String phone_ = null;
    private String conversation_id_ = null;
    private Uri pic;
    private long id;
    private boolean mark_new_messsage = false;
    private String accountType = null;

    public LheidoContact(){
        // Empty constructor
    }
    /**
     *
     * @param name            : contact name.
     * @param phone           : contact phone number
     * @param nb_sms          : sms count
     * @param conversation_id : conversation id to fetch database
     */
    public LheidoContact(String name, String phone, long nb_sms, String conversation_id){
        this.name_ = name;
        this.phone_ = phone;
        this.nb_sms_ = nb_sms;
        this.conversation_id_ = conversation_id;
    }
    public static String getContactName(Context context, String address){
        String res = "";
        Cursor cur = context.getContentResolver().query(ContactsContract.CommonDataKinds.Phone.CONTENT_URI, null, null, null, null);
        if(cur != null){
            String name = "";
            while(name.equals("") && cur.moveToNext()){
                String phone = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.NUMBER));
                //Log.v("LHEIDO SMS LOG", phone + ", " + address);
                if(name.equals("") && PhoneNumberUtils.compare(phone, address)){
                    name = cur.getString(cur.getColumnIndexOrThrow(ContactsContract.CommonDataKinds.Phone.DISPLAY_NAME));
                    res += name;
                }
            }
            if(name.equals(""))
                res += address;
            cur.close();
        }
        return res;
    }

    public LheidoContact newInstance(){
        LheidoContact c = new LheidoContact();
        c.setName(this.name_);
        c.setPhone(this.phone_);
        c.setId(this.id);
        c.setConversationId(this.conversation_id_);
        c.setPic();
        c.setNb_sms(""+this.nb_sms_);
        c.setAccountType(this.accountType);
        return c;
    }

    public String getName(){
        return name_;
    }
    public String getLastsms(){
        return lastsms_;
    }
    public long getNb_sms(){
        return nb_sms_;
    }
    public String getPhone(){
        return phone_;
    }
    public String getConversationId(){
        return conversation_id_;
    }
    public void setNb_sms(String count){
        this.nb_sms_ = Integer.parseInt(count);
    }
    public void setPhone(String address){
        this.phone_ = address;
    }
    public void setConversationId(String id){
        this.conversation_id_ = id;
    }

    public Uri getPic(){
        return this.pic;
    }

    public void setPic(){
        this.pic = ContentUris.withAppendedId(ContactsContract.Contacts.CONTENT_URI, this.id);
    }

    public long getId() {
        return this.id;
    }
    public void setId(long id_){
        this.id = id_;
    }
    public void setName(String string) {
        this.name_ = string;
    }

    public void Nb_sms_Plus() {
        this.nb_sms_ += 1;
    }

    public void markNewMessage(Boolean val) {
        this.mark_new_messsage = val;
    }

    public boolean hasNewMessage() {
        return this.mark_new_messsage;
    }

    public void setAccountType(String accountType) {
        this.accountType = accountType;
    }

    public String getAccountType() {
        return this.accountType;
    }
}




Java Source Code List

com.lheidosms.adapter.ContactsListAdapter.java
com.lheidosms.adapter.ConversationAdapter.java
com.lheidosms.adapter.ListeConversationsAdapter.java
com.lheidosms.adapter.MMSAdapter.java
com.lheidosms.adapter.SmsAdapter.java
com.lheidosms.adapter.SmsBaseAdapter.java
com.lheidosms.adapter.ViewPagerAdapter.java
com.lheidosms.app.AutoComplete.java
com.lheidosms.app.Global.java
com.lheidosms.app.MainLheidoSMS.java
com.lheidosms.fragment.MMSFragment.java
com.lheidosms.fragment.NavigationDrawerFragment.java
com.lheidosms.fragment.SMSFragment.java
com.lheidosms.fragment.SmsBaseFragment.java
com.lheidosms.preference.LheidoSMSPreferenceOldApi.java
com.lheidosms.preference.LheidoSMSPreference.java
com.lheidosms.preference.PrefConversationFragment.java
com.lheidosms.preference.PrefGeneralFragment.java
com.lheidosms.preference.PrefListConversationsFragment.java
com.lheidosms.preference.PrefReceiveFragment.java
com.lheidosms.receiver.BootReceiver.java
com.lheidosms.receiver.LheidoBaseReceiver.java
com.lheidosms.receiver.MainServiceReceiver.java
com.lheidosms.receiver.MmsFragmentReceiver.java
com.lheidosms.receiver.SmsFragmentReceiver.java
com.lheidosms.receiver.SmsReceiver.java
com.lheidosms.service.DeleteOldSMSService.java
com.lheidosms.service.LheidoSMSService.java
com.lheidosms.service.MainService.java
com.lheidosms.service.RemoveConversationService.java
com.lheidosms.utils.BuildFragment.java
com.lheidosms.utils.LheidoContact.java
com.lheidosms.utils.LheidoUtils.java
com.lheidosms.utils.Message.java