UI improvements 2

This commit is contained in:
Yuri Revich 2015-12-01 22:18:19 +03:00
parent 89683c24a8
commit d7f5787ea0
5 changed files with 45 additions and 49 deletions

View File

@ -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;
}

View File

@ -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<ChaptersPresenter> 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<ChaptersPresenter> 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<ChaptersPresenter> 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) {

View File

@ -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<ChaptersFragment> {
EventBus.getDefault().postSticky(new SourceMangaChapterEvent(source, manga, chapter));
}
public Chapter getNextUnreadChapter() {
List<Chapter> chapters = db.getNextUnreadChapter(manga).executeAsBlocking();
if(chapters.size() < 1){
return null;
}
return chapters.get(0);
}
public void markChaptersRead(Observable<Chapter> selectedChapters, boolean read) {
add(markReadSubscription = selectedChapters
.subscribeOn(Schedulers.io())

View File

@ -43,39 +43,35 @@
android:layout_height="match_parent"
android:layout_marginRight="4dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<ImageView
android:id="@+id/action_sort_up"
android:id="@+id/action_sort"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_gravity="center"
android:src="@drawable/ic_expand_less_white_36dp"
android:background="?android:selectableItemBackground"
android:title="@string/action_sort_up"
android:visible="true"/>
<ImageView
android:id="@+id/action_sort_down"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:src="@drawable/ic_expand_more_white_36dp"
android:title="@string/action_sort_down"
android:visible="true"
tools:src="@drawable/ic_expand_less_white_36dp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toEndOf="@+id/action_sort"
android:layout_toLeftOf="@+id/action_next_unread"
android:layout_toRightOf="@+id/action_sort"
android:gravity="center_vertical">
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_margin="4dp"
android:layout_margin="10dp"
android:background="@color/white"/>
<CheckBox
android:id="@+id/action_show_unread"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="1"
android:checkable="true"
android:text="@string/action_show_unread"
android:title="@string/action_show_unread"/>
@ -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"/>
<View
android:layout_width="1dp"
android:layout_height="match_parent"
android:layout_margin="10dp"
android:background="@color/white"/>
</LinearLayout>
@ -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"/>
/>
</RelativeLayout>
</android.support.v7.widget.Toolbar>

View File

@ -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"/>
<LinearLayout