Search in sources :

Example 21 with AppContactService

use of com.applozic.mobicomkit.contact.AppContactService in project Applozic-Android-SDK by AppLozic.

the class ApplozicClient method disableChatForUser.

public ApplozicClient disableChatForUser(final boolean disable, final AlCallback callback) {
    Map<String, String> userMetadata;
    Contact contact = new AppContactService(context).getContactById(MobiComUserPreference.getInstance(context).getUserId());
    if (contact != null && contact.getMetadata() != null) {
        userMetadata = contact.getMetadata();
        userMetadata.putAll(contact.getMetadata());
    } else {
        userMetadata = new HashMap<>();
    }
    userMetadata.put(Contact.DISABLE_CHAT_WITH_USER, String.valueOf(disable));
    User user = new User();
    user.setMetadata(userMetadata);
    UserService.getInstance(context).updateUser(user, new AlCallback() {

        @Override
        public void onSuccess(Object response) {
            sharedPreferences.edit().putBoolean(Contact.DISABLE_CHAT_WITH_USER, disable).commit();
            if (callback != null) {
                callback.onSuccess(response);
            }
        }

        @Override
        public void onError(Object error) {
            if (callback != null) {
                callback.onError(error);
            }
        }
    });
    return this;
}
Also used : User(com.applozic.mobicomkit.api.account.user.User) AppContactService(com.applozic.mobicomkit.contact.AppContactService) JSONObject(org.json.JSONObject) AlCallback(com.applozic.mobicomkit.listners.AlCallback) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 22 with AppContactService

use of com.applozic.mobicomkit.contact.AppContactService in project Applozic-Android-SDK by AppLozic.

the class ChannelInfoActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.channel_info_layout);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);
    String jsonString = FileUtils.loadSettingsJsonFile(getApplicationContext());
    if (!TextUtils.isEmpty(jsonString)) {
        alCustomizationSettings = (AlCustomizationSettings) GsonUtils.getObjectFromJson(jsonString, AlCustomizationSettings.class);
    } else {
        alCustomizationSettings = new AlCustomizationSettings();
    }
    refreshBroadcast = new RefreshBroadcast();
    baseContactService = new AppContactService(getApplicationContext());
    channelImage = (ImageView) findViewById(R.id.channelImage);
    userPreference = MobiComUserPreference.getInstance(this);
    createdBy = (TextView) findViewById(R.id.created_by);
    groupParticipantsTexView = (TextView) findViewById(R.id.groupParticipantsTexView);
    exitChannelButton = (Button) findViewById(R.id.exit_channel);
    deleteChannelButton = (Button) findViewById(R.id.delete_channel_button);
    channelDeleteRelativeLayout = (RelativeLayout) findViewById(R.id.channel_delete_relativeLayout);
    channelExitRelativeLayout = (RelativeLayout) findViewById(R.id.channel_exit_relativeLayout);
    collapsingToolbarLayout = (CollapsingToolbarLayout) findViewById(R.id.toolbar_layout);
    nestedScrollView = findViewById(R.id.nestedScrollView);
    textViewGroupDescription = findViewById(R.id.groupDescriptionTexView);
    cardViewGroupDescriptionContainer = findViewById(R.id.groupDescriptionCardView);
    collapsingToolbarLayout.setContentScrimColor(Color.parseColor(alCustomizationSettings.getCollapsingToolbarLayoutColor()));
    groupParticipantsTexView.setTextColor(Color.parseColor(alCustomizationSettings.getGroupParticipantsTextColor()));
    deleteChannelButton.setBackgroundColor(Color.parseColor((alCustomizationSettings.getGroupDeleteButtonBackgroundColor())));
    exitChannelButton.setBackgroundColor(Color.parseColor(alCustomizationSettings.getGroupExitButtonBackgroundColor()));
    mActionBar = getSupportActionBar();
    mActionBar.setDisplayHomeAsUpEnabled(true);
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayShowHomeEnabled(true);
    mainListView = (ListView) findViewById(R.id.mainList);
    mainListView.setLongClickable(true);
    mainListView.setSmoothScrollbarEnabled(true);
    if (Utils.hasLollipop()) {
        mainListView.setNestedScrollingEnabled(true);
    }
    nestedScrollView.post(new Runnable() {

        @Override
        public void run() {
            nestedScrollView.scrollTo(nestedScrollView.getLeft(), groupParticipantsTexView.getTop());
        }
    });
    connectivityReceiver = new ConnectivityReceiver();
    mobiComKitBroadcastReceiver = new MobiComKitBroadcastReceiver(this);
    registerForContextMenu(mainListView);
    if (alCustomizationSettings.isHideGroupExitButton()) {
        channelExitRelativeLayout.setVisibility(View.GONE);
    }
    if (alCustomizationSettings.isHideGroupDeleteButton()) {
        channelDeleteRelativeLayout.setVisibility(View.GONE);
    }
    if (getIntent().getExtras() != null) {
        channelKey = getIntent().getIntExtra(CHANNEL_KEY, 0);
        channelUpdateReceiver = getIntent().getParcelableExtra(CHANNEL_UPDATE_RECEIVER);
        channel = ChannelService.getInstance(this).getChannelByChannelKey(channelKey);
        isUserPresent = ChannelService.getInstance(this).processIsUserPresentInChannel(channelKey);
        if (channel != null) {
            String title = ChannelUtils.getChannelTitleName(channel, userPreference.getUserId());
            if (!TextUtils.isEmpty(channel.getAdminKey())) {
                contact = baseContactService.getContactById(channel.getAdminKey());
                mActionBar.setTitle(title);
                if (userPreference.getUserId().equals(contact.getUserId())) {
                    createdBy.setText(getString(R.string.channel_created_by) + " " + getString(R.string.you_string));
                } else {
                    createdBy.setText(getString(R.string.channel_created_by) + " " + contact.getDisplayName());
                }
            }
            updateChannelDescriptionUIFrom(channel.getMetadata());
            if (!isUserPresent) {
                channelExitRelativeLayout.setVisibility(View.GONE);
                channelDeleteRelativeLayout.setVisibility(View.VISIBLE);
            }
        }
    }
    if (channel != null && channel.getType() != null) {
        if (Channel.GroupType.BROADCAST.getValue().equals(channel.getType())) {
            deleteChannelButton.setText(R.string.broadcast_delete_button);
            exitChannelButton.setText(R.string.broadcast_exit_button);
            channelExitRelativeLayout.setVisibility(View.GONE);
            channelDeleteRelativeLayout.setVisibility(View.VISIBLE);
        } else {
            deleteChannelButton.setText(R.string.channel_delete_group_button);
            exitChannelButton.setText(R.string.channel_exit_button);
        }
    }
    contactImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return baseContactService.downloadContactImage(getApplicationContext(), (Contact) data);
        }
    };
    contactImageLoader.setLoadingImage(R.drawable.applozic_ic_contact_picture_holo_light);
    contactImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
    contactImageLoader.setImageFadeIn(false);
    channelImageLoader = new ImageLoader(getApplicationContext(), getListPreferredItemHeight()) {

        @Override
        protected Bitmap processBitmap(Object data) {
            return baseContactService.downloadGroupImage(getApplicationContext(), (Channel) data);
        }
    };
    channelImageLoader.setLoadingImage(R.drawable.applozic_group_icon);
    channelImageLoader.addImageCache(this.getSupportFragmentManager(), 0.1f);
    channelImageLoader.setImageFadeIn(false);
    if (channelImage != null && !channel.isBroadcastMessage()) {
        channelImageLoader.loadImage(channel, channelImage);
    } else {
        channelImage.setImageResource(R.drawable.applozic_ic_applozic_broadcast);
    }
    channelUserMapperList = ChannelService.getInstance(this).getListOfUsersFromChannelUserMapper(channel.getKey());
    contactsAdapter = new ContactsAdapter(this);
    mainListView.setAdapter(contactsAdapter);
    Helper.getListViewSize(mainListView);
    mainListView.setOnScrollListener(new AbsListView.OnScrollListener() {

        @Override
        public void onScrollStateChanged(AbsListView absListView, int scrollState) {
            // Pause image loader to ensure smoother scrolling when flinging
            if (scrollState == AbsListView.OnScrollListener.SCROLL_STATE_FLING) {
                contactImageLoader.setPauseWork(true);
            } else {
                contactImageLoader.setPauseWork(false);
            }
        }

        @Override
        public void onScroll(AbsListView absListView, int i, int i1, int i2) {
        }
    });
    exitChannelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            leaveChannel(channel);
        }
    });
    deleteChannelButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            deleteChannel(channel);
        }
    });
    cardViewGroupDescriptionContainer.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (isUserPresent && alCustomizationSettings.isEditChannelDescriptionAllowed() && channel != null) {
                Intent editChannelNameIntent = new Intent(ChannelInfoActivity.this, EditChannelDescriptionActivity.class);
                GroupInfoUpdate groupInfoUpdate = new GroupInfoUpdate(channel.getMetadata(), channel.getKey());
                String groupJson = GsonUtils.getJsonFromObject(groupInfoUpdate, GroupInfoUpdate.class);
                editChannelNameIntent.putExtra(GROUP_UPDTAE_INFO, groupJson);
                startActivityForResult(editChannelNameIntent, REQUEST_CODE_FOR_CHANNEL_NEW_DESCRIPTION);
            } else {
                Toast.makeText(ChannelInfoActivity.this, alCustomizationSettings.isEditChannelDescriptionAllowed() ? getString(R.string.channel_edit_description_alert) : getString(R.string.editing_channel_description_is_not_allowed), Toast.LENGTH_SHORT).show();
            }
        }
    });
    registerReceiver(connectivityReceiver, new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION));
}
Also used : GroupInfoUpdate(com.applozic.mobicomkit.feed.GroupInfoUpdate) IntentFilter(android.content.IntentFilter) AlCustomizationSettings(com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings) AppContactService(com.applozic.mobicomkit.contact.AppContactService) ConnectivityReceiver(com.applozic.mobicomkit.broadcast.ConnectivityReceiver) Channel(com.applozic.mobicommons.people.channel.Channel) AbsListView(android.widget.AbsListView) MobiComKitBroadcastReceiver(com.applozic.mobicomkit.uiwidgets.conversation.MobiComKitBroadcastReceiver) Intent(android.content.Intent) NestedScrollView(androidx.core.widget.NestedScrollView) ImageView(android.widget.ImageView) CircleImageView(de.hdodenhof.circleimageview.CircleImageView) View(android.view.View) AdapterView(android.widget.AdapterView) CardView(androidx.cardview.widget.CardView) TextView(android.widget.TextView) ListView(android.widget.ListView) AbsListView(android.widget.AbsListView) Contact(com.applozic.mobicommons.people.contact.Contact) Bitmap(android.graphics.Bitmap) ImageLoader(com.applozic.mobicommons.commons.image.ImageLoader) Toolbar(androidx.appcompat.widget.Toolbar)

Example 23 with AppContactService

use of com.applozic.mobicomkit.contact.AppContactService in project Applozic-Android-SDK by AppLozic.

the class BroadcastService method sendNotificationBroadcast.

public static void sendNotificationBroadcast(Context context, Message message, int index) {
    if (message != null) {
        if (ALSpecificSettings.getInstance(context).isAllNotificationMuted() || message.getMetadata() != null && message.getMetadata().containsKey("NO_ALERT") && "true".equals(message.getMetadata().get("NO_ALERT"))) {
            return;
        }
        int notificationId = Utils.getLauncherIcon(context.getApplicationContext());
        final NotificationService notificationService = new NotificationService(notificationId, context, 0, 0, 0);
        if (MobiComUserPreference.getInstance(context).isLoggedIn()) {
            Channel channel = ChannelService.getInstance(context).getChannelInfo(message.getGroupId());
            Contact contact = null;
            if (message.getConversationId() != null) {
                ConversationService.getInstance(context).getConversation(message.getConversationId());
            }
            if (message.getGroupId() == null) {
                contact = new AppContactService(context).getContactById(message.getContactIds());
            }
            if (ApplozicClient.getInstance(context).isNotificationStacking()) {
                notificationService.notifyUser(contact, channel, message, index);
            } else {
                notificationService.notifyUserForNormalMessage(contact, channel, message, index);
            }
        }
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) Channel(com.applozic.mobicommons.people.channel.Channel) NotificationService(com.applozic.mobicomkit.api.notification.NotificationService) Contact(com.applozic.mobicommons.people.contact.Contact)

Example 24 with AppContactService

use of com.applozic.mobicomkit.contact.AppContactService in project Applozic-Android-SDK by AppLozic.

the class VideoCallNotificationHelper method handleIncomingVideoNotification.

private void handleIncomingVideoNotification(Message msg) {
    String isAudioCallOnly = msg.getMetadata().get(CALL_AUDIO_ONLY);
    boolean staleNotification = System.currentTimeMillis() - msg.getCreatedAtTime() > MAX_NOTIFICATION_RING_DURATION;
    if (staleNotification || msg.isTypeOutbox()) {
        // Contact contact = baseContactService.getContactById(msg.getContactIds());
        // sendCallMissed(contact, msg.getMessage());
        Log.i(TAG, "notification not valid ignoring..");
        return;
    }
    if (BroadcastService.callRinging) {
        Contact contactDetail = baseContactService.getContactById(msg.getTo());
        VideoCallNotificationHelper helper = new VideoCallNotificationHelper(context, isAudioOnly);
        helper.sendVideoCallReject(contactDetail, videoCallId);
        return;
    }
    if (BroadcastService.videoCallAcitivityOpend) {
        Intent intent = new Intent(MobiComKitConstants.APPLOZIC_VIDEO_DIALED);
        intent.putExtra("CONTACT_ID", msg.getTo());
        intent.putExtra(CALL_ID, videoCallId);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
        return;
    }
    if (isAppInBackground()) {
        int notificationId = Utils.getLauncherIcon(context.getApplicationContext());
        final NotificationService notificationService = new NotificationService(notificationId, context, 0, 0, 0);
        Contact contact = new AppContactService(context).getContactById(msg.getTo());
        notificationService.startCallNotification(contact, msg, isAudioCallOnly, videoCallId);
    } else {
        openCallActivity(msg, isAudioCallOnly);
    }
}
Also used : AppContactService(com.applozic.mobicomkit.contact.AppContactService) Intent(android.content.Intent) Contact(com.applozic.mobicommons.people.contact.Contact)

Aggregations

AppContactService (com.applozic.mobicomkit.contact.AppContactService)24 Contact (com.applozic.mobicommons.people.contact.Contact)17 Context (android.content.Context)7 Bitmap (android.graphics.Bitmap)7 ImageLoader (com.applozic.mobicommons.commons.image.ImageLoader)7 AlCustomizationSettings (com.applozic.mobicomkit.uiwidgets.AlCustomizationSettings)5 SpannableString (android.text.SpannableString)4 MessageDatabaseService (com.applozic.mobicomkit.api.conversation.database.MessageDatabaseService)4 Channel (com.applozic.mobicommons.people.channel.Channel)4 ArrayList (java.util.ArrayList)4 Intent (android.content.Intent)3 TextView (android.widget.TextView)3 NonNull (androidx.annotation.NonNull)3 Toolbar (androidx.appcompat.widget.Toolbar)3 Message (com.applozic.mobicomkit.api.conversation.Message)3 ChannelDatabaseService (com.applozic.mobicomkit.channel.database.ChannelDatabaseService)3 ProgressDialog (android.app.ProgressDialog)2 IntentFilter (android.content.IntentFilter)2 View (android.view.View)2 ImageView (android.widget.ImageView)2