Add a black background setting for the reader
This commit is contained in:
parent
4630a5ed1a
commit
e2795f5480
@ -83,6 +83,10 @@ public class PreferencesHelper {
|
||||
return rxPrefs.getFloat(getKey(R.string.pref_custom_brightness_value_key), 0F);
|
||||
}
|
||||
|
||||
public int getReaderTheme() {
|
||||
return prefs.getInt(getKey(R.string.pref_reader_theme_key), 0);
|
||||
}
|
||||
|
||||
public int getDefaultViewer() {
|
||||
return Integer.parseInt(prefs.getString(getKey(R.string.pref_default_viewer_key), "1"));
|
||||
}
|
||||
|
@ -3,9 +3,11 @@ package eu.kanade.mangafeed.ui.reader;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.graphics.Color;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
@ -51,6 +53,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
private ReaderMenu readerMenu;
|
||||
|
||||
private int uiFlags;
|
||||
private int readerTheme;
|
||||
protected CompositeSubscription subscriptions;
|
||||
private Subscription customBrightnessSubscription;
|
||||
|
||||
@ -59,6 +62,8 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
private static final int VERTICAL = 3;
|
||||
private static final int WEBTOON = 4;
|
||||
|
||||
public static final int BLACK_THEME = 1;
|
||||
|
||||
public static Intent newIntent(Context context) {
|
||||
return new Intent(context, ReaderActivity.class);
|
||||
}
|
||||
@ -78,6 +83,10 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
if (savedState != null && readerMenu.showing)
|
||||
readerMenu.show(false);
|
||||
|
||||
readerTheme = preferences.getReaderTheme();
|
||||
if (readerTheme == BLACK_THEME)
|
||||
setBlackTheme();
|
||||
|
||||
initializeSettings();
|
||||
}
|
||||
|
||||
@ -251,6 +260,16 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
recreate();
|
||||
}
|
||||
|
||||
private void setBlackTheme() {
|
||||
getWindow().getDecorView().getRootView().setBackgroundColor(Color.BLACK);
|
||||
pageNumber.setTextColor(ContextCompat.getColor(this, R.color.light_grey));
|
||||
pageNumber.setBackgroundColor(ContextCompat.getColor(this, R.color.page_number_background_black));
|
||||
}
|
||||
|
||||
public int getReaderTheme() {
|
||||
return readerTheme;
|
||||
}
|
||||
|
||||
public ViewGroup getContainer() {
|
||||
return container;
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package eu.kanade.mangafeed.ui.reader.viewer.common;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
@ -37,6 +38,7 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
||||
@Bind(R.id.progress_text) TextView progressText;
|
||||
@Bind(R.id.retry_button) Button retryButton;
|
||||
|
||||
private ReaderActivity activity;
|
||||
private Page page;
|
||||
private Subscription progressSubscription;
|
||||
private Subscription statusSubscription;
|
||||
@ -51,17 +53,22 @@ public class ViewPagerReaderFragment extends BaseFragment {
|
||||
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
|
||||
View view = inflater.inflate(R.layout.fragment_page, container, false);
|
||||
ButterKnife.bind(this, view);
|
||||
activity = (ReaderActivity) getActivity();
|
||||
|
||||
if (activity.getReaderTheme() == ReaderActivity.BLACK_THEME) {
|
||||
progressText.setTextColor(ContextCompat.getColor(getContext(), R.color.light_grey));
|
||||
}
|
||||
|
||||
imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED);
|
||||
imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE);
|
||||
imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE);
|
||||
imageView.setOnTouchListener((v, motionEvent) ->
|
||||
((ReaderActivity) getActivity()).getViewer().onImageTouch(motionEvent));
|
||||
activity.getViewer().onImageTouch(motionEvent));
|
||||
|
||||
retryButton.setOnTouchListener((v, event) -> {
|
||||
if (event.getAction() == MotionEvent.ACTION_UP) {
|
||||
if (page != null)
|
||||
((ReaderActivity) getActivity()).getPresenter().retryPage(page);
|
||||
activity.getPresenter().retryPage(page);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
|
@ -39,4 +39,15 @@
|
||||
<item>75</item>
|
||||
<item>100</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="reader_themes">
|
||||
<item>@string/white_theme</item>
|
||||
<item>@string/black_theme</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="reader_themes_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
</string-array>
|
||||
|
||||
</resources>
|
@ -28,5 +28,6 @@
|
||||
<color name="line_grey">@color/md_light_dividers</color>
|
||||
<color name="light_grey">@color/md_grey_300</color>
|
||||
<color name="page_number_background">#AAE9E9E9</color>
|
||||
<color name="page_number_background_black">#AA252525</color>
|
||||
<color name="reader_menu_background">@color/colorPrimarySuperDark</color>
|
||||
</resources>
|
@ -14,6 +14,7 @@
|
||||
<string name="pref_keep_screen_on_key">pref_keep_screen_on_key</string>
|
||||
<string name="pref_custom_brightness_key">pref_custom_brightness_key</string>
|
||||
<string name="pref_custom_brightness_value_key">pref_custom_brightness_value_key</string>
|
||||
<string name="pref_reader_theme_key">pref_reader_theme_key</string>
|
||||
|
||||
<string name="pref_download_directory_key">pref_download_directory_key</string>
|
||||
<string name="pref_download_slots_key">pref_download_slots_key</string>
|
||||
|
@ -47,6 +47,9 @@
|
||||
<string name="pref_enable_transitions">Enable transitions</string>
|
||||
<string name="pref_show_page_number">Show page number</string>
|
||||
<string name="pref_custom_brightness">Use custom brightness</string>
|
||||
<string name="pref_reader_theme">Reader theme</string>
|
||||
<string name="white_theme">White</string>
|
||||
<string name="black_theme">Black</string>
|
||||
<string name="pref_viewer_type">Default viewer</string>
|
||||
<string name="default_viewer">Default</string>
|
||||
<string name="left_to_right_viewer">Left to right</string>
|
||||
|
@ -25,6 +25,15 @@
|
||||
android:key="@string/pref_default_viewer_key"
|
||||
android:entries="@array/viewers"
|
||||
android:entryValues="@array/viewers_values"
|
||||
android:defaultValue="1"/>
|
||||
android:defaultValue="1"
|
||||
android:summary="%s"/>
|
||||
|
||||
<eu.kanade.mangafeed.ui.setting.preference.IntListPreference
|
||||
android:title="@string/pref_reader_theme"
|
||||
android:key="@string/pref_reader_theme_key"
|
||||
android:entries="@array/reader_themes"
|
||||
android:entryValues="@array/reader_themes_values"
|
||||
android:defaultValue="0"
|
||||
android:summary="%s"/>
|
||||
|
||||
</PreferenceScreen>
|
Loading…
Reference in New Issue
Block a user