diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 633d9aea5..a15c6e32b 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -14,8 +14,6 @@ - - @@ -193,11 +191,6 @@ android:exported="true" android:launchMode="singleTask" android:screenOrientation="portrait" /> - { - if (fingerPrint != null && useFingerprint) - fingerPrint.performClick(); - }, 500); - setCurrentLtcPrice(); } diff --git a/app/src/main/java/com/breadwallet/presenter/activities/settings/FingerprintActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/settings/FingerprintActivity.java deleted file mode 100644 index 3a0a4b7dd..000000000 --- a/app/src/main/java/com/breadwallet/presenter/activities/settings/FingerprintActivity.java +++ /dev/null @@ -1,146 +0,0 @@ -package com.breadwallet.presenter.activities.settings; - -import android.app.Activity; -import android.content.Intent; -import android.graphics.Color; -import android.os.Bundle; -import android.text.SpannableString; -import android.text.Spanned; -import android.text.TextPaint; -import android.text.method.LinkMovementMethod; -import android.text.style.ClickableSpan; -import android.view.View; -import android.widget.CompoundButton; -import android.widget.ImageButton; -import android.widget.RelativeLayout; -import android.widget.TextView; -import android.widget.ToggleButton; - -import com.breadwallet.R; -import com.breadwallet.presenter.activities.util.BRActivity; -import com.breadwallet.presenter.customviews.BRDialogView; -import com.breadwallet.presenter.interfaces.BRAuthCompletion; -import com.breadwallet.tools.animation.BRDialog; -import com.breadwallet.tools.manager.BRSharedPrefs; -import com.breadwallet.tools.security.AuthManager; -import com.breadwallet.tools.security.BRKeyStore; -import com.breadwallet.tools.util.BRCurrency; -import com.breadwallet.tools.util.BRExchange; -import com.breadwallet.tools.util.Utils; - -import java.math.BigDecimal; - -import timber.log.Timber; - - -public class FingerprintActivity extends BRActivity { - - public RelativeLayout layout; - public static boolean appVisible = false; - private static FingerprintActivity app; - private TextView limitExchange; - private TextView limitInfo; - - private ToggleButton toggleButton; - - public static FingerprintActivity getApp() { - return app; - } - - @Override - protected void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - } - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - setContentView(R.layout.activity_fingerprint); - toggleButton = (ToggleButton) findViewById(R.id.toggleButton); - limitExchange = (TextView) findViewById(R.id.limit_exchange); - limitInfo = (TextView) findViewById(R.id.limit_info); - - ImageButton faq = (ImageButton) findViewById(R.id.faq_button); - //TODO: all views are using the layout of this button. Views should be refactored without it - // Hiding until layouts are built. - - toggleButton.setChecked(BRSharedPrefs.getUseFingerprint(this)); - - limitExchange.setText(getLimitText()); - - toggleButton.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - Activity app = FingerprintActivity.this; - if (isChecked && !Utils.isFingerprintEnrolled(app)) { - Timber.d("timber: onCheckedChanged: fingerprint not setup"); - BRDialog.showCustomDialog(app, getString(R.string.TouchIdSettings_disabledWarning_title_android), getString(R.string.TouchIdSettings_disabledWarning_body_android), getString(R.string.Button_ok), null, new BRDialogView.BROnClickListener() { - @Override - public void onClick(BRDialogView brDialogView) { - brDialogView.dismissWithAnimation(); - } - }, null, null, 0); - buttonView.setChecked(false); - } else { - BRSharedPrefs.putUseFingerprint(app, isChecked); - } - } - }); - SpannableString ss = new SpannableString(getString(R.string.TouchIdSettings_customizeText_android)); - ClickableSpan clickableSpan = new ClickableSpan() { - @Override - public void onClick(View textView) { - - /// DEV NOTES: Remove this call to auth Prompt - - } - - @Override - public void updateDrawState(TextPaint ds) { - super.updateDrawState(ds); - ds.setUnderlineText(false); - } - }; - //start index of the last space (beginning of the last word) - int indexOfSpace = limitInfo.getText().toString().lastIndexOf(" "); - // make the whole text clickable if failed to select the last word - ss.setSpan(clickableSpan, indexOfSpace == -1 ? 0 : indexOfSpace, limitInfo.getText().length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); - - limitInfo.setText(ss); - limitInfo.setMovementMethod(LinkMovementMethod.getInstance()); - limitInfo.setHighlightColor(Color.TRANSPARENT); - - } - - private String getLimitText() { - String iso = BRSharedPrefs.getIsoSymbol(this); - //amount in satoshis - BigDecimal satoshis = new BigDecimal(BRKeyStore.getSpendLimit(this)); - //amount in BTC, mBTC or bits - BigDecimal amount = BRExchange.getAmountFromLitoshis(this, "LTC", satoshis); - //amount in user preferred ISO (e.g. USD) - BigDecimal curAmount = BRExchange.getAmountFromLitoshis(this, iso, satoshis); - //formatted string for the label - return String.format(getString(R.string.TouchIdSettings_spendingLimit), BRCurrency.getFormattedCurrencyString(this, "LTC", amount), BRCurrency.getFormattedCurrencyString(this, iso, curAmount)); - } - - @Override - protected void onResume() { - super.onResume(); - appVisible = true; - app = this; - } - - @Override - public void onBackPressed() { - super.onBackPressed(); - overridePendingTransition(R.anim.enter_from_left, R.anim.exit_to_right); - } - - @Override - public void onPause() { - super.onPause(); - appVisible = false; - } - -} diff --git a/app/src/main/java/com/breadwallet/presenter/activities/settings/SecurityCenterActivity.java b/app/src/main/java/com/breadwallet/presenter/activities/settings/SecurityCenterActivity.java index 8481ddc4a..9d508a9e2 100644 --- a/app/src/main/java/com/breadwallet/presenter/activities/settings/SecurityCenterActivity.java +++ b/app/src/main/java/com/breadwallet/presenter/activities/settings/SecurityCenterActivity.java @@ -157,23 +157,6 @@ public void onClick(View v) { } })); - int resId = Utils.isFingerprintEnrolled(SecurityCenterActivity.this) - && BRSharedPrefs.getUseFingerprint(SecurityCenterActivity.this) - ? R.drawable.ic_check_mark_blue - : R.drawable.ic_check_mark_grey; - - if (Utils.isFingerprintAvailable(this)) { - itemList.add(new BRSecurityCenterItem(getString(R.string.SecurityCenter_touchIdTitle_android), getString(R.string.SecurityCenter_touchIdDescription), - resId, new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(SecurityCenterActivity.this, FingerprintActivity.class); - startActivity(intent); - overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left); - } - })); - } - boolean isPaperKeySet = BRSharedPrefs.getPhraseWroteDown(this); itemList.add(new BRSecurityCenterItem(getString(R.string.SecurityCenter_paperKeyTitle), getString(R.string.SecurityCenter_paperKeyDescription), isPaperKeySet ? R.drawable.ic_check_mark_blue : R.drawable.ic_check_mark_grey, new View.OnClickListener() { 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 975bf5f64..000000000 --- a/app/src/main/java/com/breadwallet/presenter/fragments/FragmentFingerprint.java +++ /dev/null @@ -1,234 +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.app.Fragment; -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 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 Activity 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 diff --git a/app/src/main/java/com/breadwallet/tools/manager/PromptManager.java b/app/src/main/java/com/breadwallet/tools/manager/PromptManager.java index 763876d26..666efdd41 100644 --- a/app/src/main/java/com/breadwallet/tools/manager/PromptManager.java +++ b/app/src/main/java/com/breadwallet/tools/manager/PromptManager.java @@ -8,14 +8,11 @@ import com.breadwallet.R; import com.breadwallet.presenter.activities.UpdatePinActivity; import com.breadwallet.presenter.activities.intro.WriteDownActivity; -import com.breadwallet.presenter.activities.settings.FingerprintActivity; import com.breadwallet.presenter.activities.settings.ShareDataActivity; import com.breadwallet.tools.security.BRKeyStore; import com.breadwallet.tools.threads.BRExecutor; -import com.breadwallet.tools.util.Utils; import com.breadwallet.wallet.BRPeerManager; -import static com.breadwallet.tools.manager.PromptManager.PromptItem.FINGER_PRINT; import static com.breadwallet.tools.manager.PromptManager.PromptItem.PAPER_KEY; import static com.breadwallet.tools.manager.PromptManager.PromptItem.RECOMMEND_RESCAN; import static com.breadwallet.tools.manager.PromptManager.PromptItem.SHARE_DATA; @@ -61,8 +58,6 @@ public PromptInfo(String title, String description, View.OnClickListener listene public boolean shouldPrompt(Context app, PromptItem item) { assert (app != null); switch (item) { - case FINGER_PRINT: - return !BRSharedPrefs.getUseFingerprint(app) && Utils.isFingerprintAvailable(app); case PAPER_KEY: return !BRSharedPrefs.getPhraseWroteDown(app); case UPGRADE_PIN: @@ -80,22 +75,12 @@ public PromptItem nextPrompt(Context app) { if (shouldPrompt(app, RECOMMEND_RESCAN)) return RECOMMEND_RESCAN; if (shouldPrompt(app, UPGRADE_PIN)) return UPGRADE_PIN; if (shouldPrompt(app, PAPER_KEY)) return PAPER_KEY; - if (shouldPrompt(app, FINGER_PRINT)) return FINGER_PRINT; if (shouldPrompt(app, SHARE_DATA)) return SHARE_DATA; return null; } public PromptInfo promptInfo(final Activity app, PromptItem item) { switch (item) { - case FINGER_PRINT: - return new PromptInfo(app.getString(R.string.Prompts_TouchId_title_android), app.getString(R.string.Prompts_TouchId_body_android), new View.OnClickListener() { - @Override - public void onClick(View v) { - Intent intent = new Intent(app, FingerprintActivity.class); - app.startActivity(intent); - app.overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left); - } - }); case PAPER_KEY: return new PromptInfo(app.getString(R.string.Prompts_PaperKey_title), app.getString(R.string.Prompts_PaperKey_body), new View.OnClickListener() { @Override @@ -157,8 +142,6 @@ public void run() { */ public String getPromptName(PromptItem prompt) { switch (prompt) { - case FINGER_PRINT: - return "touchIdPrompt"; case PAPER_KEY: return "paperKeyPrompt"; case UPGRADE_PIN: diff --git a/app/src/main/java/com/breadwallet/tools/security/AuthManager.java b/app/src/main/java/com/breadwallet/tools/security/AuthManager.java index af3725ea5..3ca7fc368 100644 --- a/app/src/main/java/com/breadwallet/tools/security/AuthManager.java +++ b/app/src/main/java/com/breadwallet/tools/security/AuthManager.java @@ -1,29 +1,17 @@ package com.breadwallet.tools.security; import android.app.Activity; -import android.app.FragmentTransaction; -import android.app.KeyguardManager; import android.content.Context; -import android.content.DialogInterface; -import android.os.Bundle; import android.os.Handler; import android.view.View; import com.breadwallet.R; import com.breadwallet.presenter.activities.DisabledActivity; import com.breadwallet.presenter.activities.util.ActivityUTILS; -import com.breadwallet.presenter.customviews.BRDialogView; -import com.breadwallet.presenter.fragments.FragmentFingerprint; -import com.breadwallet.presenter.fragments.FragmentPin; -import com.breadwallet.presenter.interfaces.BRAuthCompletion; -import com.breadwallet.tools.animation.BRDialog; import com.breadwallet.tools.manager.BRSharedPrefs; import com.breadwallet.tools.threads.BRExecutor; -import com.breadwallet.tools.util.Utils; import com.breadwallet.wallet.BRWalletManager; -import java.util.concurrent.TimeUnit; - import timber.log.Timber; public class AuthManager { @@ -173,11 +161,6 @@ public void run() { } } - - public static boolean isFingerPrintAvailableAndSetup(Context context) { - return Utils.isFingerprintAvailable(context) && Utils.isFingerprintEnrolled(context); - } - public interface OnPinSuccess { void onSuccess(); } diff --git a/app/src/main/java/com/breadwallet/tools/util/Utils.java b/app/src/main/java/com/breadwallet/tools/util/Utils.java index 4c7087547..a0a278ea7 100644 --- a/app/src/main/java/com/breadwallet/tools/util/Utils.java +++ b/app/src/main/java/com/breadwallet/tools/util/Utils.java @@ -6,7 +6,6 @@ import android.content.pm.ApplicationInfo; import android.content.pm.PackageInfo; import android.content.pm.PackageManager; -import android.hardware.fingerprint.FingerprintManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; @@ -168,24 +167,6 @@ public static String createBitcoinUrl(String address, long satoshiAmount, String } - public static boolean isFingerprintEnrolled(Context app) { - FingerprintManager fingerprintManager = (FingerprintManager) app.getSystemService(FINGERPRINT_SERVICE); - if (fingerprintManager == null) return false; - // Device doesn't support fingerprint authentication - return ActivityCompat.checkSelfPermission(app, Manifest.permission.USE_FINGERPRINT) == PackageManager.PERMISSION_GRANTED && fingerprintManager.isHardwareDetected() && fingerprintManager.hasEnrolledFingerprints(); - } - - public static boolean isFingerprintAvailable(Context app) { - FingerprintManager fingerprintManager = (FingerprintManager) app.getSystemService(FINGERPRINT_SERVICE); - if (fingerprintManager == null) return false; - // Device doesn't support fingerprint authentication - if (ActivityCompat.checkSelfPermission(app, Manifest.permission.USE_FINGERPRINT) != PackageManager.PERMISSION_GRANTED) { - Toast.makeText(app, "Fingerprint authentication permission not enabled", Toast.LENGTH_LONG).show(); - return false; - } - return fingerprintManager.isHardwareDetected(); - } - public static void hideKeyboard(Context app) { if (app != null) { View view = ((Activity) app).getCurrentFocus(); diff --git a/app/src/main/res/layout/fingerprint_dialog_container.xml b/app/src/main/res/layout/fingerprint_dialog_container.xml deleted file mode 100644 index 1892a90ad..000000000 --- a/app/src/main/res/layout/fingerprint_dialog_container.xml +++ /dev/null @@ -1,137 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file