Ejemplo n.º 1
1
  private void sendImageMessage(String url, Bitmap bitmap) {
    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();

    if (chatRoom != null && url != null && url.length() > 0 && isNetworkReachable) {
      LinphoneChatMessage chatMessage = chatRoom.createLinphoneChatMessage("");
      chatMessage.setExternalBodyUrl(url);
      chatRoom.sendMessage(chatMessage, this);

      int newId = -1;
      if (LinphoneActivity.isInstanciated()) {
        newId = LinphoneActivity.instance().onMessageSent(sipUri, bitmap, url);
      }
      newId = chatMessage.getStorageId();
      latestImageMessages.put(newId, url);

      if (useLinphoneMessageStorage) url = saveImage(bitmap, newId, chatMessage);

      adapter.refreshHistory();
      adapter.notifyDataSetChanged();

      scrollToEnd();
    } else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance()
          .displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
    }
  }
Ejemplo n.º 2
0
  @SmallTest
  @MediumTest
  @LargeTest
  public void testEReceiveTextMessage() {
    goToChat();
    solo.clickOnText(iContext.getString(org.linphone.test.R.string.account_test_calls_login));

    LinphoneChatRoom chatRoom =
        LinphoneTestManager.getLc()
            .getOrCreateChatRoom(
                "sip:"
                    + iContext.getString(R.string.account_linphone_login)
                    + "@"
                    + iContext.getString(R.string.account_linphone_domain));
    LinphoneChatMessage msg =
        chatRoom.createLinphoneChatMessage(iContext.getString(R.string.chat_test_text_received));
    chatRoom.sendMessage(
        msg,
        new LinphoneChatMessage.StateListener() {
          @Override
          public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
            Log.e("Chat message state = " + state.toString());
          }
        });

    solo.sleep(1000);
    Assert.assertTrue(solo.searchText(iContext.getString(R.string.chat_test_text_received)));
  }
Ejemplo n.º 3
0
  private void sendTextMessage(String messageToSend) {
    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();

    if (chatRoom != null
        && messageToSend != null
        && messageToSend.length() > 0
        && isNetworkReachable) {
      LinphoneChatMessage chatMessage = chatRoom.createLinphoneChatMessage(messageToSend);
      chatRoom.sendMessage(chatMessage, this);

      if (LinphoneActivity.isInstanciated()) {
        LinphoneActivity.instance().onMessageSent(sipUri, messageToSend);
      }

      adapter.refreshHistory();
      adapter.notifyDataSetChanged();

      Log.i("Sent message current status: " + chatMessage.getStatus());
      scrollToEnd();
    } else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance()
          .displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
    }
  }