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