1
0
Fork 0

For #3008, For #2162 Add Simple Logic for Menu Orientation (#3114)

* For #3008 - Adjust orientation of collections menu based on view location

* For #2162 - Add simple menu orientation logic to bookmark menu
master
Emily Kager 2019-06-04 08:37:57 -07:00 committed by Colin Lee
parent ef0618a3d1
commit dc0d153580
2 changed files with 13 additions and 2 deletions

View File

@ -57,9 +57,16 @@ class CollectionViewHolder(
collection_overflow_button.run {
increaseTapArea(buttonIncreaseDps)
setOnClickListener {
val location = IntArray(2)
it.getLocationInWindow(location)
collectionMenu.menuBuilder
.build(view.context)
.show(anchor = it, orientation = BrowserMenu.Orientation.DOWN)
.show(
anchor = it,
orientation = if (location[1] > (rootView.measuredHeight / 2))
BrowserMenu.Orientation.UP else
BrowserMenu.Orientation.DOWN
)
}
}

View File

@ -176,9 +176,13 @@ class BookmarkAdapter(val emptyView: View, val actionEmitter: Observer<BookmarkA
bookmark_overflow.increaseTapArea(bookmarkOverflowExtraDips)
bookmark_overflow.setOnClickListener {
val location = IntArray(2)
it.getLocationInWindow(location)
bookmarkItemMenu.menuBuilder.build(containerView.context).show(
anchor = it,
orientation = BrowserMenu.Orientation.DOWN
orientation = if (location[1] > (it.rootView.measuredHeight / 2))
BrowserMenu.Orientation.UP else
BrowserMenu.Orientation.DOWN
)
}
bookmark_title.text = if (item.title.isNullOrBlank()) item.url else item.title