From f431d67a1041c5fad57b2394940315fb9b82c84f Mon Sep 17 00:00:00 2001 From: Mariotaku Lee Date: Wed, 17 May 2017 14:57:52 +0800 Subject: [PATCH] fixed status TextView URL line break --- .../mariotaku/twidere/view/ComposeEditText.kt | 4 +- .../twidere/view/TimelineContentTextView.kt | 38 +++---------------- 2 files changed, 7 insertions(+), 35 deletions(-) diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/ComposeEditText.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/ComposeEditText.kt index 102fc73fd..c97f2ad0d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/ComposeEditText.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/ComposeEditText.kt @@ -26,7 +26,7 @@ import android.support.v13.view.inputmethod.InputContentInfoCompat import android.support.v4.os.BuildCompat import android.text.InputType import android.text.Selection -import android.text.method.ArrowKeyMovementMethod +import android.text.method.BaseMovementMethod import android.text.method.MovementMethod import android.util.AttributeSet import android.view.inputmethod.EditorInfo @@ -65,7 +65,7 @@ class ComposeEditText( } override fun getDefaultMovementMethod(): MovementMethod { - return ArrowKeyMovementMethod.getInstance() + return BaseMovementMethod() } override fun onAttachedToWindow() { diff --git a/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt b/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt index 7d3b0060d..01cb6384d 100644 --- a/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt +++ b/twidere/src/main/kotlin/org/mariotaku/twidere/view/TimelineContentTextView.kt @@ -21,10 +21,10 @@ package org.mariotaku.twidere.view import android.content.Context import android.text.Spannable +import android.text.method.BaseMovementMethod import android.text.method.MovementMethod import android.text.style.ClickableSpan import android.util.AttributeSet -import android.view.KeyEvent import android.view.MotionEvent import android.widget.TextView import org.mariotaku.chameleon.view.ChameleonTextView @@ -34,11 +34,10 @@ import org.mariotaku.twidere.extension.setupEmojiFactory * Returns true when not clicking links * Created by mariotaku on 15/11/20. */ -class TimelineContentTextView @JvmOverloads constructor( +class TimelineContentTextView( context: Context, - attrs: AttributeSet? = null, - defStyle: Int = 0 -) : ChameleonTextView(context, attrs, defStyle) { + attrs: AttributeSet? = null +) : ChameleonTextView(context, attrs) { init { setupEmojiFactory() @@ -85,33 +84,13 @@ class TimelineContentTextView @JvmOverloads constructor( } } - internal class InternalMovementMethod : MovementMethod { + internal class InternalMovementMethod : BaseMovementMethod() { private var targetSpan: ClickableSpan? = null override fun initialize(widget: TextView, text: Spannable) { } - override fun onKeyDown(widget: TextView, text: Spannable, keyCode: Int, keyEvent: KeyEvent): Boolean { - return false - } - - override fun onKeyUp(widget: TextView, text: Spannable, keyCode: Int, keyEvent: KeyEvent): Boolean { - return false - } - - override fun onKeyOther(widget: TextView, text: Spannable, keyEvent: KeyEvent): Boolean { - return false - } - - override fun onTakeFocus(widget: TextView, text: Spannable, direction: Int) { - - } - - override fun onTrackballEvent(widget: TextView, text: Spannable, event: MotionEvent): Boolean { - return false - } - override fun onTouchEvent(widget: TextView, text: Spannable, event: MotionEvent): Boolean { when (event.actionMasked) { MotionEvent.ACTION_DOWN -> { @@ -139,12 +118,5 @@ class TimelineContentTextView @JvmOverloads constructor( return targetSpan != null } - override fun onGenericMotionEvent(widget: TextView, text: Spannable, event: MotionEvent): Boolean { - return false - } - - override fun canSelectArbitrarily(): Boolean { - return false - } } }