diff --git a/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java b/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java index 1aedcf7a..144948c9 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java +++ b/app/src/main/java/com/m2049r/xmrwallet/data/TxData.java @@ -21,6 +21,7 @@ import android.os.Parcelable; import com.m2049r.xmrwallet.model.PendingTransaction; import com.m2049r.xmrwallet.model.Wallet; +import com.m2049r.xmrwallet.util.Helper; // https://stackoverflow.com/questions/2139134/how-to-send-an-object-from-one-android-activity-to-another-using-intents public class TxData implements Parcelable { @@ -54,7 +55,7 @@ public class TxData implements Parcelable { } public double getAmountAsDouble() { - return 1.0 * amount / 1000000000000L; + return 1.0 * amount / Helper.ONE_XMR; } public int getMixin() { diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java index 3e66a876..12edaf67 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendAmountWizardFragment.java @@ -139,7 +139,7 @@ public class SendAmountWizardFragment extends SendWizardFragment { Timber.d("onResumeFragment()"); Helper.showKeyboard(getActivity()); final long funds = getTotalFunds(); - maxFunds = 1.0 * funds / 1000000000000L; + maxFunds = 1.0 * funds / Helper.ONE_XMR; if (!sendListener.getActivityCallback().isStreetMode()) { tvFunds.setText(getString(R.string.send_available, Wallet.getDisplayAmount(funds))); diff --git a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java index f4b4ae0b..0a90c2a0 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java +++ b/app/src/main/java/com/m2049r/xmrwallet/fragment/send/SendBtcAmountWizardFragment.java @@ -34,6 +34,7 @@ import com.m2049r.xmrwallet.service.shift.ShiftException; import com.m2049r.xmrwallet.service.shift.sideshift.api.QueryOrderParameters; import com.m2049r.xmrwallet.service.shift.sideshift.api.SideShiftApi; import com.m2049r.xmrwallet.service.shift.sideshift.network.SideShiftApiImpl; +import com.m2049r.xmrwallet.util.Helper; import com.m2049r.xmrwallet.util.OkHttpHelper; import com.m2049r.xmrwallet.util.ServiceHelper; import com.m2049r.xmrwallet.widget.ExchangeOtherEditText; @@ -179,7 +180,7 @@ public class SendBtcAmountWizardFragment extends SendWizardFragment { tvXmrToParms.setText(xmrParmText); final long funds = getTotalFunds(); - double availableXmr = 1.0 * funds / 1000000000000L; + double availableXmr = 1.0 * funds / Helper.ONE_XMR; String availBtcString; String availXmrString; diff --git a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java index d53c84d6..d192f4d4 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java +++ b/app/src/main/java/com/m2049r/xmrwallet/util/Helper.java @@ -81,6 +81,7 @@ public class Helper { static public final String BASE_CRYPTO = Crypto.XMR.getSymbol(); static public final int XMR_DECIMALS = 12; + static public final long ONE_XMR = Math.round(Math.pow(10, Helper.XMR_DECIMALS)); static public final boolean SHOW_EXCHANGERATES = true; static public final boolean ALLOW_SHIFT = true; diff --git a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java index 0a04c845..deeabc6a 100644 --- a/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java +++ b/app/src/main/java/com/m2049r/xmrwallet/widget/ExchangeEditText.java @@ -349,11 +349,13 @@ public class ExchangeEditText extends LinearLayout { } } + private static final String CLEAN_FORMAT = "%." + Helper.XMR_DECIMALS + "f"; + private String getCleanAmountString(String enteredAmount) { try { double amount = Double.parseDouble(enteredAmount); if (amount >= 0) { - return String.format(Locale.US, "%,.12f", amount); + return String.format(Locale.US, CLEAN_FORMAT, amount); } else { return null; }