Search in sources :

Example 31 with ListPopupWindow

use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.

the class ContactEditorBaseFragment method onAggregationSuggestionChange.

@Override
public void onAggregationSuggestionChange() {
    final Activity activity = getActivity();
    if ((activity != null && activity.isFinishing()) || !isVisible() || mState.isEmpty() || mStatus != Status.EDITING) {
        return;
    }
    UiClosables.closeQuietly(mAggregationSuggestionPopup);
    if (mAggregationSuggestionEngine.getSuggestedContactCount() == 0) {
        return;
    }
    final View anchorView = getAggregationAnchorView(mAggregationSuggestionsRawContactId);
    if (anchorView == null) {
        // Raw contact deleted?
        return;
    }
    mAggregationSuggestionPopup = new ListPopupWindow(mContext, null);
    mAggregationSuggestionPopup.setAnchorView(anchorView);
    mAggregationSuggestionPopup.setWidth(anchorView.getWidth());
    mAggregationSuggestionPopup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    mAggregationSuggestionPopup.setAdapter(new AggregationSuggestionAdapter(getActivity(), mState.size() == 1 && mState.get(0).isContactInsert(), /* listener =*/
    this, mAggregationSuggestionEngine.getSuggestions()));
    mAggregationSuggestionPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final AggregationSuggestionView suggestionView = (AggregationSuggestionView) view;
            suggestionView.handleItemClickEvent();
            UiClosables.closeQuietly(mAggregationSuggestionPopup);
            mAggregationSuggestionPopup = null;
        }
    });
    mAggregationSuggestionPopup.show();
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) ContactEditorAccountsChangedActivity(com.android.contacts.activities.ContactEditorAccountsChangedActivity) QuickContactActivity(com.android.contacts.quickcontact.QuickContactActivity) ContactEditorBaseActivity(com.android.contacts.activities.ContactEditorBaseActivity) Activity(android.app.Activity) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 32 with ListPopupWindow

use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.

the class ContactEditorFragment method addAccountSwitcher.

private void addAccountSwitcher(final RawContactDelta currentState, BaseRawContactEditorView editor) {
    final AccountWithDataSet currentAccount = new AccountWithDataSet(currentState.getAccountName(), currentState.getAccountType(), currentState.getDataSet());
    final View accountView = editor.findViewById(R.id.account);
    final View anchorView = editor.findViewById(R.id.account_selector_container);
    if (accountView == null) {
        return;
    }
    anchorView.setVisibility(View.VISIBLE);
    accountView.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            final ListPopupWindow popup = new ListPopupWindow(mContext, null);
            final AccountsListAdapter adapter = new AccountsListAdapter(mContext, AccountListFilter.ACCOUNTS_CONTACT_WRITABLE, currentAccount);
            popup.setWidth(anchorView.getWidth());
            popup.setAnchorView(anchorView);
            popup.setAdapter(adapter);
            popup.setModal(true);
            popup.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
            popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                    UiClosables.closeQuietly(popup);
                    AccountWithDataSet newAccount = adapter.getItem(position);
                    if (!newAccount.equals(currentAccount)) {
                        rebindEditorsForNewContact(currentState, currentAccount, newAccount);
                    }
                }
            });
            popup.show();
        }
    });
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) AccountsListAdapter(com.android.contacts.common.util.AccountsListAdapter) AccountWithDataSet(com.android.contacts.common.model.account.AccountWithDataSet) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView)

Example 33 with ListPopupWindow

use of android.widget.ListPopupWindow in project packages_apps_Contacts by AOKP.

the class PhotoActionPopup method createPopupMenu.

public static ListPopupWindow createPopupMenu(Context context, View anchorView, final Listener listener, int mode) {
    final ArrayList<ChoiceListItem> choices = getChoices(context, mode);
    final ListAdapter adapter = new ArrayAdapter<ChoiceListItem>(context, R.layout.select_dialog_item, choices);
    final ListPopupWindow listPopupWindow = new ListPopupWindow(context);
    final OnItemClickListener clickListener = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            final ChoiceListItem choice = choices.get(position);
            switch(choice.getId()) {
                case ChoiceListItem.ID_REMOVE:
                    listener.onRemovePictureChosen();
                    break;
                case ChoiceListItem.ID_TAKE_PHOTO:
                    listener.onTakePhotoChosen();
                    break;
                case ChoiceListItem.ID_PICK_PHOTO:
                    listener.onPickFromGalleryChosen();
                    break;
            }
            UiClosables.closeQuietly(listPopupWindow);
        }
    };
    listPopupWindow.setAnchorView(anchorView);
    listPopupWindow.setAdapter(adapter);
    listPopupWindow.setOnItemClickListener(clickListener);
    listPopupWindow.setModal(true);
    listPopupWindow.setInputMethodMode(ListPopupWindow.INPUT_METHOD_NOT_NEEDED);
    final int minWidth = context.getResources().getDimensionPixelSize(R.dimen.photo_action_popup_min_width);
    if (anchorView.getWidth() < minWidth) {
        listPopupWindow.setWidth(minWidth);
    }
    return listPopupWindow;
}
Also used : ListPopupWindow(android.widget.ListPopupWindow) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) AdapterView(android.widget.AdapterView) View(android.view.View) AdapterView(android.widget.AdapterView) ListAdapter(android.widget.ListAdapter) ArrayAdapter(android.widget.ArrayAdapter)

Aggregations

ListPopupWindow (android.widget.ListPopupWindow)33 View (android.view.View)27 AdapterView (android.widget.AdapterView)25 TextView (android.widget.TextView)17 ImageView (android.widget.ImageView)14 Context (android.content.Context)8 Paint (android.graphics.Paint)8 ArrayList (java.util.ArrayList)8 ArrayAdapter (android.widget.ArrayAdapter)4 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)3 ImageButton (android.widget.ImageButton)3 Activity (android.app.Activity)2 Intent (android.content.Intent)2 TypedArray (android.content.res.TypedArray)2 Point (android.graphics.Point)2 Uri (android.net.Uri)2 Handler (android.os.Handler)2 Editable (android.text.Editable)2 TextWatcher (android.text.TextWatcher)2 ViewGroup (android.view.ViewGroup)2