mirror of
https://github.com/mihonapp/mihon.git
synced 2024-11-21 20:47:03 -05:00
Add more settings to the reader
This commit is contained in:
parent
5e2269df14
commit
e66ba4d834
22 changed files with 301 additions and 84 deletions
|
@ -4,6 +4,7 @@ import android.content.Context;
|
|||
import android.content.SharedPreferences;
|
||||
import android.preference.PreferenceManager;
|
||||
|
||||
import com.f2prateek.rx.preferences.Preference;
|
||||
import com.f2prateek.rx.preferences.RxSharedPreferences;
|
||||
|
||||
import eu.kanade.mangafeed.R;
|
||||
|
@ -36,21 +37,24 @@ public class PreferencesHelper {
|
|||
prefs.edit().clear().apply();
|
||||
}
|
||||
|
||||
public boolean isHideStatusBarSet() {
|
||||
return prefs.getBoolean(getKey(R.string.pref_hide_status_bar_key), true);
|
||||
public Preference<Boolean> lockOrientation() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_lock_orientation_key), true);
|
||||
}
|
||||
|
||||
public boolean isOrientationLocked() {
|
||||
return prefs.getBoolean(getKey(R.string.pref_lock_orientation_key), true);
|
||||
public Preference<Boolean> enableTransitions() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_enable_transitions_key), true);
|
||||
}
|
||||
|
||||
public void setOrientationLocked(boolean lock) {
|
||||
prefs.edit().putBoolean(getKey(R.string.pref_lock_orientation_key), lock).apply();
|
||||
public Preference<Boolean> showPageNumber() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_show_page_number_key), true);
|
||||
}
|
||||
|
||||
public Observable<Boolean> isOrientationLockedObservable() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_lock_orientation_key), true)
|
||||
.asObservable();
|
||||
public Preference<Boolean> hideStatusBar() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_hide_status_bar_key), true);
|
||||
}
|
||||
|
||||
public Preference<Boolean> keepScreenOn() {
|
||||
return rxPrefs.getBoolean(getKey(R.string.pref_keep_screen_on_key), true);
|
||||
}
|
||||
|
||||
public int getDefaultViewer() {
|
||||
|
|
|
@ -165,7 +165,7 @@ public class ChaptersFragment extends BaseRxFragment<ChaptersPresenter> implemen
|
|||
return true;
|
||||
} else {
|
||||
getPresenter().onChapterClicked(adapter.getItem(position));
|
||||
Intent intent = ReaderActivity.newInstance(getActivity());
|
||||
Intent intent = ReaderActivity.newIntent(getActivity());
|
||||
startActivity(intent);
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -2,11 +2,13 @@ package eu.kanade.mangafeed.ui.reader;
|
|||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.Surface;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.WindowManager;
|
||||
|
@ -34,6 +36,7 @@ import eu.kanade.mangafeed.ui.reader.viewer.webtoon.WebtoonReader;
|
|||
import eu.kanade.mangafeed.util.ToastUtil;
|
||||
import icepick.Icepick;
|
||||
import nucleus.factory.RequiresPresenter;
|
||||
import rx.subscriptions.CompositeSubscription;
|
||||
|
||||
@RequiresPresenter(ReaderPresenter.class)
|
||||
public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
||||
|
@ -42,20 +45,20 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
@Bind(R.id.reader) FrameLayout container;
|
||||
@Bind(R.id.toolbar) Toolbar toolbar;
|
||||
|
||||
@Inject PreferencesHelper prefs;
|
||||
@Inject PreferencesHelper preferences;
|
||||
|
||||
private BaseReader viewer;
|
||||
private ReaderMenu readerMenu;
|
||||
|
||||
private int uiFlags;
|
||||
private CompositeSubscription subscriptions;
|
||||
|
||||
private static final int LEFT_TO_RIGHT = 1;
|
||||
private static final int RIGHT_TO_LEFT = 2;
|
||||
private static final int VERTICAL = 3;
|
||||
private static final int WEBTOON = 4;
|
||||
|
||||
|
||||
public static Intent newInstance(Context context) {
|
||||
public static Intent newIntent(Context context) {
|
||||
return new Intent(context, ReaderActivity.class);
|
||||
}
|
||||
|
||||
|
@ -67,14 +70,16 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
ButterKnife.bind(this);
|
||||
|
||||
setupToolbar(toolbar);
|
||||
subscriptions = new CompositeSubscription();
|
||||
|
||||
readerMenu = new ReaderMenu(this, prefs);
|
||||
readerMenu = new ReaderMenu(this);
|
||||
Icepick.restoreInstanceState(readerMenu, savedState);
|
||||
if (savedState != null && readerMenu.showing)
|
||||
readerMenu.show(false);
|
||||
|
||||
createUiHideFlags();
|
||||
enableHardwareAcceleration();
|
||||
|
||||
initializeSettings();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -86,7 +91,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
hideSystemUI();
|
||||
setSystemUiVisibility();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -102,16 +107,17 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
super.onSaveInstanceState(outState);
|
||||
}
|
||||
|
||||
private void createUiHideFlags() {
|
||||
private void createUiHideFlags(boolean statusBarHidden) {
|
||||
uiFlags = 0;
|
||||
uiFlags |= View.SYSTEM_UI_FLAG_HIDE_NAVIGATION;
|
||||
if (prefs.isHideStatusBarSet())
|
||||
if (statusBarHidden)
|
||||
uiFlags |= View.SYSTEM_UI_FLAG_FULLSCREEN;
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT)
|
||||
uiFlags |= View.SYSTEM_UI_FLAG_IMMERSIVE_STICKY;
|
||||
}
|
||||
|
||||
public void onChapterReady(List<Page> pages, Manga manga, Chapter chapter) {
|
||||
viewer = getViewer(manga);
|
||||
viewer = createViewer(manga);
|
||||
viewer.onPageListReady(pages);
|
||||
viewer.updatePageNumber();
|
||||
readerMenu.onChapterReady(pages.size(), manga, chapter);
|
||||
|
@ -132,7 +138,7 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
viewer.setSelectedPage(pageIndex);
|
||||
}
|
||||
|
||||
public void hideSystemUI() {
|
||||
public void setSystemUiVisibility() {
|
||||
getWindow().getDecorView().setSystemUiVisibility(uiFlags);
|
||||
}
|
||||
|
||||
|
@ -154,8 +160,12 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
return container;
|
||||
}
|
||||
|
||||
private BaseReader getViewer(Manga manga) {
|
||||
int mangaViewer = manga.viewer == 0 ? prefs.getDefaultViewer() : manga.viewer;
|
||||
public PreferencesHelper getPreferences() {
|
||||
return preferences;
|
||||
}
|
||||
|
||||
private BaseReader createViewer(Manga manga) {
|
||||
int mangaViewer = manga.viewer == 0 ? preferences.getDefaultViewer() : manga.viewer;
|
||||
|
||||
switch (mangaViewer) {
|
||||
case LEFT_TO_RIGHT: default:
|
||||
|
@ -169,4 +179,69 @@ public class ReaderActivity extends BaseRxActivity<ReaderPresenter> {
|
|||
}
|
||||
}
|
||||
|
||||
private void initializeSettings() {
|
||||
subscriptions.add(preferences.showPageNumber()
|
||||
.asObservable()
|
||||
.subscribe(this::setPageNumberVisibility));
|
||||
|
||||
subscriptions.add(preferences.lockOrientation()
|
||||
.asObservable()
|
||||
.subscribe(this::setOrientation));
|
||||
|
||||
subscriptions.add(preferences.hideStatusBar()
|
||||
.asObservable()
|
||||
.subscribe(this::setStatusBarVisibility));
|
||||
|
||||
preferences.keepScreenOn()
|
||||
.asObservable()
|
||||
.subscribe(this::setKeepScreenOn);
|
||||
}
|
||||
|
||||
private void setOrientation(boolean locked) {
|
||||
if (locked) {
|
||||
int orientation;
|
||||
int rotation = ((WindowManager) getSystemService(
|
||||
Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_0:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
||||
break;
|
||||
default:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
||||
break;
|
||||
}
|
||||
setRequestedOrientation(orientation);
|
||||
} else {
|
||||
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
}
|
||||
}
|
||||
|
||||
private void setPageNumberVisibility(boolean visible) {
|
||||
pageNumber.setVisibility(visible ? View.VISIBLE : View.INVISIBLE);
|
||||
}
|
||||
|
||||
private void setStatusBarVisibility(boolean hidden) {
|
||||
createUiHideFlags(hidden);
|
||||
setSystemUiVisibility();
|
||||
}
|
||||
|
||||
private void setKeepScreenOn(boolean enabled) {
|
||||
if (enabled) {
|
||||
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
} else {
|
||||
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
|
||||
}
|
||||
}
|
||||
|
||||
protected void setMangaDefaultViewer(int viewer) {
|
||||
getPresenter().updateMangaViewer(viewer);
|
||||
recreate();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -2,16 +2,18 @@ package eu.kanade.mangafeed.ui.reader;
|
|||
|
||||
import android.app.Dialog;
|
||||
import android.content.Context;
|
||||
import android.content.pm.ActivityInfo;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.Surface;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.WindowManager;
|
||||
import android.view.WindowManager.LayoutParams;
|
||||
import android.view.animation.Animation;
|
||||
import android.view.animation.AnimationUtils;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.PopupWindow;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
@ -37,18 +39,21 @@ public class ReaderMenu {
|
|||
@Bind(R.id.total_pages) TextView totalPages;
|
||||
@Bind(R.id.lock_orientation) ImageButton lockOrientation;
|
||||
@Bind(R.id.reader_selector) ImageButton readerSelector;
|
||||
|
||||
@Bind(R.id.reader_extra_settings) ImageButton extraSettings;
|
||||
|
||||
private ReaderActivity activity;
|
||||
private PreferencesHelper preferences;
|
||||
|
||||
@State boolean showing;
|
||||
private PopupWindow popupWindow;
|
||||
|
||||
private DecimalFormat decimalFormat;
|
||||
|
||||
private CompositeSubscription subscriptions;
|
||||
|
||||
public ReaderMenu(ReaderActivity activity, PreferencesHelper preferences) {
|
||||
public ReaderMenu(ReaderActivity activity) {
|
||||
this.activity = activity;
|
||||
this.preferences = preferences;
|
||||
this.preferences = activity.getPreferences();
|
||||
ButterKnife.bind(this, activity);
|
||||
|
||||
// Intercept all image events in this layout
|
||||
|
@ -94,6 +99,8 @@ public class ReaderMenu {
|
|||
Animation bottomMenuAnimation = AnimationUtils.loadAnimation(activity, R.anim.exit_to_bottom);
|
||||
bottomMenu.startAnimation(bottomMenuAnimation);
|
||||
|
||||
popupWindow.dismiss();
|
||||
|
||||
showing = false;
|
||||
}
|
||||
|
||||
|
@ -116,11 +123,18 @@ public class ReaderMenu {
|
|||
|
||||
private void initializeOptions() {
|
||||
// Orientation changes
|
||||
lockOrientation.setOnClickListener(v ->
|
||||
preferences.setOrientationLocked(!preferences.isOrientationLocked()));
|
||||
subscriptions.add(preferences.lockOrientation().asObservable()
|
||||
.subscribe(locked -> {
|
||||
int resourceId = !locked ? R.drawable.ic_screen_rotation :
|
||||
activity.getResources().getConfiguration().orientation == 1 ?
|
||||
R.drawable.ic_screen_lock_portrait :
|
||||
R.drawable.ic_screen_lock_landscape;
|
||||
|
||||
subscriptions.add(preferences.isOrientationLockedObservable()
|
||||
.subscribe(this::onOrientationOptionChanged));
|
||||
lockOrientation.setImageResource(resourceId);
|
||||
}));
|
||||
|
||||
lockOrientation.setOnClickListener(v ->
|
||||
preferences.lockOrientation().set(!preferences.lockOrientation().get()));
|
||||
|
||||
// Reader selector
|
||||
readerSelector.setOnClickListener(v -> {
|
||||
|
@ -128,57 +142,84 @@ public class ReaderMenu {
|
|||
final Dialog dialog = new AlertDialog.Builder(activity)
|
||||
.setSingleChoiceItems(R.array.viewers_selector, manga.viewer, (d, which) -> {
|
||||
if (manga.viewer != which) {
|
||||
activity.getPresenter().updateMangaViewer(which);
|
||||
activity.recreate();
|
||||
activity.setMangaDefaultViewer(which);
|
||||
}
|
||||
d.dismiss();
|
||||
})
|
||||
.create();
|
||||
showImmersiveDialog(dialog);
|
||||
});
|
||||
|
||||
// Hack to not leave immersive mode
|
||||
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||
WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
dialog.getWindow().getDecorView().setSystemUiVisibility(
|
||||
activity.getWindow().getDecorView().getSystemUiVisibility());
|
||||
dialog.show();
|
||||
dialog.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.updateViewLayout(activity.getWindow().getDecorView(), activity.getWindow().getAttributes());
|
||||
// Extra settings menu
|
||||
final View popupView = activity.getLayoutInflater().inflate(R.layout.reader_popup, null);
|
||||
popupWindow = new SettingsPopupWindow(popupView);
|
||||
|
||||
extraSettings.setOnClickListener(v -> {
|
||||
if (!popupWindow.isShowing())
|
||||
popupWindow.showAtLocation(extraSettings,
|
||||
Gravity.BOTTOM | Gravity.RIGHT, 0, bottomMenu.getHeight());
|
||||
else
|
||||
popupWindow.dismiss();
|
||||
});
|
||||
}
|
||||
|
||||
private void onOrientationOptionChanged(boolean locked) {
|
||||
if (locked)
|
||||
lockOrientation();
|
||||
else
|
||||
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
|
||||
int resourceId = !locked ? R.drawable.ic_screen_rotation :
|
||||
activity.getResources().getConfiguration().orientation == 1 ?
|
||||
R.drawable.ic_screen_lock_portrait :
|
||||
R.drawable.ic_screen_lock_landscape;
|
||||
|
||||
lockOrientation.setImageResource(resourceId);
|
||||
private void showImmersiveDialog(Dialog dialog) {
|
||||
// Hack to not leave immersive mode
|
||||
dialog.getWindow().setFlags(LayoutParams.FLAG_NOT_FOCUSABLE,
|
||||
LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
dialog.getWindow().getDecorView().setSystemUiVisibility(
|
||||
activity.getWindow().getDecorView().getSystemUiVisibility());
|
||||
dialog.show();
|
||||
dialog.getWindow().clearFlags(LayoutParams.FLAG_NOT_FOCUSABLE);
|
||||
WindowManager wm = (WindowManager) activity.getSystemService(Context.WINDOW_SERVICE);
|
||||
wm.updateViewLayout(activity.getWindow().getDecorView(), activity.getWindow().getAttributes());
|
||||
}
|
||||
|
||||
private void lockOrientation() {
|
||||
int orientation;
|
||||
int rotation = ((WindowManager) activity.getSystemService(
|
||||
Context.WINDOW_SERVICE)).getDefaultDisplay().getRotation();
|
||||
switch (rotation) {
|
||||
case Surface.ROTATION_0:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
|
||||
break;
|
||||
case Surface.ROTATION_90:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
|
||||
break;
|
||||
case Surface.ROTATION_180:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_PORTRAIT;
|
||||
break;
|
||||
default:
|
||||
orientation = ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE;
|
||||
break;
|
||||
class SettingsPopupWindow extends PopupWindow {
|
||||
|
||||
@Bind(R.id.enable_transitions) CheckBox enableTransitions;
|
||||
@Bind(R.id.show_page_number) CheckBox showPageNumber;
|
||||
@Bind(R.id.hide_status_bar) CheckBox hideStatusBar;
|
||||
@Bind(R.id.keep_screen_on) CheckBox keepScreenOn;
|
||||
|
||||
public SettingsPopupWindow(View view) {
|
||||
super(view, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
setAnimationStyle(R.style.reader_settings_popup_animation);
|
||||
ButterKnife.bind(this, view);
|
||||
initializePopupMenu();
|
||||
}
|
||||
activity.setRequestedOrientation(orientation);
|
||||
|
||||
private void initializePopupMenu() {
|
||||
subscriptions.add(preferences.enableTransitions()
|
||||
.asObservable()
|
||||
.subscribe(enableTransitions::setChecked));
|
||||
|
||||
subscriptions.add(preferences.showPageNumber()
|
||||
.asObservable()
|
||||
.subscribe(showPageNumber::setChecked));
|
||||
|
||||
subscriptions.add(preferences.hideStatusBar()
|
||||
.asObservable()
|
||||
.subscribe(hideStatusBar::setChecked));
|
||||
|
||||
subscriptions.add(preferences.keepScreenOn()
|
||||
.asObservable()
|
||||
.subscribe(keepScreenOn::setChecked));
|
||||
|
||||
enableTransitions.setOnCheckedChangeListener((view, isChecked) ->
|
||||
preferences.enableTransitions().set(isChecked));
|
||||
|
||||
showPageNumber.setOnCheckedChangeListener((view, isChecked) ->
|
||||
preferences.showPageNumber().set(isChecked));
|
||||
|
||||
hideStatusBar.setOnCheckedChangeListener((view, isChecked) ->
|
||||
preferences.hideStatusBar().set(isChecked));
|
||||
|
||||
keepScreenOn.setOnCheckedChangeListener((view, isChecked) ->
|
||||
preferences.keepScreenOn().set(isChecked));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class PageSeekBarChangeListener implements SeekBar.OnSeekBarChangeListener {
|
||||
|
@ -214,4 +255,5 @@ public class ReaderMenu {
|
|||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import eu.kanade.mangafeed.data.source.model.Page;
|
|||
import eu.kanade.mangafeed.ui.reader.ReaderActivity;
|
||||
import eu.kanade.mangafeed.ui.reader.viewer.base.BaseReader;
|
||||
import eu.kanade.mangafeed.ui.reader.viewer.common.ViewPagerReaderAdapter;
|
||||
import rx.Subscription;
|
||||
|
||||
public abstract class HorizontalReader extends BaseReader {
|
||||
|
||||
|
@ -18,11 +19,17 @@ public abstract class HorizontalReader extends BaseReader {
|
|||
|
||||
protected ViewPagerReaderAdapter adapter;
|
||||
|
||||
private boolean transitions;
|
||||
private Subscription transitionsSubscription;
|
||||
|
||||
public HorizontalReader(ReaderActivity activity) {
|
||||
super(activity);
|
||||
activity.getLayoutInflater().inflate(R.layout.reader_horizontal, container);
|
||||
ButterKnife.bind(this, container);
|
||||
|
||||
transitionsSubscription = activity.getPreferences().enableTransitions().asObservable()
|
||||
.subscribe(value -> transitions = value);
|
||||
|
||||
viewPager.setOffscreenPageLimit(3);
|
||||
viewPager.addOnPageChangeListener(new HorizontalViewPager.SimpleOnPageChangeListener() {
|
||||
@Override
|
||||
|
@ -42,7 +49,22 @@ public abstract class HorizontalReader extends BaseReader {
|
|||
onLastPageOut();
|
||||
}
|
||||
});
|
||||
viewPager.setOnChapterSingleTapListener(activity::onCenterSingleTap);
|
||||
viewPager.setOnChapterSingleTapListener(new HorizontalViewPager.OnChapterSingleTapListener() {
|
||||
@Override
|
||||
public void onCenterTap() {
|
||||
activity.onCenterSingleTap();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLeftSideTap() {
|
||||
viewPager.setCurrentItem(viewPager.getCurrentItem() - 1, transitions);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRightSideTap() {
|
||||
viewPager.setCurrentItem(viewPager.getCurrentItem() + 1, transitions);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -67,6 +89,11 @@ public abstract class HorizontalReader extends BaseReader {
|
|||
return viewPager.onImageTouch(motionEvent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void destroySubscriptions() {
|
||||
transitionsSubscription.unsubscribe();
|
||||
}
|
||||
|
||||
public abstract void onFirstPageOut();
|
||||
public abstract void onLastPageOut();
|
||||
|
||||
|
|
|
@ -90,7 +90,9 @@ public class HorizontalViewPager extends ViewPager {
|
|||
}
|
||||
|
||||
public interface OnChapterSingleTapListener {
|
||||
void onSingleTap();
|
||||
void onCenterTap();
|
||||
void onLeftSideTap();
|
||||
void onRightSideTap();
|
||||
}
|
||||
|
||||
public void setOnChapterBoundariesOutListener(OnChapterBoundariesOutListener onChapterBoundariesOutListener) {
|
||||
|
@ -111,7 +113,9 @@ public class HorizontalViewPager extends ViewPager {
|
|||
|
||||
if (positionX < getWidth() * LEFT_REGION) {
|
||||
if (position != 0) {
|
||||
setCurrentItem(position - 1, true);
|
||||
if (mOnChapterSingleTapListener != null) {
|
||||
mOnChapterSingleTapListener.onLeftSideTap();
|
||||
}
|
||||
} else {
|
||||
if (mOnChapterBoundariesOutListener != null) {
|
||||
mOnChapterBoundariesOutListener.onFirstPageOutEvent();
|
||||
|
@ -119,7 +123,9 @@ public class HorizontalViewPager extends ViewPager {
|
|||
}
|
||||
} else if (positionX > getWidth() * RIGHT_REGION) {
|
||||
if (position != getAdapter().getCount() - 1) {
|
||||
setCurrentItem(position + 1, true);
|
||||
if (mOnChapterSingleTapListener != null) {
|
||||
mOnChapterSingleTapListener.onRightSideTap();
|
||||
}
|
||||
} else {
|
||||
if (mOnChapterBoundariesOutListener != null) {
|
||||
mOnChapterBoundariesOutListener.onLastPageOutEvent();
|
||||
|
@ -127,7 +133,7 @@ public class HorizontalViewPager extends ViewPager {
|
|||
}
|
||||
} else {
|
||||
if (mOnChapterSingleTapListener != null) {
|
||||
mOnChapterSingleTapListener.onSingleTap();
|
||||
mOnChapterSingleTapListener.onCenterTap();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shareInterpolator="false">
|
||||
<translate
|
||||
android:duration="400"
|
||||
android:duration="200"
|
||||
android:fromXDelta="-100%"
|
||||
android:toXDelta="0%" />
|
||||
</set>
|
|
@ -2,7 +2,7 @@
|
|||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shareInterpolator="false">
|
||||
<translate
|
||||
android:duration="400"
|
||||
android:duration="200"
|
||||
android:fromXDelta="100%"
|
||||
android:toXDelta="0%" />
|
||||
</set>
|
|
@ -2,7 +2,7 @@
|
|||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shareInterpolator="false">
|
||||
<translate
|
||||
android:duration="400"
|
||||
android:duration="200"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="-100%" />
|
||||
</set>
|
|
@ -2,7 +2,7 @@
|
|||
<set xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:shareInterpolator="false">
|
||||
<translate
|
||||
android:duration="400"
|
||||
android:duration="200"
|
||||
android:fromXDelta="0%"
|
||||
android:toXDelta="100%" />
|
||||
</set>
|
BIN
app/src/main/res/drawable-hdpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-hdpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 183 B |
BIN
app/src/main/res/drawable-ldpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-ldpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 156 B |
BIN
app/src/main/res/drawable-mdpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-mdpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 142 B |
BIN
app/src/main/res/drawable-xhdpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-xhdpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 239 B |
BIN
app/src/main/res/drawable-xxhdpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-xxhdpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 363 B |
BIN
app/src/main/res/drawable-xxxhdpi/ic_more_vert.png
Normal file
BIN
app/src/main/res/drawable-xxxhdpi/ic_more_vert.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 588 B |
|
@ -77,13 +77,15 @@
|
|||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/reader_selector"
|
||||
android:src="@drawable/ic_view_carousel"
|
||||
android:background="?android:selectableItemBackground" />
|
||||
<ImageButton
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:id="@+id/reader_selector"
|
||||
android:src="@drawable/ic_view_carousel"
|
||||
android:id="@+id/reader_extra_settings"
|
||||
android:src="@drawable/ic_more_vert"
|
||||
android:background="?android:selectableItemBackground" />
|
||||
|
||||
</LinearLayout>
|
||||
|
|
39
app/src/main/res/layout/reader_popup.xml
Normal file
39
app/src/main/res/layout/reader_popup.xml
Normal file
|
@ -0,0 +1,39 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:orientation="vertical" android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="#333333"
|
||||
android:paddingRight="10dp"
|
||||
android:paddingLeft="5dp"
|
||||
android:paddingTop="5dp"
|
||||
android:paddingBottom="5dp">
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/enable_transitions"
|
||||
style="@style/grey_text"
|
||||
android:text="@string/pref_enable_transitions"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/show_page_number"
|
||||
style="@style/grey_text"
|
||||
android:text="@string/pref_show_page_number"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/hide_status_bar"
|
||||
style="@style/grey_text"
|
||||
android:text="@string/pref_hide_status_bar"/>
|
||||
|
||||
<CheckBox
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:id="@+id/keep_screen_on"
|
||||
style="@style/grey_text"
|
||||
android:text="Keep screen on"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -3,9 +3,14 @@
|
|||
<string name="pref_category_reader_key">pref_category_reader_key</string>
|
||||
<string name="pref_category_accounts_key">pref_category_accounts_key</string>
|
||||
<string name="pref_category_downloads_key">pref_category_downloads_key</string>
|
||||
|
||||
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
||||
<string name="pref_hide_status_bar_key">pref_hide_status_bar_key</string>
|
||||
<string name="pref_lock_orientation_key">pref_lock_orientation_key</string>
|
||||
<string name="pref_default_viewer_key">pref_default_viewer_key</string>
|
||||
<string name="pref_enable_transitions_key">pref_enable_transitions_key</string>
|
||||
<string name="pref_show_page_number_key">pref_show_page_number_key</string>
|
||||
<string name="pref_keep_screen_on_key">pref_keep_screen_on_key</string>
|
||||
|
||||
<string name="pref_download_directory_key">pref_download_directory_key</string>
|
||||
<string name="pref_download_threads_key">pref_download_threads_key</string>
|
||||
</resources>
|
|
@ -34,6 +34,9 @@
|
|||
<string name="right_to_left_viewer">Right to left</string>
|
||||
<string name="vertical_viewer">Vertical</string>
|
||||
<string name="webtoon_viewer">Webtoon (experimental)</string>
|
||||
<string name="pref_lock_orientation">Lock orientation</string>
|
||||
<string name="pref_enable_transitions">Enable transitions</string>
|
||||
<string name="pref_show_page_number">Show page number</string>
|
||||
|
||||
<!-- Downloads section -->
|
||||
<string name="pref_download_directory">Downloads directory</string>
|
||||
|
@ -83,6 +86,5 @@
|
|||
<string name="notification_completed">Update completed</string>
|
||||
<string name="notification_no_new_chapters">No new chapters found</string>
|
||||
<string name="notification_new_chapters">Found new chapters for:</string>
|
||||
<string name="pref_lock_orientation">Lock orientation</string>
|
||||
|
||||
</resources>
|
||||
|
|
|
@ -99,4 +99,11 @@
|
|||
<item name="android:singleLine">true</item>
|
||||
<item name="android:textIsSelectable">false</item>
|
||||
</style>
|
||||
<style name="reader_settings_popup_animation">
|
||||
<item name="android:windowEnterAnimation">@anim/enter_from_right</item>
|
||||
<item name="android:windowExitAnimation">@anim/exit_to_right</item>
|
||||
</style>
|
||||
<style name="grey_text">
|
||||
<item name="android:textColor">#e0e0e0</item>
|
||||
</style>
|
||||
</resources>
|
||||
|
|
|
@ -9,6 +9,14 @@
|
|||
android:key="@string/pref_lock_orientation_key"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<CheckBoxPreference android:title="@string/pref_enable_transitions"
|
||||
android:key="@string/pref_enable_transitions_key"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<CheckBoxPreference android:title="@string/pref_show_page_number"
|
||||
android:key="@string/pref_show_page_number_key"
|
||||
android:defaultValue="true" />
|
||||
|
||||
<ListPreference android:title="@string/pref_viewer_type"
|
||||
android:key="@string/pref_default_viewer_key"
|
||||
android:entries="@array/viewers"
|
||||
|
|
Loading…
Reference in a new issue