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);
}
}
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;
}
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;
}
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();
}
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);
}
Aggregations