Search in sources :

Example 1 with UserClientService

use of com.applozic.mobicomkit.api.account.user.UserClientService in project Applozic-Android-SDK by AppLozic.

the class MobiComMessageService method processContactFromMessages.

public void processContactFromMessages(List<Message> messages) {
    try {
        if (!ApplozicClient.getInstance(context).isHandleDisplayName()) {
            return;
        }
        Set<String> userIds = new HashSet<String>();
        for (Message msg : messages) {
            if (!baseContactService.isContactExists(msg.getContactIds())) {
                userIds.add(msg.getContactIds());
            }
        }
        if (userIds.isEmpty()) {
            return;
        }
        try {
            Map<String, String> userIdsHashMap = new UserClientService(context).getUserInfo(userIds);
            for (Map.Entry<String, String> keyValue : userIdsHashMap.entrySet()) {
                Contact contact = new Contact();
                contact.setUserId(keyValue.getKey());
                contact.setFullName(keyValue.getValue());
                contact.setUnreadCount(0);
                baseContactService.upsert(contact);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
        }
    } catch (Exception ex) {
    }
}
Also used : PersonalizedMessage(com.applozic.mobicommons.personalization.PersonalizedMessage) JSONException(org.json.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map) UserClientService(com.applozic.mobicomkit.api.account.user.UserClientService) JSONException(org.json.JSONException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) HashSet(java.util.HashSet) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 2 with UserClientService

use of com.applozic.mobicomkit.api.account.user.UserClientService in project Applozic-Android-SDK by AppLozic.

the class ConversationUIService method checkForStartNewConversation.

public void checkForStartNewConversation(Intent intent) {
    Contact contact = null;
    Channel channel = null;
    Integer conversationId = null;
    if (Intent.ACTION_SEND.equals(intent.getAction()) && intent.getType() != null) {
        if ("text/plain".equals(intent.getType())) {
            String sharedText = intent.getStringExtra(Intent.EXTRA_TEXT);
            if (sharedText != null) {
                startContactActivityForResult(null, sharedText);
            }
        } else if (intent.getType().startsWith("image/")) {
        // Todo: use this for image forwarding
        }
    }
    final Uri uri = intent.getData();
    if (uri != null) {
        // Note: This is used only for the device contacts
        Long contactId = intent.getLongExtra(CONTACT_ID, 0);
        if (contactId == 0) {
            // Todo: show warning that the user doesn't have any number stored.
            return;
        }
        contact = baseContactService.getContactById(String.valueOf(contactId));
    }
    Integer channelKey = intent.getIntExtra(GROUP_ID, -1);
    String clientGroupId = intent.getStringExtra(CLIENT_GROUP_ID);
    String channelName = intent.getStringExtra(GROUP_NAME);
    if (!TextUtils.isEmpty(clientGroupId)) {
        channel = ChannelService.getInstance(fragmentActivity).getChannelByClientGroupId(clientGroupId);
        if (channel == null) {
            return;
        }
    } else if (channelKey != -1 && channelKey != null && channelKey != 0) {
        channel = ChannelService.getInstance(fragmentActivity).getChannel(channelKey);
    }
    if (channel != null && !TextUtils.isEmpty(channelName) && TextUtils.isEmpty(channel.getName())) {
        channel.setName(channelName);
        ChannelService.getInstance(fragmentActivity).updateChannel(channel);
    }
    String contactNumber = intent.getStringExtra(CONTACT_NUMBER);
    boolean firstTimeMTexterFriend = intent.getBooleanExtra(FIRST_TIME_MTEXTER_FRIEND, false);
    if (!TextUtils.isEmpty(contactNumber)) {
        contact = baseContactService.getContactById(contactNumber);
        if (BroadcastService.isIndividual()) {
            getConversationFragment().setFirstTimeMTexterFriend(firstTimeMTexterFriend);
        }
    }
    String userId = intent.getStringExtra(USER_ID);
    if (TextUtils.isEmpty(userId)) {
        userId = intent.getStringExtra("contactId");
    }
    if (!TextUtils.isEmpty(userId)) {
        contact = baseContactService.getContactById(userId);
    }
    String searchString = intent.getStringExtra(SEARCH_STRING);
    String applicationId = intent.getStringExtra(APPLICATION_ID);
    if (contact != null) {
        contact.setApplicationId(applicationId);
        baseContactService.upsert(contact);
    }
    String fullName = intent.getStringExtra(DISPLAY_NAME);
    if (contact != null && TextUtils.isEmpty(contact.getFullName()) && !TextUtils.isEmpty(fullName)) {
        contact.setFullName(fullName);
        baseContactService.upsert(contact);
        new UserClientService(fragmentActivity).updateUserDisplayName(userId, fullName);
    }
    String messageJson = intent.getStringExtra(MobiComKitConstants.MESSAGE_JSON_INTENT);
    if (!TextUtils.isEmpty(messageJson)) {
        Message message = (Message) GsonUtils.getObjectFromJson(messageJson, Message.class);
        if (message.getGroupId() != null) {
            channel = ChannelService.getInstance(fragmentActivity).getChannelByChannelKey(message.getGroupId());
        } else {
            contact = baseContactService.getContactById(message.getContactIds());
        }
        conversationId = message.getConversationId();
    }
    if (conversationId == null) {
        conversationId = intent.getIntExtra(CONVERSATION_ID, 0);
    }
    if (conversationId != 0 && conversationId != null) {
        getConversationFragment().setConversationId(conversationId);
    } else {
        conversationId = null;
    }
    boolean support = intent.getBooleanExtra(Support.SUPPORT_INTENT_KEY, false);
    if (support) {
        contact = new Support(fragmentActivity).getSupportContact();
    }
    String defaultText = intent.getStringExtra(ConversationUIService.DEFAULT_TEXT);
    if (!TextUtils.isEmpty(defaultText)) {
        getConversationFragment().setDefaultText(defaultText);
    }
    String forwardMessage = intent.getStringExtra(MobiComKitPeopleActivity.FORWARD_MESSAGE);
    if (!TextUtils.isEmpty(forwardMessage)) {
        Message messageToForward = (Message) GsonUtils.getObjectFromJson(forwardMessage, Message.class);
        getConversationFragment().forwardMessage(messageToForward, contact, channel);
    }
    if (contact != null) {
        openConversationFragment(contact, conversationId, searchString);
    }
    if (channel != null) {
        openConversationFragment(channel, conversationId, searchString);
    }
    String productTopicId = intent.getStringExtra(ConversationUIService.PRODUCT_TOPIC_ID);
    String productImageUrl = intent.getStringExtra(ConversationUIService.PRODUCT_IMAGE_URL);
    if (!TextUtils.isEmpty(productTopicId) && !TextUtils.isEmpty(productImageUrl)) {
        try {
            FileMeta fileMeta = new FileMeta();
            fileMeta.setContentType("image");
            fileMeta.setBlobKeyString(productImageUrl);
            getConversationFragment().sendProductMessage(productTopicId, fileMeta, contact, Message.ContentType.TEXT_URL.getValue());
        } catch (Exception e) {
        }
    }
    String sharedText = intent.getStringExtra(MobiComKitPeopleActivity.SHARED_TEXT);
    if (!TextUtils.isEmpty(sharedText)) {
        getConversationFragment().sendMessage(sharedText);
    }
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) Support(com.applozic.mobicommons.commons.core.utils.Support) Channel(com.applozic.mobicommons.people.channel.Channel) Uri(android.net.Uri) UserClientService(com.applozic.mobicomkit.api.account.user.UserClientService) FileMeta(com.applozic.mobicomkit.api.attachment.FileMeta) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 3 with UserClientService

use of com.applozic.mobicomkit.api.account.user.UserClientService in project Applozic-Android-SDK by AppLozic.

the class ConversationActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    // noinspection SimplifiableIfStatement
    if (id == R.id.start_new) {
        if (!TextUtils.isEmpty(contactsGroupId)) {
            if (Utils.isInternetAvailable(this)) {
                conversationUIService.startContactActivityForResult();
            } else {
                Intent intent = new Intent(this, MobiComKitPeopleActivity.class);
                ChannelDatabaseService channelDatabaseService = ChannelDatabaseService.getInstance(this);
                String[] userIdArray = channelDatabaseService.getChannelMemberByName(contactsGroupId, null);
                if (userIdArray != null) {
                    conversationUIService.startContactActivityForResult(intent, null, null, userIdArray);
                }
            }
        } else {
            conversationUIService.startContactActivityForResult();
        }
    } else if (id == R.id.conversations) {
        Intent intent = new Intent(this, ChannelCreateActivity.class);
        intent.putExtra(ChannelCreateActivity.GROUP_TYPE, Channel.GroupType.PUBLIC.getValue().intValue());
        startActivity(intent);
    } else if (id == R.id.broadcast) {
        Intent intent = new Intent(this, ContactSelectionActivity.class);
        intent.putExtra(ContactSelectionActivity.GROUP_TYPE, Channel.GroupType.BROADCAST.getValue().intValue());
        startActivity(intent);
    } else if (id == R.id.refresh) {
        Toast.makeText(this, getString(R.string.info_message_sync), Toast.LENGTH_LONG).show();
        new SyncMessagesAsyncTask(this).execute();
    } else if (id == R.id.shareOptions) {
        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setAction(Intent.ACTION_SEND).setType("text/plain").putExtra(Intent.EXTRA_TEXT, inviteMessage);
        startActivity(Intent.createChooser(intent, "Share Via"));
        return super.onOptionsItemSelected(item);
    } else if (id == R.id.applozicUserProfile) {
        profilefragment.setApplozicPermissions(applozicPermission);
        addFragment(this, profilefragment, ProfileFragment.ProfileFragmentTag);
    } else if (id == R.id.logout) {
        try {
            if (!TextUtils.isEmpty(alCustomizationSettings.getLogoutPackage())) {
                Class loginActivity = Class.forName(alCustomizationSettings.getLogoutPackage().trim());
                if (loginActivity != null) {
                    new UserClientService(this).logout();
                    Toast.makeText(getBaseContext(), getString(R.string.user_logout_info), Toast.LENGTH_SHORT).show();
                    Intent intent = new Intent(this, loginActivity);
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(intent);
                    finish();
                }
            }
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
    return false;
}
Also used : Intent(android.content.Intent) ChannelDatabaseService(com.applozic.mobicomkit.channel.database.ChannelDatabaseService) SuppressLint(android.annotation.SuppressLint) UserClientService(com.applozic.mobicomkit.api.account.user.UserClientService) RegisterUserClientService(com.applozic.mobicomkit.api.account.register.RegisterUserClientService)

Example 4 with UserClientService

use of com.applozic.mobicomkit.api.account.user.UserClientService in project Applozic-Android-SDK by AppLozic.

the class MobiComDatabaseHelper method onUpgrade.

@Override
public void onUpgrade(SQLiteDatabase database, int oldVersion, int newVersion) {
    // schedule sms table is not present.
    if (newVersion > oldVersion) {
        Utils.printLog(context, TAG, "Upgrading database from version " + oldVersion + " to " + newVersion + ", which will destroy all old data");
        if (!DBUtils.isTableExists(database, "sms")) {
            database.execSQL(CREATE_SMS_TABLE);
        }
        if (!DBUtils.isTableExists(database, SCHEDULE_SMS_TABLE_NAME)) {
            database.execSQL(CREATE_SCHEDULE_SMS_TABLE);
        }
        if (!DBUtils.isTableExists(database, CHANNEL)) {
            database.execSQL(CREATE_CHANNEL_TABLE);
        }
        if (!DBUtils.isTableExists(database, CHANNEL_USER_X)) {
            database.execSQL(CREATE_CHANNEL_USER_X_TABLE);
        }
        if (!DBUtils.isTableExists(database, CONVERSATION)) {
            database.execSQL(CREATE_CONVERSATION_TABLE);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", "deleted")) {
            database.execSQL(ALTER_SMS_TABLE_FOR_DELETE_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", "applicationId")) {
            database.execSQL(ALTER_SMS_TABLE_FOR__APPLICATION_ID_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", "applicationId")) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_APPLICATION_ID_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", UNREAD_COUNT)) {
            database.execSQL(ALTER_CONTACT_TABLE_UNREAD_COUNT_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", "connected")) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_CONNECTED_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", "lastSeenAt")) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_LAST_SEEN_AT_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", BLOCKED)) {
            database.execSQL(ALTER_CONTACT_TABLE_BLOCKED_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", BLOCKED_BY)) {
            database.execSQL(ALTER_CONTACT_TABLE_BLOCKED_BY_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", MESSAGE_CONTENT_TYPE)) {
            database.execSQL(ALTER_SMS_TABLE_FOR_CONTENT_TYPE_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", MESSAGE_METADATA)) {
            database.execSQL(ALTER_SMS_TABLE_FOR_METADATA_TYPE_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", CONVERSATION_ID)) {
            database.execSQL(ALTER_MESSAGE_TABLE_FOR_CONVERSATION_ID_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", TOPIC_ID)) {
            database.execSQL(ALTER_MESSAGE_TABLE_FOR_TOPIC_ID_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "channel", CHANNEL_IMAGE_URL)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_IMAGE_URL_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "channel", CHANNEL_IMAGE_LOCAL_URI)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_IMAGE_LOCAL_URI_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "channel", CLIENT_GROUP_ID)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_CLIENT_GROUP_ID);
        }
        if (!DBUtils.existsColumnInTable(database, CHANNEL, UNREAD_COUNT)) {
            database.execSQL(ALTER_CHANNEL_TABLE_UNREAD_COUNT_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", STATUS)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_STATUS);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", CONTACT_TYPE)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_CONTENT_TYPE_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, CONVERSATION, TOPIC_LOCAL_IMAGE_URL)) {
            database.execSQL(ALTER_CONVERSATION_TABLE_FOR_TOPIC_LOCAL_IMAGE_URL);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", USER_TYPE_ID)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_USER_TYPE_ID_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "channel", NOTIFICATION_AFTER_TIME)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_NOTIFICATION_AFTER_TIME_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "channel", DELETED_AT)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_DELETED_AT_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, "contact", DELETED_AT)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_DELETED_AT);
        }
        if (!DBUtils.existsColumnInTable(database, CHANNEL, CHANNEL_META_DATA)) {
            database.execSQL(ALTER_CHANNEL_TABLE_FOR_CHANNEL_META_DATA);
        }
        if (!DBUtils.existsColumnInTable(database, SMS, HIDDEN)) {
            database.execSQL(ALTER_SMS_TABLE_FOR_HIDDEN);
        }
        if (!DBUtils.existsColumnInTable(database, SMS, REPLY_MESSAGE)) {
            database.execSQL(ALTER_SMS_TABLE_FOR_REPLY_MESSAGE_COLUMN);
        }
        if (!DBUtils.existsColumnInTable(database, CONTACT_TABLE_NAME, NOTIFICATION_AFTER_TIME)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_NOTIFICATION_AFTER_TIME);
        }
        if (!DBUtils.existsColumnInTable(database, CONTACT_TABLE_NAME, USER_METADATA)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_METADATA);
        }
        if (!DBUtils.existsColumnInTable(database, CONTACT_TABLE_NAME, USER_ROLE_TYPE)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_ROLE_TYPE);
        }
        if (!DBUtils.existsColumnInTable(database, CONTACT_TABLE_NAME, LAST_MESSAGED_AT)) {
            database.execSQL(ALTER_CONTACT_TABLE_FOR_LAST_MESSAGED_AT);
        }
        if (!DBUtils.existsColumnInTable(database, "sms", URL)) {
            database.execSQL(ALTER_SMS_TABLE_FOR_FILE_URL);
        }
        if (!DBUtils.existsColumnInTable(database, "CHANNEL_USER_X", ROLE)) {
            database.execSQL(ALTER_CHANNEL_USER_MAPPER_TABLE_FOR_ROLE);
        }
        database.execSQL(CREATE_INDEX_ON_CREATED_AT);
        database.execSQL(CREATE_INDEX_SMS_TYPE);
        database.execSQL(ALTER_SMS_TABLE);
        database.execSQL(CREATE_SMS_TABLE);
        database.execSQL(INSERT_INTO_SMS_FROM_SMS_BACKUP_QUERY);
        database.execSQL(DROP_SMS_BACKUP);
        new Thread(new Runnable() {

            @Override
            public void run() {
                try {
                    new UserClientService(context).updateCodeVersion(MobiComUserPreference.getInstance(context).getDeviceKeyString());
                } catch (Exception e) {
                }
            }
        }).start();
    } else {
        onCreate(database);
    }
}
Also used : UserClientService(com.applozic.mobicomkit.api.account.user.UserClientService)

Example 5 with UserClientService

use of com.applozic.mobicomkit.api.account.user.UserClientService in project Applozic-Android-SDK by AppLozic.

the class ProfileFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.al_activity_profile, container, false);
    img_profile = (ImageView) view.findViewById(R.id.applozic_user_profile);
    statusEdit = (ImageView) view.findViewById(R.id.status_edit_btn);
    displayNameEdit = (ImageView) view.findViewById(R.id.displayName_edit_btn);
    contactEdit = (ImageView) view.findViewById(R.id.contact_edit_btn);
    selectImageProfileIcon = (ImageView) view.findViewById(R.id.applozic_user_profile_camera);
    logoutbtn = (Button) view.findViewById(R.id.applozic_profile_logout);
    displayNameText = (TextView) view.findViewById(R.id.applozic_profile_displayname);
    statusText = (TextView) view.findViewById(R.id.applozic_profile_status);
    contactNumberText = (TextView) view.findViewById(R.id.applozic_profile_contact);
    applozicProfileContactLayout = (RelativeLayout) view.findViewById(R.id.applozic_profile_contact_section_rl);
    setupDeviderView(view, R.id.applozic_profile_section_rl, R.id.applozic_profile_verticalline_rl);
    setupDeviderView(view, R.id.applozic_datausage_section_rl, R.id.applozic_datausage_verticalline_rl);
    setupDeviderView(view, R.id.applozic_notification_section_rl, R.id.applozic_notification_verticalline_rl);
    Toolbar toolbar = (Toolbar) getActivity().findViewById(R.id.my_toolbar);
    toolbar.setClickable(false);
    toolbar.setTitle(getString(R.string.applozic_user_profile_heading));
    toolbar.setSubtitle("");
    setHasOptionsMenu(true);
    contactService = new AppContactService(getActivity());
    userContact = contactService.getContactById(MobiComUserPreference.getInstance(getActivity()).getUserId());
    if (!TextUtils.isEmpty(userContact.getDisplayName())) {
        displayNameText.setText(userContact.getDisplayName());
    }
    if (!TextUtils.isEmpty(userContact.getStatus())) {
        statusText.setText(userContact.getStatus());
    }
    if (!TextUtils.isEmpty(userContact.getContactNumber())) {
        contactNumberText.setText(userContact.getContactNumber());
    } else {
        applozicProfileContactLayout.setVisibility(View.GONE);
    }
    final Context context = getActivity().getApplicationContext();
    mImageLoader = new ImageLoader(context, img_profile.getHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return contactService.downloadContactImage(context, (Contact) data);
        }
    };
    // For profile image
    selectImageProfileIcon.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            processPhotoOption();
        }
    });
    logoutbtn.setVisibility(View.GONE);
    logoutbtn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            try {
                final String logoutActivity = ApplozicSetting.getInstance(getActivity()).getActivityCallback(ApplozicSetting.RequestCode.USER_LOOUT);
                if (!TextUtils.isEmpty(logoutActivity)) {
                    new UserClientService(getActivity()).logout();
                    Intent intent = new Intent(getActivity(), Class.forName(logoutActivity));
                    intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                    startActivity(intent);
                    getActivity().finish();
                    return;
                }
            } catch (ClassNotFoundException e) {
                e.printStackTrace();
            }
        }
    });
    statusEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setTitle(R.string.status);
            final EditText input = new EditText(getContext());
            input.setInputType(InputType.TYPE_CLASS_TEXT);
            builder.setView(input);
            builder.setPositiveButton(R.string.ok_alert, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    changedStatusString = input.getText().toString();
                    Contact contact = new Contact();
                    contact.setStatus(changedStatusString);
                    new ProfilePictureUpload(contact, getActivity(), null, statusText, null).execute((Void[]) null);
                }
            });
            builder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    });
    displayNameEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setTitle(getString(R.string.display_name));
            final EditText input = new EditText(getContext());
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_CAP_SENTENCES);
            builder.setView(input);
            builder.setPositiveButton(getString(R.string.ok_alert), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    displayName = input.getText().toString();
                    if (!displayName.trim().isEmpty() && !TextUtils.isEmpty(displayName)) {
                        Contact contact = new Contact();
                        contact.setFullName(displayName);
                        new ProfilePictureUpload(contact, getActivity(), displayNameText, null, null).execute((Void[]) null);
                    }
                }
            });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    });
    contactEdit.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
            builder.setTitle(getString(R.string.profile_contact));
            final EditText input = new EditText(getContext());
            input.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_CLASS_PHONE);
            builder.setView(input);
            builder.setPositiveButton(getString(R.string.ok_alert), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    contactNumber = input.getText().toString();
                    if (!contactNumber.trim().isEmpty() && !TextUtils.isEmpty(contactNumber)) {
                        Contact contact = new Contact();
                        contact.setContactNumber(contactNumber);
                        new ProfilePictureUpload(contact, getActivity(), null, null, contactNumberText).execute((Void[]) null);
                    }
                }
            });
            builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            });
            builder.show();
        }
    });
    mImageLoader.setImageFadeIn(false);
    mImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_180_holo_light);
    mImageLoader.loadImage(userContact, img_profile);
    return view;
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) EditText(android.widget.EditText) AppContactService(com.applozic.mobicomkit.contact.AppContactService) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) UserClientService(com.applozic.mobicomkit.api.account.user.UserClientService) Contact(com.applozic.mobicommons.people.contact.Contact) Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Toolbar(android.support.v7.widget.Toolbar)

Aggregations

UserClientService (com.applozic.mobicomkit.api.account.user.UserClientService)5 Contact (com.applozic.mobicommons.people.contact.Contact)3 Intent (android.content.Intent)2 SuppressLint (android.annotation.SuppressLint)1 Context (android.content.Context)1 DialogInterface (android.content.DialogInterface)1 Bitmap (android.graphics.Bitmap)1 Uri (android.net.Uri)1 AlertDialog (android.support.v7.app.AlertDialog)1 Toolbar (android.support.v7.widget.Toolbar)1 View (android.view.View)1 EditText (android.widget.EditText)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 RegisterUserClientService (com.applozic.mobicomkit.api.account.register.RegisterUserClientService)1 FileMeta (com.applozic.mobicomkit.api.attachment.FileMeta)1 Message (com.applozic.mobicomkit.api.conversation.Message)1 ChannelDatabaseService (com.applozic.mobicomkit.channel.database.ChannelDatabaseService)1 AppContactService (com.applozic.mobicomkit.contact.AppContactService)1 Support (com.applozic.mobicommons.commons.core.utils.Support)1