-
Notifications
You must be signed in to change notification settings - Fork 477
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
Android Support #53
Android Support #53
Conversation
Allows for config object to specify title and color of the Fingerprint dialog. Keeps interface mostly the exact same (except for iOS specific error messages). Documentation/README updates to follow in next commits.
👏This is awesome — Great work guys! 🌴On vacation right now, but will try and get to this within a week. Otherwise, I'll see if I can get someone what to help with the review. |
Sounds good, no rush 👍 - enjoy vacay - I'll do some additional testing this weekend and Sunny will too. |
README.md
Outdated
|
||
On android you will need to add | ||
```xml | ||
<uses-permission android:name="android.permission.USE_FINGERPRINT" /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you do not need it. You already add this permission to the manifest library so it will get merged with your manifest (app).
return false; | ||
} | ||
|
||
if (ActivityCompat.checkSelfPermission(getReactApplicationContext(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You do not need this block, see USE_FINGERPRINT. This is a normal
permission so user cannot disable it.
super.onCreate(savedInstanceState); | ||
|
||
// Do not create a new Fragment when the Activity is re-created such as orientation changes. | ||
setRetainInstance(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is considered a bad practice. You should only retain a fragment for a dialog that returns no view, so onCreateView
should return null. Anyway you already use a DialogFragment (they don't leak on rotation), and RN in manifest also says that do not destroy the activity so you do not need this line.
setRetainInstance(true); | ||
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); | ||
|
||
// dialogCallback = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgotten comment?
|
||
// Do not create a new Fragment when the Activity is re-created such as orientation changes. | ||
setRetainInstance(true); | ||
setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to set style here explicitly? Can we get the default style? Maybe be able to override it with custom style
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense, we should probably do something like the following in the TouchID.android.js
DEFAULT_CONFIG = { title: 'Authentication Required', color: '#1306ff', style: 'STYLE_NORMAL' };
&& mFingerprintManager.hasEnrolledFingerprints() | ||
&& (ActivityCompat.checkSelfPermission(appContext, | ||
Manifest.permission.USE_FINGERPRINT) == | ||
PackageManager.PERMISSION_GRANTED); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same permission comment as before, also, this function seems a duplicated from FingerprintAuthModule.java
?
|
||
if (ActivityCompat.checkSelfPermission(appContext, | ||
Manifest.permission.USE_FINGERPRINT) != | ||
PackageManager.PERMISSION_GRANTED) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not needed.
See: https://developer.android.com/training/permissions/requesting.html
Normal permissions do not directly risk the user's privacy. If your app lists a normal permission in its manifest, the system grants the permission automatically.
android:layout_width="49dp" | ||
android:layout_height="49dp" | ||
android:layout_marginLeft="25dp" | ||
android:src="@drawable/ic_fp_40px" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would not generate a png for this icon but you can generate the xml with Android Studio. Then will look good anywhere.
<?xml version="1.0" encoding="utf-8"?> | ||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:app="http://schemas.android.com/apk/res-auto" | ||
android:orientation="vertical" android:layout_width="match_parent" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems it just needs to run 'Reformat' through Android Studio.
android/build.gradle
Outdated
|
||
defaultConfig { | ||
minSdkVersion 16 | ||
targetSdkVersion 22 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would bump minSdkVersion
and targetSdkVersion
up. FingerPrint works only on Android 23 and above, right? So it does not make really sense we say 16
.
Maybe rename to react-native-biometric-auth ? :) |
@ferrannp Thanks so much for the review! Will take a look at get these updates to you shortly. |
@zibs I dig it, picked up https://www.npmjs.com/package/react-native-biometric-auth. Will add you and @sunto to the package. |
Excited to see this land! |
landing shortly...thanks for the nudge @GantMan 🥇 |
Android: possible to use all color formats that are valid in react-na…
@zibs we're super excited to see this land! Great work guys :) |
@zibs Also looking forward to this! |
Is it in yet? Hyped for this! |
Sorry for delay all - just got one or two last things to update here and we should be good! |
I could not wait and implemented your branch and started testing. One comment would be to synchronize the error codes with the iOS version, for example in the IOS version I get an error of the form "LAErrorUserCancel" and the same error in this branch comes through as "Touch ID Error" |
@tactico Feel free to make a PR! The errors are handled fundamentally different on iOS and Android, which is why I haven't gone down that path yet. Definitely could be somewhat integrated eventually though! |
Agreed, let's tack on error handling in a subsequent PR, since even the
current iOS error handling could use some work.
@tactico, let me know if you're up for taking this on.
…On Fri, Nov 3, 2017, 10:40 AM Eli Zibin ***@***.***> wrote:
@tactico <https://github.com/tactico> Feel free to make a PR! The errors
are handled fundamentally different on iOS and Android, which is why I
haven't gone down that path yet. Definitely could be somewhat integrated
eventually though!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#53 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABjWsLU51DqtuKBlwATSRQUAbfPY0jiWks5sy1AGgaJpZM4PdG6w>
.
|
I probably will not be able to get to it for about a week, major release of our product scheduled for this Friday! |
Sorry noufal, got pulled into another project so likely will not be able to do this anytime soon. My apologies... |
@naoufal Hey Naoufal, sorry for dropping the ball and taking so long on this one. I've just pushed a number of commits that addressed most of the issues in the review. There is one missing about passing in a custom style theme thing, but I think that can wait until later! I just went through and tested on a brand new react native project created with Let me know if you have any suggestions! |
No worries at all! This is great work that a bunch of people will benefit from, I'd say you're doing the total opposite of dropping the ball! 🍻 Sorry about the netflix artifacts -- I'll fix that! I'll take a look tonight/tomorrow evening and try and get us setup for a merge this weekend. |
@zibs updated the And I'll bake this into the next release 🎉 |
}, | ||
|
||
authenticate(reason, config) { | ||
DEFAULT_CONFIG = { title: 'Authentication Required', color: '#1306ff' }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why do you not declare the DEFAULT_CONFIG
variable here?
It causes error in strict mode.
This PR adds support for using Fingerprint Authentication on Android.
It keeps the interface mostly the same, aside from allowing the user to pass in a config object to change the title and color of the pop-up requesting authentication.
The error handling is not as robust as iOS, but future PRs would be welcome to improve this.
Readme will be updated with an image showing it working on Android shortly.
I've tested this by creating a new project with
react-native init
for"react-native": "0.48.1",
and it seems to be working for both iOS and Android.thanks to @sunto for doing the bulk of the work!
Test Plan:
isSupported
is trueisSupported
is false doesn't die.isSupported
when Android has no fingerprint reader works