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

🛠️ [Techdebt] Refactor code and inline fees #179

Merged
merged 7 commits into from
Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
52 changes: 26 additions & 26 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -98,132 +98,132 @@
android:name=".presenter.activities.SetPinActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.intro.RecoverActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.WipeActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.ImportActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.ReEnterPinActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.UpdatePinActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.LoginActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.SettingsActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.NotificationActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.SyncBlockchainActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.DisplayCurrencyActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.AboutActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.SecurityCenterActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.ShareDataActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.intro.WriteDownActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.PaperKeyActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.SpendLimitActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.PaperKeyProveActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.InputWordsActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.camera.ScanQRActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.DisabledActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.FingerprintActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.AdvancedActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.NodesActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.camera.CameraActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />
<activity
android:name=".presenter.activities.settings.TestActivity"
android:exported="true"
android:launchMode="singleTask"
android:screenOrientation="portrait"></activity>
android:screenOrientation="portrait" />

<service
android:name=".tools.listeners.SyncReceiver"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,29 @@ public class PaymentItem {

public byte[] serializedTx;
public String[] addresses;
public String opsAddress;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is opsAdress?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the destination address

public long amount;
public String cn;
//This variable was previously called -cn- which is too short to know what it means or does
public String certifiedName;
public boolean isAmountRequested;
public String comment;

public PaymentItem(String[] addresses, byte[] tx, long theAmount, String theCn, boolean isAmountRequested) {
public PaymentItem(String[] addresses, String opsAddress, byte[] tx, long theAmount, String theCertifiedName, boolean isAmountRequested) {
this.isAmountRequested = isAmountRequested;
this.serializedTx = tx;
this.addresses = addresses;
this.opsAddress = opsAddress;
this.amount = theAmount;
this.cn = theCn;
this.certifiedName = theCertifiedName;
}

public PaymentItem(String[] addresses, byte[] tx,long theAmount, String theCn, boolean isAmountRequested, String comment) {
public PaymentItem(String[] addresses, String opsAddress, byte[] tx,long theAmount, String theCertifiedName, boolean isAmountRequested, String comment) {
this.isAmountRequested = isAmountRequested;
this.serializedTx = tx;
this.addresses = addresses;
this.opsAddress = opsAddress;
this.amount = theAmount;
this.cn = theCn;
this.certifiedName = theCertifiedName;
this.comment = comment;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,13 @@ public void onStopTrackingTouch(SeekBar seekBar) {

private void sendDonation() {
String memo = getString(R.string.Donate_toThe_LWTeam) + chosenAddress;
PaymentItem request = new PaymentItem(new String[]{chosenAddress}, null, mDonationAmount, null, false, memo);
PaymentItem request = new PaymentItem(new String[]{chosenAddress},
"testOpsAddress",
null,mDonationAmount,
null,
false,
memo);

Bundle params = new Bundle();
params.putString("DONATION_ACCOUNT", chosenAddress);
params.putLong("DONATION_AMOUNT", mDonationAmount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,14 +447,14 @@ class FragmentSend : Fragment() {
if (allFilled) {
BRSender.getInstance().sendTransaction(
context,
PaymentItem(
arrayOf(address),
PaymentItem(arrayOf(address),
"testOpsAddress",
null,
satoshiAmount.toLong(),
null,
false,
comment,
),
comment
),
)
AnalyticsManager.logCustomEvent(BRConstants._20191105_DSL)
BRSharedPrefs.incrementSendTransactionCount(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ public void pushEvent(String eventName) {
public void onBackgrounded() {
Timber.d("timber: onBackgrounded: ");
saveEvents();
pushToServer();
}

private void saveEvents() {
Expand Down Expand Up @@ -93,67 +92,6 @@ private void saveEvents() {
}
}

private void pushToServer() {
Context app = BreadApp.getBreadContext();
if (app != null) {
List<JSONArray> arrs = getEventsFromDisk(app);
int fails = 0;
for (JSONArray arr : arrs) {
JSONObject obj = new JSONObject();
try {
obj.put("deviceType", 1);
obj.put("appVersion", BRConstants.APP_VERSION_NAME_CODE);
obj.put("events", arr);

String strUtl = BASE_URL + "/events";

final MediaType JSON = MediaType.parse("application/json");
RequestBody requestBody = RequestBody.create(JSON, obj.toString());
Request request = new Request.Builder()
.url(strUtl)
.header("Content-Type", "application/json")
.header("Accept", "application/json")
.post(requestBody).build();
String strResponse = null;
Response response = null;
try {
response = APIClient.getInstance(app).sendRequest(request, true, 0);
if (response != null)
strResponse = response.body().string();
} catch (IOException e) {
Timber.e(e);
fails++;
} finally {
if (response != null) response.close();
}
if (Utils.isNullOrEmpty(strResponse)) {
Timber.i("timber: pushToServer: response is empty");
fails++;
}
} catch (JSONException e) {
Timber.e(e);
fails++;
}
}
if (fails == 0) {
//if no fails then remove the local files.
File dir = new File(app.getFilesDir().getAbsolutePath() + "/events/");
if (dir.isDirectory()) {
String[] children = dir.list();
for (int i = 0; i < children.length; i++) {
new File(dir, children[i]).delete();
}
} else {
Timber.i("timber: pushToServer: missing events directory");
}
} else {
Timber.i("timber: pushToServer: FAILED with: %s fails", fails);
}
} else {
Timber.i("timber: pushToServer: Failed to push, app is null");
}
}

private boolean writeEventsToDisk(String fileName, String json) {
Timber.d("timber: saveEvents: eventsFile: %s,\njson: %s", fileName, json);
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ public void onClick(BRDialogView brDialogView) {
}

String getReceiver(PaymentItem item) {
boolean certified = item.cn != null && item.cn.length() != 0;
return certified ? "certified: " + item.cn : Utils.join(item.addresses, ", ");
boolean certified = item.certifiedName != null && item.certifiedName.length() != 0;
return certified ? "certified: " + item.certifiedName : Utils.join(item.addresses, ", ");
}

private boolean isSmallerThanMin(PaymentItem paymentRequest) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

Expand Down Expand Up @@ -176,7 +177,7 @@ public void run() {
} else {
if (app != null) {
BRAnimator.killAllFragments(app);
BRSender.getInstance().sendTransaction(app, new PaymentItem(addresses, null, new BigDecimal(amount).longValue(), null, true));
BRSender.getInstance().sendTransaction(app, new PaymentItem(addresses, "testOpsAddress", null, new BigDecimal(amount).longValue(), null, true));
} else {
Timber.e(new NullPointerException("tryLitecoinURL, app is null!"));
}
Expand Down
13 changes: 13 additions & 0 deletions app/src/main/java/com/breadwallet/tools/util/Utils.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
import android.view.inputmethod.InputMethodManager;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.ActivityCompat;

import com.breadwallet.presenter.activities.intro.IntroActivity;
Expand All @@ -32,7 +34,11 @@
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Iterator;
import java.util.List;
import java.util.ListIterator;
import java.util.Locale;
import timber.log.Timber;
import org.json.*;
Expand All @@ -41,6 +47,9 @@

import static android.content.Context.FINGERPRINT_SERVICE;
import java.io.FileNotFoundException;
import java.util.Set;
import java.util.HashSet;

import android.content.res.AssetManager;
public class Utils {

Expand Down Expand Up @@ -255,4 +264,8 @@ public static String fetchPartnerKey(Context app, PartnerNames name) {
AnalyticsManager.logCustomEventWithParams(BRConstants._20200112_ERR,params);
return "";
}
public static Set<String> litewalletOpsSet(Context app) {
List<String> addressList = Collections.singletonList(Utils.fetchPartnerKey(app, PartnerNames.LITEWALLETOPS));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does singletonList do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

trying to remember but you can google. Im not a big Java dev...still learning and I used this after research ....;)

return new HashSet<String>(addressList);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.