diff --git a/app/src/main/java/com/keylesspalace/tusky/FiltersActivity.kt b/app/src/main/java/com/keylesspalace/tusky/FiltersActivity.kt index 202c77805..851455d92 100644 --- a/app/src/main/java/com/keylesspalace/tusky/FiltersActivity.kt +++ b/app/src/main/java/com/keylesspalace/tusky/FiltersActivity.kt @@ -83,8 +83,8 @@ class FiltersActivity: BaseActivity() { } } - private fun createFilter(phrase: String) { - api.createFilter(phrase, listOf(context), false, true, "").enqueue(object: Callback { + private fun createFilter(phrase: String, wholeWord: Boolean) { + api.createFilter(phrase, listOf(context), false, wholeWord, "").enqueue(object: Callback { override fun onResponse(call: Call, response: Response) { 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.wholeWord) + oldFilter.expiresAt, oldFilter.irreversible, dialog.phraseWholeWord.isChecked) 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() { diff --git a/app/src/main/res/layout/dialog_filter.xml b/app/src/main/res/layout/dialog_filter.xml index 9c659cbce..09c6001dc 100644 --- a/app/src/main/res/layout/dialog_filter.xml +++ b/app/src/main/res/layout/dialog_filter.xml @@ -15,4 +15,23 @@ android:hint="@string/filter_add_description" app:layout_constraintTop_toTopOf="parent" /> + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7575ffb44..0f1e3856d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -323,6 +323,8 @@ Edit filter Remove Update + Whole word + When the keyword or phrase is alphanumeric only, it will only be applied if it matches the whole word Phrase to filter Add Account