Search in sources :

Example 16 with PopupWindow

use of android.widget.PopupWindow in project ADWLauncher2 by boombuler.

the class Launcher method showPreviews.

private void showPreviews(final View anchor, int start, int end) {
    final Resources resources = getResources();
    final Workspace workspace = mWorkspace;
    CellLayout cell = ((CellLayout) workspace.getChildAt(start));
    float max = workspace.getChildCount();
    final Rect r = new Rect();
    resources.getDrawable(R.drawable.preview_background).getPadding(r);
    int extraW = (int) ((r.left + r.right) * max);
    int extraH = r.top + r.bottom;
    int aW = cell.getWidth() - extraW;
    float w = aW / max;
    int width = cell.getWidth();
    int height = cell.getHeight();
    int x = cell.getLeftPadding();
    int y = cell.getTopPadding();
    width -= (x + cell.getRightPadding());
    height -= (y + cell.getBottomPadding());
    float scale = w / width;
    int count = end - start;
    final float sWidth = width * scale;
    float sHeight = height * scale;
    LinearLayout preview = new LinearLayout(this);
    PreviewTouchHandler handler = new PreviewTouchHandler(anchor);
    ArrayList<Bitmap> bitmaps = new ArrayList<Bitmap>(count);
    for (int i = start; i < end; i++) {
        ImageView image = new ImageView(this);
        cell = (CellLayout) workspace.getChildAt(i);
        final Bitmap bitmap = Bitmap.createBitmap((int) sWidth, (int) sHeight, Bitmap.Config.ARGB_8888);
        final Canvas c = new Canvas(bitmap);
        c.scale(scale, scale);
        c.translate(-cell.getLeftPadding(), -cell.getTopPadding());
        cell.dispatchDraw(c);
        image.setBackgroundDrawable(resources.getDrawable(R.drawable.preview_background));
        image.setImageBitmap(bitmap);
        image.setTag(i);
        image.setOnClickListener(handler);
        image.setOnFocusChangeListener(handler);
        image.setFocusable(true);
        if (i == mWorkspace.getCurrentScreen())
            image.requestFocus();
        preview.addView(image, LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
        bitmaps.add(bitmap);
    }
    final PopupWindow p = new PopupWindow(this);
    p.setContentView(preview);
    p.setWidth((int) (sWidth * count + extraW));
    p.setHeight((int) (sHeight + extraH));
    p.setAnimationStyle(R.style.AnimationPreview);
    p.setOutsideTouchable(true);
    p.setFocusable(true);
    p.setBackgroundDrawable(new ColorDrawable(0));
    p.showAsDropDown(anchor, 0, 0);
    p.setOnDismissListener(new PopupWindow.OnDismissListener() {

        public void onDismiss() {
            dismissPreview(anchor);
        }
    });
    anchor.setTag(p);
    anchor.setTag(R.id.workspace, preview);
    anchor.setTag(R.id.icon, bitmaps);
}
Also used : Rect(android.graphics.Rect) Canvas(android.graphics.Canvas) ArrayList(java.util.ArrayList) PopupWindow(android.widget.PopupWindow) Bitmap(android.graphics.Bitmap) ColorDrawable(android.graphics.drawable.ColorDrawable) Resources(android.content.res.Resources) ImageView(android.widget.ImageView) LinearLayout(android.widget.LinearLayout)

Example 17 with PopupWindow

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

the class SkillFragment 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) {
            final PopupWindow pw = Util.showPopup(getActivity(), R.layout.skill_settings, true, btnSettings, 5, 5);
            View v = pw.getContentView();
            Button btn = (Button) v.findViewById(R.id.btn_learning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentSkills();
                }
            });
            btn = (Button) v.findViewById(R.id.btn_unlearning);
            btn.setOnClickListener(new OnClickListener() {

                public void onClick(View v) {
                    pw.dismiss();
                    ((HomeScreen) getActivity()).setCurrentFragmentUnlearn();
                }
            });
        }
    });
}
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)

Example 18 with PopupWindow

use of android.widget.PopupWindow in project facebook-api-android-maven by avianey.

the class ToolTipPopup method show.

/**
     * Display this tool tip to the user
     */
public void show() {
    if (mAnchorViewRef.get() != null) {
        mPopupContent = new PopupContentView(mContext);
        TextView body = (TextView) mPopupContent.findViewById(R.id.com_facebook_tooltip_bubble_view_text_body);
        body.setText(mText);
        if (mStyle == Style.BLUE) {
            mPopupContent.bodyFrame.setBackgroundResource(R.drawable.com_facebook_tooltip_blue_background);
            mPopupContent.bottomArrow.setImageResource(R.drawable.com_facebook_tooltip_blue_bottomnub);
            mPopupContent.topArrow.setImageResource(R.drawable.com_facebook_tooltip_blue_topnub);
            mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_blue_xout);
        } else {
            mPopupContent.bodyFrame.setBackgroundResource(R.drawable.com_facebook_tooltip_black_background);
            mPopupContent.bottomArrow.setImageResource(R.drawable.com_facebook_tooltip_black_bottomnub);
            mPopupContent.topArrow.setImageResource(R.drawable.com_facebook_tooltip_black_topnub);
            mPopupContent.xOut.setImageResource(R.drawable.com_facebook_tooltip_black_xout);
        }
        final Window window = ((Activity) mContext).getWindow();
        final View decorView = window.getDecorView();
        final int decorWidth = decorView.getWidth();
        final int decorHeight = decorView.getHeight();
        registerObserver();
        mPopupContent.onMeasure(View.MeasureSpec.makeMeasureSpec(decorWidth, View.MeasureSpec.AT_MOST), View.MeasureSpec.makeMeasureSpec(decorHeight, View.MeasureSpec.AT_MOST));
        mPopupWindow = new PopupWindow(mPopupContent, mPopupContent.getMeasuredWidth(), mPopupContent.getMeasuredHeight());
        mPopupWindow.showAsDropDown(mAnchorViewRef.get());
        updateArrows();
        if (mNuxDisplayTime > 0) {
            mPopupContent.postDelayed(new Runnable() {

                @Override
                public void run() {
                    dismiss();
                }
            }, mNuxDisplayTime);
        }
        mPopupWindow.setTouchable(true);
        mPopupContent.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                dismiss();
            }
        });
    }
}
Also used : PopupWindow(android.widget.PopupWindow) Window(android.view.Window) PopupWindow(android.widget.PopupWindow) Activity(android.app.Activity) TextView(android.widget.TextView) TextView(android.widget.TextView) ImageView(android.widget.ImageView) View(android.view.View)

Example 19 with PopupWindow

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

the class KeyboardView method showPreview.

private void showPreview(int keyIndex) {
    int oldKeyIndex = mCurrentKeyIndex;
    final PopupWindow previewPopup = mPreviewPopup;
    mCurrentKeyIndex = keyIndex;
    // Release the old key and press the new key
    final Key[] keys = mKeys;
    if (oldKeyIndex != mCurrentKeyIndex) {
        if (oldKeyIndex != NOT_A_KEY && keys.length > oldKeyIndex) {
            Key oldKey = keys[oldKeyIndex];
            oldKey.onReleased(mCurrentKeyIndex == NOT_A_KEY);
            invalidateKey(oldKeyIndex);
            final int keyCode = oldKey.codes[0];
            sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT, keyCode);
            // TODO: We need to implement AccessibilityNodeProvider for this view.
            sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED, keyCode);
        }
        if (mCurrentKeyIndex != NOT_A_KEY && keys.length > mCurrentKeyIndex) {
            Key newKey = keys[mCurrentKeyIndex];
            newKey.onPressed();
            invalidateKey(mCurrentKeyIndex);
            final int keyCode = newKey.codes[0];
            sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER, keyCode);
            // TODO: We need to implement AccessibilityNodeProvider for this view.
            sendAccessibilityEventForUnicodeCharacter(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED, keyCode);
        }
    }
    // If key changed and preview is on ...
    if (oldKeyIndex != mCurrentKeyIndex && mShowPreview) {
        mHandler.removeMessages(MSG_SHOW_PREVIEW);
        if (previewPopup.isShowing()) {
            if (keyIndex == NOT_A_KEY) {
                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_REMOVE_PREVIEW), DELAY_AFTER_PREVIEW);
            }
        }
        if (keyIndex != NOT_A_KEY) {
            if (previewPopup.isShowing() && mPreviewText.getVisibility() == VISIBLE) {
                // Show right away, if it's already visible and finger is moving around
                showKey(keyIndex);
            } else {
                mHandler.sendMessageDelayed(mHandler.obtainMessage(MSG_SHOW_PREVIEW, keyIndex, 0), DELAY_BEFORE_PREVIEW);
            }
        }
    }
}
Also used : PopupWindow(android.widget.PopupWindow) Paint(android.graphics.Paint) Key(android.inputmethodservice.Keyboard.Key)

Example 20 with PopupWindow

use of android.widget.PopupWindow in project VitamioBundle by yixia.

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)

Aggregations

PopupWindow (android.widget.PopupWindow)133 View (android.view.View)66 TextView (android.widget.TextView)48 ColorDrawable (android.graphics.drawable.ColorDrawable)27 ImageView (android.widget.ImageView)24 Paint (android.graphics.Paint)22 Key (android.inputmethodservice.Keyboard.Key)14 AdapterView (android.widget.AdapterView)14 LinearLayout (android.widget.LinearLayout)14 LayoutInflater (android.view.LayoutInflater)13 Button (android.widget.Button)13 ListView (android.widget.ListView)13 Activity (android.app.Activity)12 BitmapDrawable (android.graphics.drawable.BitmapDrawable)12 OnClickListener (android.view.View.OnClickListener)11 ViewGroup (android.view.ViewGroup)11 Context (android.content.Context)10 Resources (android.content.res.Resources)10 EditText (android.widget.EditText)10 ScrollView (android.widget.ScrollView)10