Search in sources :

Example 1 with PopupWindow

use of android.widget.PopupWindow in project Android-Iconics by mikepenz.

the class IconsFragment method configAdapter.

private void configAdapter() {
    //our popup on touch
    mAdapter.withOnTouchListener(new FastAdapter.OnTouchListener<IconItem>() {

        @Override
        public boolean onTouch(View v, MotionEvent motionEvent, IAdapter<IconItem> adapter, IconItem item, int position) {
            int a = motionEvent.getAction();
            if (a == MotionEvent.ACTION_DOWN) {
                if (popup != null && popup.isShowing()) {
                    popup.dismiss();
                }
                IconicsDrawable icon = new IconicsDrawable(v.getContext()).icon(item.getIcon()).sizeDp(144).paddingDp(8).backgroundColor(Color.parseColor("#DDFFFFFF")).roundedCornersDp(12);
                ImageView imageView = new ImageView(v.getContext());
                imageView.setImageDrawable(icon);
                int size = (int) UIUtils.convertDpToPixel(144, v.getContext());
                popup = new PopupWindow(imageView, size, size);
                popup.showAsDropDown(v);
                //copy to clipboard
                if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
                    android.text.ClipboardManager clipboard = (android.text.ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
                    clipboard.setText(icon.getIcon().getFormattedName());
                } else {
                    android.content.ClipboardManager clipboard = (android.content.ClipboardManager) v.getContext().getSystemService(Context.CLIPBOARD_SERVICE);
                    android.content.ClipData clip = android.content.ClipData.newPlainText("Android-Iconics icon", icon.getIcon().getFormattedName());
                    clipboard.setPrimaryClip(clip);
                }
            } else if (a == MotionEvent.ACTION_UP || a == MotionEvent.ACTION_CANCEL || a == MotionEvent.ACTION_OUTSIDE) {
                if (popup != null && popup.isShowing()) {
                    popup.dismiss();
                }
            }
            return false;
        }
    });
    mAdapter.withOnBindViewHolderListener(new FastAdapter.OnBindViewHolderListener() {

        @Override
        public void onBindViewHolder(RecyclerView.ViewHolder viewHolder, int position, List payloads) {
            IconItem.ViewHolder holder = (IconItem.ViewHolder) viewHolder;
            //as we overwrite the default listener
            mAdapter.getItem(position).bindView(holder, payloads);
            if (randomize) {
                holder.image.setColorRes(getRandomColor(position));
                holder.image.setPaddingDp(random.nextInt(12));
                holder.image.setContourWidthDp(random.nextInt(2));
                holder.image.setContourColor(getRandomColor(position - 2));
                int y = random.nextInt(10);
                if (y % 4 == 0) {
                    holder.image.setBackgroundColorRes(getRandomColor(position - 4));
                    holder.image.setRoundedCornersDp(2 + random.nextInt(10));
                }
            }
        }

        @Override
        public void unBindViewHolder(RecyclerView.ViewHolder viewHolder, int position) {
            IconItem item = mAdapter.getItem(position);
            if (item != null) {
                item.unbindView((IconItem.ViewHolder) viewHolder);
            }
        }
    });
}
Also used : PopupWindow(android.widget.PopupWindow) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) MotionEvent(android.view.MotionEvent) IconItem(com.mikepenz.iconics.sample.item.IconItem) RecyclerView(android.support.v7.widget.RecyclerView) AbstractList(java.util.AbstractList) ArrayList(java.util.ArrayList) List(java.util.List) FastAdapter(com.mikepenz.fastadapter.FastAdapter) ImageView(android.widget.ImageView) Context(android.content.Context) IconicsDrawable(com.mikepenz.iconics.IconicsDrawable)

Example 2 with PopupWindow

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

the class Window method getSystemDecorations.

/**
     * Returns the system window decorations if the implementation sets
     * {@link #FLAG_DECORATION_SYSTEM}.
     * <p/>
     * <p/>
     * The system window decorations support hiding, closing, moving, and
     * resizing.
     *
     * @return The frame view containing the system window decorations.
     */
@SuppressWarnings("deprecation")
private View getSystemDecorations() {
    final View decorations = mLayoutInflater.inflate(R.layout.system_window_decorators, null);
    try {
        ImageView icon = (ImageView) decorations.findViewById(R.id.addIV);
        icon.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                new Thread(mContext.getAddRunnable(id)).start();
            }
        });
        // close
        ImageView close = (ImageView) decorations.findViewById(R.id.closeIV);
        close.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent intent = StandOutWindow.getCloseIntent(mContext, mContext.getWindow(id).cls, id);
                mContext.startService(intent);
            }
        });
        // close
        ImageView drop = (ImageView) decorations.findViewById(R.id.dropIV);
        drop.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                PopupWindow dropDown = getDropDownList();
                dropDown.showAsDropDown(v);
            }
        });
        // move
        View titlebar = decorations.findViewById(R.id.titlebar);
        titlebar.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // handle dragging to move
                boolean consumed = mContext.onTouchHandleMove(id, Window.this, v, event);
                return consumed;
            }
        });
        // resize
        View corner = decorations.findViewById(R.id.corner);
        corner.setOnTouchListener(new OnTouchListener() {

            @Override
            public boolean onTouch(View v, MotionEvent event) {
                // handle dragging to move
                boolean consumed = mContext.onTouchHandleResize(id, Window.this, v, event);
                return consumed;
            }
        });
        // set window appearance and behavior based on flags
        if (Utils.isSet(flags, StandOutFlags.FLAG_WINDOW_HIDE_ENABLE)) {
        // hide.setVisibility(View.VISIBLE);
        }
        if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_CLOSE_DISABLE)) {
            close.setVisibility(View.GONE);
        }
        if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_MOVE_DISABLE)) {
            titlebar.setOnTouchListener(null);
        }
        if (Utils.isSet(flags, StandOutFlags.FLAG_DECORATION_RESIZE_DISABLE)) {
            corner.setVisibility(View.GONE);
        }
    } catch (Exception e) {
    }
    return decorations;
}
Also used : PopupWindow(android.widget.PopupWindow) Intent(android.content.Intent) ImageView(android.widget.ImageView) ImageView(android.widget.ImageView) View(android.view.View) TextView(android.widget.TextView) ScrollView(android.widget.ScrollView) MotionEvent(android.view.MotionEvent)

Example 3 with PopupWindow

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

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

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

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

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

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)

Aggregations

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