Skip to content

Commit

Permalink
Techdebt/ fixed send issue add syncing measurements (#255)
Browse files Browse the repository at this point in the history
* removed unused BRSharedPreferences

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* started commenting out more Timber

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Added more shared preferences for syncing

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Commented out many verbose Timber logs

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* WIP

Still trying to figure out the eplased time and last and start timestamps…???
I dunno

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Moved sync measurment into the method calls

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Debugged the install issue with send

- Moved all the measurements in new methods
- recalculated measure points
- Added analytics
- event did_complete_sync was shown!
- adding a dummy file to make sure file system is set
||||WIP still verifying the JSON is present
- added a blockheight label
-  changed the sleep time (a hack to allow the device time to refresh the view) to 100 ms from 500ms!!
-WIP Why is the bundle not showing on time
Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* replaces afID to first location

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* Removed redundant sync measurements

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

* code bump

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>

---------

Signed-off-by: kcw-grunt <mrkerrywashington@icloud.com>
  • Loading branch information
kcw-grunt authored Nov 1, 2024
1 parent 6457638 commit d37be6e
Show file tree
Hide file tree
Showing 17 changed files with 237 additions and 194 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ android {
applicationId = 'com.loafwallet'
minSdkVersion 31
targetSdkVersion 34
versionCode 20241023
versionCode 20241029
versionName "v2.12.0"
multiDexEnabled true
archivesBaseName = "${versionName}(${versionCode})"
Expand Down
4 changes: 0 additions & 4 deletions app/evil.json

This file was deleted.

3 changes: 3 additions & 0 deletions app/src/canary-file.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"filename": "dummy-file-for-testing"
}
12 changes: 9 additions & 3 deletions app/src/main/java/com/breadwallet/BreadApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,21 @@
import android.app.NotificationManager;
import android.os.Build;
import com.google.firebase.messaging.FirebaseMessaging;

import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.Timer;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger;

import timber.log.Timber;
import com.appsflyer.AppsFlyerLib;

import org.json.JSONException;

public class BreadApp extends Application {
public static int DISPLAY_HEIGHT_PX;
public static String HOST = "api.loafwallet.org";
Expand All @@ -42,19 +49,18 @@ public class BreadApp extends Application {
public void onCreate() {
super.onCreate();

/// DEV: Top placement req.
/// DEV: Top placement requirement.
boolean enableCrashlytics = !Utils.isEmulatorOrDebug(this);
FirebaseCrashlytics.getInstance().setCrashlyticsCollectionEnabled(enableCrashlytics);
AnalyticsManager.init(this);
AnalyticsManager.logCustomEvent(BRConstants._20191105_AL);

if(BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree());
DISPLAY_HEIGHT_PX = Resources.getSystem().getDisplayMetrics().heightPixels;

String afID = Utils.fetchPartnerKey(this, PartnerNames.AFDEVID);
AppsFlyerLib.getInstance().init(afID, null, this);
AppsFlyerLib.getInstance().start(this);

DISPLAY_HEIGHT_PX = Resources.getSystem().getDisplayMetrics().heightPixels;
}
public static Context getBreadContext() {
return currentActivity == null ? SyncReceiver.app : currentActivity;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.breadwallet.presenter.activities;

import android.animation.LayoutTransition;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.pm.PackageManager;
Expand All @@ -14,7 +15,6 @@
import android.view.animation.AnimationUtils;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.ViewFlipper;

Expand All @@ -26,14 +26,14 @@
import androidx.transition.TransitionManager;
import androidx.transition.TransitionSet;

import com.breadwallet.BreadApp;
import com.breadwallet.R;
import com.breadwallet.entities.Language;
import com.breadwallet.presenter.activities.intro.IntroActivity;
import com.breadwallet.presenter.activities.util.BRActivity;
import com.breadwallet.presenter.customviews.BRNotificationBar;
import com.breadwallet.presenter.fragments.BuyTabFragment;
import com.breadwallet.presenter.history.HistoryFragment;
import com.breadwallet.presenter.language.LanguageAdapter;
import com.breadwallet.tools.animation.BRAnimator;
import com.breadwallet.tools.animation.TextSizeTransition;
import com.breadwallet.tools.manager.AnalyticsManager;
Expand All @@ -51,13 +51,15 @@
import com.breadwallet.tools.util.Utils;
import com.breadwallet.wallet.BRPeerManager;
import com.breadwallet.wallet.BRWalletManager;
import com.google.android.gms.tasks.Task;
import com.google.android.material.bottomnavigation.BottomNavigationView;
import com.google.android.play.core.review.ReviewInfo;
import com.google.android.play.core.review.ReviewManager;
import com.google.android.play.core.review.ReviewManagerFactory;
import com.google.android.gms.tasks.Task;

import java.math.BigDecimal;
import java.text.DateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -454,24 +456,27 @@ public void onRequestPermissionsResult(int requestCode, @NonNull String[] permis

@Override
public void onConnectionChanged(boolean isConnected) {

Context thisContext = BreadActivity.this;
Context app = BreadApp.getBreadContext();
if (isConnected) {
if (barFlipper != null) {
if (barFlipper.getDisplayedChild() == 1) {
removeNotificationBar();
}
}
BRExecutor.getInstance().forLightWeightBackgroundTasks().execute(() -> {
final double progress = BRPeerManager.syncProgress(BRSharedPrefs.getStartHeight(BreadActivity.this));
Timber.d("timber: Sync Progress: %s", progress);
if (progress < 1 && progress > 0) {
SyncManager.getInstance().startSyncingProgressThread();
final double progress = BRPeerManager.syncProgress(BRSharedPrefs.getStartHeight(thisContext));
if (progress > 0 && progress < 1) {
SyncManager.getInstance().startSyncingProgressThread(app);
}
});
} else {
}
else {
if (barFlipper != null) {
addNotificationBar();
}
SyncManager.getInstance().stopSyncingProgressThread();
SyncManager.getInstance().stopSyncingProgressThread(app);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
package com.breadwallet.presenter.activities.intro;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
Expand All @@ -12,8 +13,11 @@
import androidx.annotation.NonNull;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.appsflyer.AppsFlyerLib;
import com.breadwallet.entities.IntroLanguageResource;
import com.breadwallet.presenter.activities.SetPinActivity;
import com.breadwallet.presenter.entities.PartnerNames;
import com.breadwallet.tools.adapter.CountryLanguageAdapter;
import com.breadwallet.tools.util.LocaleHelper;
import com.google.android.material.snackbar.Snackbar;
Expand All @@ -30,8 +34,13 @@
import com.breadwallet.tools.util.Utils;
import com.breadwallet.wallet.BRWalletManager;
import com.platform.APIClient;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.Serializable;
import java.util.Objects;
import java.util.Scanner;

import timber.log.Timber;

public class IntroActivity extends BRActivity implements Serializable {
Expand Down Expand Up @@ -158,10 +167,36 @@ public void run() {
APIClient apiClient = APIClient.getInstance(IntroActivity.this);
long endTime = System.currentTimeMillis();
Timber.d("timber: updateBundle DONE in %sms",endTime - startTime);


//DEV Moved this back until after the bundle is loaded
//STILL NOT WORKING
// String afID = Utils.fetchPartnerKey(IntroActivity.this, PartnerNames.AFDEVID)
// AppsFlyerLib.getInstance().init(afID, null, IntroActivity.this);
// AppsFlyerLib.getInstance().start(IntroActivity.this);
// boolean didVerify = verifyInstallAssets(IntroActivity.this);
}
});
}

public static boolean verifyInstallAssets(final Context context) {
Timber.d("timber: verify");

String pusherStagingKey = Utils.fetchPartnerKey(context, PartnerNames.PUSHERSTAGING);
boolean isCanaryFilePresent = false;
try (Scanner scanner = new Scanner(new File("canary-file.json"))) {
while (scanner.hasNextLine()) {
String line = scanner.nextLine();
Timber.d("timber: canary file : %s", line);
isCanaryFilePresent = line.length() > 5;
}
} catch (RuntimeException | FileNotFoundException e) {
Timber.e(e);
}

return ( pusherStagingKey.contains("4cc2-94df") && isCanaryFilePresent );
}

private void setListeners() {
newWalletButton.setOnClickListener(new View.OnClickListener() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType
else if (viewType == promptType)
return new PromptHolder(inflater.inflate(promptResId, parent, false));
else if (viewType == syncingType)
return new SyncingHolder(inflater.inflate(syncingResId, parent, false));
return new SyncingProgressViewHolder(inflater.inflate(syncingResId, parent, false));
return null;
}
@Override
Expand All @@ -125,7 +125,7 @@ public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
setPrompt((PromptHolder) holder);
break;
case syncingType:
setSyncing((SyncingHolder) holder);
setSyncing((SyncingProgressViewHolder) holder);
break;
}
}
Expand Down Expand Up @@ -304,8 +304,8 @@ private void setPrompt(final PromptHolder prompt) {
prompt.description.setText(TxManager.getInstance().promptInfo.description);
}

private void setSyncing(final SyncingHolder syncing) {
TxManager.getInstance().syncingHolder = syncing;
private void setSyncing(final SyncingProgressViewHolder syncing) {
TxManager.getInstance().syncingProgressViewHolder = syncing;
syncing.mainLayout.setBackgroundResource(R.drawable.tx_rounded);
}

Expand Down Expand Up @@ -430,14 +430,15 @@ public PromptHolder(View view) {
}
}

public class SyncingHolder extends RecyclerView.ViewHolder {
public class SyncingProgressViewHolder extends RecyclerView.ViewHolder {
public RelativeLayout mainLayout;
public ConstraintLayout constraintLayout;
public TextView date;
public TextView label;
public ProgressBar progress;
public TextView blockheightView;

public SyncingHolder(View view) {
public SyncingProgressViewHolder(View view) {
super(view);
mainLayout = (RelativeLayout) view.findViewById(R.id.main_layout);
constraintLayout = (ConstraintLayout) view.findViewById(R.id.syncing_layout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ public static JSONArray fetchRates(Activity activity) {
if (jsonString == null) return null;
try {
jsonArray = new JSONArray(jsonString);
// DEV Uncomment to view values
// Timber.d("timber: JSON %s",jsonArray.toString());

Timber.d("timber: JSON %s",jsonArray.toString());
} catch (JSONException ex) {
Timber.e(ex);
}
Expand Down
Loading

0 comments on commit d37be6e

Please sign in to comment.