mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-07 11:17:25 +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() {
|
override fun onBackPressed() {
|
||||||
supportFragmentManager.findFragmentById(R.id.frame_container)?.let {
|
supportFragmentManager.findFragmentById(R.id.frame_container)?.let {
|
||||||
if (it !is LibraryFragment) {
|
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 {
|
} else {
|
||||||
super.onBackPressed()
|
super.onBackPressed()
|
||||||
}
|
}
|
||||||
|
@ -201,21 +201,22 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
return true
|
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)
|
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) {
|
fun onChapterError(error: Throwable) {
|
||||||
Timber.e(error, error.message)
|
Timber.e(error, error.message)
|
||||||
finish()
|
finish()
|
||||||
@ -318,7 +319,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onCenterSingleTap() {
|
fun toggleMenu() {
|
||||||
setMenuVisibility(reader_menu.visibility == View.GONE)
|
setMenuVisibility(reader_menu.visibility == View.GONE)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ abstract class PagerReader : BaseReader() {
|
|||||||
} else if (positionX > pager.width * RIGHT_REGION) {
|
} else if (positionX > pager.width * RIGHT_REGION) {
|
||||||
if (tappingEnabled) onRightSideTap()
|
if (tappingEnabled) onRightSideTap()
|
||||||
} else {
|
} else {
|
||||||
readerActivity.onCenterSingleTap()
|
readerActivity.toggleMenu()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,7 @@ class WebtoonReader : BaseReader() {
|
|||||||
} else if (positionX > recycler.width * RIGHT_REGION) {
|
} else if (positionX > recycler.width * RIGHT_REGION) {
|
||||||
if (tappingEnabled) moveToNext()
|
if (tappingEnabled) moveToNext()
|
||||||
} else {
|
} else {
|
||||||
readerActivity.onCenterSingleTap()
|
readerActivity.toggleMenu()
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user