removing some unused functions

This commit is contained in:
tibbi 2020-03-29 16:04:18 +02:00
parent 2255027792
commit 9003e55709
3 changed files with 7 additions and 33 deletions

View File

@ -61,7 +61,7 @@ class MainActivity : SimpleActivity() {
private var showRedoButton = false
private var searchIndex = 0
private var searchMatches = emptyList<Int>()
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

View File

@ -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)

View File

@ -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<ChecklistItem>? {
@ -19,12 +14,3 @@ fun String.parseChecklistItems(): ArrayList<ChecklistItem>? {
}
return null
}
@RequiresApi(Build.VERSION_CODES.N)
fun String.toHtml() =
if (isNougatPlus()) {
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
} else {
Html.fromHtml(this)
}