Update transfer tab in RecordTransactionActivity
- Add backend code to the Transfer tab TODO : - Support for %/fixed fees for transfers - Edition support for transfers
This commit is contained in:
parent
40210fdbf0
commit
f907a4bdb1
50
.idea/assetWizardSettings.xml
generated
50
.idea/assetWizardSettings.xml
generated
@ -5,7 +5,55 @@
|
||||
<map>
|
||||
<entry key="imageWizard">
|
||||
<value>
|
||||
<PersistentState />
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="imageAssetPanel">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="launcher">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="children">
|
||||
<map>
|
||||
<entry key="foregroundImage">
|
||||
<value>
|
||||
<PersistentState>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="scalingPercent" value="72" />
|
||||
<entry key="trimmed" value="true" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
<option name="values">
|
||||
<map>
|
||||
<entry key="backgroundAssetType" value="COLOR" />
|
||||
<entry key="backgroundColor" value="004e92" />
|
||||
<entry key="backgroundLayerName" value="ic_launcher_background" />
|
||||
<entry key="foregroundImage" value="D:\Projets Adobe\Photoshop\Moodl_icon_white.png" />
|
||||
<entry key="foregroundLayerName" value="ic_launcher_foreground" />
|
||||
<entry key="outputName" value="ic_launcher_moodl" />
|
||||
<entry key="previewDensity" value="MEDIUM" />
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
</map>
|
||||
</option>
|
||||
</PersistentState>
|
||||
</value>
|
||||
</entry>
|
||||
<entry key="vectorWizard">
|
||||
|
@ -1,58 +1,138 @@
|
||||
package com.herbron.moodl.Activities.RecordTransactionFragments;
|
||||
|
||||
import android.app.DatePickerDialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.PorterDuffColorFilter;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.design.widget.TextInputEditText;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.DatePicker;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TimePicker;
|
||||
|
||||
import com.herbron.moodl.CustomLayouts.CustomRecordFragment;
|
||||
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
|
||||
import com.herbron.moodl.DataManagers.CurrencyData.Transaction;
|
||||
import com.herbron.moodl.DataManagers.DatabaseManager;
|
||||
import com.herbron.moodl.DataManagers.ExchangeManager.Exchange;
|
||||
import com.herbron.moodl.R;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Arrays;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class TransferFragment extends CustomRecordFragment {
|
||||
|
||||
private static Currency fragmentCurrency;
|
||||
private static Exchange fragmentExchange;
|
||||
|
||||
private Spinner fromSpinner;
|
||||
private Spinner toSpinner;
|
||||
private Spinner feeSpinner;
|
||||
|
||||
private Button saveButton;
|
||||
private int transactionId;
|
||||
private Transaction transaction;
|
||||
|
||||
private TextInputEditText transferDateEditText;
|
||||
private TextInputEditText amountEditText;
|
||||
private TextInputEditText feesEditText;
|
||||
private TextInputEditText noteEditText;
|
||||
|
||||
private SimpleDateFormat sdf;
|
||||
private Calendar calendar;
|
||||
|
||||
private View view;
|
||||
|
||||
public static final String EXCHANGE_CODE = "stra:e";
|
||||
public static final String WALLET_CODE = "stra:mw";
|
||||
public static final String MINING_CODE = "stra:m";
|
||||
public static final String ELSE_WALLET_CODE = "stra:smew";
|
||||
public static final String AIRDROP_CODE = "stra:a";
|
||||
public static final String UNKNOWN_CODE = "stra:unk";
|
||||
public static final String FORK_CODE = "stra:fo";
|
||||
|
||||
private View.OnClickListener saveButtonClickListener = new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if(isFieldCorrectlyFilled(amountEditText, true))
|
||||
{
|
||||
if(isTransactionPossible())
|
||||
{
|
||||
DatabaseManager databaseManager = new DatabaseManager(getContext());
|
||||
double amount = Double.valueOf(amountEditText.getText().toString());
|
||||
double fees = getFees();
|
||||
|
||||
databaseManager.addTransaction(fragmentCurrency.getSymbol()
|
||||
, amount
|
||||
, calendar.getTime()
|
||||
, 0
|
||||
, fees
|
||||
, noteEditText.getText().toString()
|
||||
, ""
|
||||
, fragmentCurrency.getSymbol()
|
||||
, getDestination()
|
||||
, getSource()
|
||||
, "t"
|
||||
, feeSpinner.getSelectedItemPosition() == 0 ? "p" : "f");
|
||||
|
||||
getActivity().finish();
|
||||
}
|
||||
else
|
||||
{
|
||||
Drawable backgroundDrawableTo = toSpinner.getBackground();
|
||||
backgroundDrawableTo.mutate();
|
||||
backgroundDrawableTo.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.error), PorterDuff.Mode.SRC_ATOP));
|
||||
backgroundDrawableTo.invalidateSelf();
|
||||
|
||||
Drawable backgroundDrawableFrom = fromSpinner.getBackground();
|
||||
backgroundDrawableFrom.mutate();
|
||||
backgroundDrawableFrom.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.error), PorterDuff.Mode.SRC_ATOP));
|
||||
backgroundDrawableFrom.invalidateSelf();
|
||||
|
||||
view.findViewById(R.id.errorLayouts).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
view = inflater.inflate(R.layout.record_transaction_fragment_transfer, container, false);
|
||||
|
||||
calendar = Calendar.getInstance();
|
||||
sdf = new SimpleDateFormat(" HH:mm dd/MM/yyyy", Locale.UK);
|
||||
sdf = new SimpleDateFormat("HH:mm dd/MM/yyyy", Locale.UK);
|
||||
|
||||
initializeViewElements();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
private void initializeViewElements()
|
||||
{
|
||||
fromSpinner = view.findViewById(R.id.from_transfer_spinner);
|
||||
toSpinner = view.findViewById(R.id.to_transfer_spinner);
|
||||
feeSpinner = view.findViewById(R.id.feesFormat_editText_transfer);
|
||||
|
||||
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.from_transfer_options_string_array));
|
||||
fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.to_transfer_options_string_array));
|
||||
toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
|
||||
fromSpinner.setAdapter(fromAdapter);
|
||||
toSpinner.setAdapter(toAdapter);
|
||||
setupSpinnesr();
|
||||
|
||||
feesEditText = view.findViewById(R.id.fees_editText_transfer);
|
||||
noteEditText = view.findViewById(R.id.note_editText_transfer);
|
||||
amountEditText = view.findViewById(R.id.amount_editText_transfer);
|
||||
transferDateEditText = view.findViewById(R.id.transfertDate_editText);
|
||||
transferDateEditText.setText(sdf.format(calendar.getTime()));
|
||||
|
||||
@ -63,7 +143,187 @@ public class TransferFragment extends CustomRecordFragment {
|
||||
}
|
||||
});
|
||||
|
||||
return view;
|
||||
saveButton = view.findViewById(R.id.saveTransferButton);
|
||||
saveButton.setOnClickListener(saveButtonClickListener);
|
||||
|
||||
checkCallingIntent();
|
||||
}
|
||||
|
||||
private void checkCallingIntent()
|
||||
{
|
||||
Intent intent = getActivity().getIntent();
|
||||
transactionId = intent.getIntExtra("transactionId", -1);
|
||||
|
||||
if(transactionId != -1)
|
||||
{
|
||||
DatabaseManager databaseManager = new DatabaseManager(getContext());
|
||||
transaction = databaseManager.getCurrencyTransactionById(transactionId);
|
||||
|
||||
if(transaction.getType().equals("t"))
|
||||
{
|
||||
fillFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void fillFields()
|
||||
{
|
||||
amountEditText.setText(String.valueOf(transaction.getAmount()));
|
||||
//Fill other fields
|
||||
}
|
||||
|
||||
private void setupSpinnesr()
|
||||
{
|
||||
ArrayAdapter<String> fromAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.from_transfer_options_string_array));
|
||||
fromAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
fromSpinner.setAdapter(fromAdapter);
|
||||
|
||||
ArrayAdapter<String> toAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.to_transfer_options_string_array));
|
||||
toAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
toSpinner.setAdapter(toAdapter);
|
||||
|
||||
ArrayAdapter<String> feeAdapter = new ArrayAdapter<String>(getContext(), android.R.layout.simple_spinner_item, getResources().getStringArray(R.array.fees_options));
|
||||
feeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||
feeSpinner.setAdapter(feeAdapter);
|
||||
|
||||
fromSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
|
||||
Drawable backgroundDrawableFrom = fromSpinner.getBackground();
|
||||
backgroundDrawableFrom.mutate();
|
||||
backgroundDrawableFrom.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.separationColor), PorterDuff.Mode.SRC_ATOP));
|
||||
backgroundDrawableFrom.invalidateSelf();
|
||||
|
||||
view.findViewById(R.id.errorLayouts).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
toSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
|
||||
@Override
|
||||
public void onItemSelected(AdapterView<?> parent, View v, int position, long id) {
|
||||
Drawable backgroundDrawableTo = toSpinner.getBackground();
|
||||
backgroundDrawableTo.mutate();
|
||||
backgroundDrawableTo.setColorFilter(new PorterDuffColorFilter(getResources().getColor(R.color.separationColor), PorterDuff.Mode.SRC_ATOP));
|
||||
backgroundDrawableTo.invalidateSelf();
|
||||
|
||||
view.findViewById(R.id.errorLayouts).setVisibility(View.INVISIBLE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNothingSelected(AdapterView<?> parent) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private double getFees()
|
||||
{
|
||||
double fees = 0;
|
||||
|
||||
if(!feesEditText.getText().toString().equals(""))
|
||||
{
|
||||
fees = Double.parseDouble(feesEditText.getText().toString());
|
||||
}
|
||||
|
||||
return fees;
|
||||
}
|
||||
|
||||
private boolean isTransactionPossible()
|
||||
{
|
||||
Set<Integer> conflictFrom = new HashSet<>(Arrays.asList(2, 3, 4, 5, 6));
|
||||
Set<Integer> conflictTo = new HashSet<>(Arrays.asList(2, 3));
|
||||
|
||||
return !(conflictFrom.contains(fromSpinner.getSelectedItemPosition()) && conflictTo.contains(toSpinner.getSelectedItemPosition()));
|
||||
}
|
||||
|
||||
private String getDestination()
|
||||
{
|
||||
String destination = "";
|
||||
|
||||
switch (toSpinner.getSelectedItemPosition())
|
||||
{
|
||||
case 0:
|
||||
destination = EXCHANGE_CODE;
|
||||
break;
|
||||
case 1:
|
||||
destination = WALLET_CODE;
|
||||
break;
|
||||
case 2:
|
||||
destination = ELSE_WALLET_CODE;
|
||||
break;
|
||||
case 3:
|
||||
destination = UNKNOWN_CODE;
|
||||
break;
|
||||
}
|
||||
|
||||
return destination;
|
||||
}
|
||||
|
||||
private String getSource()
|
||||
{
|
||||
String source = "";
|
||||
|
||||
switch (fromSpinner.getSelectedItemPosition())
|
||||
{
|
||||
case 0:
|
||||
source = EXCHANGE_CODE;
|
||||
break;
|
||||
case 1:
|
||||
source = WALLET_CODE;
|
||||
break;
|
||||
case 2:
|
||||
source = MINING_CODE;
|
||||
break;
|
||||
case 3:
|
||||
source = ELSE_WALLET_CODE;
|
||||
break;
|
||||
case 4:
|
||||
source = AIRDROP_CODE;
|
||||
break;
|
||||
case 5:
|
||||
source = UNKNOWN_CODE;
|
||||
break;
|
||||
case 6:
|
||||
source = FORK_CODE;
|
||||
break;
|
||||
}
|
||||
|
||||
return source;
|
||||
}
|
||||
|
||||
private boolean isFieldCorrectlyFilled(TextInputEditText editText, boolean displayError)
|
||||
{
|
||||
String purchasedPriceText = editText.getText().toString();
|
||||
double purchasedPrice;
|
||||
|
||||
try {
|
||||
purchasedPrice = Double.parseDouble(purchasedPriceText);
|
||||
|
||||
if(purchasedPrice < 0)
|
||||
{
|
||||
if(displayError) editText.setError(getResources().getString(R.string.field_negative));
|
||||
|
||||
return false;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
if(displayError) editText.setError(getResources().getString(R.string.field_nan));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
if(purchasedPriceText.equals(""))
|
||||
{
|
||||
if(displayError) editText.setError(getResources().getString(R.string.field_empty));
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void createDatePicker()
|
||||
@ -114,7 +374,7 @@ public class TransferFragment extends CustomRecordFragment {
|
||||
|
||||
@Override
|
||||
public void onExchangeUpdated() {
|
||||
|
||||
fragmentExchange = exchange;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -7,6 +7,7 @@ import android.database.sqlite.SQLiteDatabase;
|
||||
import android.database.sqlite.SQLiteOpenHelper;
|
||||
import android.util.Log;
|
||||
|
||||
import com.herbron.moodl.Activities.RecordTransactionFragments.TransferFragment;
|
||||
import com.herbron.moodl.DataManagers.CurrencyData.Currency;
|
||||
import com.herbron.moodl.DataManagers.CurrencyData.Transaction;
|
||||
import com.herbron.moodl.DataManagers.ExchangeManager.BinanceManager;
|
||||
@ -18,8 +19,11 @@ import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* Created by Guitoune on 14/01/2018.
|
||||
@ -150,7 +154,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateTransactionWithId(int transactionId, double amount, Date date, double purchasedPrice, double fees, String note, String symbolFrom, String feeCurrency, String exchange, String type, String feeFormat)
|
||||
public void updateTransactionWithId(int transactionId, double amount, Date date, double purchasedPrice, double fees, String note, String symbolFrom, String feeCurrency, String destination, String source, String type, String feeFormat)
|
||||
{
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues cv = new ContentValues();
|
||||
@ -162,7 +166,8 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
cv.put(KEY_TRANSACTION_NOTES, note);
|
||||
cv.put(KEY_TRANSACTION_PAIR, symbolFrom);
|
||||
cv.put(KEY_TRANSACTION_FEE_CURRENCY, feeCurrency);
|
||||
cv.put(KEY_TRANSACTION_SOURCE, exchange);
|
||||
cv.put(KEY_TRANSACTION_SOURCE, source);
|
||||
cv.put(KEY_TRANSACTION_DESTINATION, destination);
|
||||
cv.put(KEY_TRANSACTION_TYPE, type);
|
||||
cv.put(KEY_TRANSACTION_FEE_FORMAT, feeFormat);
|
||||
|
||||
@ -170,7 +175,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
|
||||
}
|
||||
|
||||
public void addTransaction(String symbol, Double amount, Date date, Double purchasePrice, double fees, String note, String symbolFrom, String feeCurrency, String exchange, String type, String feeFormat)
|
||||
public void addTransaction(String symbol, Double amount, Date date, double purchasePrice, double fees, String note, String symbolFrom, String feeCurrency, String destination, String source, String type, String feeFormat)
|
||||
{
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
ContentValues values = new ContentValues();
|
||||
@ -183,11 +188,12 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
values.put(KEY_TRANSACTION_NOTES, note);
|
||||
values.put(KEY_TRANSACTION_PAIR, symbolFrom);
|
||||
values.put(KEY_TRANSACTION_FEE_CURRENCY, feeCurrency);
|
||||
values.put(KEY_TRANSACTION_SOURCE, exchange);
|
||||
values.put(KEY_TRANSACTION_SOURCE, source);
|
||||
values.put(KEY_TRANSACTION_DESTINATION, destination);
|
||||
values.put(KEY_TRANSACTION_TYPE, type);
|
||||
values.put(KEY_TRANSACTION_FEE_FORMAT, feeFormat);
|
||||
|
||||
db.insert(TABLE_MANUAL_TRANSACTIONS, null, values);
|
||||
Log.d("moodl", "Insert result " + db.insert(TABLE_MANUAL_TRANSACTIONS, null, values));
|
||||
db.close();
|
||||
}
|
||||
|
||||
@ -545,7 +551,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
return accountList;
|
||||
}
|
||||
|
||||
public List<Currency> getAllCurrenciesFromManualCurrency()
|
||||
public List<Currency> getAllCurrenciesFromTransactions()
|
||||
{
|
||||
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_TRANSACTIONS;
|
||||
SQLiteDatabase db = this.getWritableDatabase();
|
||||
@ -559,7 +565,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
String feeSym = resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_FEE_CURRENCY));
|
||||
String type = resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_TYPE));
|
||||
|
||||
if(type != null)
|
||||
if(type != null && !type.equals(""))
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
@ -579,7 +585,7 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
if(symbol.equals(feeSym))
|
||||
{
|
||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
||||
, - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
||||
, -resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -588,6 +594,27 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
}
|
||||
break;
|
||||
case "t":
|
||||
if(isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SOURCE))) && isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_DESTINATION))))
|
||||
{
|
||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
||||
, -resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SOURCE))))
|
||||
{
|
||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
||||
, -resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) + resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
||||
}
|
||||
else
|
||||
{
|
||||
if(isBalanceRelated(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_DESTINATION))))
|
||||
{
|
||||
currencyList.add(new Currency(resultatList.getString(resultatList.getColumnIndex(KEY_TRANSACTION_SYMBOL))
|
||||
, resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_AMOUNT)) - resultatList.getDouble(resultatList.getColumnIndex(KEY_TRANSACTION_FEES))));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -613,6 +640,12 @@ public class DatabaseManager extends SQLiteOpenHelper{
|
||||
return currencyList;
|
||||
}
|
||||
|
||||
private boolean isBalanceRelated(String str)
|
||||
{
|
||||
Set<String> set = new HashSet<>(Arrays.asList(TransferFragment.EXCHANGE_CODE, TransferFragment.WALLET_CODE));
|
||||
return set.contains(str);
|
||||
}
|
||||
|
||||
public Transaction getCurrencyTransactionById(int id)
|
||||
{
|
||||
String searchQuerry = "SELECT * FROM " + TABLE_MANUAL_TRANSACTIONS + " WHERE " + KEY_TRANSACTION_ID + "='" + id + "'";
|
||||
|
@ -2,6 +2,7 @@
|
||||
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
android:background="@drawable/record_transaction_layout_background_transfer">
|
||||
|
||||
<LinearLayout
|
||||
@ -14,8 +15,11 @@
|
||||
android:id="@+id/from_transfer_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/spinner_background"
|
||||
android:spinnerMode="dropdown"/>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_amount_transfert"
|
||||
@ -23,7 +27,7 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/amount_editText_transfert"
|
||||
android:id="@+id/amount_editText_transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberDecimal"
|
||||
@ -35,8 +39,10 @@
|
||||
android:id="@+id/to_transfer_spinner"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:minHeight="48dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:layout_marginBottom="8dp"/>
|
||||
android:layout_marginBottom="8dp"
|
||||
android:background="@drawable/spinner_background"/>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_transfertDate"
|
||||
@ -52,19 +58,33 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_fees_transfert"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/fees_editText_transfert"
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_fees_transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberDecimal"
|
||||
android:hint="@string/activity_fees"/>
|
||||
android:layout_weight="0.7">
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/fees_editText_transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:inputType="numberDecimal"
|
||||
android:hint="@string/activity_fees"/>
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<Spinner
|
||||
android:id="@+id/feesFormat_editText_transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.design.widget.TextInputLayout
|
||||
android:id="@+id/input_note_transfert"
|
||||
@ -72,7 +92,7 @@
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.design.widget.TextInputEditText
|
||||
android:id="@+id/note_editText_transfert"
|
||||
android:id="@+id/note_editText_transfer"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/notes"
|
||||
@ -82,15 +102,43 @@
|
||||
|
||||
</android.support.design.widget.TextInputLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/saveTransfertButton"
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/save"
|
||||
android:layout_marginBottom="@dimen/mdtp_minimum_margin_top_bottom"
|
||||
android:layout_gravity="end"
|
||||
style="@style/Widget.AppCompat.Button.Colored"/>
|
||||
android:layout_gravity="end">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/errorLayouts"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal"
|
||||
android:layout_margin="15dp"
|
||||
android:visibility="invisible">
|
||||
|
||||
<ImageView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:srcCompat="@drawable/ic_error_24dp"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/errorTextView"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/error"
|
||||
android:text="@string/error_no_valid_from_to"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
android:id="@+id/saveTransferButton"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:textColor="@color/white"
|
||||
android:text="@string/save"
|
||||
android:layout_marginBottom="@dimen/mdtp_minimum_margin_top_bottom"
|
||||
style="@style/Widget.AppCompat.Button.Colored"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user