mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-23 20:10:07 +01:00
fixes
This commit is contained in:
parent
8b20ccde0b
commit
6793be0039
@ -15,6 +15,7 @@ import android.view.Gravity
|
|||||||
import android.view.Menu
|
import android.view.Menu
|
||||||
import android.view.MenuItem
|
import android.view.MenuItem
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
|
import androidx.core.graphics.ColorUtils
|
||||||
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
import com.simplemobiletools.commons.dialogs.ConfirmationAdvancedDialog
|
||||||
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
import com.simplemobiletools.commons.dialogs.FilePickerDialog
|
||||||
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
import com.simplemobiletools.commons.dialogs.RadioGroupDialog
|
||||||
@ -95,6 +96,15 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
currentTextFragment?.setTextWatcher()
|
currentTextFragment?.setTextWatcher()
|
||||||
|
|
||||||
|
if (searchMatches.isNotEmpty()) {
|
||||||
|
noteView.requestFocus()
|
||||||
|
noteView.setSelection(searchMatches.getOrNull(searchIndex) ?: 0)
|
||||||
|
}
|
||||||
|
|
||||||
|
search_query.postDelayed({
|
||||||
|
search_query.requestFocus()
|
||||||
|
}, 50)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -115,8 +125,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
currentNotesView()?.let { noteView ->
|
currentNotesView()?.let { noteView ->
|
||||||
if (searchIndex < searchMatches.lastIndex) {
|
if (searchIndex < searchMatches.lastIndex) {
|
||||||
searchIndex++
|
searchIndex++
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
searchIndex = 0
|
searchIndex = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -125,10 +134,8 @@ class MainActivity : SimpleActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
search_clear.setOnClickListener {
|
search_clear.setOnClickListener {
|
||||||
if (search_query.value.isNotBlank())
|
search_query.text?.clear()
|
||||||
search_query.text?.clear()
|
searchHide()
|
||||||
else
|
|
||||||
searchHide()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
view_pager.onPageChangeListener {
|
view_pager.onPageChangeListener {
|
||||||
@ -171,10 +178,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
while (offset < content.length && indexOf != -1) {
|
while (offset < content.length && indexOf != -1) {
|
||||||
indexOf = content.indexOf(textToHighlight, offset, ignoreCase = true)
|
indexOf = content.indexOf(textToHighlight, offset, ignoreCase = true)
|
||||||
|
|
||||||
if (indexOf == -1)
|
if (indexOf == -1) {
|
||||||
break
|
break
|
||||||
else
|
} else {
|
||||||
indexes.add(indexOf)
|
indexes.add(indexOf)
|
||||||
|
}
|
||||||
|
|
||||||
offset = indexOf + 1
|
offset = indexOf + 1
|
||||||
}
|
}
|
||||||
@ -191,9 +199,10 @@ class MainActivity : SimpleActivity() {
|
|||||||
while (offset < content.length && indexOf != -1) {
|
while (offset < content.length && indexOf != -1) {
|
||||||
indexOf = content.indexOf(textToHighlight, offset, true)
|
indexOf = content.indexOf(textToHighlight, offset, true)
|
||||||
|
|
||||||
if (indexOf == -1) break
|
if (indexOf == -1) {
|
||||||
else {
|
break
|
||||||
wordToSpan.setSpan(BackgroundColorSpan(color(R.color.color_accent)), indexOf, indexOf + textToHighlight.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
} else {
|
||||||
|
wordToSpan.setSpan(BackgroundColorSpan(ColorUtils.setAlphaComponent(config.primaryColor, 90)), indexOf, indexOf + textToHighlight.length, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE)
|
||||||
view.setText(wordToSpan, TextView.BufferType.SPANNABLE)
|
view.setText(wordToSpan, TextView.BufferType.SPANNABLE)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -235,6 +244,11 @@ class MainActivity : SimpleActivity() {
|
|||||||
setTextColor(config.textColor)
|
setTextColor(config.textColor)
|
||||||
}
|
}
|
||||||
updateTextColors(view_pager)
|
updateTextColors(view_pager)
|
||||||
|
|
||||||
|
search_root.setBackgroundColor(config.primaryColor)
|
||||||
|
search_previous.applyColorFilter(config.primaryColor.getContrastColor())
|
||||||
|
search_next.applyColorFilter(config.primaryColor.getContrastColor())
|
||||||
|
search_clear.applyColorFilter(config.primaryColor.getContrastColor())
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onPause() {
|
override fun onPause() {
|
||||||
@ -267,7 +281,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
findItem(R.id.open_note).isVisible = shouldBeVisible
|
findItem(R.id.open_note).isVisible = shouldBeVisible
|
||||||
findItem(R.id.delete_note).isVisible = shouldBeVisible
|
findItem(R.id.delete_note).isVisible = shouldBeVisible
|
||||||
findItem(R.id.export_all_notes).isVisible = shouldBeVisible
|
findItem(R.id.export_all_notes).isVisible = shouldBeVisible
|
||||||
findItem(R.id.open_search).isVisible = view_pager.currentItem != 0
|
findItem(R.id.open_search).isVisible = currentItemIsCheckList.not()
|
||||||
|
|
||||||
saveNoteButton = findItem(R.id.save_note)
|
saveNoteButton = findItem(R.id.save_note)
|
||||||
saveNoteButton!!.isVisible = !config.autosaveNotes && showSaveButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
saveNoteButton!!.isVisible = !config.autosaveNotes && showSaveButton && mCurrentNote.type == NoteType.TYPE_TEXT.value
|
||||||
@ -342,6 +356,7 @@ class MainActivity : SimpleActivity() {
|
|||||||
view_pager.currentItem = getWantedNoteIndex(wantedNoteId)
|
view_pager.currentItem = getWantedNoteIndex(wantedNoteId)
|
||||||
checkIntents(intent)
|
checkIntents(intent)
|
||||||
}
|
}
|
||||||
|
private val currentItemIsCheckList get() = mAdapter?.isChecklistFragment(view_pager.currentItem) ?: false
|
||||||
|
|
||||||
private fun checkIntents(intent: Intent) {
|
private fun checkIntents(intent: Intent) {
|
||||||
intent.apply {
|
intent.apply {
|
||||||
|
@ -45,6 +45,8 @@ class NotesPagerAdapter(fm: FragmentManager, val notes: List<Note>, val activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isChecklistFragment(position: Int): Boolean = (fragments[position] is ChecklistFragment)
|
||||||
|
|
||||||
fun textFragment(position: Int): TextFragment? = (fragments[position] as? TextFragment)
|
fun textFragment(position: Int): TextFragment? = (fragments[position] as? TextFragment)
|
||||||
|
|
||||||
fun getCurrentNotesView(position: Int) = (fragments[position] as? TextFragment)?.getNotesView()
|
fun getCurrentNotesView(position: Int) = (fragments[position] as? TextFragment)?.getNotesView()
|
||||||
|
@ -21,5 +21,9 @@ fun String.parseChecklistItems(): ArrayList<ChecklistItem>? {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@RequiresApi(Build.VERSION_CODES.N)
|
@RequiresApi(Build.VERSION_CODES.N)
|
||||||
fun String.toHtml() = if (isNougatPlus()) Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY) else Html.fromHtml(this)
|
fun String.toHtml() =
|
||||||
|
if (isNougatPlus())
|
||||||
|
Html.fromHtml(this, Html.FROM_HTML_MODE_LEGACY)
|
||||||
|
else
|
||||||
|
Html.fromHtml(this)
|
||||||
|
|
||||||
|
@ -1,53 +1,68 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:id="@+id/search_root"
|
android:id="@+id/search_root"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="@color/color_primary"
|
android:background="@color/color_primary"
|
||||||
android:gravity="center_vertical"
|
android:gravity="center_vertical"
|
||||||
android:orientation="horizontal"
|
android:orientation="vertical"
|
||||||
android:paddingTop="@dimen/small_margin"
|
|
||||||
android:paddingBottom="@dimen/small_margin"
|
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible">
|
tools:visibility="visible">
|
||||||
|
|
||||||
<com.simplemobiletools.commons.views.MyEditText
|
<LinearLayout
|
||||||
android:id="@+id/search_query"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="@dimen/normal_margin"
|
android:orientation="horizontal"
|
||||||
android:layout_marginEnd="@dimen/normal_margin"
|
android:paddingTop="@dimen/medium_margin"
|
||||||
android:layout_weight="1"
|
android:paddingBottom="@dimen/medium_margin">
|
||||||
android:maxLength="50"
|
|
||||||
android:maxLines="1"
|
|
||||||
android:singleLine="true"
|
|
||||||
android:textCursorDrawable="@null" />
|
|
||||||
|
|
||||||
<ImageView
|
<com.simplemobiletools.commons.views.MyEditText
|
||||||
android:id="@+id/search_previous"
|
android:id="@+id/search_query"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="0dp"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/smaller_margin"
|
android:layout_marginStart="@dimen/normal_margin"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:layout_marginEnd="@dimen/normal_margin"
|
||||||
android:padding="@dimen/small_margin"
|
android:layout_weight="1"
|
||||||
android:src="@drawable/ic_chevron_left_vector" />
|
android:background="@null"
|
||||||
|
android:hint="@string/search"
|
||||||
|
android:maxLength="50"
|
||||||
|
android:maxLines="1"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:textCursorDrawable="@null" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/search_next"
|
android:id="@+id/search_previous"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/smaller_margin"
|
android:layout_marginEnd="@dimen/smaller_margin"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/small_margin"
|
android:padding="@dimen/small_margin"
|
||||||
android:src="@drawable/ic_chevron_right_vector" />
|
android:src="@drawable/ic_chevron_left_vector" />
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/search_clear"
|
android:id="@+id/search_next"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginEnd="@dimen/medium_margin"
|
android:layout_marginEnd="@dimen/smaller_margin"
|
||||||
android:background="?selectableItemBackgroundBorderless"
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
android:padding="@dimen/small_margin"
|
android:padding="@dimen/small_margin"
|
||||||
android:src="@drawable/ic_cross_vector" />
|
android:src="@drawable/ic_chevron_right_vector" />
|
||||||
</LinearLayout>
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/search_clear"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/medium_margin"
|
||||||
|
android:background="?selectableItemBackgroundBorderless"
|
||||||
|
android:padding="@dimen/small_margin"
|
||||||
|
android:src="@drawable/ic_cross_vector" />
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<View
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="1dp"
|
||||||
|
android:layout_gravity="bottom"
|
||||||
|
android:alpha="0.1"
|
||||||
|
android:background="#fff" />
|
||||||
|
</FrameLayout>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user