Added the filter by Equivalent Value range option to the TransactionsFragment' FilterOptioinsDialog, which communicates the user selection back and forth. Also, renamed all string instances of Fiat Equivalent to Equivalent Value in order to use the same convention in all the screens

This commit is contained in:
Severiano Jaramillo 2019-02-07 12:52:37 -06:00
parent d36de0b30a
commit 76fea6cfc1
5 changed files with 85 additions and 88 deletions

View file

@ -38,9 +38,9 @@ class FilterOptionsDialog : DialogFragment() {
const val KEY_FILTER_END_DATE = "key_filter_end_date" const val KEY_FILTER_END_DATE = "key_filter_end_date"
const val KEY_FILTER_ASSET_ALL = "key_filter_asset_all" const val KEY_FILTER_ASSET_ALL = "key_filter_asset_all"
const val KEY_FILTER_ASSET = "key_filter_asset" const val KEY_FILTER_ASSET = "key_filter_asset"
const val KEY_FILTER_FIAT_AMOUNT_ALL = "key_filter_fiat_amount_all" const val KEY_FILTER_EQUIVALENT_VALUE_ALL = "key_filter_equivalent_value_all"
const val KEY_FILTER_FROM_FIAT_AMOUNT = "key_filter_from_fiat_amount" const val KEY_FILTER_FROM_EQUIVALENT_VALUE = "key_filter_from_equivalent_value"
const val KEY_FILTER_TO_FIAT_AMOUNT = "key_filter_to_fiat_amount" const val KEY_FILTER_TO_EQUIVALENT_VALUE = "key_filter_to_equivalent_value"
const val KEY_FILTER_AGORISE_FEES = "key_filter_agorise_fees" const val KEY_FILTER_AGORISE_FEES = "key_filter_agorise_fees"
const val KEY_TIMESTAMP = "key_timestamp" const val KEY_TIMESTAMP = "key_timestamp"
@ -50,8 +50,8 @@ class FilterOptionsDialog : DialogFragment() {
fun newInstance(filterTransactionsDirection: Int, filterDateRangeAll: Boolean, fun newInstance(filterTransactionsDirection: Int, filterDateRangeAll: Boolean,
filterStartDate: Long, filterEndDate: Long, filterAssetAll: Boolean, filterStartDate: Long, filterEndDate: Long, filterAssetAll: Boolean,
filterAsset: String, filterFiatAmountAll: Boolean, filterAsset: String, filterEquivalentValueAll: Boolean, filterFromEquivalentValue: Long,
filterFromFiatAmount: Long, filterToFiatAmount: Long, filterAgoriseFees: Boolean): FilterOptionsDialog { filterToEquivalentValue: Long, filterAgoriseFees: Boolean): FilterOptionsDialog {
val frag = FilterOptionsDialog() val frag = FilterOptionsDialog()
val args = Bundle() val args = Bundle()
args.putInt(KEY_FILTER_TRANSACTION_DIRECTION, filterTransactionsDirection) args.putInt(KEY_FILTER_TRANSACTION_DIRECTION, filterTransactionsDirection)
@ -60,9 +60,9 @@ class FilterOptionsDialog : DialogFragment() {
args.putLong(KEY_FILTER_END_DATE, filterEndDate) args.putLong(KEY_FILTER_END_DATE, filterEndDate)
args.putBoolean(KEY_FILTER_ASSET_ALL, filterAssetAll) args.putBoolean(KEY_FILTER_ASSET_ALL, filterAssetAll)
args.putString(KEY_FILTER_ASSET, filterAsset) args.putString(KEY_FILTER_ASSET, filterAsset)
args.putBoolean(KEY_FILTER_FIAT_AMOUNT_ALL, filterFiatAmountAll) args.putBoolean(KEY_FILTER_EQUIVALENT_VALUE_ALL, filterEquivalentValueAll)
args.putLong(KEY_FILTER_FROM_FIAT_AMOUNT, filterFromFiatAmount) args.putLong(KEY_FILTER_FROM_EQUIVALENT_VALUE, filterFromEquivalentValue)
args.putLong(KEY_FILTER_TO_FIAT_AMOUNT, filterToFiatAmount) args.putLong(KEY_FILTER_TO_EQUIVALENT_VALUE, filterToEquivalentValue)
args.putBoolean(KEY_FILTER_AGORISE_FEES, filterAgoriseFees) args.putBoolean(KEY_FILTER_AGORISE_FEES, filterAgoriseFees)
frag.arguments = args frag.arguments = args
return frag return frag
@ -80,10 +80,10 @@ class FilterOptionsDialog : DialogFragment() {
private lateinit var tvEndDate: TextView private lateinit var tvEndDate: TextView
private lateinit var cbAsset: CheckBox private lateinit var cbAsset: CheckBox
private lateinit var sAsset: Spinner private lateinit var sAsset: Spinner
private lateinit var cbFiatAmount: CheckBox private lateinit var cbEquivalentValue: CheckBox
private lateinit var llFiatAmount: LinearLayout private lateinit var llEquivalentValue: LinearLayout
// lateinit var etFromFiatAmount: CurrencyEditText lateinit var etFromEquivalentValue: EditText
// lateinit var etToFiatAmount: CurrencyEditText lateinit var etToEquivalentValue: EditText
private lateinit var switchAgoriseFees: Switch private lateinit var switchAgoriseFees: Switch
private var mCallback: OnFilterOptionsSelectedListener? = null private var mCallback: OnFilterOptionsSelectedListener? = null
@ -96,11 +96,6 @@ class FilterOptionsDialog : DialogFragment() {
private var startDate: Long = 0 private var startDate: Long = 0
private var endDate: Long = 0 private var endDate: Long = 0
// /**
// * Variable used to keep track of the current user's currency
// */
// private val mUserCurrency = RuntimeData.EXTERNAL_CURRENCY
private var mBalanceDetails = ArrayList<BalanceDetail>() private var mBalanceDetails = ArrayList<BalanceDetail>()
private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel private lateinit var mBalanceDetailViewModel: BalanceDetailViewModel
@ -158,9 +153,9 @@ class FilterOptionsDialog : DialogFragment() {
filterEndDate: Long, filterEndDate: Long,
filterAssetAll: Boolean, filterAssetAll: Boolean,
filterAsset: String, filterAsset: String,
filterFiatAmountAll: Boolean, filterEquivalentValueAll: Boolean,
filterFromFiatAmount: Long, filterFromEquivalentValue: Long,
filterToFiatAmount: Long, filterToEquivalentValue: Long,
filterAgoriseFees: Boolean) filterAgoriseFees: Boolean)
} }
@ -240,24 +235,20 @@ class FilterOptionsDialog : DialogFragment() {
} }
}) })
// Initialize Fiat amount // Initialize Equivalent Value
cbFiatAmount = view.findViewById(R.id.cbFiatAmount) cbEquivalentValue = view.findViewById(R.id.cbEquivalentValue)
// llFiatAmount = view.findViewById(R.id.llFiatAmount) llEquivalentValue = view.findViewById(R.id.llEquivalentValue)
// cbFiatAmount.setOnCheckedChangeListener { _, isChecked -> cbEquivalentValue.setOnCheckedChangeListener { _, isChecked ->
// llFiatAmount.visibility = if(isChecked) View.GONE else View.VISIBLE } llEquivalentValue.visibility = if(isChecked) View.GONE else View.VISIBLE }
cbFiatAmount.isChecked = arguments!!.getBoolean(KEY_FILTER_FIAT_AMOUNT_ALL, true) cbEquivalentValue.isChecked = arguments!!.getBoolean(KEY_FILTER_EQUIVALENT_VALUE_ALL, true)
// val locale = Resources.getSystem().configuration.locale etFromEquivalentValue = view.findViewById(R.id.etFromEquivalentValue)
// val fromEquivalentValue = arguments!!.getLong(KEY_FILTER_FROM_EQUIVALENT_VALUE, 0)
// etFromFiatAmount = view.findViewById(R.id.etFromFiatAmount) etFromEquivalentValue.setText("$fromEquivalentValue", TextView.BufferType.EDITABLE)
// etFromFiatAmount.locale = locale
// val fromFiatAmount = arguments!!.getLong(KEY_FILTER_FROM_FIAT_AMOUNT, 0) etToEquivalentValue = view.findViewById(R.id.etToEquivalentValue)
// etFromFiatAmount.setText("$fromFiatAmount", TextView.BufferType.EDITABLE) val toEquivalentValue = arguments!!.getLong(KEY_FILTER_TO_EQUIVALENT_VALUE, 0)
// etToEquivalentValue.setText("$toEquivalentValue", TextView.BufferType.EDITABLE)
// etToFiatAmount = view.findViewById(R.id.etToFiatAmount)
// etToFiatAmount.locale = locale
// val toFiatAmount = arguments!!.getLong(KEY_FILTER_TO_FIAT_AMOUNT, 0)
// etToFiatAmount.setText("$toFiatAmount", TextView.BufferType.EDITABLE)
// Initialize transaction network fees // Initialize transaction network fees
switchAgoriseFees = view.findViewById(R.id.switchAgoriseFees) switchAgoriseFees = view.findViewById(R.id.switchAgoriseFees)
@ -276,7 +267,7 @@ class FilterOptionsDialog : DialogFragment() {
try { try {
mCallback = fragment as OnFilterOptionsSelectedListener mCallback = fragment as OnFilterOptionsSelectedListener
} catch (e: ClassCastException) { } catch (e: ClassCastException) {
throw ClassCastException(fragment.toString() + " must implement OnFilterOptionsSelectedListener") throw ClassCastException("$fragment must implement OnFilterOptionsSelectedListener")
} }
} }
@ -318,24 +309,21 @@ class FilterOptionsDialog : DialogFragment() {
val filterAsset = (sAsset.selectedItem as BalanceDetail).symbol val filterAsset = (sAsset.selectedItem as BalanceDetail).symbol
val filterFiatAmountAll = cbFiatAmount.isChecked val filterEquivalentValueAll = cbEquivalentValue.isChecked
val filterFromFiatAmount = 0L//(etFromFiatAmount.currencyDouble * val filterFromEquivalentValue = etFromEquivalentValue.text.toString().toLong()
// Math.pow(10.0, mUserCurrency.defaultFractionDigits.toDouble())).toLong()
var filterToFiatAmount = 1L//(etToFiatAmount.currencyDouble * var filterToEquivalentValue = etToEquivalentValue.text.toString().toLong()
// Math.pow(10.0, mUserCurrency.defaultFractionDigits.toDouble())).toLong()
// Make sure ToFiatAmount is at least 50 units bigger than FromFiatAmount // Make sure ToEquivalentValue is at least 50 units bigger than FromEquivalentValue
// if (!filterFiatAmountAll && filterToFiatAmount <= filterFromFiatAmount) { if (!filterEquivalentValueAll && filterToEquivalentValue < filterFromEquivalentValue + 50) {
// filterToFiatAmount = filterFromFiatAmount + 50 * filterToEquivalentValue = filterFromEquivalentValue + 50
// Math.pow(10.0, mUserCurrency.defaultFractionDigits.toDouble()).toLong() }
// }
val filterAgoriseFees = switchAgoriseFees.isChecked val filterAgoriseFees = switchAgoriseFees.isChecked
mCallback!!.onFilterOptionsSelected(filterTransactionsDirection, filterDateRangeAll, mCallback!!.onFilterOptionsSelected(filterTransactionsDirection, filterDateRangeAll,
startDate, endDate, filterAssetAll, filterAsset, filterFiatAmountAll, startDate, endDate, filterAssetAll, filterAsset, filterEquivalentValueAll,
filterFromFiatAmount, filterToFiatAmount, filterAgoriseFees) filterFromEquivalentValue, filterToEquivalentValue, filterAgoriseFees)
} }
} }

View file

@ -51,9 +51,9 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
private var filterEndDate = 0L private var filterEndDate = 0L
private var filterAssetAll = true private var filterAssetAll = true
private var filterAsset = "BTS" private var filterAsset = "BTS"
private var filterFiatAmountAll = true private var filterEquivalentValueAll = true
private var filterFromFiatAmount = 0L private var filterFromEquivalentValue = 0L
private var filterToFiatAmount = 500L private var filterToEquivalentValue = 50L
private var filterAgoriseFees = true private var filterAgoriseFees = true
private var mDisposables = CompositeDisposable() private var mDisposables = CompositeDisposable()
@ -122,7 +122,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
val filterOptionsDialog = FilterOptionsDialog.newInstance( val filterOptionsDialog = FilterOptionsDialog.newInstance(
filterTransactionsDirection, filterDateRangeAll, filterStartDate * 1000, filterTransactionsDirection, filterDateRangeAll, filterStartDate * 1000,
filterEndDate * 1000, filterAssetAll, filterAsset, filterEndDate * 1000, filterAssetAll, filterAsset,
filterFiatAmountAll, filterFromFiatAmount, filterToFiatAmount, filterAgoriseFees filterEquivalentValueAll, filterFromEquivalentValue, filterToEquivalentValue, filterAgoriseFees
) )
filterOptionsDialog.show(childFragmentManager, "filter-options-tag") filterOptionsDialog.show(childFragmentManager, "filter-options-tag")
true true
@ -175,8 +175,8 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
if (!filterAssetAll && transferDetail.assetSymbol != filterAsset) if (!filterAssetAll && transferDetail.assetSymbol != filterAsset)
continue continue
// // Filter by fiat amount // // Filter by equivalent value
// if (!filterFiatAmountAll && (transferDetail.fiatAmount < filterFromFiatAmount || transferDetail.fiatAmount > filterToFiatAmount)) // if (!filterEquivalentValueAll && (transferDetail.fiatAmount < filterFromEquivalentValue || transferDetail.fiatAmount > filterToEquivalentValue))
// continue // continue
// Filter transactions sent to agorise // Filter transactions sent to agorise
@ -207,9 +207,9 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
filterEndDate: Long, filterEndDate: Long,
filterAssetAll: Boolean, filterAssetAll: Boolean,
filterAsset: String, filterAsset: String,
filterFiatAmountAll: Boolean, filterEquivalentValueAll: Boolean,
filterFromFiatAmount: Long, filterFromEquivalentValue: Long,
filterToFiatAmount: Long, filterToEquivalentValue: Long,
filterAgoriseFees: Boolean filterAgoriseFees: Boolean
) { ) {
this.filterTransactionsDirection = filterTransactionsDirection this.filterTransactionsDirection = filterTransactionsDirection
@ -218,9 +218,9 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
this.filterEndDate = filterEndDate / 1000 this.filterEndDate = filterEndDate / 1000
this.filterAssetAll = filterAssetAll this.filterAssetAll = filterAssetAll
this.filterAsset = filterAsset this.filterAsset = filterAsset
this.filterFiatAmountAll = filterFiatAmountAll this.filterEquivalentValueAll = filterEquivalentValueAll
this.filterFromFiatAmount = filterFromFiatAmount this.filterFromEquivalentValue = filterFromEquivalentValue
this.filterToFiatAmount = filterToFiatAmount this.filterToEquivalentValue = filterToEquivalentValue
this.filterAgoriseFees = filterAgoriseFees this.filterAgoriseFees = filterAgoriseFees
applyFilterOptions(true) applyFilterOptions(true)
} }

View file

@ -140,62 +140,71 @@
android:textColor="?android:textColorSecondary" android:textColor="?android:textColorSecondary"
app:layout_constraintTop_toBottomOf="@id/sAsset"/> app:layout_constraintTop_toBottomOf="@id/sAsset"/>
<!-- Fiat Amount --> <!-- Equivalent Value -->
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="@string/text__fiat_amount" android:layout_marginTop="2dp"
android:text="@string/text__equivalent_value"
android:textSize="16sp" android:textSize="16sp"
app:layout_constraintTop_toTopOf="@id/cbFiatAmount" app:layout_constraintTop_toTopOf="@id/cbEquivalentValue"
app:layout_constraintStart_toStartOf="parent"/> app:layout_constraintStart_toStartOf="parent"/>
<CheckBox <CheckBox
android:id="@+id/cbFiatAmount" android:id="@+id/cbEquivalentValue"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_different_topic" android:layout_marginTop="@dimen/spacing_different_topic"
android:text="@string/text__all" android:text="@string/text__all"
android:enabled="false"
app:layout_constraintTop_toBottomOf="@id/switchAgoriseFees" app:layout_constraintTop_toBottomOf="@id/switchAgoriseFees"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintEnd_toEndOf="parent"/>
<LinearLayout <LinearLayout
android:id="@+id/llFiatAmount" android:id="@+id/llEquivalentValue"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="4dp" android:layout_margin="4dp"
android:orientation="horizontal" android:orientation="horizontal"
android:visibility="gone" app:layout_constraintTop_toBottomOf="@id/cbEquivalentValue">
app:layout_constraintTop_toBottomOf="@id/cbFiatAmount">
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="Between"/> android:text="Between"/>
<!--<faranjit.currency.edittext.CurrencyEditText--> <EditText
<!--android:id="@+id/etFromFiatAmount"--> android:id="@+id/etFromEquivalentValue"
<!--android:layout_width="0dp"--> android:layout_width="0dp"
<!--android:layout_height="wrap_content"--> android:layout_height="wrap_content"
<!--android:layout_weight="1"--> android:layout_weight="1"
<!--android:inputType="number"--> android:inputType="number"
<!--android:textAlignment="center"--> android:digits="0123456789"
<!--app:showSymbol="true"/>--> android:singleLine="true"
android:imeOptions="actionNext"
android:textAlignment="center"/>
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:text="and"/> android:text="and"/>
<!--<faranjit.currency.edittext.CurrencyEditText--> <EditText
<!--android:id="@+id/etToFiatAmount"--> android:id="@+id/etToEquivalentValue"
<!--android:layout_width="0dp"--> android:layout_width="0dp"
<!--android:layout_height="wrap_content"--> android:layout_height="wrap_content"
<!--android:layout_weight="1"--> android:layout_weight="1"
<!--android:inputType="number"--> android:inputType="number"
<!--android:textAlignment="center"--> android:digits="0123456789"
<!--app:showSymbol="true"/>--> android:singleLine="true"
android:imeOptions="actionDone"
android:textAlignment="center"/>
<TextView
android:id="@+id/tvEquivalentValueSymbol"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="USD"/>
</LinearLayout> </LinearLayout>

View file

@ -54,7 +54,7 @@
<string name="text__sent">Enviadas</string> <string name="text__sent">Enviadas</string>
<string name="text__received">Recibidas</string> <string name="text__received">Recibidas</string>
<string name="text__date_range">Rango de fechas</string> <string name="text__date_range">Rango de fechas</string>
<string name="text__fiat_amount">Monto fiat</string> <string name="text__equivalent_value">Valor Equivalente</string>
<string name="text__ignore_network_fees">Ignorar cuotas de red</string> <string name="text__ignore_network_fees">Ignorar cuotas de red</string>
<string name="button__filter">Filtrar</string> <string name="button__filter">Filtrar</string>

View file

@ -54,7 +54,7 @@
<string name="text__sent">Sent</string> <string name="text__sent">Sent</string>
<string name="text__received">Received</string> <string name="text__received">Received</string>
<string name="text__date_range">Date Range</string> <string name="text__date_range">Date Range</string>
<string name="text__fiat_amount">Fiat Amount</string> <string name="text__equivalent_value">Equivalent Value</string>
<string name="text__ignore_network_fees">Ignore Network fees</string> <string name="text__ignore_network_fees">Ignore Network fees</string>
<string name="button__filter">Filter</string> <string name="button__filter">Filter</string>