@Override
 MessageEditorData executeAsync(MyAccount ma, long msgId) {
   String body = MyQuery.msgIdToStringColumnValue(MyDatabase.Msg.BODY, msgId);
   if (ma.getOrigin().isHtmlContentAllowed()) {
     body = MyHtml.fromHtml(body);
   }
   return MessageEditorData.newEmpty(ma).setBody(body);
 }
Пример #2
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    final String method = "onCreateContextMenu";
    super.onCreateContextMenu(menu, v, menuInfo);
    if (getViewItem() == null) {
      return;
    }
    MyAccount myActor = getMyActor();
    if (!myActor.isValid() || !myActor.getOrigin().equals(getOrigin())) {
      setMyActor(getMyContext().persistentAccounts().getFirstSucceededForOrigin(getOrigin()));
    }

    int order = 0;
    try {
      new ContextMenuHeader(getActivity(), menu)
          .setTitle(getViewItem().mbUser.toUserTitle(false))
          .setSubtitle(getMyActor().getAccountName());
      String shortName = getViewItem().mbUser.getUserName();
      if (getViewItem().mbUser.isIdentified()) {
        UserListContextMenuItem.USER_MESSAGES.addTo(
            menu,
            order++,
            String.format(
                getActivity().getText(R.string.menu_item_user_messages).toString(), shortName));
        UserListContextMenuItem.FRIENDS.addTo(
            menu,
            order++,
            String.format(getActivity().getText(R.string.friends_of).toString(), shortName));
        UserListContextMenuItem.FOLLOWERS.addTo(
            menu,
            order++,
            String.format(getActivity().getText(R.string.followers_of).toString(), shortName));
        if (getViewItem().userIsFollowedBy(getMyActor())) {
          UserListContextMenuItem.STOP_FOLLOWING.addTo(
              menu,
              order++,
              String.format(
                  getActivity().getText(R.string.menu_item_stop_following_user).toString(),
                  shortName));
        } else if (getViewItem().getUserId() != getMyActor().getUserId()) {
          UserListContextMenuItem.FOLLOW.addTo(
              menu,
              order++,
              String.format(
                  getActivity().getText(R.string.menu_item_follow_user).toString(), shortName));
        }
        switch (getMyActor().numberOfAccountsOfThisOrigin()) {
          case 0:
          case 1:
            break;
          case 2:
            UserListContextMenuItem.ACT_AS_FIRST_OTHER_USER.addTo(
                menu,
                order++,
                String.format(
                    getActivity().getText(R.string.menu_item_act_as_user).toString(),
                    getMyActor()
                        .firstOtherAccountOfThisOrigin()
                        .getShortestUniqueAccountName(getMyContext())));
            break;
          default:
            UserListContextMenuItem.ACT_AS.addTo(menu, order++, R.string.menu_item_act_as);
            break;
        }
      }
      UserListContextMenuItem.GET_USER.addTo(menu, order++, R.string.get_user);
    } catch (Exception e) {
      MyLog.e(this, method, e);
    }
  }