Search in sources :

Example 6 with ColorDrawable

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;
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) StateListDrawable(android.graphics.drawable.StateListDrawable)

Example 7 with ColorDrawable

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();
            }
        }
    });
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) LayoutParams(android.view.WindowManager.LayoutParams) WindowManager(android.view.WindowManager)

Example 8 with ColorDrawable

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);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) StateListDrawable(android.graphics.drawable.StateListDrawable) AnimatorSet(android.animation.AnimatorSet) StateListDrawable(android.graphics.drawable.StateListDrawable) RemoteView(android.widget.RemoteViews.RemoteView) View(android.view.View)

Example 9 with ColorDrawable

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));
    }
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable)

Example 10 with ColorDrawable

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);
}
Also used : ColorDrawable(android.graphics.drawable.ColorDrawable) View(android.view.View) SmallTest(android.test.suitebuilder.annotation.SmallTest)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)519 View (android.view.View)112 Drawable (android.graphics.drawable.Drawable)102 BitmapDrawable (android.graphics.drawable.BitmapDrawable)67 ImageView (android.widget.ImageView)62 TextView (android.widget.TextView)55 Bitmap (android.graphics.Bitmap)51 AdapterView (android.widget.AdapterView)32 LinearLayout (android.widget.LinearLayout)32 Test (org.junit.Test)31 Canvas (android.graphics.Canvas)29 ListView (android.widget.ListView)27 FrameLayout (android.widget.FrameLayout)23 ViewGroup (android.view.ViewGroup)22 Handler (android.os.Handler)20 TransitionDrawable (android.graphics.drawable.TransitionDrawable)19 Paint (android.graphics.Paint)18 StateListDrawable (android.graphics.drawable.StateListDrawable)17 WindowManager (android.view.WindowManager)17 Point (android.graphics.Point)16