Fix: Show menu from screen bottom when press menu key

This commit is contained in:
zt515
2017-08-10 11:11:28 +08:00
parent 1a5f313051
commit fa1b730cd2

View File

@ -197,12 +197,11 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
super.onStop() super.onStop()
(0..tabSwitcher.count - 1) (0..tabSwitcher.count - 1)
.map { tabSwitcher.getTab(it) } .map { tabSwitcher.getTab(it) }
.takeWhile { it is TermTab } .filterIsInstance(TermTab::class.java)
.forEach { .forEach {
val termTab = it as TermTab
// After stopped, window locations may changed // After stopped, window locations may changed
// Rebind it at next time. // Rebind it at next time.
termTab.resetAutoCompleteStatus() it.resetAutoCompleteStatus()
} }
EventBus.getDefault().unregister(this) EventBus.getDefault().unregister(this)
} }
@ -229,6 +228,14 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
return true return true
} }
} }
KeyEvent.KEYCODE_MENU -> {
if (toolbar.isOverflowMenuShowing) {
toolbar.hideOverflowMenu()
} else {
toolbar.showOverflowMenu()
}
return true
}
} }
return super.onKeyDown(keyCode, event) return super.onKeyDown(keyCode, event)
} }
@ -484,7 +491,7 @@ class NeoTermActivity : AppCompatActivity(), ServiceConnection, SharedPreference
(0..size - 1) (0..size - 1)
.map { toolbar.getChildAt(it) } .map { toolbar.getChildAt(it) }
.filterIsInstance<ImageButton>() .filterIsInstance(ImageButton::class.java)
.forEach { return it } .forEach { return it }
} }