mirror of
https://git.mihon.tech/mihonapp/mihon
synced 2024-11-28 10:38:48 +03:00
Allow fullscreen reading
This commit is contained in:
parent
afebfec737
commit
720b0a29ce
6 changed files with 31 additions and 23 deletions
|
@ -30,8 +30,8 @@ public class PreferencesHelper {
|
||||||
mPref.edit().clear().apply();
|
mPref.edit().clear().apply();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hideStatusBarSet() {
|
public boolean useFullscreenSet() {
|
||||||
return mPref.getBoolean(getKey(R.string.pref_hide_status_bar_key), false);
|
return mPref.getBoolean(getKey(R.string.pref_fullscreen_key), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDefaultViewer() {
|
public int getDefaultViewer() {
|
||||||
|
|
|
@ -29,8 +29,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
private Source source;
|
private Source source;
|
||||||
private Chapter chapter;
|
private Chapter chapter;
|
||||||
private List<Page> pageList;
|
private List<Page> pageList;
|
||||||
private boolean initialStart = true;
|
@State int currentPage;
|
||||||
@State int currentPage = 0;
|
|
||||||
|
|
||||||
private static final int GET_PAGE_LIST = 1;
|
private static final int GET_PAGE_LIST = 1;
|
||||||
private static final int GET_PAGE_IMAGES = 2;
|
private static final int GET_PAGE_IMAGES = 2;
|
||||||
|
@ -45,9 +44,7 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
.doOnCompleted(() -> start(GET_PAGE_IMAGES)),
|
.doOnCompleted(() -> start(GET_PAGE_IMAGES)),
|
||||||
(view, pages) -> {
|
(view, pages) -> {
|
||||||
view.onPageListReady(pages);
|
view.onPageListReady(pages);
|
||||||
if (initialStart && !chapter.read)
|
if (currentPage != 0)
|
||||||
view.setSelectedPage(chapter.last_page_read - 1);
|
|
||||||
else if (currentPage != 0)
|
|
||||||
view.setSelectedPage(currentPage);
|
view.setSelectedPage(currentPage);
|
||||||
},
|
},
|
||||||
(view, error) -> Timber.e("An error occurred while downloading page list")
|
(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) {
|
protected void onTakeView(ReaderActivity view) {
|
||||||
super.onTakeView(view);
|
super.onTakeView(view);
|
||||||
registerForStickyEvents();
|
registerForStickyEvents();
|
||||||
|
|
||||||
if (prefs.hideStatusBarSet()) {
|
|
||||||
view.hideStatusBar();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onDropView() {
|
protected void onDropView() {
|
||||||
unregisterForEvents();
|
unregisterForEvents();
|
||||||
initialStart = false;
|
|
||||||
super.onDropView();
|
super.onDropView();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,6 +82,8 @@ public class ReaderPresenter extends BasePresenter<ReaderActivity> {
|
||||||
if (source == null || chapter == null) {
|
if (source == null || chapter == null) {
|
||||||
source = event.getSource();
|
source = event.getSource();
|
||||||
chapter = event.getChapter();
|
chapter = event.getChapter();
|
||||||
|
if (chapter.last_page_read != 0)
|
||||||
|
currentPage = chapter.last_page_read - 1;
|
||||||
|
|
||||||
start(1);
|
start(1);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@ package eu.kanade.mangafeed.ui.activity;
|
||||||
|
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.MotionEvent;
|
import android.view.MotionEvent;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
@ -55,6 +56,9 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||||
setContentView(R.layout.activity_reader);
|
setContentView(R.layout.activity_reader);
|
||||||
ButterKnife.bind(this);
|
ButterKnife.bind(this);
|
||||||
|
|
||||||
|
if (prefs.useFullscreenSet())
|
||||||
|
enableFullScreen();
|
||||||
|
|
||||||
viewer = getViewer();
|
viewer = getViewer();
|
||||||
|
|
||||||
enableHardwareAcceleration();
|
enableHardwareAcceleration();
|
||||||
|
@ -75,10 +79,22 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||||
viewer.setSelectedPage(pageIndex);
|
viewer.setSelectedPage(pageIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void hideStatusBar() {
|
public void enableFullScreen() {
|
||||||
View decorView = getWindow().getDecorView();
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
|
||||||
int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
|
getWindow().getDecorView().setSystemUiVisibility(
|
||||||
decorView.setSystemUiVisibility(uiOptions);
|
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() {
|
public void enableHardwareAcceleration() {
|
||||||
|
|
|
@ -2,6 +2,6 @@
|
||||||
<resources>
|
<resources>
|
||||||
<string name="pref_category_reader_key">pref_category_reader_key</string>
|
<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_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>
|
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
||||||
</resources>
|
</resources>
|
|
@ -53,8 +53,7 @@
|
||||||
<string name="pref_category_reader">Reader</string>
|
<string name="pref_category_reader">Reader</string>
|
||||||
<string name="pref_category_accounts">Accounts</string>
|
<string name="pref_category_accounts">Accounts</string>
|
||||||
|
|
||||||
<string name="pref_hide_status_bar">Hide status bar</string>
|
<string name="pref_fullscreen_mode">Read in fullscreen</string>
|
||||||
<string name="pref_hide_status_bar_summary">This option will hide the status bar while reading</string>
|
|
||||||
|
|
||||||
<string name="pref_viewer_type">Default viewer</string>
|
<string name="pref_viewer_type">Default viewer</string>
|
||||||
<string name="left_to_right_viewer">Left to right</string>
|
<string name="left_to_right_viewer">Left to right</string>
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
|
||||||
<CheckBoxPreference android:title="@string/pref_hide_status_bar"
|
<CheckBoxPreference android:title="@string/pref_fullscreen_mode"
|
||||||
android:key="@string/pref_hide_status_bar_key"
|
android:key="@string/pref_fullscreen_key"
|
||||||
android:defaultValue="false"
|
android:defaultValue="true" />
|
||||||
android:summary="@string/pref_hide_status_bar_summary" />
|
|
||||||
|
|
||||||
<ListPreference android:title="@string/pref_viewer_type"
|
<ListPreference android:title="@string/pref_viewer_type"
|
||||||
android:key="@string/pref_default_viewer_key"
|
android:key="@string/pref_default_viewer_key"
|
||||||
|
|
Loading…
Reference in a new issue