Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
ShenghuoquanBusiness
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
bp
ShenghuoquanBusiness
Commits
5f0dc74f
Commit
5f0dc74f
authored
Jun 22, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix SHQBD-123 生活号名称限制长度24个字符
parent
10f59bbd
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
101 additions
and
86 deletions
+101
-86
Constant.kt
.../com/yidian/shenghuoquan/newscontent/constant/Constant.kt
+3
-0
LifeAccountCreateActivity.kt
...ghuoquan/newscontent/ui/auth/LifeAccountCreateActivity.kt
+11
-15
LifeAccountModifyNameActivity.kt
...an/newscontent/ui/center/LifeAccountModifyNameActivity.kt
+9
-4
InputFilterUtil.kt
.../yidian/shenghuoquan/newscontent/utils/InputFilterUtil.kt
+76
-65
activity_life_account_create.xml
...tent/src/main/res/layout/activity_life_account_create.xml
+1
-1
strings.xml
Components/newscontent/src/main/res/values/strings.xml
+1
-1
No files found.
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/constant/Constant.kt
View file @
5f0dc74f
...
@@ -87,4 +87,7 @@ object Constant {
...
@@ -87,4 +87,7 @@ object Constant {
const
val
MERCHANT_SERVICE_GROUP_PUBLISH
=
1
// 我要发布
const
val
MERCHANT_SERVICE_GROUP_PUBLISH
=
1
// 我要发布
const
val
MERCHANT_SERVICE_GROUP_MANAGEMENT
=
2
// 管理服务
const
val
MERCHANT_SERVICE_GROUP_MANAGEMENT
=
2
// 管理服务
const
val
MERCHANT_SERVICE_GROUP_OTHER
=
3
// 其他服务
const
val
MERCHANT_SERVICE_GROUP_OTHER
=
3
// 其他服务
// 各输入场景最大长度显示
const
val
MAX_LENGTH_LIFE_ACCOUNT_NAME
=
24
// 生活号名称
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/auth/LifeAccountCreateActivity.kt
View file @
5f0dc74f
...
@@ -3,7 +3,7 @@ package com.yidian.shenghuoquan.newscontent.ui.auth
...
@@ -3,7 +3,7 @@ package com.yidian.shenghuoquan.newscontent.ui.auth
import
android.annotation.SuppressLint
import
android.annotation.SuppressLint
import
android.os.Bundle
import
android.os.Bundle
import
android.text.Editable
import
android.text.Editable
import
android
.text.InputFilter
import
android
x.core.content.ContextCompat
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
com.orhanobut.hawk.Hawk
import
com.orhanobut.hawk.Hawk
import
com.yidian.common.HawkConfig
import
com.yidian.common.HawkConfig
...
@@ -12,6 +12,7 @@ import com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_CREATE
...
@@ -12,6 +12,7 @@ import com.yidian.common.XRouterPathConstants.Companion.LIFE_ACCOUNT_CREATE
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.base.BaseActivity
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import
com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import
com.yidian.shenghuoquan.newscontent.constant.Constant
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountCreateBinding
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountCreateBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.utils.InputFilterUtil
import
com.yidian.shenghuoquan.newscontent.utils.InputFilterUtil
...
@@ -21,7 +22,7 @@ import com.yidian.utils.ToastUtil
...
@@ -21,7 +22,7 @@ import com.yidian.utils.ToastUtil
import
com.yidian.xpage.XPageManager
import
com.yidian.xpage.XPageManager
class
LifeAccountCreateActivity
:
BaseActivity
<
ActivityLifeAccountCreateBinding
>(),
class
LifeAccountCreateActivity
:
BaseActivity
<
ActivityLifeAccountCreateBinding
>(),
ICreateLifeAccountCallback
{
ICreateLifeAccountCallback
,
InputFilterUtil
.
OnLengthFilterCallback
{
companion
object
{
companion
object
{
private
const
val
TAG
=
"LifeAccountCreate"
private
const
val
TAG
=
"LifeAccountCreate"
const
val
LIFE_ACCOUNT_ID
=
"life_account_id"
const
val
LIFE_ACCOUNT_ID
=
"life_account_id"
...
@@ -36,10 +37,6 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
...
@@ -36,10 +37,6 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
return
LIFE_ACCOUNT_CREATE
return
LIFE_ACCOUNT_CREATE
}
}
/**
* 生活号名称长度限制
*/
private
val
lifeAccountNameMaxLength
=
40
private
var
lifeAccountId
:
String
?
=
null
private
var
lifeAccountId
:
String
?
=
null
private
var
lifeAccountName
:
String
?
=
null
private
var
lifeAccountName
:
String
?
=
null
...
@@ -74,7 +71,7 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
...
@@ -74,7 +71,7 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
}
}
})
})
// 设置输入过滤规则
// 设置输入过滤规则
viewBind
.
etAccount
.
filters
=
arrayOf
(
InputFilterUtil
.
getL
ifeAccountNameFilter
(),
InputFilter
.
LengthFilter
(
lifeAccountNameMaxLength
+
1
))
viewBind
.
etAccount
.
filters
=
arrayOf
(
InputFilterUtil
.
getL
engthFilter
(
Constant
.
MAX_LENGTH_LIFE_ACCOUNT_NAME
,
this
))
viewBind
.
btnCreateAccount
.
setOnClickListener
{
viewBind
.
btnCreateAccount
.
setOnClickListener
{
createLifeAccount
()
createLifeAccount
()
}
}
...
@@ -110,14 +107,6 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
...
@@ -110,14 +107,6 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
viewBind
.
btnCreateAccount
.
isEnabled
=
false
viewBind
.
btnCreateAccount
.
isEnabled
=
false
viewBind
.
tvErrorTips
.
isVisible
=
false
viewBind
.
tvErrorTips
.
isVisible
=
false
viewBind
.
vDivider
.
setBackgroundResource
(
R
.
color
.
divider_white
)
viewBind
.
vDivider
.
setBackgroundResource
(
R
.
color
.
divider_white
)
return
}
if
(
s
.
length
>
lifeAccountNameMaxLength
)
{
viewBind
.
btnCreateAccount
.
alpha
=
0.32f
viewBind
.
btnCreateAccount
.
isEnabled
=
false
viewBind
.
tvErrorTips
.
isVisible
=
true
viewBind
.
etAccount
.
setTextColor
(
resources
.
getColor
(
R
.
color
.
red_account_tips
))
viewBind
.
vDivider
.
setBackgroundResource
(
R
.
color
.
red_account_tips
)
}
else
{
}
else
{
viewBind
.
btnCreateAccount
.
alpha
=
1f
viewBind
.
btnCreateAccount
.
alpha
=
1f
viewBind
.
btnCreateAccount
.
isEnabled
=
true
viewBind
.
btnCreateAccount
.
isEnabled
=
true
...
@@ -142,4 +131,11 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
...
@@ -142,4 +131,11 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
}
}
}
}
override
fun
onLengthOverrun
(
maxLength
:
Int
)
{
// 输入长度超限 展示错误提示
viewBind
.
tvErrorTips
.
isVisible
=
true
viewBind
.
etAccount
.
setTextColor
(
ContextCompat
.
getColor
(
this
,
R
.
color
.
red_account_tips
))
viewBind
.
vDivider
.
setBackgroundResource
(
R
.
color
.
red_account_tips
)
}
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/center/LifeAccountModifyNameActivity.kt
View file @
5f0dc74f
package
com.yidian.shenghuoquan.newscontent.ui.center
package
com.yidian.shenghuoquan.newscontent.ui.center
import
android.os.Bundle
import
android.os.Bundle
import
android.text.InputFilter
import
com.yidian.common.XEventConfig
import
com.yidian.common.XEventConfig
import
com.yidian.common.XRouterPathConstants
import
com.yidian.common.XRouterPathConstants
import
com.yidian.common.base.BaseActivity
import
com.yidian.common.base.BaseActivity
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import
com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import
com.yidian.shenghuoquan.newscontent.constant.Constant
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountModifyNameBinding
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountModifyNameBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.utils.InputFilterUtil
import
com.yidian.shenghuoquan.newscontent.utils.InputFilterUtil
...
@@ -24,7 +24,7 @@ import com.yidian.xpage.XPageManager
...
@@ -24,7 +24,7 @@ import com.yidian.xpage.XPageManager
class
LifeAccountModifyNameActivity
:
BaseActivity
<
ActivityLifeAccountModifyNameBinding
>(),
class
LifeAccountModifyNameActivity
:
BaseActivity
<
ActivityLifeAccountModifyNameBinding
>(),
CommonTopBarView
.
OnCommonTopBarActionCallback
,
CommonTopBarView
.
OnCommonTopBarActionCallback
,
LifeAccountAuthIdentityInfoEditView
.
OnLifeAccountAuthIdentityInfoEditViewCallback
,
LifeAccountAuthIdentityInfoEditView
.
OnLifeAccountAuthIdentityInfoEditViewCallback
,
ICreateLifeAccountCallback
{
ICreateLifeAccountCallback
,
InputFilterUtil
.
OnLengthFilterCallback
{
companion
object
{
companion
object
{
const
val
EXTRA_LIFE_ACCOUNT_ID
=
"life_account_id"
const
val
EXTRA_LIFE_ACCOUNT_ID
=
"life_account_id"
...
@@ -50,8 +50,8 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
...
@@ -50,8 +50,8 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
}
}
private
fun
initView
()
{
private
fun
initView
()
{
//
只允许输入中文并且最长20汉字
//
生活号名称长度限制24个字符
viewBind
.
evLifeAccountName
.
setInputFilters
(
InputFilterUtil
.
getL
ifeAccountNameFilter
(),
InputFilter
.
LengthFilter
(
40
))
viewBind
.
evLifeAccountName
.
setInputFilters
(
InputFilterUtil
.
getL
engthFilter
(
Constant
.
MAX_LENGTH_LIFE_ACCOUNT_NAME
,
this
))
}
}
private
fun
initListener
()
{
private
fun
initListener
()
{
...
@@ -100,4 +100,9 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
...
@@ -100,4 +100,9 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
viewBind
.
evLifeAccountName
.
showErrorTips
(
resources
.
getString
(
R
.
string
.
life_account_name_already_exist
))
viewBind
.
evLifeAccountName
.
showErrorTips
(
resources
.
getString
(
R
.
string
.
life_account_name_already_exist
))
}
}
}
}
override
fun
onLengthOverrun
(
maxLength
:
Int
)
{
// 输入长度超限 展示错误提示
viewBind
.
evLifeAccountName
.
showErrorTips
(
resources
.
getString
(
R
.
string
.
life_account_name_overrun_error_tips
))
}
}
}
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/utils/InputFilterUtil.kt
View file @
5f0dc74f
...
@@ -9,82 +9,93 @@ import java.util.regex.Pattern
...
@@ -9,82 +9,93 @@ import java.util.regex.Pattern
* date: 6/15/21 1:59 AM
* date: 6/15/21 1:59 AM
* description: 输入过滤
* description: 输入过滤
*/
*/
object
InputFilterUtil
{
class
InputFilterUtil
{
/**
companion
object
{
* 真实姓名过滤
/**
* 汉字 + ·
* 真实姓名过滤
*/
* 汉字 + ·
fun
getRealNameFilter
():
InputFilter
{
*/
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
fun
getRealNameFilter
():
InputFilter
{
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF|·]+"
)
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF|·]+"
)
if
(!
matcher
.
matches
())
return
@InputFilter
""
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
return
@InputFilter
null
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
}
}
}
}
/**
/**
* 身份证号过滤
* 身份证号过滤
* 数字 + X
* 数字 + X
*/
*/
fun
getIDCardNumberFilter
():
InputFilter
{
fun
getIDCardNumberFilter
():
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9|X]+"
)
val
pattern
=
Pattern
.
compile
(
"[0-9|X]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
return
@InputFilter
null
}
}
}
}
/**
/**
* 手机号过滤
* 手机号过滤
* 数字
* 数字
*/
*/
fun
getPhoneNumberFilter
():
InputFilter
{
fun
getPhoneNumberFilter
():
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9]+"
)
val
pattern
=
Pattern
.
compile
(
"[0-9]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
return
@InputFilter
null
}
}
}
}
/**
/**
* 公司注册名过滤
* 公司注册名过滤
* 汉字
* 汉字
*/
*/
fun
getRegistrationNameFilter
():
InputFilter
{
fun
getRegistrationNameFilter
():
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
return
@InputFilter
null
}
}
}
}
/**
/**
* 统一社会信用代码过滤
* 统一社会信用代码过滤
* 数字 + 大写字母
* 数字 + 大写字母
*/
*/
fun
getRegistrationCodeFilter
():
InputFilter
{
fun
getRegistrationCodeFilter
():
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9A-Z]+"
)
val
pattern
=
Pattern
.
compile
(
"[0-9A-Z]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
return
@InputFilter
null
}
}
}
}
/**
/**
* 生活号名称过滤
* 带回调的输入长度过滤
*/
*/
fun
getLifeAccountNameFilter
():
InputFilter
{
fun
getLengthFilter
(
maxLength
:
Int
,
callback
:
OnLengthFilterCallback
?):
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
if
(
dstart
+
end
>=
maxLength
+
1
)
{
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
callback
?.
onLengthOverrun
(
maxLength
)
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
""
return
@InputFilter
null
}
return
@InputFilter
null
}
}
}
}
}
interface
OnLengthFilterCallback
{
/**
* 长度超限
* @param maxLength 最大长度
*/
fun
onLengthOverrun
(
maxLength
:
Int
)
}
}
}
Components/newscontent/src/main/res/layout/activity_life_account_create.xml
View file @
5f0dc74f
...
@@ -82,7 +82,7 @@
...
@@ -82,7 +82,7 @@
android:layout_marginStart=
"20dp"
android:layout_marginStart=
"20dp"
android:paddingTop=
"6dp"
android:paddingTop=
"6dp"
android:paddingBottom=
"6dp"
android:paddingBottom=
"6dp"
android:text=
"@string/
account
_error_tips"
android:text=
"@string/
life_account_name_overrun
_error_tips"
android:textColor=
"@color/red_account_tips"
android:textColor=
"@color/red_account_tips"
android:textSize=
"12sp"
android:textSize=
"12sp"
android:visibility=
"gone"
android:visibility=
"gone"
...
...
Components/newscontent/src/main/res/values/strings.xml
View file @
5f0dc74f
...
@@ -51,7 +51,7 @@
...
@@ -51,7 +51,7 @@
<string
name=
"create_account"
>
确认创建
</string>
<string
name=
"create_account"
>
确认创建
</string>
<string
name=
"account_create_tips"
>
同企业下生活号名称不可复用
</string>
<string
name=
"account_create_tips"
>
同企业下生活号名称不可复用
</string>
<string
name=
"account_create_desc"
>
生活号作为企业服务管理载体,请正确使用生活号权益,新申请生活号默认当前申请人作为默认管理员,申请成功 后可在销售APP内进行更改
</string>
<string
name=
"account_create_desc"
>
生活号作为企业服务管理载体,请正确使用生活号权益,新申请生活号默认当前申请人作为默认管理员,申请成功 后可在销售APP内进行更改
</string>
<string
name=
"
account_error_tips"
>
名称超限,最多40
个字符
</string>
<string
name=
"
life_account_name_overrun_error_tips"
>
名称超限,最多24
个字符
</string>
<string
name=
"account_manager"
>
管理员
</string>
<string
name=
"account_manager"
>
管理员
</string>
<string
name=
"account_name"
>
生活号名称
</string>
<string
name=
"account_name"
>
生活号名称
</string>
<string
name=
"account_title"
>
创建生活号
</string>
<string
name=
"account_title"
>
创建生活号
</string>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment