Fix volume key navigation for global shared/saved/read stories (#715)

This commit is contained in:
Mark Anderson 2015-07-16 22:51:53 +01:00
parent ad24d03a85
commit b86fa09cfd
4 changed files with 37 additions and 2 deletions

View file

@ -25,4 +25,9 @@ public class GlobalSharedStoriesReading extends Reading {
menu.removeItem(R.id.menu_reading_markunread);
return true;
}
@Override
protected boolean overlayNavigationSupported() {
return false;
}
}

View file

@ -26,4 +26,8 @@ public class ReadStoriesReading extends Reading {
super.onLoadFinished(loader, cursor);
}
@Override
protected boolean overlayNavigationSupported() {
return false;
}
}

View file

@ -771,12 +771,34 @@ public abstract class Reading extends NbActivity implements OnPageChangeListener
private void processVolumeKeyNavigationEvent(int keyCode) {
if ((keyCode == KeyEvent.KEYCODE_VOLUME_DOWN && volumeKeyNavigation == VolumeKeyNavigation.DOWN_NEXT) ||
(keyCode == KeyEvent.KEYCODE_VOLUME_UP && volumeKeyNavigation == VolumeKeyNavigation.UP_NEXT)) {
overlayRight(overlayRight);
if (overlayNavigationSupported()) {
overlayRight(overlayRight);
} else {
int nextPosition = pager.getCurrentItem() + 1;
if (nextPosition < readingAdapter.getCount()) {
pager.setCurrentItem(nextPosition);
}
}
} else {
overlayLeft(overlayLeft);
if (overlayNavigationSupported()) {
overlayLeft(overlayLeft);
} else {
int nextPosition = pager.getCurrentItem() - 1;
if (nextPosition >= 0) {
pager.setCurrentItem(nextPosition);
}
}
}
}
/**
* Global shared, saved and read stories don't have overlays enabled for
* navigating between stories so we need to fall back to swipe left/right behaviour.
*/
protected boolean overlayNavigationSupported() {
return true;
}
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
// Required to prevent the default sound playing when the volume key is pressed

View file

@ -28,4 +28,8 @@ public class SavedStoriesReading extends Reading {
super.onLoadFinished(loader, cursor);
}
@Override
protected boolean overlayNavigationSupported() {
return false;
}
}