From d7f5787ea021528f905bd06c2698c4e761c09ec2 Mon Sep 17 00:00:00 2001 From: Yuri Revich Date: Tue, 1 Dec 2015 22:18:19 +0300 Subject: [PATCH] UI improvements 2 --- .../data/source/base/BaseSource.java | 9 ---- .../ui/manga/chapter/ChaptersFragment.java | 30 +++++-------- .../ui/manga/chapter/ChaptersPresenter.java | 9 +++- .../res/layout/fragment_manga_chapters.xml | 44 ++++++++++--------- app/src/main/res/layout/item_catalogue.xml | 2 +- 5 files changed, 45 insertions(+), 49 deletions(-) diff --git a/app/src/main/java/eu/kanade/mangafeed/data/source/base/BaseSource.java b/app/src/main/java/eu/kanade/mangafeed/data/source/base/BaseSource.java index 5af86ef77a..4d65b037f1 100644 --- a/app/src/main/java/eu/kanade/mangafeed/data/source/base/BaseSource.java +++ b/app/src/main/java/eu/kanade/mangafeed/data/source/base/BaseSource.java @@ -5,7 +5,6 @@ import com.squareup.okhttp.Response; import org.jsoup.nodes.Document; -import java.net.URI; import java.util.List; import eu.kanade.mangafeed.data.database.models.Chapter; @@ -81,14 +80,6 @@ public abstract class BaseSource { // Get the URL of the first page that contains a source image and the page list protected String overrideChapterUrl(String defaultPageUrl) { - if(defaultPageUrl.startsWith("http")){ - try { - URI uri = new URI(defaultPageUrl); - defaultPageUrl = uri.getPath() + "?" + uri.getQuery(); - }catch (Exception ignored){ - return defaultPageUrl; - } - } return defaultPageUrl; } diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java index 1563d86d71..8478188a1e 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersFragment.java @@ -15,6 +15,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.widget.CheckBox; +import android.widget.ImageView; import java.util.List; @@ -39,9 +40,10 @@ public class ChaptersFragment extends BaseRxFragment implemen @Bind(R.id.swipe_refresh) SwipeRefreshLayout swipeRefresh; @Bind(R.id.toolbar_bottom) Toolbar toolbarBottom; - private MenuItem sortUpBtn; - private MenuItem sortDownBtn; - private CheckBox readCb; + @Bind(R.id.action_sort) ImageView sortBtn; + @Bind(R.id.action_next_unread) ImageView nextUnreadBtn; + @Bind(R.id.action_show_unread) CheckBox readCb; + @Bind(R.id.action_show_downloaded) CheckBox downloadedCb; private ChaptersAdapter adapter; @@ -69,20 +71,11 @@ public class ChaptersFragment extends BaseRxFragment implemen createAdapter(); setSwipeRefreshListener(); - toolbarBottom.inflateMenu(R.menu.chapter_filter); - - sortUpBtn = toolbarBottom.getMenu().findItem(R.id.action_sort_up); - sortDownBtn = toolbarBottom.getMenu().findItem(R.id.action_sort_down); - readCb = (CheckBox) toolbarBottom.findViewById(R.id.action_show_unread); readCb.setOnCheckedChangeListener((arg, isCheked) -> getPresenter().setReadFilter(isCheked)); - toolbarBottom.setOnMenuItemClickListener(arg0 -> { - switch (arg0.getItemId()) { - case R.id.action_sort_up: - case R.id.action_sort_down: - getPresenter().revertSortOrder(); - return true; - } - return false; + sortBtn.setOnClickListener(v->getPresenter().revertSortOrder()); + nextUnreadBtn.setOnClickListener(v->{ + getPresenter().onChapterClicked(getPresenter().getNextUnreadChapter()); + startActivity(ReaderActivity.newIntent(getActivity())); }); return view; } @@ -247,8 +240,9 @@ public class ChaptersFragment extends BaseRxFragment implemen } public void setSortIcon(boolean aToZ) { - if (sortUpBtn != null) sortUpBtn.setVisible(aToZ); - if (sortDownBtn != null) sortDownBtn.setVisible(!aToZ); + if (sortBtn != null) { + sortBtn.setImageResource(!aToZ ? R.drawable.ic_expand_less_white_36dp : R.drawable.ic_expand_more_white_36dp); + } } public void setReadFilter(boolean onlyUnread) { diff --git a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java index afdde3f9f0..3358e7f230 100644 --- a/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java +++ b/app/src/main/java/eu/kanade/mangafeed/ui/manga/chapter/ChaptersPresenter.java @@ -1,7 +1,6 @@ package eu.kanade.mangafeed.ui.manga.chapter; import android.os.Bundle; -import android.support.v7.widget.RecyclerView; import java.io.File; import java.util.List; @@ -122,6 +121,14 @@ public class ChaptersPresenter extends BasePresenter { EventBus.getDefault().postSticky(new SourceMangaChapterEvent(source, manga, chapter)); } + public Chapter getNextUnreadChapter() { + List chapters = db.getNextUnreadChapter(manga).executeAsBlocking(); + if(chapters.size() < 1){ + return null; + } + return chapters.get(0); + } + public void markChaptersRead(Observable selectedChapters, boolean read) { add(markReadSubscription = selectedChapters .subscribeOn(Schedulers.io()) diff --git a/app/src/main/res/layout/fragment_manga_chapters.xml b/app/src/main/res/layout/fragment_manga_chapters.xml index 35569d797c..6940e96a4d 100644 --- a/app/src/main/res/layout/fragment_manga_chapters.xml +++ b/app/src/main/res/layout/fragment_manga_chapters.xml @@ -43,39 +43,35 @@ android:layout_height="match_parent" android:layout_marginRight="4dp"> + + - - - - @@ -84,10 +80,17 @@ android:id="@+id/action_show_downloaded" android:layout_width="wrap_content" android:layout_height="fill_parent" + android:layout_weight="1" android:checkable="true" android:text="@string/action_show_downloaded" android:title="@string/action_show_downloaded"/> + + @@ -96,9 +99,10 @@ android:layout_width="wrap_content" android:layout_height="fill_parent" android:layout_alignParentRight="true" + android:background="?android:selectableItemBackground" android:src="@drawable/ic_play_arrow_white_36dp" android:title="@string/action_next_unread" - android:visible="true"/> + /> diff --git a/app/src/main/res/layout/item_catalogue.xml b/app/src/main/res/layout/item_catalogue.xml index 7273d1048d..eeb72151e3 100644 --- a/app/src/main/res/layout/item_catalogue.xml +++ b/app/src/main/res/layout/item_catalogue.xml @@ -38,7 +38,7 @@ android:layout_alignTop="@+id/thumbnail" android:layout_marginRight="5dp" android:layout_marginTop="5dp" - android:src="@drawable/ic_action_favorite" + android:src="@drawable/ic_action_favorite_blue" android:visibility="invisible"/>