diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java index a2039f936..cd3016119 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/ReaderMenu.java @@ -29,6 +29,7 @@ import eu.kanade.mangafeed.R; import eu.kanade.mangafeed.data.database.models.Chapter; import eu.kanade.mangafeed.data.database.models.Manga; import eu.kanade.mangafeed.data.preference.PreferencesHelper; +import eu.kanade.mangafeed.ui.reader.viewer.base.BaseReader; import icepick.State; import rx.Subscription; @@ -245,8 +246,9 @@ public class ReaderMenu { @Bind(R.id.show_page_number) CheckBox showPageNumber; @Bind(R.id.hide_status_bar) CheckBox hideStatusBar; @Bind(R.id.keep_screen_on) CheckBox keepScreenOn; + @Bind(R.id.reader_theme) CheckBox readerTheme; @Bind(R.id.image_decoder) TextView imageDecoder; - @Bind(R.id.reader_theme) TextView readerTheme; + @Bind(R.id.image_decoder_initial) TextView imageDecoderInitial; public SettingsPopupWindow(View view) { super(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); @@ -261,6 +263,8 @@ public class ReaderMenu { showPageNumber.setChecked(preferences.showPageNumber().get()); hideStatusBar.setChecked(preferences.hideStatusBar().get()); keepScreenOn.setChecked(preferences.keepScreenOn().get()); + readerTheme.setChecked(preferences.readerTheme().get() == 1); + setDecoderInitial(preferences.imageDecoder().get()); // Add a listener to change the corresponding setting enableTransitions.setOnCheckedChangeListener((view, isChecked) -> @@ -275,6 +279,9 @@ public class ReaderMenu { keepScreenOn.setOnCheckedChangeListener((view, isChecked) -> preferences.keepScreenOn().set(isChecked)); + readerTheme.setOnCheckedChangeListener((view, isChecked) -> + preferences.readerTheme().set(isChecked ? 1 : 0)); + imageDecoder.setOnClickListener(v -> { showImmersiveDialog(new MaterialDialog.Builder(activity) .title(R.string.pref_image_decoder) @@ -282,22 +289,27 @@ public class ReaderMenu { .itemsCallbackSingleChoice(preferences.imageDecoder().get(), (dialog, itemView, which, text) -> { preferences.imageDecoder().set(which); + setDecoderInitial(which); return true; }) .build()); }); + } - readerTheme.setOnClickListener(v -> { - showImmersiveDialog(new MaterialDialog.Builder(activity) - .title(R.string.pref_reader_theme) - .items(R.array.reader_themes) - .itemsCallbackSingleChoice(preferences.readerTheme().get(), - (dialog, itemView, which, text) -> { - preferences.readerTheme().set(which); - return true; - }) - .build()); - }); + private void setDecoderInitial(int decoder) { + String initial; + switch (decoder) { + case BaseReader.SKIA_DECODER: + initial = "S"; + break; + case BaseReader.RAPID_DECODER: + initial = "R"; + break; + default: + initial = ""; + break; + } + imageDecoderInitial.setText(initial); } } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonAdapter.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonAdapter.java index ee19e380d..7a738e7f1 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonAdapter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonAdapter.java @@ -61,4 +61,8 @@ public class WebtoonAdapter extends RecyclerView.Adapter { fragment.getReaderActivity().getPresenter().retryPage(page); } + public WebtoonReader getReader() { + return fragment; + } + } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonHolder.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonHolder.java index 95fba602e..090e1d6de 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonHolder.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonHolder.java @@ -26,9 +26,11 @@ public class WebtoonHolder extends RecyclerView.ViewHolder { private Animation fadeInAnimation; private Page page; + private WebtoonAdapter adapter; public WebtoonHolder(View view, WebtoonAdapter adapter, View.OnTouchListener touchListener) { super(view); + this.adapter = adapter; ButterKnife.bind(this, view); fadeInAnimation = AnimationUtils.loadAnimation(view.getContext(), R.anim.fade_in); @@ -88,6 +90,7 @@ public class WebtoonHolder extends RecyclerView.ViewHolder { setErrorButtonVisible(false); setProgressVisible(false); setImageVisible(true); + imageView.setRegionDecoderClass(adapter.getReader().getRegionDecoderClass()); imageView.setImage(ImageSource.uri(page.getImagePath())); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java index 169604adb..9457da5d5 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/webtoon/WebtoonReader.java @@ -27,6 +27,7 @@ public class WebtoonReader extends BaseReader { private RecyclerView recycler; private PreCachingLayoutManager layoutManager; private Subscription subscription; + private Subscription decoderSubscription; private GestureDetector gestureDetector; @Nullable @@ -42,6 +43,13 @@ public class WebtoonReader extends BaseReader { recycler.setItemAnimator(null); recycler.setAdapter(adapter); + decoderSubscription = getReaderActivity().getPreferences().imageDecoder() + .asObservable() + .doOnNext(this::setRegionDecoderClass) + .skip(1) + .distinctUntilChanged() + .subscribe(v -> adapter.notifyDataSetChanged()); + gestureDetector = new GestureDetector(getActivity(), new SimpleOnGestureListener() { @Override public boolean onSingleTapConfirmed(MotionEvent e) { @@ -63,6 +71,12 @@ public class WebtoonReader extends BaseReader { return recycler; } + @Override + public void onDestroyView() { + decoderSubscription.unsubscribe(); + super.onDestroyView(); + } + @Override public void onPause() { unsubscribeStatus(); diff --git a/app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..9908433c0 Binary files /dev/null and b/app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-hdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-hdpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..195e875fb Binary files /dev/null and b/app/src/main/res/drawable-hdpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..d06d87c95 Binary files /dev/null and b/app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-ldpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-ldpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..4899a16ff Binary files /dev/null and b/app/src/main/res/drawable-ldpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..f0faf295f Binary files /dev/null and b/app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..69e1ee734 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable-xhdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-xhdpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..7c8102d17 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-xhdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-xhdpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..4faa255e6 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..287892b71 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..b279adbbd Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png b/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png new file mode 100644 index 000000000..90c1bd6f5 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_unselected.png b/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_unselected.png new file mode 100644 index 000000000..5a3af58d6 Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_unselected.png differ diff --git a/app/src/main/res/drawable/reader_background_checkbox.xml b/app/src/main/res/drawable/reader_background_checkbox.xml new file mode 100644 index 000000000..2ace26fce --- /dev/null +++ b/app/src/main/res/drawable/reader_background_checkbox.xml @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/reader_popup.xml b/app/src/main/res/layout/reader_popup.xml index e165bf56d..ec0299e68 100644 --- a/app/src/main/res/layout/reader_popup.xml +++ b/app/src/main/res/layout/reader_popup.xml @@ -8,17 +8,30 @@ android:paddingTop="5dp" android:paddingBottom="5dp"> - + - + + + + + + + android:button="@drawable/reader_background_checkbox" + android:text="@string/pref_reader_theme"/>