Tweak pull down gesture
This commit is contained in:
parent
d57b50313c
commit
a3e7d22b9f
@ -227,7 +227,7 @@ class LauncherActivity : AppCompatActivity() {
|
|||||||
val params = widgetSpacer.layoutParams as LinearLayout.LayoutParams
|
val params = widgetSpacer.layoutParams as LinearLayout.LayoutParams
|
||||||
params.topMargin = Point().also { windowManager.defaultDisplay.getSize(it) }.y
|
params.topMargin = Point().also { windowManager.defaultDisplay.getSize(it) }.y
|
||||||
widgetSpacer.layoutParams = params
|
widgetSpacer.layoutParams = params
|
||||||
container.doOnNextLayout {
|
container.doOnLayout {
|
||||||
adjustWidgetSpace()
|
adjustWidgetSpace()
|
||||||
}
|
}
|
||||||
initWidgets()
|
initWidgets()
|
||||||
@ -749,32 +749,35 @@ class LauncherActivity : AppCompatActivity() {
|
|||||||
MotionEvent.ACTION_MOVE -> {
|
MotionEvent.ACTION_MOVE -> {
|
||||||
when {
|
when {
|
||||||
scrollView.scrollY == 0 -> {
|
scrollView.scrollY == 0 -> {
|
||||||
if (container.translationY >= searchBar.height) {
|
|
||||||
return@onTouch false
|
|
||||||
}
|
|
||||||
if (event.historySize > 0) {
|
if (event.historySize > 0) {
|
||||||
val dY = event.y - event.getHistoricalY(0)
|
val dY = event.y - event.getHistoricalY(0)
|
||||||
val newTransY = 0.4f * dY + container.translationY
|
val newTransY = 0.4f * dY + container.translationY
|
||||||
if (newTransY > 0) {
|
if (newTransY > 0 && newTransY < searchBar.height) {
|
||||||
container.translationY = newTransY
|
container.translationY = newTransY
|
||||||
searchBar.show()
|
searchBar.show()
|
||||||
} else {
|
} else if (newTransY <= 0) {
|
||||||
container.translationY = 0f
|
container.translationY = 0f
|
||||||
|
} else {
|
||||||
|
container.translationY = searchBar.height.toFloat()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (container.translationY == 0f) return@onTouch false
|
if (container.translationY == 0f) return@onTouch false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
scrollView.scrollY == scrollContainer.height - scrollView.height && searchVisibility -> {
|
scrollView.scrollY == scrollContainer.height - scrollView.height && searchVisibility -> {
|
||||||
if (container.translationY <= -searchBar.height) {
|
|
||||||
return@onTouch false
|
|
||||||
}
|
|
||||||
if (event.historySize > 0) {
|
if (event.historySize > 0) {
|
||||||
val dY = event.y - event.getHistoricalY(0)
|
val dY = event.y - event.getHistoricalY(0)
|
||||||
val newTransY = 0.4f * dY + container.translationY
|
val newTransY = 0.4f * dY + container.translationY
|
||||||
container.translationY =
|
|
||||||
if (newTransY <= 0) newTransY
|
if (newTransY <= 0 && newTransY > -searchBar.height) {
|
||||||
else 0f
|
container.translationY = newTransY
|
||||||
|
searchBar.show()
|
||||||
|
} else if (newTransY > 0) {
|
||||||
|
container.translationY = 0f
|
||||||
|
} else {
|
||||||
|
container.translationY = -searchBar.height.toFloat()
|
||||||
|
}
|
||||||
|
|
||||||
if (container.translationY == 0f) return@onTouch false
|
if (container.translationY == 0f) return@onTouch false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -783,7 +786,7 @@ class LauncherActivity : AppCompatActivity() {
|
|||||||
true
|
true
|
||||||
}
|
}
|
||||||
MotionEvent.ACTION_UP -> {
|
MotionEvent.ACTION_UP -> {
|
||||||
if (container.translationY >= searchBar.height) toggleSearch()
|
if (container.translationY >= searchBar.height * 0.6) toggleSearch()
|
||||||
if (container.translationY <= -searchBar.height) hideSearch()
|
if (container.translationY <= -searchBar.height) hideSearch()
|
||||||
container.animate().translationY(0f).setDuration(200).start()
|
container.animate().translationY(0f).setDuration(200).start()
|
||||||
if (!searchVisibility && scrollView.scrollY == 0) searchBar.hide()
|
if (!searchVisibility && scrollView.scrollY == 0) searchBar.hide()
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user