Browse Source

1.支付密码设置。
2.自定义支付秘密view替换

石慧云 4 năm trước cách đây
mục cha
commit
4c5d070ecb

+ 57 - 1
app/src/main/java/com/quansu/heifengwuliu/activity/PasswordActivity.kt

@@ -1,14 +1,22 @@
 package com.quansu.heifengwuliu.activity
 
 import android.os.Bundle
+import android.os.Handler
+import com.quansu.heifengwuliu.R
 import com.quansu.heifengwuliu.base.MBActivity
 import com.quansu.heifengwuliu.databinding.ActivityPasswordBinding
+import com.quansu.heifengwuliu.view.PasswordView
+import com.quansu.heifengwuliu.view.PasswordView.PasswordListener
 import com.quansu.heifengwuliu.vmodel.PasswordVModel
+import java.util.*
 
 class PasswordActivity : MBActivity<PasswordVModel, ActivityPasswordBinding>() {
 
 
     var type=1//1:登录密码 2支付密码
+    var oldPassword=""
+    var newPassword=""
+
     override fun __before() {
         super.__before()
 
@@ -18,10 +26,58 @@ class PasswordActivity : MBActivity<PasswordVModel, ActivityPasswordBinding>() {
 
     override fun initCreate(savedInstanceState: Bundle?) {
         super.initCreate(savedInstanceState)
-        vm.type=type
+        vm.type.value= type
+        if(type==2){
+            //初始化密码输入框
+            initPassword()
+        }
     }
 
 
+
+   private fun initPassword(){
+
+
+       binding.ppetOldPassword.setPasswordListener(object :PasswordListener{
+           override fun keyEnterPress(password: String?, isComplete: Boolean) {
+
+               oldPassword= password!!
+           }
+
+           override fun passwordChange(changeText: String?) {
+           }
+
+           override fun passwordComplete() {
+
+           }
+
+       })
+
+       binding.ppetNewPassword.setPasswordListener(object :PasswordListener{
+           override fun keyEnterPress(password: String?, isComplete: Boolean) {
+
+               newPassword= password!!
+           }
+
+           override fun passwordChange(changeText: String?) {
+           }
+
+           override fun passwordComplete() {
+
+           }
+
+       })
+
+       binding.btnPaySubmit.setOnClickListener {
+           vm.toPaySubmit(oldPassword,newPassword)
+       }
+
+
+   }
+
+
+
+
     override fun title(): String? {
         return if(type==1) {
             "设置登录密码"

+ 1 - 1
app/src/main/java/com/quansu/heifengwuliu/model/DataInfoBean.kt

@@ -42,7 +42,7 @@ data class DataInfoBean(var goods_type: List<SelectData>, var nums_type: List<St
     data class OrderBean(var info_id: String, var info_state: Int,
                          var info_sn: String, var is_pay: String,
                          var uid: String, var price: String,
-                         var total: String, var driver: String,
+                         var total: String,
                          var nums: String, var is_public: String,
                          var is_insurance: String, var type: String,
                          var data: String, var pay_time: String,

+ 1 - 1
app/src/main/java/com/quansu/heifengwuliu/model/InfoListBean.kt

@@ -11,7 +11,7 @@ import com.ysnows.base.inter.IModel
 data class InfoListBean(var info_id: String, var info_state: Int,
                         var info_sn: String, var is_pay: String,
                         var uid: String, var price: String,
-                        var total: String, var driver: String,
+                        var total: String,
                         var nums: String, var is_public: String,
                         var is_insurance: String, var type: String,
                         var data: String, var pay_time: String,

+ 534 - 0
app/src/main/java/com/quansu/heifengwuliu/view/PasswordView.java

@@ -0,0 +1,534 @@
+package com.quansu.heifengwuliu.view;
+
+import android.content.Context;
+import android.content.res.TypedArray;
+import android.graphics.Canvas;
+import android.graphics.Color;
+import android.graphics.Paint;
+import android.graphics.Rect;
+import android.os.Bundle;
+import android.os.Parcelable;
+import android.text.InputType;
+import android.text.TextUtils;
+import android.util.AttributeSet;
+import android.view.KeyEvent;
+import android.view.MotionEvent;
+import android.view.View;
+import android.view.inputmethod.EditorInfo;
+import android.view.inputmethod.InputConnection;
+import android.view.inputmethod.InputMethodManager;
+
+import com.quansu.heifengwuliu.R;
+
+import java.util.Timer;
+import java.util.TimerTask;
+
+/**
+ *
+ passwordLength (密码长度)
+ smode (样式切换 underline->下划线 rect->边框)
+ passwordPadding (每个密码框间隔)
+ borderColor (边框颜色)
+ borderWidth(边框大小)
+ cursorFlashTime(光标闪烁间隔时间)
+ isCursorEnable(是否启用光标)
+ cipherTextSize(‘*’号大小)
+ cursorColor(光标颜色)
+ cipherEnable(是否启用‘*’显示)
+
+ *
+ *参考:https://github.com/EoniJJ/PasswordView
+ * Created by Arron on 2016/11/21 0021.
+ * 密码输入框
+ */
+
+public class PasswordView extends View {
+
+    private Mode mode; //样式模式
+    private int passwordLength;//密码个数
+    private long cursorFlashTime;//光标闪动间隔时间
+    private int passwordPadding;//每个密码间的间隔
+    private int passwordSize = dp2px(40);//单个密码大小
+    private int borderColor;//边框颜色
+    private int borderWidth;//下划线粗细
+    private int cursorPosition;//光标位置
+    private int cursorWidth;//光标粗细
+    private int cursorHeight;//光标长度
+    private int cursorColor;//光标颜色
+    private boolean isCursorShowing;//光标是否正在显示
+    private boolean isCursorEnable;//是否开启光标
+    private boolean isInputComplete;//是否输入完毕
+    private int cipherTextSize;//密文符号大小
+    private boolean cipherEnable;//是否开启密文
+    private static String CIPHER_TEXT = "*"; //密文符号
+    private String[] password;//密码数组
+    private InputMethodManager inputManager;
+    private PasswordListener passwordListener;
+    private Paint paint;
+    private Timer timer;
+    private TimerTask timerTask;
+    public PasswordView(Context context) {
+        super(context);
+    }
+
+    public Mode getMode() {
+        return mode;
+    }
+
+    public void setMode(Mode mode) {
+        this.mode = mode;
+        postInvalidate();
+    }
+
+    public enum Mode {
+        /**
+         * 下划线样式
+         */
+        UNDERLINE(0),
+
+        /**
+         * 边框样式
+         */
+        RECT(1);
+        private int mode;
+
+        Mode(int mode) {
+            this.mode = mode;
+        }
+
+        public int getMode() {
+            return this.mode;
+        }
+
+        static Mode formMode(int mode) {
+            for (Mode m : values()) {
+                if (mode == m.mode) {
+                    return m;
+                }
+            }
+            throw new IllegalArgumentException();
+        }
+    }
+
+    /**
+     * 当前只支持从xml中构建该控件
+     *
+     * @param context
+     * @param attrs
+     */
+    public PasswordView(Context context, AttributeSet attrs) {
+        super(context, attrs);
+        readAttribute(attrs);
+    }
+
+    private void readAttribute(AttributeSet attrs) {
+        if (attrs != null) {
+            TypedArray typedArray = getContext().obtainStyledAttributes(attrs, R.styleable.PasswordView);
+            mode = Mode.formMode(typedArray.getInteger(R.styleable.PasswordView_smode, Mode.UNDERLINE.getMode()));
+            passwordLength = typedArray.getInteger(R.styleable.PasswordView_passwordLength, 4);
+            cursorFlashTime = typedArray.getInteger(R.styleable.PasswordView_cursorFlashTime, 500);
+            borderWidth = typedArray.getDimensionPixelSize(R.styleable.PasswordView_borderWidth, dp2px(3));
+            borderColor = typedArray.getColor(R.styleable.PasswordView_borderColor, Color.BLACK);
+            cursorColor = typedArray.getColor(R.styleable.PasswordView_cursorColor, Color.GRAY);
+            isCursorEnable = typedArray.getBoolean(R.styleable.PasswordView_isCursorEnable, true);
+            //如果为边框样式,则padding 默认置为0
+            if (mode == Mode.UNDERLINE) {
+                passwordPadding = typedArray.getDimensionPixelSize(R.styleable.PasswordView_passwordPadding, dp2px(15));
+            } else {
+                passwordPadding = typedArray.getDimensionPixelSize(R.styleable.PasswordView_passwordPadding, 0);
+            }
+            cipherEnable = typedArray.getBoolean(R.styleable.PasswordView_cipherEnable, true);
+            typedArray.recycle();
+        }
+        password = new String[passwordLength];
+        init();
+    }
+
+    private void init() {
+        setFocusableInTouchMode(true);
+        MyKeyListener MyKeyListener = new MyKeyListener();
+        setOnKeyListener(MyKeyListener);
+        inputManager = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
+        paint = new Paint();
+        paint.setAntiAlias(true);
+        timerTask = new TimerTask() {
+            @Override
+            public void run() {
+                isCursorShowing = !isCursorShowing;
+                postInvalidate();
+            }
+        };
+        timer = new Timer();
+    }
+
+    @Override
+    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+        int widthMode = MeasureSpec.getMode(widthMeasureSpec);
+        int width = 0;
+        switch (widthMode) {
+            case MeasureSpec.UNSPECIFIED:
+            case MeasureSpec.AT_MOST:
+                //没有指定大小,宽度 = 单个密码框大小 * 密码位数 + 密码框间距 *(密码位数 - 1)
+                width = passwordSize * passwordLength + passwordPadding * (passwordLength - 1);
+                break;
+            case MeasureSpec.EXACTLY:
+                //指定大小,宽度 = 指定的大小
+                width = MeasureSpec.getSize(widthMeasureSpec);
+                //密码框大小等于 (宽度 - 密码框间距 *(密码位数 - 1)) / 密码位数
+                passwordSize = (width - (passwordPadding * (passwordLength - 1))) / passwordLength;
+                break;
+        }
+        setMeasuredDimension(width, passwordSize);
+
+    }
+
+    @Override
+    protected void onSizeChanged(int w, int h, int oldw, int oldh) {
+        super.onSizeChanged(w, h, oldw, oldh);
+        //文本大小
+        cipherTextSize = passwordSize / 2;
+        //光标宽度
+        cursorWidth = dp2px(2);
+        //光标长度
+        cursorHeight = passwordSize / 2;
+    }
+
+    @Override
+    protected void onDraw(Canvas canvas) {
+        super.onDraw(canvas);
+        if (mode == Mode.UNDERLINE) {
+            //绘制下划线
+            drawUnderLine(canvas, paint);
+        } else {
+            //绘制方框
+            drawRect(canvas, paint);
+        }
+        //绘制光标
+        drawCursor(canvas, paint);
+        //绘制密码文本
+        drawCipherText(canvas, paint);
+    }
+
+    class MyKeyListener implements OnKeyListener {
+
+        @Override
+        public boolean onKey(View v, int keyCode, KeyEvent event) {
+            int action = event.getAction();
+            if (action == KeyEvent.ACTION_DOWN) {
+                if (keyCode == KeyEvent.KEYCODE_DEL) {
+                    /**
+                     * 删除操作
+                     */
+                    if (TextUtils.isEmpty(password[0])) {
+                        return true;
+                    }
+                    String deleteText = delete();
+                    if (passwordListener != null && !TextUtils.isEmpty(deleteText)) {
+                        passwordListener.passwordChange(deleteText);
+                    }
+                    postInvalidate();
+                    return true;
+                }
+                if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
+                    /**
+                     * 只支持数字
+                     */
+                    if (isInputComplete) {
+                        return true;
+                    }
+                    String addText = add((keyCode - 7) + "");
+                    if (passwordListener != null && !TextUtils.isEmpty(addText)) {
+                        passwordListener.passwordChange(addText);
+                    }
+                    postInvalidate();
+                    return true;
+                }
+                if (keyCode == KeyEvent.KEYCODE_ENTER) {
+                    /**
+                     * 确认键
+                     */
+                    if (passwordListener != null) {
+                        passwordListener.keyEnterPress(getPassword(), isInputComplete);
+                    }
+                    return true;
+                }
+            }
+            return false;
+        }
+    }
+
+    /**
+     * 删除
+     */
+    private String delete() {
+        String deleteText = null;
+        if (cursorPosition > 0) {
+            deleteText = password[cursorPosition - 1];
+            password[cursorPosition - 1] = null;
+            cursorPosition--;
+        } else if (cursorPosition == 0) {
+            deleteText = password[cursorPosition];
+            password[cursorPosition] = null;
+        }
+        isInputComplete = false;
+        return deleteText;
+    }
+
+    /**
+     * 增加
+     */
+    private String add(String c) {
+        String addText = null;
+        if (cursorPosition < passwordLength) {
+            addText = c;
+            password[cursorPosition] = c;
+            cursorPosition++;
+            if (cursorPosition == passwordLength) {
+                isInputComplete = true;
+                if (passwordListener != null) {
+                    passwordListener.passwordComplete();
+                }
+            }
+        }
+        return addText;
+    }
+
+    /**
+     * 获取密码
+     */
+    private String getPassword() {
+        StringBuffer stringBuffer = new StringBuffer();
+        for (String c : password) {
+            if (TextUtils.isEmpty(c)) {
+                continue;
+            }
+            stringBuffer.append(c);
+        }
+        return stringBuffer.toString();
+    }
+
+    /**
+     * 绘制密码替代符号
+     *
+     * @param canvas
+     * @param paint
+     */
+    private void drawCipherText(Canvas canvas, Paint paint) {
+        //画笔初始化
+        paint.setColor(Color.GRAY);
+        paint.setTextSize(cipherTextSize);
+        paint.setTextAlign(Paint.Align.CENTER);
+        paint.setStyle(Paint.Style.FILL);
+        //文字居中的处理
+        Rect r = new Rect();
+        canvas.getClipBounds(r);
+        int cHeight = r.height();
+        paint.getTextBounds(CIPHER_TEXT, 0, CIPHER_TEXT.length(), r);
+        float y = cHeight / 2f + r.height() / 2f - r.bottom;
+
+        //根据输入的密码位数,进行for循环绘制
+        for (int i = 0; i < password.length; i++) {
+            if (!TextUtils.isEmpty(password[i])) {
+                // x = paddingLeft + 单个密码框大小/2 + ( 密码框大小 + 密码框间距 ) * i
+                // y = paddingTop + 文字居中所需偏移量
+                if (cipherEnable) {
+                    //没有开启明文显示,绘制密码密文
+                    canvas.drawText(CIPHER_TEXT,
+                            (getPaddingLeft() + passwordSize / 2) + (passwordSize + passwordPadding) * i,
+                            getPaddingTop() + y, paint);
+                } else {
+                    //明文显示,直接绘制密码
+                    canvas.drawText(password[i],
+                            (getPaddingLeft() + passwordSize / 2) + (passwordSize + passwordPadding) * i,
+                            getPaddingTop() + y, paint);
+                }
+            }
+        }
+    }
+
+    /**
+     * 绘制光标
+     *
+     * @param canvas
+     * @param paint
+     */
+    private void drawCursor(Canvas canvas, Paint paint) {
+        //画笔初始化
+        paint.setColor(cursorColor);
+        paint.setStrokeWidth(cursorWidth);
+        paint.setStyle(Paint.Style.FILL);
+        //光标未显示 && 开启光标 && 输入位数未满 && 获得焦点
+        if (!isCursorShowing && isCursorEnable && !isInputComplete && hasFocus()) {
+            // 起始点x = paddingLeft + 单个密码框大小 / 2 + (单个密码框大小 + 密码框间距) * 光标下标
+            // 起始点y = paddingTop + (单个密码框大小 - 光标大小) / 2
+            // 终止点x = 起始点x
+            // 终止点y = 起始点y + 光标高度
+            canvas.drawLine((getPaddingLeft() + passwordSize / 2) + (passwordSize + passwordPadding) * cursorPosition,
+                    getPaddingTop() + (passwordSize - cursorHeight) / 2,
+                    (getPaddingLeft() + passwordSize / 2) + (passwordSize + passwordPadding) * cursorPosition,
+                    getPaddingTop() + (passwordSize + cursorHeight) / 2,
+                    paint);
+        }
+    }
+
+    /**
+     * 绘制密码框下划线
+     *
+     * @param canvas
+     * @param paint
+     */
+    private void drawUnderLine(Canvas canvas, Paint paint) {
+        //画笔初始化
+        paint.setColor(borderColor);
+        paint.setStrokeWidth(borderWidth);
+        paint.setStyle(Paint.Style.FILL);
+        for (int i = 0; i < passwordLength; i++) {
+            //根据密码位数for循环绘制直线
+            // 起始点x为paddingLeft + (单个密码框大小 + 密码框边距) * i , 起始点y为paddingTop + 单个密码框大小
+            // 终止点x为 起始点x + 单个密码框大小 , 终止点y与起始点一样不变
+            canvas.drawLine(getPaddingLeft() + (passwordSize + passwordPadding) * i, getPaddingTop() + passwordSize,
+                    getPaddingLeft() + (passwordSize + passwordPadding) * i + passwordSize, getPaddingTop() + passwordSize,
+                    paint);
+        }
+    }
+
+    private void drawRect(Canvas canvas, Paint paint) {
+        paint.setColor(borderColor);
+        paint.setStrokeWidth(0);
+        paint.setStyle(Paint.Style.STROKE);
+        Rect rect;
+        for (int i = 0; i < passwordLength; i++) {
+            int startX = getPaddingLeft() + (passwordSize + passwordPadding) * i;
+            int startY = getPaddingTop();
+            int stopX = getPaddingLeft() + (passwordSize + passwordPadding) * i + passwordSize;
+            int stopY = getPaddingTop() + passwordSize;
+            rect = new Rect(startX, startY, stopX, stopY);
+            canvas.drawRect(rect, paint);
+        }
+    }
+
+    @Override
+    public boolean onTouchEvent(MotionEvent event) {
+        if (event.getAction() == MotionEvent.ACTION_DOWN) {
+            /**
+             * 弹出软键盘
+             */
+            requestFocus();
+            inputManager.showSoftInput(this, InputMethodManager.SHOW_FORCED);
+            return true;
+        }
+        return super.onTouchEvent(event);
+    }
+
+    @Override
+    public void onWindowFocusChanged(boolean hasWindowFocus) {
+        super.onWindowFocusChanged(hasWindowFocus);
+        if (!hasWindowFocus) {
+            inputManager.hideSoftInputFromWindow(this.getWindowToken(), 0);
+        }
+    }
+
+    @Override
+    protected void onAttachedToWindow() {
+        super.onAttachedToWindow();
+        //cursorFlashTime为光标闪动的间隔时间
+        timer.scheduleAtFixedRate(timerTask, 0, cursorFlashTime);
+    }
+
+    @Override
+    protected void onDetachedFromWindow() {
+        super.onDetachedFromWindow();
+        timer.cancel();
+    }
+
+    private int dp2px(float dp) {
+        float scale = getContext().getResources().getDisplayMetrics().density;
+        return (int) (dp * scale + 0.5f);
+    }
+
+    private int sp2px(float spValue) {
+        float fontScale = getContext().getResources().getDisplayMetrics().scaledDensity;
+        return (int) (spValue * fontScale + 0.5f);
+    }
+
+    @Override
+    public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
+        outAttrs.inputType = InputType.TYPE_CLASS_NUMBER; //输入类型为数字
+        return super.onCreateInputConnection(outAttrs);
+    }
+
+    public void setPasswordListener(PasswordListener passwordListener) {
+        this.passwordListener = passwordListener;
+    }
+
+    public void setPasswordSize(int passwordSize) {
+        this.passwordSize = passwordSize;
+        postInvalidate();
+    }
+
+    public void setPasswordLength(int passwordLength) {
+        this.passwordLength = passwordLength;
+        postInvalidate();
+    }
+
+    public void setCursorColor(int cursorColor) {
+        this.cursorColor = cursorColor;
+        postInvalidate();
+    }
+
+    public void setCursorEnable(boolean cursorEnable) {
+        isCursorEnable = cursorEnable;
+        postInvalidate();
+    }
+
+    public void setCipherEnable(boolean cipherEnable) {
+        this.cipherEnable = cipherEnable;
+        postInvalidate();
+    }
+
+    /**
+     * 密码监听者
+     */
+    public interface PasswordListener {
+        /**
+         * 输入/删除监听
+         *
+         * @param changeText  输入/删除的字符
+         */
+        void passwordChange(String changeText);
+
+        /**
+         * 输入完成
+         */
+        void passwordComplete();
+
+        /**
+         * 确认键后的回调
+         *
+         * @param password   密码
+         * @param isComplete 是否达到要求位数
+         */
+        void keyEnterPress(String password, boolean isComplete);
+
+    }
+
+    @Override
+    protected Parcelable onSaveInstanceState() {
+        Bundle bundle = new Bundle();
+        bundle.putParcelable("superState", super.onSaveInstanceState());
+        bundle.putStringArray("password", password);
+        bundle.putInt("cursorPosition", cursorPosition);
+        return bundle;
+    }
+
+    @Override
+    protected void onRestoreInstanceState(Parcelable state) {
+        if (state instanceof Bundle) {
+            Bundle bundle = (Bundle) state;
+            password = bundle.getStringArray("password");
+            cursorPosition = bundle.getInt("cursorPosition");
+            state = bundle.getParcelable("superState");
+        }
+        super.onRestoreInstanceState(state);
+    }
+}

+ 0 - 265
app/src/main/java/com/quansu/heifengwuliu/view/PayPwdEditText.java

@@ -1,265 +0,0 @@
-package com.quansu.heifengwuliu.view;
-
-import android.content.Context;
-import android.text.Editable;
-import android.text.InputFilter;
-import android.text.InputType;
-import android.text.Selection;
-import android.text.TextWatcher;
-import android.text.method.HideReturnsTransformationMethod;
-import android.text.method.PasswordTransformationMethod;
-import android.util.AttributeSet;
-import android.view.Gravity;
-import android.view.View;
-import android.view.ViewGroup;
-import android.view.inputmethod.InputMethodManager;
-import android.widget.EditText;
-import android.widget.LinearLayout;
-import android.widget.RelativeLayout;
-import android.widget.TextView;
-
-/**
- * Created by ywl on 2016/7/10.
- */
-public class PayPwdEditText extends RelativeLayout{
-
-    private EditText editText; //文本编辑框
-    private Context context;
-
-    private LinearLayout linearLayout; //文本密码的文本
-    private TextView[] textViews; //文本数组
-
-    private int pwdlength = 6; //密码长度, 默认6
-
-    private OnTextFinishListener onTextFinishListener;
-
-
-    public PayPwdEditText(Context context) {
-        this(context, null);
-    }
-
-    public PayPwdEditText(Context context, AttributeSet attrs) {
-        this(context, attrs, 0);
-    }
-
-    public PayPwdEditText(Context context, AttributeSet attrs, int defStyleAttr) {
-        super(context, attrs, defStyleAttr);
-        this.context = context;
-    }
-
-    /**
-     * @param bgdrawable 背景drawable
-     * @param pwdlength 密码长度
-     * @param splilinewidth 分割线宽度
-     * @param splilinecolor 分割线颜色
-     * @param pwdcolor 密码字体颜色
-     * @param pwdsize 密码字体大小
-     */
-    public void initStyle(int bgdrawable, int pwdlength, float splilinewidth, int splilinecolor, int pwdcolor, int pwdsize)
-    {
-        this.pwdlength = pwdlength;
-        initEdit(bgdrawable);
-        initShowInput(bgdrawable, pwdlength, splilinewidth, splilinecolor, pwdcolor, pwdsize);
-    }
-
-    /**
-     * 初始化编辑框
-     * @param bgcolor
-     */
-    private void initEdit(int bgcolor)
-    {
-        editText = new EditText(context);
-        editText.setBackgroundResource(bgcolor);
-        editText.setCursorVisible(false);
-        editText.setTextSize(0);
-        editText.setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_CLASS_NUMBER);
-        editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(pwdlength)});
-        editText.addTextChangedListener(new TextWatcher() {
-            @Override
-            public void beforeTextChanged(CharSequence s, int start, int count, int after) {
-                Editable etext = editText.getText();
-                Selection.setSelection(etext, etext.length());
-            }
-
-            @Override
-            public void onTextChanged(CharSequence s, int start, int before, int count) {
-
-            }
-
-            @Override
-            public void afterTextChanged(Editable s) {
-                initDatas(s);
-                if(s.length() == pwdlength)
-                {
-                    if(onTextFinishListener != null)
-                    {
-                        onTextFinishListener.onFinish(s.toString().trim());
-                    }
-                }
-            }
-        });
-        LayoutParams lp = new LayoutParams(LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
-        lp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE);
-        addView(editText, lp);
-
-    }
-
-    /**
-     * @param bgcolor 背景drawable
-     * @param pwdlength 密码长度
-     * @param slpilinewidth 分割线宽度
-     * @param splilinecolor 分割线颜色
-     * @param pwdcolor 密码字体颜色
-     * @param pwdsize 密码字体大小
-     */
-    public void initShowInput(int bgcolor, int pwdlength, float slpilinewidth, int splilinecolor, int pwdcolor, int pwdsize)
-    {
-        //添加密码框父布局
-        linearLayout = new LinearLayout(context);
-        linearLayout.setBackgroundResource(bgcolor);
-        LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.MATCH_PARENT);
-        linearLayout.setLayoutParams(layoutParams);
-        linearLayout.setOrientation(LinearLayout.HORIZONTAL);
-        addView(linearLayout);
-
-        //添加密码框
-        textViews = new TextView[pwdlength];
-        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0,LayoutParams.MATCH_PARENT);
-        params.weight = 1;
-        params.gravity = Gravity.CENTER;
-
-        LinearLayout.LayoutParams params2 = new LinearLayout.LayoutParams(dip2px(context, slpilinewidth),LayoutParams.MATCH_PARENT);
-        for(int i = 0; i < textViews.length; i++)
-        {
-            final int index = i;
-            TextView textView = new TextView(context);
-            textView.setGravity(Gravity.CENTER);
-            textViews[i] = textView;
-            textViews[i].setTextSize(pwdsize);
-            textViews[i].setTextColor(context.getResources().getColor(pwdcolor));
-            textViews[i].setInputType(InputType.TYPE_NUMBER_VARIATION_PASSWORD | InputType.TYPE_CLASS_NUMBER);
-            linearLayout.addView(textView, params);
-
-
-            if(i < textViews.length - 1)
-            {
-                View view = new View(context);
-                view.setBackgroundColor(context.getResources().getColor(splilinecolor));
-                linearLayout.addView(view, params2);
-            }
-        }
-    }
-
-    /**
-     * 是否显示明文
-     * @param showPwd
-     */
-    public void setShowPwd(boolean showPwd) {
-        int length = textViews.length;
-        for(int i = 0; i < length; i++) {
-            if (showPwd) {
-                textViews[i].setTransformationMethod(PasswordTransformationMethod.getInstance());
-            } else {
-                textViews[i].setTransformationMethod(HideReturnsTransformationMethod.getInstance());
-            }
-        }
-    }
-
-    /**
-     * 设置显示类型
-     * @param type
-     */
-    public void setInputType(int type)
-    {
-        int length = textViews.length;
-        for(int i = 0; i < length; i++) {
-            textViews[i].setInputType(type);
-        }
-    }
-
-    /**
-     * 清除文本框
-     */
-    public void clearText()
-    {
-        editText.setText("");
-        for(int i = 0; i < pwdlength; i++)
-        {
-            textViews[i].setText("");
-        }
-    }
-
-    public void setOnTextFinishListener(OnTextFinishListener onTextFinishListener) {
-        this.onTextFinishListener = onTextFinishListener;
-    }
-
-    /**
-     * 根据输入字符,显示密码个数
-     * @param s
-     */
-    public void initDatas(Editable s)
-    {
-        if(s.length() > 0)
-        {
-            int length = s.length();
-            for(int i = 0; i < pwdlength; i++)
-            {
-                if(i < length)
-                {
-                    for(int j = 0; j < length; j++)
-                    {
-                        char ch = s.charAt(j);
-                        textViews[j].setText(String.valueOf(ch));
-                    }
-                }
-                else
-                {
-                    textViews[i].setText("");
-                }
-            }
-        }
-        else
-        {
-            for(int i = 0; i < pwdlength; i++)
-            {
-                textViews[i].setText("");
-            }
-        }
-    }
-
-    public String getPwdText()
-    {
-        if(editText != null)
-            return editText.getText().toString().trim();
-        return "";
-    }
-
-    public static int dip2px(Context context, float dipValue) {
-        final float scale = context.getResources().getDisplayMetrics().density;
-        return (int) (dipValue * scale + 0.5f);
-    }
-
-    public interface OnTextFinishListener
-    {
-        void onFinish(String str);
-    }
-
-    public void setFocus()
-    {
-        editText.requestFocus();
-        editText.setFocusable(true);
-        showKeyBord(editText);
-    }
-
-    /**
-     * 显示键盘
-     * @param view
-     */
-    public void showKeyBord(View view)
-    {
-        InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
-        imm.showSoftInput(view,InputMethodManager.SHOW_FORCED);
-
-    }
-
-}

+ 26 - 2
app/src/main/java/com/quansu/heifengwuliu/vmodel/PasswordVModel.kt

@@ -15,7 +15,8 @@ open class PasswordVModel : BViewModel<BRepository>() {
 
     var isShow: MutableLiveData<Boolean> = MutableLiveData( User.get()!!.isPwd)
 
-    var type=1
+    var type: MutableLiveData<Int> = MutableLiveData(1)
+
 
 
     @Bindable
@@ -42,7 +43,7 @@ open class PasswordVModel : BViewModel<BRepository>() {
 
 
     fun toSubmit(){
-        if(type==1){//设置登录密码
+        if(type.value==1){//设置登录密码
 
             var oldpwd=""
             if(isShow.value!!) {
@@ -82,5 +83,28 @@ open class PasswordVModel : BViewModel<BRepository>() {
     }
 
 
+    fun toPaySubmit(oldPassword:String,newPassword:String){
+        if(TextUtils.isEmpty(oldPassword)){
+            toast("请输入旧支付密码")
+            return
+        }
+
+        if(TextUtils.isEmpty(newPassword)){
+            toast("请输入新支付密码")
+            return
+        }
+
+        repository().lreq(NetEngine.service.setPwd(oldPassword, newPassword,"1"))
+                .doOnNext {
+                    if (it.ok(true)) {
+                        toast(it.msg())
+                        (repository().context as Activity).finish()
+                    }
+                }
+                .subscribe()
+
+    }
+
+
 
 }

+ 16 - 16
app/src/main/java/com/quansu/heifengwuliu/vmodel/SourceDetailsVModel.kt

@@ -2,15 +2,11 @@ package com.quansu.heifengwuliu.vmodel
 
 import android.app.Activity
 import android.content.Context
-import android.os.Handler
 import android.text.TextUtils
-import android.util.Log
 import android.view.LayoutInflater
 import android.widget.FrameLayout
 import android.widget.LinearLayout
-import android.widget.Toast
 import androidx.lifecycle.MutableLiveData
-import com.google.gson.Gson
 import com.qmuiteam.qmui.layout.QMUIFrameLayout
 import com.qmuiteam.qmui.skin.QMUISkinHelper
 import com.qmuiteam.qmui.skin.QMUISkinValueBuilder
@@ -22,7 +18,7 @@ import com.qmuiteam.qmui.widget.roundwidget.QMUIRoundButton
 import com.quansu.heifengwuliu.R
 import com.quansu.heifengwuliu.model.DataInfoBean
 import com.quansu.heifengwuliu.utils.net.NetEngine
-import com.quansu.heifengwuliu.view.PayPwdEditText
+import com.quansu.heifengwuliu.view.PasswordView
 import com.ysnows.base.base.BRepository
 import com.ysnows.base.base.BViewModel
 
@@ -70,21 +66,23 @@ open class SourceDetailsVModel : BViewModel<BRepository>() {
         var layout = layoutInflater.inflate(R.layout.item_apy, null)
         val butCancel: QMUIRoundButton = layout.findViewById(R.id.but_cancel)
         val butSure: QMUIRoundButton = layout.findViewById(R.id.tv_sure)
-        val payPwdEditText: PayPwdEditText = layout.findViewById(R.id.ppet)
-
+        val payPwdEditText: PasswordView = layout.findViewById(R.id.ppet)
         var password=""
-        payPwdEditText.initStyle(R.drawable.edit_num_bg_red, 6, 0.33f, R.color.colorAccent, R.color.colorAccent, 20)
-        payPwdEditText.setOnTextFinishListener { str -> //密码输入完后的回调
-            password=str
-            //todo:
-            Log.e("-shy-", "--str-")
-            getInfoPay(info_id,password)
 
-            mNormalPopup.dismiss()
-        }
+        payPwdEditText.setPasswordListener(object : PasswordView.PasswordListener {
+            override fun keyEnterPress(pwd: String?, isComplete: Boolean) {
+                password= pwd!!
+
+            }
 
-        Handler().postDelayed(Runnable { payPwdEditText.setFocus() }, 100)
+            override fun passwordChange(changeText: String?) {
+            }
+
+            override fun passwordComplete() {
+
+            }
 
+        })
 
         butSure.setOnClickListener {
 
@@ -92,6 +90,8 @@ open class SourceDetailsVModel : BViewModel<BRepository>() {
                 toast("请输入支付密码!")
                 return@setOnClickListener
             }
+            getInfoPay(info_id,password)
+
             mNormalPopup.dismiss()
         }
 

+ 248 - 129
app/src/main/res/layout/activity_password.xml

@@ -1,17 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <layout 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" >
+    xmlns:tools="http://schemas.android.com/tools">
+
+    <data>
 
-    <data >
         <import type="android.view.View" />
+
         <import type="com.quansu.heifengwuliu.utils.MUiSwitch" />
 
         <variable
             name="vm"
             type="com.quansu.heifengwuliu.vmodel.PasswordVModel" />
 
-    </data >
+    </data>
 
     <LinearLayout
         android:name="com.ysnows.login.activity.LoginActivity"
@@ -20,149 +22,266 @@
         android:background="@color/white"
         android:fitsSystemWindows="true"
         android:orientation="vertical"
-        tools:context="com.quansu.heifengwuliu.activity.LoginActivity" >
+        tools:context="com.quansu.heifengwuliu.activity.LoginActivity">
 
 
-
-        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+        <LinearLayout
             android:layout_width="match_parent"
-            android:layout_height="48dp"
-            android:layout_marginLeft="35dp"
-            android:visibility="@{vm.isShow?View.VISIBLE :View.GONE}"
-            android:layout_marginTop="25dp"
-            android:layout_marginRight="35dp"
-            android:gravity="center_vertical"
-            android:paddingStart="@dimen/dp_8"
-            android:paddingEnd="@dimen/dp_14"
-            app:rv_radius="25dp"
-            app:qmui_borderWidth="@dimen/dp_1"
-            app:qmui_borderColor="#F4F3F9"
-            app:qmui_backgroundColor="#F4F3F9"
-
-            >
-
-            <ImageView
-                android:layout_width="35dp"
-                android:layout_height="35dp"
-                android:padding="5dp"
-                android:src="@drawable/ic_login_pwd" />
-
-            <com.ysnows.base.widget.DelEditText
-                android:id="@+id/edt_old_pwd"
+            android:layout_height="match_parent"
+            android:visibility="@{vm.type==1?View.VISIBLE:View.GONE}"
+            android:orientation="vertical">
+
+            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
                 android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="@null"
-                android:hint="@string/please_input_old_pwd"
-                android:inputType="textPassword"
-                android:text="@={vm.oldpassWord}"
-                android:textSize="@dimen/sp_15" />
+                android:layout_height="48dp"
+                android:layout_marginStart="35dp"
+                android:layout_marginEnd="35dp"
+                android:layout_marginTop="25dp"
+                android:gravity="center_vertical"
+                android:paddingStart="@dimen/dp_8"
+                android:paddingEnd="@dimen/dp_14"
+                android:visibility="@{vm.isShow?View.VISIBLE :View.GONE}"
+                app:qmui_backgroundColor="#F4F3F9"
+                app:qmui_borderColor="#F4F3F9"
+                app:qmui_borderWidth="@dimen/dp_1"
+                app:rv_radius="25dp"
+
+                >
+
+                <ImageView
+                    android:layout_width="35dp"
+                    android:layout_height="35dp"
+                    android:padding="5dp"
+                    android:src="@drawable/ic_login_pwd" />
+
+                <com.ysnows.base.widget.DelEditText
+                    android:id="@+id/edt_old_pwd"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="@null"
+                    android:hint="@string/please_input_old_pwd"
+                    android:inputType="textPassword"
+                    android:text="@={vm.oldpassWord}"
+                    android:textSize="@dimen/sp_15" />
+
+            </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
+
+            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="48dp"
+                android:layout_marginStart="35dp"
+                android:layout_marginEnd="35dp"
+                android:layout_marginTop="25dp"
+                android:gravity="center_vertical"
+                android:paddingStart="@dimen/dp_8"
+                android:paddingEnd="@dimen/dp_14"
+                app:qmui_backgroundColor="#F4F3F9"
+                app:qmui_borderColor="#F4F3F9"
+                app:qmui_borderWidth="@dimen/dp_1"
+                app:rv_radius="25dp"
+
+                >
+
+                <ImageView
+                    android:layout_width="35dp"
+                    android:layout_height="35dp"
+                    android:padding="5dp"
+                    android:src="@drawable/ic_login_pwd" />
+
+                <com.ysnows.base.widget.DelEditText
+                    android:id="@+id/edt_new_pwd"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="@null"
+                    android:hint="@string/please_input_new_pwd"
+                    android:inputType="textPassword"
+                    android:text="@={vm.passWord}"
+                    android:textSize="@dimen/sp_15" />
+
+            </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
+
+
+            <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="48dp"
+                android:layout_marginStart="35dp"
+                android:layout_marginEnd="35dp"
+                android:layout_marginTop="25dp"
+                android:gravity="center_vertical"
+                android:paddingStart="@dimen/dp_8"
+                android:paddingEnd="@dimen/dp_14"
+                app:qmui_backgroundColor="#F4F3F9"
+                app:qmui_borderColor="#F4F3F9"
+                app:qmui_borderWidth="@dimen/dp_1"
+                app:rv_radius="25dp"
+
+                >
+
+                <ImageView
+                    android:layout_width="35dp"
+                    android:layout_height="35dp"
+                    android:padding="5dp"
+                    android:src="@drawable/ic_login_pwd" />
+
+                <com.ysnows.base.widget.DelEditText
+                    android:id="@+id/edt_new_pwd_to"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="@null"
+                    android:hint="@string/please_input_new_pwd_twice"
+                    android:inputType="textPassword"
+                    android:text="@={vm.passWordTo}"
+                    android:textSize="@dimen/sp_15" />
+
+            </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout>
+
+            <View
+                android:layout_width="match_parent"
+                android:layout_height="0dp"
+                android:layout_weight="1">
 
-        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+            </View>
 
-        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="48dp"
-            android:layout_marginLeft="35dp"
-            android:layout_marginTop="25dp"
-            android:layout_marginRight="35dp"
-            android:gravity="center_vertical"
-            android:paddingStart="@dimen/dp_8"
-            android:paddingEnd="@dimen/dp_14"
-            app:rv_radius="25dp"
-            app:qmui_borderWidth="@dimen/dp_1"
-            app:qmui_borderColor="#F4F3F9"
-            app:qmui_backgroundColor="#F4F3F9"
-
-            >
-
-            <ImageView
-                android:layout_width="35dp"
-                android:layout_height="35dp"
-                android:padding="5dp"
-                android:src="@drawable/ic_login_pwd" />
-
-            <com.ysnows.base.widget.DelEditText
-                android:id="@+id/edt_new_pwd"
+            <androidx.cardview.widget.CardView
                 android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="@null"
-                android:hint="@string/please_input_new_pwd"
-                android:inputType="textPassword"
-                android:text="@={vm.passWord}"
-                android:textSize="@dimen/sp_15" />
+                android:layout_height="45dp"
+                android:layout_marginLeft="35dp"
+                android:layout_marginTop="10dp"
+                android:layout_marginRight="35dp"
+                android:layout_marginBottom="@dimen/dp_40"
+                android:background="@color/colorPrimary"
+                app:cardBackgroundColor="@color/colorPrimary"
+                app:cardCornerRadius="22.5dp"
+                app:cardElevation="2dp"
+                app:cardPreventCornerOverlap="true">
 
-        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+                <Button
+                    android:id="@+id/btn_submit"
+                    android:layout_width="match_parent"
+                    android:layout_height="match_parent"
+                    android:background="#E17E30"
+                    android:onClick="@{v->vm.toSubmit()}"
+                    android:text="@string/submit"
+                    android:textColor="@color/white"
+                    android:textSize="@dimen/sp_16" />
+
+            </androidx.cardview.widget.CardView>
+
+
+
+        </LinearLayout>
+
+      <!--    支付密码-->
+         <LinearLayout
+             android:layout_width="match_parent"
+             android:orientation="vertical"
+             android:visibility="@{vm.type==2?View.VISIBLE:View.GONE}"
+             android:layout_height="wrap_content">
 
 
-        <com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout
-            android:layout_width="match_parent"
-            android:layout_height="48dp"
-            android:layout_marginLeft="35dp"
-            android:layout_marginTop="25dp"
-            android:layout_marginRight="35dp"
-            android:gravity="center_vertical"
-            android:paddingStart="@dimen/dp_8"
-            android:paddingEnd="@dimen/dp_14"
-            app:rv_radius="25dp"
-            app:qmui_borderWidth="@dimen/dp_1"
-            app:qmui_borderColor="#F4F3F9"
-            app:qmui_backgroundColor="#F4F3F9"
-
-            >
-
-            <ImageView
-                android:layout_width="35dp"
-                android:layout_height="35dp"
-                android:padding="5dp"
-                android:src="@drawable/ic_login_pwd" />
-
-            <com.ysnows.base.widget.DelEditText
-                android:id="@+id/edt_new_pwd_to"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="@null"
-                android:hint="@string/please_input_new_pwd_twice"
-                android:inputType="textPassword"
-                android:text="@={vm.passWordTo}"
-                android:textSize="@dimen/sp_15" />
+             <LinearLayout
+                 android:layout_width="match_parent"
+                 android:orientation="horizontal"
+                 android:layout_marginTop="25dp"
+                 android:gravity="center_vertical"
+                 android:layout_marginStart="35dp"
+                 android:layout_marginEnd="35dp"
+                 android:layout_height="wrap_content">
 
-        </com.qmuiteam.qmui.widget.roundwidget.QMUIRoundLinearLayout >
+                 <TextView
+                     android:layout_width="wrap_content"
+                     android:textSize="@dimen/sp_15"
+                     android:textColor="@color/text_title"
+                     android:text="原支付密码:"
+                     android:layout_height="wrap_content">
 
+                 </TextView>
+
+
+                 <com.quansu.heifengwuliu.view.PasswordView
+                     android:id="@+id/ppet_old_password"
+                     android:layout_width="match_parent"
+                     app:cipherEnable="true"
+                     app:passwordLength="6"
+                     app:smode="rect"
+                     android:layout_height="45dp">
+
+                 </com.quansu.heifengwuliu.view.PasswordView>
+
+
+             </LinearLayout>
+
+
+             <LinearLayout
+                 android:layout_width="match_parent"
+                 android:orientation="horizontal"
+                 android:layout_marginTop="25dp"
+                 android:gravity="center_vertical"
+                 android:layout_marginStart="35dp"
+                 android:layout_marginEnd="35dp"
+                 android:layout_height="wrap_content">
+
+                 <TextView
+                     android:layout_width="wrap_content"
+                     android:textSize="@dimen/sp_15"
+                     android:textColor="@color/text_title"
+                     android:text="新支付密码:"
+                     android:layout_height="wrap_content">
+
+                 </TextView>
+
+                 <com.quansu.heifengwuliu.view.PasswordView
+                     android:id="@+id/ppet_new_password"
+                     android:layout_width="match_parent"
+                     app:cipherEnable="true"
+                     app:passwordLength="6"
+                     app:smode="rect"
+                     android:layout_height="45dp">
+
+                 </com.quansu.heifengwuliu.view.PasswordView>
+
+
+             </LinearLayout>
+
+
+             <View
+                 android:layout_width="match_parent"
+                 android:layout_height="0dp"
+                 android:layout_weight="1">
+
+             </View>
+
+             <androidx.cardview.widget.CardView
+                 android:layout_width="match_parent"
+                 android:layout_height="45dp"
+                 android:layout_marginLeft="35dp"
+                 android:layout_marginTop="10dp"
+                 android:layout_marginRight="35dp"
+                 android:layout_marginBottom="@dimen/dp_40"
+                 android:background="@color/colorPrimary"
+                 app:cardBackgroundColor="@color/colorPrimary"
+                 app:cardCornerRadius="22.5dp"
+                 app:cardElevation="2dp"
+                 app:cardPreventCornerOverlap="true">
+
+                 <Button
+                     android:id="@+id/btn_pay_submit"
+                     android:layout_width="match_parent"
+                     android:layout_height="match_parent"
+                     android:background="#E17E30"
+                     android:text="@string/submit"
+                     android:textColor="@color/white"
+                     android:textSize="@dimen/sp_16" />
+
+             </androidx.cardview.widget.CardView>
 
-        <View
-            android:layout_width="match_parent"
-            android:layout_weight="1"
-            android:layout_height="0dp">
 
-        </View>
 
-        <androidx.cardview.widget.CardView
-            android:layout_width="match_parent"
-            android:layout_height="45dp"
-            android:layout_marginLeft="35dp"
-            android:layout_marginTop="10dp"
-            android:layout_marginBottom="@dimen/dp_40"
-            android:layout_marginRight="35dp"
-            android:background="@color/colorPrimary"
-            app:cardBackgroundColor="@color/colorPrimary"
-            app:cardCornerRadius="22.5dp"
-            app:cardElevation="2dp"
-            app:cardPreventCornerOverlap="true" >
-
-            <Button
-                android:id="@+id/btn_submit"
-                android:layout_width="match_parent"
-                android:layout_height="match_parent"
-                android:background="#E17E30"
-                android:onClick="@{v->vm.toSubmit()}"
-                android:text="@string/submit"
-                android:textColor="@color/white"
-                android:textSize="@dimen/sp_16" />
 
-        </androidx.cardview.widget.CardView >
 
+         </LinearLayout>
 
 
 
-    </LinearLayout >
-</layout >
+    </LinearLayout>
+</layout>

+ 13 - 4
app/src/main/res/layout/item_apy.xml

@@ -21,14 +21,23 @@
             android:layout_centerHorizontal="true"
             android:textColor="#333333"
             android:text="输入支付密码"/>
-        <com.quansu.heifengwuliu.view.PayPwdEditText
+
+        <com.quansu.heifengwuliu.view.PasswordView
             android:id="@+id/ppet"
             android:layout_below="@+id/tv_title"
             android:layout_width="match_parent"
+            app:cipherEnable="true"
             android:layout_marginTop="30dp"
-            android:layout_marginLeft="20dp"
-            android:layout_marginRight="20dp"
-            android:layout_height="45dp"/>
+            android:layout_centerInParent="true"
+            app:passwordLength="6"
+            app:smode="rect"
+            android:layout_height="45dp">
+
+        </com.quansu.heifengwuliu.view.PasswordView>
+
+
+
+
 
 
         <View

+ 2 - 1
app/src/main/res/values/attr.xml

@@ -17,4 +17,5 @@
 <resources>
     <attr name="app_primary_color" format="color" /> <!-- topbar -->
     <attr name="app_content_bg_color" format="color" /> <!-- content-->
-</resources>
+
+</resources>

+ 17 - 0
app/src/main/res/values/styles.xml

@@ -250,4 +250,21 @@
         <attr name="sb_tv_selected_color" format="color" />
 
     </declare-styleable >
+
+    <declare-styleable name="PasswordView">
+        <attr name="passwordLength" format="integer" />
+        <attr name="passwordPadding" format="dimension" />
+        <attr name="borderColor" format="color" />
+        <attr name="borderWidth" format="dimension" />
+        <attr name="cursorFlashTime" format="integer" />
+        <attr name="isCursorEnable" format="boolean" />
+        <attr name="cipherEnable" format="boolean" />
+        <attr name="cursorColor" format="color" />
+        <attr name="smode" format="enum">
+            <enum name="underline" value="0" />
+            <enum name="rect" value="1" />
+        </attr>
+    </declare-styleable>
+
+
 </resources >