diff --git a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
index d69fc9c..fb17037 100644
--- a/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
+++ b/app/src/main/java/com/herbron/moodl/Activities/RecordTransactionFragments/BuyFragment.java
@@ -283,7 +283,7 @@ public class BuyFragment extends CustomRecordFragment {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
- if(isFieldCorrectlyFilled(amoutEditText, false) && isFieldCorrectlyFilled(buyPriceEditText, false) && isFieldCorrectlyFilled(totalValueEditText, false))
+ if((isFieldCorrectlyFilled(amoutEditText, false) || isFieldCorrectlyFilled(totalValueEditText, false)) && isFieldCorrectlyFilled(buyPriceEditText, false))
{
double amount = Double.parseDouble(amoutEditText.getText().toString());
double purchasePrice = Double.parseDouble(buyPriceEditText.getText().toString());
@@ -300,7 +300,7 @@ public class BuyFragment extends CustomRecordFragment {
amount = totalValue / purchasePrice;
}
- if(fees_editText.getText().toString().equals("") || fees_editText.getText().toString().equals("0"))
+ if(fees_editText.getText().toString().equals("0") || (start == 0 && before == 1 && count == 0))
{
if(isAmountLastUpdated)
{
@@ -314,7 +314,7 @@ public class BuyFragment extends CustomRecordFragment {
else
{
- if(feesCurrencySpinner.getSelectedItemPosition() < 1)
+ if(feesCurrencySpinner.getSelectedItemPosition() < 2)
{
feeCurrency = fragmentPair.getFrom();
}
@@ -325,13 +325,41 @@ public class BuyFragment extends CustomRecordFragment {
fees = getFees(feeCurrency, amount, purchasePrice);
- if(isAmountLastUpdated)
+ if(feesCurrencySpinner.getSelectedItemPosition() % 2 == 0)
{
- totalValueEditText.setText(String.valueOf(totalValue + fees));
+ if(isAmountLastUpdated)
+ {
+ totalValueEditText.setText(String.valueOf(totalValue + fees));
+ }
+ else
+ {
+ amoutEditText.setText(String.valueOf(amount - (fees / purchasePrice)));
+ }
}
else
{
- amoutEditText.setText(String.valueOf(amount - (fees / purchasePrice )));
+ if(fragmentCurrency.getSymbol().equals(feeCurrency))
+ {
+ if(isAmountLastUpdated)
+ {
+ totalValueEditText.setText(String.valueOf(totalValue + (fees * purchasePrice)));
+ }
+ else
+ {
+ amoutEditText.setText(String.valueOf((totalValue / purchasePrice) - fees));
+ }
+ }
+ else
+ {
+ if(isAmountLastUpdated)
+ {
+ totalValueEditText.setText(String.valueOf(totalValue + fees));
+ }
+ else
+ {
+ amoutEditText.setText(String.valueOf((totalValue - fees) / purchasePrice));
+ }
+ }
}
}
}
diff --git a/app/src/main/res/layout-v21/fragment_sell.xml b/app/src/main/res/layout-v21/fragment_sell.xml
index 88d790e..d55f53d 100644
--- a/app/src/main/res/layout-v21/fragment_sell.xml
+++ b/app/src/main/res/layout-v21/fragment_sell.xml
@@ -1,15 +1,135 @@
-
-
+ android:layout_margin="@dimen/margin"
+ android:orientation="vertical">
-
\ No newline at end of file
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/values-fr/strings.xml b/app/src/main/res/values-fr/strings.xml
index 5cca29f..1cb703e 100644
--- a/app/src/main/res/values-fr/strings.xml
+++ b/app/src/main/res/values-fr/strings.xml
@@ -157,4 +157,6 @@
Pourcentage de %1$s
%1$s fixe
+ Prix de vente
+ Date de vente
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 2423a18..41c377c 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -261,7 +261,6 @@
Informations
Choose a coin
-
Exchange
Pair
Total value
@@ -272,5 +271,7 @@
%1$s percentage
%1$s fixed
+ Sell price
+ Sell date