mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-10 04:37:25 +01:00
Allow fullscreen reading
This commit is contained in:
parent
afebfec737
commit
720b0a29ce
@ -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() {
|
||||
|
@ -29,8 +29,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||
private Source source;
|
||||
private Chapter chapter;
|
||||
private List<Page> 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<ReaderActivity> {
|
||||
.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<ReaderActivity> {
|
||||
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<ReaderActivity> {
|
||||
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);
|
||||
}
|
||||
|
@ -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<ReaderPresenter> {
|
||||
setContentView(R.layout.activity_reader);
|
||||
ButterKnife.bind(this);
|
||||
|
||||
if (prefs.useFullscreenSet())
|
||||
enableFullScreen();
|
||||
|
||||
viewer = getViewer();
|
||||
|
||||
enableHardwareAcceleration();
|
||||
@ -75,10 +79,22 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
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() {
|
||||
|
@ -2,6 +2,6 @@
|
||||
<resources>
|
||||
<string name="pref_category_reader_key">pref_category_reader_key</string>
|
||||
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
||||
<string name="pref_hide_status_bar_key">pref_hide_status_bar_key</string>
|
||||
<string name="pref_fullscreen_key">pref_fullscreen_key</string>
|
||||
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
||||
</resources>
|
@ -53,8 +53,7 @@
|
||||
<string name="pref_category_reader">Reader</string>
|
||||
<string name="pref_category_accounts">Accounts</string>
|
||||
|
||||
<string name="pref_hide_status_bar">Hide status bar</string>
|
||||
<string name="pref_hide_status_bar_summary">This option will hide the status bar while reading</string>
|
||||
<string name="pref_fullscreen_mode">Read in fullscreen</string>
|
||||
|
||||
<string name="pref_viewer_type">Default viewer</string>
|
||||
<string name="left_to_right_viewer">Left to right</string>
|
||||
|
@ -1,10 +1,9 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<CheckBoxPreference android:title="@string/pref_hide_status_bar"
|
||||
android:key="@string/pref_hide_status_bar_key"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/pref_hide_status_bar_summary" />
|
||||
<CheckBoxPreference android:title="@string/pref_fullscreen_mode"
|
||||
android:key="@string/pref_fullscreen_key"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<ListPreference android:title="@string/pref_viewer_type"
|
||||
android:key="@string/pref_default_viewer_key"
|
||||
|
Loading…
Reference in New Issue
Block a user