Search in sources :

Example 86 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project android_frameworks_base by DirtyUnicorns.

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);
    mLockTaskButton.setClickable(false);
    ((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);
    }
}
Also used : Paint(android.graphics.Paint) RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 87 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project android_frameworks_base by DirtyUnicorns.

the class NotificationBackgroundView method setRippleColor.

public void setRippleColor(int color) {
    if (mBackground instanceof RippleDrawable) {
        RippleDrawable ripple = (RippleDrawable) mBackground;
        ripple.setColor(ColorStateList.valueOf(color));
    }
}
Also used : RippleDrawable(android.graphics.drawable.RippleDrawable)

Example 88 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project android_frameworks_base by crdroidandroid.

the class PlatLogoActivity method onAttachedToWindow.

@Override
public void onAttachedToWindow() {
    final DisplayMetrics dm = getResources().getDisplayMetrics();
    final float dp = dm.density;
    final int size = (int) (Math.min(Math.min(dm.widthPixels, dm.heightPixels), 600 * dp) - 100 * dp);
    final ImageView im = new ImageView(this);
    final int pad = (int) (40 * dp);
    im.setPadding(pad, pad, pad, pad);
    im.setTranslationZ(20);
    im.setScaleX(0.5f);
    im.setScaleY(0.5f);
    im.setAlpha(0f);
    im.setBackground(new RippleDrawable(ColorStateList.valueOf(0xFFFFFFFF), getDrawable(getIntent().getBooleanExtra("is_lineage", false) ? com.android.internal.R.drawable.platlogo_lineage : com.android.internal.R.drawable.platlogo), null));
    //        im.setOutlineProvider(new ViewOutlineProvider() {
    //            @Override
    //            public void getOutline(View view, Outline outline) {
    //                outline.setOval(0, 0, view.getWidth(), view.getHeight());
    //            }
    //        });
    im.setClickable(true);
    im.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            im.setOnLongClickListener(new View.OnLongClickListener() {

                @Override
                public boolean onLongClick(View v) {
                    if (mTapCount < 5)
                        return false;
                    if (REVEAL_THE_NAME) {
                        final Drawable overlay = getDrawable(com.android.internal.R.drawable.platlogo_m);
                        overlay.setBounds(0, 0, v.getMeasuredWidth(), v.getMeasuredHeight());
                        im.getOverlay().clear();
                        im.getOverlay().add(overlay);
                        overlay.setAlpha(0);
                        ObjectAnimator.ofInt(overlay, "alpha", 0, 255).setDuration(500).start();
                    }
                    final ContentResolver cr = getContentResolver();
                    if (Settings.System.getLong(cr, Settings.System.EGG_MODE, 0) == 0) {
                        // For posterity: the moment this user unlocked the easter egg
                        try {
                            Settings.System.putLong(cr, Settings.System.EGG_MODE, System.currentTimeMillis());
                        } catch (RuntimeException e) {
                            Log.e("PlatLogoActivity", "Can't write settings", e);
                        }
                    }
                    im.post(new Runnable() {

                        @Override
                        public void run() {
                            try {
                                startActivity(new Intent(Intent.ACTION_MAIN).setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS).addCategory("com.android.internal.category.PLATLOGO"));
                            } catch (ActivityNotFoundException ex) {
                                Log.e("PlatLogoActivity", "No more eggs.");
                            }
                            if (FINISH)
                                finish();
                        }
                    });
                    return true;
                }
            });
            mTapCount++;
        }
    });
    // Enable hardware keyboard input for TV compatibility.
    im.setFocusable(true);
    im.requestFocus();
    im.setOnKeyListener(new View.OnKeyListener() {

        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode != KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
                ++mKeyCount;
                if (mKeyCount > 2) {
                    if (mTapCount > 5) {
                        im.performLongClick();
                    } else {
                        im.performClick();
                    }
                }
                return true;
            } else {
                return false;
            }
        }
    });
    mLayout.addView(im, new FrameLayout.LayoutParams(size, size, Gravity.CENTER));
    im.animate().scaleX(1f).scaleY(1f).alpha(1f).setInterpolator(mInterpolator).setDuration(500).setStartDelay(800).start();
}
Also used : Drawable(android.graphics.drawable.Drawable) GradientDrawable(android.graphics.drawable.GradientDrawable) ShapeDrawable(android.graphics.drawable.ShapeDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) Intent(android.content.Intent) DisplayMetrics(android.util.DisplayMetrics) ImageView(android.widget.ImageView) View(android.view.View) Paint(android.graphics.Paint) RippleDrawable(android.graphics.drawable.RippleDrawable) ContentResolver(android.content.ContentResolver) KeyEvent(android.view.KeyEvent) ActivityNotFoundException(android.content.ActivityNotFoundException) FrameLayout(android.widget.FrameLayout) ImageView(android.widget.ImageView)

Example 89 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project MaterialFBook by ZeeRooo.

the class FloatingActionButton method onActionUp.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
void onActionUp() {
    if (mBackgroundDrawable instanceof StateListDrawable) {
        StateListDrawable drawable = (StateListDrawable) mBackgroundDrawable;
        drawable.setState(new int[] { android.R.attr.state_enabled });
    } else if (Util.hasLollipop()) {
        RippleDrawable ripple = (RippleDrawable) mBackgroundDrawable;
        ripple.setState(new int[] { android.R.attr.state_enabled });
        ripple.setHotspot(calculateCenterX(), calculateCenterY());
        ripple.setVisible(true, true);
    }
}
Also used : StateListDrawable(android.graphics.drawable.StateListDrawable) RippleDrawable(android.graphics.drawable.RippleDrawable) TargetApi(android.annotation.TargetApi)

Example 90 with RippleDrawable

use of android.graphics.drawable.RippleDrawable in project HL4A by HL4A.

the class 绘画 method 生成背景.

public static Drawable 生成背景(Object $普通, Object $按下, Object $圆角) {
    if (设备.取SDK() > 21) {
        ShapeDrawable $波纹 = new ShapeDrawable();
        int $角 = 视图.检查大小($圆角);
        float[] $外矩形 = { $角, $角, $角, $角, $角, $角, $角, $角 };
        RectF $距离 = new RectF(0, 0, 0, 0);
        float[] $内矩形 = { 0, 0, 0, 0, 0, 0, 0, 0 };
        RoundRectShape $圆角形状 = new RoundRectShape($外矩形, $距离, $内矩形);
        $波纹.setShape($圆角形状);
        InsetDrawable $绘画 = new InsetDrawable($波纹, -1);
        ShapeDrawable $内容 = new ShapeDrawable();
        RoundRectShape $内容形状 = new RoundRectShape($外矩形, $距离, $内矩形);
        $内容.setShape($内容形状);
        $内容.getPaint().setColor(视图.检查颜色($普通));
        $内容.getPaint().setStyle(Paint.Style.FILL);
        RippleDrawable $涟漪 = new RippleDrawable(视图.创建单颜色列表($按下), $内容, $绘画);
        return $涟漪;
    } else {
        return new 按下变色绘画($普通, $按下);
    }
// return new 涟漪绘画($普通,$按下,颜色.白色);
}
Also used : RectF(android.graphics.RectF) RoundRectShape(android.graphics.drawable.shapes.RoundRectShape) 间.安卓.绘画.按下变色绘画(间.安卓.绘画.按下变色绘画) ShapeDrawable(android.graphics.drawable.ShapeDrawable) InsetDrawable(android.graphics.drawable.InsetDrawable) Paint(android.graphics.Paint) RippleDrawable(android.graphics.drawable.RippleDrawable)

Aggregations

RippleDrawable (android.graphics.drawable.RippleDrawable)115 StateListDrawable (android.graphics.drawable.StateListDrawable)60 Drawable (android.graphics.drawable.Drawable)49 ColorStateList (android.content.res.ColorStateList)47 GradientDrawable (android.graphics.drawable.GradientDrawable)30 TargetApi (android.annotation.TargetApi)26 ShapeDrawable (android.graphics.drawable.ShapeDrawable)23 View (android.view.View)21 Paint (android.graphics.Paint)20 ColorDrawable (android.graphics.drawable.ColorDrawable)20 SuppressLint (android.annotation.SuppressLint)15 TextView (android.widget.TextView)15 FrameLayout (android.widget.FrameLayout)12 LayerDrawable (android.graphics.drawable.LayerDrawable)11 ImageView (android.widget.ImageView)11 RLottieDrawable (org.telegram.ui.Components.RLottieDrawable)11 CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)10 ScamDrawable (org.telegram.ui.Components.ScamDrawable)10 Outline (android.graphics.Outline)9 BitmapDrawable (android.graphics.drawable.BitmapDrawable)9