use of android.graphics.drawable.RippleDrawable in project Slide by ccrama.
the class Peek method forceRippleAnimation.
private void forceRippleAnimation(View view, MotionEvent event) {
Drawable background = view.getBackground();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && background instanceof RippleDrawable) {
final RippleDrawable rippleDrawable = (RippleDrawable) background;
rippleDrawable.setState(new int[] { android.R.attr.state_pressed, android.R.attr.state_enabled });
rippleDrawable.setHotspot(event.getX(), event.getY());
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
rippleDrawable.setState(new int[] {});
}
}, 300);
}
}
use of android.graphics.drawable.RippleDrawable in project android_packages_apps_Dialer by LineageOS.
the class Bubble method update.
private void update() {
RippleDrawable backgroundRipple = (RippleDrawable) context.getResources().getDrawable(R.drawable.bubble_ripple_circle, context.getTheme());
int primaryTint = ColorUtils.compositeColors(context.getColor(R.color.bubble_primary_background_darken), currentInfo.getPrimaryColor());
backgroundRipple.getDrawable(0).setTint(primaryTint);
viewHolder.getPrimaryButton().setBackground(backgroundRipple);
setBackgroundDrawable(viewHolder.getFirstButton(), primaryTint);
setBackgroundDrawable(viewHolder.getSecondButton(), primaryTint);
setBackgroundDrawable(viewHolder.getThirdButton(), primaryTint);
int numButtons = currentInfo.getActions().size();
viewHolder.getThirdButton().setVisibility(numButtons < 3 ? View.GONE : View.VISIBLE);
viewHolder.getSecondButton().setVisibility(numButtons < 2 ? View.GONE : View.VISIBLE);
viewHolder.getPrimaryIcon().setImageIcon(currentInfo.getPrimaryIcon());
updatePrimaryIconAnimation();
viewHolder.getExpandedView().setBackgroundTintList(ColorStateList.valueOf(currentInfo.getPrimaryColor()));
updateButtonStates();
}
use of android.graphics.drawable.RippleDrawable in project android_packages_apps_Dialer by MoKee.
the class CallButtonFragment method compoundBackgroundDrawable.
/**
* Generate a RippleDrawable which will be the background for a compound button, i.e.
* a button with pressed and unpressed states. The unpressed state will be the same color
* as the rest of the call card, the pressed state will be the dark version of that color.
*/
private RippleDrawable compoundBackgroundDrawable(MaterialPalette palette) {
Resources res = getResources();
ColorStateList rippleColor = ColorStateList.valueOf(res.getColor(R.color.incall_accent_color));
StateListDrawable stateListDrawable = new StateListDrawable();
addSelectedAndFocused(res, stateListDrawable);
addFocused(res, stateListDrawable);
addSelected(res, stateListDrawable, palette);
addUnselected(res, stateListDrawable, palette);
return new RippleDrawable(rippleColor, stateListDrawable, null);
}
use of android.graphics.drawable.RippleDrawable in project android_packages_apps_Dialer by MoKee.
the class CallButtonFragment method updateColors.
public void updateColors() {
MaterialPalette themeColors = InCallPresenter.getInstance().getThemeColors();
if (mCurrentThemeColors != null && mCurrentThemeColors.equals(themeColors)) {
return;
}
CompoundButton[] compoundButtons = { mAudioButton, mMuteButton, mShowDialpadButton, mHoldButton, mSwitchCameraButton, mPauseVideoButton, mCallRecordButton };
for (CompoundButton button : compoundButtons) {
// Before applying background color, uncheck the button and re apply the
// saved checked state after background is changed. This is to fix
// an issue where button checked state is displayed wrongly after updating colors.
boolean isChecked = button.isChecked();
if (isChecked)
Log.d(this, "updateColors: button:" + button + " is in checked state");
button.setChecked(false);
final LayerDrawable layers = (LayerDrawable) button.getBackground();
final RippleDrawable btnCompoundDrawable = compoundBackgroundDrawable(themeColors);
layers.setDrawableByLayerId(R.id.compoundBackgroundItem, btnCompoundDrawable);
button.setChecked(isChecked);
button.requestLayout();
}
ImageButton[] normalButtons = { mSwapButton, mChangeToVideoButton, mChangeToVoiceButton, mAddCallButton, mMergeButton, mBlindTransferButton, mAssuredTransferButton, mConsultativeTransferButton, mOverflowButton };
for (ImageButton button : normalButtons) {
final LayerDrawable layers = (LayerDrawable) button.getBackground();
final RippleDrawable btnDrawable = backgroundDrawable(themeColors);
layers.setDrawableByLayerId(R.id.backgroundItem, btnDrawable);
button.requestLayout();
}
mCurrentThemeColors = themeColors;
}
use of android.graphics.drawable.RippleDrawable in project incubator-weex by apache.
the class WXComponent method prepareBackgroundRipple.
private Drawable prepareBackgroundRipple() {
try {
if (getStyles() != null && getStyles().getPesudoResetStyles() != null) {
Map<String, Object> resetStyles = getStyles().getPesudoResetStyles();
Object bgColor = resetStyles.get(Constants.Name.BACKGROUND_COLOR);
int colorInt = Color.TRANSPARENT;
if (bgColor != null) {
colorInt = WXResourceUtils.getColor(bgColor.toString(), Color.TRANSPARENT);
if (colorInt == Color.TRANSPARENT) {
return null;
}
}
Object bg = resetStyles.get(Constants.Name.BACKGROUND_COLOR + Constants.PSEUDO.ACTIVE);
if (bg == null) {
return null;
}
int rippleColor = WXResourceUtils.getColor(bg.toString(), colorInt);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
ColorStateList colorStateList = new ColorStateList(new int[][] { new int[] {} }, new int[] { rippleColor });
return new RippleDrawable(colorStateList, new ColorDrawable(colorInt), null) {
@Override
@SuppressLint("CanvasSize")
public void draw(@NonNull Canvas canvas) {
if (mBackgroundDrawable != null) {
Path border = mBackgroundDrawable.getContentPath(new RectF(0, 0, canvas.getWidth(), canvas.getHeight()));
canvas.clipPath(border);
}
super.draw(canvas);
}
};
}
}
} catch (Throwable t) {
WXLogUtils.w("Exception on create ripple: ", t);
}
return null;
}
Aggregations