From bc7afe0260a206d2320b22589c9f51c03c17d635 Mon Sep 17 00:00:00 2001 From: andhikayuana Date: Sat, 30 Nov 2024 23:10:07 +0700 Subject: [PATCH] chore: remove FragmentFingerprint.java since, not used and failed to build --- .../fragments/FragmentFingerprint.java | 235 ------------------ 1 file changed, 235 deletions(-) delete mode 100644 app/src/main/java/com/breadwallet/presenter/fragments/FragmentFingerprint.java diff --git a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentFingerprint.java b/app/src/main/java/com/breadwallet/presenter/fragments/FragmentFingerprint.java deleted file mode 100644 index 1ae433f15..000000000 --- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentFingerprint.java +++ /dev/null @@ -1,235 +0,0 @@ -package com.breadwallet.presenter.fragments; - -import android.animation.Animator; -import android.animation.AnimatorListenerAdapter; -import android.animation.ArgbEvaluator; -import android.animation.ValueAnimator; -import android.app.Activity; -import android.content.Context; -import android.hardware.fingerprint.FingerprintManager; -import android.os.Bundle; -import android.os.Handler; -import android.view.LayoutInflater; -import android.view.View; -import android.view.ViewGroup; -import android.view.ViewTreeObserver; -import android.view.animation.AnticipateInterpolator; -import android.widget.Button; -import android.widget.ImageView; -import android.widget.LinearLayout; -import android.widget.RelativeLayout; -import android.widget.TextView; - -import androidx.annotation.Nullable; -import androidx.fragment.app.Fragment; -import androidx.fragment.app.FragmentActivity; - -import com.breadwallet.R; -import com.breadwallet.presenter.activities.BreadActivity; -import com.breadwallet.presenter.interfaces.BRAuthCompletion; -import com.breadwallet.tools.animation.BRAnimator; -import com.breadwallet.tools.animation.DecelerateOvershootInterpolator; -import com.breadwallet.tools.manager.AnalyticsManager; -import com.breadwallet.tools.security.AuthManager; -import com.breadwallet.tools.security.FingerprintUiHelper; -import com.breadwallet.tools.util.BRConstants; -import com.breadwallet.tools.util.Utils; - -import timber.log.Timber; - -/** - * A dialog which uses fingerprint APIs to authenticate the user, and falls back to password - * authentication if fingerprint is not available. - */ -public class FragmentFingerprint extends Fragment - implements FingerprintUiHelper.Callback { - public static final String TAG = FragmentFingerprint.class.getName(); - - private FingerprintManager.CryptoObject mCryptoObject; - private FingerprintUiHelper mFingerprintUiHelper; - private BRAuthCompletion completion; - private TextView title; - private TextView message; - private LinearLayout fingerPrintLayout; - private RelativeLayout fingerprintBackground; - private boolean authSucceeded; - public static final int ANIMATION_DURATION = 300; - private String customTitle; - private String customMessage; - - FingerprintUiHelper.FingerprintUiHelperBuilder mFingerprintUiHelperBuilder; - - public FragmentFingerprint() { - } - - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setRetainInstance(true); - } - - @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - - View authModalView = inflater.inflate(R.layout.fingerprint_dialog_container, container, false); - message = (TextView) authModalView.findViewById(R.id.fingerprint_description); - title = (TextView) authModalView.findViewById(R.id.fingerprint_title); - fingerPrintLayout = (LinearLayout) authModalView.findViewById(R.id.fingerprint_layout); - fingerprintBackground = (RelativeLayout) authModalView.findViewById(R.id.fingerprint_background); - Bundle bundle = getArguments(); - String titleString = bundle.getString("title"); - String messageString = bundle.getString("message"); - if (!Utils.isNullOrEmpty(titleString)) { - customTitle = titleString; - title.setText(customTitle); - } - if (!Utils.isNullOrEmpty(messageString)) { - customMessage = messageString; - message.setText(customMessage); - } - FingerprintManager mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Activity.FINGERPRINT_SERVICE); - mFingerprintUiHelperBuilder = new FingerprintUiHelper.FingerprintUiHelperBuilder(mFingerprintManager); - mFingerprintUiHelper = mFingerprintUiHelperBuilder.build((ImageView) authModalView.findViewById(R.id.fingerprint_icon), - (TextView) authModalView.findViewById(R.id.fingerprint_status), this, getContext()); - View mFingerprintContent = authModalView.findViewById(R.id.fingerprint_container); - - Button mCancelButton = (Button) authModalView.findViewById(R.id.cancel_button); - Button mSecondDialogButton = (Button) authModalView.findViewById(R.id.second_dialog_button); - mCancelButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!BRAnimator.isClickAllowed()) return; - closeMe(); - } - }); - mCancelButton.setText(R.string.Button_cancel); - mSecondDialogButton.setText(getString(R.string.Prompts_TouchId_usePin_android)); - mFingerprintContent.setVisibility(View.VISIBLE); - mSecondDialogButton.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View view) { - if (!BRAnimator.isClickAllowed()) return; - closeMe(); - } - }); - - return authModalView; - } - - @Override - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { - super.onViewCreated(view, savedInstanceState); - - final ViewTreeObserver observer = fingerPrintLayout.getViewTreeObserver(); - observer.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { - @Override - public void onGlobalLayout() { - if(observer.isAlive()) { - observer.removeOnGlobalLayoutListener(this); - } - animateBackgroundDim(false); - animateSignalSlide(false); - } - }); - } - - @Override - public void onStop() { - super.onStop(); - if (!authSucceeded) - completion.onCancel(); - } - - @Override - public void onResume() { - super.onResume(); - mFingerprintUiHelper.startListening(mCryptoObject); - authSucceeded = false; - } - - @Override - public void onPause() { - super.onPause(); - mFingerprintUiHelper.stopListening(); - } - - @Override - public void onAuthenticated() { - final FragmentActivity app = getActivity(); - authSucceeded = true; - - if (completion != null) completion.onComplete(); - BRAnimator.killAllFragments(app); - BRAnimator.startBreadIfNotStarted(app); - - closeMe(); - - } - - public void setCompletion(BRAuthCompletion completion) { - this.completion = completion; - } - - @Override - public void onError() { - String authError = "auth_prompt_failed"; - Bundle params = new Bundle(); - params.putString("lwa_error_message",authError); - AnalyticsManager.logCustomEventWithParams(BRConstants._20200112_ERR, params); - } - - private void animateBackgroundDim(boolean reverse) { - int transColor = reverse ? R.color.black_trans : android.R.color.transparent; - int blackTransColor = reverse ? android.R.color.transparent : R.color.black_trans; - - ValueAnimator anim = new ValueAnimator(); - anim.setIntValues(transColor, blackTransColor); - anim.setEvaluator(new ArgbEvaluator()); - anim.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { - @Override - public void onAnimationUpdate(ValueAnimator valueAnimator) { - fingerprintBackground.setBackgroundColor((Integer) valueAnimator.getAnimatedValue()); - } - }); - - anim.setDuration(ANIMATION_DURATION); - anim.start(); - } - - private void animateSignalSlide(final boolean reverse) { - float layoutTY = fingerPrintLayout.getTranslationY(); - if (!reverse) { - fingerPrintLayout.setTranslationY(layoutTY + BreadActivity.screenParametersPoint.y); - fingerPrintLayout.animate() - .translationY(layoutTY) - .setDuration(ANIMATION_DURATION + 200) - .setInterpolator(new DecelerateOvershootInterpolator(2.0f, 1f)) - .withLayer(); - } else { - fingerPrintLayout.animate() - .translationY(1500) - .setDuration(ANIMATION_DURATION) - .withLayer() - .setInterpolator(new AnticipateInterpolator(2.0f)) - .setListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - super.onAnimationEnd(animation); - if (getActivity() != null) { - fingerPrintLayout.clearAnimation(); - AnalyticsManager.logCustomEvent(BRConstants._20230131_NENR); - } - } - }); - - } - - } - - private void closeMe() { - animateBackgroundDim(true); - animateSignalSlide(true); - } - -} \ No newline at end of file