Add fees for sent transaction
This commit is contained in:
parent
ee8ba428d7
commit
19872f5609
1
.idea/modules.xml
generated
1
.idea/modules.xml
generated
@ -3,6 +3,7 @@
|
|||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<modules>
|
||||||
<module fileurl="file://$PROJECT_DIR$/Moodl.iml" filepath="$PROJECT_DIR$/Moodl.iml" />
|
<module fileurl="file://$PROJECT_DIR$/Moodl.iml" filepath="$PROJECT_DIR$/Moodl.iml" />
|
||||||
|
<module fileurl="file://E:\Github\Moodl\Moodl.iml" filepath="E:\Github\Moodl\Moodl.iml" />
|
||||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||||
</modules>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
|
@ -23,14 +23,18 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
|
|
||||||
private String coin;
|
private String coin;
|
||||||
private String symbol;
|
private String symbol;
|
||||||
private EditText amountTxtView;
|
private TextView symbolTxtView;
|
||||||
private TextView purchasedDate;
|
private TextView purchasedDate;
|
||||||
|
private TextView feesTxtView;
|
||||||
|
private EditText amountTxtView;
|
||||||
private Button validateButton;
|
private Button validateButton;
|
||||||
|
private Button receivedButton;
|
||||||
|
private Button sentButton;
|
||||||
private DatabaseManager databaseManager;
|
private DatabaseManager databaseManager;
|
||||||
private Calendar calendar;
|
private Calendar calendar;
|
||||||
private SimpleDateFormat sdf;
|
private SimpleDateFormat sdf;
|
||||||
private PreferencesManager preferenceManager;
|
private PreferencesManager preferenceManager;
|
||||||
private EditText purchasedPrice;
|
private EditText purchasedPriceEditText;
|
||||||
private Currency currency;
|
private Currency currency;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,13 +57,18 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
databaseManager = new DatabaseManager(this);
|
databaseManager = new DatabaseManager(this);
|
||||||
preferenceManager = new PreferencesManager(this);
|
preferenceManager = new PreferencesManager(this);
|
||||||
|
|
||||||
validateButton = findViewById(R.id.validateButton);
|
symbolTxtView = findViewById(R.id.currencySymbol);
|
||||||
amountTxtView = findViewById(R.id.currencyAmount);
|
amountTxtView = findViewById(R.id.currencyAmount);
|
||||||
|
feesTxtView = findViewById(R.id.feesTextView);
|
||||||
purchasedDate = findViewById(R.id.purchaseDate);
|
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();
|
//purchasedPrice.setText();
|
||||||
purchasedDate.setText(sdf.format(calendar.getTime()));
|
purchasedDate.setText(sdf.format(calendar.getTime()));
|
||||||
|
symbolTxtView.setText(symbol);
|
||||||
|
|
||||||
purchasedDate.setOnClickListener(new View.OnClickListener() {
|
purchasedDate.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
@ -71,7 +80,16 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
validateButton.setOnClickListener(new View.OnClickListener() {
|
validateButton.setOnClickListener(new View.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(View view) {
|
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);
|
preferenceManager.setMustUpdateSummary(true);
|
||||||
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
Intent intent = new Intent(RecordTransactionActivity.this, HomeActivity.class);
|
||||||
intent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
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() {
|
currency.getTimestampPrice(this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String price) {
|
public void onSuccess(String price) {
|
||||||
purchasedPrice.setText(price);
|
purchasedPriceEditText.setText(price);
|
||||||
}
|
}
|
||||||
}, calendar.getTimeInMillis() / 1000);
|
}, calendar.getTimeInMillis() / 1000);
|
||||||
}
|
}
|
||||||
@ -122,7 +160,7 @@ public class RecordTransactionActivity extends AppCompatActivity {
|
|||||||
currency.getTimestampPrice(RecordTransactionActivity.this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
|
currency.getTimestampPrice(RecordTransactionActivity.this, preferenceManager.getDefaultCurrency(), new Currency.PriceCallBack() {
|
||||||
@Override
|
@Override
|
||||||
public void onSuccess(String price) {
|
public void onSuccess(String price) {
|
||||||
purchasedPrice.setText(price);
|
purchasedPriceEditText.setText(price);
|
||||||
}
|
}
|
||||||
}, calendar.getTimeInMillis() / 1000);
|
}, calendar.getTimeInMillis() / 1000);
|
||||||
Log.d("moodl", "Time : " + calendar.getTimeInMillis());
|
Log.d("moodl", "Time : " + calendar.getTimeInMillis());
|
||||||
|
@ -34,6 +34,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
private static final String KEY_CURRENCY_DATE = "addDate";
|
private static final String KEY_CURRENCY_DATE = "addDate";
|
||||||
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
|
private static final String KEY_CURRENCY_PURCHASED_PRICE = "purchasedPrice";
|
||||||
private static final String KEY_CURRENCY_IS_MINED = "isMined";
|
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_ID = "idExchange";
|
||||||
private static final String KEY_EXCHANGE_NAME = "name";
|
private static final String KEY_EXCHANGE_NAME = "name";
|
||||||
@ -60,7 +61,8 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
+ KEY_CURRENCY_BALANCE + " TEXT,"
|
||||||
+ KEY_CURRENCY_DATE + " TEXT,"
|
+ KEY_CURRENCY_DATE + " TEXT,"
|
||||||
+ KEY_CURRENCY_PURCHASED_PRICE + " REAL,"
|
+ 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 + "("
|
db.execSQL("CREATE TABLE IF NOT EXISTS " + TABLE_EXCHANGE_KEYS + "("
|
||||||
@ -125,7 +127,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
return currencyList;
|
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();
|
SQLiteDatabase db = this.getWritableDatabase();
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
@ -134,6 +136,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
values.put(KEY_CURRENCY_BALANCE, balance);
|
values.put(KEY_CURRENCY_BALANCE, balance);
|
||||||
values.put(KEY_CURRENCY_DATE, date.getTime());
|
values.put(KEY_CURRENCY_DATE, date.getTime());
|
||||||
values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice);
|
values.put(KEY_CURRENCY_PURCHASED_PRICE, purchasedPrice);
|
||||||
|
values.put(KEY_CURRENCY_FEES, fees);
|
||||||
|
|
||||||
db.insert(TABLE_MANUAL_CURRENCIES, null, values);
|
db.insert(TABLE_MANUAL_CURRENCIES, null, values);
|
||||||
db.close();
|
db.close();
|
||||||
@ -149,7 +152,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
|||||||
|
|
||||||
while(resultatList.moveToNext())
|
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();
|
resultatList.close();
|
||||||
|
@ -68,7 +68,7 @@ public class TransactionListAdapter extends ArrayAdapter<Transaction> {
|
|||||||
DatabaseManager databaseManager = new DatabaseManager(context);
|
DatabaseManager databaseManager = new DatabaseManager(context);
|
||||||
preferencesManager.setMustUpdateSummary(true);
|
preferencesManager.setMustUpdateSummary(true);
|
||||||
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
|
databaseManager.deleteTransactionFromId(Integer.parseInt(view.getTag().toString()));
|
||||||
collapse((View) view.getParent().getParent().getParent().getParent());
|
collapse((View) view.getParent().getParent().getParent());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
12
app/src/main/res/drawable/button_received.xml
Normal file
12
app/src/main/res/drawable/button_received.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="true">
|
||||||
|
<color android:color="@color/green"/>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:state_enabled="false">
|
||||||
|
<color android:color="@color/transparent_green"/>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
12
app/src/main/res/drawable/button_sent.xml
Normal file
12
app/src/main/res/drawable/button_sent.xml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
|
<item android:state_enabled="true">
|
||||||
|
<color android:color="@color/red"/>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
<item android:state_enabled="false">
|
||||||
|
<color android:color="@color/transparent_red"/>
|
||||||
|
</item>
|
||||||
|
|
||||||
|
</selector>
|
@ -8,7 +8,37 @@
|
|||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="vertical">
|
android:orientation="vertical"
|
||||||
|
android:layout_margin="5dp">
|
||||||
|
|
||||||
|
<LinearLayout
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginTop="5dp">
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/receivedButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:text="@string/receivedText"
|
||||||
|
android:background="@drawable/button_received"
|
||||||
|
android:layout_marginEnd="2.5dp"
|
||||||
|
android:enabled="false"
|
||||||
|
android:textColor="@color/white" />
|
||||||
|
|
||||||
|
<Button
|
||||||
|
android:id="@+id/sentButton"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.5"
|
||||||
|
android:text="@string/sentText"
|
||||||
|
android:background="@drawable/button_sent"
|
||||||
|
android:layout_marginStart="2.5dp"
|
||||||
|
android:textColor="@color/white"
|
||||||
|
android:enabled="true" />
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/currencySymbol"
|
android:id="@+id/currencySymbol"
|
||||||
@ -36,6 +66,14 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:hint="@string/activity_purchased_price"/>
|
android:hint="@string/activity_purchased_price"/>
|
||||||
|
|
||||||
|
<EditText
|
||||||
|
android:id="@+id/feesTextView"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:hint="@string/activity_fees"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:text="0"/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
android:id="@+id/validateButton"
|
android:id="@+id/validateButton"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
|
@ -38,4 +38,7 @@
|
|||||||
<color name="summary_background">#F5F7FA</color>
|
<color name="summary_background">#F5F7FA</color>
|
||||||
<color name="decreaseCandle">#FFFF5754</color>
|
<color name="decreaseCandle">#FFFF5754</color>
|
||||||
<color name="increaseCandle">#FF45B64A</color>
|
<color name="increaseCandle">#FF45B64A</color>
|
||||||
|
<color name="transparent_red">#22F55447</color>
|
||||||
|
<color name="transparent_green">#225DBF61</color>
|
||||||
|
<color name="transparent_white">#EEFFFFFF</color>
|
||||||
</resources>
|
</resources>
|
@ -64,6 +64,9 @@
|
|||||||
<item>3</item>
|
<item>3</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
<string name="receivedText">Received</string>
|
||||||
|
<string name="sentText">Sent</string>
|
||||||
|
|
||||||
<string-array name="multi_select_list_preference_default_value" />
|
<string-array name="multi_select_list_preference_default_value" />
|
||||||
|
|
||||||
<string name="pref_title_system_sync_settings">System sync settings</string>
|
<string name="pref_title_system_sync_settings">System sync settings</string>
|
||||||
@ -120,6 +123,7 @@
|
|||||||
<string name="activity_add_amount">Amount</string>
|
<string name="activity_add_amount">Amount</string>
|
||||||
<string name="activity_purchased_price">Purchased price</string>
|
<string name="activity_purchased_price">Purchased price</string>
|
||||||
<string name="activity_purchased_date">Purchased date</string>
|
<string name="activity_purchased_date">Purchased date</string>
|
||||||
|
<string name="activity_fees">Fees</string>
|
||||||
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
<string name="title_activity_currency_details">CurrencyDetailsActivity</string>
|
||||||
<string name="title_history">History charts</string>
|
<string name="title_history">History charts</string>
|
||||||
<string name="title_watchlist">Watchlist</string>
|
<string name="title_watchlist">Watchlist</string>
|
||||||
|
Loading…
Reference in New Issue
Block a user