Update
This commit is contained in:
1 parent
4133bb4e7b
commit
dbbcebab67
23 files changed
+564
-120
No files matched your search
+2
-2
@@ -1,7 +1,7 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="PROJECT_PROFILE" value="Project Default" />
|
||||
<option name="USE_PROJECT_PROFILE" value="true" />
|
||||
<option name="PROJECT_PROFILE" />
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
||||
Vendored
+15
-9
@@ -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 {*;}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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<Parcelable> container) {
|
||||
// Do nothing
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ 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.
|
||||
-->
|
||||
<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_search"
|
||||
auto:fillColor="@color/primary_drawable_light"
|
||||
|
||||
android:pathData="@string/pd_search"
|
||||
android:fillColor="@color/primary_drawable_light"/>
|
||||
|
||||
</vector>
|
||||
+2
-2
@@ -31,9 +31,9 @@
|
||||
|
||||
<path
|
||||
auto:pathData="@string/pd_search"
|
||||
auto:fillColor="@android:color/white"
|
||||
auto:fillColor="@color/primary_drawable_dark"
|
||||
|
||||
android:pathData="@string/pd_search"
|
||||
android:fillColor="@android:color/white"/>
|
||||
android:fillColor="@color/primary_drawable_dark"/>
|
||||
|
||||
</vector>
|
||||
@@ -17,29 +17,71 @@
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:tools="http://schemas.android.com/tools">
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/ic_menu"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:orientation="vertical">
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:paddingLeft="56dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"/>
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp">
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/ic_android_debug_bridge"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:id="@+id/menu"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:padding="14dp"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/logo"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="left|center_vertical"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:text="@string/app_name"
|
||||
android:textSize="@dimen/text_large"
|
||||
tools:ignore="RtlHardcoded,RtlSymmetry"/>
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:id="@+id/advance_search"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/ic_android_debug_bridge"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
|
||||
<com.hippo.ehviewer.widget.SearchEditText
|
||||
android:id="@+id/search_edit_text"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="56dp"
|
||||
android:layout_marginRight="56dp"
|
||||
android:background="@null"
|
||||
android:singleLine="true"
|
||||
android:visibility="gone"
|
||||
android:imeOptions="actionSearch"
|
||||
android:inputType="textAutoComplete"/>
|
||||
|
||||
<com.hippo.widget.SimpleImageView
|
||||
android:id="@+id/search_action"
|
||||
android:layout_width="56dp"
|
||||
android:layout_height="56dp"
|
||||
android:layout_gravity="right|center_vertical"
|
||||
android:padding="14dp"
|
||||
android:src="@drawable/ic_search"
|
||||
android:visibility="gone"
|
||||
tools:ignore="RtlHardcoded"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
<ListView
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</merge>
|
||||
@@ -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"/>
|
||||
|
||||
</merge>
|
||||
@@ -17,4 +17,6 @@
|
||||
|
||||
<bool name="is_table">false</bool>
|
||||
|
||||
<bool name="dad_spin_bars">true</bool>
|
||||
|
||||
</resources>
|
||||
@@ -24,6 +24,11 @@
|
||||
-->
|
||||
<resources>
|
||||
|
||||
<color name="primary_drawable_light">#8a000000</color>
|
||||
<color name="secondary_drawable_light">#42000000</color>
|
||||
<color name="primary_drawable_dark">#ffffffff</color>
|
||||
<color name="secondary_drawable_dark">#4dffffff</color>
|
||||
|
||||
<!-- Red -->
|
||||
<color name="doujinshi">#fff44336</color>
|
||||
<!-- Orange -->
|
||||
@@ -55,10 +60,11 @@
|
||||
|
||||
<color name="material_amber_500">#ffffc107</color>
|
||||
|
||||
<color name="primary_text_dark">#de000000</color>
|
||||
<color name="secondary_text_dark">#8a000000</color>
|
||||
<color name="primary_text_light">#deffffff</color>
|
||||
<color name="secondary_text_light">#61ffffff</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="background_dark">#ff303030</color>
|
||||
<color name="background_light">#ffeeeeee</color>
|
||||
|
||||
@@ -72,6 +72,16 @@
|
||||
<dimen name="fab_size">60dp</dimen>
|
||||
<dimen name="fab_size_small">44dp</dimen>
|
||||
|
||||
<!-- DrawerArrowDrawable -->
|
||||
<dimen name="dad_drawable_size">24dp</dimen>
|
||||
<dimen name="dad_bar_size">18dp</dimen>
|
||||
<dimen name="dad_top_bottom_bar_arrow_size">11.31dp</dimen>
|
||||
<dimen name="dad_thickness">2dp</dimen>
|
||||
<dimen name="dad_gap_between_bars">3dp</dimen>
|
||||
<dimen name="dad_middle_bar_arrow_size">16dp</dimen>
|
||||
|
||||
|
||||
|
||||
<!-- Text size -->
|
||||
<dimen name="text_super_large">24sp</dimen>
|
||||
<dimen name="text_large">22sp</dimen>
|
||||
|
||||
Reference in new issue
Block a user