Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix several UX issues in address element #5462

Merged
merged 2 commits into from Aug 26, 2022

Conversation

tillh-stripe
Copy link
Collaborator

@tillh-stripe tillh-stripe commented Aug 25, 2022

Summary

This pull request fixes a few UX issues in the address element screens:

  • Make sure there's an expand animation when opening the sheet.
  • Make screens scrollable, which is necessary in landscape mode, with a ScrollableColumn composable.
  • Prevent search field from re-requesting focus after user hits enter. Now, we only request focus on first composition.
  • Adjust Enter manually font size.
  • Prevent address sheet dismissal (only in auto-complete screen) and half-expanded state.
  • Fix the visual glitch in the dismissal animation by overriding pending transitions.

Motivation

Things that came up in the Address Element bug bash.

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screen recordings

Before

before.mp4

After

after.mp4

Changelog

Nothing to add.

@tillh-stripe tillh-stripe force-pushed the tillh/address-element-ui-fixes branch 2 times, most recently from 171398c to 05263ae Compare August 25, 2022 19:28
@github-actions
Copy link
Contributor

github-actions bot commented Aug 25, 2022

Diffuse output:

OLD: paymentsheet-example-release-master.apk (signature: none)
NEW: paymentsheet-example-release-pr.apk (signature: none)

          │            compressed            │           uncompressed           
          ├───────────┬───────────┬──────────┼───────────┬───────────┬──────────
 APK      │ old       │ new       │ diff     │ old       │ new       │ diff     
──────────┼───────────┼───────────┼──────────┼───────────┼───────────┼──────────
      dex │  15.4 MiB │  15.4 MiB │ +2.9 KiB │    52 MiB │    52 MiB │ +6.8 KiB 
     arsc │   1.8 MiB │   1.8 MiB │      0 B │   1.8 MiB │   1.8 MiB │      0 B 
 manifest │     4 KiB │     4 KiB │      0 B │  18.5 KiB │  18.5 KiB │      0 B 
      res │ 873.3 KiB │ 873.3 KiB │      0 B │   1.4 MiB │   1.4 MiB │      0 B 
   native │   2.5 MiB │   2.5 MiB │      0 B │   5.9 MiB │   5.9 MiB │      0 B 
    asset │     3 MiB │     3 MiB │     +7 B │     3 MiB │     3 MiB │     +7 B 
    other │  81.7 KiB │  81.7 KiB │      0 B │ 155.6 KiB │ 155.6 KiB │      0 B 
──────────┼───────────┼───────────┼──────────┼───────────┼───────────┼──────────
    total │  23.6 MiB │  23.6 MiB │ +2.9 KiB │  64.1 MiB │  64.1 MiB │ +6.8 KiB 

         │          raw           │              unique              
         ├────────┬────────┬──────┼────────┬────────┬────────────────
 DEX     │ old    │ new    │ diff │ old    │ new    │ diff           
─────────┼────────┼────────┼──────┼────────┼────────┼────────────────
   files │      4 │      4 │    0 │        │        │                
 strings │ 251123 │ 251144 │  +21 │ 214142 │ 214157 │ +15 (+66 -51)  
   types │  44329 │  44335 │   +6 │  40695 │  40700 │  +5 (+23 -18)  
 classes │  37891 │  37896 │   +5 │  37891 │  37896 │  +5 (+23 -18)  
 methods │ 221721 │ 221750 │  +29 │ 213725 │ 213751 │ +26 (+108 -82) 
  fields │ 162936 │ 162968 │  +32 │ 161896 │ 161926 │ +30 (+63 -33)  

 ARSC    │ old  │ new  │ diff 
─────────┼──────┼──────┼──────
 configs │  292 │  292 │  0   
 entries │ 6232 │ 6232 │  0
APK
     compressed     │    uncompressed    │                               
─────────┬──────────┼─────────┬──────────┤                               
 size    │ diff     │ size    │ diff     │ path                          
─────────┼──────────┼─────────┼──────────┼───────────────────────────────
 2.2 MiB │ +2.7 KiB │ 6.9 MiB │   +6 KiB │ ∆ classes3.dex                
 3.2 MiB │   +249 B │ 9.1 MiB │   +740 B │ ∆ classes4.dex                
 8.7 KiB │     +7 B │ 8.6 KiB │     +7 B │ ∆ assets/dexopt/baseline.prof 
─────────┼──────────┼─────────┼──────────┼───────────────────────────────
 5.5 MiB │ +2.9 KiB │  16 MiB │ +6.8 KiB │ (total)
DEX
STRINGS:

   old    │ new    │ diff          
  ────────┼────────┼───────────────
   214142 │ 214157 │ +15 (+66 -51) 
  +  
  
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���������0�2�����0�2�������0�H�¢���	���
  ��0�2�����0H�¢���
  ����0�8X�T¢��
  ������¨��
  + 6
  
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ��
  ����5���0�2�������0�2���������0�����0�0�¢����¢����H�¢���	���
  ��0�*�02��
  ����0H������0�*�0�2�����0�H¨��
  + <
  ���
  ���
  
  ���
  
  ���
  ���
  ���
  ���
  ���
  
  ��
  ���
  ���
  
  ���
  ������� (2�0�:�(B/�������0���������0���������0��
  ��������0�¢���	J�����0�HÀ�¢����J�������0�HÀ�¢����J�����0�HÀ�¢����J�������0�HÀ�¢������J:����02�������0�2
  ��������0�2�������0�2
  ��������0�HÆ�¢����J	����0�HÖ�J�����0�2�������0 HÖ�J	�!��0�HÖ�J	���0�HÖ�J��#��0_2��%��0&2��'��0�HÖ�R�������0�X��¢��
  ���
  ��R�����0�X��¢��
  ����
  R�����0�X��¢��
  �����
  R�������0�X��¢�
  
  ���������¨�)
  + <
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  �����  2�0�:� B�¢����J�����0�H�J�����0�2�����0�H�J�����0�2�������0�H�J�����0�H�J�����0�H�R�������0�8BX���¢�
  �����������R!�	��0
  8@X���¢��
  ���������������
  R_����0�8@X��¢��
  �����������������¨�!
  + @
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ��2�0�B�¢����J�����0�H�J�����0�2�������0�H�J�����0�2�������0�H�R�����0�X�.¢��
  R�����0�8BX���¢�
  ��	�
  ������R�����08BX���¢�
  ����
  ���
  ��R_����0�8@X��¢��
  �����������������¨��
  + N
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ����� �2�0�:��B�¢����J�����0H�J��
  ��02�����0�H�J����02�����0�2�����0�2�������0�H�J�����02�������0�H�J�����02�������0�H�J�����02��������0�0�H�J�����0H�R�����0�X�.¢��
  R�����0�8BX���¢�
  ��	�
  ������¨� 
  + P
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ����� #2�0�:�#B�¢����J�����0H�J��
  ��02�����0�H�J�����0�¢����2�����0�H�J�����02��������0�0�H�J����02�����0�2�����0�2�������0�H�J�����02�������0�H�J�� ��02�������0�H�J��!��0H�J����02�����0�H�R�����0�X�.¢��
  R�����0�8BX���¢�
  ��	�
  ������¨�_
  + h
  ���
  ���
  ���
  ���
  
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  ���
  
  ���
  ����� 12�0�:�1B�¢����J�����0�H�J�����0�2�����0�H�J�����0�2�����0�H�J� ��0�2��!��02��#��02��_����0%H�J��&��0�2��'����0(H�J��)��0�2��_����0%H�J��*��0�2��+��0,2��-����0.H�J��/��0�2�����0�H�J��0��0�H�R�����0�X�.¢��
  R�����0�8BX���¢�
  ��	�
  ������R�����08BX���¢�
  ����
  ���
  ��R�������08BX���¢�
  ����
  ������R�����0�8BX���¢�
  ����
  ������¨�2
  + _this_ScrollableColumn
  + (Landroidx/compose/ui/Modifier;Lkotlin/jvm/functions/Function3;Landroidx/compose/runtime/Composer;II)V
  + (Ljava/lang/String;Lcom/stripe/android/paymentsheet/addresselement/AddressLauncher_Configuration;Ljava/lang/String;Ljava/lang/Integer;)Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivityContract_Args;
  + (Ljava/lang/String;Lcom/stripe/android/paymentsheet/addresselement/AddressLauncher_Configuration;Ljava/lang/String;Ljava/lang/Integer;)V
  + InputAddressScreen_lambda-0
  + InputAddressScreen_lambda-5_lambda-2
  + InputAddressScreen_lambda-5_lambda-3
  + InputAddressScreen_lambda-5_lambda-4
  + Intent(context, AddressE…rColor = statusBarColor))
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_1_1;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_2_1;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_2_2;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_2;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_3_1;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_3;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_4_1_1_1_1;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_4_1_1_1_2;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_4_1_1_1_3;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElementActivity_onCreate_2_4_1_1_1;
  + Lcom/stripe/android/paymentsheet/addresselement/AddressElem
...✂

- Make sure there's an expand animation when opening the sheet
- Make screens scrollable, which is necessary in landscape mode
- Prevent search field from re-requesting focus after user hits enter
- Adjust `Enter manually` font size
- Prevent address sheet dismissal (only in auto-complete screen) and half-expanded state
- Fix dismissal animation by overriding pending transitions
// this is a transparent Activity so we want to disable animations
overridePendingTransition(0, 0)
private fun setFadeAnimations() {
overridePendingTransition(AnimationConstants.FADE_IN, AnimationConstants.FADE_OUT)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured we could use fade animations in all places where we were currently overriding pending transitions, as this results in a much smoother look. Any concerns about this?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it change anything? This activity has no UI

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That one is indeed a bad example 🙈 There is a noticeable difference with the payment sheet though. I figured it wouldn’t hurt to apply the same everywhere to discourage using no animations.

Comment on lines +73 to +76
confirmStateChange = {
val route = navController.currentDestination?.route
route != AddressElementScreen.Autocomplete.route
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find that the user shouldn’t be able to exit from the sheet while in the autocomplete screen. Any concerns around this?

Comment on lines -858 to -864
public final class com/stripe/android/paymentsheet/addresselement/AddressUtilsKt {
public static final fun levenshtein (Ljava/lang/CharSequence;Ljava/lang/CharSequence;)I
}

public final class com/stripe/android/paymentsheet/addresselement/AutocompleteScreenKt {
public static final field TEST_TAG_ATTRIBUTION_DRAWABLE Ljava/lang/String;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two things were made public by accident, right?

Comment on lines +58 to +71
@Composable
internal fun ScrollableColumn(
modifier: Modifier = Modifier,
content: @Composable ColumnScope.() -> Unit
) {
Box(
modifier = Modifier.verticalScroll(rememberScrollState())
) {
Column(
modifier = modifier,
content = content
)
}
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to what we’re using in Link. Let me know if you prefer a different approach.

Comment on lines +161 to +164
.padding(
vertical = 8.dp,
horizontal = 16.dp
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Throughout this file, I made a few changes to where padding is applied. I did this to make sure that the click ripple effect looks correct, meaning that it spans the entire width and height of a row.

@tillh-stripe tillh-stripe merged commit d6be9b7 into master Aug 26, 2022
@tillh-stripe tillh-stripe deleted the tillh/address-element-ui-fixes branch August 26, 2022 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants