PFLockScreen Android Library Beta 4 Update

Beauty Coder
Beauty Coder
Published in
3 min readFeb 4, 2019

I just published new Update for a PFLockScreen Android Library. So publishing a small update here.

What’s new

  • Separate UI from Encryption part in case if you want to create your own encryption. (Please see detail below)
  • Added options to change the style for next button, Hint (Can’t remember) button and title. Also Removed some parameters as background and margin from “Next” button to make it more flexible to customize. If you want a transparent background or any other and margin please added your custom style.
  • Updated to AndroidX and grade version.

Some more details

So I was requested to add support of custom Encryption. Some people want to do something server-side related or just have something custom.

If you one of those people you need to override: IPFPinCodeHelper

This interface has four methods:

void encodePin(Context context, String pin, PFPinCodeHelperCallback<String> callBack);

void checkPin(Context context, String encodedPin, String pin, PFPinCodeHelperCallback<Boolean> callback);

void delete(PFPinCodeHelperCallback<Boolean> callback);

void isPinCodeEncryptionKeyExist(PFPinCodeHelperCallback<Boolean> callback);

It’s pretty obvious what are they doing, but just in case some explanation:

  • encodePin — method to encode pinched. Takes a pin and return encodedPin in the callback. You can save it in an account or in SharedPref or any other place.
  • checkPin — method to validate pin. Takes a encodedPin and just inputted by user pin. And checks if pin and encodedPin are the same.
  • delete — method should delete any encrypted keys you are using in encodePin method. Not made to delete encryptedPin string. Just anything you need to decrypt encrypted Pin.
  • isPinCodeEncryptionKeyExist — so check if encrypted keys or anything you used to encrypt a pin exists. (Same stuff you delete in the previous method). Basically, need to check that you can decrypt your key.

All methods are return values in callbacks. So you can implement something asynchronously.

Usually such pin code screens are being used for bank apps, or other apps with additional security and usually pin codes are being used locally. But if for some reasons you want to have a use same pin in multiple devices be sure you not sending pure pin over HTTP request or be sure it’s secure.

Also added more options for UI customization

Full list with new options:

You can customize buttons, backgrounds, etc. To do that, use attributes in your activity theme:

pf_key_button - style object for key buttons (0-9) pf_lock_screen - style object for the background. Use it to set a custom background. pf_fingerprint_button - style object for fingerprint button. You can set custom drawable, paddings, etc. pf_delete_button - style object for delete/backspace button. You can set custom drawable, paddings, etc. pf_code_view - style object to customize code view. (The view from the top of the screen). The view itself is set of checkboxes. To customize it use a custom selector with checked states.
pf_title (NEW) - style object for title.
pf_next (NEW) - style object for next button.
pf_hint (NEW) - style object for a hint button (Can't remember).

GitHub: PFLockScreen

If you like the article please support the project with the ⭐️ on GitHub and please press 👏 button.

--

--