allow editing files in the text editor

This commit is contained in:
tibbi 2019-01-29 19:23:29 +01:00
parent 07568ffddf
commit a175922a1d
2 changed files with 13 additions and 5 deletions

View File

@ -51,7 +51,7 @@ android {
}
dependencies {
implementation 'com.simplemobiletools:commons:5.6.18'
implementation 'com.simplemobiletools:commons:5.7.5'
implementation 'com.github.Stericson:RootTools:df729dcb13'
implementation 'com.alexvasilkov:gesture-views:2.5.2'
}

View File

@ -4,7 +4,7 @@ import android.content.Context
import android.util.AttributeSet
import android.util.TypedValue
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatTextView
import androidx.appcompat.widget.AppCompatEditText
import com.alexvasilkov.gestures.GestureController
import com.alexvasilkov.gestures.State
import com.alexvasilkov.gestures.views.interfaces.GestureView
@ -14,14 +14,19 @@ import com.simplemobiletools.filemanager.pro.extensions.config
// taken from
// https://github.com/alexvasilkov/GestureViews/blob/f0a4c266e31dcad23bd0d9013531bc1c501b9c9f/sample/src/main/java/com/alexvasilkov/gestures/sample/ex/custom/text/GestureTextView.java
class GestureTextView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null, defStyle: Int = 0) : AppCompatTextView(context, attrs, defStyle), GestureView {
class GestureTextView : AppCompatEditText, GestureView {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet, defStyle: Int) : super(context, attrs, defStyle)
private val controller: GestureController = GestureController(this)
private var origSize = 0f
private var size = 0f
init {
controller.settings.setOverzoomFactor(1f).isPanEnabled = false
controller.settings.initFromAttributes(context, attrs)
controller.addOnStateChangeListener(object : GestureController.OnStateChangeListener {
override fun onStateChanged(state: State) {
applyState(state)
@ -47,7 +52,10 @@ class GestureTextView @JvmOverloads constructor(context: Context, attrs: Attribu
override fun getController() = controller
override fun onTouchEvent(event: MotionEvent) = controller.onTouch(this, event)
override fun onTouchEvent(event: MotionEvent): Boolean {
controller.onTouch(this, event)
return super.onTouchEvent(event)
}
override fun setTextSize(size: Float) {
super.setTextSize(size)