From 08d0794fe8595d1f36bee1a095169098f56e8554 Mon Sep 17 00:00:00 2001 From: seven332 Date: Mon, 18 May 2015 00:15:49 +0800 Subject: [PATCH] Add sign in scene --- .../hippo/ehviewer/network/EhHttpHelper.java | 5 + .../hippo/ehviewer/ui/ContentActivity.java | 23 ++- .../ehviewer/ui/scene/GalleryListScene.java | 2 +- .../hippo/ehviewer/ui/scene/SignInScene.java | 57 ++++++ .../java/com/hippo/ehviewer/util/Config.java | 22 +++ .../ehviewer/widget/DrawerLeftPanel.java | 32 +++- .../java/com/hippo/scene/SimpleCurtain.java | 165 ++++++++++++++++++ .../com/hippo/scene/SimpleDialogCurtain.java | 15 +- .../java/com/hippo/scene/StageActivity.java | 9 + .../com/hippo/widget/FloatLabelEditText.java | 67 ++++--- .../res/color/float_label_edit_text_light.xml | 2 +- app/src/main/res/layout/scene_sign_in.xml | 121 +++++++++++++ app/src/main/res/mipmap-mdpi/ic_launcher.png | Bin 1086 -> 0 bytes app/src/main/res/values-zh-rCN/strings.xml | 15 ++ app/src/main/res/values/strings.xml | 7 + 15 files changed, 495 insertions(+), 47 deletions(-) create mode 100644 app/src/main/java/com/hippo/ehviewer/ui/scene/SignInScene.java create mode 100644 app/src/main/java/com/hippo/scene/SimpleCurtain.java create mode 100644 app/src/main/res/layout/scene_sign_in.xml delete mode 100644 app/src/main/res/mipmap-mdpi/ic_launcher.png diff --git a/app/src/main/java/com/hippo/ehviewer/network/EhHttpHelper.java b/app/src/main/java/com/hippo/ehviewer/network/EhHttpHelper.java index 7be731735..35a2cd19f 100644 --- a/app/src/main/java/com/hippo/ehviewer/network/EhHttpHelper.java +++ b/app/src/main/java/com/hippo/ehviewer/network/EhHttpHelper.java @@ -27,6 +27,11 @@ public class EhHttpHelper extends HttpHelper { private static final Pool sPool = new Pool<>(10); + private static String[] EHENTAI_DOMAIN = { + "exhentai.org", + "e-hentai.org" + }; + public static @NonNull EhHttpHelper obtain() { EhHttpHelper ehh = sPool.obtain(); if (ehh == null) { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java b/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java index 429e87b99..18e5ef58d 100644 --- a/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java +++ b/app/src/main/java/com/hippo/ehviewer/ui/ContentActivity.java @@ -29,16 +29,19 @@ import android.widget.AdapterView; import com.hippo.content.VectorContext; import com.hippo.ehviewer.R; import com.hippo.ehviewer.ui.scene.GalleryListScene; +import com.hippo.ehviewer.ui.scene.SignInScene; import com.hippo.ehviewer.util.Config; import com.hippo.ehviewer.widget.DrawerLeftPanel; import com.hippo.ehviewer.widget.StatusBarLayout; import com.hippo.scene.Announcer; +import com.hippo.scene.SimpleCurtain; import com.hippo.scene.StageActivity; import com.hippo.scene.StageLayout; import com.hippo.widget.DrawerListView; -public class ContentActivity extends StageActivity - implements StatusBarLayout.OnGetFitPaddingBottomListener { +public final class ContentActivity extends StageActivity + implements StatusBarLayout.OnGetFitPaddingBottomListener, + DrawerLeftPanel.Helper { public static final int DRAWER_LIST_NONE = -1; public static final int DRAWER_LIST_HOMEPAGE = 0; @@ -92,6 +95,7 @@ public class ContentActivity extends StageActivity return Config.getShowApplicationStats(); } + @SuppressLint("RtlHardcoded") @SuppressWarnings("deprecation") @Override protected void onCreate(Bundle savedInstanceState) { @@ -108,6 +112,10 @@ public class ContentActivity extends StageActivity mStatusBarLayout.setOnGetFitPaddingBottomListener(this); + mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow_left, Gravity.LEFT); + + mDrawerLeftPanel.setHelper(this); + // Drawer Drawable[] drawerListDrawables = new Drawable[] { mResources.getDrawable(R.drawable.ic_drawer_list_home), @@ -171,4 +179,15 @@ public class ContentActivity extends StageActivity public void onGetFitPaddingBottom(int b) { setFitPaddingBottom(b); } + + @Override + public void onClickSignIn() { + mDrawerLayout.closeDrawers(); + startScene(SignInScene.class, null, new SimpleCurtain(SimpleCurtain.DIRECTION_BOTTOM)); + } + + @Override + public void onClickSignOut() { + + } } 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 dbe2793db..909109e80 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 @@ -76,7 +76,7 @@ import java.util.List; // TODO remeber the data in ContentHelper after screen dirction change // TODO Must refresh when change source // TODO disable click action when animating -public class GalleryListScene extends Scene implements SearchBar.Helper, +public final class GalleryListScene extends Scene implements SearchBar.Helper, View.OnClickListener, FabLayout.OnCancelListener, SearchLayout.SearhLayoutHelper { diff --git a/app/src/main/java/com/hippo/ehviewer/ui/scene/SignInScene.java b/app/src/main/java/com/hippo/ehviewer/ui/scene/SignInScene.java new file mode 100644 index 000000000..9984aed64 --- /dev/null +++ b/app/src/main/java/com/hippo/ehviewer/ui/scene/SignInScene.java @@ -0,0 +1,57 @@ +/* + * 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.ui.scene; + +import android.annotation.Nullable; +import android.os.Bundle; +import android.view.View; +import android.widget.TextView; + +import com.hippo.effect.ripple.RippleSalon; +import com.hippo.ehviewer.R; +import com.hippo.scene.Scene; + +public class SignInScene extends Scene { + + private View mMainView; + private TextView mSignUp; + private TextView mSignIn; + + @Override + public int getLaunchMode() { + return LAUNCH_MODE_SINGLE_TOP; + } + + @Override + protected void onCreate(@Nullable Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.scene_sign_in); + + mMainView = findViewById(R.id.sigin_in_main); + mSignUp = (TextView) mMainView.findViewById(R.id.sign_up); + mSignIn = (TextView) mMainView.findViewById(R.id.sign_in); + + RippleSalon.addRipple(mSignUp, false); + RippleSalon.addRipple(mSignIn, false); + } + + @Override + protected void onGetFitPaddingBottom(int b) { + mMainView.setPadding(mMainView.getPaddingLeft(), + mMainView.getPaddingTop(), + mMainView.getPaddingRight(), b); + } +} diff --git a/app/src/main/java/com/hippo/ehviewer/util/Config.java b/app/src/main/java/com/hippo/ehviewer/util/Config.java index a0b843517..174a1d773 100644 --- a/app/src/main/java/com/hippo/ehviewer/util/Config.java +++ b/app/src/main/java/com/hippo/ehviewer/util/Config.java @@ -80,6 +80,10 @@ public final class Config { private static final String KEY_EH_SOURCE = "eh_source"; private static final int DEFAULT_EH_SOURCE = BuildConfig.DEBUG ? EhClient.SOURCE_LOFI : EhClient.SOURCE_G; + private static final String KEY_IPD_MEMBER_ID = "ipb_member_id"; + private static final String DEFAULT_IPD_MEMBER_ID = null; + private static final String KEY_IPD_PASS_HASH = "ipb_pass_hash"; + private static final String DEFAULT_IPD_PASS_HASH = null; public static int getEhSource() { int value = getInt(KEY_EH_SOURCE, DEFAULT_EH_SOURCE); @@ -97,6 +101,24 @@ public final class Config { Messenger.getInstance().notify(Constants.MESSENGER_ID_EH_SOURCE, value); } + public static String getIpdNumberId() { + return getString(KEY_IPD_MEMBER_ID, DEFAULT_IPD_MEMBER_ID); + } + + public static void putIpdMemberId(String value) { + putString(KEY_IPD_MEMBER_ID, value); + } + + public static String getIpdPassHash() { + return getString(KEY_IPD_PASS_HASH, DEFAULT_IPD_PASS_HASH); + } + + public static void putIpdPassHash(String value) { + putString(KEY_IPD_PASS_HASH, value); + } + + + /****** Advance ******/ private static final String KEY_SHOW_APPLICATION_STATS = "show_application_stats"; diff --git a/app/src/main/java/com/hippo/ehviewer/widget/DrawerLeftPanel.java b/app/src/main/java/com/hippo/ehviewer/widget/DrawerLeftPanel.java index 18c1d504f..a7e9a8734 100644 --- a/app/src/main/java/com/hippo/ehviewer/widget/DrawerLeftPanel.java +++ b/app/src/main/java/com/hippo/ehviewer/widget/DrawerLeftPanel.java @@ -65,6 +65,8 @@ public class DrawerLeftPanel extends LinearLayout { private boolean mSignIn; + private Helper mHelper; + private Messenger.Receiver mMessengerReceiver = new Messenger.Receiver() { @Override public void onReceive(int id, Object obj) { @@ -117,20 +119,37 @@ public class DrawerLeftPanel extends LinearLayout { mDrawerListView = (DrawerListView) getChildAt(1); RippleSalon.addRipple(mAction, false); - - mAvatar.setImageURI(DEFAULT_AVATAR_URI); - mUsename.setText(""); - mAction.setText(mContext.getString(R.string.signin)); + mAction.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (mHelper != null) { + if (mSignIn) { + mHelper.onClickSignOut(); + } else { + mHelper.onClickSignIn(); + } + } + } + }); mSuperUserPanelHeight = mSuperUserPanel.getLayoutParams().height; mUserPanelOriginalPaddingTop = mUserPanel.getPaddingTop(); mDrawerListViewOriginalPaddingBottom = mDrawerListView.getPaddingBottom(); + + // TODO + mAvatar.setImageURI(DEFAULT_AVATAR_URI); + mUsename.setText(""); + mAction.setText(mContext.getString(R.string.signin)); } public DrawerListView getDrawerListView() { return mDrawerListView; } + public void setHelper(Helper helper) { + mHelper = helper; + } + @Override protected void onAttachedToWindow() { super.onAttachedToWindow(); @@ -217,4 +236,9 @@ public class DrawerLeftPanel extends LinearLayout { return super.fitSystemWindows(insets); } + + public interface Helper { + void onClickSignIn(); + void onClickSignOut(); + } } diff --git a/app/src/main/java/com/hippo/scene/SimpleCurtain.java b/app/src/main/java/com/hippo/scene/SimpleCurtain.java new file mode 100644 index 000000000..98e358cf8 --- /dev/null +++ b/app/src/main/java/com/hippo/scene/SimpleCurtain.java @@ -0,0 +1,165 @@ +/* + * 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.scene; + +import android.animation.Animator; +import android.animation.ObjectAnimator; +import android.animation.PropertyValuesHolder; +import android.support.annotation.NonNull; +import android.view.View; +import android.view.ViewTreeObserver; + +import com.hippo.animation.SimpleAnimatorListener; +import com.hippo.util.AnimationUtils; +import com.hippo.util.AssertUtils; +import com.hippo.util.ViewUtils; + +public class SimpleCurtain extends Curtain { + + private static long ANIMATE_TIME = 300L; + + public static final int DIRECTION_LEFT = 0; + public static final int DIRECTION_TOP = 1; + public static final int DIRECTION_RIGHT = 2; + public static final int DIRECTION_BOTTOM = 3; + + private int mDirection; + + private Animator mAnimator; + + public SimpleCurtain(int direction) { + mDirection = direction; + } + + @Override + public void open(@NonNull final Scene enter, @NonNull final Scene exit) { + final View enterSceneView = enter.getSceneView(); + AssertUtils.assertNotNull("Enter scene view must not be null.", enterSceneView); + + ViewUtils.setVisibility(enterSceneView, View.INVISIBLE); + + enterSceneView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { + @Override + public void onGlobalLayout() { + ViewUtils.removeOnGlobalLayoutListener(enterSceneView.getViewTreeObserver(), this); + + int width = enterSceneView.getWidth(); + int height = enterSceneView.getHeight(); + float translationX = 0f; + float translationY = 0f; + switch (mDirection) { + case DIRECTION_LEFT: + translationX = -width; + break; + case DIRECTION_TOP: + translationY = -height; + break; + case DIRECTION_RIGHT: + translationX = width; + break; + default: + case DIRECTION_BOTTOM: + translationY = height; + break; + } + PropertyValuesHolder pvh; + if (translationX != 0f) { + pvh = PropertyValuesHolder.ofFloat("translationX", translationX, 0f); + } else { + pvh = PropertyValuesHolder.ofFloat("translationY", translationY, 0f); + } + Animator animator = ObjectAnimator.ofPropertyValuesHolder(enterSceneView, pvh); + animator.setDuration(ANIMATE_TIME); + animator.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); + animator.addListener(new SimpleAnimatorListener() { + @Override + public void onAnimationStart(Animator animation) { + ViewUtils.setVisibility(enterSceneView, View.VISIBLE); + } + + @Override + public void onAnimationEnd(Animator animation, boolean canceled) { + super.onAnimationEnd(animation, canceled); + dispatchOpenFinished(enter, exit); + hideSceneOnOpen(exit); + mAnimator = null; + } + }); + animator.start(); + mAnimator = animator; + } + }); + } + + @Override + public void close(@NonNull final Scene enter, @NonNull final Scene exit) { + showSceneOnClose(enter); + + final View exitSceneView = exit.getSceneView(); + AssertUtils.assertNotNull("Exit scene view must not be null.", exitSceneView); + + int width = exitSceneView.getWidth(); + int height = exitSceneView.getHeight(); + float translationX = 0f; + float translationY = 0f; + switch (mDirection) { + case DIRECTION_LEFT: + translationX = -width; + break; + case DIRECTION_TOP: + translationY = -height; + break; + case DIRECTION_RIGHT: + translationX = width; + break; + default: + case DIRECTION_BOTTOM: + translationY = height; + break; + } + PropertyValuesHolder pvh; + if (translationX != 0f) { + pvh = PropertyValuesHolder.ofFloat("translationX", 0f, translationX); + } else { + pvh = PropertyValuesHolder.ofFloat("translationY", 0f, translationY); + } + Animator animator = ObjectAnimator.ofPropertyValuesHolder(exitSceneView, pvh); + animator.setDuration(ANIMATE_TIME); + animator.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR); + animator.addListener(new SimpleAnimatorListener() { + @Override + public void onAnimationEnd(Animator animation, boolean canceled) { + super.onAnimationEnd(animation, canceled); + dispatchCloseFinished(enter, exit); + mAnimator = null; + } + }); + animator.start(); + mAnimator = animator; + } + + @Override + public void endAnimation() { + if (mAnimator != null) { + mAnimator.end(); + } + } + + @Override + public boolean isInAnimation() { + return mAnimator != null; + } +} diff --git a/app/src/main/java/com/hippo/scene/SimpleDialogCurtain.java b/app/src/main/java/com/hippo/scene/SimpleDialogCurtain.java index 8b91fc340..6e0799e30 100644 --- a/app/src/main/java/com/hippo/scene/SimpleDialogCurtain.java +++ b/app/src/main/java/com/hippo/scene/SimpleDialogCurtain.java @@ -20,14 +20,12 @@ import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.animation.PropertyValuesHolder; import android.support.annotation.NonNull; -import android.support.v4.view.animation.FastOutLinearInInterpolator; -import android.support.v4.view.animation.LinearOutSlowInInterpolator; import android.view.View; import android.view.ViewTreeObserver; -import android.view.animation.Interpolator; import com.hippo.animation.ArgbEvaluator; import com.hippo.animation.SimpleAnimatorListener; +import com.hippo.util.AnimationUtils; import com.hippo.util.AssertUtils; import com.hippo.util.ViewUtils; @@ -38,9 +36,6 @@ public class SimpleDialogCurtain extends Curtain { private static long ANIMATE_TIME = 300L; - private final static Interpolator FAST_OUT_LINEAR_IN_INTERPOLATOR = new FastOutLinearInInterpolator(); - private final static Interpolator LINEAR_OUT_SLOW_IN_INTERPOLATOR = new LinearOutSlowInInterpolator(); - private int mStartX; private int mStartY; @@ -69,7 +64,7 @@ public class SimpleDialogCurtain extends Curtain { ObjectAnimator colorAnim = ObjectAnimator.ofInt(enter, "backgroundColor", bgColor); colorAnim.setEvaluator(ArgbEvaluator.getInstance()); colorAnim.setDuration(ANIMATE_TIME); - colorAnim.setInterpolator(LINEAR_OUT_SLOW_IN_INTERPOLATOR); + colorAnim.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); animatorCollection.add(colorAnim); final View mFrame = enterDialog.getFrame(); @@ -111,7 +106,7 @@ public class SimpleDialogCurtain extends Curtain { PropertyValuesHolder bottomPvh = PropertyValuesHolder.ofInt("drawBottom", startBottom, endBottom); ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(mFrame, leftPvh, topPvh, rightPvh, bottomPvh); anim.setDuration(ANIMATE_TIME); - anim.setInterpolator(LINEAR_OUT_SLOW_IN_INTERPOLATOR); + anim.setInterpolator(AnimationUtils.FAST_SLOW_INTERPOLATOR); animatorCollection.add(anim); @@ -147,7 +142,7 @@ public class SimpleDialogCurtain extends Curtain { colorAnim.setEvaluator(ArgbEvaluator.getInstance()); colorAnim.setDuration(ANIMATE_TIME); animatorCollection.add(colorAnim); - colorAnim.setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR); + colorAnim.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR); final View mFrame = exitDialog.getFrame(); AssertUtils.assertNotNull("Frame view must not be null.", mFrame); @@ -180,7 +175,7 @@ public class SimpleDialogCurtain extends Curtain { PropertyValuesHolder bottomPvh = PropertyValuesHolder.ofInt("drawBottom", startBottom, endBottom); ObjectAnimator anim = ObjectAnimator.ofPropertyValuesHolder(mFrame, leftPvh, topPvh, rightPvh, bottomPvh); anim.setDuration(ANIMATE_TIME); - anim.setInterpolator(FAST_OUT_LINEAR_IN_INTERPOLATOR); + anim.setInterpolator(AnimationUtils.SLOW_FAST_INTERPOLATOR); animatorCollection.add(anim); diff --git a/app/src/main/java/com/hippo/scene/StageActivity.java b/app/src/main/java/com/hippo/scene/StageActivity.java index ad9a1fb65..eafb84e22 100644 --- a/app/src/main/java/com/hippo/scene/StageActivity.java +++ b/app/src/main/java/com/hippo/scene/StageActivity.java @@ -82,10 +82,19 @@ public abstract class StageActivity extends StatsActivity { } } + public void startScene(@NonNull Class sceneClass) { + sSceneManager.startScene(sceneClass, null, null); + } + public void startScene(@NonNull Class sceneClass, @Nullable Announcer announcer) { sSceneManager.startScene(sceneClass, announcer, null); } + public void startScene(@NonNull Class sceneClass, @Nullable Announcer announcer, + @Nullable Curtain curtain) { + sSceneManager.startScene(sceneClass, announcer, curtain); + } + /** * Start new Activity for result to listener * diff --git a/app/src/main/java/com/hippo/widget/FloatLabelEditText.java b/app/src/main/java/com/hippo/widget/FloatLabelEditText.java index 8cb4f3bda..cfe205679 100644 --- a/app/src/main/java/com/hippo/widget/FloatLabelEditText.java +++ b/app/src/main/java/com/hippo/widget/FloatLabelEditText.java @@ -22,13 +22,15 @@ import android.annotation.TargetApi; import android.content.Context; import android.content.res.TypedArray; import android.os.Build; +import android.support.annotation.NonNull; import android.text.Editable; import android.text.TextUtils; import android.text.TextWatcher; import android.util.AttributeSet; import android.view.Gravity; -import android.view.LayoutInflater; import android.view.View; +import android.view.ViewGroup; +import android.widget.EditText; import android.widget.FrameLayout; import android.widget.TextView; @@ -52,10 +54,11 @@ public class FloatLabelEditText extends FrameLayout { }; private TextView mLabel; - private PrefixEditText mEditText; + private EditText mEditText; private Trigger mTrigger = Trigger.TEXT; + // Text for hint text view private CharSequence mHint; public FloatLabelEditText(Context context, AttributeSet attrs) { @@ -70,39 +73,43 @@ public class FloatLabelEditText extends FrameLayout { private void init(Context context, AttributeSet attrs) { mLabel = new TextView(context); + mLabel.setVisibility(View.INVISIBLE); addView(mLabel, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT); - PrefixEditText attrCollector = new PrefixEditText(context, attrs); - mEditText = (PrefixEditText) LayoutInflater.from(getContext()).inflate( - R.layout.widget_float_label_edit_text, this, false); - final LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT); - lp.gravity = Gravity.BOTTOM; - lp.topMargin = (int) mLabel.getTextSize(); - addView(mEditText, lp); - - // Collect attr - mHint = attrCollector.getHint(); - mEditText.setInputType(attrCollector.getInputType()); - final TypedArray a = context .obtainStyledAttributes(attrs, R.styleable.FloatLabelEditText); mLabel.setTextAppearance(context, a.getResourceId(R.styleable.FloatLabelEditText_labelAppearance, android.R.style.TextAppearance_Small)); - CharSequence labelHint = a.getText(R.styleable.FloatLabelEditText_labelHint); - if (labelHint == null) { - labelHint = mHint; - } - mLabel.setText(labelHint); + mHint = a.getText(R.styleable.FloatLabelEditText_labelHint); + mLabel.setText(mHint); final int index = a.getInt(R.styleable.FloatLabelEditText_trigger, -1); if (index >= 0) { setTrigger(sTriggerArray[index]); } a.recycle(); + } - mLabel.setVisibility(View.INVISIBLE); + @Override + public final void addView(@NonNull View child, int index, ViewGroup.LayoutParams params) { + if (child instanceof EditText) { + setEditText((EditText) child); - mEditText.setHint(mHint); + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) params; + lp.gravity = Gravity.BOTTOM; + lp.topMargin = (int) mLabel.getTextSize(); + } + + // Carry on adding the View... + super.addView(child, index, params); + } + + private void setEditText(EditText editText) { + // If we already have an EditText, throw an exception + if (mEditText != null) { + throw new IllegalArgumentException("We already have an EditText, can only have one"); + } + mEditText = editText; // Add a TextWatcher so that we know when the text input has changed mEditText.addTextChangedListener(mTextWatcher); @@ -111,6 +118,11 @@ public class FloatLabelEditText extends FrameLayout { // Allows the use of a ColorStateList for the text color on the label mEditText.setOnFocusChangeListener(mOnFocusChangeListener); + // If we do not have a valid hint, try and retrieve it from the EditText + if (TextUtils.isEmpty(mHint)) { + setHint(mEditText.getHint()); + } + // Align with label and edittext mLabel.setPadding(mEditText.getPaddingLeft(), 0, 0, 0); } @@ -119,6 +131,11 @@ public class FloatLabelEditText extends FrameLayout { mTrigger = trigger; } + public void setHint(CharSequence hint) { + mHint = hint; + mLabel.setText(hint); + } + /** * Show the label using an animation */ @@ -179,14 +196,6 @@ public class FloatLabelEditText extends FrameLayout { return mEditText.getText(); } - public void setPrefix(int resId) { - mEditText.setPrefix(resId); - } - - public void setPrefix(String prefix) { - mEditText.setPrefix(prefix); - } - private TextWatcher mTextWatcher = new TextWatcher() { @Override diff --git a/app/src/main/res/color/float_label_edit_text_light.xml b/app/src/main/res/color/float_label_edit_text_light.xml index bbcf73f26..09c4e9e23 100644 --- a/app/src/main/res/color/float_label_edit_text_light.xml +++ b/app/src/main/res/color/float_label_edit_text_light.xml @@ -17,6 +17,6 @@ xmlns:android="http://schemas.android.com/apk/res/android"> - + diff --git a/app/src/main/res/layout/scene_sign_in.xml b/app/src/main/res/layout/scene_sign_in.xml new file mode 100644 index 000000000..39d5035ea --- /dev/null +++ b/app/src/main/res/layout/scene_sign_in.xml @@ -0,0 +1,121 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/mipmap-mdpi/ic_launcher.png b/app/src/main/res/mipmap-mdpi/ic_launcher.png deleted file mode 100644 index 27ba08261dd1851a1301c912a4db6b960f5c3ce7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1086 zcmV-E1i|}>P)ikJvx5*sF25Dg>~4JRUn zrCaKpZnxg|Jm>AUU3cEOo#6v7ckk`l_WYjb_x#@X?tpb$H&td(;A2Q|Y@s;kvH=)z zwV@c98Hd0yg-J;-8yvxu_Z=?Z{!V7WSU?PMKpAoW`W+aJ^}66mAn*VeE?p#N^I{Oj z815$AyLJ~QQ@w78&M*}?axf2_-LGj~qyR8zsNad)oL1d+tI=4FqV3Po_jy8C1ttnW zZcdeMC10q}CQ~8L8bd4q25y8xjBWvhSVo+5{RS&@{aUL41d_SR zR*;d2!t|{0+%Y~%WpV8Qs4Ff(Q)zj4p4D;_NKexYgfajui^|R0WVuew`{D9VqHVAr z&f!7aupNeVlZE>YOwRxr>6(C02p|Oe(G#*{;^DHEz)o@MxM5FUflpD=9XTjiNpp-H(s)<>jYC0(dz`!vz5uVbl zI>y{lZV}mD0uhIjYU!lBiD}8rW=WT}udc`o6hz#`NgbV5MTMdOh?S|tinII57n_>* zZ|r#skHMh05}FBe_Qn)c<`-~BDQl^&<$C1H#1Az0Ik`UK09nfx>BO?h0Z>Y^X+M67 zJ4*X)!QMwLIMZcE^9LtRcC>TXkL}pCOeZPIX-Od~38sSty;K1?R`cR_z88v6D2WAAE}c|Wz(sgWGfIu}-_BPTcMX=Z!DVmd7>BnCj;ZmTRwRa^<5UnPZTCW5Tu#YR7OWF&a+ z>GR>KjnKqR(Hgi*5qN%0)k;LZGCVlmQ@H75WECl!>%An&FIb zeObB0_YtdC0iwsvu1|!EK1J%}h!d0+%B8%C%^QH!RNeHz%2Y^4AXYA;Isu_>9nb*? z^$S^&K?nhaxH0D+)h!60Z%hzt%nF1sF!Wxxl^7W6h3E~97yyg5_F;Iut-1p->1jh} z_YgS?2rCf#PNB=ui~VI5ax+o7qQ@@uRxl9IF8E)QPjTzv6$*n4zYsvIx0DnVeUz4i z>dHN^mK-2^@qGR(^4}HD&8Y奇怪的问题 联网了么? + + “啥?” + “我把熊猫给丢了……” + 关键字 搜索 重试 跳页 未知 + 首页 + 热门 + 历史 + 收藏 + 下载 + 设置 + 注册 + 登录 + 退出 + 用户名 + 密码 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index fe93c06f1..78a94a68b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -89,6 +89,10 @@ Weird Network available ? + + \"What ?\" + \"I lose my panda …\" + Keyword Search Retry @@ -100,7 +104,10 @@ Favorite Download Settings + Sign up Sign in Sign out + Username + Password