diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml
index 6933c1eaf..e4fefe369 100644
--- a/.idea/inspectionProfiles/profiles_settings.xml
+++ b/.idea/inspectionProfiles/profiles_settings.xml
@@ -1,7 +1,7 @@
-
-
+
+
\ No newline at end of file
diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro
index df08d904d..7ebac8139 100644
--- a/app/proguard-rules.pro
+++ b/app/proguard-rules.pro
@@ -18,22 +18,28 @@
# For bug report
-keepattributes SourceFile,LineNumberTable
--keep class com.hippo.**
# For ObjectAnimator
-keepclassmembers class com.hippo.effect.ripple.Ripple {
- void set*(***);
- *** get*();
+ void set*(***);
+ *** get*();
}
-keepclassmembers class com.hippo.effect.ripple.RippleBackground {
- void set*(***);
- *** get*();
+ void set*(***);
+ *** get*();
}
-keepclassmembers public class * extends com.hippo.drawable.VectorDrawable.VGroup {
- void set*(***);
- *** get*();
+ void set*(***);
+ *** get*();
}
-keepclassmembers public class * extends com.hippo.scene.Scene {
- void setBackgroundColor(int);
- int getBackgroundColor();
+ void setBackgroundColor(int);
+ int getBackgroundColor();
}
+-keepclassmembers class com.hippo.drawable.DrawerArrowDrawable {
+ void setProgress(float);
+ float getProgress();
+}
+
+#For VectorResources
+-keep class android.content.res.VectorResources {*;}
diff --git a/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java
new file mode 100644
index 000000000..aedfc0f0b
--- /dev/null
+++ b/app/src/main/java/com/hippo/drawable/DrawerArrowDrawable.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 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
+ * 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.drawable;
+
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Canvas;
+import android.graphics.ColorFilter;
+import android.graphics.Paint;
+import android.graphics.Path;
+import android.graphics.PixelFormat;
+import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+
+import com.hippo.ehviewer.R;
+import com.hippo.util.MathUtils;
+
+/**
+ * A drawable that can draw a "Drawer hamburger" menu or an Arrow and animate between them.
+ */
+public class DrawerArrowDrawable extends Drawable {
+
+ private final Paint mPaint = new Paint();
+
+ // The angle in degress that the arrow head is inclined at.
+ private static final float ARROW_HEAD_ANGLE = (float) Math.toRadians(45);
+ private final float mBarThickness;
+ // The length of top and bottom bars when they merge into an arrow
+ private final float mTopBottomArrowSize;
+ // The length of middle bar
+ private final float mBarSize;
+ // The length of the middle bar when arrow is shaped
+ private final float mMiddleArrowSize;
+ // The space between bars when they are parallel
+ private final float mBarGap;
+ // Whether bars should spin or not during progress
+ private final boolean mSpin;
+ // Use Path instead of canvas operations so that if color has transparency, overlapping sections
+ // wont look different
+ private final Path mPath = new Path();
+ // The reported intrinsic size of the drawable.
+ private final int mSize;
+ // Whether we should mirror animation when animation is reversed.
+ private boolean mVerticalMirror = false;
+ // The interpolated version of the original progress
+ private float mProgress;
+ // the amount that overlaps w/ bar size when rotation is max
+ private float mMaxCutForBarSize;
+
+ /**
+ * @param context used to get the configuration for the drawable from
+ */
+ public DrawerArrowDrawable(Context context) {
+ Resources resources = context.getResources();
+
+ mPaint.setAntiAlias(true);
+ mPaint.setColor(resources.getColor(R.color.primary_drawable_light));
+ mSize = resources.getDimensionPixelSize(R.dimen.dad_drawable_size);
+ // round this because having this floating may cause bad measurements
+ mBarSize = Math.round(resources.getDimension(R.dimen.dad_bar_size));
+ // round this because having this floating may cause bad measurements
+ mTopBottomArrowSize = Math.round(resources.getDimension(R.dimen.dad_top_bottom_bar_arrow_size));
+ mBarThickness = resources.getDimension(R.dimen.dad_thickness);
+ // round this because having this floating may cause bad measurements
+ mBarGap = Math.round(resources.getDimension(R.dimen.dad_gap_between_bars));
+ mSpin = resources.getBoolean(R.bool.dad_spin_bars);
+ mMiddleArrowSize = resources.getDimension(R.dimen.dad_middle_bar_arrow_size);
+
+ mPaint.setStyle(Paint.Style.STROKE);
+ mPaint.setStrokeJoin(Paint.Join.MITER);
+ mPaint.setStrokeCap(Paint.Cap.BUTT);
+ mPaint.setStrokeWidth(mBarThickness);
+
+ mMaxCutForBarSize = (float) (mBarThickness / 2 * Math.cos(ARROW_HEAD_ANGLE));
+ }
+
+ /**
+ * If set, canvas is flipped when progress reached to end and going back to start.
+ */
+ protected void setVerticalMirror(boolean verticalMirror) {
+ mVerticalMirror = verticalMirror;
+ }
+
+ @Override
+ public void draw(Canvas canvas) {
+ Rect bounds = getBounds();
+ // Interpolated widths of arrow bars
+ final float arrowSize = MathUtils.lerp(mBarSize, mTopBottomArrowSize, mProgress);
+ final float middleBarSize = MathUtils.lerp(mBarSize, mMiddleArrowSize, mProgress);
+ // Interpolated size of middle bar
+ final float middleBarCut = Math.round(MathUtils.lerp(0, mMaxCutForBarSize, mProgress));
+ // The rotation of the top and bottom bars (that make the arrow head)
+ final float rotation = MathUtils.lerp(0, ARROW_HEAD_ANGLE, mProgress);
+
+ // The whole canvas rotates as the transition happens
+ final float canvasRotate = MathUtils.lerp(-180, 0, mProgress);
+ final float arrowWidth = Math.round(arrowSize * Math.cos(rotation));
+ final float arrowHeight = Math.round(arrowSize * Math.sin(rotation));
+
+ mPath.rewind();
+ final float topBottomBarOffset = MathUtils.lerp(mBarGap + mBarThickness, -mMaxCutForBarSize,
+ mProgress);
+
+ final float arrowEdge = -middleBarSize / 2;
+ // draw middle bar
+ mPath.moveTo(arrowEdge + middleBarCut, 0);
+ mPath.rLineTo(middleBarSize - middleBarCut * 2, 0);
+
+ // bottom bar
+ mPath.moveTo(arrowEdge, topBottomBarOffset);
+ mPath.rLineTo(arrowWidth, arrowHeight);
+
+ // top bar
+ mPath.moveTo(arrowEdge, -topBottomBarOffset);
+ mPath.rLineTo(arrowWidth, -arrowHeight);
+
+ mPath.close();
+
+ canvas.save();
+ // Rotate the whole canvas if spinning, if not, rotate it 180 to get
+ // the arrow pointing the other way for RTL.
+ canvas.translate(bounds.centerX(), bounds.centerY());
+ if (mSpin) {
+ canvas.rotate(canvasRotate * (mVerticalMirror ? -1 : 1));
+ }
+ canvas.drawPath(mPath, mPaint);
+
+ canvas.restore();
+ }
+
+ @Override
+ public void setAlpha(int i) {
+ mPaint.setAlpha(i);
+ }
+
+ @Override
+ public void setColorFilter(ColorFilter colorFilter) {
+ mPaint.setColorFilter(colorFilter);
+ }
+
+ @Override
+ public int getIntrinsicHeight() {
+ return mSize;
+ }
+
+ @Override
+ public int getIntrinsicWidth() {
+ return mSize;
+ }
+
+ @Override
+ public int getOpacity() {
+ return PixelFormat.TRANSLUCENT;
+ }
+
+ @SuppressWarnings("unused")
+ public float getProgress() {
+ return mProgress;
+ }
+
+ @SuppressWarnings("unused")
+ public void setProgress(float progress) {
+ if (progress == 1f) {
+ setVerticalMirror(true);
+ } else if (progress == 0f) {
+ setVerticalMirror(false);
+ }
+ mProgress = progress;
+ invalidateSelf();
+ }
+}
diff --git a/app/src/main/java/com/hippo/effect/ripple/Ripple.java b/app/src/main/java/com/hippo/effect/ripple/Ripple.java
index 383764b2f..e56835a62 100644
--- a/app/src/main/java/com/hippo/effect/ripple/Ripple.java
+++ b/app/src/main/java/com/hippo/effect/ripple/Ripple.java
@@ -29,7 +29,6 @@ import android.os.Build;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
-import com.hippo.util.ApiHelper;
import com.hippo.util.MathUtils;
/**
@@ -257,7 +256,7 @@ class Ripple {
cY.setInterpolator(LINEAR_INTERPOLATOR);
cY.setStartDelay(RIPPLE_ENTER_DELAY);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
radius.setAutoCancel(true);
cX.setAutoCancel(true);
cY.setAutoCancel(true);
@@ -347,7 +346,7 @@ class Ripple {
opacityAnim.setInterpolator(LINEAR_INTERPOLATOR);
opacityAnim.addListener(mAnimationListener);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
radiusAnim.setAutoCancel(true);
xAnim.setAutoCancel(true);
yAnim.setAutoCancel(true);
diff --git a/app/src/main/java/com/hippo/effect/ripple/RippleBackground.java b/app/src/main/java/com/hippo/effect/ripple/RippleBackground.java
index 9f54181e9..13ae65f37 100644
--- a/app/src/main/java/com/hippo/effect/ripple/RippleBackground.java
+++ b/app/src/main/java/com/hippo/effect/ripple/RippleBackground.java
@@ -28,7 +28,6 @@ import android.os.Build;
import android.view.animation.Interpolator;
import android.view.animation.LinearInterpolator;
-import com.hippo.util.ApiHelper;
import com.hippo.util.MathUtils;
/**
@@ -164,7 +163,7 @@ class RippleBackground {
final ObjectAnimator outer = ObjectAnimator.ofFloat(this, "outerOpacity", 0, 1);
outer.setDuration(outerDuration);
outer.setInterpolator(LINEAR_INTERPOLATOR);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
outer.setAutoCancel(true);
}
@@ -226,7 +225,7 @@ class RippleBackground {
"outerOpacity", inflectionOpacity / 255.0f);
outerOpacityAnim.setDuration(inflectionDuration);
outerOpacityAnim.setInterpolator(LINEAR_INTERPOLATOR);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
outerOpacityAnim.setAutoCancel(true);
}
@@ -240,7 +239,7 @@ class RippleBackground {
RippleBackground.this, "outerOpacity", 0);
outerFadeOutAnim.setDuration(outerDuration);
outerFadeOutAnim.setInterpolator(LINEAR_INTERPOLATOR);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
outerFadeOutAnim.setAutoCancel(true);
}
@@ -258,7 +257,7 @@ class RippleBackground {
} else {
outerOpacityAnim = ObjectAnimator.ofFloat(this, "outerOpacity", 0);
outerOpacityAnim.setDuration(opacityDuration);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
outerOpacityAnim.setAutoCancel(true);
}
}
diff --git a/app/src/main/java/com/hippo/ehviewer/EhApplication.java b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
index d9d25c1e1..1d2c2451d 100644
--- a/app/src/main/java/com/hippo/ehviewer/EhApplication.java
+++ b/app/src/main/java/com/hippo/ehviewer/EhApplication.java
@@ -15,6 +15,9 @@
package com.hippo.ehviewer;
+import android.content.Context;
+
+import com.hippo.content.VectorContext;
import com.hippo.scene.SceneApplication;
public class EhApplication extends SceneApplication {
@@ -23,4 +26,9 @@ public class EhApplication extends SceneApplication {
public void onCreate() {
super.onCreate();
}
+
+ @Override
+ protected void attachBaseContext(Context newBase) {
+ super.attachBaseContext(VectorContext.wrapContext(newBase));
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
index f249c19f7..9cade1cae 100644
--- a/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
+++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/GalleryListScene.java
@@ -26,8 +26,10 @@ import com.hippo.ehviewer.widget.ContentLayout;
import com.hippo.ehviewer.widget.SearchBar;
import com.hippo.scene.Scene;
import com.hippo.scene.TransitionCurtain;
+import com.hippo.util.Log;
-public class GalleryListScene extends Scene implements SearchBar.Helper{
+public
+class GalleryListScene extends Scene implements SearchBar.Helper{
private final static int PAGE_INDEX_SEARCH = 0;
private final static int PAGE_INDEX_LIST = 1;
@@ -79,4 +81,14 @@ public class GalleryListScene extends Scene implements SearchBar.Helper{
public void onClickMenu() {
mActivity.toggleDrawer();
}
+
+ @Override
+ public void onClickAdvance() {
+
+ }
+
+ @Override
+ public void onApplySearch(String query) {
+ Log.d("onApplySearch " + query);
+ }
}
diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java b/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
index e9cdaf4bb..b3514da58 100644
--- a/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
+++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchBar.java
@@ -15,24 +15,43 @@
package com.hippo.ehviewer.widget;
+import android.animation.ObjectAnimator;
import android.content.Context;
import android.graphics.Typeface;
+import android.os.Build;
import android.support.v7.widget.CardView;
+import android.text.TextUtils;
import android.util.AttributeSet;
+import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputMethodManager;
import android.widget.TextView;
+import com.hippo.drawable.DrawerArrowDrawable;
import com.hippo.ehviewer.R;
import com.hippo.util.UiUtils;
+import com.hippo.util.ViewUtils;
+import com.hippo.widget.SimpleImageView;
-public class SearchBar extends CardView implements View.OnClickListener {
+public class SearchBar extends CardView implements View.OnClickListener,
+ TextView.OnEditorActionListener {
- private View mMenuButton;
+ private static final long ANIMATION_TIME = 300;
+
+ private SimpleImageView mMenuButton;
private TextView mLogoTextView;
+ private View mAdvanceButton;
+ private SearchEditText mEditText;
+ private View mSearchButton;
+
+ private DrawerArrowDrawable mDrawerArrowDrawable;
private Helper mHelper;
+ private boolean mInEditMode = false;
+
public SearchBar(Context context) {
super(context);
init(context);
@@ -51,14 +70,24 @@ public class SearchBar extends CardView implements View.OnClickListener {
private void init(Context context) {
setRadius(UiUtils.dp2pix(context, 2));
setCardElevation(UiUtils.dp2pix(context, 2));
+ setOnClickListener(this);
LayoutInflater.from(context).inflate(R.layout.widget_search_bar, this);
- mMenuButton = getChildAt(0);
- mLogoTextView = (TextView) getChildAt(1);
+ mMenuButton = (SimpleImageView) findViewById(R.id.menu);
+ mLogoTextView = (TextView) findViewById(R.id.logo);
+ mAdvanceButton = findViewById(R.id.advance_search);
+ mEditText = (SearchEditText) findViewById(R.id.search_edit_text);
+ mSearchButton = findViewById(R.id.search_action);
+ mDrawerArrowDrawable = new DrawerArrowDrawable(getContext());
+
+ mMenuButton.setDrawable(mDrawerArrowDrawable);
mMenuButton.setOnClickListener(this);
- mLogoTextView.setTypeface(Typeface.createFromAsset(context.getAssets(),
- "fonts/Slabo.ttf"));
+ mLogoTextView.setTypeface(Typeface.createFromAsset(context.getAssets(), "fonts/Slabo.ttf"));
+ mAdvanceButton.setOnClickListener(this);
+ mEditText.setSearchBar(this);
+ mEditText.setOnEditorActionListener(this);
+ mSearchButton.setOnClickListener(this);
}
public void setHelper(Helper helper) {
@@ -67,14 +96,84 @@ public class SearchBar extends CardView implements View.OnClickListener {
@Override
public void onClick(View v) {
- if (v == mMenuButton) {
- if (mHelper != null) {
+ if (v == this) {
+ setInEditMode();
+ } else if (v == mMenuButton) {
+ if (mInEditMode) {
+ setInNormalMode();
+ } else {
mHelper.onClickMenu();
}
+ } else if (v == mAdvanceButton) {
+ mHelper.onClickAdvance();
+ } else if (v == mSearchButton) {
+ String query = mEditText.getText().toString();
+ if (!TextUtils.isEmpty(query)) {
+ mHelper.onApplySearch(query);
+ }
+ }
+ }
+
+ @Override
+ public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
+ if (v == mEditText) {
+ if (actionId == EditorInfo.IME_ACTION_SEARCH || actionId == EditorInfo.IME_NULL) {
+ String query = mEditText.getText().toString();
+ if (!TextUtils.isEmpty(query)) {
+ mHelper.onApplySearch(query);
+ }
+ return true;
+ }
+ }
+ return false;
+ }
+
+ public void setInEditMode() {
+ if (!mInEditMode) {
+ mInEditMode = true;
+ setClickable(false);
+ ViewUtils.setVisibility(mLogoTextView, View.GONE);
+ ViewUtils.setVisibility(mAdvanceButton, View.GONE);
+ ViewUtils.setVisibility(mEditText, View.VISIBLE);
+ ViewUtils.setVisibility(mSearchButton, View.VISIBLE);
+ mEditText.requestFocus();
+ // show ime
+ InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
+ // start animator
+ ObjectAnimator oa = ObjectAnimator.ofFloat(mDrawerArrowDrawable, "progress", 0f, 1f);
+ oa.setDuration(ANIMATION_TIME);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ oa.setAutoCancel(true);
+ }
+ oa.start();
+ }
+ }
+
+ public void setInNormalMode() {
+ if (mInEditMode) {
+ mInEditMode = false;
+ setOnClickListener(this);
+ ViewUtils.setVisibility(mLogoTextView, View.VISIBLE);
+ ViewUtils.setVisibility(mAdvanceButton, View.VISIBLE);
+ ViewUtils.setVisibility(mEditText, View.GONE);
+ ViewUtils.setVisibility(mSearchButton, View.GONE);
+ // hide ime
+ InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+ imm.hideSoftInputFromWindow(this.getWindowToken(), 0);
+ // start animator
+ ObjectAnimator oa = ObjectAnimator.ofFloat(mDrawerArrowDrawable, "progress", 1f, 0f);
+ oa.setDuration(ANIMATION_TIME);
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ oa.setAutoCancel(true);
+ }
+ oa.start();
}
}
public interface Helper {
void onClickMenu();
+ void onClickAdvance();
+ void onApplySearch(String query);
}
}
diff --git a/app/src/main/java/com/hippo/ehviewer/widget/SearchEditText.java b/app/src/main/java/com/hippo/ehviewer/widget/SearchEditText.java
new file mode 100644
index 000000000..a5f3687b1
--- /dev/null
+++ b/app/src/main/java/com/hippo/ehviewer/widget/SearchEditText.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 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
+ * 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.widget;
+
+import android.content.Context;
+import android.support.annotation.NonNull;
+import android.util.AttributeSet;
+import android.view.KeyEvent;
+import android.widget.EditText;
+
+public class SearchEditText extends EditText {
+
+ private SearchBar mSearchBar;
+
+ public SearchEditText(Context context) {
+ super(context);
+ }
+
+ public SearchEditText(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public SearchEditText(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ public void setSearchBar(SearchBar searchBar) {
+ mSearchBar = searchBar;
+ }
+
+ @Override
+ public boolean onKeyPreIme(int keyCode, @NonNull KeyEvent event) {
+ if (keyCode == KeyEvent.KEYCODE_BACK) {
+ // special case for the back key, we do not even try to send it
+ // to the drop down list but instead, consume it immediately
+ if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
+ KeyEvent.DispatcherState state = getKeyDispatcherState();
+ if (state != null) {
+ state.startTracking(event, this);
+ }
+ return true;
+ } else if (event.getAction() == KeyEvent.ACTION_UP) {
+ KeyEvent.DispatcherState state = getKeyDispatcherState();
+ if (state != null) {
+ state.handleUpEvent(event);
+ }
+ if (event.isTracking() && !event.isCanceled()) {
+ if (mSearchBar != null) {
+ mSearchBar.setInNormalMode();
+ return true;
+ }
+ }
+ }
+ }
+ return super.onKeyPreIme(keyCode, event);
+ }
+}
diff --git a/app/src/main/java/com/hippo/scene/StageLayout.java b/app/src/main/java/com/hippo/scene/StageLayout.java
index 12546548b..363fba107 100644
--- a/app/src/main/java/com/hippo/scene/StageLayout.java
+++ b/app/src/main/java/com/hippo/scene/StageLayout.java
@@ -15,10 +15,8 @@
package com.hippo.scene;
-import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.Rect;
-import android.os.Build;
import android.os.Parcelable;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
@@ -43,11 +41,6 @@ public class StageLayout extends FrameLayout {
super(context, attrs, defStyleAttr);
}
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public StageLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- }
-
@Override
protected void dispatchSaveInstanceState(@NonNull SparseArray container) {
// Do nothing
diff --git a/app/src/main/java/com/hippo/util/ApiHelper.java b/app/src/main/java/com/hippo/util/ApiHelper.java
deleted file mode 100644
index b36379eaf..000000000
--- a/app/src/main/java/com/hippo/util/ApiHelper.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 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
- * 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.util;
-
-import android.os.Build;
-
-public class ApiHelper {
-
- public static final boolean HAS_AUTO_CANCEL_ON_ANIMATION =
- Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2;
-}
diff --git a/app/src/main/java/com/hippo/widget/CheckTextView.java b/app/src/main/java/com/hippo/widget/CheckTextView.java
index dd9a74a0b..1044c68e5 100644
--- a/app/src/main/java/com/hippo/widget/CheckTextView.java
+++ b/app/src/main/java/com/hippo/widget/CheckTextView.java
@@ -30,7 +30,6 @@ import android.view.View;
import android.view.View.OnClickListener;
import android.widget.TextView;
-import com.hippo.util.ApiHelper;
import com.hippo.util.MathUtils;
public class CheckTextView extends TextView implements OnClickListener, Hotspotable {
@@ -131,7 +130,7 @@ public class CheckTextView extends TextView implements OnClickListener, Hotspota
}
radiusAnim.setDuration(ANIMATION_DURATION); // TODO decide duration according to mMaxRadius
radiusAnim.addListener(mAnimatorListener);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
radiusAnim.setAutoCancel(true);
}
radiusAnim.start();
diff --git a/app/src/main/java/com/hippo/widget/DrawerFrameLayout.java b/app/src/main/java/com/hippo/widget/DrawerFrameLayout.java
index 182cdeaa6..07ab4d3f0 100644
--- a/app/src/main/java/com/hippo/widget/DrawerFrameLayout.java
+++ b/app/src/main/java/com/hippo/widget/DrawerFrameLayout.java
@@ -15,11 +15,9 @@
package com.hippo.widget;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Rect;
-import android.os.Build;
import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.widget.FrameLayout;
@@ -39,27 +37,20 @@ public class DrawerFrameLayout extends FrameLayout {
public DrawerFrameLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- init(context, attrs, 0, 0);
+ init(context, attrs);
}
public DrawerFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- init(context, attrs, defStyleAttr, 0);
+ init(context, attrs);
}
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public DrawerFrameLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- init(context, attrs, defStyleAttr, defStyleRes);
- }
-
- private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- final TypedArray a = context.obtainStyledAttributes(attrs, MAX_ATTRS, defStyleAttr, defStyleRes);
+ private void init(Context context, AttributeSet attrs) {
+ final TypedArray a = context.obtainStyledAttributes(attrs, MAX_ATTRS);
mMaxWidth = a.getDimensionPixelSize(0, -1);
a.recycle();
}
-
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
int widthSpecSize = MeasureSpec.getSize(widthMeasureSpec);
diff --git a/app/src/main/java/com/hippo/widget/FixedAspectLayout.java b/app/src/main/java/com/hippo/widget/FixedAspectLayout.java
index 8d7b56966..003a1d50d 100644
--- a/app/src/main/java/com/hippo/widget/FixedAspectLayout.java
+++ b/app/src/main/java/com/hippo/widget/FixedAspectLayout.java
@@ -15,10 +15,8 @@
package com.hippo.widget;
-import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.TypedArray;
-import android.os.Build;
import android.util.AttributeSet;
import android.widget.FrameLayout;
@@ -37,23 +35,17 @@ public class FixedAspectLayout extends FrameLayout {
public FixedAspectLayout(Context context, AttributeSet attrs) {
super(context, attrs);
- init(context, attrs, 0, 0);
+ init(context, attrs);
}
public FixedAspectLayout(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
- init(context, attrs, defStyleAttr, 0);
+ init(context, attrs);
}
- @TargetApi(Build.VERSION_CODES.LOLLIPOP)
- public FixedAspectLayout(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
- super(context, attrs, defStyleAttr, defStyleRes);
- init(context, attrs, defStyleAttr, defStyleRes);
- }
-
- private void init(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
+ private void init(Context context, AttributeSet attrs) {
TypedArray a = context.obtainStyledAttributes(
- attrs, R.styleable.FixedAspectLayout, defStyleAttr, defStyleRes);
+ attrs, R.styleable.FixedAspectLayout);
setAspect(a.getFloat(R.styleable.FixedAspectLayout_aspect, -1f));
a.recycle();
}
diff --git a/app/src/main/java/com/hippo/widget/FloatLabelEditText.java b/app/src/main/java/com/hippo/widget/FloatLabelEditText.java
index 0d65687ea..6660d2a6a 100644
--- a/app/src/main/java/com/hippo/widget/FloatLabelEditText.java
+++ b/app/src/main/java/com/hippo/widget/FloatLabelEditText.java
@@ -33,7 +33,6 @@ import android.widget.FrameLayout;
import android.widget.TextView;
import com.hippo.ehviewer.R;
-import com.hippo.util.ApiHelper;
// Get code from https://gist.github.com/jromero/233cfd8ef22a8b8c29ea
/**
@@ -142,7 +141,7 @@ public class FloatLabelEditText extends FrameLayout {
"translationY", mLabel.getHeight(), 0f);
translationYAnim.setDuration(ANIMATION_DURATION);
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
alphaAnim.setAutoCancel(true);
translationYAnim.setAutoCancel(true);
}
@@ -172,7 +171,7 @@ public class FloatLabelEditText extends FrameLayout {
}
});
- if (ApiHelper.HAS_AUTO_CANCEL_ON_ANIMATION) {
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
alphaAnim.setAutoCancel(true);
translationYAnim.setAutoCancel(true);
}
diff --git a/app/src/main/java/com/hippo/widget/SimpleImageView.java b/app/src/main/java/com/hippo/widget/SimpleImageView.java
index 528c9b71a..8f30d753f 100644
--- a/app/src/main/java/com/hippo/widget/SimpleImageView.java
+++ b/app/src/main/java/com/hippo/widget/SimpleImageView.java
@@ -19,10 +19,11 @@ import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
+import android.support.annotation.NonNull;
import android.util.AttributeSet;
import android.view.View;
-public class SimpleImageView extends View {
+public class SimpleImageView extends View implements Drawable.Callback {
private Drawable mDrawable;
@@ -42,10 +43,26 @@ public class SimpleImageView extends View {
private void init(Context context, AttributeSet attrs) {
final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
- mDrawable = a.getDrawable(0);
+ setDrawable(a.getDrawable(0));
a.recycle();
}
+ public void setDrawable(Drawable drawable) {
+ if (mDrawable != null) {
+ mDrawable.setCallback(null);
+ }
+ mDrawable = drawable;
+ if (mDrawable != null) {
+ mDrawable.setCallback(this);
+ }
+ requestLayout();
+ }
+
+ @Override
+ public void invalidateDrawable(@NonNull Drawable who) {
+ invalidate();
+ }
+
@Override
protected int getSuggestedMinimumWidth() {
int superMinWidth = super.getSuggestedMinimumWidth();
diff --git a/app/src/main/res/drawable/ic_search.xml b/app/src/main/res/drawable/ic_search.xml
new file mode 100644
index 000000000..edc784068
--- /dev/null
+++ b/app/src/main/res/drawable/ic_search.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/drawable/ic_fab_search.xml b/app/src/main/res/drawable/ic_search_dark.xml
similarity index 90%
rename from app/src/main/res/drawable/ic_fab_search.xml
rename to app/src/main/res/drawable/ic_search_dark.xml
index f6bcb6de3..d1e784358 100644
--- a/app/src/main/res/drawable/ic_fab_search.xml
+++ b/app/src/main/res/drawable/ic_search_dark.xml
@@ -31,9 +31,9 @@
+ android:fillColor="@color/primary_drawable_dark"/>
diff --git a/app/src/main/res/layout/widget_search_bar.xml b/app/src/main/res/layout/widget_search_bar.xml
index 43c725ee5..ec17c3a97 100644
--- a/app/src/main/res/layout/widget_search_bar.xml
+++ b/app/src/main/res/layout/widget_search_bar.xml
@@ -17,29 +17,71 @@
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
-
+
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/widget_search_layout.xml b/app/src/main/res/layout/widget_search_layout.xml
index 7d2493288..0c8043e87 100644
--- a/app/src/main/res/layout/widget_search_layout.xml
+++ b/app/src/main/res/layout/widget_search_layout.xml
@@ -31,6 +31,6 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
auto:color="?attr/colorAccent"
- auto:drawable="@drawable/ic_fab_search"/>
+ auto:drawable="@drawable/ic_search_dark"/>
diff --git a/app/src/main/res/values/bools.xml b/app/src/main/res/values/bools.xml
index 1841ac55c..924cfb446 100644
--- a/app/src/main/res/values/bools.xml
+++ b/app/src/main/res/values/bools.xml
@@ -17,4 +17,6 @@
false
+ true
+
diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml
index 4374a3033..fb163d163 100644
--- a/app/src/main/res/values/colors.xml
+++ b/app/src/main/res/values/colors.xml
@@ -24,6 +24,11 @@
-->
+ #8a000000
+ #42000000
+ #ffffffff
+ #4dffffff
+
#fff44336
@@ -55,10 +60,11 @@
#ffffc107
- #de000000
- #8a000000
- #deffffff
- #61ffffff
+
+ #de000000
+ #8a000000
+ #deffffff
+ #61ffffff
#ff303030
#ffeeeeee
diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml
index 6daa13869..92dee9f73 100644
--- a/app/src/main/res/values/dimens.xml
+++ b/app/src/main/res/values/dimens.xml
@@ -72,6 +72,16 @@
60dp
44dp
+
+ 24dp
+ 18dp
+ 11.31dp
+ 2dp
+ 3dp
+ 16dp
+
+
+
24sp
22sp