Customising SmartLicence

Text Customisation and Internationalisation

The SmartLicence currently only supports British English. To provide support for additional languages in your app, define additional string resources matching the corresponding resource identifiers:

<resources>
  <string name="waiting_for_smart_licence">Hold the SmartLicence card to the back of the device</string>
  <string name="exceeded_licence_status">There are no remaining licences on this SmartLicence. Please try another.</string>
  <string name="card_not_configured_status">This SmartLicence has not yet been configured.</string>
  <string name="product_mismatch_status">This SmartLicence is for another software product.</string>
  <string name="OK">OK</string>
  <string name="cancel">Cancel</string>
  <string name="incorrect_pin_status">Incorrect PIN supplied.</string>
  <string name="unknown_error">Unable to read the card. Please try again.</string>
  <string name="error_reading_card">Error reading card. Please try again</string>
  <string name="auth_required">Authentication Required</string>
  <string name="passphrase_title">PIN or passphrase</string>
  <string name="not_smartlicence">Not a SmartLicence card.</string>
  <string name="card_removed_too_soon">The card was removed too soon: please try again\n\n\nHold the SmartLicence card to the back of the device</string>
</resources>

Custom user interface

The activation user interface can be replaced by extending the ActivationFragment class and overriding onCreateView(), to inflate your own layout:

public class MyActivationFragment extends ActivationFragment {

  @Override
  public View onCreateView(
      LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.fragment_my_activation_bump, container, false);
  }
}

After creating an instance of your fragment, set the arguments using a Bundle:

MyActivationFragment myActivationFragment = new MyActivationFragment();
Bundle args = new Bundle();
args.putShort(ActivationFragment.ARG_VENDOR_ID, VENDOR_ID);
args.putShort(ActivationFragment.ARG_APP_ID, APPLICATION_ID);
args.putString(ActivationFragment.ARG_SERIAL_NO, serialNumber);
myActivationFragment.setArguments(args);

When extending ActivationFragment, you must call super() first if you override any of the following methods:

public void onCreate();
public void onResume();
public void onPause();

ActivationFragment uses a view model (SmartLicenceViewModel) for reporting messages for the user. This is useful when the user has:

  • attempted to use the wrong vendor’s SmartLicence;
  • removed the card from the NFC field before the activation is complete; and
  • when the card has run out of licences.

Your activity can observe these changes and update your customised user interface with the status message as follows:

SmartLicenceViewModel smartLicenceViewModel =
    new ViewModelProvider(this).get(SmartLicenceViewModel.class);
smartLicenceViewModel.getLicence().observe(this, licenceObserver);
smartLicenceViewModel
    .getStatus()
    .observe(
        this,
        status -> {
          TextView statusTextView = findViewById(R.id.myActivationProgressMessage);
          if (statusTextView != null) {
            statusTextView.setText(status);
          }
        });

Card NFC Tag

The SmartLicence smartcard supports storing a read-only URL that the Android device can read and launch via NFC when the activation fragment is not displayed. This could be used to direct the user to a support web page or your online store for purchasing more licences. Simply specify the URL to be stored when ordering additional smartcards.