mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 12:47:26 +01:00
Toggle reader menu with the menu button, closes #286. Fix incorrect drawer selected item when using back button
This commit is contained in:
parent
49628e9cf5
commit
1d1e5f1f99
@ -76,7 +76,8 @@ class MainActivity : BaseActivity() {
|
||||
override fun onBackPressed() {
|
||||
supportFragmentManager.findFragmentById(R.id.frame_container)?.let {
|
||||
if (it !is LibraryFragment) {
|
||||
setFragment(LibraryFragment.newInstance())
|
||||
nav_view.setCheckedItem(R.id.nav_drawer_library)
|
||||
nav_view.menu.performIdentifierAction(R.id.nav_drawer_library, 0)
|
||||
} else {
|
||||
super.onBackPressed()
|
||||
}
|
||||
|
@ -201,21 +201,22 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
return true
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
viewer?.moveToNext()
|
||||
}
|
||||
}
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> {
|
||||
if (event.action == KeyEvent.ACTION_UP) {
|
||||
viewer?.moveToPrevious()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return super.dispatchKeyEvent(event)
|
||||
}
|
||||
|
||||
override fun onKeyUp(keyCode: Int, event: KeyEvent): Boolean {
|
||||
if (!isFinishing) {
|
||||
when (keyCode) {
|
||||
KeyEvent.KEYCODE_DPAD_RIGHT -> viewer?.moveToNext()
|
||||
KeyEvent.KEYCODE_DPAD_LEFT -> viewer?.moveToPrevious()
|
||||
KeyEvent.KEYCODE_MENU -> toggleMenu()
|
||||
}
|
||||
}
|
||||
return super.onKeyUp(keyCode, event)
|
||||
}
|
||||
|
||||
fun onChapterError(error: Throwable) {
|
||||
Timber.e(error, error.message)
|
||||
finish()
|
||||
@ -318,7 +319,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
||||
}
|
||||
}
|
||||
|
||||
fun onCenterSingleTap() {
|
||||
fun toggleMenu() {
|
||||
setMenuVisibility(reader_menu.visibility == View.GONE)
|
||||
}
|
||||
|
||||
|
@ -168,7 +168,7 @@ abstract class PagerReader : BaseReader() {
|
||||
} else if (positionX > pager.width * RIGHT_REGION) {
|
||||
if (tappingEnabled) onRightSideTap()
|
||||
} else {
|
||||
readerActivity.onCenterSingleTap()
|
||||
readerActivity.toggleMenu()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ class WebtoonReader : BaseReader() {
|
||||
} else if (positionX > recycler.width * RIGHT_REGION) {
|
||||
if (tappingEnabled) moveToNext()
|
||||
} else {
|
||||
readerActivity.onCenterSingleTap()
|
||||
readerActivity.toggleMenu()
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user