From d03e7e2f8c077497533f751dace79b826d469e76 Mon Sep 17 00:00:00 2001 From: inorichi Date: Fri, 8 Jan 2016 20:16:17 +0100 Subject: [PATCH] Add Rapid decoder for better image support. Reorganize readers. --- app/build.gradle | 3 ++ .../data/preference/PreferencesHelper.java | 13 +++-- .../mangafeed/ui/reader/ReaderActivity.java | 21 +++++--- .../mangafeed/ui/reader/ReaderMenu.java | 46 ++++++++++++---- .../decoder/RapidImageRegionDecoder.java | 53 +++++++++++++++++++ .../ui/reader/viewer/base/BaseReader.java | 24 +++++++++ .../OnChapterBoundariesOutListener.java | 2 +- .../OnChapterSingleTapListener.java | 2 +- .../viewer/{common => pager}/Pager.java | 4 +- .../PagerGestureListener.java | 2 +- .../viewer/{common => pager}/PagerReader.java | 25 ++++++--- .../{common => pager}/PagerReaderAdapter.java | 2 +- .../PagerReaderFragment.java | 22 +++----- .../horizontal/HorizontalPager.java | 10 ++-- .../horizontal/HorizontalReader.java | 4 +- .../horizontal/LeftToRightReader.java | 2 +- .../horizontal/RightToLeftReader.java | 3 +- .../{ => pager}/vertical/VerticalPager.java | 10 ++-- .../{ => pager}/vertical/VerticalReader.java | 5 +- .../vertical/VerticalViewPagerImpl.java | 2 +- app/src/main/res/layout/reader_brightness.xml | 2 +- app/src/main/res/layout/reader_popup.xml | 28 +++++----- app/src/main/res/values/arrays.xml | 10 ++++ app/src/main/res/values/keys.xml | 1 + app/src/main/res/values/strings.xml | 3 ++ app/src/main/res/values/styles.xml | 5 +- app/src/main/res/xml/pref_reader.xml | 8 +++ build.gradle | 1 + 28 files changed, 233 insertions(+), 80 deletions(-) create mode 100644 app/src/main/java/eu/kanade/mangafeed/ui/reader/decoder/RapidImageRegionDecoder.java rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => base}/OnChapterBoundariesOutListener.java (67%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => base}/OnChapterSingleTapListener.java (69%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => pager}/Pager.java (81%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => pager}/PagerGestureListener.java (97%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => pager}/PagerReader.java (76%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => pager}/PagerReaderAdapter.java (94%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{common => pager}/PagerReaderFragment.java (95%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/horizontal/HorizontalPager.java (91%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/horizontal/HorizontalReader.java (77%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/horizontal/LeftToRightReader.java (81%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/horizontal/RightToLeftReader.java (86%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/vertical/VerticalPager.java (92%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/vertical/VerticalReader.java (75%) rename app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/{ => pager}/vertical/VerticalViewPagerImpl.java (99%) diff --git a/app/build.gradle b/app/build.gradle index 04407f9470..ab932e1a4f 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -113,6 +113,9 @@ dependencies { compile 'eu.davidea:flexible-adapter:4.2.0@aar' compile 'com.nononsenseapps:filepicker:2.5.0' compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1' + compile 'rapid.decoder:library:0.3.0' + compile 'rapid.decoder:jpeg-decoder:0.3.0' + compile 'rapid.decoder:png-decoder:0.3.0' compile "com.google.dagger:dagger:$DAGGER_VERSION" apt "com.google.dagger:dagger-compiler:$DAGGER_VERSION" 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 b6b2f838db..3a067429df 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 @@ -84,11 +84,8 @@ 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() { + // TODO use IntListPreference return Integer.parseInt(prefs.getString(getKey(R.string.pref_default_viewer_key), "1")); } @@ -100,6 +97,14 @@ public class PreferencesHelper { return rxPrefs.getInteger(getKey(R.string.pref_library_columns_landscape_key), 0); } + public Preference imageDecoder() { + return rxPrefs.getInteger(getKey(R.string.pref_image_decoder_key), 0); + } + + public Preference readerTheme() { + return rxPrefs.getInteger(getKey(R.string.pref_reader_theme_key), 0); + } + public String getSourceUsername(Source source) { return prefs.getString(SOURCE_ACCOUNT_USERNAME + source.getId(), ""); } 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 0f512b39f5..cc67ea3d6a 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 @@ -30,9 +30,9 @@ import eu.kanade.mangafeed.data.preference.PreferencesHelper; import eu.kanade.mangafeed.data.source.model.Page; import eu.kanade.mangafeed.ui.base.activity.BaseRxActivity; import eu.kanade.mangafeed.ui.reader.viewer.base.BaseReader; -import eu.kanade.mangafeed.ui.reader.viewer.horizontal.LeftToRightReader; -import eu.kanade.mangafeed.ui.reader.viewer.horizontal.RightToLeftReader; -import eu.kanade.mangafeed.ui.reader.viewer.vertical.VerticalReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal.LeftToRightReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal.RightToLeftReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.vertical.VerticalReader; import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader; import eu.kanade.mangafeed.util.GLUtil; import eu.kanade.mangafeed.util.ToastUtil; @@ -85,9 +85,6 @@ public class ReaderActivity extends BaseRxActivity { if (savedState != null && readerMenu.showing) readerMenu.show(false); - readerTheme = preferences.getReaderTheme(); - applyTheme(); - initializeSettings(); maxBitmapSize = GLUtil.getMaxTextureSize(); @@ -211,6 +208,11 @@ public class ReaderActivity extends BaseRxActivity { subscriptions.add(preferences.customBrightness() .asObservable() .subscribe(this::setCustomBrightness)); + + subscriptions.add(preferences.readerTheme() + .asObservable() + .distinctUntilChanged() + .subscribe(this::applyTheme)); } private void setOrientation(boolean locked) { @@ -291,14 +293,17 @@ public class ReaderActivity extends BaseRxActivity { recreate(); } - private void applyTheme() { + private void applyTheme(int theme) { + readerTheme = theme; View rootView = getWindow().getDecorView().getRootView(); - if (readerTheme == BLACK_THEME) { + if (theme == BLACK_THEME) { rootView.setBackgroundColor(Color.BLACK); pageNumber.setTextColor(ContextCompat.getColor(this, R.color.light_grey)); pageNumber.setBackgroundColor(ContextCompat.getColor(this, R.color.page_number_background_black)); } else { rootView.setBackgroundColor(Color.WHITE); + pageNumber.setTextColor(ContextCompat.getColor(this, R.color.primary_text)); + pageNumber.setBackgroundColor(ContextCompat.getColor(this, R.color.page_number_background)); } } 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 25db12bf43..a2039f9362 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 @@ -2,7 +2,6 @@ package eu.kanade.mangafeed.ui.reader; import android.app.Dialog; import android.content.Context; -import android.support.v7.app.AlertDialog; import android.support.v7.widget.Toolbar; import android.view.Gravity; import android.view.Menu; @@ -20,6 +19,8 @@ import android.widget.RelativeLayout; import android.widget.SeekBar; import android.widget.TextView; +import com.afollestad.materialdialogs.MaterialDialog; + import java.text.DecimalFormat; import butterknife.Bind; @@ -191,15 +192,14 @@ public class ReaderMenu { // Reader selector readerSelector.setOnClickListener(v -> { final Manga manga = activity.getPresenter().getManga(); - final Dialog dialog = new AlertDialog.Builder(activity) - .setSingleChoiceItems(R.array.viewers_selector, manga.viewer, (d, which) -> { - if (manga.viewer != which) { - activity.setMangaDefaultViewer(which); - } - d.dismiss(); - }) - .create(); - showImmersiveDialog(dialog); + showImmersiveDialog(new MaterialDialog.Builder(activity) + .items(R.array.viewers_selector) + .itemsCallbackSingleChoice(manga.viewer, + (d, itemView, which, text) -> { + activity.setMangaDefaultViewer(which); + return true; + }) + .build()); }); // Extra settings menu @@ -245,6 +245,8 @@ 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.image_decoder) TextView imageDecoder; + @Bind(R.id.reader_theme) TextView readerTheme; public SettingsPopupWindow(View view) { super(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); @@ -272,6 +274,30 @@ public class ReaderMenu { keepScreenOn.setOnCheckedChangeListener((view, isChecked) -> preferences.keepScreenOn().set(isChecked)); + + imageDecoder.setOnClickListener(v -> { + showImmersiveDialog(new MaterialDialog.Builder(activity) + .title(R.string.pref_image_decoder) + .items(R.array.image_decoders) + .itemsCallbackSingleChoice(preferences.imageDecoder().get(), + (dialog, itemView, which, text) -> { + preferences.imageDecoder().set(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()); + }); } } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/decoder/RapidImageRegionDecoder.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/decoder/RapidImageRegionDecoder.java new file mode 100644 index 0000000000..1c1e3bb564 --- /dev/null +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/decoder/RapidImageRegionDecoder.java @@ -0,0 +1,53 @@ +package eu.kanade.mangafeed.ui.reader.decoder; + +import android.content.Context; +import android.graphics.Bitmap; +import android.graphics.Point; +import android.graphics.Rect; +import android.net.Uri; + +import com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder; + +import rapid.decoder.BitmapDecoder; + +/** + * A very simple implementation of {@link com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder} + * using the RapidDecoder library (https://github.com/suckgamony/RapidDecoder). For PNGs, this can + * give more reliable decoding and better performance. For JPGs, it is slower and can run out of + * memory with large images, but has better support for grayscale and CMYK images. + * + * This is an incomplete and untested implementation provided as an example only. + */ +public class RapidImageRegionDecoder implements ImageRegionDecoder { + + private BitmapDecoder decoder; + + @Override + public Point init(Context context, Uri uri) throws Exception { + decoder = BitmapDecoder.from(context, uri); + decoder.useBuiltInDecoder(true); + return new Point(decoder.sourceWidth(), decoder.sourceHeight()); + } + + @Override + public synchronized Bitmap decodeRegion(Rect sRect, int sampleSize) { + try { + return decoder.reset().region(sRect).scale(sRect.width()/sampleSize, sRect.height()/sampleSize).decode(); + } catch (Exception e) { + return null; + } + } + + @Override + public boolean isReady() { + return decoder != null; + } + + @Override + public void recycle() { + BitmapDecoder.destroyMemoryCache(); + BitmapDecoder.destroyDiskCache(); + decoder.reset(); + decoder = null; + } +} \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java index 149abaec4f..fd725d3a11 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/BaseReader.java @@ -2,16 +2,24 @@ package eu.kanade.mangafeed.ui.reader.viewer.base; import android.view.MotionEvent; +import com.davemorrissey.labs.subscaleview.decoder.ImageRegionDecoder; +import com.davemorrissey.labs.subscaleview.decoder.SkiaImageRegionDecoder; + import java.util.List; import eu.kanade.mangafeed.data.source.model.Page; import eu.kanade.mangafeed.ui.base.fragment.BaseFragment; import eu.kanade.mangafeed.ui.reader.ReaderActivity; +import eu.kanade.mangafeed.ui.reader.decoder.RapidImageRegionDecoder; public abstract class BaseReader extends BaseFragment { protected int currentPage; protected List pages; + protected Class regionDecoderClass; + + public static final int RAPID_DECODER = 0; + public static final int SKIA_DECODER = 1; public void updatePageNumber() { getReaderActivity().onPageChanged(getCurrentPage(), getTotalPages()); @@ -42,6 +50,22 @@ public abstract class BaseReader extends BaseFragment { public abstract void onPageListReady(List pages, int currentPage); public abstract boolean onImageTouch(MotionEvent motionEvent); + public void setRegionDecoderClass(int value) { + switch (value) { + case RAPID_DECODER: + default: + regionDecoderClass = RapidImageRegionDecoder.class; + break; + case SKIA_DECODER: + regionDecoderClass = SkiaImageRegionDecoder.class; + break; + } + } + + public Class getRegionDecoderClass() { + return regionDecoderClass; + } + public ReaderActivity getReaderActivity() { return (ReaderActivity) getActivity(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterBoundariesOutListener.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterBoundariesOutListener.java similarity index 67% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterBoundariesOutListener.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterBoundariesOutListener.java index dd23426a84..0e1989ad14 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterBoundariesOutListener.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterBoundariesOutListener.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.base; public interface OnChapterBoundariesOutListener { void onFirstPageOutEvent(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterSingleTapListener.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterSingleTapListener.java similarity index 69% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterSingleTapListener.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterSingleTapListener.java index 385b49dd08..8c12865854 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/OnChapterSingleTapListener.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/base/OnChapterSingleTapListener.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.base; public interface OnChapterSingleTapListener { void onCenterTap(); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/Pager.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/Pager.java similarity index 81% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/Pager.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/Pager.java index 3fce355ac4..685e151519 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/Pager.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/Pager.java @@ -1,9 +1,11 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.support.v4.view.PagerAdapter; import android.view.MotionEvent; import android.view.ViewGroup; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterBoundariesOutListener; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterSingleTapListener; import rx.functions.Action1; public interface Pager { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerGestureListener.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerGestureListener.java similarity index 97% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerGestureListener.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerGestureListener.java index 5554bce562..c304c8479a 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerGestureListener.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerGestureListener.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.view.GestureDetector; import android.view.MotionEvent; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java similarity index 76% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReader.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java index a109857810..419f91402e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReader.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.view.MotionEvent; import android.view.ViewGroup; @@ -8,7 +8,9 @@ import java.util.List; import eu.kanade.mangafeed.R; import eu.kanade.mangafeed.data.source.model.Page; import eu.kanade.mangafeed.ui.reader.viewer.base.BaseReader; -import rx.Subscription; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterBoundariesOutListener; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterSingleTapListener; +import rx.subscriptions.CompositeSubscription; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; @@ -18,7 +20,7 @@ public abstract class PagerReader extends BaseReader { protected Pager pager; protected boolean transitions; - protected Subscription transitionsSubscription; + protected CompositeSubscription subscriptions; protected void initializePager(Pager pager) { this.pager = pager; @@ -55,16 +57,25 @@ public abstract class PagerReader extends BaseReader { adapter = new PagerReaderAdapter(getChildFragmentManager()); pager.setAdapter(adapter); - setPages(); - transitionsSubscription = getReaderActivity().getPreferences().enableTransitions() + subscriptions = new CompositeSubscription(); + subscriptions.add(getReaderActivity().getPreferences().imageDecoder() .asObservable() - .subscribe(value -> transitions = value); + .doOnNext(this::setRegionDecoderClass) + .skip(1) + .distinctUntilChanged() + .subscribe(v -> adapter.notifyDataSetChanged())); + + subscriptions.add(getReaderActivity().getPreferences().enableTransitions() + .asObservable() + .subscribe(value -> transitions = value)); + + setPages(); } @Override public void onDestroyView() { - transitionsSubscription.unsubscribe(); + subscriptions.unsubscribe(); super.onDestroyView(); } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderAdapter.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderAdapter.java similarity index 94% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderAdapter.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderAdapter.java index 3a609f85e5..f67ba6c1ee 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderAdapter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderAdapter.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java similarity index 95% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderFragment.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java index 2e59d7a05f..0249ef0bde 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/common/PagerReaderFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.common; +package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.os.Bundle; import android.support.annotation.Nullable; @@ -54,6 +54,7 @@ public class PagerReaderFragment extends BaseFragment { View view = inflater.inflate(R.layout.item_pager_reader, container, false); ButterKnife.bind(this, view); ReaderActivity activity = (ReaderActivity) getActivity(); + BaseReader parentFragment = (BaseReader) getParentFragment(); if (activity.getReaderTheme() == ReaderActivity.BLACK_THEME) { progressText.setTextColor(ContextCompat.getColor(getContext(), R.color.light_grey)); @@ -64,8 +65,8 @@ public class PagerReaderFragment extends BaseFragment { imageView.setDoubleTapZoomStyle(SubsamplingScaleImageView.ZOOM_FOCUS_FIXED); imageView.setPanLimit(SubsamplingScaleImageView.PAN_LIMIT_INSIDE); imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE); - imageView.setOnTouchListener((v, motionEvent) -> - ((BaseReader) getParentFragment()).onImageTouch(motionEvent)); + imageView.setRegionDecoderClass(parentFragment.getRegionDecoderClass()); + imageView.setOnTouchListener((v, motionEvent) -> parentFragment.onImageTouch(motionEvent)); retryButton.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP) { @@ -76,25 +77,16 @@ public class PagerReaderFragment extends BaseFragment { return true; }); + observeStatus(); return view; } @Override public void onDestroyView() { - ButterKnife.unbind(this); - super.onDestroyView(); - } - - public void onStart() { - super.onStart(); - observeStatus(); - } - - @Override - public void onStop() { unsubscribeProgress(); unsubscribeStatus(); - super.onStop(); + ButterKnife.unbind(this); + super.onDestroyView(); } public void setPage(Page page) { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalPager.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalPager.java similarity index 91% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalPager.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalPager.java index 2115fdfbd6..29144d5abc 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalPager.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalPager.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.horizontal; +package eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal; import android.content.Context; import android.support.v4.view.ViewPager; @@ -6,10 +6,10 @@ import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; -import eu.kanade.mangafeed.ui.reader.viewer.common.OnChapterBoundariesOutListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.OnChapterSingleTapListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.PagerGestureListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.Pager; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterBoundariesOutListener; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterSingleTapListener; +import eu.kanade.mangafeed.ui.reader.viewer.pager.PagerGestureListener; +import eu.kanade.mangafeed.ui.reader.viewer.pager.Pager; import rx.functions.Action1; public class HorizontalPager extends ViewPager implements Pager { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalReader.java similarity index 77% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalReader.java index 692cd71fae..c1b71da715 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/HorizontalReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/HorizontalReader.java @@ -1,11 +1,11 @@ -package eu.kanade.mangafeed.ui.reader.viewer.horizontal; +package eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import eu.kanade.mangafeed.ui.reader.viewer.common.PagerReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.PagerReader; public abstract class HorizontalReader extends PagerReader { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/LeftToRightReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/LeftToRightReader.java similarity index 81% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/LeftToRightReader.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/LeftToRightReader.java index 9256f8d97d..5378c1dd82 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/LeftToRightReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/LeftToRightReader.java @@ -1,4 +1,4 @@ -package eu.kanade.mangafeed.ui.reader.viewer.horizontal; +package eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal; public class LeftToRightReader extends HorizontalReader { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/RightToLeftReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/RightToLeftReader.java similarity index 86% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/RightToLeftReader.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/RightToLeftReader.java index 043a90ddfd..c26cf6ff63 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/horizontal/RightToLeftReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/horizontal/RightToLeftReader.java @@ -1,10 +1,11 @@ -package eu.kanade.mangafeed.ui.reader.viewer.horizontal; +package eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal; import java.util.ArrayList; import java.util.Collections; import java.util.List; import eu.kanade.mangafeed.data.source.model.Page; +import eu.kanade.mangafeed.ui.reader.viewer.pager.horizontal.HorizontalReader; public class RightToLeftReader extends HorizontalReader { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalPager.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalPager.java similarity index 92% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalPager.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalPager.java index 03c9b9f445..10c384886e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalPager.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalPager.java @@ -1,14 +1,14 @@ -package eu.kanade.mangafeed.ui.reader.viewer.vertical; +package eu.kanade.mangafeed.ui.reader.viewer.pager.vertical; import android.content.Context; import android.util.AttributeSet; import android.view.GestureDetector; import android.view.MotionEvent; -import eu.kanade.mangafeed.ui.reader.viewer.common.OnChapterBoundariesOutListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.OnChapterSingleTapListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.PagerGestureListener; -import eu.kanade.mangafeed.ui.reader.viewer.common.Pager; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterBoundariesOutListener; +import eu.kanade.mangafeed.ui.reader.viewer.base.OnChapterSingleTapListener; +import eu.kanade.mangafeed.ui.reader.viewer.pager.PagerGestureListener; +import eu.kanade.mangafeed.ui.reader.viewer.pager.Pager; import rx.functions.Action1; public class VerticalPager extends VerticalViewPagerImpl implements Pager { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalReader.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalReader.java similarity index 75% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalReader.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalReader.java index ca1fa944e2..ffe2ef465c 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalReader.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalReader.java @@ -1,11 +1,12 @@ -package eu.kanade.mangafeed.ui.reader.viewer.vertical; +package eu.kanade.mangafeed.ui.reader.viewer.pager.vertical; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; -import eu.kanade.mangafeed.ui.reader.viewer.common.PagerReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.PagerReader; +import eu.kanade.mangafeed.ui.reader.viewer.pager.vertical.VerticalPager; public class VerticalReader extends PagerReader { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalViewPagerImpl.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java similarity index 99% rename from app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalViewPagerImpl.java rename to app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java index 162eeff97c..231ce0bcdd 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/vertical/VerticalViewPagerImpl.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/vertical/VerticalViewPagerImpl.java @@ -14,7 +14,7 @@ * limitations under the License. */ -package eu.kanade.mangafeed.ui.reader.viewer.vertical; +package eu.kanade.mangafeed.ui.reader.viewer.pager.vertical; import android.content.Context; import android.content.res.Resources; diff --git a/app/src/main/res/layout/reader_brightness.xml b/app/src/main/res/layout/reader_brightness.xml index 5742a4fca0..7a19d8c3f4 100644 --- a/app/src/main/res/layout/reader_brightness.xml +++ b/app/src/main/res/layout/reader_brightness.xml @@ -12,7 +12,7 @@ diff --git a/app/src/main/res/layout/reader_popup.xml b/app/src/main/res/layout/reader_popup.xml index 82cedc90c3..e165bf56d7 100644 --- a/app/src/main/res/layout/reader_popup.xml +++ b/app/src/main/res/layout/reader_popup.xml @@ -8,32 +8,36 @@ android:paddingTop="5dp" android:paddingBottom="5dp"> + + + + \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index eb10977ebc..1cd743672f 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -38,4 +38,14 @@ 1 + + @string/rapid_decoder + @string/skia_decoder + + + + 0 + 1 + + \ 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 aa54cc4411..66fbbf4a51 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -20,6 +20,7 @@ pref_custom_brightness_key pref_custom_brightness_value_key pref_reader_theme_key + pref_image_decoder_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 e97dbeebf6..ddd25f5fa4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -80,6 +80,9 @@ Right to left Vertical Webtoon (experimental) + Image decoder + Rapid + Skia Downloads directory diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 320db14473..4757dda11c 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -109,7 +109,10 @@ @anim/exit_to_left - diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 4b3f47bbec..7899bd930a 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -36,4 +36,12 @@ android:defaultValue="0" android:summary="%s"/> + + \ No newline at end of file diff --git a/build.gradle b/build.gradle index 4a7361f908..ee0d8ee2c8 100644 --- a/build.gradle +++ b/build.gradle @@ -23,5 +23,6 @@ allprojects { maven { url "http://dl.bintray.com/davideas/maven" } maven { url "https://jitpack.io" } maven { url 'http://dl.bintray.com/amulyakhare/maven' } + maven { url 'https://github.com/suckgamony/RapidDecoder/raw/master/repository' } } }