Skip to content

Commit

Permalink
Several fixes and suggestions, b 236
Browse files Browse the repository at this point in the history
  • Loading branch information
MIPPL committed Oct 22, 2019
1 parent 6e05bc2 commit 3adb50f
Show file tree
Hide file tree
Showing 20 changed files with 251 additions and 88 deletions.
Binary file modified .idea/caches/build_file_checksums.ser
Binary file not shown.
Binary file modified .idea/caches/gradle_models.ser
Binary file not shown.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ android {
applicationId = 'com.wagerrwallet'
minSdkVersion 23
targetSdkVersion 28
versionCode 235
versionName "235"
versionCode 236
versionName "236"
multiDexEnabled true

// Similar to other properties in the defaultConfig block,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ public void hidePrompt() {
if (mCurrentPrompt == PromptManager.PromptItem.SHARE_DATA) {
BRSharedPrefs.putShareDataDismissed(app, true);
}
if (mCurrentPrompt == PromptManager.PromptItem.FINGER_PRINT) {
BRSharedPrefs.putFingerprintDismissed(app, true);
}
if (mCurrentPrompt != null)
BREventManager.getInstance().pushEvent("prompt." + PromptManager.getInstance().getPromptName(mCurrentPrompt) + ".dismissed");
mCurrentPrompt = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public void onClick(View v) {
policyText.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://www.wagerr.com/privacy/"));
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse("https://github.com/wagerr/WagerrWalletAndroid/blob/master/PrivacyPolicy.md"));
startActivity(browserIntent);
app.overridePendingTransition(R.anim.enter_from_bottom, R.anim.empty_300);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,11 +140,11 @@ private String getLimitText() {
BigDecimal satoshis = new BigDecimal(BRKeyStore.getSpendLimit(this));
WalletsMaster master = WalletsMaster.getInstance(this);
//amount in BTC, mBTC or bits
BigDecimal amount = master.getCurrentWallet(this).getFiatForSmallestCrypto(this, satoshis, null);
BigDecimal amount = satoshis.divide( new BigDecimal(BRConstants.ONE_BITCOIN)); // master.getCurrentWallet(this).getFiatForSmallestCrypto(this, satoshis, null);
//amount in user preferred ISO (e.g. USD)
BigDecimal curAmount = master.getCurrentWallet(this).getFiatForSmallestCrypto(this, satoshis, null);
//formatted string for the label
return String.format(getString(R.string.TouchIdSettings_spendingLimit), CurrencyUtils.getFormattedAmount(this, "WGR", amount), CurrencyUtils.getFormattedAmount(this, iso, curAmount));
return String.format(getString(R.string.TouchIdSettings_spendingLimit), CurrencyUtils.getFormattedAmount(this, "WGR", satoshis), CurrencyUtils.getFormattedAmount(this, iso, curAmount));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@ public void onClick(View v) {
}
}, false));
*/
/* remove this option upon request
items.add(new BRSettingsItem(getString(R.string.Settings_review), "", new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -267,7 +268,7 @@ public void onClick(View v) {
overridePendingTransition(R.anim.enter_from_right, R.anim.exit_to_left);
}
}, false));

*/
items.add(new BRSettingsItem(getString(R.string.Settings_aboutBread), "", new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.text.Editable;
import android.text.TextWatcher;
import android.util.Log;
import android.view.KeyEvent;
import android.view.LayoutInflater;
Expand Down Expand Up @@ -39,6 +41,7 @@
import com.wagerrwallet.tools.manager.BRClipboardManager;
import com.wagerrwallet.tools.manager.BRSharedPrefs;
import com.wagerrwallet.tools.manager.SendManager;
import com.wagerrwallet.tools.util.BRConstants;
import com.wagerrwallet.tools.util.BRDateUtil;
import com.wagerrwallet.tools.util.CurrencyUtils;
import com.wagerrwallet.tools.util.Utils;
Expand Down Expand Up @@ -122,6 +125,7 @@ public class FragmentEventDetails extends DialogFragment implements View.OnClick
private ImageButton mAcceptBet;
private ImageButton mCancelBet;
private View mCurrentSelectedBetOption = null;
private ImageButton faq;
private BRText mPotentialReward;


Expand Down Expand Up @@ -153,6 +157,16 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,

View rootView = inflater.inflate(R.layout.event_details, container, false);

faq = (ImageButton) rootView.findViewById(R.id.faq_button);

faq.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!BRAnimator.isClickAllowed()) return;
BRAnimator.showSupportFragment(getActivity(), BRConstants.betSlip);
}
});

mMainLayout = rootView.findViewById(R.id.dynamic_container);
mTxEventHeader = rootView.findViewById(R.id.tx_eventheader);
mTxEventDate= rootView.findViewById(R.id.tx_eventdate);
Expand Down Expand Up @@ -229,6 +243,33 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
}
});


mTxAmount.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
String oddTx = ((BRText)mCurrentSelectedBetOption).getText().toString();
float odds = 0;
int value = getContext().getResources().getInteger(R.integer.min_bet_amount);
int minvalue = value;
Float fValue = 0.0f;
try {
odds = Float.parseFloat( oddTx );
fValue = Float.parseFloat(mTxAmount.getText().toString());
value = Math.max(minvalue, fValue.intValue());
} catch (NumberFormatException e) {
}
setRewardAmount(value, odds);
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
// TODO Auto-generated method stub
}
@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub
}
});

mSpreadsContainer = rootView.findViewById(R.id.spreads_container);
mSpreadsLayout = rootView.findViewById(R.id.spreads_layout);
mTxSpreadPoints= rootView.findViewById(R.id.tx_spread_points);
Expand Down Expand Up @@ -266,7 +307,7 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
mTxLastDate = rootView.findViewById(R.id.tx_last_date);
mToFrom = rootView.findViewById(R.id.tx_to_from);
mToFromAddress = rootView.findViewById(R.id.tx_to_from_address);
mMemoText = rootView.findViewById(R.id.memo);
//mMemoText = rootView.findViewById(R.id.memo);
mStartingBalance = rootView.findViewById(R.id.tx_starting_balance);
mEndingBalance = rootView.findViewById(R.id.tx_ending_balance);
mExchangeRate = rootView.findViewById(R.id.exchange_rate);
Expand Down Expand Up @@ -333,11 +374,7 @@ protected void updateSeekBar( int amount, int posX ) {
try {
odds = Float.parseFloat( oddTx );
stake = amount;
long rewardAmount = stake + (long)((stake * (odds - 1)) * 0.94);
BigDecimal rewardCryptoAmount = new BigDecimal((long)rewardAmount*UNIT_MULTIPLIER);
BigDecimal rewardFiatAmount = walletManager.getFiatForSmallestCrypto(getActivity(), rewardCryptoAmount.abs(), null);
String rewardFiatAmountStr = CurrencyUtils.getFormattedAmount(getContext(), BRSharedPrefs.getPreferredFiatIso(getContext()), rewardFiatAmount);
mPotentialReward.setText("" + rewardAmount + " WGR (" + rewardFiatAmountStr +")" );
setRewardAmount(stake, odds);
}
catch (NumberFormatException e) {
mPotentialReward.setText("---");
Expand All @@ -349,6 +386,21 @@ protected void updateSeekBar( int amount, int posX ) {
//mTxAmount.setX(seekBar.getX() + posX);
}

protected void setRewardAmount(long stake, float odds) {
BaseWalletManager walletManager = WalletsMaster.getInstance(getActivity()).getCurrentWallet(getActivity());

try {
long rewardAmount = stake + (long)((stake * (odds - 1)) * 0.94);
BigDecimal rewardCryptoAmount = new BigDecimal((long)rewardAmount*UNIT_MULTIPLIER);
BigDecimal rewardFiatAmount = walletManager.getFiatForSmallestCrypto(getActivity(), rewardCryptoAmount.abs(), null);
String rewardFiatAmountStr = CurrencyUtils.getFormattedAmount(getContext(), BRSharedPrefs.getPreferredFiatIso(getContext()), rewardFiatAmount);
mPotentialReward.setText("" + rewardAmount + " WGR (" + rewardFiatAmountStr +")" );
}
catch (NumberFormatException e) {
mPotentialReward.setText("---");
}
}

protected void AcceptBet() {
int min = getContext().getResources().getInteger(R.integer.min_bet_amount);
BetEntity.BetTxType betType = (mTransaction.getType()== BetEventEntity.BetTxType.PEERLESS)? BetEntity.BetTxType.PEERLESS:BetEntity.BetTxType.CHAIN_LOTTO;
Expand All @@ -370,7 +422,7 @@ public void onClick(BRDialogView brDialogView) {

CryptoRequest item = new CryptoRequest(tx, null, false, "", "", new BigDecimal(amount));
SendManager.sendTransaction(getActivity(), item, wallet);
BRAnimator.showFragmentEvent = mTransaction;
//BRAnimator.showFragmentEvent = mTransaction;
dismiss(); // close fragment
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.wagerrwallet.presenter.customviews.BRButton;
import com.wagerrwallet.presenter.customviews.BRKeyboard;
import com.wagerrwallet.presenter.customviews.BRLinearLayoutWithCaret;
import com.wagerrwallet.presenter.entities.CryptoRequest;
import com.wagerrwallet.tools.animation.BRAnimator;
import com.wagerrwallet.tools.animation.SlideDetector;
import com.wagerrwallet.tools.manager.BRClipboardManager;
Expand Down Expand Up @@ -232,6 +233,7 @@ public void onClick(View v) {
QRUtils.share("sms:", getActivity(), bitcoinUri.toString());
}
});
/*
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand All @@ -241,6 +243,21 @@ public void onClick(View v) {
showKeyboard(false);
}
});
*/
shareButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
if (!BRAnimator.isClickAllowed()) {
return;
}
showKeyboard(false);
BaseWalletManager walletManager = WalletsMaster.getInstance(getActivity()).getCurrentWallet(getActivity());
CryptoRequest cryptoRequest = new CryptoRequest.Builder().setAddress(walletManager.decorateAddress(getActivity(), mReceiveAddress)).setAmount(new BigDecimal(getAmount())).build();
Uri cryptoUri = CryptoUriParser.createCryptoUrl(getActivity(), walletManager, cryptoRequest);
QRUtils.sendShareIntent(getActivity(), cryptoUri.toString(), cryptoRequest.getAddress(true));
}
});

mAddress.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import com.wagerrwallet.tools.manager.BRSharedPrefs;
import com.wagerrwallet.tools.sqlite.BetEventTxDataStore;
import com.wagerrwallet.tools.sqlite.BetResultTxDataStore;
import com.wagerrwallet.tools.util.BRConstants;
import com.wagerrwallet.tools.util.BRDateUtil;
import com.wagerrwallet.tools.util.CurrencyUtils;
import com.wagerrwallet.tools.util.Utils;
Expand Down Expand Up @@ -62,6 +63,7 @@ public class FragmentTxDetails extends DialogFragment {
private BRText mToFromAddress2;
private BRText mToFromAddress3;
private BRText mMemoText;
private BRText mLinkOpenInExplorer;

private BRText mStartingBalance;
private BRText mEndingBalance;
Expand Down Expand Up @@ -108,7 +110,8 @@ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
mToFromAddress = rootView.findViewById(R.id.tx_to_from_address);
mToFromAddress2 = rootView.findViewById(R.id.tx_to_from_address2);
mToFromAddress3 = rootView.findViewById(R.id.tx_to_from_address3);
mMemoText = rootView.findViewById(R.id.memo);
//mMemoText = rootView.findViewById(R.id.memo);
mLinkOpenInExplorer = rootView.findViewById(R.id.link_open_in_explorer);
mStartingBalance = rootView.findViewById(R.id.tx_starting_balance);
mEndingBalance = rootView.findViewById(R.id.tx_ending_balance);
mExchangeRate = rootView.findViewById(R.id.exchange_rate);
Expand Down Expand Up @@ -200,9 +203,9 @@ private void updateUi() {

BigDecimal tmpStartingBalance = new BigDecimal(mTransaction.getBalanceAfterTx()).subtract(cryptoAmount.abs()).subtract(new BigDecimal(mTransaction.getFee()).abs());

BigDecimal startingBalance = isCryptoPreferred ? walletManager.getCryptoForSmallestCrypto(getActivity(), tmpStartingBalance) : walletManager.getFiatForSmallestCrypto(getActivity(), tmpStartingBalance, null);
BigDecimal startingBalance = isCryptoPreferred ? walletManager.getCryptoForSmallestCrypto(getActivity(), tmpStartingBalance).multiply(new BigDecimal(BRConstants.ONE_BITCOIN)) : walletManager.getFiatForSmallestCrypto(getActivity(), tmpStartingBalance, null);

BigDecimal endingBalance = isCryptoPreferred ? walletManager.getCryptoForSmallestCrypto(getActivity(), new BigDecimal(mTransaction.getBalanceAfterTx())) : walletManager.getFiatForSmallestCrypto(getActivity(), new BigDecimal(mTransaction.getBalanceAfterTx()), null);
BigDecimal endingBalance = isCryptoPreferred ? walletManager.getCryptoForSmallestCrypto(getActivity(), new BigDecimal(mTransaction.getBalanceAfterTx())).multiply(new BigDecimal(BRConstants.ONE_BITCOIN)) : walletManager.getFiatForSmallestCrypto(getActivity(), new BigDecimal(mTransaction.getBalanceAfterTx()), null);

mStartingBalance.setText(CurrencyUtils.getFormattedAmount(getActivity(), iso, startingBalance == null ? null : startingBalance.abs()));
mEndingBalance.setText(CurrencyUtils.getFormattedAmount(getActivity(), iso, endingBalance == null ? null : endingBalance.abs()));
Expand Down Expand Up @@ -299,6 +302,7 @@ public void onClick(View v) {
mTxAmount.setTextColor(getContext().getColor(R.color.transaction_amount_received_color));

// Set the memo text if one is available
/* disable memo upon request
String memo;
TxMetaData txMetaData = KVStoreManager.getInstance().getTxMetaData(getActivity(), mTransaction.getTxHash());
Expand All @@ -320,7 +324,7 @@ public void onClick(View v) {
} else {
mMemoText.setText("");
}

*/
// timestamp is 0 if it's not confirmed in a block yet so make it now
mTxDate.setText(BRDateUtil.getMidDate(mTransaction.getTimeStamp() == 0 ? System.currentTimeMillis() : (mTransaction.getTimeStamp() * 1000)));

Expand Down Expand Up @@ -350,6 +354,15 @@ public void run() {
}
});

mLinkOpenInExplorer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(String.format("https://explorer.wagerr.com/#/tx/%s", mTransaction.getTxHashHexReversed())));
startActivity(browserIntent);
getActivity().overridePendingTransition(R.anim.enter_from_bottom, R.anim.empty_300);
}
});

// Set the transaction block number
mConfirmedInBlock.setText(String.valueOf(mTransaction.getBlockHeight()));

Expand Down
Loading

0 comments on commit 3adb50f

Please sign in to comment.