Search in sources :

Example 71 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class DecorView method drawableChanged.

private void drawableChanged() {
    if (mChanging) {
        return;
    }
    setPadding(mFramePadding.left + mBackgroundPadding.left, mFramePadding.top + mBackgroundPadding.top, mFramePadding.right + mBackgroundPadding.right, mFramePadding.bottom + mBackgroundPadding.bottom);
    requestLayout();
    invalidate();
    int opacity = PixelFormat.OPAQUE;
    if (StackId.hasWindowShadow(mStackId)) {
        // If the window has a shadow, it must be translucent.
        opacity = PixelFormat.TRANSLUCENT;
    } else {
        // Note: If there is no background, we will assume opaque. The
        // common case seems to be that an application sets there to be
        // no background so it can draw everything itself. For that,
        // we would like to assume OPAQUE and let the app force it to
        // the slower TRANSLUCENT mode if that is really what it wants.
        Drawable bg = getBackground();
        Drawable fg = getForeground();
        if (bg != null) {
            if (fg == null) {
                opacity = bg.getOpacity();
            } else if (mFramePadding.left <= 0 && mFramePadding.top <= 0 && mFramePadding.right <= 0 && mFramePadding.bottom <= 0) {
                // If the frame padding is zero, then we can be opaque
                // if either the frame -or- the background is opaque.
                int fop = fg.getOpacity();
                int bop = bg.getOpacity();
                if (false)
                    Log.v(mLogTag, "Background opacity: " + bop + ", Frame opacity: " + fop);
                if (fop == PixelFormat.OPAQUE || bop == PixelFormat.OPAQUE) {
                    opacity = PixelFormat.OPAQUE;
                } else if (fop == PixelFormat.UNKNOWN) {
                    opacity = bop;
                } else if (bop == PixelFormat.UNKNOWN) {
                    opacity = fop;
                } else {
                    opacity = Drawable.resolveOpacity(fop, bop);
                }
            } else {
                // frame and background together will draw all pixels.
                if (false)
                    Log.v(mLogTag, "Padding: " + mFramePadding);
                opacity = PixelFormat.TRANSLUCENT;
            }
        }
        if (false)
            Log.v(mLogTag, "Background: " + bg + ", Frame: " + fg);
    }
    if (false)
        Log.v(mLogTag, "Selected default opacity: " + opacity);
    mDefaultOpacity = opacity;
    if (mFeatureId < 0) {
        mWindow.setDefaultWindowFormat(opacity);
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) Paint(android.graphics.Paint)

Example 72 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class DecorView method setFrame.

@Override
protected boolean setFrame(int l, int t, int r, int b) {
    boolean changed = super.setFrame(l, t, r, b);
    if (changed) {
        final Rect drawingBounds = mDrawingBounds;
        getDrawingRect(drawingBounds);
        Drawable fg = getForeground();
        if (fg != null) {
            final Rect frameOffsets = mFrameOffsets;
            drawingBounds.left += frameOffsets.left;
            drawingBounds.top += frameOffsets.top;
            drawingBounds.right -= frameOffsets.right;
            drawingBounds.bottom -= frameOffsets.bottom;
            fg.setBounds(drawingBounds);
            final Rect framePadding = mFramePadding;
            drawingBounds.left += framePadding.left - frameOffsets.left;
            drawingBounds.top += framePadding.top - frameOffsets.top;
            drawingBounds.right -= framePadding.right - frameOffsets.right;
            drawingBounds.bottom -= framePadding.bottom - frameOffsets.bottom;
        }
        Drawable bg = getBackground();
        if (bg != null) {
            bg.setBounds(drawingBounds);
        }
        if (SWEEP_OPEN_MENU) {
            if (mMenuBackground == null && mFeatureId < 0 && mWindow.getAttributes().height == WindowManager.LayoutParams.MATCH_PARENT) {
                mMenuBackground = getContext().getDrawable(R.drawable.menu_background);
            }
            if (mMenuBackground != null) {
                mMenuBackground.setBounds(drawingBounds.left, drawingBounds.bottom - 6, drawingBounds.right, drawingBounds.bottom + 20);
            }
        }
    }
    return changed;
}
Also used : Rect(android.graphics.Rect) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable)

Example 73 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class AnimationScaleListDrawable method isRunning.

@Override
public boolean isRunning() {
    boolean result = false;
    Drawable dr = getCurrent();
    if (dr != null && dr instanceof Animatable) {
        result = ((Animatable) dr).isRunning();
    }
    return result;
}
Also used : Drawable(android.graphics.drawable.Drawable) Animatable(android.graphics.drawable.Animatable)

Example 74 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class NekoLand method showNameDialog.

private void showNameDialog(final Cat cat) {
    final Context context = new ContextThemeWrapper(this, android.R.style.Theme_Material_Light_Dialog_NoActionBar);
    // TODO: Move to XML, add correct margins.
    View view = LayoutInflater.from(context).inflate(R.layout.edit_text, null);
    final EditText text = (EditText) view.findViewById(android.R.id.edit);
    text.setText(cat.getName());
    text.setSelection(cat.getName().length());
    final int size = context.getResources().getDimensionPixelSize(android.R.dimen.app_icon_size);
    Drawable catIcon = cat.createIcon(this, size, size).loadDrawable(this);
    new AlertDialog.Builder(context).setTitle(" ").setIcon(catIcon).setView(view).setPositiveButton(android.R.string.ok, new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            cat.logRename(context);
            cat.setName(text.getText().toString().trim());
            mPrefs.addCat(cat);
        }
    }).show();
}
Also used : Context(android.content.Context) EditText(android.widget.EditText) AlertDialog(android.app.AlertDialog) ContextThemeWrapper(android.view.ContextThemeWrapper) DialogInterface(android.content.DialogInterface) Drawable(android.graphics.drawable.Drawable) OnClickListener(android.content.DialogInterface.OnClickListener) ImageView(android.widget.ImageView) View(android.view.View) RecyclerView(android.support.v7.widget.RecyclerView) TextView(android.widget.TextView)

Example 75 with Drawable

use of android.graphics.drawable.Drawable in project platform_frameworks_base by android.

the class UserIconDrawable method setBadgeIfManagedUser.

public UserIconDrawable setBadgeIfManagedUser(Context context, int userId) {
    Drawable badge = null;
    boolean isManaged = context.getSystemService(DevicePolicyManager.class).getProfileOwnerAsUser(userId) != null;
    if (isManaged) {
        badge = getManagedUserBadgeDrawable(context);
    }
    return setBadge(badge);
}
Also used : Drawable(android.graphics.drawable.Drawable)

Aggregations

Drawable (android.graphics.drawable.Drawable)2742 BitmapDrawable (android.graphics.drawable.BitmapDrawable)527 View (android.view.View)316 ColorDrawable (android.graphics.drawable.ColorDrawable)283 Bitmap (android.graphics.Bitmap)244 ImageView (android.widget.ImageView)232 TextView (android.widget.TextView)220 Paint (android.graphics.Paint)213 LayerDrawable (android.graphics.drawable.LayerDrawable)212 Rect (android.graphics.Rect)204 StateListDrawable (android.graphics.drawable.StateListDrawable)152 Resources (android.content.res.Resources)143 AnimationDrawable (android.graphics.drawable.AnimationDrawable)137 PackageManager (android.content.pm.PackageManager)127 Context (android.content.Context)126 TypedArray (android.content.res.TypedArray)115 ClipDrawable (android.graphics.drawable.ClipDrawable)108 ViewGroup (android.view.ViewGroup)100 Test (org.junit.Test)100 ShapeDrawable (android.graphics.drawable.ShapeDrawable)94