Skip to content

Enter Passcode Screen

The layout of the EnterPasscodeScreen

In general, the enter passcode screen may contain:

  • an "Enter passcode" label
  • a passcode field
  • and a floating button for "Done".

The screen is enhanced with a label displaying the number of the remaining attempts. By default, this label is invisible and appears only if the user entered a wrong passcode. The counter of this attempts label is updated after entering a wrong passcode. If the maximum number of attempts reached (that is there is no more remaining attempt), then the passcode field is disabled and message dialog is displayed saying:

  • Maximum Passcode Attempts Reached (caption)
  • Please enter your credentials to Sign In and reset the passcode (text) and containing a single "OK" button.

Furthermore, the screen is extended to support resetting the passcode. In this case, the layout contains a reset button (labelled as Reset client) below the attempts label, allowing the user to reset the passcode. This is a disabled button be default and will be enabled only if the enter passcode screen is configured explicitly to enable it or an invalid passcode was provided by the user.

All the mentioned labels can be customized via the Settings configuration, that is you can overwrite them via the corresponding set methods of the EnterPasscodeSettings class. The EnterPasscodeSettings class can be instantiated with default constructor. The set methods should be called before calling the saveToIntent method, which saves the configuration into an Intent. Finally, this intent should be used when starting the EnterPasscodeActivity via the startActivityForResult method.

Customizing the Enter Passcode Screen

You can use the EnterPasscodeSettings object for customize the labels of the enter passcode screen. The following options are available:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
public boolean isResetEnabled() {
        return resetEnabled;
    }

public void setResetEnabled(boolean resetEnabled) {
    this.resetEnabled = resetEnabled;
}

public String getEnterYourPasscodeLabel() {
    return enterYourPasscodeLabel;
}

public void setEnterYourPasscodeLabel(String enterYourPasscodeLabel) {
    this.enterYourPasscodeLabel = enterYourPasscodeLabel;
}

public String getEnterYourCurrentPasscodeLabel() {
    return enterYourCurrentPasscodeLabel;
}

public void setEnterYourCurrentPasscodeLabel(String enterYourCurrentPasscodeLabel) {
    this.enterYourCurrentPasscodeLabel = enterYourCurrentPasscodeLabel;
}

public String getOneAttemptLeftMessage() {
    return oneAttemptLeftMessage;
}

public void setOneAttemptLeftMessage(String oneAttemptLeftMessage) {
    this.oneAttemptLeftMessage = oneAttemptLeftMessage;
}

public String getAttemptsLeftMessage() {
    return attemptsLeftMessage;
}

public void setAttemptsLeftMessage(String attemptsLeftMessage) {
    this.attemptsLeftMessage = attemptsLeftMessage;
}

public String getMaxAttemptsReachedMessage() {
    return maxAttemptsReachedMessage;
}

public void setMaxAttemptsReachedMessage(String maxAttemptsReachedMessage) {
    this.maxAttemptsReachedMessage = maxAttemptsReachedMessage;
}

public String getEnterCredentialsMessage() {
    return enterCredentialsMessage;
}

public void setEnterCredentialsMessage(String enterCredentialsMessage) {
    this.enterCredentialsMessage = enterCredentialsMessage;
}

public String getRetryPasscodeMessage() {
    return retryPasscodeMessage;
}

public void setRetryPasscodeMessage(String retryPasscodeMessage) {
    this.retryPasscodeMessage = retryPasscodeMessage;
}

public String getOkButtonString() {
    return okButtonString;
}

public void setOkButtonString(String okButtonString) {
    this.okButtonString = okButtonString;
}

Add Enter passcode screen activity to your manifest file

The EnterPasscodeActivity should be added to the AndroidManifest.xml file in an activity xml tag. It is required to specify also the "action_handler" meta-data tag.

1
2
3
4
5
6
7
8
  <activity
       android:name="com.sap.cloud.mobile.onboarding.passcode.EnterPasscodeActivity"
       android:label="@string/app_name"
       android:theme="@style/Theme.AppCompat.Light.NoActionBar"
   <meta-data
       android:name="action_handler"
   android:value="com.sap.cloud.mobile.fiori.demo.onboarding.PasscodeActionHandlerImpl"/>
    </activity>

Start the EnterPasscodeActivity

The EnterPasscodeActivity can be started with standard startActivityResult method of the Activity and you can configure it via the EnterPasscodeSettings class. For example:

1
2
3
4
5
6
  Intent i = new Intent(this,
                com.sap.cloud.mobile.onboarding.passcode.EnterPasscodeActivity.class);
  EnterPasscodeSettings settings = new EnterPasscodeSettings();
   settings.setEnterYourPasscodeLabel("Enter passcode here");
   // config via set methods
   startActivityForResult(i, ENTER_PASSCODE);