Search in sources :

Example 96 with PopupWindow

use of android.widget.PopupWindow in project android_frameworks_base by AOSPA.

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 97 with PopupWindow

use of android.widget.PopupWindow in project android_frameworks_base by DirtyUnicorns.

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 98 with PopupWindow

use of android.widget.PopupWindow in project android_frameworks_base by DirtyUnicorns.

the class FloatingToolbar method createPopupWindow.

private static PopupWindow createPopupWindow(ViewGroup content) {
    ViewGroup popupContentHolder = new LinearLayout(content.getContext());
    PopupWindow popupWindow = new PopupWindow(popupContentHolder);
    // TODO: Use .setLayoutInScreenEnabled(true) instead of .setClippingEnabled(false)
    // unless FLAG_LAYOUT_IN_SCREEN has any unintentional side-effects.
    popupWindow.setClippingEnabled(false);
    popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL);
    popupWindow.setAnimationStyle(0);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    content.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    popupContentHolder.addView(content);
    return popupWindow;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup) PopupWindow(android.widget.PopupWindow) LinearLayout(android.widget.LinearLayout)

Example 99 with PopupWindow

use of android.widget.PopupWindow in project android_frameworks_base by crdroidandroid.

the class FloatingToolbar method createPopupWindow.

private static PopupWindow createPopupWindow(ViewGroup content) {
    ViewGroup popupContentHolder = new LinearLayout(content.getContext());
    PopupWindow popupWindow = new PopupWindow(popupContentHolder);
    // TODO: Use .setLayoutInScreenEnabled(true) instead of .setClippingEnabled(false)
    // unless FLAG_LAYOUT_IN_SCREEN has any unintentional side-effects.
    popupWindow.setClippingEnabled(false);
    popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_APPLICATION_ABOVE_SUB_PANEL);
    popupWindow.setAnimationStyle(0);
    popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    content.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    popupContentHolder.addView(content);
    return popupWindow;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ViewGroup(android.view.ViewGroup) PopupWindow(android.widget.PopupWindow) LinearLayout(android.widget.LinearLayout)

Example 100 with PopupWindow

use of android.widget.PopupWindow in project SmartMesh_Android by SmartMeshFoundation.

the class AccountFragment method initHomePop.

/**
 * Initialize the Pop layout
 */
private void initHomePop() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View view = inflater.inflate(R.layout.account_more_popup_layout, null);
    homePop = new PopupWindow(view, Utils.dip2px(getActivity(), 160), LinearLayout.LayoutParams.WRAP_CONTENT);
    homePop.setBackgroundDrawable(new BitmapDrawable());
    homePop.setOutsideTouchable(true);
    homePop.setFocusable(true);
    view.findViewById(R.id.txt_home_pop_1).setOnClickListener(this);
    if (homePop.isShowing()) {
        homePop.dismiss();
    } else {
        // On the coordinates of a specific display PopupWindow custom menu
        homePop.showAsDropDown(walletImg, Utils.dip2px(getActivity(), -118), Utils.dip2px(getActivity(), 0));
    }
}
Also used : LayoutInflater(android.view.LayoutInflater) PopupWindow(android.widget.PopupWindow) BitmapDrawable(android.graphics.drawable.BitmapDrawable) CustomListView(com.lingtuan.firefly.custom.CustomListView) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) ListView(android.widget.ListView)

Aggregations

PopupWindow (android.widget.PopupWindow)145 View (android.view.View)68 TextView (android.widget.TextView)52 ColorDrawable (android.graphics.drawable.ColorDrawable)29 Paint (android.graphics.Paint)26 ImageView (android.widget.ImageView)24 AdapterView (android.widget.AdapterView)15 Key (android.inputmethodservice.Keyboard.Key)14 LayoutInflater (android.view.LayoutInflater)14 LinearLayout (android.widget.LinearLayout)14 ListView (android.widget.ListView)14 BitmapDrawable (android.graphics.drawable.BitmapDrawable)13 Button (android.widget.Button)13 Activity (android.app.Activity)12 Context (android.content.Context)11 Resources (android.content.res.Resources)11 OnClickListener (android.view.View.OnClickListener)11 ViewGroup (android.view.ViewGroup)11 EditText (android.widget.EditText)11 ScrollView (android.widget.ScrollView)10