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);
    }
  }
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.clearFastChatField) {
      fastNewChat.setText("");
    } else if (id == R.id.ok) {
      edit.setVisibility(View.VISIBLE);
      ok.setVisibility(View.GONE);
      isEditMode = false;
      hideAndDisplayMessageIfNoChat();
    } else if (id == R.id.edit) {
      edit.setVisibility(View.GONE);
      ok.setVisibility(View.VISIBLE);
      isEditMode = true;
      hideAndDisplayMessageIfNoChat();
    } else if (id == R.id.newDiscussion) {
      String sipUri = fastNewChat.getText().toString();
      if (sipUri.equals("")) {
        LinphoneActivity.instance().displayContacts(true);
      } else {
        if (!LinphoneUtils.isSipAddress(sipUri)) {
          if (LinphoneManager.getLc().getDefaultProxyConfig() == null) {
            return;
          }
          sipUri = sipUri + "@" + LinphoneManager.getLc().getDefaultProxyConfig().getDomain();
        }
        if (!LinphoneUtils.isStrictSipAddress(sipUri)) {
          sipUri = "sip:" + sipUri;
        }
        LinphoneActivity.instance().displayChat(sipUri);
      }
    }
  }
  @Override
  public synchronized void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
    final LinphoneChatMessage finalMessage = msg;
    final String finalImage = finalMessage.getExternalBodyUrl();
    final State finalState = state;
    if (LinphoneActivity.isInstanciated() && state != State.InProgress) {
      if (finalMessage != null && !finalMessage.equals("")) {
        LinphoneActivity.instance()
            .onMessageStateChanged(sipUri, finalMessage.getText(), finalState.toInt());
      } else if (finalImage != null && !finalImage.equals("")) {
        if (latestImageMessages != null && latestImageMessages.containsValue(finalImage)) {
          int id = -1;
          for (int key : latestImageMessages.keySet()) {
            String object = latestImageMessages.get(key);
            if (object.equals(finalImage)) {
              id = key;
              break;
            }
          }
          if (id != -1) {
            LinphoneActivity.instance().onImageMessageStateChanged(sipUri, id, finalState.toInt());
          }
        }
      }

      if (lastSentMessagesBubbles != null && lastSentMessagesBubbles.size() > 0) {
        for (BubbleChat bubble : lastSentMessagesBubbles) {
          if (bubble.getNativeMessageObject() == finalMessage) {
            bubble.updateStatusView(finalState);
          }
        }
      }
      adapter.notifyDataSetChanged();
    }
  }
Exemple #4
0
  @SuppressLint("UseSparseArrays")
  @Override
  public void onResume() {
    message.addTextChangedListener(textWatcher);
    addVirtualKeyboardVisiblityListener();

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      lc.addListener(mListener);
    }

    if (LinphoneActivity.isInstanciated()) {
      if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
        LinphoneActivity.instance().hideStatusBar();
      }
      LinphoneActivity.instance().updateChatFragment(this);
    }

    String draft = getArguments().getString("messageDraft");
    message.setText(draft);

    remoteComposing.setVisibility(chatRoom.isRemoteComposing() ? View.VISIBLE : View.GONE);
    dispayMessageList();

    super.onResume();
  }
  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);
    }
  }
Exemple #6
0
 private void copyTextMessageToClipboard(int id) {
   String msg = LinphoneActivity.instance().getChatStorage().getTextMessageForId(chatRoom, id);
   if (msg != null) {
     Compatibility.copyTextToClipboard(getActivity(), msg);
     LinphoneActivity.instance()
         .displayCustomToast(getString(R.string.text_copied_to_clipboard), Toast.LENGTH_SHORT);
   }
 }
 @Override
 public void onClick(View v) {
   if (LinphoneActivity.isInstanciated()) {
     LinphoneActivity.instance()
         .setAddresGoToDialerAndCall(
             v.getTag().toString(), contact.getName(), contact.getPhotoUri());
   }
 }
  @Override
  public void onResume() {
    super.onResume();

    if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().selectMenu(about);

      if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
        LinphoneActivity.instance().hideStatusBar();
      }
    }
  }
  @Override
  public boolean onContextItemSelected(MenuItem item) {
    AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo();
    if (info == null || info.targetView == null) {
      return false;
    }
    String sipUri = (String) info.targetView.getTag();

    LinphoneActivity.instance().removeFromChatList(sipUri);
    mConversations = LinphoneActivity.instance().getChatList();
    mDrafts = LinphoneActivity.instance().getDraftChatList();
    mConversations.removeAll(mDrafts);
    hideAndDisplayMessageIfNoChat();
    return true;
  }
  private boolean importAndroidStoredMessagedIntoLibLinphoneStorage() {
    Log.w("Importing previous messages into new database...");
    try {
      ChatStorage db = LinphoneActivity.instance().getChatStorage();
      List<String> conversations = db.getChatList();
      for (int j = conversations.size() - 1; j >= 0; j--) {
        String correspondent = conversations.get(j);
        LinphoneChatRoom room = LinphoneManager.getLc().getOrCreateChatRoom(correspondent);
        for (ChatMessage message : db.getMessages(correspondent)) {
          LinphoneChatMessage msg =
              room.createLinphoneChatMessage(
                  message.getMessage(),
                  message.getUrl(),
                  message.getStatus(),
                  Long.parseLong(message.getTimestamp()),
                  true,
                  message.isIncoming());
          if (message.getImage() != null) {
            String path = saveImageAsFile(message.getId(), message.getImage());
            if (path != null) msg.setExternalBodyUrl(path);
          }
          msg.store();
        }
        db.removeDiscussion(correspondent);
      }
      return true;
    } catch (Exception e) {
      e.printStackTrace();
    }

    return false;
  }
 @Override
 public boolean onContextItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case MENU_DELETE_MESSAGE:
       LinphoneActivity.instance().getChatStorage().deleteMessage(chatRoom, item.getGroupId());
       hideMessageBubble(item.getGroupId());
       break;
     case MENU_SAVE_PICTURE:
       saveImage(item.getGroupId());
       break;
     case MENU_COPY_TEXT:
       copyTextMessageToClipboard(item.getGroupId());
       break;
     case MENU_PICTURE_SMALL:
       uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.SMALL);
       break;
     case MENU_PICTURE_MEDIUM:
       uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.MEDIUM);
       break;
     case MENU_PICTURE_LARGE:
       uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.LARGE);
       break;
     case MENU_PICTURE_REAL:
       uploadAndSendImage(fileToUploadPath, imageToUpload, ImageSize.REAL);
       break;
     case MENU_RESEND_MESSAGE:
       resendMessage(item.getGroupId());
       break;
   }
   return true;
 }
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.editContact) {
      LinphoneActivity.instance().editContact(contact);
    }
  }
Exemple #13
0
  private void sendImageMessage(String path) {
    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    boolean isNetworkReachable = lc == null ? false : lc.isNetworkReachable();

    if (chatRoom != null && path != null && path.length() > 0 && isNetworkReachable) {
      Bitmap bm = BitmapFactory.decodeFile(path);
      if (bm != null) {
        FileUploadPrepareTask task = new FileUploadPrepareTask(getActivity(), path);
        task.execute(bm);
      } else {
        Log.e("Error, bitmap factory can't read " + path);
      }
    } else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance()
          .displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
    }
  }
 private void saveImage(int id) {
   byte[] rawImage = LinphoneActivity.instance().getChatStorage().getRawImageFromMessage(id);
   Bitmap bm = BitmapFactory.decodeByteArray(rawImage, 0, rawImage.length);
   if (saveImage(bm, id, null) != null) {
     Toast.makeText(getActivity(), getString(R.string.image_saved), Toast.LENGTH_SHORT).show();
   } else {
     Toast.makeText(getActivity(), getString(R.string.image_not_saved), Toast.LENGTH_LONG).show();
   }
 }
 @Override
 public void onClick(View v) {
   if (LinphoneActivity.isInstanciated()) {
     LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
     if (v == sendLogButton) {
       // LinphoneUtils.collectLogs(LinphoneActivity.instance(),
       // getString(R.string.about_bugreport_email));
       if (lc != null) {
         lc.uploadLogCollection();
       }
     } else if (v == resetLogButton) {
       if (lc != null) {
         lc.resetLogCollection();
       }
     } else {
       LinphoneActivity.instance().exit();
     }
   }
 }
 private boolean isVersionUsingNewChatStorage() {
   try {
     Context context = LinphoneActivity.instance();
     return context.getPackageManager().getPackageInfo(context.getPackageName(), 0).versionCode
         >= 2200;
   } catch (NameNotFoundException e) {
     e.printStackTrace();
   }
   return true;
 }
  @Override
  public void onResume() {
    super.onResume();

    if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().selectMenu(FragmentsAvailable.CONTACT);

      if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
        LinphoneActivity.instance().hideStatusBar();
      }
    }

    contact.refresh(getActivity().getContentResolver());
    if (contact.getName() == null || contact.getName().equals("")) {
      // Contact has been deleted, return
      LinphoneActivity.instance().displayContacts(false);
    }
    displayContact(inflater, view);
  }
Exemple #18
0
  public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) {
    this.sipUri = newSipUri;
    this.displayName = displayName;
    this.pictureUri = pictureUri;

    if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
      ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage();
      if (chatStorage.getDraft(sipUri) == null) {
        chatStorage.saveDraft(sipUri, message.getText().toString());
      } else {
        chatStorage.updateDraft(sipUri, message.getText().toString());
      }
    } else if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().getChatStorage().deleteDraft(sipUri);
    }

    if (LinphoneActivity.isInstanciated()) {
      String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri);
      if (draft == null) draft = "";
      message.setText(draft);
    }

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      chatRoom = lc.getOrCreateChatRoom(sipUri);
      // Only works if using liblinphone storage
      chatRoom.markAsRead();
    }

    displayChatHeader(displayName, pictureUri);
    dispayMessageList();
  }
  private void resendMessage(int id) {
    LinphoneChatMessage message = getMessageForId(id);
    if (message == null) return;

    LinphoneActivity.instance().getChatStorage().deleteMessage(chatRoom, id);
    hideMessageBubble(id);

    if (message.getText() != null && message.getText().length() > 0) {
      sendTextMessage(message.getText());
    } else {
      sendImageMessage(message.getExternalBodyUrl(), null);
    }
  }
Exemple #20
0
  @Override
  public void onLinphoneChatMessageStateChanged(LinphoneChatMessage msg, State state) {
    if (LinphoneActivity.isInstanciated() && state != LinphoneChatMessage.State.InProgress) {
      if (msg != null) {
        LinphoneActivity.instance().onMessageStateChanged(sipUri, msg.getText(), state.toInt());
      }
      invalidate();
    }

    if (state == State.FileTransferDone) {
      if (mDownloadedImageStream != null) {
        byte[] bytes = mDownloadedImageStream.toByteArray();
        Bitmap bm = BitmapFactory.decodeByteArray(bytes, 0, mDownloadedImageStreamSize);

        String path = msg.getExternalBodyUrl();
        String fileName = path.substring(path.lastIndexOf("/") + 1);
        String url =
            MediaStore.Images.Media.insertImage(
                getActivity().getContentResolver(), bm, fileName, null);
        if (url != null) {
          msg.setAppData(url);
        }

        mDownloadedImageStream = null;
        mDownloadedImageStreamSize = 0;
      } else if (mUploadingImageStream != null) {
        mUploadingImageStream = null;
      }
    }

    if (state == State.FileTransferDone || state == State.FileTransferError) {
      uploadLayout.setVisibility(View.GONE);
      textLayout.setVisibility(View.VISIBLE);
      progressBar.setProgress(0);
      currentMessageInFileTransferUploadState = null;
    }
    invalidate();
  }
Exemple #21
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 message = chatRoom.createLinphoneChatMessage(messageToSend);
      message.setListener(this);
      chatRoom.sendChatMessage(message);

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

      invalidate();
      Log.i("Sent message current status: " + message.getStatus());
    } else if (!isNetworkReachable && LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance()
          .displayCustomToast(getString(R.string.error_network_unreachable), Toast.LENGTH_LONG);
    }
  }
Exemple #22
0
  @Override
  public void onPause() {
    message.removeTextChangedListener(textWatcher);
    removeVirtualKeyboardVisiblityListener();

    LinphoneService.instance().removeMessageNotification();

    if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().updateChatFragment(null);
    }

    LinphoneCore lc = LinphoneManager.getLcIfManagerNotDestroyedOrNull();
    if (lc != null) {
      lc.removeListener(mListener);
    }

    onSaveInstanceState(getArguments());

    // Hide keybord
    InputMethodManager imm =
        (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.hideSoftInputFromWindow(message.getWindowToken(), 0);
    super.onPause();
  }
  @Override
  public void onClick(View v) {
    int id = v.getId();

    if (id == R.id.setup_apply) {
      String url = remoteProvisioningUrl.getText().toString();
      LinphonePreferences.instance().setRemoteProvisioningUrl(url);

      // Restart Linphone
      Intent intent = new Intent();
      intent.setClass(getActivity(), LinphoneLauncherActivity.class);
      getActivity().finish();
      LinphoneActivity.instance().exit();
      startActivity(intent);
    }
  }
  @Override
  public void onItemClick(AdapterView<?> adapter, View view, int position, long id) {
    String sipUri = (String) view.getTag();

    if (LinphoneActivity.isInstanciated() && !isEditMode) {
      LinphoneActivity.instance().displayChat(sipUri);
    } else if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().removeFromChatList(sipUri);
      LinphoneActivity.instance().removeFromDrafts(sipUri);

      mConversations = LinphoneActivity.instance().getChatList();
      mDrafts = LinphoneActivity.instance().getDraftChatList();
      mConversations.removeAll(mDrafts);
      hideAndDisplayMessageIfNoChat();

      LinphoneActivity.instance().updateMissedChatCount();
    }
  }
  private LinphoneChatMessage getMessageForId(int id) {
    LinphoneChatMessage msg = null;
    try {
      msg = LinphoneActivity.instance().getChatStorage().getMessage(chatRoom, id);
    } catch (Exception e) {
    }

    if (msg == null) {
      for (BubbleChat bubble : lastSentMessagesBubbles) {
        if (bubble.getId() == id) {
          return bubble.getNativeMessageObject();
        }
      }
    }

    return msg;
  }
  public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) {
    if (!message.getText().toString().equals("") && LinphoneActivity.isInstanciated()) {
      ChatStorage chatStorage = LinphoneActivity.instance().getChatStorage();
      if (chatStorage.getDraft(sipUri) == null) {
        chatStorage.saveDraft(sipUri, message.getText().toString());
      } else {
        chatStorage.updateDraft(sipUri, message.getText().toString());
      }
    } else if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().getChatStorage().deleteDraft(sipUri);
    }

    sipUri = newSipUri;
    if (LinphoneActivity.isInstanciated()) {
      String draft = LinphoneActivity.instance().getChatStorage().getDraft(sipUri);
      if (draft == null) draft = "";
      message.setText(draft);
    }

    displayChatHeader(displayName, pictureUri);
    displayMessages();
  }
 public void onClick(View v) {
   if (!LinphoneManager.getInstance().addVideo()) {
     LinphoneActivity.instance().startVideoActivity(LinphoneManager.getLc().getCurrentCall(), 0);
   }
 }
 public void hideKeyboardVisibleMode() {
   LinphoneActivity.instance().hideMenu(false);
   contactPicture.setVisibility(View.VISIBLE);
   // scrollToEnd();
 }
    public View getView(int position, View convertView, ViewGroup parent) {
      View view = null;

      if (convertView != null) {
        view = convertView;
      } else {
        view = mInflater.inflate(R.layout.chatlist_cell, parent, false);
      }
      String contact;
      boolean isDraft = false;
      if (position >= mDrafts.size()) {
        contact = mConversations.get(position - mDrafts.size());
      } else {
        contact = mDrafts.get(position);
        isDraft = true;
      }
      view.setTag(contact);
      int unreadMessagesCount =
          LinphoneActivity.instance().getChatStorage().getUnreadMessageCount(contact);

      LinphoneAddress address;
      try {
        address = LinphoneCoreFactory.instance().createLinphoneAddress(contact);
      } catch (LinphoneCoreException e) {
        Log.e("Chat view cannot parse address", e);
        return view;
      }
      LinphoneUtils.findUriPictureOfContactAndSetDisplayName(
          address, view.getContext().getContentResolver());

      String message = "";
      if (useNativeAPI) {
        LinphoneChatRoom chatRoom = LinphoneManager.getLc().getOrCreateChatRoom(contact);
        LinphoneChatMessage[] history = chatRoom.getHistory(20);
        if (history != null && history.length > 0) {
          for (int i = history.length - 1; i >= 0; i--) {
            LinphoneChatMessage msg = history[i];
            if (msg.getText() != null && msg.getText().length() > 0) {
              message = msg.getText();
              break;
            }
          }
        }
      } else {
        List<ChatMessage> messages = LinphoneActivity.instance().getChatMessages(contact);
        if (messages != null && messages.size() > 0) {
          int iterator = messages.size() - 1;
          ChatMessage lastMessage = null;

          while (iterator >= 0) {
            lastMessage = messages.get(iterator);
            if (lastMessage.getMessage() == null) {
              iterator--;
            } else {
              iterator = -1;
            }
          }
          message =
              (lastMessage == null || lastMessage.getMessage() == null)
                  ? ""
                  : lastMessage.getMessage();
        }
      }
      TextView lastMessageView = (TextView) view.findViewById(R.id.lastMessage);
      lastMessageView.setText(message);

      TextView sipUri = (TextView) view.findViewById(R.id.sipUri);
      sipUri.setSelected(true); // For animation

      if (getResources().getBoolean(R.bool.only_display_username_if_unknown)
          && address.getDisplayName() != null
          && LinphoneUtils.isSipAddress(address.getDisplayName())) {
        address.setDisplayName(LinphoneUtils.getUsernameFromAddress(address.getDisplayName()));
      } else if (getResources().getBoolean(R.bool.only_display_username_if_unknown)
          && LinphoneUtils.isSipAddress(contact)) {
        contact = LinphoneUtils.getUsernameFromAddress(contact);
      }

      sipUri.setText(address.getDisplayName() == null ? contact : address.getDisplayName());
      if (isDraft) {
        view.findViewById(R.id.draft).setVisibility(View.VISIBLE);
      }

      ImageView delete = (ImageView) view.findViewById(R.id.delete);
      TextView unreadMessages = (TextView) view.findViewById(R.id.unreadMessages);

      if (unreadMessagesCount > 0) {
        unreadMessages.setVisibility(View.VISIBLE);
        unreadMessages.setText(String.valueOf(unreadMessagesCount));
      } else {
        unreadMessages.setVisibility(View.GONE);
      }

      if (isEditMode) {
        delete.setVisibility(View.VISIBLE);
      } else {
        delete.setVisibility(View.INVISIBLE);
      }

      return view;
    }
  @Override
  public void onResume() {
    super.onResume();

    // Check if the is the first time we show the chat view since we use liblinphone chat storage
    useLinphoneStorage = getResources().getBoolean(R.bool.use_linphone_chat_storage);
    final SharedPreferences prefs =
        PreferenceManager.getDefaultSharedPreferences(LinphoneActivity.instance());
    boolean updateNeeded =
        prefs.getBoolean(getString(R.string.pref_first_time_linphone_chat_storage), true);
    updateNeeded = updateNeeded && !isVersionUsingNewChatStorage();
    if (useLinphoneStorage && updateNeeded) {
      AsyncTask<Void, Void, Void> task =
          new AsyncTask<Void, Void, Void>() {
            private ProgressDialog pd;

            @Override
            protected void onPreExecute() {
              pd = new ProgressDialog(LinphoneActivity.instance());
              pd.setTitle(getString(R.string.wait));
              pd.setMessage(getString(R.string.importing_messages));
              pd.setCancelable(false);
              pd.setIndeterminate(true);
              pd.show();
            }

            @Override
            protected Void doInBackground(Void... arg0) {
              try {
                if (importAndroidStoredMessagedIntoLibLinphoneStorage()) {
                  prefs
                      .edit()
                      .putBoolean(getString(R.string.pref_first_time_linphone_chat_storage), false)
                      .commit();
                  LinphoneActivity.instance().getChatStorage().restartChatStorage();
                }
              } catch (Exception e) {
                e.printStackTrace();
              }
              return null;
            }

            @Override
            protected void onPostExecute(Void result) {
              pd.dismiss();
            }
          };
      task.execute((Void[]) null);
    }

    if (LinphoneActivity.isInstanciated()) {
      LinphoneActivity.instance().selectMenu(FragmentsAvailable.CHATLIST);
      LinphoneActivity.instance().updateChatListFragment(this);

      if (getResources().getBoolean(R.bool.show_statusbar_only_on_dialer)) {
        LinphoneActivity.instance().hideStatusBar();
      }
    }

    refresh();
  }