diff --git a/app/src/main/java/eu/kanade/mangafeed/data/helpers/PreferencesHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/helpers/PreferencesHelper.java index 80c503f70..cb73a99bf 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/helpers/PreferencesHelper.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/helpers/PreferencesHelper.java @@ -30,8 +30,8 @@ public class PreferencesHelper { mPref.edit().clear().apply(); } - public boolean hideStatusBarSet() { - return mPref.getBoolean(getKey(R.string.pref_hide_status_bar_key), false); + public boolean useFullscreenSet() { + return mPref.getBoolean(getKey(R.string.pref_fullscreen_key), false); } public int getDefaultViewer() { diff --git a/app/src/main/java/eu/kanade/mangafeed/presenter/ReaderPresenter.java b/app/src/main/java/eu/kanade/mangafeed/presenter/ReaderPresenter.java index 9efee111b..1b02aa2a1 100644 --- a/app/src/main/java/eu/kanade/mangafeed/presenter/ReaderPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/presenter/ReaderPresenter.java @@ -29,8 +29,7 @@ public class ReaderPresenter extends BasePresenter { private Source source; private Chapter chapter; private List pageList; - private boolean initialStart = true; - @State int currentPage = 0; + @State int currentPage; private static final int GET_PAGE_LIST = 1; private static final int GET_PAGE_IMAGES = 2; @@ -45,9 +44,7 @@ public class ReaderPresenter extends BasePresenter { .doOnCompleted(() -> start(GET_PAGE_IMAGES)), (view, pages) -> { view.onPageListReady(pages); - if (initialStart && !chapter.read) - view.setSelectedPage(chapter.last_page_read - 1); - else if (currentPage != 0) + if (currentPage != 0) view.setSelectedPage(currentPage); }, (view, error) -> Timber.e("An error occurred while downloading page list") @@ -64,16 +61,11 @@ public class ReaderPresenter extends BasePresenter { protected void onTakeView(ReaderActivity view) { super.onTakeView(view); registerForStickyEvents(); - - if (prefs.hideStatusBarSet()) { - view.hideStatusBar(); - } } @Override protected void onDropView() { unregisterForEvents(); - initialStart = false; super.onDropView(); } @@ -90,6 +82,8 @@ public class ReaderPresenter extends BasePresenter { if (source == null || chapter == null) { source = event.getSource(); chapter = event.getChapter(); + if (chapter.last_page_read != 0) + currentPage = chapter.last_page_read - 1; start(1); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/activity/ReaderActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/activity/ReaderActivity.java index 856b9a10d..d2aee1021 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/activity/ReaderActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/activity/ReaderActivity.java @@ -2,6 +2,7 @@ package eu.kanade.mangafeed.ui.activity; import android.content.Context; import android.content.Intent; +import android.os.Build; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; @@ -55,6 +56,9 @@ public class ReaderActivity extends BaseRxActivity { setContentView(R.layout.activity_reader); ButterKnife.bind(this); + if (prefs.useFullscreenSet()) + enableFullScreen(); + viewer = getViewer(); enableHardwareAcceleration(); @@ -75,10 +79,22 @@ public class ReaderActivity extends BaseRxActivity { viewer.setSelectedPage(pageIndex); } - public void hideStatusBar() { - View decorView = getWindow().getDecorView(); - int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN; - decorView.setSystemUiVisibility(uiOptions); + public void enableFullScreen() { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LOW_PROFILE + | View.SYSTEM_UI_FLAG_LAYOUT_STABLE + | View.SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN + | View.SYSTEM_UI_FLAG_HIDE_NAVIGATION + | View.SYSTEM_UI_FLAG_FULLSCREEN + | View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY + ); + } else { + getWindow().getDecorView().setSystemUiVisibility( + View.SYSTEM_UI_FLAG_LOW_PROFILE + ); + } } public void enableHardwareAcceleration() { diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 00eab40e4..bfc0bb9a2 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -2,6 +2,6 @@ pref_category_reader_key pref_category_accounts_key - pref_hide_status_bar_key + pref_fullscreen_key pref_default_viewer_key \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9123594de..60d8bf72c 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -53,8 +53,7 @@ Reader Accounts - Hide status bar - This option will hide the status bar while reading + Read in fullscreen Default viewer Left to right diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 2ce8e16b4..312cbb5f3 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -1,10 +1,9 @@ - +