diff --git a/.idea/modules.xml b/.idea/modules.xml
index 52a531e..f4fed45 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,6 +3,7 @@
+
diff --git a/app/src/main/java/com/nauk/moodl/Activities/RecordTransactionActivity.java b/app/src/main/java/com/nauk/moodl/Activities/RecordTransactionActivity.java
index 7971e97..6986192 100644
--- a/app/src/main/java/com/nauk/moodl/Activities/RecordTransactionActivity.java
+++ b/app/src/main/java/com/nauk/moodl/Activities/RecordTransactionActivity.java
@@ -23,14 +23,18 @@ public class RecordTransactionActivity extends AppCompatActivity {
private String coin;
private String symbol;
- private EditText amountTxtView;
+ private TextView symbolTxtView;
private TextView purchasedDate;
+ private TextView feesTxtView;
+ private EditText amountTxtView;
private Button validateButton;
+ private Button receivedButton;
+ private Button sentButton;
private DatabaseManager databaseManager;
private Calendar calendar;
private SimpleDateFormat sdf;
private PreferencesManager preferenceManager;
- private EditText purchasedPrice;
+ private EditText purchasedPriceEditText;
private Currency currency;
@Override
@@ -53,13 +57,18 @@ public class RecordTransactionActivity extends AppCompatActivity {
databaseManager = new DatabaseManager(this);
preferenceManager = new PreferencesManager(this);
- validateButton = findViewById(R.id.validateButton);
+ symbolTxtView = findViewById(R.id.currencySymbol);
amountTxtView = findViewById(R.id.currencyAmount);
+ feesTxtView = findViewById(R.id.feesTextView);
purchasedDate = findViewById(R.id.purchaseDate);
- purchasedPrice = findViewById(R.id.purchasePrice);
+ purchasedPriceEditText = findViewById(R.id.purchasePrice);
+ validateButton = findViewById(R.id.validateButton);
+ receivedButton = findViewById(R.id.receivedButton);
+ sentButton = findViewById(R.id.sentButton);
//purchasedPrice.setText();
purchasedDate.setText(sdf.format(calendar.getTime()));
+ symbolTxtView.setText(symbol);
purchasedDate.setOnClickListener(new View.OnClickListener() {
@Override
@@ -71,7 +80,16 @@ public class RecordTransactionActivity extends AppCompatActivity {
validateButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
- databaseManager.addCurrencyToManualCurrency(symbol, Double.parseDouble(amountTxtView.getText().toString()), calendar.getTime(), purchasedPrice.getText().toString());
+ double amount = Double.parseDouble(amountTxtView.getText().toString());
+ double purchasedPrice = Double.parseDouble(purchasedPriceEditText.getText().toString());
+ double fees = Double.parseDouble(feesTxtView.getText().toString());
+
+ if(!sentButton.isEnabled())
+ {
+ amount *= -1;
+ }
+
+ databaseManager.addCurrencyToManualCurrency(symbol, amount, calendar.getTime(), purchasedPrice, fees);
preferenceManager.setMustUpdateSummary(true);
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
@@ -80,10 +98,30 @@ public class RecordTransactionActivity extends AppCompatActivity {
}
});
+ receivedButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ receivedButton.setEnabled(false);
+ sentButton.setEnabled(true);
+ purchasedPriceEditText.setVisibility(View.VISIBLE);
+ feesTxtView.setVisibility(View.GONE);
+ }
+ });
+
+ sentButton.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ receivedButton.setEnabled(true);
+ sentButton.setEnabled(false);
+ purchasedPriceEditText.setVisibility(View.GONE);
+ feesTxtView.setVisibility(View.VISIBLE);
+ }
+ });
+
currency.getTimestampPrice(this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
@Override
public void onSuccess(String price) {
- purchasedPrice.setText(price);
+ purchasedPriceEditText.setText(price);
}
}, calendar.getTimeInMillis() / 1000);
}
@@ -122,7 +160,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
currency.getTimestampPrice(RecordTransactionActivity.this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
@Override
public void onSuccess(String price) {
- purchasedPrice.setText(price);
+ purchasedPriceEditText.setText(price);
}
}, calendar.getTimeInMillis() / 1000);
Log.d("moodl", "Time : " + calendar.getTimeInMillis());
diff --git a/app/src/main/java/com/nauk/moodl/DataManagers/DatabaseManager.java b/app/src/main/java/com/nauk/moodl/DataManagers/DatabaseManager.java
index b1bd661..5f9bad3 100644
--- a/app/src/main/java/com/nauk/moodl/DataManagers/DatabaseManager.java
+++ b/app/src/main/java/com/nauk/moodl/DataManagers/DatabaseManager.java
@@ -34,6 +34,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
private static final String KEY_CURRENCY_DATE = "addDate";
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
private static final String KEY_CURRENCY_IS_MINED = "isMined";
+ private static final String KEY_CURRENCY_FEES = "fees";
private static final String KEY_EXCHANGE_ID = "idExchange";
private static final String KEY_EXCHANGE_NAME = "name";
@@ -60,7 +61,8 @@ public class DatabaseManager extends SQLiteOpenHelper{
+ KEY_CURRENCY_BALANCE + " TEXT,"
+ KEY_CURRENCY_DATE + " TEXT,"
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
- + KEY_CURRENCY_IS_MINED + " INTEGER"
+ + KEY_CURRENCY_IS_MINED + " INTEGER,"
+ + KEY_CURRENCY_FEES + " REAL"
+ ");");
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "("
@@ -125,7 +127,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
return currencyList;
}
- public void addCurrencyToManualCurrency(String symbol, double balance, Date date, String purchasedPrice)
+ public void addCurrencyToManualCurrency(String symbol, double balance, Date date, double purchasedPrice, double fees)
{
SQLiteDatabase db = this.getWritableDatabase();
ContentValues values = new ContentValues();
@@ -134,6 +136,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
values.put(KEY_CURRENCY_BALANCE, balance);
values.put(KEY_CURRENCY_DATE, date.getTime());
values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice);
+ values.put(KEY_CURRENCY_FEES, fees);
db.insert(TABLE_MANUAL_CURRENCIES, null, values);
db.close();
@@ -149,7 +152,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
while(resultatList.moveToNext())
{
- currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3)));
+ currencyList.add(new Currency(resultatList.getString(1), resultatList.getDouble(3) - resultatList.getDouble(7)));
}
resultatList.close();
diff --git a/app/src/main/java/com/nauk/moodl/LayoutManagers/TransactionListAdapter.java b/app/src/main/java/com/nauk/moodl/LayoutManagers/TransactionListAdapter.java
index 1521f12..4e1ac51 100644
--- a/app/src/main/java/com/nauk/moodl/LayoutManagers/TransactionListAdapter.java
+++ b/app/src/main/java/com/nauk/moodl/LayoutManagers/TransactionListAdapter.java
@@ -68,7 +68,7 @@ public class TransactionListAdapter extends ArrayAdapter {
DatabaseManager databaseManager = new DatabaseManager(context);
preferencesManager.setMustUpdateSummary(true);
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
- collapse((View) view.getParent().getParent().getParent().getParent());
+ collapse((View) view.getParent().getParent().getParent());
}
});
diff --git a/app/src/main/res/drawable/button_received.xml b/app/src/main/res/drawable/button_received.xml
new file mode 100644
index 0000000..f8aebaf
--- /dev/null
+++ b/app/src/main/res/drawable/button_received.xml
@@ -0,0 +1,12 @@
+
+
+
+ -
+
+
+
+ -
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/drawable/button_sent.xml b/app/src/main/res/drawable/button_sent.xml
new file mode 100644
index 0000000..01dc145
--- /dev/null
+++ b/app/src/main/res/drawable/button_sent.xml
@@ -0,0 +1,12 @@
+
+
+
+ -
+
+
+
+ -
+
+
+
+
\ No newline at end of file
diff --git a/app/src/main/res/layout/activity_record_transaction.xml b/app/src/main/res/layout/activity_record_transaction.xml
index e0e8ae9..d7f0fd4 100644
--- a/app/src/main/res/layout/activity_record_transaction.xml
+++ b/app/src/main/res/layout/activity_record_transaction.xml
@@ -8,7 +8,37 @@
+ android:orientation="vertical"
+ android:layout_margin="5dp">
+
+
+
+
+
+
+
+
+
+