summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--res/drawable/wallet_empty_state_bg.xml18
-rw-r--r--res/drawable/wallet_overflow_popup_bg.xml35
-rw-r--r--res/layout/empty_state_view.xml12
-rw-r--r--res/layout/wallet_more_item.xml2
-rw-r--r--res/layout/wallet_view.xml5
-rw-r--r--res/values/dimens.xml3
-rw-r--r--res/values/strings.xml4
-rw-r--r--src/com/android/systemui/plugin/globalactions/wallet/WalletPanelViewController.java2
-rw-r--r--src/com/android/systemui/plugin/globalactions/wallet/WalletPopupMenu.java99
-rw-r--r--src/com/android/systemui/plugin/globalactions/wallet/WalletView.java70
10 files changed, 167 insertions, 83 deletions
diff --git a/res/drawable/wallet_empty_state_bg.xml b/res/drawable/wallet_empty_state_bg.xml
index 170253c..94722d9 100644
--- a/res/drawable/wallet_empty_state_bg.xml
+++ b/res/drawable/wallet_empty_state_bg.xml
@@ -14,12 +14,20 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+<ripple xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="?android:attr/colorControlHighlight">
+ <item android:id="@android:id/mask">
+ <shape android:shape="rectangle">
+ <solid android:color="#000000" />
+ <corners android:radius="@dimen/wallet_empty_state_corner_radius" />
+ </shape>
+ </item>
<item>
<shape>
- <stroke android:width="1dp" android:color="#66FFFFFF"/>
- <corners android:radius="20dp"/>
+ <stroke
+ android:width="1dp"
+ android:color="#4DFFFFFF" />
+ <corners android:radius="@dimen/wallet_empty_state_corner_radius" />
</shape>
</item>
- <item android:drawable="?android:selectableItemBackground"/>
-</layer-list>
+</ripple> \ No newline at end of file
diff --git a/res/drawable/wallet_overflow_popup_bg.xml b/res/drawable/wallet_overflow_popup_bg.xml
new file mode 100644
index 0000000..6c145d2
--- /dev/null
+++ b/res/drawable/wallet_overflow_popup_bg.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ 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.
+ -->
+<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
+ <item>
+ <inset xmlns:android="http://schemas.android.com/apk/res/android"
+ android:insetBottom="12dp"
+ android:insetTop="12dp">
+ <shape android:shape="rectangle" />
+ </inset>
+ </item>
+
+ <item
+ android:top="-12dp"
+ android:bottom="-12dp">
+ <shape android:shape="rectangle">
+ <corners android:radius="8dp" />
+ <solid android:color="@color/wallet_grey_800" />
+ </shape>
+ </item>
+
+</layer-list>
+
diff --git a/res/layout/empty_state_view.xml b/res/layout/empty_state_view.xml
index 3bf0000..6563d57 100644
--- a/res/layout/empty_state_view.xml
+++ b/res/layout/empty_state_view.xml
@@ -22,12 +22,12 @@
android:id="@+id/empty_state"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:orientation="vertical"
- android:paddingTop="40dp"
- android:paddingBottom="40dp"
- android:layout_marginHorizontal="12dp"
- android:layout_marginTop="44dp"
+ android:layout_marginHorizontal="16dp"
+ android:layout_marginTop="32dp"
android:background="@drawable/wallet_empty_state_bg"
+ android:orientation="vertical"
+ android:paddingVertical="52dp"
+ android:theme="@style/Wallet.Theme"
android:visibility="gone">
<ImageView
@@ -39,7 +39,7 @@
android:scaleType="fitCenter"/>
<TextView
- style="@style/Wallet.TextAppearance.Title"
+ style="@style/Wallet.TextAppearance"
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
diff --git a/res/layout/wallet_more_item.xml b/res/layout/wallet_more_item.xml
index 3298fcf..24c1c7a 100644
--- a/res/layout/wallet_more_item.xml
+++ b/res/layout/wallet_more_item.xml
@@ -20,5 +20,5 @@
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingVertical="18dp"
- android:layout_gravity="start"/>
+ android:gravity="start"/>
diff --git a/res/layout/wallet_view.xml b/res/layout/wallet_view.xml
index a49399e..b855d89 100644
--- a/res/layout/wallet_view.xml
+++ b/res/layout/wallet_view.xml
@@ -24,6 +24,7 @@
android:id="@+id/card_carousel_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:layout_marginTop="28dp"
android:orientation="vertical"
android:clipChildren="false"
android:visibility="gone">
@@ -47,10 +48,10 @@
android:src="@drawable/ic_more_vert"
android:layout_gravity="center|end"
android:layout_width="@dimen/wallet_menu_btn_size"
- android:layout_height="48dp"
+ android:layout_height="@dimen/wallet_menu_btn_size"
android:padding="12dp"
android:tint="@color/wallet_more_vert"
- android:contentDescription="@string/global_actions_settings_description"
+ android:contentDescription="@string/accessibility_menu"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:theme="@style/Wallet.Theme" />
</FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index de0e4b9..4df223b 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -3,8 +3,11 @@
<dimen name="icon_size">18sp</dimen>
<dimen name="card_margin">16dp</dimen>
<dimen name="min_wallet_empty_height">208dp</dimen>
+ <dimen name="wallet_empty_state_corner_radius">12dp</dimen>
<dimen name="wallet_more_text_size">16sp</dimen>
<dimen name="wallet_more_padding">32dp</dimen>
<dimen name="wallet_menu_btn_size">48dp</dimen>
+ <dimen name="wallet_menu_vertical_offset">-36dp</dimen>
+ <dimen name="wallet_menu_horizontal_offset">12dp</dimen>
<dimen name="wallet_menu_padding_vertical">48dp</dimen>
</resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index d15a26d..d44c2c0 100644
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -2,8 +2,8 @@
<resources>
<!-- Message shown when launching Wallet before device is unlocked for the first time after a reboot [CHAR LIMIT=NONE] -->
<string name="error_user_locked">Unlock your phone to load your payment info</string>
- <!-- Content description for settings button. [CHAR LIMIT=NONE] -->
- <string name="global_actions_settings_description">Tap to view settings for cards &amp; passes in the power menu</string>
+ <!-- Content description of the menu button for accessibility (not shown on the screen). [CHAR LIMIT=NONE] -->
+ <string name="accessibility_menu">Menu</string>
<!-- Message shown when an unknown failure occurred when fetching cards. [CHAR LIMIT=NONE] -->
<string name="error_generic">There was a problem getting your cards, please try again later</string>
<!-- Overflow menu option directing user to System Settings [CHAR LIMIT=15]-->
diff --git a/src/com/android/systemui/plugin/globalactions/wallet/WalletPanelViewController.java b/src/com/android/systemui/plugin/globalactions/wallet/WalletPanelViewController.java
index 1699b5d..9442773 100644
--- a/src/com/android/systemui/plugin/globalactions/wallet/WalletPanelViewController.java
+++ b/src/com/android/systemui/plugin/globalactions/wallet/WalletPanelViewController.java
@@ -37,7 +37,7 @@ import android.util.Log;
import android.view.View;
import android.widget.FrameLayout;
-import com.android.systemui.plugin.globalactions.wallet.WalletView.OverflowItem;
+import com.android.systemui.plugin.globalactions.wallet.WalletPopupMenu.OverflowItem;
import com.android.systemui.plugins.GlobalActionsPanelPlugin;
import java.util.ArrayList;
diff --git a/src/com/android/systemui/plugin/globalactions/wallet/WalletPopupMenu.java b/src/com/android/systemui/plugin/globalactions/wallet/WalletPopupMenu.java
new file mode 100644
index 0000000..5d047d4
--- /dev/null
+++ b/src/com/android/systemui/plugin/globalactions/wallet/WalletPopupMenu.java
@@ -0,0 +1,99 @@
+/*
+ * 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.content.res.Resources;
+import android.view.ContextThemeWrapper;
+import android.view.Gravity;
+import android.view.View;
+import android.view.View.MeasureSpec;
+import android.view.WindowManager;
+import android.widget.ArrayAdapter;
+import android.widget.FrameLayout;
+import android.widget.ListPopupWindow;
+
+/**
+ * This is the overflow popup menu. To maintain visual consistency within Global Actions, this
+ * implementation and {@code com.android.systemui.globalactions.GlobalActionsPopupMenu} should stay
+ * in sync.
+ */
+class WalletPopupMenu extends ListPopupWindow {
+
+ private final Context mContext;
+ private final ArrayAdapter<OverflowItem> mAdapter;
+
+ WalletPopupMenu(Context context, View anchorView) {
+ super(new ContextThemeWrapper(context, R.style.Wallet_ListPopupWindow));
+ mContext = context;
+ setWindowLayoutType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
+ setModal(true);
+ setAnchorView(anchorView);
+ setDropDownGravity(Gravity.END);
+ mAdapter = new ArrayAdapter<>(context, R.layout.wallet_more_item);
+ setAdapter(mAdapter);
+ Resources res = context.getResources();
+ setBackgroundDrawable(res.getDrawable(R.drawable.wallet_overflow_popup_bg, null));
+ setVerticalOffset(res.getDimensionPixelSize(R.dimen.wallet_menu_vertical_offset));
+ int horizontalOffset = res.getDimensionPixelSize(R.dimen.wallet_menu_horizontal_offset);
+ boolean isLtr = res.getConfiguration().getLayoutDirection() == View.LAYOUT_DIRECTION_LTR;
+ setHorizontalOffset(isLtr ? -horizontalOffset : horizontalOffset);
+ setOnItemClickListener((parent, view, position, id) -> {
+ mAdapter.getItem(position).onClickListener.run();
+ dismiss();
+ });
+ }
+
+ void setMenuItems(OverflowItem[] menuItems) {
+ mAdapter.clear();
+ mAdapter.addAll(menuItems);
+ setContentWidth(measureContentWidth());
+ }
+
+ private int measureContentWidth() {
+ int screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels;
+ // width should be between [.5, .9] of screen
+ int width = Math.round(screenWidth * 0.5f);
+ int widthMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ int heightMeasureSpec = MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED);
+ int count = mAdapter.getCount();
+ FrameLayout measureParent = new FrameLayout(mContext);
+ View itemView = null;
+ for (int i = 0; i < count; i++) {
+ itemView = mAdapter.getView(i, itemView, measureParent);
+ itemView.measure(widthMeasureSpec, heightMeasureSpec);
+ width = Math.max(itemView.getMeasuredWidth(), width);
+ }
+ int maxWidth = Math.round(screenWidth * 0.9f);
+ return Math.min(maxWidth, width);
+ }
+
+ static class OverflowItem {
+ final CharSequence label;
+ final Runnable onClickListener;
+
+ OverflowItem(CharSequence label, Runnable onClickListener) {
+ this.label = label;
+ this.onClickListener = onClickListener;
+ }
+
+ @Override
+ public String toString() {
+ return label.toString();
+ }
+ }
+}
diff --git a/src/com/android/systemui/plugin/globalactions/wallet/WalletView.java b/src/com/android/systemui/plugin/globalactions/wallet/WalletView.java
index 2cbbd12..6aeeea1 100644
--- a/src/com/android/systemui/plugin/globalactions/wallet/WalletView.java
+++ b/src/com/android/systemui/plugin/globalactions/wallet/WalletView.java
@@ -21,25 +21,21 @@ import static com.android.systemui.plugin.globalactions.wallet.WalletCardCarouse
import android.annotation.Nullable;
import android.content.Context;
-import android.content.res.Resources;
-import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.text.TextUtils;
import android.util.AttributeSet;
-import android.view.ContextThemeWrapper;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
-import android.view.WindowManager;
import android.view.animation.AnimationUtils;
import android.view.animation.Interpolator;
-import android.widget.ArrayAdapter;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListPopupWindow;
import android.widget.TextView;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.systemui.plugin.globalactions.wallet.WalletPopupMenu.OverflowItem;
import java.util.List;
@@ -60,8 +56,7 @@ class WalletView extends FrameLayout implements WalletCardCarousel.OnCardScrollL
private final TextView mErrorView;
private final ViewGroup mEmptyStateView;
private final ImageView mOverflowButton;
- private final ArrayAdapter<OverflowItem> mOverflowAdapter;
- private final ListPopupWindow mOverflowPopup;
+ private final WalletPopupMenu mOverflowPopup;
private final int mIconSizePx;
private final Interpolator mInInterpolator;
private final Interpolator mOutInterpolator;
@@ -80,8 +75,7 @@ class WalletView extends FrameLayout implements WalletCardCarousel.OnCardScrollL
mCardCarousel.setCardScrollListener(this);
mCardLabel = requireViewById(R.id.card_label);
mOverflowButton = requireViewById(R.id.menu_btn);
- mOverflowAdapter = new ArrayAdapter<>(context, R.layout.wallet_more_item);
- mOverflowPopup = createOverflowPopup(context);
+ mOverflowPopup = new WalletPopupMenu(context, mOverflowButton);
mOverflowButton.setOnClickListener(v -> mOverflowPopup.show());
mErrorView = requireViewById(R.id.error_view);
mEmptyStateView = requireViewById(R.id.empty_state);
@@ -122,9 +116,7 @@ class WalletView extends FrameLayout implements WalletCardCarousel.OnCardScrollL
void showCardCarousel(
List<WalletCardViewInfo> data, int selectedIndex, OverflowItem[] menuItems) {
boolean shouldAnimate = mCardCarousel.setData(data, selectedIndex);
- mOverflowAdapter.clear();
- mOverflowAdapter.addAll(menuItems);
- updateOverflowPopupWidth(menuItems);
+ mOverflowPopup.setMenuItems(menuItems);
mOverflowButton.setVisibility(menuItems.length == 0 ? GONE : VISIBLE);
mCardCarouselContainer.setVisibility(VISIBLE);
mErrorView.setVisibility(GONE);
@@ -194,60 +186,6 @@ class WalletView extends FrameLayout implements WalletCardCarousel.OnCardScrollL
setVisibility(GONE);
}
- static class OverflowItem {
- final CharSequence label;
- final Runnable onClickListener;
-
- OverflowItem(CharSequence label, Runnable onClickListener) {
- this.label = label;
- this.onClickListener = onClickListener;
- }
-
- @Override
- public String toString() {
- return label.toString();
- }
- }
-
- private ListPopupWindow createOverflowPopup(Context context) {
- ListPopupWindow popup = new ListPopupWindow(
- new ContextThemeWrapper(context, R.style.Wallet_ListPopupWindow));
- popup.setWindowLayoutType(WindowManager.LayoutParams.TYPE_VOLUME_OVERLAY);
- popup.setModal(true);
- popup.setAnchorView(mOverflowButton);
- popup.setAdapter(mOverflowAdapter);
- int overflowIconSize = getResources().getDimensionPixelSize(R.dimen.wallet_menu_btn_size);
- popup.setVerticalOffset(-overflowIconSize / 2);
- popup.setOnItemClickListener((parent, view, position, id) -> {
- mOverflowAdapter.getItem(position).onClickListener.run();
- popup.dismiss();
- });
- return popup;
- }
-
- private void updateOverflowPopupWidth(OverflowItem[] overflowItems) {
- if (overflowItems.length == 0) {
- return;
- }
- Paint paint = new Paint();
- float textSize = getResources().getDimension(R.dimen.wallet_more_text_size);
- paint.setTextSize(textSize);
- float maxItemWidth = 0;
- for (OverflowItem item : overflowItems) {
- maxItemWidth = Math.max(maxItemWidth, paint.measureText(item.toString()));
- }
- int itemPadding = getResources().getDimensionPixelSize(R.dimen.wallet_more_padding);
- float width = maxItemWidth + itemPadding * 2;
- // width should be between [.5, .9] of screen
- int screenWidth = Resources.getSystem().getDisplayMetrics().widthPixels;
- width = Math.max(screenWidth * 0.5f, width);
- width = Math.min(screenWidth * 0.9f, width);
- int contentWidth = Math.round(width);
- mOverflowPopup.setContentWidth(contentWidth);
- int overflowIconSize = getResources().getDimensionPixelSize(R.dimen.wallet_menu_btn_size);
- mOverflowPopup.setHorizontalOffset(overflowIconSize / 2 - contentWidth);
- }
-
void hideErrorMessage() {
mErrorView.setVisibility(GONE);
}