Update
This commit is contained in:
1 parent
dc465e89a6
commit
cd852f4003
24 files changed
+456
-62
No files matched your search
@@ -20,6 +20,7 @@ import com.hippo.yorozuya.Messenger;
|
||||
|
||||
public final class Constants {
|
||||
|
||||
public static final int MESSENGER_ID_READING_DIRECTION;
|
||||
public static final int MESSENGER_ID_EH_SOURCE;
|
||||
public static final int MESSENGER_ID_SHOW_APP_STATUS;
|
||||
public static final int MESSENGER_ID_SIGN_IN_OR_OUT;
|
||||
@@ -30,6 +31,7 @@ public final class Constants {
|
||||
|
||||
static {
|
||||
Messenger messenger = Messenger.getInstance();
|
||||
MESSENGER_ID_READING_DIRECTION = messenger.newId();
|
||||
MESSENGER_ID_EH_SOURCE = messenger.newId();
|
||||
MESSENGER_ID_SHOW_APP_STATUS = messenger.newId();
|
||||
MESSENGER_ID_SIGN_IN_OR_OUT = messenger.newId();
|
||||
|
||||
@@ -714,7 +714,6 @@ public class GLView implements TouchOwner {
|
||||
public void setMinimumWidth(int minWidth) {
|
||||
mMinWidth = minWidth;
|
||||
requestLayout();
|
||||
|
||||
}
|
||||
|
||||
protected void setMeasuredSize(int width, int height) {
|
||||
|
||||
@@ -55,12 +55,11 @@ public class GalleryLayout extends FrameLayout implements GalleryView.ActionList
|
||||
@Override
|
||||
public void onTapCenter() {
|
||||
mGalleryPanel.setShown(true, true);
|
||||
mActionListener.onShowGalleryPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSetMode(GalleryView.Mode mode) {
|
||||
mGalleryPanel.setRange(1, mGalleryView.getPages());
|
||||
mGalleryPanel.setGalleryViewMode(mode, mGalleryView.getPages());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -77,6 +76,11 @@ public class GalleryLayout extends FrameLayout implements GalleryView.ActionList
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onShow() {
|
||||
mActionListener.onShowGalleryPanel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHide() {
|
||||
mActionListener.onHideGalleryPanel();
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.hippo.ehviewer.gallery.ui;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.util.Log;
|
||||
import android.view.MotionEvent;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
@@ -30,7 +31,8 @@ import com.hippo.util.AnimationUtils;
|
||||
import com.hippo.widget.FitPaddingImpl;
|
||||
import com.hippo.yorozuya.LayoutUtils;
|
||||
|
||||
public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSetProgressListener {
|
||||
public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSetProgressListener,
|
||||
GLView.OnClickListener {
|
||||
|
||||
private static final String KEY_SHOWN = "shown_key";
|
||||
|
||||
@@ -42,13 +44,14 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
private XmlResourceView mShare;
|
||||
|
||||
private LinearLayout mBottomView;
|
||||
private TextView mProgressTextView;
|
||||
private TextView mPagesTextView;
|
||||
private TextView mLeftTextView;
|
||||
private TextView mRightTextView;
|
||||
private Slider mSlider;
|
||||
|
||||
private float mShowPercent = 0.0f;
|
||||
|
||||
private int mEnd = 0;
|
||||
private GalleryView.Mode mGalleryViewMode = GalleryView.Mode.NONE;
|
||||
private int mPages = 0;
|
||||
|
||||
private ActionListener mListener;
|
||||
|
||||
@@ -77,12 +80,15 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
mScreenRotation = new XmlResourceView();
|
||||
XmlResourceTexture screenRotationTexture = new XmlResourceTexture(context, R.drawable.ic_screen_rotation_dark_x48);
|
||||
mScreenRotation.setTexture(screenRotationTexture);
|
||||
mScreenRotation.setOnClickListener(this);
|
||||
mRefresh = new XmlResourceView();
|
||||
XmlResourceTexture refreshTexture = new XmlResourceTexture(context, R.drawable.ic_refresh_dark_x48);
|
||||
mRefresh.setTexture(refreshTexture);
|
||||
mRefresh.setOnClickListener(this);
|
||||
mShare = new XmlResourceView();
|
||||
XmlResourceTexture shareTexture = new XmlResourceTexture(context, R.drawable.ic_share_dark_x48);
|
||||
mShare.setTexture(shareTexture);
|
||||
mShare.setOnClickListener(this);
|
||||
|
||||
int actionSize = LayoutUtils.dp2pix(context, 48);
|
||||
lp = new LinearLayout.LayoutParams(
|
||||
@@ -100,10 +106,10 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
mBottomView.setBackgroundColor(background);
|
||||
mBottomView.setPaddingLeft(LayoutUtils.dp2pix(context, 8));
|
||||
mBottomView.setPaddingRight(LayoutUtils.dp2pix(context, 8));
|
||||
mProgressTextView = new TextView(sTextTexture);
|
||||
mProgressTextView.setGravity(Gravity.CENTER);
|
||||
mPagesTextView = new TextView(sTextTexture);
|
||||
mPagesTextView.setGravity(Gravity.CENTER);
|
||||
mLeftTextView = new TextView(sTextTexture);
|
||||
mLeftTextView.setGravity(Gravity.CENTER);
|
||||
mRightTextView = new TextView(sTextTexture);
|
||||
mRightTextView.setGravity(Gravity.CENTER);
|
||||
mSlider = new Slider(context);
|
||||
mSlider.setPaddings(LayoutUtils.dp2pix(context, 8), LayoutUtils.dp2pix(context, 18),
|
||||
LayoutUtils.dp2pix(context, 8), LayoutUtils.dp2pix(context, 18));
|
||||
@@ -113,7 +119,7 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
lp = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.CENTER_VERTICAL;
|
||||
mBottomView.addComponent(mProgressTextView, lp);
|
||||
mBottomView.addComponent(mLeftTextView, lp);
|
||||
lp = new LinearLayout.LayoutParams(
|
||||
LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.CENTER_VERTICAL;
|
||||
@@ -122,7 +128,7 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
lp = new LinearLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
lp.gravity = Gravity.CENTER_VERTICAL;
|
||||
mBottomView.addComponent(mPagesTextView, lp);
|
||||
mBottomView.addComponent(mRightTextView, lp);
|
||||
|
||||
addComponent(mRightView, new LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
|
||||
@@ -140,7 +146,15 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isShown() {
|
||||
return mShown;
|
||||
}
|
||||
|
||||
public void setShown(boolean shown, boolean animation) {
|
||||
if (shown && mGalleryViewMode == GalleryView.Mode.NONE) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (mShown != shown) {
|
||||
mShown = shown;
|
||||
|
||||
@@ -150,7 +164,9 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
mAnimation.forceReset();
|
||||
invalidate();
|
||||
|
||||
if (!shown) {
|
||||
if (shown) {
|
||||
mListener.onShow();
|
||||
} else {
|
||||
mListener.onHide();
|
||||
}
|
||||
}
|
||||
@@ -174,32 +190,48 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
@Override
|
||||
protected void onLayout(
|
||||
boolean changeSize, int left, int top, int right, int bottom) {
|
||||
if (changeSize) {
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
int l = width - (int) (mRightView.getMeasuredWidth() * mShowPercent);
|
||||
mRightView.layout(l, height / 2 - mRightView.getMeasuredHeight() / 2,
|
||||
l + mRightView.getMeasuredWidth(), height / 2 + mRightView.getMeasuredHeight() / 2);
|
||||
int width = getWidth();
|
||||
int height = getHeight();
|
||||
|
||||
int t = height - (int) (mBottomView.getMeasuredHeight() * mShowPercent);
|
||||
mBottomView.layout(0, t, width, t + mBottomView.getMeasuredHeight());
|
||||
}
|
||||
int l = width - (int) (mRightView.getMeasuredWidth() * mShowPercent);
|
||||
mRightView.layout(l, height / 2 - mRightView.getMeasuredHeight() / 2,
|
||||
l + mRightView.getMeasuredWidth(), height / 2 + mRightView.getMeasuredHeight() / 2);
|
||||
|
||||
int t = height - (int) (mBottomView.getMeasuredHeight() * mShowPercent);
|
||||
mBottomView.layout(0, t, width, t + mBottomView.getMeasuredHeight());
|
||||
}
|
||||
|
||||
public void setRange(int start, int end) {
|
||||
mSlider.setRange(start, end);
|
||||
mEnd = end;
|
||||
public void setGalleryViewMode(GalleryView.Mode galleryViewMode, int pages) {
|
||||
mGalleryViewMode = galleryViewMode;
|
||||
mPages = pages;
|
||||
|
||||
String pages = Integer.toString(end);
|
||||
mProgressTextView.setMinimumWidth((int) (sTextTexture.getMaxWidth() * pages.length()));
|
||||
mPagesTextView.setMinimumWidth((int) (sTextTexture.getMaxWidth() * pages.length()));
|
||||
mPagesTextView.setText(pages);
|
||||
mSlider.setRange(1, pages);
|
||||
|
||||
String pagesStr = Integer.toString(pages);
|
||||
int maxWidth = (int) (sTextTexture.getMaxWidth() * pagesStr.length());
|
||||
mLeftTextView.setMinimumWidth(maxWidth);
|
||||
mRightTextView.setMinimumWidth(maxWidth);
|
||||
|
||||
if (galleryViewMode == GalleryView.Mode.RIGHT_TO_LEFT) {
|
||||
mSlider.setReverse(true);
|
||||
mLeftTextView.setText(pagesStr);
|
||||
mRightTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
} else {
|
||||
mSlider.setReverse(false);
|
||||
mRightTextView.setText(pagesStr);
|
||||
mLeftTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
}
|
||||
}
|
||||
|
||||
public void setProgress(int progress) {
|
||||
mSlider.setProgress(progress);
|
||||
mProgressTextView.setText(Integer.toString(progress));
|
||||
|
||||
if (mGalleryViewMode == GalleryView.Mode.RIGHT_TO_LEFT) {
|
||||
mRightTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
} else {
|
||||
mLeftTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -212,7 +244,24 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
@Override
|
||||
public void onSetProgress(int newProgress, int oldProgress, boolean byUser) {
|
||||
mListener.onSetProgress(newProgress, oldProgress, byUser);
|
||||
mProgressTextView.setText(Integer.toString(newProgress));
|
||||
|
||||
if (mGalleryViewMode == GalleryView.Mode.RIGHT_TO_LEFT) {
|
||||
mRightTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
} else {
|
||||
mLeftTextView.setText(Integer.toString(mSlider.getProgress()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onClick(GLView v) {
|
||||
if (v == mScreenRotation) {
|
||||
Log.d("TAG", "mScreenRotation");
|
||||
} else if (v == mRefresh) {
|
||||
Log.d("TAG", "mRefresh");
|
||||
} else if (v == mShare) {
|
||||
Log.d("TAG", "mShare");
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -240,6 +289,8 @@ public class GalleryPanel extends GLView implements FitPaddingImpl, Slider.OnSet
|
||||
public interface ActionListener {
|
||||
void onSetProgress(int newProgress, int oldProgress, boolean byUser);
|
||||
|
||||
void onShow();
|
||||
|
||||
void onHide();
|
||||
}
|
||||
}
|
||||
@@ -7,17 +7,19 @@ import android.view.MotionEvent;
|
||||
import android.view.animation.Interpolator;
|
||||
import android.view.animation.OvershootInterpolator;
|
||||
|
||||
import com.hippo.ehviewer.Constants;
|
||||
import com.hippo.ehviewer.gallery.anim.Animation;
|
||||
import com.hippo.ehviewer.gallery.glrenderer.GLCanvas;
|
||||
import com.hippo.ehviewer.gallery.util.GalleryUtils;
|
||||
import com.hippo.yorozuya.IntArray;
|
||||
import com.hippo.yorozuya.MathUtils;
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
public class GalleryView extends GLView implements GestureRecognizer.Listener, Messenger.Receiver {
|
||||
|
||||
private static final String TAG = GalleryView.class.getSimpleName();
|
||||
|
||||
@@ -95,10 +97,29 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
private ActionListener mListener;
|
||||
|
||||
public enum Mode {
|
||||
NONE, // Just a progress view
|
||||
LEFT_TO_RIGHT,
|
||||
RIGHT_TO_LEFT,
|
||||
TOP_TO_BOTTOM
|
||||
NONE (-1), // Just a progress view
|
||||
LEFT_TO_RIGHT (0),
|
||||
RIGHT_TO_LEFT (1),
|
||||
TOP_TO_BOTTOM (2);
|
||||
|
||||
Mode(int ni) {
|
||||
nativeInt = ni;
|
||||
}
|
||||
final int nativeInt;
|
||||
}
|
||||
|
||||
public static Mode intToMode(int value) {
|
||||
switch (value) {
|
||||
case -1:
|
||||
return Mode.NONE;
|
||||
case 0:
|
||||
return Mode.LEFT_TO_RIGHT;
|
||||
default:
|
||||
case 1:
|
||||
return Mode.RIGHT_TO_LEFT;
|
||||
case 2:
|
||||
return Mode.TOP_TO_BOTTOM;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Scale {
|
||||
@@ -127,6 +148,19 @@ public class GalleryView extends GLView implements GestureRecognizer.Listener {
|
||||
mSmoothScaler = new SmoothScaler();
|
||||
mSmoothScaler.setInterpolator(SMOOTH_SCALER_INTERPOLATOR);
|
||||
mRecycler = new Recycler();
|
||||
|
||||
Messenger.getInstance().register(Constants.MESSENGER_ID_READING_DIRECTION, this);
|
||||
}
|
||||
|
||||
public void onClose() {
|
||||
Messenger.getInstance().unregister(Constants.MESSENGER_ID_READING_DIRECTION, this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onReceive(int id, Object obj) {
|
||||
if (Constants.MESSENGER_ID_READING_DIRECTION == id) {
|
||||
setMode(intToMode((Integer) obj));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,6 @@ public class GalleryUtils {
|
||||
// works most of the time, but that's ok because it's for debugging only.
|
||||
|
||||
private static volatile Thread sCurrentThread;
|
||||
private static volatile boolean sWarned;
|
||||
|
||||
public static void setRenderThread() {
|
||||
sCurrentThread = Thread.currentThread();
|
||||
|
||||
@@ -48,6 +48,7 @@ import com.hippo.ehviewer.gallery.ui.GalleryLayout;
|
||||
import com.hippo.ehviewer.gallery.ui.GalleryPageView;
|
||||
import com.hippo.ehviewer.gallery.ui.GalleryPanel;
|
||||
import com.hippo.ehviewer.gallery.ui.GalleryView;
|
||||
import com.hippo.ehviewer.util.Settings;
|
||||
import com.hippo.util.SystemUiHelper;
|
||||
import com.hippo.yorozuya.PriorityThreadFactory;
|
||||
import com.hippo.yorozuya.SimpleHandler;
|
||||
@@ -72,6 +73,7 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
public static final SparseArray<CloseGalleryProviderTask> sCloseGalleryProviderTaskMap = new SparseArray<>();
|
||||
|
||||
private SystemUiHelper mSystemUiHelper;
|
||||
private boolean mSystemUiShowing = false;
|
||||
|
||||
private Resources mResources;
|
||||
|
||||
@@ -151,12 +153,15 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
return;
|
||||
}
|
||||
|
||||
mSystemUiHelper = new SystemUiHelper(this, SystemUiHelper.LEVEL_IMMERSIVE,
|
||||
mSystemUiHelper = new SystemUiHelper(this,
|
||||
Settings.getReadingHideNavBar() ? SystemUiHelper.LEVEL_IMMERSIVE : SystemUiHelper.LEVEL_HIDE_STATUS_BAR,
|
||||
SystemUiHelper.FLAG_LAYOUT_IN_SCREEN_OLDER_DEVICES | SystemUiHelper.FLAG_IMMERSIVE_STICKY);
|
||||
if (savedInstanceState == null || !savedInstanceState.getBoolean(KEY_SHOWING, false)) {
|
||||
mSystemUiHelper.hide();
|
||||
mSystemUiShowing = false;
|
||||
} else {
|
||||
mSystemUiHelper.show();
|
||||
mSystemUiShowing = true;
|
||||
}
|
||||
|
||||
mResources = getResources();
|
||||
@@ -202,7 +207,7 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
if (mSize <= 0) {
|
||||
setMode(GalleryView.Mode.NONE);
|
||||
} else {
|
||||
setMode(GalleryView.Mode.LEFT_TO_RIGHT);
|
||||
setMode(GalleryView.intToMode(Settings.getReadingDirection()));
|
||||
}
|
||||
mGalleryProvider.addGalleryProviderListener(this);
|
||||
|
||||
@@ -226,7 +231,7 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
protected void onSaveInstanceState(Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putInt(KEY_HASH_CODE, hashCode());
|
||||
outState.putBoolean(KEY_SHOWING, mSystemUiHelper.isShowing());
|
||||
outState.putBoolean(KEY_SHOWING, mSystemUiShowing);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -261,17 +266,30 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
clearTiledTextureInPage((GalleryPageView) view);
|
||||
}
|
||||
}
|
||||
|
||||
mGalleryView.onClose();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
public void onWindowFocusChanged(boolean hasFocus) {
|
||||
super.onWindowFocusChanged(hasFocus);
|
||||
|
||||
if (mSystemUiHelper.isShowing()) {
|
||||
mSystemUiHelper.show();
|
||||
if (hasFocus) {
|
||||
if (mSystemUiShowing) {
|
||||
mSystemUiHelper.show();
|
||||
} else {
|
||||
mSystemUiHelper.hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
if (mGalleryPanel.isShown()) {
|
||||
mGalleryPanel.setShown(false, true);
|
||||
} else {
|
||||
mSystemUiHelper.hide();
|
||||
super.onBackPressed();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,7 +320,7 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
public void onGetSize(int size) {
|
||||
if (mSize != size) {
|
||||
mSize = size;
|
||||
setMode(GalleryView.Mode.LEFT_TO_RIGHT);
|
||||
setMode(GalleryView.intToMode(Settings.getReadingDirection()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -449,11 +467,17 @@ public class GalleryActivity extends StatsActivity implements TiledTexture.OnFre
|
||||
@Override
|
||||
public void onShowGalleryPanel() {
|
||||
mSystemUiHelper.show();
|
||||
mSystemUiShowing = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onHideGalleryPanel() {
|
||||
mSystemUiHelper.hide();
|
||||
if (Settings.getReadingHideNavBar()) {
|
||||
mSystemUiHelper.delayHide(3000);
|
||||
} else {
|
||||
mSystemUiHelper.hide();
|
||||
}
|
||||
mSystemUiShowing = false;
|
||||
}
|
||||
|
||||
class GalleryAdapter extends GalleryView.Adapter {
|
||||
|
||||
@@ -21,10 +21,11 @@ import android.support.v4.content.ContextCompat;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.ui.ContentActivity;
|
||||
import com.hippo.ehviewer.ui.scene.preference.AdvanceSettingsScene;
|
||||
import com.hippo.ehviewer.ui.scene.preference.AdvancedSettingsScene;
|
||||
import com.hippo.ehviewer.ui.scene.preference.DisplaySettingsScene;
|
||||
import com.hippo.ehviewer.ui.scene.preference.DownloadSettingsScene;
|
||||
import com.hippo.ehviewer.ui.scene.preference.EHSettingsScene;
|
||||
import com.hippo.ehviewer.ui.scene.preference.ReadingSettingsScene;
|
||||
import com.hippo.scene.preference.PreferenceHeader;
|
||||
import com.hippo.scene.preference.PreferenceHeaderScene;
|
||||
|
||||
@@ -48,6 +49,10 @@ public final class MainSettingsScene extends PreferenceHeaderScene {
|
||||
R.drawable.ic_cellphone_android_theme_accent,
|
||||
R.string.settings_display,
|
||||
DisplaySettingsScene.class),
|
||||
newPreferenceHeader(
|
||||
R.drawable.ic_book_open_theme_accent_x24,
|
||||
R.string.settings_reading,
|
||||
ReadingSettingsScene.class),
|
||||
newPreferenceHeader(
|
||||
R.drawable.ic_eh_theme_accent,
|
||||
R.string.settings_eh,
|
||||
@@ -58,8 +63,8 @@ public final class MainSettingsScene extends PreferenceHeaderScene {
|
||||
DownloadSettingsScene.class),
|
||||
newPreferenceHeader(
|
||||
R.drawable.ic_black_mesa_theme_accent,
|
||||
R.string.settings_advance,
|
||||
AdvanceSettingsScene.class)
|
||||
R.string.settings_advanced,
|
||||
AdvancedSettingsScene.class)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ import com.hippo.scene.preference.SwitchPreference;
|
||||
import com.hippo.yorozuya.FileUtils;
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
public class AdvanceSettingsScene extends PreferenceScene implements
|
||||
public class AdvancedSettingsScene extends PreferenceScene implements
|
||||
Preference.OnValueChangeListener, Preference.OnClickListener {
|
||||
|
||||
private static final String KEY_SHOW_APPLICATION_STATS = "show_application_stats";
|
||||
@@ -56,7 +56,7 @@ public final class EHSettingsScene extends PreferenceScene implements Preference
|
||||
ListPreference sourcePreference = new ListPreference(this, Settings.KEY_EH_SOURCE,
|
||||
resources.getString(R.string.settings_eh_source_title), null);
|
||||
sourcePreference.setKeys(resources.getStringArray(R.array.settings_eh_source_entries));
|
||||
sourcePreference.setValues(resources.getIntArray(R.array.settings_eh_source_entry_values));
|
||||
sourcePreference.setValues(resources.getIntArray(R.array.settings_eh_source_values));
|
||||
sourcePreference.setDefaultValue(Settings.DEFAULT_EH_SOURCE);
|
||||
sourcePreference.setOnValueChangeListener(this);
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* Copyright 2015 Hippo Seven
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.hippo.ehviewer.ui.scene.preference;
|
||||
|
||||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
|
||||
import com.hippo.ehviewer.Constants;
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.ehviewer.util.Settings;
|
||||
import com.hippo.scene.preference.ListPreference;
|
||||
import com.hippo.scene.preference.Preference;
|
||||
import com.hippo.scene.preference.PreferenceScene;
|
||||
import com.hippo.scene.preference.PreferenceSet;
|
||||
import com.hippo.scene.preference.SwitchPreference;
|
||||
import com.hippo.yorozuya.Messenger;
|
||||
|
||||
public class ReadingSettingsScene extends PreferenceScene implements ListPreference.OnValueChangeListener {
|
||||
|
||||
@Override
|
||||
protected void onCreate(boolean rebirth) {
|
||||
super.onCreate(rebirth);
|
||||
|
||||
setTitle(R.string.settings_reading);
|
||||
setIcon(R.drawable.ic_arrow_left_dark);
|
||||
|
||||
setPreferenceSet(getPreferenceSet());
|
||||
}
|
||||
|
||||
private PreferenceSet[] getPreferenceSet() {
|
||||
Resources resources = getStageActivity().getResources();
|
||||
|
||||
// Reading direction
|
||||
ListPreference directionPreference = new ListPreference(this, Settings.KEY_READING_DIRECTION,
|
||||
resources.getString(R.string.settings_reading_direction_title), null);
|
||||
directionPreference.setKeys(resources.getStringArray(R.array.settings_reading_direction_entries));
|
||||
directionPreference.setValues(resources.getIntArray(R.array.settings_reading_direction_values));
|
||||
directionPreference.setDefaultValue(Settings.DEFAULT_READING_DIRECTION);
|
||||
directionPreference.setOnValueChangeListener(this);
|
||||
|
||||
// Hide nav bar
|
||||
SwitchPreference hideNavbarPreference = new SwitchPreference(Settings.KEY_READING_HIDE_NAV_BAR,
|
||||
resources.getString(R.string.settings_reading_hide_nav_bar_title),
|
||||
resources.getString(R.string.settings_reading_hide_nav_bar_summary));
|
||||
hideNavbarPreference.setSummaryOn(resources.getString(R.string.settings_reading_hide_nav_bar_summary_on));
|
||||
hideNavbarPreference.setSummaryOff(resources.getString(R.string.settings_reading_hide_nav_bar_summary_off));
|
||||
hideNavbarPreference.setDefaultValue(Settings.getReadingHideNavBar());
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
|
||||
hideNavbarPreference.setEnable(false);
|
||||
}
|
||||
|
||||
PreferenceSet preferenceSet = new PreferenceSet();
|
||||
preferenceSet.setPreferenceList(new Preference[] {
|
||||
directionPreference,
|
||||
hideNavbarPreference
|
||||
});
|
||||
|
||||
return new PreferenceSet[] {
|
||||
preferenceSet
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean OnValueChange(Preference preference, Object newValue) {
|
||||
String key = preference.getKey();
|
||||
switch (key) {
|
||||
case Settings.KEY_READING_DIRECTION:
|
||||
Messenger.getInstance().notify(Constants.MESSENGER_ID_READING_DIRECTION, newValue);
|
||||
return true;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,29 @@ public final class Settings {
|
||||
}
|
||||
}
|
||||
|
||||
/****** Reading ******/
|
||||
public static final String KEY_READING_DIRECTION = "reading_direction";
|
||||
public static final int DEFAULT_READING_DIRECTION = 1;
|
||||
public static final String KEY_READING_HIDE_NAV_BAR = "reading_hide_nav_bar";
|
||||
public static final boolean DEFAULT_READING_HIDE_NAV_BAR = true;
|
||||
|
||||
public static void putReadingDirection(int value) {
|
||||
putInt(KEY_READING_DIRECTION, value);
|
||||
}
|
||||
|
||||
public static int getReadingDirection() {
|
||||
return getInt(KEY_READING_DIRECTION, DEFAULT_READING_DIRECTION);
|
||||
}
|
||||
|
||||
public static void putReadingHideNavBar(boolean value) {
|
||||
putBoolean(KEY_READING_HIDE_NAV_BAR, value);
|
||||
}
|
||||
|
||||
public static boolean getReadingHideNavBar() {
|
||||
return getBoolean(KEY_READING_HIDE_NAV_BAR, DEFAULT_READING_HIDE_NAV_BAR);
|
||||
}
|
||||
|
||||
|
||||
/****** EH ******/
|
||||
public static final String KEY_EH_SOURCE = "eh_source";
|
||||
public static final int DEFAULT_EH_SOURCE = EhUrl.SOURCE_G;
|
||||
|
||||
@@ -25,6 +25,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.FrameLayout;
|
||||
|
||||
import com.hippo.ehviewer.R;
|
||||
import com.hippo.yorozuya.ViewUtils;
|
||||
|
||||
// TODO Need a better way to update it
|
||||
public class Preference extends PreferenceBase {
|
||||
@@ -35,6 +36,8 @@ public class Preference extends PreferenceBase {
|
||||
private String mTitle;
|
||||
private String mSummary;
|
||||
|
||||
private boolean mEnable = true;
|
||||
|
||||
private OnClickListener mOnClickListener;
|
||||
private OnValueChangeListener mOnValueChangeListener;
|
||||
private ViewHolderGetter mViewHolderGetter;
|
||||
@@ -70,6 +73,18 @@ public class Preference extends PreferenceBase {
|
||||
mPosition = position;
|
||||
}
|
||||
|
||||
public boolean getEnable() {
|
||||
return mEnable;
|
||||
}
|
||||
|
||||
public void setEnable(boolean enable) {
|
||||
mEnable = enable;
|
||||
RecyclerView.ViewHolder viewHolder = getViewHolder();
|
||||
if (viewHolder != null) {
|
||||
ViewUtils.setEnabledRecursively(viewHolder.itemView, mEnable);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the text display below title
|
||||
*/
|
||||
@@ -125,6 +140,8 @@ public class Preference extends PreferenceBase {
|
||||
}
|
||||
|
||||
onUpdateView(viewHolder);
|
||||
|
||||
ViewUtils.setEnabledRecursively(pvh.itemView, mEnable);
|
||||
}
|
||||
|
||||
protected void onBind(Context context, FrameLayout widgetFrame) {
|
||||
|
||||
@@ -52,8 +52,9 @@ public class SwitchPreference extends Preference {
|
||||
@Override
|
||||
public String getDisplaySummary() {
|
||||
String displaySummary = getValue() ? mSummaryOn : mSummaryOff;
|
||||
if (displaySummary == null) {
|
||||
displaySummary = getSummary();
|
||||
String summary = getSummary();
|
||||
if (displaySummary == null || (!getEnable() && summary != null)) {
|
||||
displaySummary = summary;
|
||||
}
|
||||
return displaySummary;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/primary_text_disabled_dark"/>
|
||||
<item android:color="@color/primary_text_default_dark"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/primary_text_disabled_light"/>
|
||||
<item android:color="@color/primary_text_default_light"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/secondary_text_disabled_dark"/>
|
||||
<item android:color="@color/secondary_text_default_dark"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
<item android:state_enabled="false" android:color="@color/secondary_text_disabled_light"/>
|
||||
<item android:color="@color/secondary_text_default_light"/>
|
||||
</selector>
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
~ Copyright 2015 Hippo Seven
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
<vector
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
xmlns:auto="http://schemas.android.com/apk/res-auto"
|
||||
tools:targetApi="21"
|
||||
|
||||
auto:width="24dp"
|
||||
auto:height="24dp"
|
||||
auto:viewportWidth="24"
|
||||
auto:viewportHeight="24"
|
||||
|
||||
android:width="24dp"
|
||||
android:height="24dp"
|
||||
android:viewportWidth="24"
|
||||
android:viewportHeight="24">
|
||||
|
||||
<path
|
||||
auto:pathData="@string/pd_book_open"
|
||||
auto:fillColor="@color/theme_accent"
|
||||
|
||||
android:pathData="@string/pd_book_open"
|
||||
android:fillColor="@color/theme_accent"/>
|
||||
|
||||
</vector>
|
||||
@@ -22,13 +22,25 @@
|
||||
<item>@string/star_5</item>
|
||||
</string-array>
|
||||
|
||||
<string-array name="settings_reading_direction_entries">
|
||||
<item>@string/settings_reading_direction_left_to_right</item>
|
||||
<item>@string/settings_reading_direction_right_to_left</item>
|
||||
<item>@string/settings_reading_direction_top_to_bottom</item>
|
||||
</string-array>
|
||||
|
||||
<array name="settings_reading_direction_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
</array>
|
||||
|
||||
<string-array name="settings_eh_source_entries">
|
||||
<item>@string/settings_eh_source_g</item>
|
||||
<item>@string/settings_eh_source_ex</item>
|
||||
<item>@string/settings_eh_source_lofi</item>
|
||||
</string-array>
|
||||
|
||||
<array name="settings_eh_source_entry_values">
|
||||
<array name="settings_eh_source_values">
|
||||
<item>0</item>
|
||||
<item>1</item>
|
||||
<item>2</item>
|
||||
|
||||
@@ -67,10 +67,14 @@
|
||||
<color name="material_indigo_700">#ff303f9f</color>
|
||||
|
||||
<!-- Text -->
|
||||
<color name="primary_text_light">#de000000</color>
|
||||
<color name="secondary_text_light">#8a000000</color>
|
||||
<color name="primary_text_dark">#deffffff</color>
|
||||
<color name="secondary_text_dark">#61ffffff</color>
|
||||
<color name="primary_text_default_light">#de000000</color>
|
||||
<color name="primary_text_disabled_dark">#4dffffff</color>
|
||||
<color name="secondary_text_default_light">#8a000000</color>
|
||||
<color name="secondary_text_disabled_dark">#36ffffff</color>
|
||||
<color name="primary_text_default_dark">#deffffff</color>
|
||||
<color name="primary_text_disabled_light">#39000000</color>
|
||||
<color name="secondary_text_default_dark">#61ffffff</color>
|
||||
<color name="secondary_text_disabled_light">#24000000</color>
|
||||
|
||||
<!-- Background -->
|
||||
<color name="background_dark">#ff303030</color>
|
||||
|
||||
@@ -46,5 +46,6 @@
|
||||
<string name="pd_screen_rotation" translatable="false">M8.3,20c-2.8-1.3-4.6-4-5-7.2H2C2.4,18,6.8,22,12,22h0.5l-3.3-3.1 M14.4,19.7L4.4,9.7l5.4-5.3l10,10.1 M10.5,3.5C10,3,9.3,3,8.8,3.5L3.4,8.8c-0.5,0.5-0.5,1.3,0,1.8l10,10.1c0.5,0.5,1.3,0.5,1.8,0l5.4-5.3c0.5-0.5,0.5-1.3,0-1.8L10.5,3.5M15.8,4.1c2.8,1.3,4.6,4,5,7.2H22C21.6,6,17.3,2,12,2h-0.5l3.3,3.1L15.8,4.1z</string>
|
||||
<string name="pd_refresh" translatable="false">M17.65,6.35C16.2,4.9 14.21,4 12,4A8,8 0 0,0 4,12A8,8 0 0,0 12,20C15.73,20 18.84,17.45 19.73,14H17.65C16.83,16.33 14.61,18 12,18A6,6 0 0,1 6,12A6,6 0 0,1 12,6C13.66,6 15.14,6.69 16.22,7.78L13,11H20V4L17.65,6.35Z</string>
|
||||
<string name="pd_url" translatable="false">M11.6,7v7.1c0,1-0.3,1.8-0.9,2.4c-0.6,0.6-1.5,1-2.5,1.1l-0.4,0c-1.1,0-2.1-0.3-2.7-0.9c-0.7-0.6-1-1.5-1-2.6V7h1.4v7.1c0,0.8,0.2,1.3,0.6,1.8c0.4,0.4,1,0.6,1.8,0.6c0.8,0,1.4-0.2,1.8-0.6c0.4-0.4,0.6-1,0.6-1.8V7H11.6M17.3,10.9c-0.2,0-0.4-0.1-0.7-0.1c-0.9,0-1.5,0.4-1.8,1.1v5.5h-1.3V9.7h1.3l0,0.9c0.4-0.7,1.1-1,1.9-1c0.3,0,0.5,0,0.6,0.1V10.9M20,17.5h-1.3V6.4H20V17.5z</string>
|
||||
<string name="pd_book_open" translatable="false">M11,19V9A2,2 0 0,0 9,7H5V17H9A2,2 0 0,1 11,19M13,9V19A2,2 0 0,1 15,17H19V7H15A2,2 0 0,0 13,9M21,19H15A2,2 0 0,0 13,21H11A2,2 0 0,0 9,19H3V5H9A2,2 0 0,1 11,7H13A2,2 0 0,1 15,5H21V19Z</string>
|
||||
|
||||
</resources>
|
||||
@@ -137,6 +137,16 @@
|
||||
<!-- Settings -->
|
||||
<string name="settings_display">Display</string>
|
||||
|
||||
<string name="settings_reading">Reading</string>
|
||||
<string name="settings_reading_direction_title">Reading direction</string>
|
||||
<string name="settings_reading_direction_left_to_right">Left to right</string>
|
||||
<string name="settings_reading_direction_right_to_left">Right to left</string>
|
||||
<string name="settings_reading_direction_top_to_bottom">Top to bottom</string>
|
||||
<string name="settings_reading_hide_nav_bar_title">Hide nav bar</string>
|
||||
<string name="settings_reading_hide_nav_bar_summary">Only work for Android 4.4 and above</string>
|
||||
<string name="settings_reading_hide_nav_bar_summary_on">Immersive full-screen mode</string>
|
||||
<string name="settings_reading_hide_nav_bar_summary_off">Do not hide nav bar</string>
|
||||
|
||||
<string name="settings_eh" translatable="false">EH</string>
|
||||
<string name="settings_eh_source_title">EH source</string>
|
||||
<string name="settings_eh_source_g" translatable="false">g.e-hentai.org</string>
|
||||
@@ -155,7 +165,7 @@
|
||||
<string name="settings_image_download_location">Image download location</string>
|
||||
<string name="settings_archive_download_location">Archive download location</string>
|
||||
|
||||
<string name="settings_advance">Advance</string>
|
||||
<string name="settings_advanced">Advanced</string>
|
||||
<string name="settings_show_application_stats_title">Show application stats</string>
|
||||
<string name="settings_show_application_stats_summary">Show application stats at the top-right corner of the screen</string>
|
||||
<string name="settings_clear_image_memory_cache_title">Clear image memory cache</string>
|
||||
|
||||
+1
-1
Submodule yorozuya updated: 78bcf1c6b7...86de3b869d.
Reference in new issue
Block a user