Esempio n. 1
0
  /* (non-Javadoc)
   * @see android.app.Activity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
   */
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { // :-)

    super.onCreateContextMenu(menu, v, menuInfo);
    getMenuInflater().inflate(R.menu.device_context_menu, menu);

    AdapterContextMenuInfo info = (AdapterContextMenuInfo) menuInfo;
    ListAdapter adapter = getListAdapter();
    SoftAPDetails item = (SoftAPDetails) adapter.getItem(info.position);

    if (!item.supportOnboarding) menu.removeItem(R.id.context_menu_onboarding);
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
    if (isEncryptedConversation && isSingleConversation()) {
      boolean isPushDestination = DirectoryHelper.isPushDestination(this, getRecipients());
      Recipient primaryRecipient =
          getRecipients() == null ? null : getRecipients().getPrimaryRecipient();
      boolean hasSession = Session.hasSession(this, masterSecret, primaryRecipient);

      getMenuInflater().inflate(R.menu.conversation_button_context, menu);

      if (attachmentManager.isAttachmentPresent()) {
        menu.removeItem(R.id.menu_context_send_encrypted_sms);
        menu.removeItem(R.id.menu_context_send_unencrypted_sms);
      } else {
        menu.removeItem(R.id.menu_context_send_encrypted_mms);
        menu.removeItem(R.id.menu_context_send_unencrypted_mms);
      }

      if (!isPushDestination) {
        menu.removeItem(R.id.menu_context_send_push);
      }

      if (!hasSession) {
        menu.removeItem(R.id.menu_context_send_encrypted_mms);
        menu.removeItem(R.id.menu_context_send_encrypted_sms);
      }
    }
  }
Esempio n. 3
0
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
    MenuInflater inflater = getActivity().getMenuInflater();
    if (PrefsUtils.getStoryOrder(activity, getFeedSet()) == StoryOrder.NEWEST) {
      inflater.inflate(R.menu.context_story_newest, menu);
    } else {
      inflater.inflate(R.menu.context_story_oldest, menu);
    }

    int truePosition = ((AdapterView.AdapterContextMenuInfo) menuInfo).position - 1;
    Story story = adapter.getStory(truePosition);
    if (story.read) {
      menu.removeItem(R.id.menu_mark_story_as_read);
    } else {
      menu.removeItem(R.id.menu_mark_story_as_unread);
    }

    if (story.starred) {
      menu.removeItem(R.id.menu_save_story);
    } else {
      menu.removeItem(R.id.menu_unsave_story);
    }
  }
  @Override
  public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfoIn) {
    super.onCreateContextMenu(menu, v, menuInfoIn);
    if (v.getId() == R.id.edt_dpkb_call_number) {
      menu.removeItem(android.R.id.switchInputMethod);
      menu.removeItem(android.R.id.selectAll);
      menu.removeItem(android.R.id.startSelectingText);

      return;
    }
    if (menuInfoIn != null) {
      AdapterView.AdapterContextMenuInfo menuInfo = null;
      try {
        menuInfo = (AdapterView.AdapterContextMenuInfo) menuInfoIn;
      } catch (ClassCastException e) {
        log("bad menuInfoIn e = " + e);
        return;
      }

      mContextMenuIdx = menuInfo.position;
      mDialpadItem = mItemAdapter.getItem(mContextMenuIdx);
      String name = mDialpadItem.getName();
      String number = mDialpadItem.getNumber();
      long contactId = mDialpadItem.getContactId();
      log("onCreateContextMenu: name=" + name + " number=" + number + " contactId=" + contactId);
      if (!TextUtils.isEmpty(name)) {
        menu.setHeaderTitle(name);
      } else {
        if (number.equals(CallerInfo.UNKNOWN_NUMBER)) {
          number = getResources().getString(R.string.unknown);
        } else if (number.equals(CallerInfo.PRIVATE_NUMBER)) {
          number = getResources().getString(R.string.private_num);
        } else if (number.equals(CallerInfo.PAYPHONE_NUMBER)) {
          number = getResources().getString(R.string.payphone);
        }
        menu.setHeaderTitle(number);
      }

      if (DialpadItem.CALLLOG_TYPE == mDialpadItem.getType()) {
        menu.add(0, R.id.menu_log_detail, 0, R.string.view_calllog_detail);
      }

      menu.add(0, R.id.menu_send_message, 0, R.string.send_message);
      if (0 == contactId) {
        menu.add(0, R.id.menu_new_contact, 0, R.string.menu_newContact);
        // modify by zenghuaying fix bug #5705
        if (!CommonMethod.contactsIsEmpty(this)) {
          menu.add(0, R.id.menu_add_to_contacts, 0, R.string.menu_add_to_contacts);
        }
        // modify end
      } else {
        menu.add(0, R.id.menu_view_contact, 0, R.string.view_contact);
      }

      if (DialpadItem.CALLLOG_TYPE == mDialpadItem.getType()) {
        menu.add(0, R.id.menu_delete_log, 0, R.string.delete_call_log);
      }

      if (CommonMethod.numberIsInBlacklist(this, number)) {
        menu.add(0, R.id.menu_clear_from_blacklist, 0, R.string.clear_from_blacklist);
      } else {
        menu.add(0, R.id.menu_add_to_blacklist, 0, R.string.add_to_blacklist);
      }
    }
  }