From 8be44c209c381e806416ce8a943782c94c9379db Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 9 Jan 2016 00:57:02 +0100 Subject: [PATCH] Show selected decoder and background color in the popup menu. Reload adapter when the decoder changes. --- .../mangafeed/ui/reader/ReaderMenu.java | 36 ++++++++++++------ .../reader/viewer/webtoon/WebtoonAdapter.java | 4 ++ .../reader/viewer/webtoon/WebtoonHolder.java | 3 ++ .../reader/viewer/webtoon/WebtoonReader.java | 14 +++++++ .../reader_background_checkbox_selected.png | Bin 0 -> 227 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 249 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 136 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 153 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 142 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 148 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 234 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 234 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 366 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 387 bytes .../reader_background_checkbox_selected.png | Bin 0 -> 434 bytes .../reader_background_checkbox_unselected.png | Bin 0 -> 499 bytes .../drawable/reader_background_checkbox.xml | 5 +++ app/src/main/res/layout/reader_popup.xml | 31 ++++++++++----- 18 files changed, 72 insertions(+), 21 deletions(-) create mode 100644 app/src/main/res/drawable-hdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-hdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-ldpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-ldpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-mdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-mdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-xhdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-xhdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-xxhdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-xxhdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_selected.png create mode 100644 app/src/main/res/drawable-xxxhdpi/reader_background_checkbox_unselected.png create mode 100644 app/src/main/res/drawable/reader_background_checkbox.xml 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 0000000000000000000000000000000000000000..9908433c073331a4d7356e7ea97e53e8377abaf3 GIT binary patch literal 227 zcmeAS@N?(olHy`uVBq!ia0vp^1|ZDA1|-9oezpUtRh}-6Ar-gY&N#?>SV4g0r{cwi zyKylcg`SGJH~sGg^1Zyo*xh8T{8l`#fnS=5f#JY>L0!)&E9B}n+UV?7EkE}zd;O`0 z^QT=7a?Q*ZZ*}={Ia7Mi(ah?cz4L=VX|H2uS!KWSO0)vMh(((C2@Zt@1|}rp&P#90 zugmLF))r}IO?{9WEGQnG`(yg1xzT@1HtoM0xAjr^T3^dQx~F0p7#ik3V)mCgv;Fno SnjJt_GkCiCxvXIlZ*%=rLRGm0#*Uk?9y6*6CiT9^B z*%X}%UYim#`P@2Nw(}3?FP*aW+Ov@Cw;zqBU%33L?AC{S9!Vy#>Tj3N+i`c2`Rp(+ z+qJBh`j|dnWEEoKP-tL4BGP{a$^8o6pT6dkVSi}U22+iaBED@Ve{LJkoqXiRq60S# q!v4%%y7_LKz3UEc28Iv$HH>^Wj;nEXT4n?N!rn literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..d06d87c9571bac625d670ea2a8fbcfa0578831bc GIT binary patch literal 136 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`{+=$5Ar-fh6C`>Xx*3jft2FH3 z>X2^OA;)X(@Koi)O`f0+Tpjx#99X{~Ye#|P1%}Wc{OtdjLYpr)R4MVSkblM&Ak!h@ js(h5QQ_FMaKL&7S66E(|eFe0O!PC{xWt~$(696tE BGmZcN literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..f0faf295f8548ba7617af2bcec6c1faff28fdf8d GIT binary patch literal 142 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJP)`@fkcwMxr)}f~O0eYKIdE5I z9?0l#FY%d0$9mpmY!BUo-X$Lr_exj+jTJYD@<);T3K0RYA_E|vfQ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..69e1ee734a399d3880c6b4aa55b467f257eba37a GIT binary patch literal 148 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=ffJXipc%kcwMxuNm?lFyL{ysFRqG zm-~)y=BPPY#`w3D6+Kt zaA-|tpNs!t-i!dTOzvAE8#`_Mf0>>;BI`3*#dDI%%hz!mg=Sl?eImK*OW)NSLbsEu zALssjGb=sw-}!j{xMcS?Z?-6(4~V|sGU=CX{U6!Hlg6gm=d>&AQljUr)I9J{p+OdC zFCJjeEb;5~)y`{)^SV5xg;j)?Y z9}4U}pm&!!^vd~yW=SKv%V*9x9Q~}8@z3t)!A%~MR6HmBTRmmdx34;%Pu+VxrT_l6 zw}mptS6|!p{p-5Nr{`6tozOY_zs4+Y?cCbhTYENrpBdRUuSI6>3;%yVxD_|2ESt!n z>b~Lbk~5QLx-nmoW()zk0T0+AQ)>IJu|?fT&eIcQb=@zf14sY&omgYK38c%@)z4*} HQ$iB}LHk}{ literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..287892b71b130a0fa24a9bd738323c915b22d0f6 GIT binary patch literal 366 zcmeAS@N?(olHy`uVBq!ia0vp^2_VeD1|%QND7Ro>U^Mk~aSW-r_4dxfzC#WI4G%?C z(zQR-PT0Mj@t%NAfAB???#xSfOeA@PE}!}I_vDYf{b{e4nR-rAfg!v1>S-O8VzU+J z@6BnSVfaj>xPNBSGbQ7v#`8b(w0G(MH-9Gexg#>^TGHkxo9}=I8k){eQLd zIt{{hefIzPb>Zq-_y-COO#rv2TzsQU4-J$VD$2IaSW-r_4bZp-eCs;hl>qf zOW964*S3E%E6t0zEO*$QBSOsxx| literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..90c1bd6f56549cce91c1055099eaf7bb5df43060 GIT binary patch literal 434 zcmeAS@N?(olHy`uVBq!ia0vp^4Is?H1|$#LC7xzrV660XaSW-r_4ckKSF?eLYvA#` z<-2)P%-}pHH}BowyyL0-eon9dOnyIH@BG?4ZHciwQou1V a{OD)T{q(Kt;-+0{AaPGuKbLh*2~7Yab%iD;uunK>+Ri(oXrLz4j1co z_uXdO)EjNll^~_4%es1sljp~|?BxuTowvrn5A)iona9V-&<-?5fPu+@frEijfq?}d z=f|Rr)3SFR^ha! zZ>!C(3MZZZZFc|uwnWPBpL+LuUQz$<7pw^@eBb@C47Q$Zz#zv_^x^u!Tjvs9l=9m$ z?x_=A@{LvIq5h*w^Gv^1JpZrEz(^o0k%QdsJ>QhCj;Ed%cDjQC#M9N!Wt~$(699+? BfB^si literal 0 HcmV?d00001 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"/>