Search in sources :

Example 1 with MobiComConversationService

use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.

the class MainActivity method onNavigationDrawerItemSelected.

@Override
public void onNavigationDrawerItemSelected(int position) {
    if (position == 1) {
        Intent intent = new Intent(this, ConversationActivity.class);
        if (ApplozicClient.getInstance(this).isContextBasedChat()) {
            intent.putExtra(ConversationUIService.CONTEXT_BASED_CHAT, true);
        }
        startActivity(intent);
        return;
    }
    /*
        if (position == 1) {
            ConversationFragment conversationFragment = new ConversationFragment();
            Contact contact = new Contact(this, "mobicomkit");
            mTitle = getString(R.string.user_id);
            addFragment(this, conversationFragment, "conversationFragment");
            conversationFragment.loadConversation(contact);
            return;

        }*/
    if (position == 0) {
        mTitle = getString(R.string.ecommerce);
        FragmentManager fragmentManager = getSupportFragmentManager();
        fragmentManager.beginTransaction().replace(R.id.container, EcommerceFragment.newInstance("", "")).commit();
        return;
    }
    if (position == 2) {
        UserLogoutTask.TaskListener userLogoutTaskListener = new UserLogoutTask.TaskListener() {

            @Override
            public void onSuccess(Context context) {
                userLogoutTask = null;
                Toast.makeText(getBaseContext(), getBaseContext().getString(R.string.log_out_successful), Toast.LENGTH_SHORT).show();
                Intent intent = new Intent(context, LoginActivity.class);
                intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_SINGLE_TOP);
                startActivity(intent);
                finish();
            }

            @Override
            public void onFailure(Exception exception) {
                userLogoutTask = null;
                AlertDialog alertDialog = new AlertDialog.Builder(MainActivity.this).create();
                alertDialog.setTitle(getString(R.string.text_alert));
                alertDialog.setMessage(exception.toString());
                alertDialog.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.ok_alert), new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int which) {
                        dialog.dismiss();
                    }
                });
                if (!isFinishing()) {
                    alertDialog.show();
                }
            }
        };
        userLogoutTask = new UserLogoutTask(userLogoutTaskListener, this);
        userLogoutTask.execute((Void) null);
    }
    if (position == 3) {
        Map<String, String> messageMetaData = new HashMap<>();
        messageMetaData.put(Message.MetaDataType.KEY.getValue(), Message.MetaDataType.HIDDEN.getValue());
        Message message = new Message();
        MobiComUserPreference userPreferences = MobiComUserPreference.getInstance(MainActivity.this);
        message.setContactIds("android");
        message.setTo("android");
        message.setContentType(Message.ContentType.CUSTOM.getValue());
        message.setMessage("this is meta data hidden");
        message.setMetadata(messageMetaData);
        message.setStoreOnDevice(Boolean.TRUE);
        message.setRead(Boolean.TRUE);
        message.setCreatedAtTime(System.currentTimeMillis() + userPreferences.getDeviceTimeOffset());
        message.setSendToDevice(Boolean.FALSE);
        message.setType(Message.MessageType.MT_OUTBOX.getValue());
        message.setDeviceKeyString(userPreferences.getDeviceKeyString());
        message.setSource(Message.Source.MT_MOBILE_APP.getValue());
        new MobiComConversationService(MainActivity.this).sendMessage(message, MessageIntentService.class);
    }
    FragmentManager fragmentManager = getSupportFragmentManager();
    fragmentManager.beginTransaction().replace(R.id.container, PlaceholderFragment.newInstance(position + 1)).commit();
}
Also used : Context(android.content.Context) AlertDialog(android.support.v7.app.AlertDialog) Message(com.applozic.mobicomkit.api.conversation.Message) DialogInterface(android.content.DialogInterface) HashMap(java.util.HashMap) MobiComUserPreference(com.applozic.mobicomkit.api.account.user.MobiComUserPreference) Intent(android.content.Intent) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService) FragmentManager(android.support.v4.app.FragmentManager) UserLogoutTask(com.applozic.mobicomkit.api.account.user.UserLogoutTask)

Example 2 with MobiComConversationService

use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.

the class ChannelService method processChannelDeleteConversation.

public synchronized String processChannelDeleteConversation(Channel channel, Context context) {
    String response = new MobiComConversationService(context).deleteSync(null, channel, null);
    if (!TextUtils.isEmpty(response) && "success".equals(response)) {
        channelDatabaseService.deleteChannelUserMappers(channel.getKey());
        channelDatabaseService.deleteChannel(channel.getKey());
    }
    return response;
}
Also used : MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService)

Example 3 with MobiComConversationService

use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method init.

public void init() {
    this.conversationService = new MobiComConversationService(context);
    this.baseContactService = new AppContactService(context);
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService)

Example 4 with MobiComConversationService

use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.

the class UserIntentService method onCreate.

@Override
public void onCreate() {
    super.onCreate();
    messageClientService = new MessageClientService(getApplicationContext());
    mobiComConversationService = new MobiComConversationService(getApplicationContext());
}
Also used : MessageClientService(com.applozic.mobicomkit.api.conversation.MessageClientService) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService)

Example 5 with MobiComConversationService

use of com.applozic.mobicomkit.api.conversation.MobiComConversationService in project Applozic-Android-SDK by AppLozic.

the class ScheduleMessageService method onHandleIntent.

@Override
protected void onHandleIntent(Intent intent) {
    Calendar c = Calendar.getInstance();
    long time = c.getTimeInMillis();
    MessageDatabaseService messageDatabaseService = new MessageDatabaseService(getApplicationContext());
    MobiComConversationService conversationService = new MobiComConversationService(getApplicationContext());
    List<Message> messages = messageDatabaseService.getScheduledMessages(time);
    for (Message message : messages) {
        message.setScheduledAt(null);
        conversationService.sendMessage(message, MessageIntentService.class);
    // Todo: broadcast for scheduled message fragment.
    }
    messageDatabaseService.deleteScheduledMessages(time);
}
Also used : Message(com.applozic.mobicomkit.api.conversation.Message) Calendar(java.util.Calendar) MobiComConversationService(com.applozic.mobicomkit.api.conversation.MobiComConversationService) MessageDatabaseService(com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)

Aggregations

MobiComConversationService (com.applozic.mobicomkit.api.conversation.MobiComConversationService)10 Message (com.applozic.mobicomkit.api.conversation.Message)4 DialogInterface (android.content.DialogInterface)3 AlertDialog (android.app.AlertDialog)2 MobiComUserPreference (com.applozic.mobicomkit.api.account.user.MobiComUserPreference)2 MessageClientService (com.applozic.mobicomkit.api.conversation.MessageClientService)2 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)2 Contact (com.applozic.mobicommons.people.contact.Contact)2 Context (android.content.Context)1 Intent (android.content.Intent)1 FragmentManager (android.support.v4.app.FragmentManager)1 AlertDialog (android.support.v7.app.AlertDialog)1 View (android.view.View)1 UserLogoutTask (com.applozic.mobicomkit.api.account.user.UserLogoutTask)1 SyncCallService (com.applozic.mobicomkit.api.conversation.SyncCallService)1 AppContactService (com.applozic.mobicomkit.contact.AppContactService)1 GcmMessageResponse (com.applozic.mobicomkit.feed.GcmMessageResponse)1 InstantMessageResponse (com.applozic.mobicomkit.feed.InstantMessageResponse)1 MqttMessageResponse (com.applozic.mobicomkit.feed.MqttMessageResponse)1 DeleteConversationAsyncTask (com.applozic.mobicomkit.uiwidgets.conversation.DeleteConversationAsyncTask)1