Search in sources :

Example 51 with PopupWindow

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

the class ActivityFragment method composeNotes.

private void composeNotes() {
    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.compose_notes, null, false);
    final EditText ed = (EditText) v.findViewById(R.id.note_editor);
    final PopupWindow pw = new PopupWindow(getActivity());
    pw.setContentView(v);
    pw.setWindowLayoutMode(ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.FILL_PARENT);
    pw.setFocusable(true);
    pw.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE | WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    pw.setOutsideTouchable(false);
    pw.setTouchable(true);
    pw.setBackgroundDrawable(new BitmapDrawable());
    if (Util.GetScreenSizeAttribute(getActivity()) == 0)
        pw.showAsDropDown(m_btnFilter, 0, -40);
    else
        pw.showAtLocation(m_root, 0, 0, 0);
    Button btnSend = (Button) v.findViewById(R.id.btnSend);
    btnSend.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            sendActivityStatus(null, ed.getText().toString());
            FlurryAgent.logEvent("Activity Compose Status Message - 'Send' button pressed");
            pw.dismiss();
        }
    });
    Button btnClose = (Button) v.findViewById(R.id.btnClose);
    btnClose.setOnClickListener(new OnClickListener() {

        public void onClick(View v) {
            FlurryAgent.logEvent("Activity Compose Status Message - 'Close' button pressed");
            pw.dismiss();
        }
    });
}
Also used : EditText(android.widget.EditText) Button(android.widget.Button) LayoutInflater(android.view.LayoutInflater) PopupWindow(android.widget.PopupWindow) OnClickListener(android.view.View.OnClickListener) BitmapDrawable(android.graphics.drawable.BitmapDrawable) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) View(android.view.View)

Example 52 with PopupWindow

use of android.widget.PopupWindow in project bilibili-android-client by HotBitmapGG.

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

use of android.widget.PopupWindow in project AndroidChromium by JackyAndroid.

the class CardUnmaskPrompt method onTooltipIconClicked.

private void onTooltipIconClicked() {
    // the popup.
    if (mStoreLocallyTooltipPopup != null)
        return;
    mStoreLocallyTooltipPopup = new PopupWindow(mDialog.getContext());
    TextView text = new TextView(mDialog.getContext());
    text.setText(R.string.autofill_card_unmask_prompt_storage_tooltip);
    // Width is the dialog's width less the margins and padding around the checkbox and
    // icon.
    text.setWidth(mMainView.getWidth() - ViewCompat.getPaddingStart(mStoreLocallyCheckbox) - ViewCompat.getPaddingEnd(mStoreLocallyTooltipIcon) - MarginLayoutParamsCompat.getMarginStart((RelativeLayout.LayoutParams) mStoreLocallyCheckbox.getLayoutParams()) - MarginLayoutParamsCompat.getMarginEnd((RelativeLayout.LayoutParams) mStoreLocallyTooltipIcon.getLayoutParams()));
    text.setTextColor(Color.WHITE);
    Resources resources = mDialog.getContext().getResources();
    int hPadding = resources.getDimensionPixelSize(R.dimen.autofill_card_unmask_tooltip_horizontal_padding);
    int vPadding = resources.getDimensionPixelSize(R.dimen.autofill_card_unmask_tooltip_vertical_padding);
    text.setPadding(hPadding, vPadding, hPadding, vPadding);
    mStoreLocallyTooltipPopup.setContentView(text);
    mStoreLocallyTooltipPopup.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
    mStoreLocallyTooltipPopup.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
    mStoreLocallyTooltipPopup.setOutsideTouchable(true);
    mStoreLocallyTooltipPopup.setBackgroundDrawable(ApiCompatibilityUtils.getDrawable(resources, R.drawable.store_locally_tooltip_background));
    mStoreLocallyTooltipPopup.setOnDismissListener(new PopupWindow.OnDismissListener() {

        @Override
        public void onDismiss() {
            Handler h = new Handler();
            h.postDelayed(new Runnable() {

                @Override
                public void run() {
                    mStoreLocallyTooltipPopup = null;
                }
            }, 200);
        }
    });
    mStoreLocallyTooltipPopup.showAsDropDown(mStoreLocallyCheckbox, ViewCompat.getPaddingStart(mStoreLocallyCheckbox), 0);
    text.announceForAccessibility(text.getText());
}
Also used : PopupWindow(android.widget.PopupWindow) RelativeLayout(android.widget.RelativeLayout) Handler(android.os.Handler) TextView(android.widget.TextView) Resources(android.content.res.Resources)

Example 54 with PopupWindow

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

the class KeyboardView method showKey.

private void showKey(final int keyIndex) {
    final PopupWindow previewPopup = mPreviewPopup;
    final Key[] keys = mKeys;
    if (keyIndex < 0 || keyIndex >= mKeys.length)
        return;
    Key key = keys[keyIndex];
    if (key.icon != null) {
        mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon);
        mPreviewText.setText(null);
    } else {
        mPreviewText.setCompoundDrawables(null, null, null, null);
        mPreviewText.setText(getPreviewText(key));
        if (key.label.length() > 1 && key.codes.length < 2) {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
            mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
        } else {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
            mPreviewText.setTypeface(Typeface.DEFAULT);
        }
    }
    mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
    final int popupHeight = mPreviewHeight;
    LayoutParams lp = mPreviewText.getLayoutParams();
    if (lp != null) {
        lp.width = popupWidth;
        lp.height = popupHeight;
    }
    if (!mPreviewCentered) {
        mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
        mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
    } else {
        // TODO: Fix this if centering is brought back
        mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
        mPopupPreviewY = -mPreviewText.getMeasuredHeight();
    }
    mHandler.removeMessages(MSG_REMOVE_PREVIEW);
    getLocationInWindow(mCoordinates);
    // Offset may be zero
    mCoordinates[0] += mMiniKeyboardOffsetX;
    // Offset may be zero
    mCoordinates[1] += mMiniKeyboardOffsetY;
    // Set the preview background state
    mPreviewText.getBackground().setState(key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
    mPopupPreviewX += mCoordinates[0];
    mPopupPreviewY += mCoordinates[1];
    // If the popup cannot be shown above the key, put it on the side
    getLocationOnScreen(mCoordinates);
    if (mPopupPreviewY + mCoordinates[1] < 0) {
        // the right, offset by enough to see at least one key to the left/right.
        if (key.x + key.width <= getWidth() / 2) {
            mPopupPreviewX += (int) (key.width * 2.5);
        } else {
            mPopupPreviewX -= (int) (key.width * 2.5);
        }
        mPopupPreviewY += popupHeight;
    }
    if (previewPopup.isShowing()) {
        previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight);
    } else {
        previewPopup.setWidth(popupWidth);
        previewPopup.setHeight(popupHeight);
        previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY);
    }
    mPreviewText.setVisibility(VISIBLE);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) PopupWindow(android.widget.PopupWindow) Key(android.inputmethodservice.Keyboard.Key) Paint(android.graphics.Paint)

Example 55 with PopupWindow

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

the class KeyboardView method showKey.

private void showKey(final int keyIndex) {
    final PopupWindow previewPopup = mPreviewPopup;
    final Key[] keys = mKeys;
    if (keyIndex < 0 || keyIndex >= mKeys.length)
        return;
    Key key = keys[keyIndex];
    if (key.icon != null) {
        mPreviewText.setCompoundDrawables(null, null, null, key.iconPreview != null ? key.iconPreview : key.icon);
        mPreviewText.setText(null);
    } else {
        mPreviewText.setCompoundDrawables(null, null, null, null);
        mPreviewText.setText(getPreviewText(key));
        if (key.label.length() > 1 && key.codes.length < 2) {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mKeyTextSize);
            mPreviewText.setTypeface(Typeface.DEFAULT_BOLD);
        } else {
            mPreviewText.setTextSize(TypedValue.COMPLEX_UNIT_PX, mPreviewTextSizeLarge);
            mPreviewText.setTypeface(Typeface.DEFAULT);
        }
    }
    mPreviewText.measure(MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
    int popupWidth = Math.max(mPreviewText.getMeasuredWidth(), key.width + mPreviewText.getPaddingLeft() + mPreviewText.getPaddingRight());
    final int popupHeight = mPreviewHeight;
    LayoutParams lp = mPreviewText.getLayoutParams();
    if (lp != null) {
        lp.width = popupWidth;
        lp.height = popupHeight;
    }
    if (!mPreviewCentered) {
        mPopupPreviewX = key.x - mPreviewText.getPaddingLeft() + mPaddingLeft;
        mPopupPreviewY = key.y - popupHeight + mPreviewOffset;
    } else {
        // TODO: Fix this if centering is brought back
        mPopupPreviewX = 160 - mPreviewText.getMeasuredWidth() / 2;
        mPopupPreviewY = -mPreviewText.getMeasuredHeight();
    }
    mHandler.removeMessages(MSG_REMOVE_PREVIEW);
    getLocationInWindow(mCoordinates);
    // Offset may be zero
    mCoordinates[0] += mMiniKeyboardOffsetX;
    // Offset may be zero
    mCoordinates[1] += mMiniKeyboardOffsetY;
    // Set the preview background state
    mPreviewText.getBackground().setState(key.popupResId != 0 ? LONG_PRESSABLE_STATE_SET : EMPTY_STATE_SET);
    mPopupPreviewX += mCoordinates[0];
    mPopupPreviewY += mCoordinates[1];
    // If the popup cannot be shown above the key, put it on the side
    getLocationOnScreen(mCoordinates);
    if (mPopupPreviewY + mCoordinates[1] < 0) {
        // the right, offset by enough to see at least one key to the left/right.
        if (key.x + key.width <= getWidth() / 2) {
            mPopupPreviewX += (int) (key.width * 2.5);
        } else {
            mPopupPreviewX -= (int) (key.width * 2.5);
        }
        mPopupPreviewY += popupHeight;
    }
    if (previewPopup.isShowing()) {
        previewPopup.update(mPopupPreviewX, mPopupPreviewY, popupWidth, popupHeight);
    } else {
        previewPopup.setWidth(popupWidth);
        previewPopup.setHeight(popupHeight);
        previewPopup.showAtLocation(mPopupParent, Gravity.NO_GRAVITY, mPopupPreviewX, mPopupPreviewY);
    }
    mPreviewText.setVisibility(VISIBLE);
}
Also used : LayoutParams(android.view.ViewGroup.LayoutParams) PopupWindow(android.widget.PopupWindow) Key(android.inputmethodservice.Keyboard.Key) Paint(android.graphics.Paint)

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