Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,8 @@ Returns a `Promise` object.
- `sensorDescription` - **Android** - text shown next to the fingerprint image
- `sensorErrorDescription` - **Android** - text shown next to the fingerprint image after failed attempt
- `cancelText` - **Android** - cancel button text
- `cancelTextColor` - **Android** - cancel button text color
- `cancelButtonColor` - **Android** - cancel button color
- `fallbackLabel` - **iOS** - by default specified 'Show Password' label. If set to empty string label is invisible.
- `unifiedErrors` - return unified error messages (see below) (default = false)
- `passcodeFallback` - **iOS** - by default set to false. If set to true, will allow use of keypad passcode.
Expand All @@ -191,6 +193,8 @@ const optionalConfigObject = {
sensorDescription: 'Touch sensor', // Android
sensorErrorDescription: 'Failed', // Android
cancelText: 'Cancel', // Android
cancelTextColor: '#ffffff', // Android
cancelButtonColor: '#e00606', // Android
fallbackLabel: 'Show Passcode', // iOS (if empty, then label is hidden)
unifiedErrors: false, // use unified error messages (default false)
passcodeFallback: false, // iOS - allows the device to fall back to using the passcode, if faceid/touch is not available. this does not mean that if touchid/faceid fails the first few times it will revert to passcode, rather that if the former are not enrolled, then it will use the passcode.
Expand Down
6 changes: 6 additions & 0 deletions TouchID.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,21 @@ export default {
sensorDescription: 'Touch sensor',
sensorErrorDescription: 'Failed',
cancelText: 'Cancel',
cancelTextColor: '#ffffff',
cancelButtonColor: '#6200ee',
unifiedErrors: false
};
var authReason = reason ? reason : ' ';
var authConfig = Object.assign({}, DEFAULT_CONFIG, config);
var imageColor = processColor(authConfig.imageColor);
var imageErrorColor = processColor(authConfig.imageErrorColor);
var cancelTextColor = processColor(authConfig.cancelTextColor);
var cancelButtonColor = processColor(authConfig.cancelButtonColor);

authConfig.imageColor = imageColor;
authConfig.imageErrorColor = imageErrorColor;
authConfig.cancelTextColor = cancelTextColor;
authConfig.cancelButtonColor = cancelButtonColor;

return new Promise((resolve, reject) => {
NativeTouchID.authenticate(
Expand Down
14 changes: 6 additions & 8 deletions android/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Inspired by rayronvictor's PR #248 tp react-native-config
// https://github.com/luggit/react-native-config/pull/248

def _ext = rootProject.ext

buildscript {
repositories {
maven {
Expand All @@ -14,17 +12,17 @@ buildscript {
}

dependencies {
classpath _ext.has('gradleBuildTools') ? _ext.gradleBuildTools : 'com.android.tools.build:gradle:3.4.0'
classpath rootProject.ext.has('gradleBuildTools') ? rootProject.ext.gradleBuildTools : 'com.android.tools.build:gradle:3.4.0'
}
}

apply plugin: 'com.android.library'

def _reactNativeVersion = _ext.has('reactNative') ? _ext.reactNative : '+'
def _compileSdkVersion = _ext.has('compileSdkVersion') ? _ext.compileSdkVersion : 27
def _buildToolsVersion = _ext.has('buildToolsVersion') ? _ext.buildToolsVersion : '27.0.3'
def _minSdkVersion = _ext.has('minSdkVersion') ? _ext.minSdkVersion : 16
def _targetSdkVersion = _ext.has('targetSdkVersion') ? _ext.targetSdkVersion : 27
def _reactNativeVersion = rootProject.ext.has('reactNative') ? rootProject.ext.reactNative : '+'
def _compileSdkVersion = rootProject.ext.has('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 27
def _buildToolsVersion = rootProject.ext.has('buildToolsVersion') ? rootProject.ext.buildToolsVersion : '27.0.3'
def _minSdkVersion = rootProject.ext.has('minSdkVersion') ? rootProject.ext.minSdkVersion : 16
def _targetSdkVersion = rootProject.ext.has('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 27

android {
compileSdkVersion _compileSdkVersion
Expand Down
16 changes: 16 additions & 0 deletions android/src/main/java/com/rnfingerprint/FingerprintDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public class FingerprintDialog extends DialogFragment implements FingerprintHand

private String authReason;
private int imageColor = 0;
private int cancelTextColor = 0;
private int cancelButtonColor = 0;
private int imageErrorColor = 0;
private String dialogTitle = "";
private String cancelText = "";
Expand Down Expand Up @@ -68,6 +70,12 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
this.mFingerprintError.setText(this.errorText);

final Button mCancelButton = (Button) v.findViewById(R.id.cancel_button);
if (this.cancelTextColor != 0) {
mCancelButton.setTextColor(this.cancelTextColor);
}
if (this.cancelButtonColor != 0) {
mCancelButton.setBackgroundColor(this.cancelButtonColor);
}
mCancelButton.setText(this.cancelText);
mCancelButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down Expand Up @@ -138,6 +146,14 @@ public void setAuthConfig(final ReadableMap config) {
this.cancelText = config.getString("cancelText");
}

if (config.hasKey("cancelTextColor")) {
this.cancelTextColor = config.getInt("cancelTextColor");
}

if (config.hasKey("cancelButtonColor")) {
this.cancelButtonColor = config.getInt("cancelButtonColor");
}

if (config.hasKey("sensorDescription")) {
this.sensorDescription = config.getString("sensorDescription");
}
Expand Down
8 changes: 8 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,14 @@ declare module 'react-native-touch-id' {
* **Android only** - Cancel button text
*/
cancelText?: string;
/**
* **Android only** - Cancel button text color
*/
cancelTextColor?: string;
/**
* **Android only** - Cancel button color
*/
cancelButtonColor?: string;
/**
* **iOS only** - By default specified 'Show Password' label. If set to empty string label is invisible.
*/
Expand Down