use of android.graphics.drawable.RippleDrawable in project FloatingActionButton by Clans.
the class Label method onActionUp.
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
if (mUsingStyle) {
mBackgroundDrawable = getBackground();
}
if (mBackgroundDrawable instanceof StateListDrawable) {
StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
drawable.setState(new int[] {});
} else if (Util.hasLollipop() && mBackgroundDrawable instanceof RippleDrawable) {
RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
ripple.setState(new int[] {});
ripple.setHotspot(getMeasuredWidth() / 2, getMeasuredHeight() / 2);
ripple.setVisible(true, true);
}
// setPressed(false);
}
use of android.graphics.drawable.RippleDrawable in project MagicaSakura by Bilibili.
the class RippleDrawableInflateImpl method inflateDrawable.
@Override
public Drawable inflateDrawable(Context context, XmlPullParser parser, AttributeSet attrs) throws IOException, XmlPullParserException {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
final int innerDepth = parser.getDepth() + 1;
int type;
int depth;
int markIndex = -1;
int layerAttrUseCount = 0;
int drawableUseCount = 0;
int space = STEP;
//L,T,R,B,S,E,id
int[][] childLayersAttrs = new int[space][ATTRS.length];
Drawable[] drawables = new Drawable[space];
ColorStateList csl = DrawableUtils.getTintColorList(context, attrs, android.R.attr.color);
if (csl == null) {
return null;
}
while ((type = parser.next()) != XmlPullParser.END_DOCUMENT && ((depth = parser.getDepth()) >= innerDepth || type != XmlPullParser.END_TAG)) {
if (type != XmlPullParser.START_TAG) {
continue;
}
if (depth > innerDepth || !parser.getName().equals("item")) {
continue;
}
if (layerAttrUseCount >= childLayersAttrs.length) {
int[][] dstInt = new int[drawables.length + STEP][ATTRS.length];
System.arraycopy(childLayersAttrs, 0, dstInt, 0, childLayersAttrs.length);
childLayersAttrs = dstInt;
}
updateLayerAttrs(context, attrs, childLayersAttrs[layerAttrUseCount]);
layerAttrUseCount++;
Drawable drawable = DrawableUtils.getAttrDrawable(context, attrs, android.R.attr.drawable);
if (DrawableUtils.getAttrResourceId(context, attrs, android.R.attr.id, 0) == android.R.id.mask) {
markIndex = layerAttrUseCount - 1;
}
// element.
if (drawable == null) {
while ((type = parser.next()) == XmlPullParser.TEXT) {
}
if (type != XmlPullParser.START_TAG) {
throw new XmlPullParserException(parser.getPositionDescription() + ": <item> tag requires a 'drawable' attribute or " + "child tag defining a drawable");
}
drawable = DrawableUtils.createFromXmlInner(context, parser, attrs);
} else {
final ColorStateList cls = DrawableUtils.getTintColorList(context, attrs, R.attr.drawableTint);
if (cls != null) {
drawable = ThemeUtils.tintDrawable(drawable, cls, DrawableUtils.getTintMode(context, attrs, R.attr.drawableTintMode));
}
}
if (drawable != null) {
if (drawableUseCount >= drawables.length) {
Drawable[] dst = new Drawable[drawables.length + STEP];
System.arraycopy(drawables, 0, dst, 0, drawables.length);
drawables = dst;
}
drawables[drawableUseCount] = drawable;
drawableUseCount++;
}
}
if (drawables[0] == null || drawableUseCount != layerAttrUseCount) {
return null;
} else {
RippleDrawable rippleDrawable;
rippleDrawable = new RippleDrawable(csl, null, markIndex >= 0 ? drawables[markIndex] : null);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
int radius = DrawableUtils.getAttrDimensionPixelSize(context, attrs, android.R.attr.radius, RippleDrawable.RADIUS_AUTO);
rippleDrawable.setRadius(radius);
}
for (int i = 0; i < drawables.length; i++) {
if (i == markIndex) {
continue;
}
addLayer(rippleDrawable, drawables[i]);
int[] childLayersAttr = childLayersAttrs[i];
if (childLayersAttr[0] != 0 || childLayersAttr[1] != 0 || childLayersAttr[2] != 0 || childLayersAttr[3] != 0) {
rippleDrawable.setLayerInset(i, childLayersAttr[0], childLayersAttr[1], childLayersAttr[2], childLayersAttr[3]);
}
if (childLayersAttr[4] != 0) {
rippleDrawable.setId(i, childLayersAttr[4]);
}
}
return rippleDrawable;
}
}
return null;
}
use of android.graphics.drawable.RippleDrawable in project android_frameworks_base by crdroidandroid.
the class TaskViewHeader method bindToTask.
/**
* Binds the bar view to the task.
*/
public void bindToTask(Task t, boolean touchExplorationEnabled, boolean disabledInSafeMode) {
mTask = t;
int primaryColor = disabledInSafeMode ? mDisabledTaskBarBackgroundColor : t.colorPrimary;
if (mBackground.getColor() != primaryColor) {
updateBackgroundColor(primaryColor, mDimAlpha);
}
if (!mTitleView.getText().toString().equals(t.title)) {
mTitleView.setText(t.title);
}
mTitleView.setContentDescription(t.titleDescription);
mTitleView.setTextColor(t.useLightOnPrimaryColor ? mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightDismissDrawable : mDarkDismissDrawable);
mDismissButton.setContentDescription(t.dismissDescription);
mDismissButton.setOnClickListener(this);
mDismissButton.setClickable(false);
((RippleDrawable) mDismissButton.getBackground()).setForceSoftware(true);
updateLockTaskDrawable();
mLockTaskButton.setOnClickListener(this);
((RippleDrawable) mLockTaskButton.getBackground()).setForceSoftware(true);
mPinButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightPinDrawable : mDarkPinDrawable);
mPinButton.setOnClickListener(this);
mPinButton.setClickable(false);
((RippleDrawable) mPinButton.getBackground()).setForceSoftware(true);
// current task
if (mMoveTaskButton != null) {
if (t.isFreeformTask()) {
mMoveTaskTargetStackId = FULLSCREEN_WORKSPACE_STACK_ID;
mMoveTaskButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightFullscreenIcon : mDarkFullscreenIcon);
} else {
mMoveTaskTargetStackId = FREEFORM_WORKSPACE_STACK_ID;
mMoveTaskButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightFreeformIcon : mDarkFreeformIcon);
}
mMoveTaskButton.setOnClickListener(this);
mMoveTaskButton.setClickable(false);
((RippleDrawable) mMoveTaskButton.getBackground()).setForceSoftware(true);
}
if (Recents.getDebugFlags().isFastToggleRecentsEnabled()) {
if (mFocusTimerIndicator == null) {
mFocusTimerIndicator = (ProgressBar) Utilities.findViewStubById(this, R.id.focus_timer_indicator_stub).inflate();
}
mFocusTimerIndicator.getProgressDrawable().setColorFilter(getSecondaryColor(t.colorPrimary, t.useLightOnPrimaryColor), PorterDuff.Mode.SRC_IN);
}
// In accessibility, a single click on the focused app info button will show it
if (touchExplorationEnabled) {
mIconView.setContentDescription(t.appInfoDescription);
mIconView.setOnClickListener(this);
mIconView.setClickable(true);
}
}
use of android.graphics.drawable.RippleDrawable in project android_frameworks_base by crdroidandroid.
the class NotificationBackgroundView method setRippleColor.
public void setRippleColor(int color) {
if (mBackground instanceof RippleDrawable) {
RippleDrawable ripple = (RippleDrawable) mBackground;
ripple.setColor(ColorStateList.valueOf(color));
}
}
use of android.graphics.drawable.RippleDrawable in project platform_frameworks_base by android.
the class TaskViewHeader method bindToTask.
/**
* Binds the bar view to the task.
*/
public void bindToTask(Task t, boolean touchExplorationEnabled, boolean disabledInSafeMode) {
mTask = t;
int primaryColor = disabledInSafeMode ? mDisabledTaskBarBackgroundColor : t.colorPrimary;
if (mBackground.getColor() != primaryColor) {
updateBackgroundColor(primaryColor, mDimAlpha);
}
if (!mTitleView.getText().toString().equals(t.title)) {
mTitleView.setText(t.title);
}
mTitleView.setContentDescription(t.titleDescription);
mTitleView.setTextColor(t.useLightOnPrimaryColor ? mTaskBarViewLightTextColor : mTaskBarViewDarkTextColor);
mDismissButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightDismissDrawable : mDarkDismissDrawable);
mDismissButton.setContentDescription(t.dismissDescription);
mDismissButton.setOnClickListener(this);
mDismissButton.setClickable(false);
((RippleDrawable) mDismissButton.getBackground()).setForceSoftware(true);
// current task
if (mMoveTaskButton != null) {
if (t.isFreeformTask()) {
mMoveTaskTargetStackId = FULLSCREEN_WORKSPACE_STACK_ID;
mMoveTaskButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightFullscreenIcon : mDarkFullscreenIcon);
} else {
mMoveTaskTargetStackId = FREEFORM_WORKSPACE_STACK_ID;
mMoveTaskButton.setImageDrawable(t.useLightOnPrimaryColor ? mLightFreeformIcon : mDarkFreeformIcon);
}
mMoveTaskButton.setOnClickListener(this);
mMoveTaskButton.setClickable(false);
((RippleDrawable) mMoveTaskButton.getBackground()).setForceSoftware(true);
}
if (Recents.getDebugFlags().isFastToggleRecentsEnabled()) {
if (mFocusTimerIndicator == null) {
mFocusTimerIndicator = (ProgressBar) Utilities.findViewStubById(this, R.id.focus_timer_indicator_stub).inflate();
}
mFocusTimerIndicator.getProgressDrawable().setColorFilter(getSecondaryColor(t.colorPrimary, t.useLightOnPrimaryColor), PorterDuff.Mode.SRC_IN);
}
// In accessibility, a single click on the focused app info button will show it
if (touchExplorationEnabled) {
mIconView.setContentDescription(t.appInfoDescription);
mIconView.setOnClickListener(this);
mIconView.setClickable(true);
}
}
Aggregations