From e2795f5480f636caa5e3d6304954fb8696490a8f Mon Sep 17 00:00:00 2001 From: inorichi Date: Tue, 15 Dec 2015 13:34:14 +0100 Subject: [PATCH] Add a black background setting for the reader --- .../data/preference/PreferencesHelper.java | 4 ++++ .../mangafeed/ui/reader/ReaderActivity.java | 19 +++++++++++++++++++ .../common/ViewPagerReaderFragment.java | 11 +++++++++-- app/src/main/res/values/arrays.xml | 11 +++++++++++ app/src/main/res/values/colors.xml | 1 + app/src/main/res/values/keys.xml | 1 + app/src/main/res/values/strings.xml | 3 +++ app/src/main/res/xml/pref_reader.xml | 11 ++++++++++- 8 files changed, 58 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java b/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java index a1f560f15..38ce41a51 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/preference/PreferencesHelper.java @@ -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")); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java index 6670774bf..cdad40313 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderActivity.java @@ -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 { private ReaderMenu readerMenu; private int uiFlags; + private int readerTheme; protected CompositeSubscription subscriptions; private Subscription customBrightnessSubscription; @@ -59,6 +62,8 @@ public class ReaderActivity extends BaseRxActivity { 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 { 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 { 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; } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/ViewPagerReaderFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/ViewPagerReaderFragment.java index 9632dd406..046fc11ef 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/ViewPagerReaderFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/ViewPagerReaderFragment.java @@ -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; diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 9f98f05e3..37d080d1d 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -39,4 +39,15 @@ 75 100 + + + @string/white_theme + @string/black_theme + + + + 0 + 1 + + \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 52e1beee2..7e072d34f 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -28,5 +28,6 @@ @color/md_light_dividers @color/md_grey_300 #AAE9E9E9 + #AA252525 @color/colorPrimarySuperDark \ No newline at end of file diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 5c4c98870..0ea9054d6 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -14,6 +14,7 @@ pref_keep_screen_on_key pref_custom_brightness_key pref_custom_brightness_value_key + pref_reader_theme_key pref_download_directory_key pref_download_slots_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 285d22626..70ba9dbf8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -47,6 +47,9 @@ Enable transitions Show page number Use custom brightness + Reader theme + White + Black Default viewer Default Left to right diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 60a8e07c4..4b3f47bbe 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -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"/> + + \ No newline at end of file