@ -83,8 +83,8 @@ class FiltersActivity: BaseActivity() {
}
}
private fun createFilter ( phrase : String ) {
api . createFilter ( phrase , listOf ( context ) , false , true , " " ) . enqueue ( object : Callback < Filter > {
private fun createFilter ( phrase : String , wholeWord : Boolean ) {
api . createFilter ( phrase , listOf ( context ) , false , wholeWord , " " ) . enqueue ( object : Callback < Filter > {
override fun onResponse ( call : Call < Filter > , response : Response < Filter > ) {
filters . add ( response . body ( ) !! )
refreshFilterDisplay ( )
@ -102,11 +102,12 @@ class FiltersActivity: BaseActivity() {
. setTitle ( R . string . filter _addition _dialog _title )
. setView ( R . layout . dialog _filter )
. setPositiveButton ( android . R . string . ok ) { _ , _ ->
createFilter ( dialog . phraseEditText . text . toString ( ) )
createFilter ( dialog . phraseEditText . text . toString ( ) , dialog . phraseWholeWord . isChecked )
}
. setNeutralButton ( android . R . string . cancel , null )
. create ( )
dialog . show ( )
dialog . phraseWholeWord . isChecked = true
}
private fun setupEditDialogForItem ( itemIndex : Int ) {
@ -116,7 +117,7 @@ class FiltersActivity: BaseActivity() {
. setPositiveButton ( R . string . filter _dialog _update _button ) { _ , _ ->
val oldFilter = filters [ itemIndex ]
val newFilter = Filter ( oldFilter . id , dialog . phraseEditText . text . toString ( ) , oldFilter . context ,
oldFilter . expiresAt , oldFilter . irreversible , oldFilter . wholeWor d)
oldFilter . expiresAt , oldFilter . irreversible , dialog . phraseWholeWord . isChecke d)
updateFilter ( newFilter , itemIndex )
}
. setNegativeButton ( R . string . filter _dialog _remove _button ) { _ , _ ->
@ -127,7 +128,9 @@ class FiltersActivity: BaseActivity() {
dialog . show ( )
// Need to show the dialog before referencing any elements from its view
dialog . phraseEditText . setText ( filters [ itemIndex ] . phrase )
val filter = filters [ itemIndex ]
dialog . phraseEditText . setText ( filter . phrase )
dialog . phraseWholeWord . isChecked = filter . wholeWord
}
private fun refreshFilterDisplay ( ) {