浏览代码

feat: enterpassword invite

tongmengxiao 5 月之前
父节点
当前提交
6c7ecb3450

+ 92 - 0
baseswago/src/main/java/com/swago/baseswago/cusview/CodeTextView.kt

@@ -0,0 +1,92 @@
+package com.swago.baseswago.cusview
+
+import android.content.Context
+import android.text.Editable
+import android.text.TextWatcher
+import android.util.AttributeSet
+import android.view.KeyEvent
+import android.view.View
+import android.widget.EditText
+import android.widget.RelativeLayout
+import android.widget.TextView
+import com.swago.baseswago.R
+import com.swago.baseswago.util.LogUtil
+
+class CodeTextView : RelativeLayout {
+    private var editText: EditText? = null
+    private val textViewList: MutableList<TextView> = ArrayList()
+    private val viewList: MutableList<View> = ArrayList()
+    private val stringBuffer = StringBuffer()
+
+    constructor(context: Context?) : this(context, null)
+    constructor(context: Context?, attrs: AttributeSet?) : this(context, attrs, 0)
+    constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
+
+    init {
+        //添加布局内容
+        View.inflate(context, R.layout.view_code_textview, this)
+        editText = findViewById(R.id.editCode)
+        textViewList.add(findViewById(R.id.txtCode1))
+        textViewList.add(findViewById(R.id.txtCode2))
+        textViewList.add(findViewById(R.id.txtCode3))
+        textViewList.add(findViewById(R.id.txtCode4))
+        viewList.add(findViewById(R.id.view_1))
+        viewList.add(findViewById(R.id.view_2))
+        viewList.add(findViewById(R.id.view_3))
+        viewList.add(findViewById(R.id.view_4))
+
+        editText!!.setOnFocusChangeListener { v, hasFocus ->
+            if (hasFocus)
+                viewList[0].visibility = View.VISIBLE
+        }
+
+        editText!!.addTextChangedListener(object : TextWatcher {
+
+            override fun beforeTextChanged(s: CharSequence, start: Int, count: Int, after: Int) {
+            }
+            override fun onTextChanged(s: CharSequence, start: Int, before: Int, count: Int) {
+            }
+
+            override fun afterTextChanged(s: Editable) {
+                //如果有字符输入时才进行操作
+                if (s.toString() != "") {
+                    //我们限制了4个验证码
+                    if (stringBuffer.length > 3) {
+                        editText!!.setText("")
+                        return
+                    } else {
+                        stringBuffer.append(s)
+                        //因为editText是辅助的,根本字符串是stringBuffer,所以将EditText置空
+                        editText!!.setText("")
+                        //现在很多App都是输入完毕后自动进入下一步逻辑,所以咱们一般都是在这监听,完成后进行回调业务即可
+                    }
+                    for (i in 0 until stringBuffer.length) {
+                        textViewList[i].text = stringBuffer[i].toString() + ""
+                        viewList[i].visibility = View.GONE
+                        if (i + 1 < viewList.size){
+                            viewList[i+1].visibility = View.VISIBLE
+                        }
+                    }
+                }
+            }
+        })
+
+        //设置删除按键的监听
+        editText!!.setOnKeyListener(OnKeyListener { v, keyCode, event ->
+            if (keyCode == KeyEvent.KEYCODE_DEL && event.action == KeyEvent.ACTION_DOWN) {
+                if (stringBuffer.length > 0) {
+                    //删除字符
+                    stringBuffer.delete(stringBuffer.length - 1, stringBuffer.length)
+                    //将TextView显示内容置空
+                    textViewList[stringBuffer.length].text = ""
+                    viewList.forEach {
+                        it.visibility = View.GONE
+                    }
+                    viewList[stringBuffer.length].visibility = View.VISIBLE
+                }
+                return@OnKeyListener true
+            }
+            false
+        })
+    }
+}

+ 4 - 0
baseswago/src/main/res/drawable/cursor_color.xml

@@ -0,0 +1,4 @@
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <size android:width="2dp" />
+    <solid android:color="#ffffff" /> <!-- 设置光标颜色 -->
+</shape>

+ 6 - 0
baseswago/src/main/res/drawable/shape_9b20fc_line_20.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <stroke android:width="2dp" android:color="#9b20fc"/>
+    <solid android:color="@color/_ffffff"/>
+    <corners android:radius="20dp"/>
+</shape>

+ 5 - 0
baseswago/src/main/res/drawable/shape_eceff2_12.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<shape xmlns:android="http://schemas.android.com/apk/res/android">
+    <solid android:color="#ECEFF2"/>
+    <corners android:radius="12dp"/>
+</shape>

+ 83 - 0
baseswago/src/main/res/layout/dialog_enter_password.xml

@@ -0,0 +1,83 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    app:layout_constraintTop_toTopOf="parent"
+    android:layout_width="match_parent"
+    android:layout_height="wrap_content"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:background="@drawable/shape_white_20"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:paddingBottom="30dp"
+        app:layout_constraintBottom_toBottomOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content">
+
+
+    <TextView
+        android:id="@+id/tv_invite_title"
+        android:text="Set Room Password"
+        android:textColor="#0F172A"
+        android:textSize="18sp"
+        android:textStyle="bold"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_marginTop="30dp"/>
+
+    <TextView
+        android:id="@+id/tv_hint"
+        android:text="Please enter your password"
+        android:textColor="#0F172A"
+        android:textSize="14sp"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        android:layout_marginTop="16dp"
+        app:layout_constraintTop_toBottomOf="@+id/tv_invite_title"/>
+
+    <com.swago.baseswago.cusview.CodeTextView
+        android:id="@+id/activation_code"
+        android:layout_width="match_parent"
+        android:layout_height="60dp"
+        android:layout_marginStart="32dp"
+        android:layout_marginEnd="32dp"
+        android:layout_marginTop="16dp"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/tv_hint"/>
+
+    <TextView
+        android:id="@+id/tv_setting"
+        android:layout_width="match_parent"
+        android:layout_height="50dp"
+        android:layout_marginTop="20dp"
+        app:layout_constraintTop_toBottomOf="@+id/activation_code"
+        app:layout_constraintEnd_toEndOf="parent"
+        android:layout_marginEnd="20dp"
+        android:textColor="#fff"
+        android:textSize="@dimen/sp_16"
+        android:text="Setting"
+        android:gravity="center"
+        android:layout_marginBottom="30dp"
+        android:layout_marginStart="30dp"
+        android:background="@drawable/shape_9b20fc_20"/>
+
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <RelativeLayout
+        android:id="@+id/iv_bg"
+        android:layout_width="match_parent"
+        android:layout_height="match_parent"
+        android:background="@mipmap/bg_invite"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 94 - 0
baseswago/src/main/res/layout/dialog_invite_binding.xml

@@ -0,0 +1,94 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    xmlns:tools="http://schemas.android.com/tools">
+
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/clRoot"
+        android:layout_marginTop="50dp"
+        android:layout_marginStart="40dp"
+        android:layout_marginEnd="40dp"
+        android:background="@drawable/shape_white_20"
+        app:layout_constraintTop_toTopOf="parent"
+        android:layout_width="match_parent"
+        android:layout_height="220dp">
+
+        <ImageView
+            android:id="@+id/iv_head"
+            android:layout_width="match_parent"
+            android:layout_height="match_parent"
+            android:background="@mipmap/bg_invite"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            app:layout_constraintBottom_toBottomOf="parent" />
+
+        <TextView
+            android:id="@+id/tv_invite_title"
+            android:text="Agency invitation"
+            android:textColor="#0F172A"
+            android:textSize="18sp"
+            android:textStyle="bold"
+            android:layout_width="wrap_content"
+            android:layout_height="wrap_content"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            app:layout_constraintTop_toTopOf="parent"
+            android:layout_marginTop="50dp"/>
+
+        <TextView
+            android:text="Nickname (ID: 324235) invites you to join his guild "
+            android:textColor="#0F172A"
+            android:textSize="14sp"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:layout_constraintEnd_toEndOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            android:layout_marginStart="20dp"
+            android:layout_marginEnd="20dp"
+            android:layout_marginTop="24dp"
+            app:layout_constraintTop_toBottomOf="@+id/tv_invite_title"/>
+
+
+        <TextView
+            android:id="@+id/tv_refuse"
+            android:layout_width="120dp"
+            android:layout_height="50dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintStart_toStartOf="parent"
+            android:layout_marginStart="20dp"
+            android:text="Refuse"
+            android:textColor="#9b20fc"
+            android:textSize="@dimen/sp_16"
+            android:gravity="center"
+            android:layout_marginBottom="20dp"
+            android:background="@drawable/shape_9b20fc_line_20"/>
+
+        <TextView
+            android:id="@+id/tv_agree"
+            android:layout_width="120dp"
+            android:layout_height="50dp"
+            app:layout_constraintBottom_toBottomOf="parent"
+            app:layout_constraintEnd_toEndOf="parent"
+            android:layout_marginEnd="20dp"
+            android:textColor="#fff"
+            android:textSize="@dimen/sp_16"
+            android:text="Agree"
+            android:gravity="center"
+            android:layout_marginBottom="20dp"
+            android:background="@drawable/shape_9b20fc_20"/>
+    </androidx.constraintlayout.widget.ConstraintLayout>
+
+    <ImageView
+        android:id="@+id/iv"
+        android:layout_width="100dp"
+        android:layout_height="100dp"
+        android:src="@mipmap/ic_invite"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintTop_toTopOf="parent"/>
+
+</androidx.constraintlayout.widget.ConstraintLayout>

+ 133 - 0
baseswago/src/main/res/layout/view_code_textview.xml

@@ -0,0 +1,133 @@
+<?xml version="1.0" encoding="utf-8"?>
+<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent">
+
+    <LinearLayout
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        android:orientation="horizontal"
+        android:weightSum="4"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent">
+
+        <RelativeLayout
+            android:layout_width="0dp"
+            android:layout_height="60dp"
+            android:layout_marginStart="4dp"
+            android:layout_marginEnd="4dp"
+            android:layout_weight="1">
+
+            <TextView
+                android:id="@+id/txtCode1"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/shape_eceff2_12"
+                android:gravity="center"
+                android:textColor="#0F172A"
+                android:textSize="28sp" />
+
+            <View
+                android:id="@+id/view_1"
+                android:layout_width="2dp"
+                android:layout_height="30dp"
+                android:layout_centerInParent="true"
+                android:visibility="gone"
+                android:background="@drawable/shape_80000000_20" />
+        </RelativeLayout>
+
+
+        <RelativeLayout
+            android:layout_width="0dp"
+            android:layout_height="60dp"
+            android:layout_marginStart="4dp"
+            android:layout_marginEnd="4dp"
+            android:layout_weight="1">
+
+            <TextView
+                android:id="@+id/txtCode2"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/shape_eceff2_12"
+                android:gravity="center"
+                android:textColor="#0F172A"
+                android:textSize="28sp" />
+
+            <View
+                android:id="@+id/view_2"
+                android:layout_width="2dp"
+                android:layout_height="30dp"
+                android:layout_centerInParent="true"
+                android:visibility="gone"
+                android:background="@drawable/shape_80000000_20" />
+        </RelativeLayout>
+
+        <RelativeLayout
+            android:layout_width="0dp"
+            android:layout_height="60dp"
+            android:layout_marginStart="4dp"
+            android:layout_marginEnd="4dp"
+            android:layout_weight="1">
+
+            <TextView
+                android:id="@+id/txtCode3"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/shape_eceff2_12"
+                android:gravity="center"
+                android:textColor="#0F172A"
+                android:textSize="28sp" />
+
+            <View
+                android:id="@+id/view_3"
+                android:layout_width="2dp"
+                android:layout_height="30dp"
+                android:layout_centerInParent="true"
+                android:visibility="gone"
+                android:background="@drawable/shape_80000000_20" />
+        </RelativeLayout>
+
+
+        <RelativeLayout
+            android:layout_width="0dp"
+            android:layout_height="60dp"
+            android:layout_marginStart="4dp"
+            android:layout_marginEnd="4dp"
+            android:layout_weight="1">
+
+            <TextView
+                android:id="@+id/txtCode4"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:background="@drawable/shape_eceff2_12"
+                android:gravity="center"
+                android:textColor="#0F172A"
+                android:textSize="28sp" />
+
+            <View
+                android:id="@+id/view_4"
+                android:layout_width="2dp"
+                android:layout_height="30dp"
+                android:layout_centerInParent="true"
+                android:visibility="gone"
+                android:background="@drawable/shape_80000000_20" />
+        </RelativeLayout>
+
+
+    </LinearLayout>
+
+    <EditText
+        android:id="@+id/editCode"
+        android:layout_width="match_parent"
+        android:layout_height="80dp"
+        android:background="@android:color/transparent"
+        android:inputType="number"
+        android:textCursorDrawable="@drawable/cursor_color"
+        android:textScaleX="1"
+        app:layout_constraintEnd_toEndOf="parent"
+        app:layout_constraintStart_toStartOf="parent"
+        app:layout_constraintTop_toTopOf="parent" />
+
+</androidx.constraintlayout.widget.ConstraintLayout>

二进制
baseswago/src/main/res/mipmap-xxhdpi/bg_invite.png


二进制
baseswago/src/main/res/mipmap-xxhdpi/ic_invite.png


+ 38 - 0
home/src/main/java/com/swago/home/dialog/EnterPasswordDialog.kt

@@ -0,0 +1,38 @@
+package com.swago.home.dialog
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.View.OnClickListener
+import com.swago.baseswago.databinding.DialogEnterPasswordBinding
+import com.swago.baseswago.databinding.DialogInviteBindingBinding
+import com.swago.baseswago.dialog.BaseXDFragment
+
+class EnterPasswordDialog : BaseXDFragment<DialogEnterPasswordBinding>() {
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.5f)
+        setCanCancel(false)
+    }
+
+    companion object {
+        fun newInstance(): EnterPasswordDialog {
+            val args = Bundle()
+            val fragment = EnterPasswordDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        binding.tvSetting.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+
+    }
+
+    override fun initLiveData() {
+
+    }
+}

+ 39 - 0
home/src/main/java/com/swago/home/dialog/InviteBindingDialog.kt

@@ -0,0 +1,39 @@
+package com.swago.home.dialog
+
+import android.os.Bundle
+import android.view.Gravity
+import android.view.View
+import android.view.View.OnClickListener
+import com.swago.baseswago.databinding.DialogInviteBindingBinding
+import com.swago.baseswago.dialog.BaseXDFragment
+
+class InviteBindingDialog : BaseXDFragment<DialogInviteBindingBinding>() {
+
+    init {
+        setGravity(Gravity.CENTER)
+        setDimAmount(0.5f)
+        setCanCancel(false)
+    }
+
+    companion object {
+        fun newInstance(): InviteBindingDialog {
+            val args = Bundle()
+            val fragment = InviteBindingDialog()
+            fragment.arguments = args
+            return fragment
+        }
+    }
+
+    override fun initOther() {
+        binding.tvRefuse.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+        binding.tvAgree.setOnClickListener {
+            dismissAllowingStateLoss()
+        }
+    }
+
+    override fun initLiveData() {
+
+    }
+}