Search in sources :

Example 1 with Support

use of com.applozic.mobicommons.commons.core.utils.Support in project Applozic-Android-SDK by AppLozic.

the class MobiComConversationFragment method onAttach.

@Override
public void onAttach(Activity activity) {
    super.onAttach(activity);
    support = new Support(activity);
    try {
        messageCommunicator = (MessageCommunicator) activity;
    } catch (ClassCastException e) {
        throw new ClassCastException(activity.toString() + " must implement interfaceDataCommunicator");
    }
}
Also used : Support(com.applozic.mobicommons.commons.core.utils.Support)

Example 2 with Support

use of com.applozic.mobicommons.commons.core.utils.Support in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method addWelcomeMessage.

public void addWelcomeMessage(String content) {
    Message message = new Message();
    MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(context);
    message.setContactIds(new Support(context).getSupportNumber());
    message.setTo(new Support(context).getSupportNumber());
    message.setMessage(content);
    message.setStoreOnDevice(Boolean.TRUE);
    message.setSendToDevice(Boolean.FALSE);
    message.setType(Message.MessageType.MT_INBOX.getValue());
    message.setDeviceKeyString(userPreferences.getDeviceKeyString());
    message.setSource(Message.Source.MT_MOBILE_APP.getValue());
    conversationService.sendMessage(message, messageIntentServiceClass);
}
Also used : PersonalizedMessage(com.applozic.mobicommons.personalization.PersonalizedMessage) Support(com.applozic.mobicommons.commons.core.utils.Support) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference)

Example 3 with Support

use of com.applozic.mobicommons.commons.core.utils.Support in project Applozic-Android-SDK by AppLozic.

the class ContactUtils method getContact.

public static Contact getContact(Context context, String contactId, String number) {
    Contact contact = new Contact();
    contact.setContactNumber(number);
    Support support = new Support(context);
    if (support.isSupportNumber(number)) {
        return support.getSupportContact();
    } else if (TextUtils.isEmpty(contactId) || UNKNOWN_NUMBER.equals(contactId)) {
        contact.processContactNumbers(context);
        return contact;
    }
    contact.setContactId(Long.valueOf(contactId));
    String structuredNameWhere = ContactsContract.Data.CONTACT_ID + " = ? AND " + ContactsContract.Data.MIMETYPE + " = ?";
    String[] structuredNameWhereParams = new String[] { contactId, ContactsContract.CommonDataKinds.StructuredName.CONTENT_ITEM_TYPE };
    Cursor cursor = context.getContentResolver().query(ContactsContract.Data.CONTENT_URI, null, structuredNameWhere, structuredNameWhereParams, null);
    try {
        if (cursor.moveToFirst()) {
            String id = cursor.getString(cursor.getColumnIndex(ContactsContract.Contacts._ID));
            String prefix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.PREFIX));
            String fullName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.DISPLAY_NAME));
            String firstName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.GIVEN_NAME));
            String middleName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.MIDDLE_NAME));
            String lastName = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.FAMILY_NAME));
            String suffix = cursor.getString(cursor.getColumnIndex(ContactsContract.CommonDataKinds.StructuredName.SUFFIX));
            prefix = prefix == null ? "" : prefix;
            firstName = firstName == null ? "" : firstName;
            middleName = middleName == null ? "" : middleName;
            lastName = lastName == null ? "" : lastName;
            suffix = suffix == null ? "" : suffix;
            contact.setFirstName(TextUtils.isEmpty(prefix) ? firstName : (prefix + " " + firstName));
            contact.setMiddleName(middleName);
            contact.setLastName(TextUtils.isEmpty(suffix) ? lastName : (lastName + " " + suffix));
            // contact.setContactId(Long.valueOf(id));
            contact.setFullName(fullName);
        }
    } finally {
        if (cursor != null) {
            cursor.close();
        }
    }
    contact.processContactNumbers(context);
    return contact;
}
Also used : Support(com.applozic.mobicommons.commons.core.utils.Support) Cursor(android.database.Cursor)

Aggregations

Support (com.applozic.mobicommons.commons.core.utils.Support)3 Cursor (android.database.Cursor)1 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)1 PersonalizedMessage (com.applozic.mobicommons.personalization.PersonalizedMessage)1