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

[Financial Connections] Compose support. #5117

Merged
merged 7 commits into from Jun 6, 2022

Conversation

carlosmuvi-stripe
Copy link
Collaborator

@carlosmuvi-stripe carlosmuvi-stripe commented Jun 3, 2022

Summary

  • Adds rememberFinancialConnectionsSheet and rememberFinancialConnectionsSheetForToken @composable functions.
  • Adds example flow using Compose.

Why not on a different module?

SDK binary size would be a concern that could be solved by having a financial-connections-compose kind of module for integrators using Compose. However, we're planning on using Compose in the SDK as well so we're not seeing added value on an extra module.

Motivation

Support Financial Connections in Jetpack Compose.

Screenshots

flow.mp4

Changelog

- [Added] -  `createComposable` and `createComposableForToken` to FinancialConnectionsSheet.

@github-actions
Copy link
Contributor

github-actions bot commented Jun 3, 2022

Diffuse output:

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

          │            compressed             │           uncompressed            
          ├───────────┬───────────┬───────────┼───────────┬───────────┬───────────
 APK      │ old       │ new       │ diff      │ old       │ new       │ diff      
──────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────
      dex │   3.7 MiB │   5.8 MiB │  +2.1 MiB │   9.9 MiB │  16.1 MiB │  +6.2 MiB 
     arsc │ 859.3 KiB │ 921.5 KiB │ +62.2 KiB │ 859.2 KiB │ 921.4 KiB │ +62.2 KiB 
 manifest │   1.7 KiB │   1.9 KiB │    +233 B │   6.3 KiB │   7.5 KiB │  +1.2 KiB 
      res │ 422.8 KiB │ 423.5 KiB │    +645 B │ 607.1 KiB │ 607.8 KiB │    +680 B 
    asset │       0 B │   5.7 KiB │  +5.7 KiB │       0 B │   5.5 KiB │  +5.5 KiB 
    other │    58 KiB │  61.6 KiB │  +3.6 KiB │  63.7 KiB │  63.8 KiB │    +120 B 
──────────┼───────────┼───────────┼───────────┼───────────┼───────────┼───────────
    total │     5 MiB │   7.2 MiB │  +2.2 MiB │  11.4 MiB │  17.7 MiB │  +6.3 MiB 

         │           raw           │               unique                
         ├───────┬────────┬────────┼───────┬───────┬─────────────────────
 DEX     │ old   │ new    │ diff   │ old   │ new   │ diff                
─────────┼───────┼────────┼────────┼───────┼───────┼─────────────────────
   files │     2 │      2 │      0 │       │       │                     
 strings │ 69411 │ 109399 │ +39988 │ 68371 │ 98156 │ +29785 (+29830 -45) 
   types │  9162 │  14578 │  +5416 │  8927 │ 13712 │  +4785 (+4793 -8)   
 classes │  7504 │  12146 │  +4642 │  7504 │ 12146 │  +4642 (+4650 -8)   
 methods │ 66857 │  96848 │ +29991 │ 66382 │ 94797 │ +28415 (+28430 -15) 
  fields │ 51944 │  65019 │ +13075 │ 51902 │ 64512 │ +12610 (+12633 -23) 

 ARSC    │ old  │ new  │ diff         
─────────┼──────┼──────┼──────────────
 configs │  260 │  261 │  +1 (+1 -0)  
 entries │ 4391 │ 4415 │ +24 (+24 -0)
APK
       compressed       │       uncompressed       │                                                                  
───────────┬────────────┼───────────┬──────────────┤                                                                  
 size      │ diff       │ size      │ diff         │ path                                                             
───────────┼────────────┼───────────┼──────────────┼──────────────────────────────────────────────────────────────────
   1.8 MiB │   +1.7 MiB │   5.5 MiB │     +5.2 MiB │ ∆ classes2.dex                                                   
   3.9 MiB │ +389.8 KiB │  10.6 MiB │ +1,016.2 KiB │ ∆ classes.dex                                                    
 921.5 KiB │  +62.2 KiB │ 921.4 KiB │    +62.2 KiB │ ∆ resources.arsc                                                 
   5.4 KiB │   +5.4 KiB │   5.2 KiB │     +5.2 KiB │ + assets/dexopt/baseline.prof                                    
     353 B │     +353 B │     221 B │       +221 B │ + assets/dexopt/baseline.profm                                   
     332 B │     +332 B │     340 B │       +340 B │ + res/color/vector_tint_theme_color.xml                          
     318 B │     +318 B │     340 B │       +340 B │ + res/color/vector_tint_color.xml                                
   1.9 KiB │     +233 B │   7.5 KiB │     +1.2 KiB │ ∆ AndroidManifest.xml                                            
     206 B │     +206 B │       6 B │         +6 B │ + META-INF/androidx.compose.foundation_foundation-layout.version 
     206 B │     +206 B │       6 B │         +6 B │ + META-INF/androidx.compose.material_material-icons-core.version 
     200 B │     +200 B │       6 B │         +6 B │ + META-INF/androidx.profileinstaller_profileinstaller.version    
     198 B │     +198 B │       6 B │         +6 B │ + META-INF/androidx.compose.animation_animation-core.version     
     198 B │     +198 B │       6 B │         +6 B │ + META-INF/androidx.compose.material_material-ripple.version     
     198 B │     +198 B │       6 B │         +6 B │ + META-INF/androidx.compose.runtime_runtime-livedata.version     
     198 B │     +198 B │       6 B │         +6 B │ + META-INF/androidx.compose.runtime_runtime-saveable.version     
     192 B │     +192 B │       6 B │         +6 B │ + META-INF/androidx.compose.foundation_foundation.version        
     192 B │     +192 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-tooling-preview.version        
     188 B │     +188 B │       6 B │         +6 B │ + META-INF/androidx.compose.animation_animation.version          
     184 B │     +184 B │       6 B │         +6 B │ + META-INF/androidx.activity_activity-compose.version            
     184 B │     +184 B │       6 B │         +6 B │ + META-INF/androidx.compose.material_material.version            
     180 B │     +180 B │       6 B │         +6 B │ + META-INF/androidx.compose.runtime_runtime.version              
     178 B │     +178 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-geometry.version               
     178 B │     +178 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-graphics.version               
     170 B │     +170 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-text.version                   
     170 B │     +170 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-unit.version                   
     170 B │     +170 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui-util.version                   
     168 B │     +168 B │       6 B │         +6 B │ + META-INF/androidx.autofill_autofill.version                    
     160 B │     +160 B │       6 B │         +6 B │ + META-INF/androidx.compose.ui_ui.version                        
     737 B │       -4 B │   1.4 KiB │          0 B │ ∆ res/Am.xml                                                     
   1.1 KiB │       +3 B │   3.1 KiB │          0 B │ ∆ res/FR.xml                                                     
     542 B │       +3 B │     952 B │          0 B │ ∆ res/a2.xml                                                     
     614 B │       -3 B │   1.2 KiB │          0 B │ ∆ res/jH.xml                                                     
     875 B │       +2 B │   2.4 KiB │          0 B │ ∆ res/AK.xml                                                     
     767 B │       +2 B │   1.8 KiB │          0 B │ ∆ res/Hy.xml                                
...✂
MANIFEST
@@ -57,2 +57,6 @@
     <activity
+        android:name=com.stripe.android.financialconnections.example.FinancialConnectionsComposeExampleActivity
+        android:theme=@style/AppTheme.NoActionBar
+        />
+    <activity
         android:exported=true
@@ -106,3 +110,20 @@
           />
+      <meta-data
+          android:name=androidx.profileinstaller.ProfileInstallerInitializer
+          android:value=androidx.startup
+          />
     </provider>
+    <receiver
+        android:directBootAware=false
+        android:enabled=true
+        android:exported=true
+        android:name=androidx.profileinstaller.ProfileInstallReceiver
+        android:permission=android.permission.DUMP
+        >
+      <intent-filter>
+        <action
+            android:name=androidx.profileinstaller.action.INSTALL_PROFILE
+            />
+      </intent-filter>
+    </receiver>
   </application>
DEX
STRINGS:

   old   │ new   │ diff                
  ───────┼───────┼─────────────────────
   68371 │ 98156 │ +29785 (+29830 -45) 
  + �
  ������H�����H
  
  + �
  ������H�����H�@
  + �
  ��������H�����H
  ¢������
  + �
  ��������H�����2�������H�2�����H�H
  ¢������
  + �
  
  ��������0�H
  
  + �
  
  ���
  ���0�����H
  
  + �
  
  ���
  ���0�2�����0�H
  
  + �
  
  ���
  ����0�X�T¢��
  ¨��
  + �
  
  ���
  ����0�X�T¢��
  ¨��
  + �
  
  ��	
  �����0�H¨��
  + �
  
  ���
  �����0�H�¨��
  + �
  
  ��
  ����0�X�T¢��
  ¨��
  + �
  
  ���
  ���0�H
  ¢����
  + �
  
  ���
  �����0�H
  ¢����
  + �
  
  ���
  �����0�¨��
  + �
  
  ���
  �����0�H¨��
  + �
  
  ���
  �
  ���0�*�0�¨��
  + �
  
  ���
  ����0�X��¢��
  ¨��
  + �
  ���
  ������H����������*�0�H�@
  + 
  
  
  ��
  ��������0�2�����0�H
  ¢����
  + 
  
  
  ���
  ������0�H�¢������
  + 
  
  
  ���
  ������0�����*�H�2�����0�H
  ¢������
  + 
  
  
  ���
  ������0�����2�����H�H
  ¢������
  + 
  
  
  ���
  ��������0�2�������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ��������0�*�0�H�@
  + 
  
  
  ���
  ������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ������0�H
  ¢������
  + 
  
  
  ���
  ������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ���������0�2�����0�H�����0�X�T¢��
  ¨��
  + 
  
  
  ���
  ������0�����2�����0�2�����0�H
  ¢������
  + 
  
  
  ���
  ���������0�2�����0�2�����0�H�����0�X��¢��
  �����0�X�T¢��
  �����0�X�T¢��
  ¨��
  + 
  
  
  ���
  ������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ��������0�*�0�2�����0�H�������0�*�0�2�����0�H�¨��
  + 
  
  
  ���
  �������0�X�D¢��
  ������¨��
  + 
  
  
  ���
  ������0�����2�����0�H
  ¢������
  + 
  
  
  ���
  �������0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  ¨��
  + 
  
  
  ���
  �������0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  �����0�X�T¢��
  ¨��
  + 
  
  
  ��	
  ������0�����H
  ¢������
  + 
  
  
  ��	
  ��������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ������0�H
  ¢������
  + 
  
  
  ���
  ����
  ���0�H�¢����¨��
  + 
  
  
  ���
  ����
  ���0�H�¢����¨��
  + 
  
  
  ���
  �������0�X�D¢��
  �����¨��
  + 
  
  
  ���
  ��������0�2�������0�2�����0�H
  ¢����
  + 
  
  
  ���
  ������0�*�0�H�¢������
  + 
  
  
  ���
  ������0�H
  ¢������
  + 
  
  
  ���
  ������0�H�¢������
  + 
  
  
  ���
  ����
  ���0�H�¢����¨��
  + 
  
  
  ���
  ����
  ���0�H�¢����¨��
  + 
  
  
  ���
  �������
  ������H�0�����H¨��
  + 
  
  
  ���
  ������0�����*�0�H�¢������
  + 
  
  
  ���
  ������0�2�����0�H
  ¢������
  + 
  
  
  ���
  �������0�X��¢��
  ������¨��
  + 
  
  
  ���
  ������0�����2�����H�H
  ¢������
  + 
  
  
  ���
  ��������0�2�������0�2�����0�H
  ¢������
  + 
  
  
  ���
  ������������H�0���������������H�0���������������H�0�����¨��
  + 
  
  
  ���
  ������0�����2�����H�2�����H�H
  ¢������
  + 
  
  
  ���
  ����%���0�2�����0�2�����0�Hø�ø��¢���������
  ���
  ��¡�0�¨��
  + 
  
  
  ���
  �������0�8�X��¢��
  ������������¨��
  + 
  
  
  ���
  ����%���0�2�����0�2�����0�Hø�ø��¢�������%����0�2�����0�2�����0�Hø�ø��¢���������
  ���
  ��¡�0�¨��
  + 
  
  
  ���
  ������0�*�0�H�@
  + 
  
  
  ���
  ��������0�*�0�H�@
  + 
  
  ���
  ���
  ���0�*�0�H
  ¨��
  + 
  
  ���
  ���
  ����0�*�0�H�¨��
  + 
  
  ���
  ���
  ����0�*�0�H¨��
  + 
  
  �� 
  ���
  ��������0�0�X��¢��
  ¨��
  + 
  
  ��#
  ���
  ��
  ����0���0�H
  ¢����
  + 
  
  ���
  
  ������0�2�����0�H
  
  + 
  
  ���
  
  �����
   �*���0�0�*�0�H�@
  + 
  
  ���
  ��
  �����0�*�0�2����0�H�¨��
  + 
  
  ���
  ���
  *��������0�0�2�����0�0�¨��
  + 
  
  ���
  ���
  �����0�*�0�2����0�H�¨��
  + 
  
  ���
  ���
  ����0�*�0�H¨��
  + 
  
  ���
  ���
  �����0�*�0�2����0�¨��
  + 
  
  ���
  ���
  ��������0�0�X��ø�¢��
  ���
  ���¨��
  + 
  ���
  ���
  ������H�����*�0�2�����H�H
  ¢������
  + 
  ���
  ��	
  ������H�����2�����0�H
  ¢������
  + 
  ���
  ���
  ���� �����H�������2�����0�H��¢����¨��
  + 
  ���
  
  ���
  ��*���� �2�����H�0�¨��
  + 
  ���
  ��
  �����2�0�B�¢����¨��
  + 
  ���
  ��
  ������2�0�B�¢����¨��
  + 
  ���
  ��
  ����f� �2�0�:��¨��
  + 
  ���
  ��
  ����Ç��2�0�B���¢����¨��
  + 
  ���
  ��
  ����� �2�0�:��B�¢����¨��
  + 
  ���
  �
...✂
ARSC
CONFIGS:

   old │ new │ diff       
  ─────┼─────┼────────────
   260 │ 261 │ +1 (+1 -0) 
  + color-land
  

ENTRIES:

   old  │ new  │ diff         
  ──────┼──────┼──────────────
   4391 │ 4415 │ +24 (+24 -0) 
  + color/triangle_color
  + color/vector_tint_color
  + color/vector_tint_theme_color
  + id/androidx_compose_ui_view_composition_context
  + id/compose_view_saveable_id_tag
  + id/hide_in_inspector_tag
  + id/inspection_slot_table_set
  + id/wrapped_composition_tag
  + string/close_drawer
  + string/close_sheet
  + string/collect_bank_account_for_data_compose
  + string/default_error_message
  + string/default_popup_window_title
  + string/dropdown_menu
  + string/in_progress
  + string/indeterminate
  + string/navigation_menu
  + string/not_selected
  + string/off
  + string/on
  + string/selected
  + string/tab
  + string/template_percent
  + style/DialogWindowTheme

Comment on lines 86 to 95
@Composable
fun createComposable(
callback: (FinancialConnectionsSheetResult) -> Unit
): FinancialConnectionsSheet = FinancialConnectionsSheet(
FinancialConnectionsSheetForDataLauncher(
rememberLauncherForActivityResult(
FinancialConnectionsSheetForDataContract()
) { callback(it) }
)
)
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Alternatively we could use the same naming we do in the Payments SDK. However, this is not the Compose naming convention when using the remember API.

image

https://github.com/androidx/androidx/blob/androidx-main/compose/docs/compose-api-guidelines.md#naming-composable-functions-that-remember--the-objects-they-return

jameswoo-stripe
jameswoo-stripe previously approved these changes Jun 6, 2022
Copy link
Contributor

@jameswoo-stripe jameswoo-stripe left a comment

Choose a reason for hiding this comment

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

This is really cool!

ccen-stripe
ccen-stripe previously approved these changes Jun 6, 2022
@jameswoo-stripe
Copy link
Contributor

Should we also migrate PaymentLauncher to follow this pattern?

@carlosmuvi-stripe carlosmuvi-stripe merged commit 3ef8752 into master Jun 6, 2022
@carlosmuvi-stripe carlosmuvi-stripe deleted the f/compose-in-financial-connections-module branch June 6, 2022 21:34
@carlosmuvi-stripe carlosmuvi-stripe added the financial-connections Relates to the Financial Connections SDK label Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
financial-connections Relates to the Financial Connections SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants