diff --git a/src/com/money/manager/ex/CheckingAccountActivity.java b/src/com/money/manager/ex/CheckingAccountActivity.java index 373c387fc3..bc6a388c2a 100644 --- a/src/com/money/manager/ex/CheckingAccountActivity.java +++ b/src/com/money/manager/ex/CheckingAccountActivity.java @@ -784,12 +784,10 @@ private void initTransactionTypeSelector() { SpinTransCode.setAdapter(adapterTrans); // select the current value if (mTransactionType != null) { -// if (!TextUtils.isEmpty(getTransactionType())) { if (Arrays.asList(mTransCodeValues).indexOf(getTransactionType()) >= 0) { SpinTransCode.setSelection(Arrays.asList(mTransCodeValues).indexOf(getTransactionType()), true); } } else { -// mTransCode = (String) SpinTransCode.getSelectedItem(); mTransactionType = TransactionTypes.values()[SpinTransCode.getSelectedItemPosition()]; } SpinTransCode.setOnItemSelectedListener(new OnItemSelectedListener() { @@ -805,7 +803,6 @@ public void onItemSelected(AdapterView parent, View view, int position, long return; } -// mTransCode = selectedValue; mTransactionType = TransactionTypes.values()[position]; } // aggiornamento dell'interfaccia grafica @@ -947,7 +944,6 @@ public void onFinishedInputAmountDialog(int id, Double amount) { } } if (txtTotAmount.equals(view)) { -// if (Constants.TRANSACTION_TYPE_TRANSFER.equals(mTransCode)) { if (mTransactionType.equals(TransactionTypes.Transfer)) { accountId = mToAccountId; } else { diff --git a/src/com/money/manager/ex/Constants.java b/src/com/money/manager/ex/Constants.java index 0d25ad7e0e..3dab1b12d5 100644 --- a/src/com/money/manager/ex/Constants.java +++ b/src/com/money/manager/ex/Constants.java @@ -24,11 +24,6 @@ public class Constants { public static final String EMPTY_STRING = ""; // Database public static final String PATTERN_DB_DATE = "yyyy-MM-dd"; - // todo: use TransactionTypes enum instead of these strings! - // Transaction Type - public static final String TRANSACTION_TYPE_WITHDRAWAL = "Withdrawal"; - public static final String TRANSACTION_TYPE_DEPOSIT = "Deposit"; -// public static final String TRANSACTION_TYPE_TRANSFER = "Transfer"; // Transaction Status public static final String TRANSACTION_STATUS_UNRECONCILED = ""; public static final String TRANSACTION_STATUS_RECONCILED = "R"; diff --git a/src/com/money/manager/ex/MainActivity.java b/src/com/money/manager/ex/MainActivity.java index bceb06d212..4f8238657b 100644 --- a/src/com/money/manager/ex/MainActivity.java +++ b/src/com/money/manager/ex/MainActivity.java @@ -63,6 +63,7 @@ import com.money.manager.ex.core.Core; import com.money.manager.ex.core.MoneyManagerBootReceiver; import com.money.manager.ex.core.Passcode; +import com.money.manager.ex.core.TransactionTypes; import com.money.manager.ex.currency.CurrencyFormatsListActivity; import com.money.manager.ex.database.TableAccountList; import com.money.manager.ex.dropbox.DropboxHelper; @@ -958,13 +959,13 @@ public boolean onDrawerMenuAndOptionMenuSelected(DrawerMenuItem item) { return true; } else if (item.getId() == R.id.menu_report_where_money_goes) { intent = new Intent(this, CategoriesReportActivity.class); - intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, Constants.TRANSACTION_TYPE_WITHDRAWAL); + intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, TransactionTypes.Withdrawal.name()); intent.putExtra(CategoriesReportActivity.REPORT_TITLE, getString(R.string.menu_report_where_money_goes)); startActivity(intent); return true; } else if (item.getId() == R.id.menu_report_where_money_comes_from) { intent = new Intent(this, CategoriesReportActivity.class); - intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, Constants.TRANSACTION_TYPE_DEPOSIT); + intent.putExtra(CategoriesReportActivity.REPORT_FILTERS, TransactionTypes.Deposit.name()); intent.putExtra(CategoriesReportActivity.REPORT_TITLE, getString(R.string.menu_report_where_money_comes_from)); startActivity(intent); return true; diff --git a/src/com/money/manager/ex/adapter/AllDataAdapter.java b/src/com/money/manager/ex/adapter/AllDataAdapter.java index 0e78c7a7bb..847a911552 100644 --- a/src/com/money/manager/ex/adapter/AllDataAdapter.java +++ b/src/com/money/manager/ex/adapter/AllDataAdapter.java @@ -145,10 +145,12 @@ public void bindView(View view, Context context, Cursor cursor) { // check amount sign CurrencyUtils currencyUtils = new CurrencyUtils(mContext); holder.txtAmount.setText(currencyUtils.getCurrencyFormatted(getCurrencyId(), amount)); + + String transType = cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE)); // text color amount if (isTransfer) { holder.txtAmount.setTextColor(mContext.getResources().getColor(R.color.material_grey_700)); - } else if (Constants.TRANSACTION_TYPE_DEPOSIT.equalsIgnoreCase(cursor.getString(cursor.getColumnIndex(TRANSACTIONTYPE)))) { + } else if (TransactionTypes.valueOf(transType).equals(TransactionTypes.Deposit)) { holder.txtAmount.setTextColor(mContext.getResources().getColor(R.color.material_green_700)); } else { holder.txtAmount.setTextColor(mContext.getResources().getColor(R.color.material_red_700)); diff --git a/src/com/money/manager/ex/adapter/BalanceAmountTask.java b/src/com/money/manager/ex/adapter/BalanceAmountTask.java index 93829fa880..314f84aeb5 100644 --- a/src/com/money/manager/ex/adapter/BalanceAmountTask.java +++ b/src/com/money/manager/ex/adapter/BalanceAmountTask.java @@ -25,6 +25,7 @@ import android.widget.TextView; import com.money.manager.ex.Constants; +import com.money.manager.ex.core.TransactionTypes; import com.money.manager.ex.database.MoneyManagerOpenHelper; import com.money.manager.ex.database.TableAccountList; import com.money.manager.ex.database.TableCheckingAccount; @@ -59,13 +60,14 @@ protected Boolean doInBackground(Void... params) { if (cursor != null && cursor.moveToFirst()) { while (!cursor.isAfterLast()) { - if (Constants.TRANSACTION_TYPE_WITHDRAWAL.equalsIgnoreCase( - cursor.getString(cursor.getColumnIndex(TableCheckingAccount.TRANSCODE)))) { + String transType = cursor.getString(cursor.getColumnIndex(TableCheckingAccount.TRANSCODE)); + + if (TransactionTypes.valueOf(transType).equals(TransactionTypes.Withdrawal)) { total -= cursor.getDouble(cursor.getColumnIndex(TableCheckingAccount.TRANSAMOUNT)); - } else if (Constants.TRANSACTION_TYPE_DEPOSIT.equalsIgnoreCase( - cursor.getString(cursor.getColumnIndex(TableCheckingAccount.TRANSCODE)))) { + } else if (TransactionTypes.valueOf(transType).equals(TransactionTypes.Deposit)) { total += cursor.getDouble(cursor.getColumnIndex(TableCheckingAccount.TRANSAMOUNT)); } else { + // transfer if (cursor.getInt(cursor.getColumnIndex(TableCheckingAccount.ACCOUNTID)) == getAccountId()) { total -= cursor.getDouble(cursor.getColumnIndex(TableCheckingAccount.TRANSAMOUNT)); } else { diff --git a/src/com/money/manager/ex/businessobjects/qif/QifRecord.java b/src/com/money/manager/ex/businessobjects/qif/QifRecord.java index 1e97ca609a..c61ef3d76c 100644 --- a/src/com/money/manager/ex/businessobjects/qif/QifRecord.java +++ b/src/com/money/manager/ex/businessobjects/qif/QifRecord.java @@ -162,10 +162,10 @@ private String getSplitCategory(TableSplitTransactions split, String transaction // amount double amount = split.getSplitTransAmount(); // handle sign - if (transactionType.equals(Constants.TRANSACTION_TYPE_WITHDRAWAL)) { + if (TransactionTypes.valueOf(transactionType).equals(TransactionTypes.Withdrawal)) { amount = amount * (-1); } - if (transactionType.equals(Constants.TRANSACTION_TYPE_DEPOSIT)) { + if (TransactionTypes.valueOf(transactionType).equals(TransactionTypes.Deposit)) { // leave positive? } builder.append("$"); diff --git a/src/com/money/manager/ex/reports/CategoriesReportActivity.java b/src/com/money/manager/ex/reports/CategoriesReportActivity.java index 78752c911f..02408ef0dc 100644 --- a/src/com/money/manager/ex/reports/CategoriesReportActivity.java +++ b/src/com/money/manager/ex/reports/CategoriesReportActivity.java @@ -43,6 +43,7 @@ import com.money.manager.ex.Constants; import com.money.manager.ex.R; import com.money.manager.ex.core.Core; +import com.money.manager.ex.core.TransactionTypes; import com.money.manager.ex.database.ViewMobileData; import com.money.manager.ex.fragment.BaseFragmentActivity; import com.money.manager.ex.fragment.IncomeVsExpensesChartFragment; @@ -277,7 +278,8 @@ protected String prepareQuery(String whereClause) { String groupBy = ViewMobileData.CategID + ", " + ViewMobileData.Category + ", " + ViewMobileData.SubcategID + ", " + ViewMobileData.Subcategory; String having = null; if (!TextUtils.isEmpty(((CategoriesReportActivity) getActivity()).mFilter)) { - if (Constants.TRANSACTION_TYPE_WITHDRAWAL.equalsIgnoreCase(((CategoriesReportActivity) getActivity()).mFilter)) { + String filter = ((CategoriesReportActivity) getActivity()).mFilter; + if (TransactionTypes.valueOf(filter).equals(TransactionTypes.Withdrawal)) { having = "SUM(" + ViewMobileData.AmountBaseConvRate + ") < 0"; } else { having = "SUM(" + ViewMobileData.AmountBaseConvRate + ") > 0";