Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f1de6ecc authored by Silin Huang's avatar Silin Huang Committed by Automerger Merge Worker
Browse files

Merge "WalletTile should display the default card of wallet." into sc-dev am: 3061389c

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14324210

Change-Id: I87e68ff6a81e70a8c95db94d4e5b1c3263f84790
parents 5fcdd639 3061389c
Loading
Loading
Loading
Loading
+16 −4
Original line number Diff line number Diff line
@@ -129,8 +129,15 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
                Intent intent = new Intent(mContext, WalletActivity.class)
                        .setAction(Intent.ACTION_VIEW)
                        .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_NEW_TASK);
                if (mKeyguardStateController.isUnlocked()) {
                    mActivityStarter.startActivity(intent, true /* dismissShade */,
                            animationController);
                } else {
                    mHost.collapsePanels();
                    // Do not use ActivityStarter here because the WalletActivity is required to be
                    // started without prompting keyguard when the device is locked.
                    mContext.startActivity(intent);
                }
            } else {
                if (mQuickAccessWalletClient.createWalletIntent() == null) {
                    Log.w(TAG, "Could not get intent of the wallet app.");
@@ -147,7 +154,7 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
    protected void handleUpdateState(State state, Object arg) {
        state.label = mLabel;
        state.contentDescription = state.label;
        state.icon = ResourceIcon.get(R.drawable.ic_qs_wallet);
        state.icon = ResourceIcon.get(R.drawable.ic_wallet_lockscreen);
        boolean isDeviceLocked = !mKeyguardStateController.isUnlocked();
        if (mQuickAccessWalletClient.isWalletServiceAvailable()) {
            if (mHasCard) {
@@ -219,7 +226,12 @@ public class QuickAccessWalletTile extends QSTileImpl<QSTile.State> {
                refreshState();
                return;
            }
            mCardViewDrawable = cards.get(0).getCardImage().loadDrawable(mContext);
            int selectedIndex = response.getSelectedIndex();
            if (selectedIndex >= cards.size()) {
                Log.d(TAG, "Selected card index out of bounds.");
                return;
            }
            mCardViewDrawable = cards.get(selectedIndex).getCardImage().loadDrawable(mContext);
            mHasCard = true;
            refreshState();
        }
+20 −2
Original line number Diff line number Diff line
@@ -207,7 +207,25 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
    }

    @Test
    public void testHandleClick_hasCards_startWalletActivity() {
    public void testHandleClick_hasCards_deviceLocked_startWalletActivity() {
        when(mKeyguardStateController.isUnlocked()).thenReturn(false);
        setUpWalletCard(/* hasCard= */ true);

        mTile.handleClick(null /* view */);
        mTestableLooper.processAllMessages();

        verify(mSpiedContext).startActivity(mIntentCaptor.capture());

        Intent nextStartedIntent = mIntentCaptor.getValue();
        String walletClassName = "com.android.systemui.wallet.ui.WalletActivity";

        assertNotNull(nextStartedIntent);
        assertThat(nextStartedIntent.getComponent().getClassName()).isEqualTo(walletClassName);
    }

    @Test
    public void testHandleClick_hasCards_deviceUnlocked_startWalletActivity() {
        when(mKeyguardStateController.isUnlocked()).thenReturn(true);
        setUpWalletCard(/* hasCard= */ true);

        mTile.handleClick(null /* view */);
@@ -226,7 +244,7 @@ public class QuickAccessWalletTileTest extends SysuiTestCase {
    @Test
    public void testHandleUpdateState_updateLabelAndIcon() {
        QSTile.State state = new QSTile.State();
        QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_qs_wallet);
        QSTile.Icon icon = QSTileImpl.ResourceIcon.get(R.drawable.ic_wallet_lockscreen);

        mTile.handleUpdateState(state, null);