mirror of
https://github.com/mihonapp/mihon.git
synced 2024-12-24 18:08:24 +01:00
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).
This commit is contained in:
parent
8be44c209c
commit
201650ced7
@ -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);
|
||||
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
@ -46,16 +46,11 @@
|
||||
android:src="@drawable/ic_action_favorite_blue"
|
||||
android:visibility="invisible"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/footerLinearLayout"
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="36dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_alignBottom="@+id/thumbnail"
|
||||
android:layout_alignLeft="@+id/unreadText"
|
||||
android:layout_alignStart="@+id/unreadText"
|
||||
android:background="@color/white"
|
||||
android:gravity="center"
|
||||
android:orientation="vertical">
|
||||
android:background="@color/manga_cover_title_background">
|
||||
|
||||
<eu.kanade.mangafeed.widget.PTSansTextView
|
||||
android:id="@+id/title"
|
||||
@ -66,13 +61,16 @@
|
||||
android:lineSpacingExtra="-4dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="2"
|
||||
android:paddingLeft="8dp"
|
||||
android:paddingRight="8dp"
|
||||
android:textColor="@color/primary_text"
|
||||
android:padding="8dp"
|
||||
android:textColor="@color/white"
|
||||
android:textSize="14sp"
|
||||
android:shadowDx="0"
|
||||
android:shadowDy="0"
|
||||
android:shadowColor="@color/primary_text"
|
||||
android:shadowRadius="4"
|
||||
tools:text="Sample name"/>
|
||||
|
||||
</LinearLayout>
|
||||
</FrameLayout>
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
@ -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"
|
||||
|
@ -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">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="0dp"
|
||||
|
@ -8,5 +8,5 @@
|
||||
android:theme="@style/AppTheme.Overlay.Dark"
|
||||
app:tabGravity="fill"
|
||||
android:background="@color/colorPrimary"
|
||||
android:elevation="4dp"
|
||||
app:elevation="4dp"
|
||||
app:tabIndicatorColor="@color/white"/>
|
@ -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"/>
|
@ -23,6 +23,7 @@
|
||||
<color name="list_choice_pressed_bg_light">@color/colorPrimaryLight</color>
|
||||
|
||||
<color name="manga_unread_bg">@color/colorAccent</color>
|
||||
<color name="manga_cover_title_background">#55333333</color>
|
||||
|
||||
<color name="super_light_grey">@color/md_grey_50</color>
|
||||
<color name="line_grey">@color/md_light_dividers</color>
|
||||
@ -30,4 +31,5 @@
|
||||
<color name="page_number_background">#AAE9E9E9</color>
|
||||
<color name="page_number_background_black">#99252525</color>
|
||||
<color name="reader_menu_background">@color/colorPrimarySuperDark</color>
|
||||
|
||||
</resources>
|
@ -8,6 +8,9 @@
|
||||
<dimen name="margin_right">16dp</dimen>
|
||||
<dimen name="fab_margin">16dp</dimen>
|
||||
|
||||
<dimen name="dialog_content_padding">24dp</dimen>
|
||||
<dimen name="dialog_margin_top_content">20dp</dimen>
|
||||
|
||||
<dimen name="text_headline">24sp</dimen>
|
||||
<dimen name="text_large_title">22sp</dimen>
|
||||
<dimen name="text_title">20sp</dimen>
|
||||
|
@ -59,7 +59,7 @@
|
||||
<string name="pref_category_about">About</string>
|
||||
|
||||
<!-- General section -->
|
||||
<string name="pref_library_columns">Number of columns</string>
|
||||
<string name="pref_library_columns">Library mangas per row</string>
|
||||
<string name="portrait">Portrait</string>
|
||||
<string name="landscape">Landscape</string>
|
||||
<string name="default_columns">Default</string>
|
||||
@ -165,6 +165,7 @@
|
||||
<string name="chapter_subtitle">Chapter %1$s</string>
|
||||
<string name="no_next_chapter">Next chapter not found</string>
|
||||
<string name="no_previous_chapter">Previous chapter not found</string>
|
||||
<string name="decode_image_error">The image could not be loaded.\nTry to change the image decoder</string>
|
||||
|
||||
<!-- Library update service notifications -->
|
||||
<string name="notification_progress">Update progress: %1$d/%2$d</string>
|
||||
|
@ -7,17 +7,15 @@
|
||||
<item name="alertDialogTheme">@style/AlertDialogStyle</item>
|
||||
<item name="android:itemTextAppearance">@style/OptionsMenuTextColor</item>
|
||||
<item name="android:textColor">@color/primary_text</item>
|
||||
<item name="android:windowActionModeOverlay">true</item>
|
||||
<item name="windowActionModeOverlay">true</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.ActionBar" parent="AppTheme">
|
||||
<item name="android:textColorPrimary">@color/white</item>
|
||||
<item name="android:itemTextAppearance">@style/OptionsMenuTextColor</item>
|
||||
<style name="AppTheme.ActionBar" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
<item name="android:spinnerItemStyle">@style/ActionBarSpinner</item>
|
||||
<item name="android:actionModeBackground">@color/colorPrimarySuperDark</item>
|
||||
<item name="android:spinnerDropDownItemStyle">@style/ActionBarSpinnerItem</item>
|
||||
<item name="actionModeBackground">@color/colorPrimarySuperDark</item>
|
||||
<item name="colorControlNormal">@color/white</item>
|
||||
<item name="popupTheme">@style/ThemeOverlay.AppCompat.Light</item>
|
||||
<item name="colorAccent">@color/white</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Overlay.Dark" parent="ThemeOverlay.AppCompat.Dark.ActionBar">
|
||||
@ -43,6 +41,10 @@
|
||||
<item name="android:textColorHint">@color/hint_foreground_material_dark</item>
|
||||
</style>
|
||||
|
||||
<style name="ActionBarSpinnerItem" parent="@style/Widget.AppCompat.DropDownItem.Spinner">
|
||||
<item name="android:background">@color/background_material_light</item>
|
||||
</style>
|
||||
|
||||
<style name="AppTheme.Popup" parent="@style/AppTheme.Overlay.Dark">
|
||||
<item name="colorAccent">@color/white</item>
|
||||
<item name="android:background">@color/colorPrimary</item>
|
||||
@ -51,7 +53,7 @@
|
||||
|
||||
<style name="AppTheme.GridView" parent="AppTheme">
|
||||
<item name="android:layout_width">match_parent</item>
|
||||
<item name="android:padding">10dp</item>
|
||||
<item name="android:padding">5dp</item>
|
||||
<item name="android:layout_height">match_parent</item>
|
||||
<item name="android:clipToPadding">false</item>
|
||||
<item name="android:gravity">top|left</item>
|
||||
@ -115,4 +117,5 @@
|
||||
<item name="android:layout_height">36dp</item>
|
||||
<item name="android:gravity">center</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user