Merge "Polish Wallet empty state view." into sc-dev
diff --git a/packages/SystemUI/res/layout/wallet_empty_state.xml b/packages/SystemUI/res/layout/wallet_empty_state.xml
index cc2e781..d41679a 100644
--- a/packages/SystemUI/res/layout/wallet_empty_state.xml
+++ b/packages/SystemUI/res/layout/wallet_empty_state.xml
@@ -22,7 +22,7 @@
android:id="@+id/wallet_empty_state"
android:layout_width="match_parent"
android:layout_height="match_parent"
- android:layout_marginHorizontal="16dp"
+ android:layout_marginHorizontal="48dp"
android:layout_marginTop="48dp"
android:background="@drawable/wallet_empty_state_bg"
android:orientation="vertical"
diff --git a/packages/SystemUI/res/layout/wallet_fullscreen.xml b/packages/SystemUI/res/layout/wallet_fullscreen.xml
index aceefee..71006f0 100644
--- a/packages/SystemUI/res/layout/wallet_fullscreen.xml
+++ b/packages/SystemUI/res/layout/wallet_fullscreen.xml
@@ -54,9 +54,12 @@
android:id="@+id/label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- style="@style/Wallet.TextAppearance"
+ android:layout_marginHorizontal="48dp"
+ android:textColor="?androidprv:attr/textColorPrimary"
android:textAlignment="center"/>
+ <include layout="@layout/wallet_empty_state"/>
+
<com.android.systemui.wallet.ui.WalletCardCarousel
android:id="@+id/card_carousel"
android:layout_width="match_parent"
@@ -97,8 +100,6 @@
android:layout_marginVertical="24dp"/>
</LinearLayout>
- <include layout="@layout/wallet_empty_state"/>
-
<TextView
android:id="@+id/error_view"
android:layout_width="match_parent"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index e2a49a1..3fe6acd 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1653,6 +1653,8 @@
<!-- Wallet strings -->
<!-- Wallet empty state, title [CHAR LIMIT=32] -->
<string name="wallet_title">Wallet</string>
+ <!-- Wallet empty state label. [CHAR LIMIT=NONE] -->
+ <string name="wallet_empty_state_label">Get set up to make faster, more secure purchases with your phone</string>
<!-- Label of the button at the bottom prompting user enter wallet app. [CHAR LIMIT=NONE] -->
<string name="wallet_app_button_label">Show all</string>
<!-- Label of the button underneath the card carousel prompting user unlock device. [CHAR LIMIT=NONE] -->
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
index 64aec5e..7fab0f5 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/QuickAccessWalletTile.java
@@ -56,7 +56,6 @@
import com.android.systemui.wallet.ui.WalletActivity;
import java.util.List;
-import java.util.concurrent.Executor;
import javax.inject.Inject;
@@ -71,7 +70,6 @@
private final KeyguardStateController mKeyguardStateController;
private final PackageManager mPackageManager;
private final SecureSettings mSecureSettings;
- private final Executor mExecutor;
private final QuickAccessWalletController mController;
private final FeatureFlags mFeatureFlags;
@@ -91,7 +89,6 @@
KeyguardStateController keyguardStateController,
PackageManager packageManager,
SecureSettings secureSettings,
- @Main Executor executor,
QuickAccessWalletController quickAccessWalletController,
FeatureFlags featureFlags) {
super(host, backgroundLooper, mainHandler, falsingManager, metricsLogger,
@@ -100,7 +97,6 @@
mKeyguardStateController = keyguardStateController;
mPackageManager = packageManager;
mSecureSettings = secureSettings;
- mExecutor = executor;
mFeatureFlags = featureFlags;
}
@@ -118,6 +114,7 @@
if (listening) {
mController.setupWalletChangeObservers(mCardRetriever, DEFAULT_PAYMENT_APP_CHANGE);
if (!mController.getWalletClient().isWalletServiceAvailable()) {
+ Log.i(TAG, "QAW service is unavailable, recreating the wallet client.");
mController.reCreateWalletClient();
}
mController.queryWalletCards(mCardRetriever);
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
index 9d0cc6a..65f236b 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/controller/QuickAccessWalletController.java
@@ -25,7 +25,6 @@
import android.service.quickaccesswallet.GetWalletCardsRequest;
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.QuickAccessWalletClientImpl;
-import android.util.Log;
import com.android.systemui.R;
import com.android.systemui.dagger.SysUISingleton;
@@ -143,10 +142,6 @@
*/
public void queryWalletCards(
QuickAccessWalletClient.OnWalletCardsRetrievedCallback cardsRetriever) {
- if (!mWalletEnabled) {
- Log.w(TAG, "QuickAccessWallet is unavailable, unable to query cards.");
- return;
- }
int cardWidth =
mContext.getResources().getDimensionPixelSize(R.dimen.wallet_tile_card_view_width);
int cardHeight =
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
index c6123e7..236954b 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletActivity.java
@@ -24,6 +24,7 @@
import android.os.Bundle;
import android.os.Handler;
import android.service.quickaccesswallet.QuickAccessWalletClient;
+import android.service.quickaccesswallet.WalletServiceEvent;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
@@ -51,7 +52,8 @@
/**
* Displays Wallet carousel screen inside an activity.
*/
-public class WalletActivity extends LifecycleActivity {
+public class WalletActivity extends LifecycleActivity implements
+ QuickAccessWalletClient.WalletServiceEventListener {
private static final String TAG = "WalletActivity";
private final KeyguardStateController mKeyguardStateController;
@@ -63,6 +65,8 @@
private final UserTracker mUserTracker;
private final StatusBarKeyguardViewManager mKeyguardViewManager;
private WalletScreenController mWalletScreenController;
+ private QuickAccessWalletClient mWalletClient;
+ private boolean mHasRegisteredListener;
@Inject
public WalletActivity(
@@ -102,11 +106,11 @@
getActionBar().setHomeActionContentDescription(R.string.accessibility_desc_close);
WalletView walletView = requireViewById(R.id.wallet_view);
- QuickAccessWalletClient walletClient = QuickAccessWalletClient.create(this);
+ mWalletClient = QuickAccessWalletClient.create(this);
mWalletScreenController = new WalletScreenController(
this,
walletView,
- walletClient,
+ mWalletClient,
mActivityStarter,
mExecutor,
mHandler,
@@ -116,7 +120,7 @@
walletView.getAppButton().setOnClickListener(
v -> {
- if (walletClient.createWalletIntent() == null) {
+ if (mWalletClient.createWalletIntent() == null) {
Log.w(TAG, "Unable to create wallet app intent.");
return;
}
@@ -127,12 +131,12 @@
if (mKeyguardStateController.isUnlocked()) {
mActivityStarter.startActivity(
- walletClient.createWalletIntent(), true);
+ mWalletClient.createWalletIntent(), true);
finish();
} else {
mKeyguardDismissUtil.executeWhenUnlocked(() -> {
mActivityStarter.startActivity(
- walletClient.createWalletIntent(), true);
+ mWalletClient.createWalletIntent(), true);
finish();
return false;
}, false, true);
@@ -154,6 +158,11 @@
@Override
protected void onStart() {
super.onStart();
+ if (!mHasRegisteredListener) {
+ // Listener is registered even when device is locked. Should only be registered once.
+ mWalletClient.addWalletServiceEventListener(this);
+ mHasRegisteredListener = true;
+ }
mKeyguardStateController.addCallback(mWalletScreenController);
}
@@ -178,6 +187,24 @@
return super.onCreateOptionsMenu(menu);
}
+ /**
+ * Implements {@link QuickAccessWalletClient.WalletServiceEventListener}. Called when the wallet
+ * application propagates an event, such as an NFC tap, to the quick access wallet view.
+ */
+ @Override
+ public void onWalletServiceEvent(WalletServiceEvent event) {
+ switch (event.getEventType()) {
+ case WalletServiceEvent.TYPE_NFC_PAYMENT_STARTED:
+ finish();
+ break;
+ case WalletServiceEvent.TYPE_WALLET_CARDS_UPDATED:
+ mWalletScreenController.queryWalletCards();
+ break;
+ default:
+ Log.w(TAG, "onWalletServiceEvent: Unknown event type");
+ }
+ }
+
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
int itemId = item.getItemId();
@@ -198,6 +225,8 @@
protected void onDestroy() {
mKeyguardStateController.removeCallback(mWalletScreenController);
mWalletScreenController.onDismissed();
+ mWalletClient.removeWalletServiceEventListener(this);
+ mHasRegisteredListener = false;
super.onDestroy();
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
index 8da80ca..96a3087 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletScreenController.java
@@ -30,7 +30,6 @@
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.SelectWalletCardRequest;
import android.service.quickaccesswallet.WalletCard;
-import android.service.quickaccesswallet.WalletServiceEvent;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
@@ -55,7 +54,6 @@
public class WalletScreenController implements
WalletCardCarousel.OnSelectionListener,
QuickAccessWalletClient.OnWalletCardsRetrievedCallback,
- QuickAccessWalletClient.WalletServiceEventListener,
KeyguardStateController.Callback {
private static final String TAG = "WalletScreenCtrl";
@@ -77,7 +75,6 @@
@VisibleForTesting String mSelectedCardId;
@VisibleForTesting boolean mIsDismissed;
- private boolean mHasRegisteredListener;
public WalletScreenController(
Context context,
@@ -117,6 +114,7 @@
if (mIsDismissed) {
return;
}
+ Log.i(TAG, "Successfully retrieved wallet cards.");
List<WalletCard> walletCards = response.getWalletCards();
List<WalletCardViewInfo> data = new ArrayList<>(walletCards.size());
for (WalletCard card : walletCards) {
@@ -158,26 +156,6 @@
});
}
- /**
- * Implements {@link QuickAccessWalletClient.WalletServiceEventListener}. Called when the wallet
- * application propagates an event, such as an NFC tap, to the quick access wallet view.
- */
- @Override
- public void onWalletServiceEvent(WalletServiceEvent event) {
- if (mIsDismissed) {
- return;
- }
- switch (event.getEventType()) {
- case WalletServiceEvent.TYPE_NFC_PAYMENT_STARTED:
- break;
- case WalletServiceEvent.TYPE_WALLET_CARDS_UPDATED:
- queryWalletCards();
- break;
- default:
- Log.w(TAG, "onWalletServiceEvent: Unknown event type");
- }
- }
-
@Override
public void onKeyguardFadingAwayChanged() {
queryWalletCards();
@@ -236,11 +214,6 @@
if (cardWidthPx == 0 || cardHeightPx == 0) {
return;
}
- if (!mHasRegisteredListener) {
- // Listener is registered even when device is locked. Should only be registered once.
- mWalletClient.addWalletServiceEventListener(this);
- mHasRegisteredListener = true;
- }
mWalletView.show();
mWalletView.hideErrorMessage();
@@ -261,7 +234,6 @@
mSelectedCardId = null;
mHandler.removeCallbacks(mSelectionRunnable);
mWalletClient.notifyWalletDismissed();
- mWalletClient.removeWalletServiceEventListener(this);
mWalletView.animateDismissal();
// clear refs to the Wallet Activity
mContext = null;
@@ -282,7 +254,6 @@
mWalletView.hide();
mPrefs.edit().putInt(PREFS_WALLET_VIEW_HEIGHT, 0).apply();
} else {
- logo.setTint(mContext.getColor(R.color.GM2_grey_900));
mWalletView.showEmptyStateView(
logo,
logoContentDesc,
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
index bf146b6..4f83abf 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/ui/WalletView.java
@@ -161,10 +161,12 @@
OnClickListener clickListener) {
mEmptyStateView.setVisibility(VISIBLE);
mErrorView.setVisibility(GONE);
- mCardCarouselContainer.setVisibility(GONE);
+ mCardCarousel.setVisibility(GONE);
+ mIcon.setImageDrawable(logo);
+ mIcon.setContentDescription(logoContentDescription);
+ mCardLabel.setText(R.string.wallet_empty_state_label);
ImageView logoView = mEmptyStateView.requireViewById(R.id.empty_state_icon);
- logoView.setImageDrawable(logo);
- logoView.setContentDescription(logoContentDescription);
+ logoView.setImageDrawable(mContext.getDrawable(R.drawable.ic_qs_plus));
mEmptyStateView.<TextView>requireViewById(R.id.empty_state_title).setText(label);
mEmptyStateView.setOnClickListener(clickListener);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
index b09afab3..09b0427 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/QuickAccessWalletTileTest.java
@@ -46,7 +46,6 @@
import android.graphics.drawable.Icon;
import android.os.Handler;
import android.service.quickaccesswallet.GetWalletCardsError;
-import android.service.quickaccesswallet.GetWalletCardsRequest;
import android.service.quickaccesswallet.GetWalletCardsResponse;
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.QuickAccessWalletService;
@@ -75,8 +74,6 @@
import com.android.systemui.util.settings.SecureSettings;
import com.android.systemui.wallet.controller.QuickAccessWalletController;
-import com.google.common.util.concurrent.MoreExecutors;
-
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -126,8 +123,6 @@
@Captor
ArgumentCaptor<Intent> mIntentCaptor;
@Captor
- ArgumentCaptor<GetWalletCardsRequest> mRequestCaptor;
- @Captor
ArgumentCaptor<QuickAccessWalletClient.OnWalletCardsRetrievedCallback> mCallbackCaptor;
private Context mSpiedContext;
@@ -163,7 +158,6 @@
mKeyguardStateController,
mPackageManager,
mSecureSettings,
- MoreExecutors.directExecutor(),
mController,
mFeatureFlags);
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
index 33666bc..23abce0 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/controller/QuickAccessWalletControllerTest.java
@@ -21,9 +21,7 @@
import static org.junit.Assert.assertNotSame;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.never;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -127,17 +125,7 @@
}
@Test
- public void queryWalletCards_walletNotEnabled_notQuery() {
- when(mQuickAccessWalletClient.isWalletServiceAvailable()).thenReturn(false);
-
- mController.queryWalletCards(mCardsRetriever);
-
- verify(mQuickAccessWalletClient, never()).getWalletCards(any(), any(), any());
- }
-
- @Test
public void queryWalletCards_walletEnabled_queryCards() {
- mController.updateWalletPreference();
mController.queryWalletCards(mCardsRetriever);
verify(mQuickAccessWalletClient)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
index cd1eb1c..01623d6 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/wallet/ui/WalletScreenControllerTest.java
@@ -20,13 +20,9 @@
import static android.view.View.VISIBLE;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNull;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.when;
import android.app.PendingIntent;
@@ -43,7 +39,6 @@
import android.service.quickaccesswallet.QuickAccessWalletClient;
import android.service.quickaccesswallet.QuickAccessWalletService;
import android.service.quickaccesswallet.WalletCard;
-import android.service.quickaccesswallet.WalletServiceEvent;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper;
@@ -250,7 +245,7 @@
callback.onWalletCardsRetrieved(response);
mTestableLooper.processAllMessages();
- assertEquals(GONE, mWalletView.getCardCarouselContainer().getVisibility());
+ assertEquals(GONE, mWalletView.getCardCarousel().getVisibility());
assertEquals(VISIBLE, mWalletView.getEmptyStateView().getVisibility());
assertEquals(GONE, mWalletView.getErrorView().getVisibility());
}
@@ -267,7 +262,7 @@
mCallbackCaptor.getValue().onWalletCardsRetrieved(response);
mTestableLooper.processAllMessages();
- assertEquals(GONE, mWalletView.getCardCarouselContainer().getVisibility());
+ assertEquals(GONE, mWalletView.getCardCarousel().getVisibility());
assertEquals(VISIBLE, mWalletView.getEmptyStateView().getVisibility());
assertEquals(GONE, mWalletView.getErrorView().getVisibility());
}
@@ -292,40 +287,6 @@
}
@Test
- public void onWalletServiceEvent_nfcPaymentStart_doNothing() {
- WalletServiceEvent event =
- new WalletServiceEvent(WalletServiceEvent.TYPE_NFC_PAYMENT_STARTED);
-
- mController.onWalletServiceEvent(event);
- mTestableLooper.processAllMessages();
-
- assertNull(mController.mSelectedCardId);
- assertFalse(mController.mIsDismissed);
- verifyZeroInteractions(mWalletClient);
- }
-
- @Test
- public void onWalletServiceEvent_walletCardsUpdate_queryCards() {
- mController.queryWalletCards();
-
- verify(mWalletClient).addWalletServiceEventListener(mListenerCaptor.capture());
-
- WalletServiceEvent event =
- new WalletServiceEvent(WalletServiceEvent.TYPE_WALLET_CARDS_UPDATED);
-
- QuickAccessWalletClient.WalletServiceEventListener listener = mListenerCaptor.getValue();
- listener.onWalletServiceEvent(event);
- mTestableLooper.processAllMessages();
-
- verify(mWalletClient, times(2))
- .getWalletCards(any(), mRequestCaptor.capture(), mCallbackCaptor.capture());
-
- GetWalletCardsRequest request = mRequestCaptor.getValue();
-
- assertEquals(MAX_CARDS, request.getMaxCards());
- }
-
- @Test
public void onKeyguardFadingAwayChanged_queryCards() {
mController.onKeyguardFadingAwayChanged();