Commit 44d58fd4 authored by JingChao's avatar JingChao

Initial commit

parents
# Contributor Covenant Code of Conduct
## Our Pledge
In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
## Our Standards
Examples of behavior that contributes to creating a positive environment include:
* Using welcoming and inclusive language
* Being respectful of differing viewpoints and experiences
* Gracefully accepting constructive criticism
* Focusing on what is best for the community
* Showing empathy towards other community members
Examples of unacceptable behavior by participants include:
* The use of sexualized language or imagery and unwelcome sexual attention or advances
* Trolling, insulting/derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or electronic address, without explicit permission
* Other conduct which could reasonably be considered inappropriate in a professional setting
## Our Responsibilities
Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
## Scope
This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at NiklasMerz@gmx.net. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
[homepage]: http://contributor-covenant.org
[version]: http://contributor-covenant.org/version/1/4/
# Asking questions
If you want to ask a question about the use of this plugin, please avoid submmitting an issue and ask on [Gitter](https://gitter.im/cordova-plugin-fingerprint-aio) instead.
# Submitting bugs
Create a new issue and please use the template
# Contributing
* Fork
* Create new feature branch (git checkout -b feature-or-fix-something)
* Commit your changes (git commit -am 'Add fix for android ...')
* Push to the branch (git push origin feature-or-fix-something)
* Create new Pull Request with description what you did and why you did it
## Tips
* Please avoid changing the indentation of a complete file in your pull request, because that makes reviewing changes hard
* Use the command `npm test PLATFORM` to run automatic and manual tests first
[comment]: <> (Please remove this comment and other template lines before submitting)
## Do you have a question ?
**Please go to [Gitter](https://gitter.im/cordova-plugin-fingerprint-aio) and ask here. Avoid submitting support requests as issues on Github. If you have trouble installing this plugin, please ask on Gitter first.**
## Description
* What did you do?
* What did happen?
* What did you expect to happen?
* Type of issue (bug, feature request)
## Environment
* Plugin version
* Build environment (```cordova info```)
* ```cordova platform ls```
### Logs
MIT License
Copyright (c) 2016-2018 Niklas Merz
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
# Cordova Plugin Fingerprint All-In-One
## **Android** and **iOS**
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.png)](https://gitter.im/cordova-plugin-fingerprint-aio)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/NiklasMerz/cordova-plugin-fingerprint-aio/master/LICENSE)
[![Build Status](https://travis-ci.org/NiklasMerz/cordova-plugin-fingerprint-aio.svg?branch=master)](https://travis-ci.org/NiklasMerz/cordova-plugin-fingerprint-aio)
[![Issue Count](https://codeclimate.com/github/NiklasMerz/cordova-plugin-fingerprint-aio/badges/issue_count.svg)](https://codeclimate.com/github/NiklasMerz/cordova-plugin-fingerprint-aio)
[![NPM](https://nodei.co/npm/cordova-plugin-fingerprint-aio.png?downloads=true&downloadRank=true&stars=true)](https://nodei.co/npm/cordova-plugin-fingerprint-aio/)
**This plugin provides a single and simple interface for accessing fingerprint APIs on both Android 6+ and iOS.**
## Features
* Check if fingerprint scanner is available
* Fingerprint authentication
* Ionic Native support
* ngCordova support
* Fallback options
* Now with **FaceID** on iPhone X
### Platforms
* Android - Minimum SDK 23
* iOS - **XCode 9.2 or higher** required
* _Please set `<preference name="UseSwiftLanguageVersion" value="3.2" />` in your config.xml_
## How to use
---
**[Tutorial about using this plugin with Ionic](https://www.youtube.com/watch?v=tQDChMJ6er8)** thanks to Paul Halliday
[Examples](https://github.com/NiklasMerz/fingerprint-aio-demo)
[ngCordova Example](https://github.com/NiklasMerz/fingerprint-aio-demo/tree/ng-cordova)
[Ionic Native Example](https://github.com/NiklasMerz/fingerprint-aio-demo/tree/ionic-native)
---
### Install
**Install from NPM**
```
cordova plugin add cordova-plugin-fingerprint-aio --save
```
If you want to set a FaceID description use:
```
cordova plugin add cordova-plugin-fingerprint-aio --variable FACEID_USAGE_DESCRIPTION="Login now...."
```
**Use Release candidate**
You can use preview versions with the `rc` tag on npm.
```
cordova plugin add cordova-plugin-fingerprint-aio@rc
```
**Use this Github repo**
Get the latest development version. *Not recommended!*
```
cordova plugin add https://github.com/NiklasMerz/cordova-plugin-fingerprint-aio.git
```
### Check if fingerprint authentication is available
```javascript
Fingerprint.isAvailable(isAvailableSuccess, isAvailableError);
function isAvailableSuccess(result) {
/*
result depends on device and os.
iPhone X will return 'face' other Android or iOS devices will return 'finger'
*/
alert("Fingerprint available");
}
function isAvailableError(message) {
alert(message);
}
```
### Show authentication dialogue
```javascript
Fingerprint.show({
clientId: "Fingerprint-Demo",
clientSecret: "password" //Only necessary for Android
}, successCallback, errorCallback);
function successCallback(){
alert("Authentication successfull");
}
function errorCallback(err){
alert("Authentication invalid " + err);
}
```
**Optional parameters**
* __disableBackup__: If true remove backup option on authentication dialogue for Android. Default false.
* __localizedFallbackTitle__ (iOS only): Title of fallback button.
* __localizedReason__ (iOS only): Description in authentication dialogue.
## Thanks to the authors of the original fingerprint plugins
Some code is refactored from their projects and I learned how to make Cordova plugins from their great plugins:
@EddyVerbruggen and @mjwheatley
[Android](https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth)
[iOS](https://github.com/EddyVerbruggen/cordova-plugin-touch-id)
## License
* Project and iOS source -> MIT
* Android source -> MIT and Apache 2.0
{
"name": "cordova-plugin-fingerprint",
"version": "1.3.6",
"description": "Cordova plugin to use fingerprint authentication on Android",
"cordova": {
"id": "cordova-plugin-fingerprint",
"platforms": [
"android",
"ios"
]
},
"repository": {
"type": "git",
"url": "git+https://github.com/niklasmerz/cordova-plugin-fingerprint-aio"
},
"keywords": [
"cordova",
"plugin",
"android",
"fingerprint",
"authentication",
"ecosystem:cordova",
"cordova-android",
"cordova-ios",
"ios"
],
"author": "Niklas Merz",
"license": "MIT",
"bugs": {
"url": "https://github.com/niklasmerz/cordova-plugin-fingerprint-aio/issues"
},
"homepage": "https://github.com/niklasmerz/cordova-plugin-fingerprint-aio#readme",
"dependencies": {
"cordova-plugin-add-swift-support": "^1.7.1"
},
"devDependencies": {
"cordova-paramedic": "git+https://github.com/apache/cordova-paramedic.git",
"cordova-plugin-xml": "^0.1.2",
"eslint": "^4.19.1",
"jasmine": "^2.8.0"
},
"scripts": {
"test": "./node_modules/cordova-paramedic/main.js --plugin . --platform",
"plugin-version": "cordova-plugin-xml setVersion"
}
}
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-fingerprint" version="1.3.6">
<name>FingerprintAllInOne</name>
<description>Cordova plugin to use fingerprint on Android</description>
<license>MIT</license>
<keywords>cordova,plugin,android,fingerprint,authentication</keywords>
<repo>https://github.com/niklasmerz/cordova-plugin-fingerprint-aio.git</repo>
<issue>https://github.com/cordova-plugin-fingerprint-aio/issues</issue>
<js-module src="www/Fingerprint.js" name="Fingerprint">
<clobbers target="Fingerprint"/>
</js-module>
<!-- android -->
<platform name="android">
<config-file target="res/xml/config.xml" parent="/*">
<feature name="Fingerprint">
<param name="android-package" value="de.niklasmerz.cordova.fingerprint.Fingerprint"/>
</feature>
</config-file>
<config-file target="AndroidManifest.xml" parent="/*">
<uses-permission android:name="android.permission.USE_FINGERPRINT"/>
</config-file>
<source-file src="src/android/Fingerprint.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="src/android/FingerprintAuthenticationDialogFragment.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="src/android/FingerprintUiHelper.java" target-dir="src/de/niklasmerz/cordova/fingerprint"/>
<source-file src="res/android/drawable/ic_fingerprint_error.xml" target-dir="res/drawable"/>
<source-file src="res/android/drawable/ic_fingerprint_success.xml" target-dir="res/drawable"/>
<resource-file src="res/android/drawable-hdpi/ic_fp_40px.png" target="res/drawable-hdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-mdpi/ic_fp_40px.png" target="res/drawable-mdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-nodpi/android_robot.png" target="res/drawable-nodpi/android_robot.png"/>
<resource-file src="res/android/drawable-xhdpi/ic_fp_40px.png" target="res/drawable-xhdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxhdpi/ic_fp_40px.png" target="res/drawable-xxhdpi/ic_fp_40px.png"/>
<resource-file src="res/android/drawable-xxxhdpi/ic_fp_40px.png" target="res/drawable-xxxhdpi/ic_fp_40px.png"/>
<source-file src="res/android/layout/fingerprint_dialog_container.xml" target-dir="res/layout"/>
<source-file src="res/android/layout/fingerprint_dialog_content.xml" target-dir="res/layout"/>
<source-file src="res/android/values/fpauth-colors.xml" target-dir="res/values"/>
<source-file src="res/android/values/fpauth-strings.xml" target-dir="res/values"/>
<source-file src="res/android/values-es/fpauth-strings.xml" target-dir="res/values-es"/>
<source-file src="res/android/values-de/fpauth-strings.xml" target-dir="res/values-de"/>
<source-file src="res/android/values-fr/fpauth-strings.xml" target-dir="res/values-fr"/>
<source-file src="res/android/values-zh/fpauth-strings.xml" target-dir="res/values-zh"/>
<source-file src="res/android/values-pt/fpauth-strings.xml" target-dir="res/values-pt"/>
<source-file src="res/android/values-it/fpauth-strings.xml" target-dir="res/values-it"/>
<source-file src="res/android/values-el/fpauth-strings.xml" target-dir="res/values-el"/>
<source-file src="res/android/values-zh-rTW/fpauth-strings.xml" target-dir="res/values-zh-rTW"/>
</platform>
</plugin>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,0.0C8.96,0.0 0.0,8.95 0.0,20.0s8.96,20.0 20.0,20.0c11.04,0.0 20.0,-8.95 20.0,-20.0S31.04,0.0 20.0,0.0z"
android:fillColor="#F4511E"/>
<path
android:pathData="M21.33,29.33l-2.67,0.0l0.0,-2.67l2.67,0.0L21.33,29.33zM21.33,22.67l-2.67,0.0l0.0,-12.0l2.67,0.0L21.33,22.67z"
android:fillColor="#FFFFFF"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="40.0dp"
android:height="40.0dp"
android:viewportWidth="40.0"
android:viewportHeight="40.0">
<path
android:pathData="M20.0,20.0m-20.0,0.0a20.0,20.0 0.0,1.0 1.0,40.0 0.0a20.0,20.0 0.0,1.0 1.0,-40.0 0.0"
android:fillColor="#009688"/>
<path
android:pathData="M11.2,21.41l1.63,-1.619999 4.17,4.169998 10.59,-10.589999 1.619999,1.63 -12.209999,12.209999z"
android:fillColor="#FFFFFF"/>
</vector>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<include layout="@layout/fingerprint_dialog_content" />
</FrameLayout>
<LinearLayout
android:id="@+id/buttonPanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:paddingStart="12dp"
android:paddingEnd="12dp"
android:paddingTop="4dp"
android:paddingBottom="4dp"
android:gravity="bottom"
style="?android:attr/buttonBarStyle">
<Space
android:id="@+id/spacer"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1"
android:visibility="invisible" />
<Button
android:id="@+id/cancel_button"
style="?android:attr/buttonBarNegativeButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<Button
android:id="@+id/second_dialog_button"
style="?android:attr/buttonBarPositiveButtonStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
</LinearLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fingerprint_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="8dp"
android:paddingStart="24dp"
android:paddingEnd="24dp"
android:paddingTop="16dp">
<TextView
android:id="@+id/fingerprint_description"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="@string/fingerprint_description"
android:textAppearance="@android:style/TextAppearance.Material.Subhead"
android:textColor="?android:attr/textColorSecondary"/>
<ImageView
android:id="@+id/fingerprint_icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentStart="true"
android:layout_below="@+id/fingerprint_description"
android:layout_marginTop="20dp"
android:src="@drawable/ic_fp_40px" />
<TextView
android:id="@+id/fingerprint_status"
style="@android:style/TextAppearance.Material.Body1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/fingerprint_icon"
android:layout_alignTop="@+id/fingerprint_icon"
android:layout_marginStart="16dp"
android:layout_toEndOf="@+id/fingerprint_icon"
android:gravity="center_vertical"
android:text="@string/fingerprint_hint"
android:textColor="@color/hint_color" />
</RelativeLayout>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<resources>
<string name="fingerprint_cancel">Abbrechen</string>
<string name="fingerprint_use_backup">Passwort</string>
<string name="fingerprint_auth_dialog_title">Authentifizierung</string>
<string name="fingerprint_ok">OK</string>
<string name="fingerprint_description">Fingerabdruck bestätigen</string>
<string name="fingerprint_hint">Fingerabdrucksensor</string>
<string name="fingerprint_not_recognized">Fingerabdruck nicht erkannt. Versuchen Sie es erneut</string>
<string name="fingerprint_success">Authentifiziert</string>
<string name="new_fingerprint_enrolled_description">Ein neuer Fingerabdruck wurde gespeichert. Bitte geben Sie ihr Passwort ein.</string>
<string name="secure_lock_screen_required">Passwortgeschützter Sperrbildschirm benötigt</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fingerprint_cancel">Ακύρωση</string>
<string name="fingerprint_use_backup">Χρήση αρχείου</string>
<string name="fingerprint_auth_dialog_title">Ελεγχος αποτυπώματος</string>
<string name="fingerprint_ok">Ok</string>
<string name="fingerprint_description">Επιβεβαίωση αποτυπώματος</string>
<string name="fingerprint_hint">Αιθηστήρας αφής</string>
<string name="fingerprint_not_recognized">Σφάλμα. Προσπαθήστε ξανά</string>
<string name="fingerprint_success">Σωστό αποτύπωμα</string>
<string name="new_fingerprint_enrolled_description">Νεο αποτύπωμα προστέθηκε , απαιτείται ο κωδικός σας.</string>
<string name="secure_lock_screen_required">Απαιτείται κλειδωμα οθόνης</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<resources>
<string name="fingerprint_cancel">Cancelar</string>
<string name="fingerprint_use_backup">El Respaldo</string>
<string name="fingerprint_auth_dialog_title">Autenticación de Huellas Digitales</string>
<string name="fingerprint_ok">De Acuerdo</string>
<string name="fingerprint_description">Confirmar la huella digital para continuar</string>
<string name="fingerprint_hint">Sensor tactil</string>
<string name="fingerprint_not_recognized">No se reconoce la huella digital. Inténtalo de nuevo.</string>
<string name="fingerprint_success">Reconocido de huella dactilar</string>
<string name="new_fingerprint_enrolled_description">Una nueva huella digital fue agregada a este dispositivo, por lo que se requiere la contraseña.</string>
<string name="secure_lock_screen_required">¡Requiere pantalla de bloqueo seguro!</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<resources>
<string name="fingerprint_cancel">Annuler</string>
<string name="fingerprint_use_backup">Utiliser la sauvegarde</string>
<string name="fingerprint_auth_dialog_title">Authentification par empreinte digitale</string>
<string name="fingerprint_ok">Ok</string>
<string name="fingerprint_description">Confirmer l\'empreinte pour continuer</string>
<string name="fingerprint_hint">Toucher le capteur</string>
<string name="fingerprint_not_recognized">Empreinte non reconnue. Essayer à nouveau.</string>
<string name="fingerprint_success">Empreinte reconnue</string>
<string name="new_fingerprint_enrolled_description">Une nouvelle empreinte digitale a été ajoutée à ce dispositif, de sorte que votre mot de passe est nécessaire.</string>
<string name="secure_lock_screen_required">Écran de verrouillage sécurisé nécessaire!</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fingerprint_cancel">Cancella</string>
<string name="fingerprint_use_backup">Usa backup</string>
<string name="fingerprint_auth_dialog_title">Autenticazione impronta digitale</string>
<string name="fingerprint_ok">Ok</string>
<string name="fingerprint_description">Conferma l\'impronta digitale per continuare</string>
<string name="fingerprint_hint">Sensore Touch</string>
<string name="fingerprint_not_recognized">Impronta digitale non riconosciuta. Riprova.</string>
<string name="fingerprint_success">Impronta digitale riconosciuta</string>
<string name="new_fingerprint_enrolled_description">Una nuova impronta è stata aggiunta a questo dispositivo, quindi è necessaria la tua password</string>
<string name="secure_lock_screen_required">Blocco schermo richiesto!</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fingerprint_cancel">Cancelar</string>
<string name="fingerprint_use_backup">Use o backup</string>
<string name="fingerprint_auth_dialog_title">Autenticação de impressão digital</string>
<string name="fingerprint_ok">Ok</string>
<string name="fingerprint_description">Confirme a impressão digital para continuar</string>
<string name="fingerprint_hint">Sensor de toque</string>
<string name="fingerprint_not_recognized">impressão digital não reconhecida. Tente novamente.</string>
<string name="fingerprint_success">impressão digital reconhecida</string>
<string name="new_fingerprint_enrolled_description">Uma nova impressão digital foi adicionada a este dispositivo, é necessário o seu código</string>
<string name="secure_lock_screen_required">É necessário um ecrã de bloqueio seguro!</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fingerprint_cancel">取消</string>
<string name="fingerprint_use_backup">使用密码</string>
<string name="fingerprint_auth_dialog_title">"车租易"的指纹</string>
<string name="fingerprint_ok">确认</string><string name="fingerprint_description">验证已存在的指纹</string>
<string name="fingerprint_hint">请触摸指纹识传感器</string>
<string name="fingerprint_not_recognized">指纹无法识别,请再试一次</string>
<string name="fingerprint_success">指纹识别成功</string>
<string name="new_fingerprint_enrolled_description">添加一个新的指纹,需要设置密码</string>
<string name="secure_lock_screen_required">指纹验证失败,屏幕已被锁定</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="fingerprint_cancel">取消</string>
<string name="fingerprint_use_backup">使用密码</string>
<string name="fingerprint_auth_dialog_title">"车租易"的指纹</string>
<string name="fingerprint_ok">确认</string><string name="fingerprint_description">验证已存在的指纹</string>
<string name="fingerprint_hint">请触摸指纹识传感器</string>
<string name="fingerprint_not_recognized">指纹无法识别,请再试一次</string>
<string name="fingerprint_success">指纹识别成功</string>
<string name="new_fingerprint_enrolled_description">添加一个新的指纹,需要设置密码</string>
<string name="secure_lock_screen_required">指纹验证失败,屏幕已被锁定</string>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<resources>
<color name="warning_color">#f4511e</color>
<color name="hint_color">#42000000</color>
<color name="success_color">#009688</color>
</resources>
<?xml version="1.0" encoding="utf-8"?>
<!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ Licensed under the Apache License, Version 2.0 (the "License");
~ you may not use this file except in compliance with the License.
~ You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing, software
~ distributed under the License is distributed on an "AS IS" BASIS,
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
~ See the License for the specific language governing permissions and
~ limitations under the License
-->
<resources>
<string name="fingerprint_cancel">取消</string>
<string name="fingerprint_use_backup">Use backup</string>
<string name="fingerprint_auth_dialog_title">"车租易"的指纹</string>
<string name="fingerprint_ok">确认</string>
<string name="fingerprint_description">通过Home验证已存在的指纹</string>
<string name="fingerprint_hint">Touch sensor</string>
<string name="fingerprint_not_recognized">识别失败,请从新识别</string>
<string name="fingerprint_success">识别成功</string>
<string name="new_fingerprint_enrolled_description">添加新的指纹到当前设备,请输入开机密码</string>
<string name="secure_lock_screen_required">指纹验证失败,屏幕已被锁定</string>
</resources>
This diff is collapsed.
This diff is collapsed.
/*
* Copyright (C) 2015 The Android Open Source Project
* Modifications copyright (C) 2016 Niklas Merz
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License
*/
package de.niklasmerz.cordova.fingerprint;
import android.annotation.TargetApi;
import android.content.Context;
import android.hardware.fingerprint.FingerprintManager;
import android.os.CancellationSignal;
import android.widget.ImageView;
import android.widget.TextView;
/**
* Small helper class to manage text/icon around fingerprint authentication UI.
*/
@TargetApi(23)
public class FingerprintUiHelper extends FingerprintManager.AuthenticationCallback {
static final long ERROR_TIMEOUT_MILLIS = 1600;
static final long SUCCESS_DELAY_MILLIS = 1300;
private final Context mContext;
private final FingerprintManager mFingerprintManager;
private final ImageView mIcon;
private final TextView mErrorTextView;
private final Callback mCallback;
private CancellationSignal mCancellationSignal;
boolean mSelfCancelled;
/**
* Builder class for {@link FingerprintUiHelper} in which injected fields from Dagger
* holds its fields and takes other arguments in the {@link #build} method.
*/
public static class FingerprintUiHelperBuilder {
private final FingerprintManager mFingerPrintManager;
private final Context mContext;
public FingerprintUiHelperBuilder(Context context, FingerprintManager fingerprintManager) {
mFingerPrintManager = fingerprintManager;
mContext = context;
}
public FingerprintUiHelper build(ImageView icon, TextView errorTextView, Callback callback) {
return new FingerprintUiHelper(mContext, mFingerPrintManager, icon, errorTextView,
callback);
}
}
/**
* Constructor for {@link FingerprintUiHelper}. This method is expected to be called from
* only the {@link FingerprintUiHelperBuilder} class.
*/
private FingerprintUiHelper(Context context, FingerprintManager fingerprintManager,
ImageView icon, TextView errorTextView, Callback callback) {
mFingerprintManager = fingerprintManager;
mIcon = icon;
mErrorTextView = errorTextView;
mCallback = callback;
mContext = context;
}
public boolean isFingerprintAuthAvailable() {
return mFingerprintManager.isHardwareDetected()
&& mFingerprintManager.hasEnrolledFingerprints();
}
public void startListening(FingerprintManager.CryptoObject cryptoObject) {
if (!isFingerprintAuthAvailable()) {
return;
}
mCancellationSignal = new CancellationSignal();
mSelfCancelled = false;
mFingerprintManager
.authenticate(cryptoObject, mCancellationSignal, 0 /* flags */, this, null);
int ic_fp_40px_id = mContext.getResources()
.getIdentifier("ic_fp_40px", "drawable", Fingerprint.packageName);
mIcon.setImageResource(ic_fp_40px_id);
}
public void stopListening() {
if (mCancellationSignal != null) {
mSelfCancelled = true;
mCancellationSignal.cancel();
mCancellationSignal = null;
}
}
@Override
public void onAuthenticationError(int errMsgId, CharSequence errString) {
if (!mSelfCancelled) {
showError(errString);
mIcon.postDelayed(new Runnable() {
@Override
public void run() {
mCallback.onError();
}
}, ERROR_TIMEOUT_MILLIS);
}
}
@Override
public void onAuthenticationHelp(int helpMsgId, CharSequence helpString) {
showError(helpString);
}
@Override
public void onAuthenticationFailed() {
int fingerprint_not_recognized_id = mContext.getResources()
.getIdentifier("fingerprint_not_recognized", "string", Fingerprint.packageName);
showError(mIcon.getResources().getString(
fingerprint_not_recognized_id));
}
@Override
public void onAuthenticationSucceeded(FingerprintManager.AuthenticationResult result) {
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
int ic_fingerprint_success_id = mContext.getResources()
.getIdentifier("ic_fingerprint_success", "drawable", Fingerprint.packageName);
mIcon.setImageResource(ic_fingerprint_success_id);
int success_color_id = mContext.getResources()
.getIdentifier("success_color", "color", Fingerprint.packageName);
mErrorTextView.setTextColor(
mErrorTextView.getResources().getColor(success_color_id, null));
int fingerprint_success_id = mContext.getResources()
.getIdentifier("fingerprint_success", "string", Fingerprint.packageName);
mErrorTextView.setText(
mErrorTextView.getResources().getString(fingerprint_success_id));
mIcon.postDelayed(new Runnable() {
@Override
public void run() {
mCallback.onAuthenticated();
}
}, SUCCESS_DELAY_MILLIS);
}
private void showError(CharSequence error) {
int ic_fingerprint_error_id = mContext.getResources()
.getIdentifier("ic_fingerprint_error", "drawable", Fingerprint.packageName);
mIcon.setImageResource(ic_fingerprint_error_id);
mErrorTextView.setText(error);
int warning_color_id = mContext.getResources()
.getIdentifier("warning_color", "color", Fingerprint.packageName);
mErrorTextView.setTextColor(
mErrorTextView.getResources().getColor(warning_color_id, null));
mErrorTextView.removeCallbacks(mResetErrorTextRunnable);
mErrorTextView.postDelayed(mResetErrorTextRunnable, ERROR_TIMEOUT_MILLIS);
}
Runnable mResetErrorTextRunnable = new Runnable() {
@Override
public void run() {
int hint_color_id = mContext.getResources()
.getIdentifier("hint_color", "color", Fingerprint.packageName);
mErrorTextView.setTextColor(
mErrorTextView.getResources().getColor(hint_color_id, null));
int fingerprint_hint_id = mContext.getResources()
.getIdentifier("fingerprint_hint", "string", Fingerprint.packageName);
mErrorTextView.setText(
mErrorTextView.getResources().getString(fingerprint_hint_id));
int ic_fp_40px_id = mContext.getResources()
.getIdentifier("ic_fp_40px", "drawable", Fingerprint.packageName);
mIcon.setImageResource(ic_fp_40px_id);
}
};
public interface Callback {
void onAuthenticated();
void onError();
}
}
{
"name": "cordova-plugin-fingerprint-aio-tests",
"version": "2.0.0-dev",
"description": "",
"cordova": {
"id": "cordova-plugin-fingerprint-aio-tests",
"platforms": ["android", "ios"]
},
"keywords": [
"ecosystem:cordova"
],
"author": "Niklas Merz",
"license": "MIT"
}
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
xmlns:android="http://schemas.android.com/apk/res/android"
id="cordova-plugin-fingerprint-aio-tests"
version="0.1.0">
<name>FingerprintAllInOne Tests</name>
<description>Cordova plugin to use fingerprint on Android and iOS</description>
<license>MIT</license>
<keywords>cordova,plugin,android,fingerprint,authentication,ios</keywords>
<repo>https://github.com/niklasmerz/cordova-plugin-fingerprint-aio.git</repo>
<issue>https://github.com/cordova-plugin-fingerprint-aio/issues</issue>
<js-module src="tests.js" name="tests">
</js-module>
</plugin>
/* global Fingerprint */
/* eslint-disable no-alert, no-console */
exports.defineAutoTests = function() {
describe("Fingerprint Object", function () {
it("should exist", function() {
expect(window.Fingerprint).toBeDefined();
});
});
describe("isAvailable", function () {
it("isAvailable schould be defined", function () {
expect(window.Fingerprint.isAvailable).toBeDefined();
});
it("isAvailable schould return an result or error in callback", function (done) {
window.Fingerprint.isAvailable( function (result) {
expect(result).toBeDefined();
done();
}, function(result) {
expect(result).toBeDefined();
done();
});
});
});
describe("show", function () {
it("show schould be defined", function () {
expect(window.Fingerprint.show).toBeDefined();
});
});
};
exports.defineManualTests = function (contentEl, createActionButton) {
createActionButton("isAvailable", function () {
window.Fingerprint.isAvailable(isAvailableSuccess, isAvailableError);
function isAvailableSuccess(result) {
console.log(result);
alert("Fingerprint available (" + result + ")");
}
function isAvailableError(message) {
alert(message);
}
});
createActionButton("show", function () {
Fingerprint.show({
clientId: "Fingerprint-Tests",
clientSecret: "password",
disableBackup: false
}, successCallback, errorCallback);
function successCallback() {
alert("Authentication successfull");
}
function errorCallback(err) {
alert("Authentication invalid " + err);
}
});
createActionButton("show-disablebackup", function () {
Fingerprint.show({
clientId: "Fingerprint-Tests",
clientSecret: "password",
disableBackup: true
}, successCallback, errorCallback);
function successCallback() {
alert("Authentication successfull");
}
function errorCallback(err) {
alert("Authentication invalid " + err);
}
});
};
/*global cordova */
function Fingerprint() {
}
Fingerprint.prototype.show = function (params, successCallback, errorCallback) {
cordova.exec(
successCallback,
errorCallback,
"Fingerprint",
"authenticate",
[params]
);
};
Fingerprint.prototype.isAvailable = function (successCallback, errorCallback) {
cordova.exec(
successCallback,
errorCallback,
"Fingerprint",
"isAvailable",
[{}]
);
};
module.exports = new Fingerprint();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment