Add a switch to the bottom of the Transactions' FilterOptionsDialog which will be used to hide/show the network fees sent to Agorise. Also added the communication back and forth from the Transactions to the Dialog to keep updated the user selection of the switch.

This commit is contained in:
Severiano Jaramillo 2019-01-15 21:23:54 -06:00
parent 6d4b229e7e
commit 027f690480
4 changed files with 49 additions and 24 deletions

View file

@ -38,8 +38,9 @@ class FilterOptionsDialog : DialogFragment() {
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_FIAT_AMOUNT_ALL = "key_filter_fiat_amount_all"
const val KEY_FILTER_FROM_FIAT_AMOUNT = "filter_from_fiat_amount" const val KEY_FILTER_FROM_FIAT_AMOUNT = "key_filter_from_fiat_amount"
const val KEY_FILTER_TO_FIAT_AMOUNT = "filter_to_fiat_amount" const val KEY_FILTER_TO_FIAT_AMOUNT = "key_filter_to_fiat_amount"
const val KEY_FILTER_AGORISE_FEES = "key_filter_agorise_fees"
const val KEY_TIMESTAMP = "key_timestamp" const val KEY_TIMESTAMP = "key_timestamp"
@ -49,7 +50,7 @@ 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, filterFiatAmountAll: Boolean,
filterFromFiatAmount: Long, filterToFiatAmount: Long): FilterOptionsDialog { filterFromFiatAmount: Long, filterToFiatAmount: 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)
@ -61,6 +62,7 @@ class FilterOptionsDialog : DialogFragment() {
args.putBoolean(KEY_FILTER_FIAT_AMOUNT_ALL, filterFiatAmountAll) args.putBoolean(KEY_FILTER_FIAT_AMOUNT_ALL, filterFiatAmountAll)
args.putLong(KEY_FILTER_FROM_FIAT_AMOUNT, filterFromFiatAmount) args.putLong(KEY_FILTER_FROM_FIAT_AMOUNT, filterFromFiatAmount)
args.putLong(KEY_FILTER_TO_FIAT_AMOUNT, filterToFiatAmount) args.putLong(KEY_FILTER_TO_FIAT_AMOUNT, filterToFiatAmount)
args.putBoolean(KEY_FILTER_AGORISE_FEES, filterAgoriseFees)
frag.arguments = args frag.arguments = args
return frag return frag
} }
@ -81,6 +83,7 @@ class FilterOptionsDialog : DialogFragment() {
private lateinit var llFiatAmount: LinearLayout private lateinit var llFiatAmount: LinearLayout
// lateinit var etFromFiatAmount: CurrencyEditText // lateinit var etFromFiatAmount: CurrencyEditText
// lateinit var etToFiatAmount: CurrencyEditText // lateinit var etToFiatAmount: CurrencyEditText
private lateinit var switchAgoriseFees: Switch
private var mCallback: OnFilterOptionsSelectedListener? = null private var mCallback: OnFilterOptionsSelectedListener? = null
@ -154,7 +157,8 @@ class FilterOptionsDialog : DialogFragment() {
filterAsset: String, filterAsset: String,
filterFiatAmountAll: Boolean, filterFiatAmountAll: Boolean,
filterFromFiatAmount: Long, filterFromFiatAmount: Long,
filterToFiatAmount: Long) filterToFiatAmount: Long,
filterAgoriseFees: Boolean)
} }
@ -247,6 +251,10 @@ class FilterOptionsDialog : DialogFragment() {
// val toFiatAmount = arguments!!.getLong(KEY_FILTER_TO_FIAT_AMOUNT, 0) // val toFiatAmount = arguments!!.getLong(KEY_FILTER_TO_FIAT_AMOUNT, 0)
// etToFiatAmount.setText("$toFiatAmount", TextView.BufferType.EDITABLE) // etToFiatAmount.setText("$toFiatAmount", TextView.BufferType.EDITABLE)
// Initialize transaction network fees
switchAgoriseFees = view.findViewById(R.id.switchAgoriseFees)
switchAgoriseFees.isChecked = arguments!!.getBoolean(KEY_FILTER_AGORISE_FEES, true)
builder.setView(view) builder.setView(view)
return builder.create() return builder.create()
@ -316,8 +324,10 @@ class FilterOptionsDialog : DialogFragment() {
// Math.pow(10.0, mUserCurrency.defaultFractionDigits.toDouble()).toLong() // Math.pow(10.0, mUserCurrency.defaultFractionDigits.toDouble()).toLong()
// } // }
val filterAgoriseFees = switchAgoriseFees.isChecked
mCallback!!.onFilterOptionsSelected(filterTransactionsDirection, filterDateRangeAll, mCallback!!.onFilterOptionsSelected(filterTransactionsDirection, filterDateRangeAll,
startDate, endDate, filterAssetAll, filterAsset, filterFiatAmountAll, startDate, endDate, filterAssetAll, filterAsset, filterFiatAmountAll,
filterFromFiatAmount, filterToFiatAmount) filterFromFiatAmount, filterToFiatAmount, filterAgoriseFees)
} }
} }

View file

@ -44,6 +44,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
private var filterFiatAmountAll = true private var filterFiatAmountAll = true
private var filterFromFiatAmount = 0L private var filterFromFiatAmount = 0L
private var filterToFiatAmount = 500L private var filterToFiatAmount = 500L
private var filterAgoriseFees = true
private var mDisposables = CompositeDisposable() private var mDisposables = CompositeDisposable()
@ -111,7 +112,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 filterFiatAmountAll, filterFromFiatAmount, filterToFiatAmount, filterAgoriseFees
) )
filterOptionsDialog.show(childFragmentManager, "filter-options-tag") filterOptionsDialog.show(childFragmentManager, "filter-options-tag")
true true
@ -194,7 +195,8 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
filterAsset: String, filterAsset: String,
filterFiatAmountAll: Boolean, filterFiatAmountAll: Boolean,
filterFromFiatAmount: Long, filterFromFiatAmount: Long,
filterToFiatAmount: Long filterToFiatAmount: Long,
filterAgoriseFees: Boolean
) { ) {
this.filterTransactionsDirection = filterTransactionsDirection this.filterTransactionsDirection = filterTransactionsDirection
this.filterDateRangeAll = filterDateRangeAll this.filterDateRangeAll = filterDateRangeAll
@ -205,6 +207,7 @@ class TransactionsFragment : Fragment(), FilterOptionsDialog.OnFilterOptionsSele
this.filterFiatAmountAll = filterFiatAmountAll this.filterFiatAmountAll = filterFiatAmountAll
this.filterFromFiatAmount = filterFromFiatAmount this.filterFromFiatAmount = filterFromFiatAmount
this.filterToFiatAmount = filterToFiatAmount this.filterToFiatAmount = filterToFiatAmount
this.filterAgoriseFees = filterAgoriseFees
applyFilterOptions(true) applyFilterOptions(true)
} }

View file

@ -148,18 +148,19 @@
app:layout_constraintTop_toBottomOf="@id/sAsset" app:layout_constraintTop_toBottomOf="@id/sAsset"
app:layout_constraintEnd_toEndOf="parent"/> app:layout_constraintEnd_toEndOf="parent"/>
<!--<LinearLayout--> <LinearLayout
<!--android:id="@+id/llFiatAmount"--> android:id="@+id/llFiatAmount"
<!--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"
<!--app:layout_constraintTop_toBottomOf="@id/cbFiatAmount">--> android:visibility="gone"
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="@string/between"/>--> android:text="Between"/>
<!--<faranjit.currency.edittext.CurrencyEditText--> <!--<faranjit.currency.edittext.CurrencyEditText-->
<!--android:id="@+id/etFromFiatAmount"--> <!--android:id="@+id/etFromFiatAmount"-->
@ -170,10 +171,10 @@
<!--android:textAlignment="center"--> <!--android:textAlignment="center"-->
<!--app:showSymbol="true"/>--> <!--app:showSymbol="true"/>-->
<!--<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/and"/>--> android:text="and"/>
<!--<faranjit.currency.edittext.CurrencyEditText--> <!--<faranjit.currency.edittext.CurrencyEditText-->
<!--android:id="@+id/etToFiatAmount"--> <!--android:id="@+id/etToFiatAmount"-->
@ -184,6 +185,16 @@
<!--android:textAlignment="center"--> <!--android:textAlignment="center"-->
<!--app:showSymbol="true"/>--> <!--app:showSymbol="true"/>-->
<!--</LinearLayout>--> </LinearLayout>
<Switch
android:id="@+id/switchAgoriseFees"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/spacing_different_topic"
android:switchPadding="12dp"
android:text="@string/msg__ignore_transaction_fees"
android:textSize="16sp"
app:layout_constraintTop_toBottomOf="@id/llFiatAmount"/>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

View file

@ -58,6 +58,7 @@
<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__fiat_amount">Fiat Amount</string>
<string name="msg__ignore_transaction_fees">Ignore transaction network fees</string>
<string name="button__filter">Filter</string> <string name="button__filter">Filter</string>
<!-- Send Transaction --> <!-- Send Transaction -->
@ -110,6 +111,7 @@
<string name="title__general">General</string> <string name="title__general">General</string>
<string name="msg__close_timer">Automatically close BiTSy after 3 minutes of inactivity</string> <string name="msg__close_timer">Automatically close BiTSy after 3 minutes of inactivity</string>
<string name="msg__night_mode">Night mode</string> <string name="msg__night_mode">Night mode</string>
<string name="text__view_network_status">View Network Status</string>
<string name="title__backup">Backup</string> <string name="title__backup">Backup</string>
<string name="msg__brainkey_description">BrainKey. Account recovery words that can be captured or copied, but not <string name="msg__brainkey_description">BrainKey. Account recovery words that can be captured or copied, but not
edited. edited.
@ -124,6 +126,5 @@
https://github.com/Agorise https://github.com/Agorise
</string> </string>
<string name="title__bitshares_nodes_dialog">Block: %1$s</string> <string name="title__bitshares_nodes_dialog">Block: %1$s</string>
<string name="text__view_network_status">View Network Status</string>
</resources> </resources>