QuickBlox / q-municate-android

Qmunicate Android chat application
MIT License
252 stars 198 forks source link

how can i remove those step like send friendrequest of each other? #287

Closed tatveshwebmigrates closed 1 year ago

tatveshwebmigrates commented 6 years ago

how can i do like whats app, without being friend to each other, i am already upload addressbook and retrive alluser but how m'i remove add friend and accept friend step, which function to solve this?

tatveshwebmigrates commented 6 years ago

hello anyone there???

RomanPronin commented 6 years ago

Just have a look at related to https://github.com/QuickBlox/q-municate-android/issues/267

tatveshwebmigrates commented 6 years ago

i just read this question answer but which property to enable autojoin true like ios. i want to remove those step add and accept friend. i want to direct send message to the registered user. it is possible in quickblox android app or not???

RomanPronin commented 6 years ago

Firstly, you can set autojoin settings in QBChatService to automatically join loaded or created on server dialogs: In that way you don't need to join chat dialog manually in code. //Set it before login in chat QBChatService.ConfigurationBuilder builder = new QBChatService.ConfigurationBuilder(); builder.setAutojoinEnabled(true); QBChatService.setConfigurationBuilder(builder); Secondly, sure you can send message to the registered user without being friend. You can look at sample-chat.

tatveshwebmigrates commented 6 years ago

where can i get QBChatService file?

RomanPronin commented 6 years ago

You can find description of QBChatService class and other useful info in official docs.

sureapps commented 6 years ago

when i have open privatedialogActivity before i call this code

QBChatService.ConfigurationBuilder builder = new QBChatService.ConfigurationBuilder(); builder.setAutojoinEnabled(true); QBChatService.setConfigurationBuilder(builder);

after that i have open PrivateDialogActivity in this activity i have seen "You have accepted request"
image but i am not able to type any message or audio/video call.

when i was put the code on audio/video call on click put the code there Like

boolean isFriend = DataManager.getInstance().getFriendDataManager().getByUserId(opponentUser.getId()) != null; if (!isFriend && item.getItemId() != android.R.id.home) { ToastUtils.longToast(R.string.dialog_user_is_not_friend); return true; }


i have get opponentUser.getId() this id but i have not find in my user friend list. so how can i add friend bypass accepting friend request like whatsapp. please reply us as soon as possible.

Thanks.

sureapps commented 6 years ago

are you there ? Please reply me fast as soon as possible .

RomanPronin commented 6 years ago

If you want use Roster for monitoring user status, you should have a look at #267 branch to autoAcceptIncomingRequests() function. If you don't want use Roster at all, then to be able to type any message just replace in your project:


    @Override
    protected void checkMessageSendingPossibility() {
      //  boolean enable = dataManager.getFriendDataManager().existsByUserId(opponentUser.getId()) && isNetworkAvailable();
      boolean enable = isNetworkAvailable();
        checkMessageSendingPossibility(enable);
    }
sureapps commented 6 years ago

thanks for the replying. chat option is soved out but when i was click on audio or video call so call the method in ConversationCallFragment like

private void displayOpponentAvatar() { QMUser opponent = ((CallActivity) getActivity()).getOpponentAsUserFromDB(opponents.get(0).getId()); if (StartConversationReason.INCOME_CALL_FOR_ACCEPTION.equals(startConversationReason) && !isVideoCall){ avatarAndNameView.setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage(opponent.getAvatar(), avatarImageview, ImageLoaderUtils.UIL_USER_AVATAR_DISPLAY_OPTIONS); callingToTextView.setText(opponent.getFullName()); // calling_to_set_timer.setText(); } else if (StartConversationReason.OUTCOME_CALL_MADE.equals(startConversationReason)) { avatarAndNameView.setVisibility(View.VISIBLE); ImageLoader.getInstance().displayImage(opponent.getAvatar(), avatarImageview, ImageLoaderUtils.UIL_USER_AVATAR_DISPLAY_OPTIONS); callingToTextView.setText(getString(R.string.calling_to, opponent.getFullName())); // calling_to_set_timer.setText(); } }


so in this method CallActivity.java in calling this function

public QMUser getOpponentAsUserFromDB(int opponentId) { DataManager dataManager = DataManager.getInstance(); Friend friend = dataManager.getFriendDataManager().getByUserId(opponentId); return friend.getUser(); }

return null so my app was crash. so how can i enable this features like same as chat option.

RomanPronin commented 6 years ago

You can try for example the next, replace code:


QMUser opponent = ((CallActivity) getActivity()).getOpponentAsUserFromDB(opponents.get(0).getId());
//with
QMUser opponent = QMUserService.getInstance().getUserCache().get((long)opponents.get(0).getId());
sureapps commented 6 years ago

thanks for replying .

IncomingCallFragment.java in this function call so in this function in change any thing. private void setOpponentAvatarAndName(){ QMUser opponent = ((CallActivity) getActivity()).getOpponentAsUserFromDB(sessionDescription.getCallerID()); ImageLoader.getInstance().displayImage(opponent.getAvatar(), avatarImageView, ImageLoaderUtils.UIL_USER_AVATAR_DISPLAY_OPTIONS); callerName.setText(opponent.getFullName()); }

sureapps commented 6 years ago

and also we can implement QBFriendListHelper.java file so that is right or wrong?


private Collection createFriendList( Collection rosterEntryCollection) throws QBResponseException { Collection friendList = new ArrayList<>(); Collection userList = new ArrayList<>();

    for (QBRosterEntry rosterEntry : rosterEntryCollection) {
        if (!UserFriendUtils.isOutgoingFriend(rosterEntry) && !UserFriendUtils.isNoneFriend(rosterEntry)) {
            friendList.add(rosterEntry.getUserId());
        } else if (UserFriendUtils.isNoneFriend(rosterEntry)){
            //need remove friend from DB which deleted me when I was offline
            friendList.add(rosterEntry.getUserId());
          //  removeFriendLocal(rosterEntry.getUserId());
        }

        if (UserFriendUtils.isOutgoingFriend(rosterEntry)) {
            userList.add(rosterEntry.getUserId());
        }
    }

    loadAndSaveUsers(userList, UserRequest.RequestStatus.OUTGOING);

    return friendList;
}