Skip to content

Commit 9315c56

Browse files
committed
Fix many problems due to the custom ScrollView returning false
Skip super.requestChildRectangleOnScreen only after tapping. It seems that we can safely skip it ever after tapping, but only one time after tapping is enough.
1 parent 3d9ead7 commit 9315c56

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

app/src/main/java/jp/deadend/noname/skk/SKKKanaRuleManager.kt

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package jp.deadend.noname.skk
22

3+
import android.annotation.SuppressLint
34
import android.content.Context
45
import android.content.Intent
56
import android.graphics.Rect
@@ -61,6 +62,11 @@ class SKKKanaRuleManager : AppCompatActivity() {
6162

6263
updateStatusView()
6364
binding.kanaRuleEditor.addTextChangedListener(afterTextChanged = { isModified = true })
65+
@SuppressLint("ClickableViewAccessibility")
66+
binding.kanaRuleEditor.setOnTouchListener { _, _ ->
67+
binding.kanaRuleScrollView.isIgnoring = true
68+
false
69+
}
6470
}
6571

6672
override fun onPause() {
@@ -120,7 +126,12 @@ class SKKKanaRuleManager : AppCompatActivity() {
120126

121127
class StableScrollView @JvmOverloads constructor(c: Context, a: AttributeSet? = null, d: Int = 0) :
122128
ScrollView(c, a, d) {
129+
var isIgnoring = false
123130
override fun requestChildRectangleOnScreen(c: View, r: Rect, i: Boolean): Boolean {
124-
return false
131+
if (isIgnoring) {
132+
isIgnoring = false
133+
return false
134+
}
135+
return super.requestChildRectangleOnScreen(c, r, i)
125136
}
126137
}

app/src/main/res/layout/activity_kana_rule_manager.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
android:layout_height="wrap_content" />
1212

1313
<jp.deadend.noname.skk.StableScrollView
14+
android:id="@+id/kanaRuleScrollView"
1415
android:layout_width="match_parent"
1516
android:layout_height="match_parent">
1617

0 commit comments

Comments
 (0)