mirror of
https://github.com/SimpleMobileTools/Simple-Notes.git
synced 2025-03-21 02:50:07 +01:00
make swiping between notes easier
This commit is contained in:
parent
b101a17e31
commit
bb0e66b4d0
@ -1,5 +1,6 @@
|
|||||||
package com.simplemobiletools.notes.pro.fragments
|
package com.simplemobiletools.notes.pro.fragments
|
||||||
|
|
||||||
|
import android.annotation.SuppressLint
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Typeface
|
import android.graphics.Typeface
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
@ -10,6 +11,7 @@ import android.text.style.UnderlineSpan
|
|||||||
import android.text.util.Linkify
|
import android.text.util.Linkify
|
||||||
import android.util.TypedValue
|
import android.util.TypedValue
|
||||||
import android.view.LayoutInflater
|
import android.view.LayoutInflater
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.view.inputmethod.EditorInfo
|
import android.view.inputmethod.EditorInfo
|
||||||
@ -37,12 +39,15 @@ class TextFragment : NoteFragment() {
|
|||||||
private var isUndoOrRedo = false
|
private var isUndoOrRedo = false
|
||||||
private var skipTextUpdating = false
|
private var skipTextUpdating = false
|
||||||
private var noteId = 0L
|
private var noteId = 0L
|
||||||
|
private var touchDownX = 0f
|
||||||
|
private var moveXThreshold = 0 // make sure swiping across notes works well, do not swallow the gestures
|
||||||
|
|
||||||
lateinit var view: ViewGroup
|
lateinit var view: ViewGroup
|
||||||
|
|
||||||
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View {
|
||||||
view = inflater.inflate(R.layout.fragment_text, container, false) as ViewGroup
|
view = inflater.inflate(R.layout.fragment_text, container, false) as ViewGroup
|
||||||
noteId = requireArguments().getLong(NOTE_ID, 0L)
|
noteId = requireArguments().getLong(NOTE_ID, 0L)
|
||||||
|
moveXThreshold = resources.getDimension(R.dimen.activity_margin).toInt()
|
||||||
retainInstance = true
|
retainInstance = true
|
||||||
|
|
||||||
val layoutToInflate = if (config!!.enableLineWrap) R.layout.note_view_static else R.layout.note_view_horiz_scrollable
|
val layoutToInflate = if (config!!.enableLineWrap) R.layout.note_view_static else R.layout.note_view_horiz_scrollable
|
||||||
@ -112,6 +117,7 @@ class TextFragment : NoteFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressLint("ClickableViewAccessibility")
|
||||||
private fun setupFragment() {
|
private fun setupFragment() {
|
||||||
val config = config ?: return
|
val config = config ?: return
|
||||||
view.text_note_view.apply {
|
view.text_note_view.apply {
|
||||||
@ -156,8 +162,21 @@ class TextFragment : NoteFragment() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
view.text_note_view.setOnTouchListener { v, event ->
|
||||||
|
when (event.action) {
|
||||||
|
MotionEvent.ACTION_DOWN -> touchDownX = event.x
|
||||||
|
MotionEvent.ACTION_MOVE -> {
|
||||||
|
val diffX = Math.abs(event.x - touchDownX)
|
||||||
|
if (diffX > moveXThreshold) {
|
||||||
|
view.requestDisallowInterceptTouchEvent(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
if (config.showWordCount) {
|
if (config.showWordCount) {
|
||||||
view.notes_counter.setTextColor(context!!.getProperTextColor())
|
view.notes_counter.setTextColor(requireContext().getProperTextColor())
|
||||||
setWordCounter(view.text_note_view.text.toString())
|
setWordCounter(view.text_note_view.text.toString())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user