diff options
author | Sean Pont <seanpont@google.com> | 2020-05-29 15:29:00 -0700 |
---|---|---|
committer | Sean Pont <seanpont@google.com> | 2020-05-29 15:29:00 -0700 |
commit | d9300f77619b3482f421976daf3580ad3d989b0f (patch) | |
tree | 2fedac58e1efde45a386931b50eea1c5401fafe2 | |
parent | 3c29c9b565d033460ecebde8d77a70ccaec79efd (diff) | |
download | QuickAccessWallet-d9300f77619b3482f421976daf3580ad3d989b0f.tar.gz |
Add light border to quick access wallet cards
Adds a 20% white border to wallet cards. On brightly colored cards, the
change is not visible. On dark and black cards, it highlights the border
and makes them visible against the black global actions menu background.
Fixes: 157247772
Test: atest QuickAccessWalletRoboTests
Change-Id: I1b0f9e9f059991c4f7dbdf578996023ffb793c0a
-rw-r--r-- | res/layout/wallet_card_view.xml | 4 | ||||
-rw-r--r-- | res/values/colors.xml | 2 | ||||
-rw-r--r-- | res/values/dimens.xml | 1 | ||||
-rw-r--r-- | src/com/android/systemui/plugin/globalactions/wallet/WalletCardView.java | 56 |
4 files changed, 60 insertions, 3 deletions
diff --git a/res/layout/wallet_card_view.xml b/res/layout/wallet_card_view.xml index 3e2ad4c..8c320a7 100644 --- a/res/layout/wallet_card_view.xml +++ b/res/layout/wallet_card_view.xml @@ -20,7 +20,7 @@ android:layout_width="wrap_content" android:layout_height="wrap_content"> - <androidx.cardview.widget.CardView + <com.android.systemui.plugin.globalactions.wallet.WalletCardView android:id="@+id/card" android:layout_width="match_parent" android:layout_height="match_parent" @@ -35,5 +35,5 @@ android:adjustViewBounds="true" android:contentDescription="@null" android:scaleType="fitXY" /> - </androidx.cardview.widget.CardView> + </com.android.systemui.plugin.globalactions.wallet.WalletCardView> </FrameLayout>
\ No newline at end of file diff --git a/res/values/colors.xml b/res/values/colors.xml index e393de6..e4e1271 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -22,5 +22,5 @@ <color name="wallet_primary_text">@color/wallet_grey_100</color> <color name="wallet_more_vert">@*android:color/foreground_material_dark</color> <color name="wallet_secondary_text">@color/wallet_grey_500</color> - + <color name="wallet_card_border">#33FFFFFF</color> </resources> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 4df223b..eeeeeb0 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -10,4 +10,5 @@ <dimen name="wallet_menu_vertical_offset">-36dp</dimen> <dimen name="wallet_menu_horizontal_offset">12dp</dimen> <dimen name="wallet_menu_padding_vertical">48dp</dimen> + <dimen name="wallet_card_border_width">1dp</dimen> </resources> diff --git a/src/com/android/systemui/plugin/globalactions/wallet/WalletCardView.java b/src/com/android/systemui/plugin/globalactions/wallet/WalletCardView.java new file mode 100644 index 0000000..e57a3b0 --- /dev/null +++ b/src/com/android/systemui/plugin/globalactions/wallet/WalletCardView.java @@ -0,0 +1,56 @@ +/* + * Copyright (C) 2020 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.systemui.plugin.globalactions.wallet; + +import android.content.Context; +import android.graphics.Canvas; +import android.graphics.Paint; +import android.util.AttributeSet; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.cardview.widget.CardView; + +/** + * A CardView that draws a light border around its contents. This is done to make black cards easier + * to see against the black background of the global actions menu. On more brightly colored cards, + * the border is barely visible. + */ +public class WalletCardView extends CardView { + private final Paint mBorderPaint; + + public WalletCardView(@NonNull Context context) { + this(context, null); + } + + public WalletCardView(@NonNull Context context, @Nullable AttributeSet attrs) { + super(context, attrs); + mBorderPaint = new Paint(); + mBorderPaint.setColor(context.getColor(R.color.wallet_card_border)); + mBorderPaint.setStrokeWidth( + context.getResources().getDimension(R.dimen.wallet_card_border_width)); + mBorderPaint.setStyle(Paint.Style.STROKE); + mBorderPaint.setAntiAlias(true); + } + + @Override + public void draw(Canvas canvas) { + super.draw(canvas); + float radius = getRadius(); + canvas.drawRoundRect(0, 0, getWidth(), getHeight(), radius, radius, mBorderPaint); + } +} |