Search in sources :

Example 61 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 62 with PopupWindow

use of android.widget.PopupWindow in project socialauth-android by 3pillarlabs.

the class SocialAuthAdapter method enable.

/**
	 * Enables a button with the SocialAuth menu
	 * 
	 * @param actionView
	 *            The button on providersthat will be clicked by user to show
	 *            list of providers
	 */
public void enable(final View actionView) {
    // Creating List to show providers
    final Context ctx = actionView.getContext();
    final ListView pList = new ListView(ctx);
    pList.setLayoutParams(new LinearLayout.LayoutParams(500, 500));
    pList.setBackgroundColor(Color.WHITE);
    // Getting provider names and logos to display
    final String[] providerNames = new String[providerCount];
    final int[] providerLogos = new int[providerCount];
    for (int i = 0; i < providerCount; i++) {
        providerNames[i] = authProviders[i].toString();
        providerLogos[i] = authProviderLogos[i];
    }
    // Query native apps
    final ArrayList<AppList> appList = Util.queryIntentActivities(ctx, providerNames, providerLogos);
    // Handle Click Events on Action Provider button
    actionView.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // Populating List
            pList.setAdapter(new PopUpListAdapter(ctx, appList));
            pList.setDivider(new ColorDrawable(0x99474747));
            // Creating Popup Window to show List
            final PopupWindow popupWindow = new PopupWindow(ctx);
            popupWindow.setFocusable(true);
            WindowManager wm = (WindowManager) ctx.getSystemService(Context.WINDOW_SERVICE);
            float width = (wm.getDefaultDisplay().getWidth() * 2) / 3;
            popupWindow.setWidth((int) width);
            popupWindow.setHeight(WindowManager.LayoutParams.WRAP_CONTENT);
            // set the list view as pop up window content
            popupWindow.setContentView(pList);
            popupWindow.showAsDropDown(actionView, 10, 10);
            // Handle Click events on list item
            pList.setOnItemClickListener(new OnItemClickListener() {

                @Override
                public void onItemClick(AdapterView<?> adapter, View view, int position, long arg) {
                    // Dismiss popup window
                    popupWindow.dismiss();
                    // Start provider
                    if (position > providerNames.length) {
                        ctx.startActivity(appList.get(position).intent);
                    } else {
                        authorize(ctx, authProviders[position]);
                    }
                }
            });
        }
    });
    // If network not available show message
    if (!Util.isNetworkAvailable(ctx)) {
        dialogListener.onError(new SocialAuthError("Please check your Internet connection", new Exception("")));
        return;
    }
}
Also used : Context(android.content.Context) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PopupWindow(android.widget.PopupWindow) ImageView(android.widget.ImageView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) UnsupportedEncodingException(java.io.UnsupportedEncodingException) SocialAuthException(org.brickred.socialauth.exception.SocialAuthException) WindowManager(android.view.WindowManager) ListView(android.widget.ListView) ColorDrawable(android.graphics.drawable.ColorDrawable) OnClickListener(android.view.View.OnClickListener) AdapterView(android.widget.AdapterView) LinearLayout(android.widget.LinearLayout)

Example 63 with PopupWindow

use of android.widget.PopupWindow in project PLDroidPlayer by pili-engineering.

the class MediaController method initFloatingWindow.

private void initFloatingWindow() {
    mWindow = new PopupWindow(mContext);
    mWindow.setFocusable(false);
    mWindow.setBackgroundDrawable(null);
    mWindow.setOutsideTouchable(true);
    mAnimStyle = android.R.style.Animation;
}
Also used : PopupWindow(android.widget.PopupWindow)

Example 64 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 65 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)

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