2018-03-01 18:57:19 +00:00
|
|
|
package com.nauk.coinfolio.FingerprintToolkit;
|
|
|
|
|
2018-03-01 23:22:26 +00:00
|
|
|
import android.Manifest;
|
2018-03-01 18:57:19 +00:00
|
|
|
import android.app.AlertDialog;
|
|
|
|
import android.app.Dialog;
|
|
|
|
import android.app.DialogFragment;
|
2018-03-01 23:22:26 +00:00
|
|
|
import android.app.KeyguardManager;
|
|
|
|
import android.content.Context;
|
|
|
|
import android.content.pm.PackageManager;
|
|
|
|
import android.graphics.Color;
|
|
|
|
import android.graphics.PorterDuff;
|
|
|
|
import android.hardware.fingerprint.FingerprintManager;
|
|
|
|
import android.os.Build;
|
2018-03-01 18:57:19 +00:00
|
|
|
import android.os.Bundle;
|
2018-03-01 23:22:26 +00:00
|
|
|
import android.support.v4.app.ActivityCompat;
|
|
|
|
import android.support.v4.content.ContextCompat;
|
|
|
|
import android.support.v4.content.res.ResourcesCompat;
|
2018-03-01 18:57:19 +00:00
|
|
|
import android.view.LayoutInflater;
|
|
|
|
import android.view.View;
|
|
|
|
import android.view.ViewGroup;
|
2018-03-01 23:22:26 +00:00
|
|
|
import android.view.animation.Animation;
|
|
|
|
import android.widget.Button;
|
2018-03-02 11:19:57 +00:00
|
|
|
import android.widget.LinearLayout;
|
|
|
|
import android.widget.TextView;
|
2018-03-01 18:57:19 +00:00
|
|
|
|
2018-03-01 23:22:26 +00:00
|
|
|
import com.mattprecious.swirl.SwirlView;
|
|
|
|
import com.nauk.coinfolio.Activities.SettingsActivity;
|
2018-03-01 18:57:19 +00:00
|
|
|
import com.nauk.coinfolio.R;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Created by Guitoune on 28/02/2018.
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class FingerprintDialogFragment extends DialogFragment{
|
|
|
|
|
2018-03-01 23:22:26 +00:00
|
|
|
public static FingerprintDialogFragment newInstance()
|
2018-03-01 18:57:19 +00:00
|
|
|
{
|
|
|
|
FingerprintDialogFragment frag = new FingerprintDialogFragment();
|
|
|
|
Bundle args = new Bundle();
|
|
|
|
frag.setArguments(args);
|
|
|
|
return frag;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
|
|
|
|
{
|
2018-03-02 11:19:57 +00:00
|
|
|
|
2018-03-01 18:57:19 +00:00
|
|
|
View view = inflater.inflate(R.layout.fragment_fingerprint_scanner, container);
|
|
|
|
|
2018-03-02 11:19:57 +00:00
|
|
|
//getDialog().getWindow().setLayout(getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_width), getResources().getDimensionPixelSize(R.dimen.fingerprint_dialog_height));
|
|
|
|
|
2018-03-01 23:22:26 +00:00
|
|
|
((Button) view.findViewById(R.id.cancelButton)).setOnClickListener(new View.OnClickListener() {
|
|
|
|
@Override
|
|
|
|
public void onClick(View view) {
|
2018-03-02 11:19:57 +00:00
|
|
|
dismiss();
|
2018-03-01 23:22:26 +00:00
|
|
|
getActivity().finish();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
((SwirlView) view.findViewById(R.id.swirlBackground)).setState(SwirlView.State.ON, false);
|
|
|
|
|
2018-03-01 18:57:19 +00:00
|
|
|
return view;
|
|
|
|
}
|
2018-03-01 23:22:26 +00:00
|
|
|
|
|
|
|
public void correctFingerprint()
|
|
|
|
{
|
|
|
|
SwirlView swirlView = this.getView().findViewById(R.id.swirl);
|
|
|
|
|
|
|
|
swirlView.setColorFilter(getResources().getColor(R.color.colorAccent), PorterDuff.Mode.SRC_IN);
|
|
|
|
|
|
|
|
swirlView.setState(SwirlView.State.ON);
|
|
|
|
}
|
|
|
|
|
2018-03-02 11:19:57 +00:00
|
|
|
public void wrongFingerprint(String errorString)
|
2018-03-01 23:22:26 +00:00
|
|
|
{
|
|
|
|
((SwirlView) this.getView().findViewById(R.id.swirl)).clearColorFilter();
|
|
|
|
((SwirlView) this.getView().findViewById(R.id.swirlBackground)).clearColorFilter();
|
|
|
|
((SwirlView) this.getView().findViewById(R.id.swirl)).setState(SwirlView.State.ERROR);
|
|
|
|
((SwirlView) this.getView().findViewById(R.id.swirlBackground)).setState(SwirlView.State.ERROR);
|
2018-03-02 11:19:57 +00:00
|
|
|
|
|
|
|
((TextView) this.getView().findViewById(R.id.fingerprint_error)).setText(errorString);
|
2018-03-01 23:22:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public void resetFingerprint()
|
|
|
|
{
|
|
|
|
((SwirlView) this.getView().findViewById(R.id.swirlBackground)).setState(SwirlView.State.ON);
|
2018-03-02 11:19:57 +00:00
|
|
|
((TextView) this.getView().findViewById(R.id.fingerprint_error)).setText("");
|
2018-03-01 23:22:26 +00:00
|
|
|
SwirlView swirlView = this.getView().findViewById(R.id.swirl);
|
|
|
|
|
|
|
|
swirlView.clearColorFilter();
|
|
|
|
|
|
|
|
swirlView.setState(SwirlView.State.OFF);
|
|
|
|
}
|
2018-03-01 18:57:19 +00:00
|
|
|
}
|