Skip to content

Commit

Permalink
Tech debt/add af sdk (#248)
Browse files Browse the repository at this point in the history
- AF working
- Changed requiredActivity
- Added analytics error report
- test this.Activity is null or not
- Bugfix - Phrase Reminder crash
- added an exception handler for UserNotAuthenticatedException.
		 - note: this should allow for the system to display the native authorization UI when needed
		 - fixes issue - https://console.firebase.google.com/u/0/project/litewallet-beta/crashlytics/app/android:com.loafwallet/issues/09dac17241309f0e823ef597a9a82cd4
- Added dev note
- remove calls to BREventManager
- removed BREventManager
- renamed error message
- fixed Firebase Analytics event error

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>
  • Loading branch information
kcw-grunt committed Oct 23, 2024
1 parent 41b3970 commit d9aea64
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 156 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ android {
applicationId = 'com.loafwallet'
minSdkVersion 31
targetSdkVersion 34
versionCode 20241007
versionName "v2.11.1"
versionCode 20241016
versionName "v2.11.4"
multiDexEnabled true
archivesBaseName = "${versionName}(${versionCode})"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import android.widget.*
import androidx.fragment.app.Fragment
import com.breadwallet.R
import com.breadwallet.tools.animation.BRAnimator
import com.breadwallet.tools.manager.AnalyticsManager
import com.breadwallet.tools.manager.TxManager
import com.breadwallet.tools.security.BRKeyStore
import com.breadwallet.tools.util.BRConstants
import timber.log.Timber
import java.util.*

class FragmentBalanceSeedReminder : Fragment() {
Expand Down Expand Up @@ -66,14 +70,21 @@ class FragmentBalanceSeedReminder : Fragment() {
setListeners()
fetchSeedPhrase()
}

private fun registerAnalyticsError(errorString: String) {
Timber.d("Fragment Balance Seed: RegisterError : %s", errorString)
val params = Bundle()
params.putString("lwa_error_message", errorString);
AnalyticsManager.logCustomEventWithParams(BRConstants._20200112_ERR, params)
}
fun fetchSeedPhrase() {
try {
seedPhraseTextView.text = String(BRKeyStore.getPhrase(context, 0))
} catch (_: UserNotAuthenticatedException) {
seedPhraseTextView.text = "NO_PHRASE"
if (this.activity == null) {
registerAnalyticsError("null_in_fragment_balance_fetch_seed")
}
else {
seedPhraseTextView.text = String(BRKeyStore.getPhrase(this.activity, 0)) ?: "NO_PHRASE"
}
}

private fun animateClose() {
BRAnimator.animateBackgroundDim(backgroundLayout, true)
BRAnimator.animateSignalSlide(signalLayout, true) { close() }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ public void setCompletion(BRAuthCompletion completion) {
public void onError() {
String authError = "auth_prompt_failed";
Bundle params = new Bundle();
params.putString("error_message",authError);
params.putString("lwa_error_message",authError);
AnalyticsManager.logCustomEventWithParams(BRConstants._20200112_ERR, params);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,18 @@ import android.view.ViewGroup
import com.breadwallet.databinding.FragmentHistoryBinding
import com.breadwallet.presenter.activities.BreadActivity
import com.breadwallet.presenter.base.BaseFragment
import com.breadwallet.tools.manager.AnalyticsManager
import com.breadwallet.tools.manager.BRSharedPrefs
import com.breadwallet.tools.manager.BRSharedPrefs.OnIsoChangedListener
import com.breadwallet.tools.manager.TxManager
import com.breadwallet.tools.sqlite.TransactionDataSource.OnTxAddedListener
import com.breadwallet.tools.threads.BRExecutor
import com.breadwallet.tools.util.BRConstants
import com.breadwallet.wallet.BRPeerManager
import com.breadwallet.wallet.BRPeerManager.OnTxStatusUpdate
import com.breadwallet.wallet.BRWalletManager
import com.breadwallet.wallet.BRWalletManager.OnBalanceChanged
import timber.log.Timber

/** Litewallet
* Created by Mohamed Barry on 6/1/20
Expand Down Expand Up @@ -56,11 +59,22 @@ class HistoryFragment :
BRPeerManager.getInstance().removeListener(this)
BRSharedPrefs.removeListener(this)
}

private fun registerAnalyticsError(errorString: String) {
val params = Bundle()
params.putString("lwa_error_message", errorString);
AnalyticsManager.logCustomEventWithParams(BRConstants._20200112_ERR, params)
Timber.d("History Fragment: RegisterError : %s", errorString)
}
override fun onResume() {
super.onResume()
addObservers()
TxManager.getInstance().onResume(requireActivity() as BreadActivity)

if (this.activity == null) {
registerAnalyticsError("null_in_history_fragment_on_resume")
}
else {
TxManager.getInstance().onResume(this.activity)
}
}

override fun onPause() {
Expand All @@ -74,7 +88,12 @@ class HistoryFragment :

override fun onStatusUpdate() {
BRExecutor.getInstance().forBackgroundTasks().execute {
TxManager.getInstance().updateTxList(requireActivity() as BreadActivity)
if (this.activity == null) {
registerAnalyticsError("null_in_history_fragment_on_status_update")
}
else {
TxManager.getInstance().updateTxList(this.activity)
}
}
}

Expand All @@ -84,14 +103,23 @@ class HistoryFragment :

override fun onTxAdded() {
BRExecutor.getInstance().forBackgroundTasks().execute {
TxManager.getInstance().updateTxList(requireActivity() as BreadActivity)
if (this.activity == null) {
registerAnalyticsError("null_in_history_fragment_on_tx_added")
}
else {
TxManager.getInstance().updateTxList(this.activity)
}
}
}

private fun updateUI() {
BRExecutor.getInstance().forLightWeightBackgroundTasks().execute {
Thread.currentThread().name = Thread.currentThread().name + "HistoryFragment:updateUI"
TxManager.getInstance().updateTxList(requireActivity() as BreadActivity)
if (this.activity == null) {
registerAnalyticsError("null_in_history_fragment_update_ui")
}
else {
Thread.currentThread().name = Thread.currentThread().name + "HistoryFragment:updateUI"
TxManager.getInstance().updateTxList(this.activity)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
import android.app.Activity;
import android.app.FragmentManager;
import android.app.FragmentTransaction;

import android.content.Intent;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.OvershootInterpolator;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
Expand All @@ -29,7 +29,6 @@
import com.breadwallet.R;
import com.breadwallet.presenter.activities.BreadActivity;
import com.breadwallet.presenter.activities.LoginActivity;
import com.breadwallet.presenter.activities.camera.CameraActivity;
import com.breadwallet.presenter.activities.camera.ScanQRActivity;
import com.breadwallet.presenter.customviews.BRDialogView;
import com.breadwallet.presenter.entities.TxItem;
Expand All @@ -43,6 +42,7 @@
import com.breadwallet.presenter.fragments.FragmentSend;
import com.breadwallet.presenter.fragments.FragmentSignal;
import com.breadwallet.presenter.fragments.FragmentTransactionDetails;

import com.breadwallet.presenter.interfaces.BROnSignalCompletion;
import com.breadwallet.tools.threads.BRExecutor;
import com.breadwallet.tools.util.BRConstants;
Expand Down Expand Up @@ -325,6 +325,7 @@ public void run() {
}

public static void killAllFragments(Activity app) {
//DEV: Needs refactor
if (app != null && !app.isDestroyed())
app.getFragmentManager().popBackStack(null, FragmentManager.POP_BACK_STACK_INCLUSIVE);
}
Expand Down
116 changes: 0 additions & 116 deletions app/src/main/java/com/breadwallet/tools/manager/BREventManager.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public static void putGeoPermissionsRequested(Context activity, boolean requeste

public static int getStartHeight(Context context) {
SharedPreferences settingsToGet = context.getSharedPreferences(BRConstants.PREFS_NAME, 0);
return settingsToGet.getInt(BRConstants.START_HEIGHT, 0);
return settingsToGet.getInt(BRConstants.START_HEIGHT, 0);
}

public static void putStartHeight(Context context, int startHeight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ public static void addConnectionListener(ConnectionReceiverListener listener) {
if (!connectionReceiverListeners.contains(listener))
connectionReceiverListeners.add(listener);
}

@Override
public void onReceive(final Context context, final Intent intent) {
boolean connected = false;
Expand All @@ -48,7 +47,6 @@ public void onReceive(final Context context, final Intent intent) {
connected = false;
}

BREventManager.getInstance().pushEvent(connected ? "reachability.isReachble" : "reachability.isNotReachable");
for (ConnectionReceiverListener listener : connectionReceiverListeners) {
listener.onConnectionChanged(connected);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.animation.AnimatorListenerAdapter;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Looper;
import android.util.AttributeSet;
import android.view.View;
Expand All @@ -20,6 +21,7 @@
import com.breadwallet.tools.animation.BRAnimator;
import com.breadwallet.tools.listeners.RecyclerItemClickListener;
import com.breadwallet.tools.threads.BRExecutor;
import com.breadwallet.tools.util.BRConstants;
import com.breadwallet.wallet.BRPeerManager;
import com.breadwallet.wallet.BRWalletManager;

Expand Down Expand Up @@ -64,7 +66,6 @@ public void onAnimationEnd(Animator animation) {
});

} else { //clicked on the prompt
BREventManager.getInstance().pushEvent("prompt." + PromptManager.getInstance().getPromptName(currentPrompt) + ".trigger");
if (currentPrompt != PromptManager.PromptItem.SYNCING) {
PromptManager.PromptInfo info = PromptManager.getInstance().promptInfo(app, currentPrompt);
if (info != null)
Expand Down Expand Up @@ -114,7 +115,6 @@ public void run() {
void showPrompt(Activity app, PromptManager.PromptItem item) {
crashIfNotMain();
if (item == null) throw new RuntimeException("can't be null");
BREventManager.getInstance().pushEvent("prompt." + PromptManager.getInstance().getPromptName(item) + ".displayed");
if (currentPrompt != PromptManager.PromptItem.SYNCING) {
currentPrompt = item;
}
Expand All @@ -132,9 +132,6 @@ void hidePrompt(final Activity app, final PromptManager.PromptItem item) {
if (item == PromptManager.PromptItem.SYNCING) {
showNextPrompt(app);
updateCard(app);
} else {
if (item != null)
BREventManager.getInstance().pushEvent("prompt." + PromptManager.getInstance().getPromptName(item) + ".dismissed");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import com.breadwallet.presenter.entities.RequestObject;
import com.breadwallet.tools.animation.BRAnimator;
import com.breadwallet.tools.animation.BRDialog;
import com.breadwallet.tools.manager.BREventManager;
import com.breadwallet.tools.threads.PaymentProtocolTask;
import com.breadwallet.tools.util.Utils;
import com.breadwallet.wallet.BRWalletManager;
Expand All @@ -35,18 +34,6 @@ public static synchronized boolean processRequest(FragmentActivity app, String u
return false;
}

Map<String, String> attr = new HashMap<>();
URI uri = null;
try {
uri = new URI(url);
} catch (URISyntaxException e) {
Timber.e(e);
}
attr.put("scheme", uri == null ? "null" : uri.getScheme());
attr.put("host", uri == null ? "null" : uri.getHost());
attr.put("path", uri == null ? "null" : uri.getPath());
BREventManager.getInstance().pushEvent("send.handleURL", attr);

RequestObject requestObject = getRequestFromString(url);
if (BRWalletManager.getInstance().confirmSweep(app, url)) {
return true;
Expand Down
Loading

0 comments on commit d9aea64

Please sign in to comment.