close #745
This commit is contained in:
parent
ab96713b8e
commit
add7cf309d
|
@ -30,6 +30,7 @@ import android.content.DialogInterface
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
import android.graphics.PorterDuff.Mode
|
import android.graphics.PorterDuff.Mode
|
||||||
|
import android.graphics.Rect
|
||||||
import android.location.*
|
import android.location.*
|
||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.os.AsyncTask
|
import android.os.AsyncTask
|
||||||
|
@ -54,7 +55,6 @@ import android.view.View.OnClickListener
|
||||||
import android.view.View.OnLongClickListener
|
import android.view.View.OnLongClickListener
|
||||||
import android.view.animation.DecelerateInterpolator
|
import android.view.animation.DecelerateInterpolator
|
||||||
import android.widget.ImageView
|
import android.widget.ImageView
|
||||||
import android.widget.TextView
|
|
||||||
import android.widget.Toast
|
import android.widget.Toast
|
||||||
import com.bumptech.glide.Glide
|
import com.bumptech.glide.Glide
|
||||||
import com.twitter.Extractor
|
import com.twitter.Extractor
|
||||||
|
@ -559,13 +559,11 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
override fun dispatchTouchEvent(ev: MotionEvent): Boolean {
|
||||||
when (ev.actionMasked) {
|
when (ev.actionMasked) {
|
||||||
MotionEvent.ACTION_DOWN -> {
|
MotionEvent.ACTION_DOWN -> {
|
||||||
val x = ev.rawX
|
if (isAccountSelectorVisible && !TwidereViewUtils.hitView(ev, accountSelectorButton)) {
|
||||||
val y = ev.rawY
|
|
||||||
if (isAccountSelectorVisible && !TwidereViewUtils.hitView(x, y, accountSelectorButton)) {
|
|
||||||
var clickedItem = false
|
var clickedItem = false
|
||||||
val layoutManager = accountSelector.layoutManager
|
val layoutManager = accountSelector.layoutManager
|
||||||
for (i in 0..layoutManager.childCount - 1) {
|
for (i in 0..layoutManager.childCount - 1) {
|
||||||
if (TwidereViewUtils.hitView(x, y, layoutManager.getChildAt(i))) {
|
if (TwidereViewUtils.hitView(ev, layoutManager.getChildAt(i))) {
|
||||||
clickedItem = true
|
clickedItem = true
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -582,10 +580,8 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent): Boolean {
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||||
val x = event.rawX
|
|
||||||
val y = event.rawY
|
|
||||||
val window = window
|
val window = window
|
||||||
if (!TwidereViewUtils.hitView(x, y, window.decorView)
|
if (!TwidereViewUtils.hitView(event, window.decorView)
|
||||||
&& window.peekDecorView() != null && !hasComposingStatus()) {
|
&& window.peekDecorView() != null && !hasComposingStatus()) {
|
||||||
onBackPressed()
|
onBackPressed()
|
||||||
return true
|
return true
|
||||||
|
@ -833,6 +829,7 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
editText.customSelectionActionModeCallback = this
|
editText.customSelectionActionModeCallback = this
|
||||||
|
editTextContainer.touchDelegate = ComposeEditTextTouchDelegate(editTextContainer, editText)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, event: KeyEvent, metaState: Int): Boolean {
|
override fun handleKeyboardShortcutSingle(handler: KeyboardShortcutsHandler, keyCode: Int, event: KeyEvent, metaState: Int): Boolean {
|
||||||
|
@ -1365,6 +1362,10 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onSetAltText(position: Int, altText: String?) {
|
||||||
|
mediaPreviewAdapter.setAltText(position, altText)
|
||||||
|
}
|
||||||
|
|
||||||
private fun setRecentLocation(location: ParcelableLocation?) {
|
private fun setRecentLocation(location: ParcelableLocation?) {
|
||||||
if (location != null) {
|
if (location != null) {
|
||||||
val attachPreciseLocation = kPreferences[attachPreciseLocationKey]
|
val attachPreciseLocation = kPreferences[attachPreciseLocationKey]
|
||||||
|
@ -1869,10 +1870,6 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
internal class NoAddress
|
internal class NoAddress
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onSetAltText(position: Int, altText: String?) {
|
|
||||||
mediaPreviewAdapter.setAltText(position, altText)
|
|
||||||
}
|
|
||||||
|
|
||||||
class RetweetProtectedStatusWarnFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
class RetweetProtectedStatusWarnFragment : BaseDialogFragment(), DialogInterface.OnClickListener {
|
||||||
|
|
||||||
override fun onClick(dialog: DialogInterface, which: Int) {
|
override fun onClick(dialog: DialogInterface, which: Int) {
|
||||||
|
@ -1995,6 +1992,38 @@ class ComposeActivity : BaseActivity(), OnMenuItemClickListener, OnClickListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class ComposeEditTextTouchDelegate(
|
||||||
|
val parentView: View, val delegateView: View
|
||||||
|
) : TouchDelegate(Rect(), delegateView) {
|
||||||
|
|
||||||
|
private var delegateTargeted: Boolean = false
|
||||||
|
|
||||||
|
override fun onTouchEvent(event: MotionEvent): Boolean {
|
||||||
|
var sendToDelegate = false
|
||||||
|
var handled = false
|
||||||
|
|
||||||
|
when (event.action) {
|
||||||
|
MotionEvent.ACTION_DOWN -> {
|
||||||
|
if (TwidereViewUtils.hitView(event, parentView)) {
|
||||||
|
delegateTargeted = true
|
||||||
|
sendToDelegate = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MotionEvent.ACTION_UP, MotionEvent.ACTION_MOVE -> {
|
||||||
|
sendToDelegate = delegateTargeted
|
||||||
|
}
|
||||||
|
MotionEvent.ACTION_CANCEL -> {
|
||||||
|
sendToDelegate = delegateTargeted
|
||||||
|
delegateTargeted = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sendToDelegate) {
|
||||||
|
handled = delegateView.dispatchTouchEvent(event)
|
||||||
|
}
|
||||||
|
return handled
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
|
|
|
@ -597,7 +597,7 @@ class AccountsDashboardFragment : BaseFragment(), LoaderCallbacks<AccountsInfo>,
|
||||||
|
|
||||||
fun shouldDisableDrawerSlide(e: MotionEvent): Boolean {
|
fun shouldDisableDrawerSlide(e: MotionEvent): Boolean {
|
||||||
if (accountsSelector == null) return false
|
if (accountsSelector == null) return false
|
||||||
return TwidereViewUtils.hitView(e.rawX, e.rawY, accountsSelector)
|
return TwidereViewUtils.hitView(e, accountsSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal class AccountSpaceViewHolder(itemView: View) : RecyclerPagerAdapter.ViewHolder(itemView)
|
internal class AccountSpaceViewHolder(itemView: View) : RecyclerPagerAdapter.ViewHolder(itemView)
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
package org.mariotaku.twidere.util
|
package org.mariotaku.twidere.util
|
||||||
|
|
||||||
|
import android.graphics.RectF
|
||||||
import android.support.annotation.UiThread
|
import android.support.annotation.UiThread
|
||||||
|
import android.view.MotionEvent
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -8,11 +10,14 @@ import android.view.View
|
||||||
*/
|
*/
|
||||||
object TwidereViewUtils {
|
object TwidereViewUtils {
|
||||||
|
|
||||||
|
private val location = IntArray(2)
|
||||||
|
private val rect = RectF()
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
fun hitView(x: Float, y: Float, view: View): Boolean {
|
fun hitView(event: MotionEvent, view: View): Boolean {
|
||||||
val location = IntArray(2)
|
|
||||||
view.getLocationOnScreen(location)
|
view.getLocationOnScreen(location)
|
||||||
return x in (location[0] until location[0] + view.width)
|
rect.set(location[0].toFloat(), location[1].toFloat(), location[0].toFloat() + view.width,
|
||||||
&& y in (location[1] until location[1] + view.height)
|
location[1].toFloat() + view.height)
|
||||||
|
return rect.contains(event.rawX, event.rawY)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,6 @@
|
||||||
android:layout_weight="1">
|
android:layout_weight="1">
|
||||||
|
|
||||||
<org.mariotaku.twidere.view.MaxHeightScrollView
|
<org.mariotaku.twidere.view.MaxHeightScrollView
|
||||||
android:id="@+id/editTextContainer"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:maxHeight="240dp">
|
android:maxHeight="240dp">
|
||||||
|
@ -53,7 +52,8 @@
|
||||||
android:padding="@dimen/element_spacing_normal"
|
android:padding="@dimen/element_spacing_normal"
|
||||||
tools:text="In reply to name: A quick brown fox jumps over the lazy dog"/>
|
tools:text="In reply to name: A quick brown fox jumps over the lazy dog"/>
|
||||||
|
|
||||||
<LinearLayout
|
<org.mariotaku.twidere.view.ExtendedLinearLayout
|
||||||
|
android:id="@+id/editTextContainer"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:minHeight="160dp"
|
android:minHeight="160dp"
|
||||||
|
@ -101,7 +101,7 @@
|
||||||
app:iabIconWidth="20dp"
|
app:iabIconWidth="20dp"
|
||||||
tools:text="11.4, 51.4"/>
|
tools:text="11.4, 51.4"/>
|
||||||
|
|
||||||
</LinearLayout>
|
</org.mariotaku.twidere.view.ExtendedLinearLayout>
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
</org.mariotaku.twidere.view.MaxHeightScrollView>
|
</org.mariotaku.twidere.view.MaxHeightScrollView>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue