diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.java b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.java index ba8668658..eacead925 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.java +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.java @@ -116,6 +116,10 @@ public class PreferencesHelper { return rxPrefs.getInteger(getKey(R.string.pref_image_decoder_key), 0); } + public Preference zoomStart() { + return rxPrefs.getInteger(getKey(R.string.pref_zoom_start_key), 1); + } + public Preference readerTheme() { return rxPrefs.getInteger(getKey(R.string.pref_reader_theme_key), 0); } diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderMenu.java b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderMenu.java index 76a1c1e38..2645405ac 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderMenu.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderMenu.java @@ -43,9 +43,10 @@ public class ReaderMenu { @Bind(R.id.page_seeker) SeekBar seekBar; @Bind(R.id.total_pages) TextView totalPages; @Bind(R.id.lock_orientation) ImageButton lockOrientation; + @Bind(R.id.reader_zoom_selector) ImageButton zoomSelector; + @Bind(R.id.reader_scale_type_selector) ImageButton scaleTypeSelector; @Bind(R.id.reader_selector) ImageButton readerSelector; @Bind(R.id.reader_extra_settings) ImageButton extraSettings; - @Bind(R.id.reader_scale_type_selector) ImageButton scaleTypeSelector; private MenuItem nextChapterBtn; private MenuItem prevChapterBtn; @@ -189,9 +190,23 @@ public class ReaderMenu { lockOrientation.setOnClickListener(v -> preferences.lockOrientation().set(!preferences.lockOrientation().get())); + // Zoom selector + zoomSelector.setOnClickListener(v -> { + showImmersiveDialog(new MaterialDialog.Builder(activity) + .title(R.string.pref_zoom_start) + .items(R.array.zoom_start) + .itemsCallbackSingleChoice(preferences.zoomStart().get() - 1, + (d, itemView, which, text) -> { + preferences.zoomStart().set(which + 1); + return true; + }) + .build()); + }); + // Scale type selector scaleTypeSelector.setOnClickListener(v -> { showImmersiveDialog(new MaterialDialog.Builder(activity) + .title(R.string.pref_image_scale_type) .items(R.array.image_scale_type) .itemsCallbackSingleChoice(preferences.imageScaleType().get() - 1, (d, itemView, which, text) -> { @@ -205,6 +220,7 @@ public class ReaderMenu { readerSelector.setOnClickListener(v -> { final Manga manga = activity.getPresenter().getManga(); showImmersiveDialog(new MaterialDialog.Builder(activity) + .title(R.string.pref_viewer_type) .items(R.array.viewers_selector) .itemsCallbackSingleChoice(manga.viewer, (d, itemView, which, text) -> { diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.java b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.java index 7f6bd146f..0bc556270 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReader.java @@ -6,10 +6,13 @@ import android.view.ViewGroup; import java.util.List; import eu.kanade.tachiyomi.R; +import eu.kanade.tachiyomi.data.preference.PreferencesHelper; import eu.kanade.tachiyomi.data.source.model.Page; import eu.kanade.tachiyomi.ui.reader.viewer.base.BaseReader; import eu.kanade.tachiyomi.ui.reader.viewer.base.OnChapterBoundariesOutListener; import eu.kanade.tachiyomi.ui.reader.viewer.base.OnChapterSingleTapListener; +import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.LeftToRightReader; +import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.RightToLeftReader; import rx.subscriptions.CompositeSubscription; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; @@ -24,6 +27,12 @@ public abstract class PagerReader extends BaseReader { protected CompositeSubscription subscriptions; protected int scaleType = 1; + protected int zoomStart = 1; + + public static final int ALIGN_AUTO = 1; + public static final int ALIGN_LEFT = 2; + public static final int ALIGN_RIGHT = 3; + public static final int ALIGN_CENTER = 4; protected void initializePager(Pager pager) { this.pager = pager; @@ -61,22 +70,30 @@ public abstract class PagerReader extends BaseReader { adapter = new PagerReaderAdapter(getChildFragmentManager()); pager.setAdapter(adapter); + PreferencesHelper preferences = getReaderActivity().getPreferences(); subscriptions = new CompositeSubscription(); - subscriptions.add(getReaderActivity().getPreferences().imageDecoder() + subscriptions.add(preferences.imageDecoder() .asObservable() .doOnNext(this::setDecoderClass) .skip(1) .distinctUntilChanged() .subscribe(v -> adapter.notifyDataSetChanged())); - subscriptions.add(getReaderActivity().getPreferences().imageScaleType() + subscriptions.add(preferences.imageScaleType() .asObservable() .doOnNext(this::setImageScaleType) .skip(1) .distinctUntilChanged() .subscribe(v -> adapter.notifyDataSetChanged())); - subscriptions.add(getReaderActivity().getPreferences().enableTransitions() + subscriptions.add(preferences.zoomStart() + .asObservable() + .doOnNext(this::setZoomStart) + .skip(1) + .distinctUntilChanged() + .subscribe(v -> adapter.notifyDataSetChanged())); + + subscriptions.add(preferences.enableTransitions() .asObservable() .subscribe(value -> transitions = value)); @@ -125,6 +142,19 @@ public abstract class PagerReader extends BaseReader { this.scaleType = scaleType; } + private void setZoomStart(int zoomStart) { + if (zoomStart == ALIGN_AUTO) { + if (this instanceof LeftToRightReader) + setZoomStart(ALIGN_LEFT); + else if (this instanceof RightToLeftReader) + setZoomStart(ALIGN_RIGHT); + else + setZoomStart(ALIGN_CENTER); + } else { + this.zoomStart = zoomStart; + } + } + public abstract void onFirstPageOut(); public abstract void onLastPageOut(); diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReaderFragment.java b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReaderFragment.java index a0279d91c..26892364d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReaderFragment.java +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/viewer/pager/PagerReaderFragment.java @@ -1,5 +1,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager; +import android.graphics.PointF; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; @@ -70,6 +71,23 @@ public class PagerReaderFragment extends BaseFragment { imageView.setVerticalScrollingParent(parentFragment instanceof VerticalReader); imageView.setOnTouchListener((v, motionEvent) -> parentFragment.onImageTouch(motionEvent)); imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { + @Override + public void onReady() { + switch (parentFragment.zoomStart) { + case PagerReader.ALIGN_LEFT: + imageView.setScaleAndCenter(imageView.getScale(), new PointF(0, 0)); + break; + case PagerReader.ALIGN_RIGHT: + imageView.setScaleAndCenter(imageView.getScale(), new PointF(99999f, 0)); + break; + case PagerReader.ALIGN_CENTER: + PointF center = imageView.getCenter(); + center.y = 0; + imageView.setScaleAndCenter(imageView.getScale(), center); + break; + } + } + @Override public void onImageLoadError(Exception e) { showImageLoadError(); @@ -93,6 +111,7 @@ public class PagerReaderFragment extends BaseFragment { public void onDestroyView() { unsubscribeProgress(); unsubscribeStatus(); + imageView.setOnImageEventListener(null); ButterKnife.unbind(this); super.onDestroyView(); } diff --git a/app/src/main/res/drawable-hdpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-hdpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..78ad3222d Binary files /dev/null and b/app/src/main/res/drawable-hdpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/drawable-ldpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-ldpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..82a55ffbe Binary files /dev/null and b/app/src/main/res/drawable-ldpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/drawable-mdpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-mdpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..a3e55bdc3 Binary files /dev/null and b/app/src/main/res/drawable-mdpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/drawable-xhdpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-xhdpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..1e26e6e61 Binary files /dev/null and b/app/src/main/res/drawable-xhdpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxhdpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-xxhdpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..ec0e760e0 Binary files /dev/null and b/app/src/main/res/drawable-xxhdpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/drawable-xxxhdpi/ic_crop_original_white_24dp.png b/app/src/main/res/drawable-xxxhdpi/ic_crop_original_white_24dp.png new file mode 100644 index 000000000..8fba54fca Binary files /dev/null and b/app/src/main/res/drawable-xxxhdpi/ic_crop_original_white_24dp.png differ diff --git a/app/src/main/res/layout/reader_menu.xml b/app/src/main/res/layout/reader_menu.xml index 001742557..8d4f8a50e 100644 --- a/app/src/main/res/layout/reader_menu.xml +++ b/app/src/main/res/layout/reader_menu.xml @@ -78,6 +78,16 @@ android:src="@drawable/ic_screen_rotation" android:layout_gravity="center_vertical" android:background="?android:selectableItemBackground" /> + + + + 6 + + @string/zoom_start_automatic + @string/zoom_start_left + @string/zoom_start_right + @string/zoom_start_center + + + + 1 + 2 + 3 + 4 + + @string/update_never @string/update_1hour diff --git a/app/src/main/res/values/keys.xml b/app/src/main/res/values/keys.xml index 4eac520ce..1967a589f 100644 --- a/app/src/main/res/values/keys.xml +++ b/app/src/main/res/values/keys.xml @@ -17,6 +17,7 @@ pref_default_viewer_key pref_image_scale_type_key + pref_zoom_start_key pref_hide_status_bar_key pref_lock_orientation_key pref_enable_transitions_key diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 7532f1ef0..b3ee4d191 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -93,7 +93,7 @@ Left to right Right to left Vertical - Webtoon (experimental) + Webtoon Image decoder Rapid Skia @@ -104,7 +104,11 @@ Fit height Original size Smart fit - + Zoom start position + Automatic + Left + Right + Center Downloads directory diff --git a/app/src/main/res/xml/pref_reader.xml b/app/src/main/res/xml/pref_reader.xml index 5587253d8..35fe58f3b 100644 --- a/app/src/main/res/xml/pref_reader.xml +++ b/app/src/main/res/xml/pref_reader.xml @@ -37,6 +37,14 @@ android:defaultValue="1" android:summary="%s"/> + +