Search in sources :

Example 46 with PopupWindow

use of android.widget.PopupWindow in project platform_frameworks_base by android.

the class DecorView method createStandaloneActionMode.

private ActionMode createStandaloneActionMode(ActionMode.Callback callback) {
    endOnGoingFadeAnimation();
    cleanupPrimaryActionMode();
    // cleanupPrimaryActionMode() invocation above.
    if (mPrimaryActionModeView == null || !mPrimaryActionModeView.isAttachedToWindow()) {
        if (mWindow.isFloating()) {
            // Use the action bar theme.
            final TypedValue outValue = new TypedValue();
            final Resources.Theme baseTheme = mContext.getTheme();
            baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
            final Context actionBarContext;
            if (outValue.resourceId != 0) {
                final Resources.Theme actionBarTheme = mContext.getResources().newTheme();
                actionBarTheme.setTo(baseTheme);
                actionBarTheme.applyStyle(outValue.resourceId, true);
                actionBarContext = new ContextThemeWrapper(mContext, 0);
                actionBarContext.getTheme().setTo(actionBarTheme);
            } else {
                actionBarContext = mContext;
            }
            mPrimaryActionModeView = new ActionBarContextView(actionBarContext);
            mPrimaryActionModePopup = new PopupWindow(actionBarContext, null, R.attr.actionModePopupWindowStyle);
            mPrimaryActionModePopup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION);
            mPrimaryActionModePopup.setContentView(mPrimaryActionModeView);
            mPrimaryActionModePopup.setWidth(MATCH_PARENT);
            actionBarContext.getTheme().resolveAttribute(R.attr.actionBarSize, outValue, true);
            final int height = TypedValue.complexToDimensionPixelSize(outValue.data, actionBarContext.getResources().getDisplayMetrics());
            mPrimaryActionModeView.setContentHeight(height);
            mPrimaryActionModePopup.setHeight(WRAP_CONTENT);
            mShowPrimaryActionModePopup = new Runnable() {

                public void run() {
                    mPrimaryActionModePopup.showAtLocation(mPrimaryActionModeView.getApplicationWindowToken(), Gravity.TOP | Gravity.FILL_HORIZONTAL, 0, 0);
                    endOnGoingFadeAnimation();
                    if (shouldAnimatePrimaryActionModeView()) {
                        mFadeAnim = ObjectAnimator.ofFloat(mPrimaryActionModeView, View.ALPHA, 0f, 1f);
                        mFadeAnim.addListener(new AnimatorListenerAdapter() {

                            @Override
                            public void onAnimationStart(Animator animation) {
                                mPrimaryActionModeView.setVisibility(VISIBLE);
                            }

                            @Override
                            public void onAnimationEnd(Animator animation) {
                                mPrimaryActionModeView.setAlpha(1f);
                                mFadeAnim = null;
                            }
                        });
                        mFadeAnim.start();
                    } else {
                        mPrimaryActionModeView.setAlpha(1f);
                        mPrimaryActionModeView.setVisibility(VISIBLE);
                    }
                }
            };
        } else {
            ViewStub stub = (ViewStub) findViewById(R.id.action_mode_bar_stub);
            if (stub != null) {
                mPrimaryActionModeView = (ActionBarContextView) stub.inflate();
                mPrimaryActionModePopup = null;
            }
        }
    }
    if (mPrimaryActionModeView != null) {
        mPrimaryActionModeView.killMode();
        ActionMode mode = new StandaloneActionMode(mPrimaryActionModeView.getContext(), mPrimaryActionModeView, callback, mPrimaryActionModePopup == null);
        return mode;
    }
    return null;
}
Also used : Context(android.content.Context) PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) ViewStub(android.view.ViewStub) Animator(android.animation.Animator) ObjectAnimator(android.animation.ObjectAnimator) ContextThemeWrapper(android.view.ContextThemeWrapper) AnimatorListenerAdapter(android.animation.AnimatorListenerAdapter) ActionMode(android.view.ActionMode) StandaloneActionMode(com.android.internal.view.StandaloneActionMode) FloatingActionMode(com.android.internal.view.FloatingActionMode) ActionBarContextView(com.android.internal.widget.ActionBarContextView) Resources(android.content.res.Resources) TypedValue(android.util.TypedValue)

Example 47 with PopupWindow

use of android.widget.PopupWindow in project FloatingStickies by MohammadAdib.

the class Window method getDropDownList.

public PopupWindow getDropDownList() {
    final List<DropDownListItem> items = new ArrayList<DropDownListItem>();
    items.add(new DropDownListItem("Copy", new Runnable() {

        @Override
        public void run() {
            ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
            clipboard.setText(getText());
        }
    }));
    items.add(new DropDownListItem("Paste", new Runnable() {

        @Override
        public void run() {
            try {
                ClipboardManager clipboard = (ClipboardManager) mContext.getSystemService(Context.CLIPBOARD_SERVICE);
                setText(getText() + clipboard.getText().toString());
            } catch (Exception e) {
            }
        }
    }));
    items.add(new DropDownListItem("Share", new Runnable() {

        @Override
        public void run() {
            // Share
            Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND);
            sharingIntent.setType("text/plain");
            sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Floating Stickies");
            sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, getText());
            mContext.startActivity(Intent.createChooser(sharingIntent, "Share Sticky").setFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
        }
    }));
    // turn item list into views in PopupWindow
    LinearLayout list = new LinearLayout(mContext);
    list.setOrientation(LinearLayout.VERTICAL);
    ScrollView scroller = new ScrollView(mContext);
    scroller.addView(list);
    final PopupWindow dropDown = new PopupWindow(scroller, StandOutLayoutParams.WRAP_CONTENT, StandOutLayoutParams.WRAP_CONTENT, true);
    for (final DropDownListItem item : items) {
        LayoutInflater inflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        ViewGroup listItem = (ViewGroup) inflater.inflate(R.layout.drop_down_list_item, null);
        list.addView(listItem);
        TextView textView = (TextView) listItem.findViewById(R.id.text);
        textView.setText(item.text);
        listItem.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dropDown.dismiss();
                item.action.run();
            }
        });
    }
    return dropDown;
}
Also used : ClipboardManager(android.text.ClipboardManager) ViewGroup(android.view.ViewGroup) ArrayList(java.util.ArrayList) PopupWindow(android.widget.PopupWindow) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) ScrollView(android.widget.ScrollView) LayoutInflater(android.view.LayoutInflater) TextView(android.widget.TextView) LinearLayout(android.widget.LinearLayout)

Example 48 with PopupWindow

use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.

the class Util method showPopup.

public static PopupWindow showPopup(Activity act, int nLayout, boolean bDropDown, View vAnchor, int offsetX, int offsetY) {
    final PopupWindow pw = new PopupWindow(act);
    LayoutInflater inflater = (LayoutInflater) act.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(nLayout, null, false);
    pw.setContentView(v);
    pw.setFocusable(true);
    pw.setWindowLayoutMode(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
    pw.setOutsideTouchable(true);
    pw.setTouchable(true);
    pw.setBackgroundDrawable(new BitmapDrawable());
    if (bDropDown)
        pw.showAsDropDown(vAnchor, offsetX, offsetY);
    else
        pw.showAtLocation(vAnchor.getRootView(), Gravity.NO_GRAVITY, offsetX, offsetY);
    return pw;
}
Also used : LayoutInflater(android.view.LayoutInflater) PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView)

Example 49 with PopupWindow

use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.

the class ProfileFragment method setupSettings.

private void setupSettings() {
    final Button btnSettings = (Button) m_root.findViewById(R.id.btnSettings);
    btnSettings.setVisibility(View.VISIBLE);
    btnSettings.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            int nLayout = m_bOtherProfile ? R.layout.profile_settings : R.layout.profile_settings2;
            final PopupWindow pw = Util.showPopup(getActivity(), nLayout, true, btnSettings, 5, 5);
            View v = pw.getContentView();
            Button btn = (Button) v.findViewById(R.id.btn_filter_all);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    m_currentActType = ActivityFragment.ACTIVITY_TYPE_ALL;
                    pw.dismiss();
                    getProfileInfo(false);
                }
            });
            btn = (Button) v.findViewById(R.id.btn_filter_updates);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    m_currentActType = ActivityFragment.ACTIVITY_TYPE_UPDATES;
                    getProfileInfo(false);
                    pw.dismiss();
                }
            });
            btn = (Button) v.findViewById(R.id.btn_add_remove_friend);
            if (btn != null) {
                btn.setBackgroundResource(m_bFriend ? R.drawable.friend_remove_button_background : R.drawable.friend_add_button_background);
                btn.setText(m_bFriend ? "Remove from friends" : "Add to friends");
                btn.setOnClickListener(new OnClickListener() {

                    public void onClick(View v) {
                        AddOrRemoveFriend(m_bFriend, m_playerTsid);
                        m_bFriend = !m_bFriend;
                        pw.dismiss();
                    }
                });
            }
        }
    });
}
Also used : Button(android.widget.Button) PopupWindow(android.widget.PopupWindow) OnClickListener(android.view.View.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView)

Example 50 with PopupWindow

use of android.widget.PopupWindow in project glitch-hq-android by tinyspeck.

the class ActivityFragment method initTopMenu.

private void initTopMenu() {
    m_btnFilter = (Button) m_root.findViewById(R.id.btnFilter);
    m_btnFilter.setVisibility(View.VISIBLE);
    m_btnNewUpdate = (Button) m_root.findViewById(R.id.btnNewUpdate);
    m_btnNewUpdate.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            FlurryAgent.logEvent("Activity - 'Compose' button pressed");
            composeNotes();
        }
    });
    m_btnFilter.setOnClickListener(new OnClickListener() {

        public void onClick(View arg0) {
            final PopupWindow pw = Util.showPopup(getActivity(), R.layout.filter_menu, true, m_btnFilter, 5, 5);
            View v = pw.getContentView();
            Button btn = (Button) v.findViewById(R.id.btn_filter_all);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    m_currentActType = ACTIVITY_TYPE_ALL;
                    pw.dismiss();
                    getActivity(false);
                }
            });
            btn = (Button) v.findViewById(R.id.btn_filter_updates);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    m_currentActType = ACTIVITY_TYPE_UPDATES;
                    pw.dismiss();
                    getActivity(false);
                }
            });
            btn = (Button) v.findViewById(R.id.btn_filter_requests);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    m_currentActType = ACTIVITY_TYPE_REQUESTS;
                    pw.dismiss();
                    getActivity(false);
                }
            });
        }
    });
}
Also used : Button(android.widget.Button) PopupWindow(android.widget.PopupWindow) OnClickListener(android.view.View.OnClickListener) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Aggregations

PopupWindow (android.widget.PopupWindow)69 View (android.view.View)30 TextView (android.widget.TextView)22 Paint (android.graphics.Paint)20 ImageView (android.widget.ImageView)17 Key (android.inputmethodservice.Keyboard.Key)14 ColorDrawable (android.graphics.drawable.ColorDrawable)12 LinearLayout (android.widget.LinearLayout)12 ViewGroup (android.view.ViewGroup)10 ScrollView (android.widget.ScrollView)10 OnClickListener (android.view.View.OnClickListener)9 Context (android.content.Context)8 Resources (android.content.res.Resources)8 LayoutInflater (android.view.LayoutInflater)8 LayoutParams (android.view.ViewGroup.LayoutParams)7 Button (android.widget.Button)6 Animator (android.animation.Animator)5 AnimatorListenerAdapter (android.animation.AnimatorListenerAdapter)5 ObjectAnimator (android.animation.ObjectAnimator)5 Activity (android.app.Activity)5