mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Add a black background setting for the reader
This commit is contained in:
		| @@ -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; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user