Browse Source

request fix, and lots more

gradlePlay
Gutyn 9 years ago
parent
commit
d1a6124a12
  1. 0
      .idea/.name
  2. 2
      .idea/compiler.xml
  3. 0
      .idea/copyright/profiles_settings.xml
  4. 16
      .idea/dictionaries/Mihail.xml
  5. 0
      .idea/gradle.xml
  6. 1985
      .idea/inspectionProfiles/Project_Default.xml
  7. 7
      .idea/inspectionProfiles/profiles_settings.xml
  8. 2
      .idea/misc.xml
  9. 0
      .idea/modules.xml
  10. 0
      .idea/runConfigurations.xml
  11. 2
      .idea/vcs.xml
  12. 29
      app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java
  13. 11
      app/src/main/java/com/breadwallet/presenter/activities/RequestQRActivity.java
  14. 28
      app/src/main/java/com/breadwallet/presenter/fragments/FragmentDecoder.java
  15. 17
      app/src/main/java/com/breadwallet/presenter/fragments/MainFragment.java
  16. 1
      app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentQR.java
  17. 6
      app/src/main/java/com/breadwallet/tools/CurrencyManager.java
  18. 3
      app/src/main/java/com/breadwallet/tools/adapter/CustomPagerAdapter.java
  19. 15
      app/src/main/java/com/breadwallet/tools/adapter/ParallaxViewPager.java
  20. 90
      app/src/main/java/com/breadwallet/tools/adapter/TransactionListAdapter.java
  21. 2
      app/src/main/java/com/breadwallet/tools/animation/FragmentAnimator.java
  22. 20
      app/src/main/java/com/breadwallet/tools/security/RequestHandler.java
  23. 4
      app/src/main/java/com/breadwallet/wallet/BRWalletManager.java
  24. 2
      app/src/main/jni/breadwallet-core
  25. 26
      app/src/main/jni/transition/PeerManager.c
  26. 2
      app/src/main/jni/transition/wallet.c
  27. 6
      app/src/main/res/layout/activity_main.xml
  28. 1
      app/src/main/res/values/colors.xml
  29. 2
      app/src/main/res/values/strings.xml

0
.idea/.name

2
.idea/compiler.xml

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<option name="DEFAULT_COMPILER" value="Javac" />
<resourceExtensions />
<wildcardResourcePatterns>
<entry name="!?*.java" />
@ -12,6 +11,7 @@
<entry name="!?*.flex" />
<entry name="!?*.kt" />
<entry name="!?*.clj" />
<entry name="!?*.aj" />
</wildcardResourcePatterns>
<annotationProcessing>
<profile default="true" name="Default" enabled="false">

0
.idea/copyright/profiles_settings.xml

16
.idea/dictionaries/Mihail.xml

@ -1,16 +0,0 @@
<component name="ProjectDictionaryState">
<dictionary name="Mihail">
<words>
<w>bitcoin</w>
<w>breadwallet</w>
<w>gutan</w>
<w>merkle</w>
<w>mihail</w>
<w>mydecoderview</w>
<w>passcode</w>
<w>qrdecoderview</w>
<w>satoshis</w>
<w>testnet</w>
</words>
</dictionary>
</component>

0
.idea/gradle.xml

1985
.idea/inspectionProfiles/Project_Default.xml

File diff suppressed because it is too large

7
.idea/inspectionProfiles/profiles_settings.xml

@ -1,7 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="PROJECT_PROFILE" value="Project Default" />
<option name="USE_PROJECT_PROFILE" value="true" />
<version value="1.0" />
</settings>
</component>

2
.idea/misc.xml

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.7" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" />
</component>
<component name="ProjectType">

0
.idea/modules.xml

0
.idea/runConfigurations.xml

2
.idea/vcs.xml

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
<mapping directory="" vcs="" />
</component>
</project>

29
app/src/main/java/com/breadwallet/presenter/activities/MainActivity.java

@ -61,6 +61,7 @@ import com.breadwallet.tools.threads.ToastBlockShowTask;
import com.breadwallet.wallet.BRPeerManager;
import com.breadwallet.wallet.BRWalletManager;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -125,8 +126,8 @@ public class MainActivity extends FragmentActivity implements Observer {
public static final Point screenParametersPoint = new Point();
private int middleViewPressedCount = 0;
private BroadcastReceiver mPowerKeyReceiver = null;
private String amountHolder;
private String addressHolder;
// private String amountHolder;
// private String addressHolder;
private static int MODE = RELEASE;
private TextView testnet;
@ -177,7 +178,10 @@ public class MainActivity extends FragmentActivity implements Observer {
pay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
pay();
String amountHolder = FragmentScanResult.currentCurrencyPosition == FragmentScanResult.BITCOIN_RIGHT ?
AmountAdapter.getRightValue() : AmountAdapter.getLeftValue();
String addressHolder = FragmentScanResult.address;
pay(addressHolder, amountHolder);
}
});
@ -256,8 +260,6 @@ public class MainActivity extends FragmentActivity implements Observer {
super.onResume();
appInBackground = false;
app = this;
amountHolder = null;
addressHolder = null;
CurrencyManager currencyManager = CurrencyManager.getInstance(this);
currencyManager.startTimer();
currencyManager.deleteObservers();
@ -484,14 +486,11 @@ public class MainActivity extends FragmentActivity implements Observer {
}
public void pay() {
public void pay(final String addressHolder, String amountHolder) {
amountHolder = FragmentScanResult.currentCurrencyPosition == FragmentScanResult.BITCOIN_RIGHT ?
AmountAdapter.getRightValue() : AmountAdapter.getLeftValue();
addressHolder = FragmentScanResult.address;
final Double amountAsDouble = Double.parseDouble(amountHolder);
if (addressHolder == null) return;
if (addressHolder == null || amountHolder == null) return;
if (addressHolder.length() < 20) return;
final Double amountAsDouble = Double.parseDouble(amountHolder);
if (amountAsDouble <= 0) return;
Log.e(TAG, "*********Sending: " + amountHolder + " to: " + addressHolder);
CurrencyManager cm = CurrencyManager.getInstance(this);
@ -526,7 +525,7 @@ public class MainActivity extends FragmentActivity implements Observer {
long feeForTx = cm.getBitsFromSatoshi(m.feeForTransaction(addressHolder, cm.getSatoshisFromBits(Math.round(amountAsDouble))));
Log.e(TAG, "pay >>>> feeForTx: " + feeForTx + ", amountAsDouble: " + amountAsDouble +
", CurrencyManager.getInstance(this).getBALANCE(): " + cm.getBitsFromSatoshi(cm.getBALANCE()));
if (feeForTx != 0 && amountAsDouble + feeForTx < cm.getBALANCE()) {
if (feeForTx != 0 && amountAsDouble + feeForTx < cm.getBitsFromSatoshi(cm.getBALANCE())) {
confirmPay(new PaymentRequestEntity(new String[]{addressHolder}, Math.round(amountAsDouble), null));
} else {
@ -561,11 +560,13 @@ public class MainActivity extends FragmentActivity implements Observer {
Intent intent;
String tempAmount = FragmentScanResult.currentCurrencyPosition == FragmentScanResult.BITCOIN_RIGHT ?
AmountAdapter.getRightValue() : AmountAdapter.getLeftValue();
String strAmount = String.valueOf(new BigDecimal(tempAmount).divide(new BigDecimal("1000000")));
SharedPreferences prefs = getSharedPreferences(MainFragmentQR.RECEIVE_ADDRESS_PREFS, Context.MODE_PRIVATE);
String testTemp = prefs.getString(MainFragmentQR.RECEIVE_ADDRESS, "");
intent = new Intent(this, RequestQRActivity.class);
intent.putExtra(BRConstants.INTENT_EXTRA_REQUEST_AMOUNT, tempAmount);
intent.putExtra(BRConstants.INTENT_EXTRA_REQUEST_AMOUNT, strAmount);
intent.putExtra(BRConstants.INTENT_EXTRA_REQUEST_ADDRESS, testTemp);
startActivity(intent);
overridePendingTransition(R.anim.fade_in, R.anim.fade_out);
@ -583,7 +584,7 @@ public class MainActivity extends FragmentActivity implements Observer {
// }
} else {
Log.e(TAG, "Auth for phrase was rejected");
// The user canceled or didn’t complete the lock screen
// operation. Go to error/cancellation flow.
}
}

11
app/src/main/java/com/breadwallet/presenter/activities/RequestQRActivity.java

@ -1,6 +1,7 @@
package com.breadwallet.presenter.activities;
import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.graphics.Point;
@ -26,6 +27,7 @@ import com.breadwallet.tools.security.RequestHandler;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.WriterException;
import java.math.BigDecimal;
import java.security.InvalidAlgorithmParameterException;
public class RequestQRActivity extends Activity {
@ -67,17 +69,24 @@ public class RequestQRActivity extends Activity {
SharedPreferences settings = getSharedPreferences(MainActivity.PREFS_NAME, 0);
final String iso = settings.getString(FragmentCurrency.CURRENT_CURRENCY, "USD");
final float rate = settings.getFloat(FragmentCurrency.RATE, 1);
amount = CurrencyManager.getInstance(this).getBitsAndExchangeString(rate, iso, obj.amount);
amount = CurrencyManager.getInstance(this).getBitsAndExchangeString(rate, iso,
String.valueOf(new BigDecimal(obj.amount).multiply(new BigDecimal("1000000"))));
} catch (InvalidAlgorithmParameterException e) {
e.printStackTrace();
}
final Intent intent = new Intent(this, MainActivity.class);
close.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
SpringAnimator.showAnimation(v);
onBackPressed();
startActivity(intent);
if (!RequestQRActivity.this.isDestroyed()) {
finish();
}
}
});
requestAddressText.setText(address);
requestAmountText.setText(amount);

28
app/src/main/java/com/breadwallet/presenter/fragments/FragmentDecoder.java

@ -1,6 +1,5 @@
package com.breadwallet.presenter.fragments;
import android.app.Activity;
import android.app.Fragment;
import android.content.Context;
import android.graphics.ImageFormat;
@ -68,7 +67,7 @@ import java.util.concurrent.TimeUnit;
import static android.hardware.camera2.CameraCharacteristics.LENS_FACING;
import static android.hardware.camera2.CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP;
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_STATE_ACTIVE_SCAN;
import static android.hardware.camera2.CameraMetadata.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
import static android.hardware.camera2.CameraMetadata.LENS_FACING_FRONT;
import static android.hardware.camera2.CaptureRequest.CONTROL_AF_MODE;
@ -79,6 +78,8 @@ public class FragmentDecoder extends Fragment
private static final String CAMERA_GUIDE = "reg";
private static final String TEXT_EMPTY = "";
private boolean useImageAvailable = true;
/**
* Conversion from screen rotation to JPEG orientation.
*/
@ -149,6 +150,20 @@ public class FragmentDecoder extends Fragment
@Override
public void onImageAvailable(ImageReader reader) {
// Log.e(TAG, "onImageAvailable: " + count++);
// if (!useImageAvailable) {
// return;
// } else {
// useImageAvailable = false;
// new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// useImageAvailable = true;
// }
// }, 300);
// }
// Log.e(TAG, "onImageAvailable after the check ");
Image img = null;
img = reader.acquireLatestImage();
Result rawResult = null;
@ -171,7 +186,7 @@ public class FragmentDecoder extends Fragment
String validationString = validateResult(decoded);
// Log.e(TAG, "validationString: " + validationString);
if (Objects.equals(validationString, TEXT_EMPTY)) {
onQRCodeRead(getActivity(),rawResult.getText());
onQRCodeRead((MainActivity) getActivity(), rawResult.getText());
} else {
setCameraGuide(CAMERA_GUIDE_RED);
setGuideText(validationString);
@ -494,7 +509,7 @@ public class FragmentDecoder extends Fragment
mCaptureSession = cameraCaptureSession;
try {
// Auto focus should be continuous for camera preview.
mPreviewRequestBuilder.set(CONTROL_AF_MODE, CONTROL_AF_STATE_ACTIVE_SCAN);
mPreviewRequestBuilder.set(CONTROL_AF_MODE, CONTROL_AF_MODE_CONTINUOUS_PICTURE);
// Flash is automatically enabled when necessary.
/**no need for flash_on now*/
//mPreviewRequestBuilder.set(CONTROL_AE_MODE, CONTROL_AE_MODE_ON_AUTO_FLASH);
@ -552,7 +567,7 @@ public class FragmentDecoder extends Fragment
mTextureView.setTransform(matrix);
}
private static synchronized void onQRCodeRead(final Activity app,final String text) {
private static synchronized void onQRCodeRead(final MainActivity app, final String text) {
if (accessGranted) {
accessGranted = false;
app.runOnUiThread(new Runnable() {
@ -560,7 +575,7 @@ public class FragmentDecoder extends Fragment
public void run() {
if (text != null) {
FragmentAnimator.hideDecoderFragment();
// Log.e(TAG, "BEFORE processRequest");
Log.e(TAG, "BEFORE processRequest");
RequestHandler.processRequest(app, text);
}
@ -665,4 +680,5 @@ public class FragmentDecoder extends Fragment
}
}

17
app/src/main/java/com/breadwallet/presenter/fragments/MainFragment.java

@ -4,6 +4,7 @@ import android.app.AlertDialog;
import android.app.Fragment;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@ -13,6 +14,7 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import com.breadwallet.R;
import com.breadwallet.presenter.BreadWalletApp;
import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.tools.BRClipboardManager;
import com.breadwallet.tools.adapter.MiddleViewAdapter;
@ -55,7 +57,7 @@ public class MainFragment extends Fragment {
// Inflate the layout for this fragment
View rootView = inflater.inflate(R.layout.fragment_main, container, false);
Button scanQRButton = (Button) rootView.findViewById(R.id.main_button_scan_qr_code);
final Button scanQRButton = (Button) rootView.findViewById(R.id.main_button_scan_qr_code);
LinearLayout mainFragmentLayout = (LinearLayout) rootView.findViewById(R.id.main_fragment);
Button payAddressFromClipboardButton = (Button)
rootView.findViewById(R.id.main_button_pay_address_from_clipboard);
@ -68,6 +70,14 @@ public class MainFragment extends Fragment {
}
});
rootView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
((BreadWalletApp) getActivity().getApplication()).hideKeyboard(getActivity());
addressEditText.clearFocus();
}
});
mainFragmentLayout.setPadding(0, MainActivity.screenParametersPoint.y / 5, 0, 0);
scanQRButton.setOnClickListener(new View.OnClickListener() {
@Override
@ -89,6 +99,7 @@ public class MainFragment extends Fragment {
if (!addressEditText.getText().toString().isEmpty()) {
tempAddress = addressEditText.getText().toString();
}
Log.e(TAG, "tempAddress: " + tempAddress);
final String finalAddress = tempAddress;
if (checkIfAddressIsValid(finalAddress)) {
if (finalAddress != null) {
@ -105,6 +116,8 @@ public class MainFragment extends Fragment {
});
alert = builder.create();
alert.show();
BRClipboardManager.copyToClipboard(getActivity(), "");
addressEditText.setText("");
} else if (m.addressIsUsed(finalAddress)) {
builder.setTitle(getResources().getString(R.string.warning));
@ -156,7 +169,7 @@ public class MainFragment extends Fragment {
private boolean checkIfAddressIsValid(String str) {
BRWalletManager m = BRWalletManager.getInstance(getActivity());
return m.validateAddress(str);
return m.validateAddress(str.trim());
}
@Override

1
app/src/main/java/com/breadwallet/presenter/fragments/MainFragmentQR.java

@ -95,6 +95,7 @@ public class MainFragmentQR extends Fragment {
// if (receiveAddress == null) {
BRWalletManager.refreshAddress();
receiveAddress = prefs.getString(RECEIVE_ADDRESS, null);
// }
qrcode = (ImageView) getActivity().findViewById(R.id.main_image_qr_code);
sharingFragment = new SharingFragment();

6
app/src/main/java/com/breadwallet/tools/CurrencyManager.java

@ -16,6 +16,7 @@ import com.breadwallet.tools.adapter.AmountAdapter;
import com.breadwallet.tools.adapter.CurrencyListAdapter;
import com.breadwallet.tools.adapter.MiddleViewAdapter;
import com.breadwallet.tools.animation.FragmentAnimator;
import com.breadwallet.wallet.BRWalletManager;
import org.json.JSONArray;
import org.json.JSONException;
@ -237,6 +238,11 @@ public class CurrencyManager extends Observable {
public String getExchangeForAmount(double rate, String iso, String target) {
if (rate == 0) rate = 1;
double exchange = (Double.parseDouble(target) * rate / 1000000);
if (ctx != null) {
long exchangeFromCore = BRWalletManager.getInstance(ctx).localAmount(new Double(target).longValue(),rate);
Log.e(TAG,"exchange: " + exchange);
Log.e(TAG,"exchangeFromCore: " + exchangeFromCore);
}
DecimalFormat decimalFormat = new DecimalFormat("0.00");
return getFormattedCurrencyString(iso, String.valueOf(decimalFormat.format(exchange)));
}

3
app/src/main/java/com/breadwallet/tools/adapter/CustomPagerAdapter.java

@ -4,8 +4,10 @@ import android.app.Fragment;
import android.app.FragmentManager;
import android.os.Handler;
import android.support.v13.app.FragmentPagerAdapter;
import android.util.Log;
import android.view.View;
import com.breadwallet.presenter.BreadWalletApp;
import com.breadwallet.presenter.activities.MainActivity;
import com.breadwallet.presenter.fragments.MainFragment;
import com.breadwallet.presenter.fragments.MainFragmentQR;
@ -76,6 +78,7 @@ public class CustomPagerAdapter extends FragmentPagerAdapter {
@Override
public Fragment getItem(int position) {
return fragments.get(position);
}

15
app/src/main/java/com/breadwallet/tools/adapter/ParallaxViewPager.java

@ -19,20 +19,20 @@ import com.breadwallet.tools.animation.SpringAnimator;
/**
* BreadWallet
*
* <p/>
* Created by Mihail on 6/29/15.
* Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
*
* <p/>
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* <p/>
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* <p/>
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@ -102,7 +102,12 @@ public class ParallaxViewPager extends ViewPager {
if (secondOnPageChangeListener != null) {
secondOnPageChangeListener.onPageSelected(position);
}
((BreadWalletApp) MainActivity.app.getApplication()).cancelToast();
MainActivity app = MainActivity.app;
if (app != null) {
((BreadWalletApp) app.getApplication()).cancelToast();
((BreadWalletApp) app.getApplication()).hideKeyboard(app);
}
MainActivity.app.setPagerIndicator(position);
if (FragmentAnimator.level == 0) {
if (position == 1) {

90
app/src/main/java/com/breadwallet/tools/adapter/TransactionListAdapter.java

@ -1,90 +0,0 @@
//package com.breadwallet.tools.adapter;
//
//import android.app.Activity;
//import android.content.Context;
//import android.util.Log;
//import android.view.LayoutInflater;
//import android.view.View;
//import android.view.ViewGroup;
//import android.widget.ArrayAdapter;
//import android.widget.Button;
//
//import com.breadwallet.R;
//import com.breadwallet.presenter.entities.TransactionListItem;
//
///**
// * BreadWallet
// * <p/>
// * Created by Mihail on 7/27/15.
// * Copyright (c) 2015 Mihail Gutan <mihail@breadwallet.com>
// * <p/>
// * Permission is hereby granted, free of charge, to any person obtaining a copy
// * of this software and associated documentation files (the "Software"), to deal
// * in the Software without restriction, including without limitation the rights
// * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// * copies of the Software, and to permit persons to whom the Software is
// * furnished to do so, subject to the following conditions:
// * <p/>
// * The above copyright notice and this permission notice shall be included in
// * all copies or substantial portions of the Software.
// * <p/>
// * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// * THE SOFTWARE.
// */
//
//public class TransactionListAdapter extends ArrayAdapter<TransactionListItem> {
// public static final String TAG = TransactionListAdapter.class.getName();
//
// private final Context mContext;
// private final int layoutResourceId;
// private Button sentReceived;
//// private final Point displayParameters = new Point();
//// public static TransactionListAdapter currencyListAdapter;
//
// public TransactionListAdapter(Context mContext) {
//
// super(mContext, R.layout.transaction_list_item);
//
// this.layoutResourceId = R.layout.transaction_list_item;
// this.mContext = mContext;
//// ((Activity)mContext).getWindowManager().getDefaultDisplay().getSize(displayParameters);
//// currencyListAdapter = this;
// }
//
// @Override
// public View getView(int position, View convertView, ViewGroup parent) {
//
//// SharedPreferences settings = mContext.getSharedPreferences(MainActivity.PREFS_NAME, 0);
//// final int tmp = settings.getInt(FragmentCurrency.POSITION, 0);
// if (convertView == null) {
// // inflate the layout
// LayoutInflater inflater = ((Activity) mContext).getLayoutInflater();
// convertView = inflater.inflate(layoutResourceId, parent, false);
// }
// // get the TextView and then set the text (item name) and tag (item ID) values
// sentReceived = (Button) convertView.findViewById(R.id.transaction_sent_received_label);
// sentReceived.setText(getItem(position).getHexId());
// Log.e(TAG, "transaction list adapter (&#^*&^#*$*#%$%#*$^%#*%*$%@%$@%$%(&@: " + position);
//// textViewItem.setText(this.getItem(position).codeAndName);
//// ImageView checkMark = (ImageView) convertView.findViewById(R.id.currency_checkmark);
//// if (position == tmp) {
//// checkMark.setVisibility(View.VISIBLE);
//// } else {
//// checkMark.setVisibility(View.GONE);
//// }
// return convertView;
//
// }
//
// @Override
// public int getItemViewType(int position) {
// return IGNORE_ITEM_VIEW_TYPE;
// }
//
//
//}

2
app/src/main/java/com/breadwallet/tools/animation/FragmentAnimator.java

@ -302,9 +302,11 @@ public class FragmentAnimator {
FragmentAnimator.multiplePressingAvailable = true;
}
}, 300);
FragmentManager fragmentManager = app.getFragmentManager();
FragmentScanResult fragmentScanResult = (FragmentScanResult)
fragmentManager.findFragmentByTag(FragmentScanResult.class.getName());
if (fragmentScanResult == null) return;
fragmentManager.beginTransaction().
setCustomAnimations(R.animator.from_left, R.animator.to_right).
remove(fragmentScanResult).commit();

20
app/src/main/java/com/breadwallet/tools/security/RequestHandler.java

@ -1,6 +1,7 @@
package com.breadwallet.tools.security;
import android.app.Activity;
import android.content.Context;
import android.os.AsyncTask;
import android.util.Log;
@ -57,7 +58,7 @@ public class RequestHandler {
private static final String TAG = RequestHandler.class.getName();
private static final Object lockObject = new Object();
public static synchronized void processRequest(Activity app, String address) {
public static synchronized void processRequest(MainActivity app, String address) {
try {
RequestObject requestObject = getRequestFromString(address);
@ -71,7 +72,7 @@ public class RequestHandler {
if (requestObject.r != null) {
tryAndProcessRequestURL(requestObject);
} else if (requestObject.address != null) {
tryAndProcessBitcoinURL(requestObject);
tryAndProcessBitcoinURL(requestObject, app);
} else {
if (app != null) {
((BreadWalletApp) app.getApplication()).showCustomDialog(app.getString(R.string.warning),
@ -133,25 +134,28 @@ public class RequestHandler {
}
private static boolean tryAndProcessBitcoinURL(RequestObject requestObject) {
private static boolean tryAndProcessBitcoinURL(RequestObject requestObject, MainActivity app) {
/** use the C implementation to check it */
final String str = requestObject.address;
if (str == null) return false;
int length = str.length();
if (length < 26 || length > 35) {
if (!BRWalletManager.getInstance(app).validateAddress(str.trim())) {
Log.e(TAG, "WRONG ADDRESS");
return false;
}
final String[] addresses = new String[1];
addresses[0] = str;
// CustomLogger.LogThis("amount", requestObject.amount, "address", requestObject.address);
if (requestObject.amount != null) {
Double doubleAmount = Double.parseDouble(requestObject.amount) * 100000000;
Double doubleAmount = Double.parseDouble(requestObject.amount ) * 1000000;
long amount = doubleAmount.longValue();
PaymentRequestEntity requestEntity = new PaymentRequestEntity(addresses,
amount, "");
MainActivity app = MainActivity.app;
Log.e(TAG, "requestEntity.amount: " + requestEntity.amount);
Log.e(TAG, "requestEntity.addresses[0]: " + requestEntity.addresses[0]);
String strAmount = String.valueOf(requestEntity.amount );
if (app != null) {
app.confirmPay(requestEntity);
app.pay(requestEntity.addresses[0], strAmount);
}
} else {
MainActivity.app.runOnUiThread(new Runnable() {

4
app/src/main/java/com/breadwallet/wallet/BRWalletManager.java

@ -318,4 +318,8 @@ public class BRWalletManager {
public native boolean tryTransaction(String addressHolder, long amountHolder);
public native long localAmount(long amount, double price);
public native long bitcoinAmount(long localAmount, double price);
}

2
app/src/main/jni/breadwallet-core

@ -1 +1 @@
Subproject commit 3412bb9500e785316f481f73d1d13c2d5d3ed21f
Subproject commit d74485f7467ff9051075e1b5e8955c927d138e70

26
app/src/main/jni/transition/PeerManager.c

@ -23,20 +23,16 @@ static jclass _blockClass;
static jclass _peerClass;
static JNIEnv *_env;
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved){
if ((*vm)->GetEnv(vm, &_env, JNI_VERSION_1_6) != JNI_OK) {
__android_log_print(ANDROID_LOG_ERROR, "Message from C: ", "syncStarted");
return -1;
}
//JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved){
//
// if ((*vm)->GetEnv(vm, &_env, JNI_VERSION_1_6) != JNI_OK) {
// __android_log_print(ANDROID_LOG_ERROR, "Message from C: ", "syncStarted");
// return -1;
// }
jclass tmpBlockClass = (*_env)->FindClass(_env, "com/breadwallet/presenter/entities/BlockEntity");
_blockClass = (jclass)(*_env)->NewGlobalRef(_env, tmpBlockClass);
jclass tmpPeerClass = (*_env)->FindClass(_env, "com/breadwallet/presenter/entities/PeerEntity");
_peerClass = (jclass)(*_env)->NewGlobalRef(_env, tmpPeerClass);
return JNI_VERSION_1_6;
}
// return JNI_VERSION_1_6;
//}
static JNIEnv* getEnv() {
JNIEnv *env;
@ -182,6 +178,7 @@ static void savePeers(void *info, const BRPeer peers[], size_t count) {
(*env)->DeleteLocalRef(env, peerAddress);
(*env)->DeleteLocalRef(env, peerPort);
(*env)->DeleteLocalRef(env, peerTimeStamp);
(*env)->DeleteLocalRef(env, peerObject);
}
(*env)->CallStaticVoidMethod(env, _peerManagerClass, mid, peersObjects);
@ -214,6 +211,11 @@ JNIEXPORT void Java_com_breadwallet_wallet_BRPeerManager_createAndConnect(JNIEnv
jclass walletManagerCLass = (*env)->FindClass(env, "com/breadwallet/wallet/BRPeerManager");
_peerManagerClass = (jclass) (*env)->NewGlobalRef(env, (jobject) walletManagerCLass);
jclass tmpBlockClass = (*env)->FindClass(env, "com/breadwallet/presenter/entities/BlockEntity");
_blockClass = (jclass)(*env)->NewGlobalRef(env, (jobject) tmpBlockClass);
jclass tmpPeerClass = (*env)->FindClass(env, "com/breadwallet/presenter/entities/PeerEntity");
_peerClass = (jclass)(*env)->NewGlobalRef(env, (jobject) tmpPeerClass);
if (rs != JNI_OK) {
__android_log_print(ANDROID_LOG_ERROR, "Message from C: ",
"WARNING, GetJavaVM is not JNI_OK");

2
app/src/main/jni/transition/wallet.c

File diff suppressed because one or more lines are too long

6
app/src/main/res/layout/activity_main.xml

@ -104,10 +104,10 @@
<RelativeLayout
android:id="@+id/main_internet_status_bar"
android:layout_width="match_parent"
android:layout_height="20dp"
android:layout_height="30dp"
android:layout_below="@+id/sync_progress_bar"
android:layout_centerHorizontal="true"
android:background="@color/red"
android:background="@color/pink"
android:orientation="horizontal"
android:visibility="gone">
@ -118,7 +118,7 @@
android:layout_centerHorizontal="true"
android:layout_gravity="center"
android:text="@string/no_internet_connection"
android:textColor="@android:color/white" />
android:textColor="@color/red" />
</RelativeLayout>

1
app/src/main/res/values/colors.xml

@ -24,6 +24,7 @@
<item name="black_trans" type="color">#b54a2500</item>
<item name="red_text" type="color">#FF5454</item>
<item name="green_text" type="color">#00BF00</item>
<item name="pink" type="color">#68fda8aa</item>
//fingerprint
<color name="warning_color">#f4511e</color>

2
app/src/main/res/values/strings.xml

@ -39,7 +39,7 @@
<string name="toast_qr_tip">Let others scan this QR code to get your bitcoin address. Anyone can send bitcoins to your wallet by transferring them to your address</string>
<string name="toast_address_tip">This is your bitcoin address. Tap to copy it or send it by email or sms. The address will change each time you receive funds, but old addresses always work</string>
<string name="mainactivity_press_back_again">Press again to exit!</string>
<string name="no_internet_connection">No internet connection</string>
<string name="no_internet_connection">not connected</string>
<string name="warning">WARNING</string>
<string name="dialog_do_not_let_anyone">DO NOT let anyone see your recovery phrase or they can spend your bitcoins.
\n\nNEVER type your recovery phrase into password managers or elsewhere.\nOther devices may be infected.\n\nDO NOT take a screenshot.\nScreenshots are visible to other apps and devices.</string>

Loading…
Cancel
Save