diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt index 71151932..31c3182b 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/activities/MainActivity.kt @@ -61,7 +61,7 @@ class MainActivity : SimpleActivity() { private var showRedoButton = false private var searchIndex = 0 private var searchMatches = emptyList() - private var searchIsActive = false + private var isSearchActive = false override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) @@ -89,7 +89,7 @@ class MainActivity : SimpleActivity() { search_query.onTextChangeListener { query -> currentNotesView()?.let { noteView -> currentTextFragment?.removeTextWatcher() - searchClearSpans(noteView.text) + noteView.text.clearSpans() if (query.isNotBlank() && query.length > 1) { searchMatches = searchMatches(query, noteView.value) @@ -141,7 +141,7 @@ class MainActivity : SimpleActivity() { view_pager.onPageChangeListener { currentTextFragment?.removeTextWatcher() currentNotesView()?.let { noteView -> - searchClearSpans(noteView.text) + noteView.text.clearSpans() } searchHide() @@ -160,15 +160,6 @@ class MainActivity : SimpleActivity() { private val currentTextFragment: TextFragment? get() = mAdapter?.textFragment(view_pager.currentItem) - private fun searchClearSpans(editable: Editable) { - val spans = editable.getSpans(0, editable.length, Any::class.java) - for (span in spans) { - if (span is BackgroundColorSpan) { - editable.removeSpan(span) - } - } - } - private fun selectMatch(noteView: MyEditText) { if (searchMatches.isNotEmpty()) { noteView.requestFocus() @@ -220,7 +211,7 @@ class MainActivity : SimpleActivity() { } private fun searchShow() { - searchIsActive = true + isSearchActive = true search_root.beVisible() showKeyboard(search_query) @@ -236,7 +227,7 @@ class MainActivity : SimpleActivity() { private fun searchHide() { search_query.text?.clear() - searchIsActive = false + isSearchActive = false search_root.beGone() } @@ -356,7 +347,7 @@ class MainActivity : SimpleActivity() { } super.onBackPressed() } - } else if (searchIsActive) { + } else if (isSearchActive) { searchHide() } else { super.onBackPressed() @@ -916,7 +907,7 @@ class MainActivity : SimpleActivity() { } fun currentNoteTextChanged(newText: String, showUndo: Boolean, showRedo: Boolean) { - if (searchIsActive.not()) { + if (isSearchActive.not()) { var shouldRecreateMenu = false if (showUndo != showUndoButton) { showUndoButton = showUndo diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/Context.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/Context.kt index c213f570..ee459e6d 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/Context.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/Context.kt @@ -4,7 +4,6 @@ import android.appwidget.AppWidgetManager import android.content.ComponentName import android.content.Context import android.content.Intent -import androidx.core.content.ContextCompat import com.simplemobiletools.notes.pro.databases.NotesDatabase import com.simplemobiletools.notes.pro.helpers.Config import com.simplemobiletools.notes.pro.helpers.MyWidgetProvider @@ -27,5 +26,3 @@ fun Context.updateWidgets() { } } } - -fun Context.color(id: Int) = ContextCompat.getColor(this, id) diff --git a/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/String.kt b/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/String.kt index 3ce92869..a7be6176 100644 --- a/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/String.kt +++ b/app/src/main/kotlin/com/simplemobiletools/notes/pro/extensions/String.kt @@ -1,12 +1,7 @@ package com.simplemobiletools.notes.pro.extensions -import android.os.Build -import android.text.Html -import androidx.annotation.RequiresApi import com.google.gson.Gson import com.google.gson.reflect.TypeToken -import com.simplemobiletools.commons.helpers.isMarshmallowPlus -import com.simplemobiletools.commons.helpers.isNougatPlus import com.simplemobiletools.notes.pro.models.ChecklistItem fun String.parseChecklistItems(): ArrayList? { @@ -19,12 +14,3 @@ fun String.parseChecklistItems(): ArrayList? { } return null } - -@RequiresApi(Build.VERSION_CODES.N) -fun String.toHtml() = - if (isNougatPlus()) { - Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY) - } else { - Html.fromHtml(this) - } -