cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Android SDK - Flows enhancement - custom controls

yohann_weberfr
Explorer
0 Kudos
658

Hi experts,

I'm working on SAP Android 4.0.0. My requirement is to add, on the Basic Auth Screen of the flow, a link or a button to trigger the navigation to a custom Activity. At the end of the custom activity, user should get back to the basic auth screen.

I know how to change the screen and add the button but what would be the best strategy to trigger a navigation to my custom activity ? Is it possible ? Do we have some examples ?

I would like to thanks in advance for your help.

Yohann

Accepted Solutions (1)

Accepted Solutions (1)

yohann_weberfr
Explorer
0 Kudos

Hi,

I found the current solution to enhancement the behavior of the BasicAuthenticationScreen :

  1. I've copied the layout C:\{USER_PATH}\.gradle\caches\transforms-3\d284a9c18079791fdcb2ae635df16208\transformed\jetified-onboarding-5.0.2\res\layout\activity_basic_authentication.xml in my own package.
    In this copy layout, I've added my new button to add my functionnality "Reset password" (R.id.basic_auth_screen_reset_button)
  2. I've copied the layout C:\{USER_PATH}\.gradle\caches\transforms-3\090ea5ce3bfa026f5a494e181f777ae3\transformed\jetified-flowsv2-5.0.2\res\layout\fragment_basic_authentication.xml in my own package.
  3. I've enhanced the view com.sap.cloud.mobile.fiori.onboarding.BasicAuthenticationScreen
class BasicAuthenticationEnhancedScreen  @JvmOverloads constructor(context : Context, attrs : AttributeSet? = null, defStyleAttr : Int = 0, defStyleRes : Int = 0) : BasicAuthenticationScreen(context,attrs, defStyleAttr, defStyleRes) {
init{
findViewById<Button>(R.id.basic_auth_screen_reset_button)?.let{
it.setOnClickListener {
//some logic here
}
}
}
}

3. I've added the custom view in the copy of the layout :

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/stepBasicAuth"
android:layout_width="match_parent"
android:layout_height="match_parent">

<com...mdui.common.BasicAuthenticationEnhancedScreen
android:id="@+id/basicAuthenticationScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
</FrameLayout>

Answers (2)

Answers (2)

qiang_zhang3
Advisor
Advisor
0 Kudos

Hi Yohann

SAP BTP SDK for Android 4.0 has a feature to let the client code insert custom steps at various points during the onboarding process, which could be able to help in this case. I have a blog post on this here: https://blogs.sap.com/2021/12/30/customizing-the-onboarding-flow-with-sap-btp-sdk-for-android-4.0/

In your case, would you please try the following:

  1. insert a custom step at the insertion point 'BeforeAuthentication', this will insert a step before 'Basic Auth' screen.
  2. in this step, you can your reset password API;
  3. navigate to the next step, which will be the 'Basic Auth' screen, only after the password reset id done. (Since the step will be implemented with Fragment, then maybe onResume can be used when navigating back, or use Activity Result callback to monitor the result.
    https://developer.android.com/training/basics/intents/result#registerhttps://developer.android.com/t...

Hope this works for you.

Best

Qiang

yohann_weberfr
Explorer
0 Kudos

Hi Qiang,

thanks a lot for your quick answer.

Sorry, if I wasn't be clear.

Our requirment is to put a "reset password" link (or a button) on the basic auth screen to trigger a custom screen(activity). This screen gives the posssibility to the user to reset the password. Our client have a legacy API (on premise backend) reseting the password, we should call in this custom screen (i.e It sends mail with some instruction) After the password reset done, we should come back on the basic auth screen.

When I talk about screen modification, I mean the layouts. We customed the standard flow layouts by copy the xml files in our own package. So I know I can just add a button on the layout basic auth screen.

My question is, how can I enhance the current basic auth screen to put some code behind this new button click ? Is it possible directly ? If it's not, I have thinked about custom flow ? Is it possible to replace the current basic auth screen by a custom ? Or have a solution to fill our requirment ?

Thanks a lot

Yohann