[BugFix]修复发红包支付密码弹出手机自带键盘的bug
This commit is contained in:
@@ -8,13 +8,13 @@ import android.text.TextWatcher
|
||||
import android.view.KeyEvent
|
||||
import android.view.View
|
||||
import android.view.WindowManager
|
||||
import com.jungly.gridpasswordview.GridPasswordView
|
||||
import com.umeng.commonsdk.statistics.common.DeviceConfig
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseDialog
|
||||
import com.yizhuan.erban.common.widget.dialog.DialogManager
|
||||
import com.yizhuan.erban.databinding.DialogRedPackageSendBinding
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.pay.ChargeActivity
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
@@ -43,7 +43,7 @@ import org.greenrobot.eventbus.Subscribe
|
||||
import org.greenrobot.eventbus.ThreadMode
|
||||
|
||||
@ActLayoutRes(R.layout.dialog_red_package_send)
|
||||
class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPasswordView.OnPasswordChangedListener, TextWatcher {
|
||||
class RedPackageSendDialog : BaseDialog<DialogRedPackageSendBinding>(), GridPasswordNoFocusView.OnPasswordChangedListener, TextWatcher {
|
||||
|
||||
private var passWordFragment: GiveGoldPassWordFragment? = null
|
||||
private val dialogManager by lazy { DialogManager(context) }
|
||||
|
@@ -13,6 +13,7 @@ import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
import com.yizhuan.erban.databinding.ActivityEarnWithdrawBinding
|
||||
import com.yizhuan.erban.earn.EarnRecordViewModel
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.webview.CommonWebViewActivity
|
||||
import com.yizhuan.erban.ui.widget.dialog.CommonTipDialog
|
||||
@@ -27,7 +28,7 @@ import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
* desc: 提现
|
||||
*/
|
||||
class EarnWithdrawActivity : BaseViewBindingActivity<ActivityEarnWithdrawBinding>(),
|
||||
GridPasswordView.OnPasswordChangedListener {
|
||||
GridPasswordNoFocusView.OnPasswordChangedListener {
|
||||
|
||||
private val earnRecordModel: EarnRecordViewModel by viewModels()
|
||||
|
||||
|
@@ -15,7 +15,6 @@ import androidx.recyclerview.widget.GridLayoutManager
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.viewpager.widget.PagerAdapter
|
||||
import com.chad.library.adapter.base.BaseQuickAdapter
|
||||
import com.jungly.gridpasswordview.GridPasswordView
|
||||
import com.netease.nim.uikit.StatusBarUtil
|
||||
import com.yizhuan.erban.R
|
||||
import com.yizhuan.erban.base.BaseViewBindingActivity
|
||||
@@ -24,6 +23,7 @@ import com.yizhuan.erban.miniworld.listener.DoubleClickCheckListener
|
||||
import com.yizhuan.erban.pay.GiveGoldModel
|
||||
import com.yizhuan.erban.pay.adapter.GiveGiftAdapter
|
||||
import com.yizhuan.erban.pay.password.GiveGoldPassWordFragment
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity
|
||||
import com.yizhuan.erban.ui.utils.ImageLoadUtils
|
||||
import com.yizhuan.erban.ui.widget.OnPageSelectedListener
|
||||
@@ -38,13 +38,11 @@ import com.yizhuan.xchat_android_core.initial.InitialModel
|
||||
import com.yizhuan.xchat_android_core.pay.PayModel
|
||||
import com.yizhuan.xchat_android_core.user.UserModel
|
||||
import com.yizhuan.xchat_android_core.user.bean.SearchUserInfo
|
||||
import com.yizhuan.xchat_android_core.user.bean.UserInfo
|
||||
import com.yizhuan.xchat_android_core.utils.net.RxHelper
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil
|
||||
import kotlinx.android.synthetic.main.activity_give_gold_to_user.*
|
||||
|
||||
class GiveGoldToUserActivity : BaseViewBindingActivity<ActivityGiveGoldToUserBinding>(),
|
||||
GridPasswordView.OnPasswordChangedListener,
|
||||
GridPasswordNoFocusView.OnPasswordChangedListener,
|
||||
TextWatcher {
|
||||
|
||||
private val giveGoldModel: GiveGoldModel by viewModels()
|
||||
|
@@ -0,0 +1,23 @@
|
||||
package com.yizhuan.erban.pay.interfaces;
|
||||
|
||||
import com.jungly.gridpasswordview.PasswordType;
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView;
|
||||
|
||||
public interface PasswordView {
|
||||
|
||||
//void setError(String error);
|
||||
|
||||
String getPassWord();
|
||||
|
||||
void clearPassword();
|
||||
|
||||
void setPassword(String password);
|
||||
|
||||
void setPasswordVisibility(boolean visible);
|
||||
|
||||
void togglePasswordVisibility();
|
||||
|
||||
void setOnPasswordChangedListener(GridPasswordNoFocusView.OnPasswordChangedListener listener);
|
||||
|
||||
void setPasswordType(PasswordType passwordType);
|
||||
}
|
@@ -15,8 +15,8 @@ import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.DialogFragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
|
||||
import com.jungly.gridpasswordview.GridPasswordView;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView;
|
||||
import com.yizhuan.erban.ui.setting.ModifyPwdActivity;
|
||||
import com.yizhuan.xchat_android_library.utils.ResUtil;
|
||||
|
||||
@@ -26,7 +26,7 @@ public class GiveGoldPassWordFragment extends DialogFragment {
|
||||
|
||||
private GiveGoldPasswordView mPassword;
|
||||
|
||||
private GridPasswordView.OnPasswordChangedListener listener;
|
||||
private GridPasswordNoFocusView.OnPasswordChangedListener listener;
|
||||
|
||||
private static GiveGoldPassWordFragment passWordFragment;
|
||||
|
||||
@@ -116,7 +116,7 @@ public class GiveGoldPassWordFragment extends DialogFragment {
|
||||
}
|
||||
}
|
||||
|
||||
public void setListener(GridPasswordView.OnPasswordChangedListener listener) {
|
||||
public void setListener(GridPasswordNoFocusView.OnPasswordChangedListener listener) {
|
||||
this.listener = listener;
|
||||
}
|
||||
|
||||
|
@@ -7,8 +7,8 @@ import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jungly.gridpasswordview.GridPasswordView;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.pay.widget.GridPasswordNoFocusView;
|
||||
import com.yizhuan.erban.ui.widget.password.PasswordKeyboardView;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -23,7 +23,7 @@ public class GiveGoldPasswordView extends RelativeLayout {
|
||||
private ImageView mClose;
|
||||
private TextView mTitle;
|
||||
private TextView mForgetPwd;
|
||||
private GridPasswordView mPassword;
|
||||
private GridPasswordNoFocusView mPassword;
|
||||
private TextView tvNickname;
|
||||
private TextView tvRate;
|
||||
private TextView tvGold;
|
||||
@@ -57,10 +57,6 @@ public class GiveGoldPasswordView extends RelativeLayout {
|
||||
tvRate = findViewById(R.id.tv_rate);
|
||||
//打乱数字的位置
|
||||
//mKeyboard.shuffleKeyboard();
|
||||
|
||||
mPassword.setOnClickListener(view -> {
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
private void initEvent() {
|
||||
@@ -126,7 +122,7 @@ public class GiveGoldPasswordView extends RelativeLayout {
|
||||
}
|
||||
|
||||
//输入密码控件
|
||||
public GridPasswordView getPswView() {
|
||||
public GridPasswordNoFocusView getPswView() {
|
||||
return mPassword;
|
||||
}
|
||||
|
||||
|
@@ -0,0 +1,436 @@
|
||||
package com.yizhuan.erban.pay.widget;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.ColorStateList;
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.drawable.ColorDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.GradientDrawable;
|
||||
import android.os.Bundle;
|
||||
import android.os.Parcelable;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
import android.text.method.PasswordTransformationMethod;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.jungly.gridpasswordview.CustomPasswordTransformationMethod;
|
||||
import com.jungly.gridpasswordview.PasswordType;
|
||||
import com.jungly.gridpasswordview.Util;
|
||||
import com.jungly.gridpasswordview.imebugfixer.ImeDelBugFixedEditText;
|
||||
import com.yizhuan.erban.R;
|
||||
import com.yizhuan.erban.pay.interfaces.PasswordView;
|
||||
|
||||
public class GridPasswordNoFocusView extends LinearLayout implements PasswordView {
|
||||
private static final int DEFAULT_PASSWORDLENGTH = 6;
|
||||
private static final int DEFAULT_TEXTSIZE = 16;
|
||||
private static final String DEFAULT_TRANSFORMATION = "●";
|
||||
private static final int DEFAULT_LINECOLOR = 0xaa888888;
|
||||
private static final int DEFAULT_GRIDCOLOR = 0xffffffff;
|
||||
|
||||
private ColorStateList mTextColor;
|
||||
private int mTextSize = DEFAULT_TEXTSIZE;
|
||||
private int mLineWidth;
|
||||
private int mLineColor;
|
||||
private int mGridColor;
|
||||
private Drawable mLineDrawable;
|
||||
private Drawable mOuterLineDrawable;
|
||||
private int mPasswordLength;
|
||||
private String mPasswordTransformation;
|
||||
private int mPasswordType;
|
||||
|
||||
private String[] mPasswordArr;
|
||||
private TextView[] mViewArr;
|
||||
|
||||
private ImeDelBugFixedEditText mInputView;
|
||||
private OnPasswordChangedListener mListener;
|
||||
private PasswordTransformationMethod mTransformationMethod;
|
||||
|
||||
public GridPasswordNoFocusView(Context context) {
|
||||
super(context);
|
||||
initViews(context);
|
||||
init(context, null, 0);
|
||||
}
|
||||
|
||||
public GridPasswordNoFocusView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init(context, attrs, 0);
|
||||
}
|
||||
|
||||
public GridPasswordNoFocusView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public GridPasswordNoFocusView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
init(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
initAttrs(context, attrs, defStyleAttr);
|
||||
initViews(context);
|
||||
}
|
||||
|
||||
private void initAttrs(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.gridPasswordView, defStyleAttr, 0);
|
||||
|
||||
mTextColor = ta.getColorStateList(R.styleable.gridPasswordView_gpvTextColor);
|
||||
if (mTextColor == null)
|
||||
mTextColor = ColorStateList.valueOf(getResources().getColor(android.R.color.primary_text_light));
|
||||
int textSize = ta.getDimensionPixelSize(R.styleable.gridPasswordView_gpvTextSize, -1);
|
||||
if (textSize != -1) {
|
||||
this.mTextSize = Util.px2sp(context, textSize);
|
||||
}
|
||||
|
||||
mLineWidth = (int) ta.getDimension(R.styleable.gridPasswordView_gpvLineWidth, Util.dp2px(getContext(), 1));
|
||||
mLineColor = ta.getColor(R.styleable.gridPasswordView_gpvLineColor, DEFAULT_LINECOLOR);
|
||||
mGridColor = ta.getColor(R.styleable.gridPasswordView_gpvGridColor, DEFAULT_GRIDCOLOR);
|
||||
mLineDrawable = ta.getDrawable(R.styleable.gridPasswordView_gpvLineColor);
|
||||
if (mLineDrawable == null)
|
||||
mLineDrawable = new ColorDrawable(mLineColor);
|
||||
mOuterLineDrawable = generateBackgroundDrawable();
|
||||
|
||||
mPasswordLength = ta.getInt(R.styleable.gridPasswordView_gpvPasswordLength, DEFAULT_PASSWORDLENGTH);
|
||||
mPasswordTransformation = ta.getString(R.styleable.gridPasswordView_gpvPasswordTransformation);
|
||||
if (TextUtils.isEmpty(mPasswordTransformation))
|
||||
mPasswordTransformation = DEFAULT_TRANSFORMATION;
|
||||
|
||||
|
||||
mPasswordType = ta.getInt(R.styleable.gridPasswordView_gpvPasswordType, 0);
|
||||
|
||||
ta.recycle();
|
||||
|
||||
mPasswordArr = new String[mPasswordLength];
|
||||
mViewArr = new TextView[mPasswordLength];
|
||||
}
|
||||
|
||||
private void initViews(Context context) {
|
||||
super.setBackgroundDrawable(mOuterLineDrawable);
|
||||
setShowDividers(SHOW_DIVIDER_NONE);
|
||||
setOrientation(HORIZONTAL);
|
||||
|
||||
mTransformationMethod = new CustomPasswordTransformationMethod(mPasswordTransformation);
|
||||
inflaterViews(context);
|
||||
}
|
||||
|
||||
private void inflaterViews(Context context) {
|
||||
LayoutInflater inflater = LayoutInflater.from(context);
|
||||
inflater.inflate(R.layout.grid_password_view, this);
|
||||
|
||||
mInputView = (ImeDelBugFixedEditText) findViewById(R.id.inputView);
|
||||
mInputView.setMaxEms(mPasswordLength);
|
||||
mInputView.addTextChangedListener(textWatcher);
|
||||
mInputView.setDelKeyEventListener(onDelKeyEventListener);
|
||||
setCustomAttr(mInputView);
|
||||
|
||||
mViewArr[0] = mInputView;
|
||||
|
||||
int index = 1;
|
||||
while (index < mPasswordLength) {
|
||||
View dividerView = inflater.inflate(R.layout.divider, null);
|
||||
LinearLayout.LayoutParams dividerParams = new LinearLayout.LayoutParams(mLineWidth, LinearLayout.LayoutParams.MATCH_PARENT);
|
||||
dividerView.setBackgroundDrawable(mLineDrawable);
|
||||
addView(dividerView, dividerParams);
|
||||
|
||||
TextView textView = (TextView) inflater.inflate(R.layout.textview, null);
|
||||
setCustomAttr(textView);
|
||||
LinearLayout.LayoutParams textViewParams = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT, 1f);
|
||||
addView(textView, textViewParams);
|
||||
|
||||
mViewArr[index] = textView;
|
||||
index++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void setCustomAttr(TextView view) {
|
||||
if (mTextColor != null)
|
||||
view.setTextColor(mTextColor);
|
||||
view.setTextSize(mTextSize);
|
||||
|
||||
int inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
||||
switch (mPasswordType) {
|
||||
|
||||
case 1:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
|
||||
break;
|
||||
}
|
||||
view.setInputType(inputType);
|
||||
view.setTransformationMethod(mTransformationMethod);
|
||||
}
|
||||
|
||||
private GradientDrawable generateBackgroundDrawable() {
|
||||
GradientDrawable drawable = new GradientDrawable();
|
||||
drawable.setColor(mGridColor);
|
||||
drawable.setStroke(mLineWidth, mLineColor);
|
||||
return drawable;
|
||||
}
|
||||
|
||||
private ImeDelBugFixedEditText.OnDelKeyEventListener onDelKeyEventListener = new ImeDelBugFixedEditText.OnDelKeyEventListener() {
|
||||
|
||||
@Override
|
||||
public void onDeleteClick() {
|
||||
for (int i = mPasswordArr.length - 1; i >= 0; i--) {
|
||||
if (mPasswordArr[i] != null) {
|
||||
mPasswordArr[i] = null;
|
||||
mViewArr[i].setText(null);
|
||||
notifyTextChanged();
|
||||
break;
|
||||
} else {
|
||||
mViewArr[i].setText(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private TextWatcher textWatcher = new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
||||
if (s == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
String newStr = s.toString();
|
||||
if (newStr.length() == 1) {
|
||||
mPasswordArr[0] = newStr;
|
||||
notifyTextChanged();
|
||||
} else if (newStr.length() == 2) {
|
||||
String newNum = newStr.substring(1);
|
||||
for (int i = 0; i < mPasswordArr.length; i++) {
|
||||
if (mPasswordArr[i] == null) {
|
||||
mPasswordArr[i] = newNum;
|
||||
mViewArr[i].setText(newNum);
|
||||
notifyTextChanged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
mInputView.removeTextChangedListener(this);
|
||||
mInputView.setText(mPasswordArr[0]);
|
||||
if (mInputView.getText().length() >= 1) {
|
||||
mInputView.setSelection(1);
|
||||
}
|
||||
mInputView.addTextChangedListener(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@Deprecated
|
||||
private OnKeyListener onKeyListener = new OnKeyListener() {
|
||||
@Override
|
||||
public boolean onKey(View v, int keyCode, KeyEvent event) {
|
||||
if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
|
||||
onDelKeyEventListener.onDeleteClick();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
private void notifyTextChanged() {
|
||||
if (mListener == null)
|
||||
return;
|
||||
|
||||
String currentPsw = getPassWord();
|
||||
mListener.onTextChanged(currentPsw);
|
||||
|
||||
if (currentPsw.length() == mPasswordLength)
|
||||
mListener.onInputFinish(currentPsw);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Parcelable onSaveInstanceState() {
|
||||
Bundle bundle = new Bundle();
|
||||
bundle.putParcelable("instanceState", super.onSaveInstanceState());
|
||||
bundle.putStringArray("passwordArr", mPasswordArr);
|
||||
return bundle;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onRestoreInstanceState(Parcelable state) {
|
||||
if (state instanceof Bundle) {
|
||||
Bundle bundle = (Bundle) state;
|
||||
mPasswordArr = bundle.getStringArray("passwordArr");
|
||||
state = bundle.getParcelable("instanceState");
|
||||
mInputView.removeTextChangedListener(textWatcher);
|
||||
setPassword(getPassWord());
|
||||
mInputView.addTextChangedListener(textWatcher);
|
||||
}
|
||||
super.onRestoreInstanceState(state);
|
||||
}
|
||||
|
||||
//TODO
|
||||
//@Override
|
||||
private void setError(String error) {
|
||||
mInputView.setError(error);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the text the PasswordView is displaying.
|
||||
*/
|
||||
@Override
|
||||
public String getPassWord() {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (int i = 0; i < mPasswordArr.length; i++) {
|
||||
if (mPasswordArr[i] != null)
|
||||
sb.append(mPasswordArr[i]);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear the passwrod the PasswordView is displaying.
|
||||
*/
|
||||
@Override
|
||||
public void clearPassword() {
|
||||
for (int i = 0; i < mPasswordArr.length; i++) {
|
||||
mPasswordArr[i] = null;
|
||||
mViewArr[i].setText(null);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the string value of the PasswordView.
|
||||
*/
|
||||
@Override
|
||||
public void setPassword(String password) {
|
||||
clearPassword();
|
||||
|
||||
if (TextUtils.isEmpty(password))
|
||||
return;
|
||||
|
||||
char[] pswArr = password.toCharArray();
|
||||
for (int i = 0; i < pswArr.length; i++) {
|
||||
if (i < mPasswordArr.length) {
|
||||
mPasswordArr[i] = pswArr[i] + "";
|
||||
mViewArr[i].setText(mPasswordArr[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the enabled state of this view.
|
||||
*/
|
||||
@Override
|
||||
public void setPasswordVisibility(boolean visible) {
|
||||
for (TextView textView : mViewArr) {
|
||||
textView.setTransformationMethod(visible ? null : mTransformationMethod);
|
||||
if (textView instanceof EditText) {
|
||||
EditText et = (EditText) textView;
|
||||
et.setSelection(et.getText().length());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Toggle the enabled state of this view.
|
||||
*/
|
||||
@Override
|
||||
public void togglePasswordVisibility() {
|
||||
boolean currentVisible = getPassWordVisibility();
|
||||
setPasswordVisibility(!currentVisible);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the visibility of this view.
|
||||
*/
|
||||
private boolean getPassWordVisibility() {
|
||||
return mViewArr[0].getTransformationMethod() == null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Register a callback to be invoked when password changed.
|
||||
*/
|
||||
@Override
|
||||
public void setOnPasswordChangedListener(OnPasswordChangedListener listener) {
|
||||
this.mListener = listener;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPasswordType(PasswordType passwordType) {
|
||||
boolean visible = getPassWordVisibility();
|
||||
int inputType = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
|
||||
switch (passwordType) {
|
||||
|
||||
case TEXT:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
|
||||
break;
|
||||
|
||||
case TEXTVISIBLE:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
|
||||
break;
|
||||
|
||||
case TEXTWEB:
|
||||
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_WEB_PASSWORD;
|
||||
break;
|
||||
}
|
||||
|
||||
for (TextView textView : mViewArr)
|
||||
textView.setInputType(inputType);
|
||||
|
||||
setPasswordVisibility(visible);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackground(Drawable background) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundColor(int color) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundResource(int resid) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBackgroundDrawable(Drawable background) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Interface definition for a callback to be invoked when the password changed or is at the maximum length.
|
||||
*/
|
||||
public interface OnPasswordChangedListener {
|
||||
|
||||
/**
|
||||
* Invoked when the password changed.
|
||||
*
|
||||
* @param psw new text
|
||||
*/
|
||||
void onTextChanged(String psw);
|
||||
|
||||
/**
|
||||
* Invoked when the password is at the maximum length.
|
||||
*
|
||||
* @param psw complete text
|
||||
*/
|
||||
void onInputFinish(String psw);
|
||||
|
||||
}
|
||||
}
|
11
app/src/main/res/layout/grid_password_view.xml
Normal file
11
app/src/main/res/layout/grid_password_view.xml
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<merge xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<com.jungly.gridpasswordview.imebugfixer.ImeDelBugFixedEditText
|
||||
android:id="@+id/inputView"
|
||||
style="@style/GridPasswordView.EditText"
|
||||
android:focusable="false"
|
||||
android:inputType="numberPassword"
|
||||
android:focusableInTouchMode="false" />
|
||||
|
||||
</merge>
|
@@ -1,11 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:background="@color/color_white"
|
||||
>
|
||||
android:background="@color/color_white">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/ll_main_password"
|
||||
@@ -17,9 +16,9 @@
|
||||
android:id="@+id/img_close"
|
||||
android:layout_width="22dp"
|
||||
android:layout_height="22dp"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
android:layout_gravity="end"
|
||||
android:layout_marginTop="@dimen/dp_14"
|
||||
android:layout_marginEnd="@dimen/dp_15"
|
||||
android:background="@drawable/ic_pwd_close" />
|
||||
|
||||
<TextView
|
||||
@@ -33,28 +32,28 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_nickname"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:layout_marginTop="10dp"
|
||||
android:textColor="#333333"
|
||||
android:textSize="13sp" />
|
||||
android:textSize="13sp"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_gold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_horizontal"
|
||||
android:gravity="center"
|
||||
android:visibility="gone"
|
||||
android:drawableLeft="@drawable/ic_redpackage_bigdiamond"
|
||||
android:layout_marginTop="3dp"
|
||||
android:drawableLeft="@drawable/ic_redpackage_bigdiamond"
|
||||
android:drawablePadding="@dimen/dp_8"
|
||||
android:gravity="center"
|
||||
android:includeFontPadding="false"
|
||||
android:textColor="#333333"
|
||||
tools:text="20000"
|
||||
android:drawablePadding="@dimen/dp_8"
|
||||
android:textSize="28sp" />
|
||||
android:textSize="28sp"
|
||||
android:visibility="gone"
|
||||
tools:text="20000" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_rate"
|
||||
@@ -65,7 +64,7 @@
|
||||
android:textColor="#333333"
|
||||
android:textSize="10sp" />
|
||||
|
||||
<com.jungly.gridpasswordview.GridPasswordView
|
||||
<com.yizhuan.erban.pay.widget.GridPasswordNoFocusView
|
||||
android:id="@+id/view_password"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="46dp"
|
||||
@@ -82,13 +81,13 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/tv_forgetPwd"
|
||||
android:visibility="gone"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="right"
|
||||
android:layout_margin="13dp"
|
||||
android:text="@string/layout_view_give_gold_password_02"
|
||||
android:textColor="#EA3B36" />
|
||||
android:textColor="#EA3B36"
|
||||
android:visibility="gone" />
|
||||
</LinearLayout>
|
||||
|
||||
<View
|
||||
|
Reference in New Issue
Block a user