Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐜[Bugfix] Fragment fingerprint crash 125 #131

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ android {
applicationId = 'com.loafwallet'
minSdkVersion 27
targetSdkVersion 32
versionCode 722
versionName "v2.8.0"
versionCode 724
versionName "v2.8.1"
multiDexEnabled true
archivesBaseName = "${versionName}(${versionCode})"

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,4 @@
package com.breadwallet.presenter.fragments;/*
* 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
*/
package com.breadwallet.presenter.fragments;

import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
Expand All @@ -24,7 +10,6 @@
import android.hardware.fingerprint.FingerprintManager;
import android.os.Bundle;
import android.os.Handler;
import androidx.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
Expand All @@ -36,15 +21,20 @@
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
Expand Down Expand Up @@ -74,22 +64,18 @@ public FragmentFingerprint() {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);

// Do not create a new Fragment when the Activity is re-created such as orientation changes.
setRetainInstance(true);
// setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Material_Light_Dialog);
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

View v = inflater.inflate(R.layout.fingerprint_dialog_container, container, false);
// getDialog().setTitle(R.string.fingerprint_auth);
message = (TextView) v.findViewById(R.id.fingerprint_description);
title = (TextView) v.findViewById(R.id.fingerprint_title);
fingerPrintLayout = (LinearLayout) v.findViewById(R.id.fingerprint_layout);
fingerprintBackground = (RelativeLayout) v.findViewById(R.id.fingerprint_background);
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");
Expand All @@ -103,21 +89,16 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container,
}
FingerprintManager mFingerprintManager = (FingerprintManager) getActivity().getSystemService(Activity.FINGERPRINT_SERVICE);
mFingerprintUiHelperBuilder = new FingerprintUiHelper.FingerprintUiHelperBuilder(mFingerprintManager);
mFingerprintUiHelper = mFingerprintUiHelperBuilder.build((ImageView) v.findViewById(R.id.fingerprint_icon),
(TextView) v.findViewById(R.id.fingerprint_status), this, getContext());
View mFingerprintContent = v.findViewById(R.id.fingerprint_container);
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) v.findViewById(R.id.cancel_button);
Button mSecondDialogButton = (Button) v.findViewById(R.id.second_dialog_button);
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;
// if (!BRAnimator.scanResultFragmentOn && mode == BRConstants.AUTH_FOR_PAY && request.isAmountRequested) {
//// FragmentScanResult.address = request.address[0];
// BRWalletManager.getInstance().offerToChangeTheAmount(getActivity(), "");
// }
// dismiss();
closeMe();
}
});
Expand All @@ -133,7 +114,7 @@ public void onClick(View view) {
}
});

return v;
return authModalView;
}

@Override
Expand All @@ -156,9 +137,8 @@ public void onGlobalLayout() {
@Override
public void onStop() {
super.onStop();

animateBackgroundDim(true);
animateSignalSlide(true);
// animateBackgroundDim(true);
// animateSignalSlide(true);
if (!authSucceeded)
completion.onCancel();
}
Expand Down Expand Up @@ -248,12 +228,16 @@ private void animateSignalSlide(final boolean reverse) {
fingerPrintLayout.animate()
.translationY(1500)
.setDuration(ANIMATION_DURATION)
.withLayer().setInterpolator(new AnticipateInterpolator(2f)).setListener(new AnimatorListenerAdapter() {
.withLayer()
.setInterpolator(new AnticipateInterpolator(2.0f))
.setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
super.onAnimationEnd(animation);
if (getActivity() != null)
getActivity().getFragmentManager().beginTransaction().remove(FragmentFingerprint.this).commit();
if (getActivity() != null) {
fingerPrintLayout.clearAnimation();
AnalyticsManager.logCustomEvent(BRConstants._20230131_NENR);
}
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public View onCreateView(LayoutInflater inflater,
background.setOnClickListener(v -> {
if (!BRAnimator.isClickAllowed()) return;
closeMenu();
getActivity().onBackPressed();
});

itemList = new ArrayList<>();
Expand Down Expand Up @@ -82,21 +81,18 @@ public View onCreateView(LayoutInflater inflater,
itemList.add(new BRMenuItem(getString(R.string.MenuButton_lock), R.drawable.ic_lock, v -> {
closeMenu();
final Activity from = getActivity();
from.getFragmentManager().popBackStack();
BRAnimator.startBreadActivity(from, true);
}));

/* Close button*/
rootView.findViewById(R.id.close_button).setOnClickListener(v -> {
closeMenu();
Activity app = getActivity();
app.getFragmentManager().popBackStack();
});

mTitle = rootView.findViewById(R.id.title);
mListView = rootView.findViewById(R.id.menu_listview);
mListView.setAdapter(new MenuListAdapter(getContext(), R.layout.menu_list_item, itemList));
signalLayout.setOnTouchListener(new SlideDetector(getContext(), signalLayout));
signalLayout.setOnTouchListener(new SlideDetector(signalLayout, this::closeMenu));

return rootView;
}
Expand Down Expand Up @@ -154,7 +150,7 @@ public View getView(int position, @Nullable View convertView, @NonNull ViewGroup
private void closeMenu() {
BRAnimator.animateBackgroundDim(background, true);
BRAnimator.animateSignalSlide(signalLayout, true, () -> {
if (getActivity() != null) {
if (getActivity() != null && !getActivity().isDestroyed() && !getActivity().isFinishing()) {
getActivity().getFragmentManager().popBackStack();
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,22 +204,22 @@ public void run() {
@Override
public void onStop() {
super.onStop();
keyboard.animate()
.translationY(1000)
.withLayer();
dialogLayout.animate()
.scaleY(0)
.scaleX(0).alpha(0);
mainLayout.animate().alpha(0);
if (!authSucceeded)
completion.onCancel();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (getActivity() != null)
getActivity().getFragmentManager().beginTransaction().remove(FragmentPin.this).commit();
}
}, 1000);
// keyboard.animate()
// .translationY(1000)
// .withLayer();
// dialogLayout.animate()
// .scaleY(0)
// .scaleX(0).alpha(0);
// mainLayout.animate().alpha(0);
// if (!authSucceeded)
// completion.onCancel();
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// if (getActivity() != null)
// getActivity().getFragmentManager().beginTransaction().remove(FragmentPin.this).commit();
// }
// }, 1000);
}

public void setCompletion(BRAuthCompletion completion) {
Expand Down
Loading