2018-03-04 11:35:37 -08:00
|
|
|
/*
|
2011-12-20 10:20:44 -08:00
|
|
|
* Copyright (C) 2011 Whisper Systems
|
2012-07-31 14:18:14 -07:00
|
|
|
*
|
2011-12-20 10:20:44 -08:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
2012-07-31 14:18:14 -07:00
|
|
|
*
|
2011-12-20 10:20:44 -08:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
package org.thoughtcrime.securesms;
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
import android.animation.Animator;
|
|
|
|
import android.app.KeyguardManager;
|
|
|
|
import android.content.Context;
|
2014-02-25 19:53:12 -08:00
|
|
|
import android.content.Intent;
|
2018-03-04 11:35:37 -08:00
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.os.Build;
|
2011-12-20 10:20:44 -08:00
|
|
|
import android.os.Bundle;
|
2012-08-07 19:06:23 -07:00
|
|
|
import android.text.Editable;
|
2015-07-24 03:16:45 +12:00
|
|
|
import android.text.InputType;
|
2014-05-13 20:41:16 -07:00
|
|
|
import android.text.SpannableString;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.style.RelativeSizeSpan;
|
|
|
|
import android.text.style.TypefaceSpan;
|
2014-05-30 11:40:23 +02:00
|
|
|
import android.view.KeyEvent;
|
2014-06-28 20:40:57 -07:00
|
|
|
import android.view.Menu;
|
|
|
|
import android.view.MenuInflater;
|
|
|
|
import android.view.MenuItem;
|
2011-12-20 10:20:44 -08:00
|
|
|
import android.view.View;
|
|
|
|
import android.view.View.OnClickListener;
|
2018-03-04 11:35:37 -08:00
|
|
|
import android.view.WindowManager;
|
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.view.animation.BounceInterpolator;
|
|
|
|
import android.view.animation.TranslateAnimation;
|
2014-05-30 11:40:23 +02:00
|
|
|
import android.view.inputmethod.EditorInfo;
|
2020-01-09 11:35:43 +11:00
|
|
|
import android.widget.Button;
|
2011-12-20 10:20:44 -08:00
|
|
|
import android.widget.EditText;
|
2014-05-13 20:41:16 -07:00
|
|
|
import android.widget.ImageButton;
|
2018-03-04 11:35:37 -08:00
|
|
|
import android.widget.ImageView;
|
2014-05-30 11:40:23 +02:00
|
|
|
import android.widget.TextView;
|
2011-12-20 10:20:44 -08:00
|
|
|
|
2020-09-08 12:04:51 +10:00
|
|
|
import androidx.core.hardware.fingerprint.FingerprintManagerCompat;
|
|
|
|
import androidx.core.os.CancellationSignal;
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
import org.thoughtcrime.securesms.animation.AnimationCompleteListener;
|
2015-07-24 03:16:45 +12:00
|
|
|
import org.thoughtcrime.securesms.components.AnimatingToggle;
|
2012-07-31 14:18:14 -07:00
|
|
|
import org.thoughtcrime.securesms.crypto.InvalidPassphraseException;
|
2018-03-04 11:35:37 -08:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecret;
|
2012-07-31 14:18:14 -07:00
|
|
|
import org.thoughtcrime.securesms.crypto.MasterSecretUtil;
|
2019-07-24 12:30:23 +10:00
|
|
|
import org.thoughtcrime.securesms.logging.Log;
|
2014-12-11 15:04:32 -08:00
|
|
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
2018-03-04 11:35:37 -08:00
|
|
|
import org.thoughtcrime.securesms.util.TextSecurePreferences;
|
2012-07-31 14:18:14 -07:00
|
|
|
|
2019-07-24 12:30:23 +10:00
|
|
|
import network.loki.messenger.R;
|
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
/**
|
2014-05-13 20:41:16 -07:00
|
|
|
* Activity that prompts for a user's passphrase.
|
2012-07-31 14:18:14 -07:00
|
|
|
*
|
|
|
|
* @author Moxie Marlinspike
|
2011-12-20 10:20:44 -08:00
|
|
|
*/
|
|
|
|
public class PassphrasePromptActivity extends PassphraseActivity {
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
private static final String TAG = PassphrasePromptActivity.class.getSimpleName();
|
|
|
|
|
2015-03-09 00:32:57 +01:00
|
|
|
private DynamicLanguage dynamicLanguage = new DynamicLanguage();
|
2014-12-11 15:04:32 -08:00
|
|
|
|
2019-08-30 10:24:39 +10:00
|
|
|
private View passphraseAuthContainer;
|
|
|
|
private ImageView fingerprintPrompt;
|
2020-01-09 11:35:43 +11:00
|
|
|
private Button lockScreenButton;
|
2018-03-04 11:35:37 -08:00
|
|
|
|
2015-07-24 03:16:45 +12:00
|
|
|
private EditText passphraseText;
|
2020-09-08 12:04:51 +10:00
|
|
|
private ImageButton showButton;
|
|
|
|
private ImageButton hideButton;
|
2015-07-24 03:16:45 +12:00
|
|
|
private AnimatingToggle visibilityToggle;
|
2012-07-31 14:18:14 -07:00
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
private FingerprintManagerCompat fingerprintManager;
|
|
|
|
private CancellationSignal fingerprintCancellationSignal;
|
|
|
|
private FingerprintListener fingerprintListener;
|
|
|
|
|
2018-03-08 17:41:27 -08:00
|
|
|
private boolean authenticated;
|
2018-03-09 10:25:29 -08:00
|
|
|
private boolean failure;
|
2018-03-08 17:41:27 -08:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
@Override
|
|
|
|
public void onCreate(Bundle savedInstanceState) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onCreate()");
|
2014-12-11 15:04:32 -08:00
|
|
|
dynamicLanguage.onCreate(this);
|
2011-12-20 10:20:44 -08:00
|
|
|
super.onCreate(savedInstanceState);
|
|
|
|
|
|
|
|
setContentView(R.layout.prompt_passphrase_activity);
|
|
|
|
initializeResources();
|
|
|
|
}
|
2012-07-31 14:18:14 -07:00
|
|
|
|
2014-12-11 15:04:32 -08:00
|
|
|
@Override
|
|
|
|
public void onResume() {
|
|
|
|
super.onResume();
|
|
|
|
dynamicLanguage.onResume(this);
|
2018-03-04 11:35:37 -08:00
|
|
|
|
2018-03-09 10:25:29 -08:00
|
|
|
setLockTypeVisibility();
|
|
|
|
|
|
|
|
if (TextSecurePreferences.isScreenLockEnabled(this) && !authenticated && !failure) {
|
2018-03-04 11:35:37 -08:00
|
|
|
resumeScreenLock();
|
|
|
|
}
|
2018-03-09 10:25:29 -08:00
|
|
|
|
|
|
|
failure = false;
|
2018-03-04 11:35:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onPause() {
|
|
|
|
super.onPause();
|
|
|
|
|
|
|
|
if (TextSecurePreferences.isScreenLockEnabled(this)) {
|
|
|
|
pauseScreenLock();
|
|
|
|
}
|
2014-12-11 15:04:32 -08:00
|
|
|
}
|
|
|
|
|
2014-12-15 12:25:55 -08:00
|
|
|
@Override
|
|
|
|
protected void onNewIntent(Intent intent) {
|
|
|
|
super.onNewIntent(intent);
|
|
|
|
setIntent(intent);
|
|
|
|
}
|
|
|
|
|
2014-02-25 19:53:12 -08:00
|
|
|
@Override
|
|
|
|
public boolean onPrepareOptionsMenu(Menu menu) {
|
2014-06-28 20:40:57 -07:00
|
|
|
MenuInflater inflater = this.getMenuInflater();
|
2014-02-25 19:53:12 -08:00
|
|
|
menu.clear();
|
|
|
|
|
2019-08-30 10:24:39 +10:00
|
|
|
// inflater.inflate(R.menu.log_submit, menu);
|
2014-02-25 19:53:12 -08:00
|
|
|
super.onPrepareOptionsMenu(menu);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean onOptionsItemSelected(MenuItem item) {
|
|
|
|
super.onOptionsItemSelected(item);
|
|
|
|
switch (item.getItemId()) {
|
|
|
|
case R.id.menu_submit_debug_logs: handleLogSubmit(); return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
public void onActivityResult(int requestCode, int resultcode, Intent data) {
|
|
|
|
if (requestCode != 1) return;
|
|
|
|
|
|
|
|
if (resultcode == RESULT_OK) {
|
|
|
|
handleAuthenticated();
|
|
|
|
} else {
|
|
|
|
Log.w(TAG, "Authentication failed");
|
2018-03-09 10:25:29 -08:00
|
|
|
failure = true;
|
2018-03-04 11:35:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-02-25 19:53:12 -08:00
|
|
|
private void handleLogSubmit() {
|
|
|
|
Intent intent = new Intent(this, LogSubmitActivity.class);
|
|
|
|
startActivity(intent);
|
|
|
|
}
|
|
|
|
|
2014-05-30 11:40:23 +02:00
|
|
|
private void handlePassphrase() {
|
|
|
|
try {
|
|
|
|
Editable text = passphraseText.getText();
|
|
|
|
String passphrase = (text == null ? "" : text.toString());
|
2014-12-15 12:25:55 -08:00
|
|
|
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, passphrase);
|
2014-05-30 11:40:23 +02:00
|
|
|
|
|
|
|
setMasterSecret(masterSecret);
|
|
|
|
} catch (InvalidPassphraseException ipe) {
|
|
|
|
passphraseText.setText("");
|
2016-02-19 23:27:31 +00:00
|
|
|
passphraseText.setError(
|
|
|
|
getString(R.string.PassphrasePromptActivity_invalid_passphrase_exclamation));
|
2014-05-30 11:40:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
private void handleAuthenticated() {
|
|
|
|
try {
|
2018-03-08 17:41:27 -08:00
|
|
|
authenticated = true;
|
|
|
|
|
2018-03-04 11:35:37 -08:00
|
|
|
MasterSecret masterSecret = MasterSecretUtil.getMasterSecret(this, MasterSecretUtil.UNENCRYPTED_PASSPHRASE);
|
|
|
|
setMasterSecret(masterSecret);
|
|
|
|
} catch (InvalidPassphraseException e) {
|
|
|
|
throw new AssertionError(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-24 03:16:45 +12:00
|
|
|
private void setPassphraseVisibility(boolean visibility) {
|
|
|
|
int cursorPosition = passphraseText.getSelectionStart();
|
|
|
|
if (visibility) {
|
|
|
|
passphraseText.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
|
|
InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);
|
|
|
|
} else {
|
|
|
|
passphraseText.setInputType(InputType.TYPE_CLASS_TEXT |
|
|
|
|
InputType.TYPE_TEXT_VARIATION_PASSWORD);
|
|
|
|
}
|
|
|
|
passphraseText.setSelection(cursorPosition);
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
private void initializeResources() {
|
2018-03-09 10:25:29 -08:00
|
|
|
|
2020-09-08 12:04:51 +10:00
|
|
|
ImageButton okButton = findViewById(R.id.ok_button);
|
2014-05-13 20:41:16 -07:00
|
|
|
|
2020-09-08 12:04:51 +10:00
|
|
|
showButton = findViewById(R.id.passphrase_visibility);
|
|
|
|
hideButton = findViewById(R.id.passphrase_visibility_off);
|
2018-03-04 11:35:37 -08:00
|
|
|
visibilityToggle = findViewById(R.id.button_toggle);
|
|
|
|
passphraseText = findViewById(R.id.passphrase_edit);
|
2018-03-09 10:25:29 -08:00
|
|
|
passphraseAuthContainer = findViewById(R.id.password_auth_container);
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintPrompt = findViewById(R.id.fingerprint_auth_container);
|
2018-03-09 10:25:29 -08:00
|
|
|
lockScreenButton = findViewById(R.id.lock_screen_auth_container);
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintManager = FingerprintManagerCompat.from(this);
|
|
|
|
fingerprintCancellationSignal = new CancellationSignal();
|
|
|
|
fingerprintListener = new FingerprintListener();
|
|
|
|
|
2015-01-20 21:26:58 -10:00
|
|
|
SpannableString hint = new SpannableString(" " + getString(R.string.PassphrasePromptActivity_enter_passphrase));
|
|
|
|
hint.setSpan(new RelativeSizeSpan(0.9f), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
2014-05-13 20:41:16 -07:00
|
|
|
hint.setSpan(new TypefaceSpan("sans-serif"), 0, hint.length(), Spanned.SPAN_INCLUSIVE_INCLUSIVE);
|
2015-01-20 21:26:58 -10:00
|
|
|
|
2014-05-13 20:41:16 -07:00
|
|
|
passphraseText.setHint(hint);
|
2020-09-08 12:04:51 +10:00
|
|
|
okButton.setOnClickListener(new OkButtonClickListener());
|
|
|
|
showButton.setOnClickListener(new ShowButtonOnClickListener());
|
|
|
|
hideButton.setOnClickListener(new HideButtonOnClickListener());
|
2014-05-30 11:40:23 +02:00
|
|
|
passphraseText.setOnEditorActionListener(new PassphraseActionListener());
|
2020-09-08 12:04:51 +10:00
|
|
|
passphraseText.setImeActionLabel(getString(R.string.prompt_passphrase_activity__unlock), EditorInfo.IME_ACTION_DONE);
|
2018-03-04 11:35:37 -08:00
|
|
|
|
|
|
|
fingerprintPrompt.setImageResource(R.drawable.ic_fingerprint_white_48dp);
|
|
|
|
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.signal_primary), PorterDuff.Mode.SRC_IN);
|
|
|
|
|
2018-03-09 10:25:29 -08:00
|
|
|
lockScreenButton.setOnClickListener(v -> resumeScreenLock());
|
|
|
|
}
|
|
|
|
|
|
|
|
private void setLockTypeVisibility() {
|
2018-03-04 11:35:37 -08:00
|
|
|
if (TextSecurePreferences.isScreenLockEnabled(this)) {
|
|
|
|
passphraseAuthContainer.setVisibility(View.GONE);
|
2018-03-09 10:25:29 -08:00
|
|
|
|
|
|
|
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
|
|
|
|
fingerprintPrompt.setVisibility(View.VISIBLE);
|
|
|
|
lockScreenButton.setVisibility(View.GONE);
|
|
|
|
} else {
|
|
|
|
fingerprintPrompt.setVisibility(View.GONE);
|
|
|
|
lockScreenButton.setVisibility(View.VISIBLE);
|
|
|
|
}
|
2018-03-04 11:35:37 -08:00
|
|
|
} else {
|
|
|
|
passphraseAuthContainer.setVisibility(View.VISIBLE);
|
|
|
|
fingerprintPrompt.setVisibility(View.GONE);
|
2018-03-09 10:25:29 -08:00
|
|
|
lockScreenButton.setVisibility(View.GONE);
|
2018-03-04 11:35:37 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void resumeScreenLock() {
|
|
|
|
KeyguardManager keyguardManager = (KeyguardManager) getSystemService(Context.KEYGUARD_SERVICE);
|
|
|
|
|
|
|
|
assert keyguardManager != null;
|
|
|
|
|
2019-03-20 15:09:27 -07:00
|
|
|
if (!keyguardManager.isKeyguardSecure()) {
|
2018-03-04 11:35:37 -08:00
|
|
|
Log.w(TAG ,"Keyguard not secure...");
|
|
|
|
handleAuthenticated();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-03-20 15:09:27 -07:00
|
|
|
if (fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints()) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "Listening for fingerprints...");
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintCancellationSignal = new CancellationSignal();
|
|
|
|
fingerprintManager.authenticate(null, 0, fingerprintCancellationSignal, fingerprintListener, null);
|
|
|
|
} else if (Build.VERSION.SDK_INT >= 21){
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "firing intent...");
|
2020-01-09 11:35:43 +11:00
|
|
|
Intent intent = keyguardManager.createConfirmDeviceCredentialIntent("Unlock Session", "");
|
2018-03-04 11:35:37 -08:00
|
|
|
startActivityForResult(intent, 1);
|
|
|
|
} else {
|
|
|
|
Log.w(TAG, "Not compatible...");
|
|
|
|
handleAuthenticated();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private void pauseScreenLock() {
|
2019-03-20 15:09:27 -07:00
|
|
|
if (fingerprintCancellationSignal != null) {
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintCancellationSignal.cancel();
|
|
|
|
}
|
2014-05-30 11:40:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private class PassphraseActionListener implements TextView.OnEditorActionListener {
|
|
|
|
@Override
|
|
|
|
public boolean onEditorAction(TextView exampleView, int actionId, KeyEvent keyEvent) {
|
|
|
|
if ((keyEvent == null && actionId == EditorInfo.IME_ACTION_DONE) ||
|
|
|
|
(keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_DOWN &&
|
|
|
|
(actionId == EditorInfo.IME_NULL)))
|
|
|
|
{
|
|
|
|
handlePassphrase();
|
|
|
|
return true;
|
|
|
|
} else if (keyEvent != null && keyEvent.getAction() == KeyEvent.ACTION_UP &&
|
|
|
|
actionId == EditorInfo.IME_NULL)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|
2012-07-31 14:18:14 -07:00
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
private class OkButtonClickListener implements OnClickListener {
|
2013-02-17 11:42:30 -08:00
|
|
|
@Override
|
2011-12-20 10:20:44 -08:00
|
|
|
public void onClick(View v) {
|
2014-05-30 11:40:23 +02:00
|
|
|
handlePassphrase();
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|
|
|
|
}
|
2012-07-31 14:18:14 -07:00
|
|
|
|
2015-07-24 03:16:45 +12:00
|
|
|
private class ShowButtonOnClickListener implements OnClickListener {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2020-09-08 12:04:51 +10:00
|
|
|
visibilityToggle.display(hideButton);
|
2015-07-24 03:16:45 +12:00
|
|
|
setPassphraseVisibility(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private class HideButtonOnClickListener implements OnClickListener {
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
2020-09-08 12:04:51 +10:00
|
|
|
visibilityToggle.display(showButton);
|
2015-07-24 03:16:45 +12:00
|
|
|
setPassphraseVisibility(false);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-12-20 10:20:44 -08:00
|
|
|
@Override
|
|
|
|
protected void cleanup() {
|
2013-05-06 19:27:09 -07:00
|
|
|
this.passphraseText.setText("");
|
2011-12-20 10:20:44 -08:00
|
|
|
System.gc();
|
|
|
|
}
|
2018-03-04 11:35:37 -08:00
|
|
|
|
|
|
|
private class FingerprintListener extends FingerprintManagerCompat.AuthenticationCallback {
|
|
|
|
@Override
|
|
|
|
public void onAuthenticationError(int errMsgId, CharSequence errString) {
|
|
|
|
Log.w(TAG, "Authentication error: " + errMsgId + " " + errString);
|
2018-08-14 13:04:33 -07:00
|
|
|
onAuthenticationFailed();
|
2018-03-04 11:35:37 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAuthenticationSucceeded(FingerprintManagerCompat.AuthenticationResult result) {
|
2018-08-02 09:25:33 -04:00
|
|
|
Log.i(TAG, "onAuthenticationSucceeded");
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintPrompt.setImageResource(R.drawable.ic_check_white_48dp);
|
2018-08-14 13:04:33 -07:00
|
|
|
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.green_500), PorterDuff.Mode.SRC_IN);
|
2018-03-04 11:35:37 -08:00
|
|
|
fingerprintPrompt.animate().setInterpolator(new BounceInterpolator()).scaleX(1.1f).scaleY(1.1f).setDuration(500).setListener(new AnimationCompleteListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animator animation) {
|
|
|
|
handleAuthenticated();
|
2018-08-14 13:04:33 -07:00
|
|
|
|
|
|
|
fingerprintPrompt.setImageResource(R.drawable.ic_fingerprint_white_48dp);
|
|
|
|
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.signal_primary), PorterDuff.Mode.SRC_IN);
|
2018-03-04 11:35:37 -08:00
|
|
|
}
|
|
|
|
}).start();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAuthenticationFailed() {
|
|
|
|
Log.w(TAG, "onAuthenticatoinFailed()");
|
|
|
|
FingerprintManagerCompat.AuthenticationCallback callback = this;
|
|
|
|
|
2018-08-14 13:04:33 -07:00
|
|
|
fingerprintPrompt.setImageResource(R.drawable.ic_close_white_48dp);
|
|
|
|
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.red_500), PorterDuff.Mode.SRC_IN);
|
2018-03-04 11:35:37 -08:00
|
|
|
|
2018-08-14 13:04:33 -07:00
|
|
|
TranslateAnimation shake = new TranslateAnimation(0, 30, 0, 0);
|
2018-03-04 11:35:37 -08:00
|
|
|
shake.setDuration(50);
|
2018-08-14 13:04:33 -07:00
|
|
|
shake.setRepeatCount(7);
|
2018-03-04 11:35:37 -08:00
|
|
|
shake.setAnimationListener(new Animation.AnimationListener() {
|
|
|
|
@Override
|
|
|
|
public void onAnimationStart(Animation animation) {}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationEnd(Animation animation) {
|
|
|
|
fingerprintPrompt.setImageResource(R.drawable.ic_fingerprint_white_48dp);
|
|
|
|
fingerprintPrompt.getBackground().setColorFilter(getResources().getColor(R.color.signal_primary), PorterDuff.Mode.SRC_IN);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void onAnimationRepeat(Animation animation) {}
|
|
|
|
});
|
|
|
|
|
|
|
|
fingerprintPrompt.startAnimation(shake);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2011-12-20 10:20:44 -08:00
|
|
|
}
|