use of android.graphics.drawable.ColorDrawable in project MyDiary by erttyy8821.
the class ThemeManager method createTopicItemSelectBg.
private Drawable createTopicItemSelectBg(Context context) {
StateListDrawable stateListDrawable = new StateListDrawable();
stateListDrawable.addState(new int[] { android.R.attr.state_pressed }, new ColorDrawable(getThemeMainColor(context)));
stateListDrawable.addState(new int[] {}, new ColorDrawable(Color.WHITE));
return stateListDrawable;
}
use of android.graphics.drawable.ColorDrawable in project android_frameworks_base by ParanoidAndroid.
the class DreamService method attach.
/**
* Called when the Dream is ready to be shown.
*
* Must run on mHandler.
*
* @param windowToken A window token that will allow a window to be created in the correct layer.
*/
private final void attach(IBinder windowToken) {
if (mWindowToken != null) {
Slog.e(TAG, "attach() called when already attached with token=" + mWindowToken);
return;
}
if (mDebug)
Slog.v(TAG, "Attached on thread " + Thread.currentThread().getId());
if (mSandman == null) {
loadSandman();
}
mWindowToken = windowToken;
mWindow = PolicyManager.makeNewWindow(this);
mWindow.setCallback(this);
mWindow.requestFeature(Window.FEATURE_NO_TITLE);
mWindow.setBackgroundDrawable(new ColorDrawable(0xFF000000));
mWindow.setFormat(PixelFormat.OPAQUE);
if (mDebug)
Slog.v(TAG, String.format("Attaching window token: %s to window of type %s", windowToken, WindowManager.LayoutParams.TYPE_DREAM));
WindowManager.LayoutParams lp = mWindow.getAttributes();
lp.type = WindowManager.LayoutParams.TYPE_DREAM;
lp.token = windowToken;
lp.windowAnimations = com.android.internal.R.style.Animation_Dream;
lp.flags |= (WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN | WindowManager.LayoutParams.FLAG_LAYOUT_INSET_DECOR | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD | WindowManager.LayoutParams.FLAG_ALLOW_LOCK_WHILE_SCREEN_ON | (mFullscreen ? WindowManager.LayoutParams.FLAG_FULLSCREEN : 0) | (mScreenBright ? WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON : 0));
mWindow.setAttributes(lp);
if (mDebug)
Slog.v(TAG, "Created and attached window: " + mWindow);
mWindow.setWindowManager(null, windowToken, "dream", true);
mWindowManager = mWindow.getWindowManager();
if (mDebug)
Slog.v(TAG, "Window added on thread " + Thread.currentThread().getId());
try {
applySystemUiVisibilityFlags((mLowProfile ? View.SYSTEM_UI_FLAG_LOW_PROFILE : 0), View.SYSTEM_UI_FLAG_LOW_PROFILE);
getWindowManager().addView(mWindow.getDecorView(), mWindow.getAttributes());
} catch (Throwable t) {
Slog.w(TAG, "Crashed adding window view", t);
safelyFinish();
return;
}
// start it up
mHandler.post(new Runnable() {
@Override
public void run() {
try {
onDreamingStarted();
} catch (Throwable t) {
Slog.w(TAG, "Crashed in onDreamingStarted()", t);
safelyFinish();
}
}
});
}
use of android.graphics.drawable.ColorDrawable in project android_frameworks_base by ParanoidAndroid.
the class SizeAdaptiveLayout method initialize.
private void initialize() {
mModestyPanel = new View(getContext());
// If the SizeAdaptiveLayout has a solid background, use it as a transition hint.
Drawable background = getBackground();
if (background instanceof StateListDrawable) {
StateListDrawable sld = (StateListDrawable) background;
sld.setState(StateSet.WILD_CARD);
background = sld.getCurrent();
}
if (background instanceof ColorDrawable) {
mModestyPanel.setBackgroundDrawable(background);
} else {
mModestyPanel.setBackgroundColor(Color.BLACK);
}
SizeAdaptiveLayout.LayoutParams layout = new SizeAdaptiveLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
mModestyPanel.setLayoutParams(layout);
addView(mModestyPanel);
mFadePanel = ObjectAnimator.ofFloat(mModestyPanel, "alpha", 0f);
mFadeView = ObjectAnimator.ofFloat(null, "alpha", 0f);
mAnimatorListener = new BringToFrontOnEnd();
mTransitionAnimation = new AnimatorSet();
mTransitionAnimation.play(mFadeView).with(mFadePanel);
mTransitionAnimation.setDuration(CROSSFADE_TIME);
mTransitionAnimation.addListener(mAnimatorListener);
}
use of android.graphics.drawable.ColorDrawable in project android_frameworks_base by ParanoidAndroid.
the class View method setBackgroundColor.
/**
* Sets the background color for this view.
* @param color the color of the background
*/
@RemotableViewMethod
public void setBackgroundColor(int color) {
if (mBackground instanceof ColorDrawable) {
((ColorDrawable) mBackground.mutate()).setColor(color);
computeOpaqueFlags();
mBackgroundResource = 0;
} else {
setBackground(new ColorDrawable(color));
}
}
use of android.graphics.drawable.ColorDrawable in project android_frameworks_base by ParanoidAndroid.
the class SizeAdaptiveLayoutTest method testModestyPanelTracksStateListColor.
@SmallTest
public void testModestyPanelTracksStateListColor() {
inflate(R.layout.size_adaptive_color_statelist);
View panel = mSizeAdaptiveLayout.getModestyPanel();
assertEquals("ModestyPanel should have a ColorDrawable background", panel.getBackground().getClass(), ColorDrawable.class);
ColorDrawable panelColor = (ColorDrawable) panel.getBackground();
assertEquals("ModestyPanel color should match the SizeAdaptiveLayout", panelColor.getColor(), Color.RED);
}
Aggregations