From 201650ced7770774ad687e99034594dadf7a39b8 Mon Sep 17 00:00:00 2001 From: inorichi Date: Sat, 9 Jan 2016 18:23:38 +0100 Subject: [PATCH] Notify when an image can't be decoded in the pager reader. Changes to theme. Reload library adapter when the mangas per row setting is changed (to recalculate covers height). --- .../ui/library/LibraryCategoryFragment.java | 5 +++- .../viewer/pager/PagerReaderFragment.java | 29 +++++++++++++++++-- .../mangafeed/widget/PTSansTextView.java | 8 +++++ app/src/main/res/layout/item_catalogue.xml | 22 +++++++------- .../main/res/layout/library_tab_layout.xml | 3 +- .../main/res/layout/pref_library_columns.xml | 5 +++- app/src/main/res/layout/tab_layout.xml | 2 +- app/src/main/res/layout/toolbar.xml | 2 +- app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/dimens.xml | 3 ++ app/src/main/res/values/strings.xml | 3 +- app/src/main/res/values/styles.xml | 17 ++++++----- 12 files changed, 74 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryCategoryFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryCategoryFragment.java index d06883a40..60ec5dbad 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryCategoryFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/library/LibraryCategoryFragment.java @@ -63,7 +63,10 @@ public class LibraryCategoryFragment extends BaseFragment getLibraryPresenter().preferences.landscapeColumns(); numColumnsSubscription = columnsPref.asObservable() - .subscribe(recycler::setSpanCount); + .doOnNext(recycler::setSpanCount) + .skip(1) + // Set again the adapter to recalculate the covers height + .subscribe(count -> recycler.setAdapter(adapter)); if (savedState != null) { adapter.onRestoreInstanceState(savedState); diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java index 0249ef0bd..cc070922e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/reader/viewer/pager/PagerReaderFragment.java @@ -3,6 +3,7 @@ package eu.kanade.mangafeed.ui.reader.viewer.pager; import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v4.content.ContextCompat; +import android.view.Gravity; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; @@ -53,7 +54,7 @@ public class PagerReaderFragment extends BaseFragment { public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { View view = inflater.inflate(R.layout.item_pager_reader, container, false); ButterKnife.bind(this, view); - ReaderActivity activity = (ReaderActivity) getActivity(); + ReaderActivity activity = getReaderActivity(); BaseReader parentFragment = (BaseReader) getParentFragment(); if (activity.getReaderTheme() == ReaderActivity.BLACK_THEME) { @@ -67,12 +68,17 @@ public class PagerReaderFragment extends BaseFragment { imageView.setMinimumScaleType(SubsamplingScaleImageView.SCALE_TYPE_CENTER_INSIDE); imageView.setRegionDecoderClass(parentFragment.getRegionDecoderClass()); imageView.setOnTouchListener((v, motionEvent) -> parentFragment.onImageTouch(motionEvent)); + imageView.setOnImageEventListener(new SubsamplingScaleImageView.DefaultOnImageEventListener() { + @Override + public void onImageLoadError(Exception e) { + showImageLoadError(); + } + }); retryButton.setOnTouchListener((v, event) -> { if (event.getAction() == MotionEvent.ACTION_UP) { if (page != null) activity.getPresenter().retryPage(page); - return true; } return true; }); @@ -121,6 +127,21 @@ public class PagerReaderFragment extends BaseFragment { retryButton.setVisibility(View.GONE); } + private void showImageLoadError() { + ViewGroup view = (ViewGroup) getView(); + if (view == null) + return; + + TextView errorText = new TextView(getContext()); + errorText.setGravity(Gravity.CENTER); + errorText.setText(R.string.decode_image_error); + errorText.setTextColor(getReaderActivity().getReaderTheme() == ReaderActivity.BLACK_THEME ? + ContextCompat.getColor(getContext(), R.color.light_grey) : + ContextCompat.getColor(getContext(), R.color.primary_text)); + + view.addView(errorText); + } + private void processStatus(int status) { switch (status) { case Page.QUEUE: @@ -191,4 +212,8 @@ public class PagerReaderFragment extends BaseFragment { } } + private ReaderActivity getReaderActivity() { + return (ReaderActivity) getActivity(); + } + } diff --git a/app/src/main/java/eu/kanade/mangafeed/widget/PTSansTextView.java b/app/src/main/java/eu/kanade/mangafeed/widget/PTSansTextView.java index 2486669e9..b74ae96bd 100644 --- a/app/src/main/java/eu/kanade/mangafeed/widget/PTSansTextView.java +++ b/app/src/main/java/eu/kanade/mangafeed/widget/PTSansTextView.java @@ -2,6 +2,7 @@ package eu.kanade.mangafeed.widget; import android.content.Context; import android.content.res.TypedArray; +import android.graphics.Canvas; import android.graphics.Typeface; import android.util.AttributeSet; import android.widget.TextView; @@ -49,4 +50,11 @@ public class PTSansTextView extends TextView { values.recycle(); } + + @Override + public void draw(Canvas canvas) { + // Draw two times for a more visible shadow around the text + super.draw(canvas); + super.draw(canvas); + } } diff --git a/app/src/main/res/layout/item_catalogue.xml b/app/src/main/res/layout/item_catalogue.xml index ffa8e4b02..9e57bfd87 100644 --- a/app/src/main/res/layout/item_catalogue.xml +++ b/app/src/main/res/layout/item_catalogue.xml @@ -46,16 +46,11 @@ android:src="@drawable/ic_action_favorite_blue" android:visibility="invisible"/> - + android:background="@color/manga_cover_title_background"> - + diff --git a/app/src/main/res/layout/library_tab_layout.xml b/app/src/main/res/layout/library_tab_layout.xml index 0bd6debce..1fb589cdc 100644 --- a/app/src/main/res/layout/library_tab_layout.xml +++ b/app/src/main/res/layout/library_tab_layout.xml @@ -7,7 +7,8 @@ android:layout_height="wrap_content" android:theme="@style/AppTheme.Overlay.Dark" android:background="@color/colorPrimary" - android:elevation="4dp" + android:visibility="gone" + app:elevation="4dp" app:tabGravity="center" app:tabMode="scrollable" app:tabMinWidth="75dp" diff --git a/app/src/main/res/layout/pref_library_columns.xml b/app/src/main/res/layout/pref_library_columns.xml index fa180b338..3fbcb8d4c 100644 --- a/app/src/main/res/layout/pref_library_columns.xml +++ b/app/src/main/res/layout/pref_library_columns.xml @@ -4,7 +4,10 @@ android:orientation="horizontal" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingTop="15dp"> + android:paddingTop="@dimen/dialog_margin_top_content" + android:paddingLeft="@dimen/dialog_content_padding" + android:paddingRight="@dimen/dialog_content_padding" + android:paddingBottom="@dimen/dialog_content_padding"> \ No newline at end of file diff --git a/app/src/main/res/layout/toolbar.xml b/app/src/main/res/layout/toolbar.xml index 92084e99e..925b4cdff 100644 --- a/app/src/main/res/layout/toolbar.xml +++ b/app/src/main/res/layout/toolbar.xml @@ -5,6 +5,6 @@ android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:background="@color/colorPrimary" - android:elevation="4dp" + app:elevation="4dp" android:theme="@style/AppTheme.ActionBar" app:layout_scrollFlags="scroll|enterAlways|snap"/> \ No newline at end of file diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index cc8437e95..746a25f81 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -23,6 +23,7 @@ @color/colorPrimaryLight @color/colorAccent + #55333333 @color/md_grey_50 @color/md_light_dividers @@ -30,4 +31,5 @@ #AAE9E9E9 #99252525 @color/colorPrimarySuperDark + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index 9445bffbe..970ef0afe 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -8,6 +8,9 @@ 16dp 16dp + 24dp + 20dp + 24sp 22sp 20sp diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ddd25f5fa..4fc74f371 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,7 +59,7 @@ About - Number of columns + Library mangas per row Portrait Landscape Default @@ -165,6 +165,7 @@ Chapter %1$s Next chapter not found Previous chapter not found + The image could not be loaded.\nTry to change the image decoder Update progress: %1$d/%2$d diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 4757dda11..230f34198 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -7,17 +7,15 @@ @style/AlertDialogStyle @style/OptionsMenuTextColor @color/primary_text - true true - + + +