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
eaf22524
Commit
eaf22524
authored
Jun 18, 2021
by
yinjiacheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix SHQBD-156 SHQBD-147 生活号名称修改长度上限修改为40
parent
b8e54f47
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
39 deletions
+39
-39
LifeAccountCreateActivity.kt
...ghuoquan/newscontent/ui/auth/LifeAccountCreateActivity.kt
+19
-19
LifeAccountModifyNameActivity.kt
...an/newscontent/ui/center/LifeAccountModifyNameActivity.kt
+1
-1
InputFilterUtil.kt
.../yidian/shenghuoquan/newscontent/utils/InputFilterUtil.kt
+17
-17
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/ui/auth/LifeAccountCreateActivity.kt
View file @
eaf22524
...
...
@@ -3,6 +3,7 @@ package com.yidian.shenghuoquan.newscontent.ui.auth
import
android.annotation.SuppressLint
import
android.os.Bundle
import
android.text.Editable
import
android.text.InputFilter
import
androidx.core.view.isVisible
import
com.orhanobut.hawk.Hawk
import
com.yidian.common.HawkConfig
...
...
@@ -13,6 +14,8 @@ import com.yidian.shenghuoquan.newscontent.R
import
com.yidian.shenghuoquan.newscontent.bean.ICreateLifeAccountCallback
import
com.yidian.shenghuoquan.newscontent.databinding.ActivityLifeAccountCreateBinding
import
com.yidian.shenghuoquan.newscontent.http.ApiService
import
com.yidian.shenghuoquan.newscontent.utils.InputFilterUtil
import
com.yidian.shenghuoquan.newscontent.utils.SensitiveInfoUtil
import
com.yidian.shenghuoquan.newscontent.utils.TextWatcherAdapter
import
com.yidian.utils.ToastUtil
import
com.yidian.xpage.XPageManager
...
...
@@ -33,9 +36,12 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
return
LIFE_ACCOUNT_CREATE
}
private
val
accountMaxLength
=
20
/**
* 生活号名称长度限制
*/
private
val
lifeAccountNameMaxLength
=
40
private
var
lifeAccountId
:
String
?
=
null
private
var
lifeAccountName
:
String
=
""
private
var
lifeAccountName
:
String
?
=
null
override
fun
init
(
savedInstanceState
:
Bundle
?)
{
super
.
init
(
savedInstanceState
)
...
...
@@ -45,15 +51,13 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
}
private
fun
initData
()
{
val
params
=
intent
.
getSerializableExtra
(
XRouterPathConstants
.
ParamsKey
)
if
(
params
!=
null
&&
params
is
HashMap
<*,
*>)
{
lifeAccountId
=
params
[
LIFE_ACCOUNT_ID
]
as
String
lifeAccountId
=
intent
.
getSerializableExtra
(
XRouterPathConstants
.
ParamsKey
)
?.
let
{
params
->
(
params
as
HashMap
<*,
*>)[
LIFE_ACCOUNT_ID
]
?.
let
{
it
as
String
}
}
// 设置管理员信息
val
name
=
Hawk
.
get
(
HawkConfig
.
Nickname
,
""
)
val
phone
=
Hawk
.
get
(
HawkConfig
.
Mobile
,
""
)
setUserName
(
name
,
phone
)
setUserName
(
Hawk
.
get
(
HawkConfig
.
Nickname
,
""
),
Hawk
.
get
(
HawkConfig
.
Mobile
,
""
))
}
private
fun
initView
()
{
...
...
@@ -69,6 +73,8 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
checkAccount
(
s
.
toString
())
}
})
// 设置输入过滤规则
viewBind
.
etAccount
.
filters
=
arrayOf
(
InputFilterUtil
.
getLifeAccountNameFilter
(),
InputFilter
.
LengthFilter
(
lifeAccountNameMaxLength
+
1
))
viewBind
.
btnCreateAccount
.
setOnClickListener
{
createLifeAccount
()
}
...
...
@@ -79,15 +85,13 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
*/
private
fun
createLifeAccount
()
{
lifeAccountName
=
viewBind
.
etAccount
.
text
.
toString
()
if
(
lifeAccountName
.
isEmpty
())
{
ToastUtil
.
showToast
(
this
,
"生活号名称不能为空"
)
if
(
lifeAccountName
.
isNullOrEmpty
()
||
lifeAccountId
.
isNullOrEmpty
())
{
return
}
ApiService
.
createLifeAccount
(
this
,
hashMapOf
(
Pair
(
LIFE_ACCOUNT_ID
,
lifeAccountId
.
toString
()),
Pair
(
LIFE_ACCOUNT_NAME
,
lifeAccountName
)
Pair
(
LIFE_ACCOUNT_ID
,
lifeAccountId
),
Pair
(
LIFE_ACCOUNT_NAME
,
lifeAccountName
)
)
)
...
...
@@ -95,14 +99,10 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
@SuppressLint
(
"SetTextI18n"
)
private
fun
setUserName
(
name
:
String
,
number
:
String
)
{
val
numberFormat
=
formatNumber
(
number
)
val
numberFormat
=
SensitiveInfoUtil
.
mobileEncrypt
(
number
)
viewBind
.
tvUserName
.
text
=
"$name $numberFormat"
}
private
fun
formatNumber
(
number
:
String
):
String
{
return
number
.
replace
(
"(\\d{3})\\d{4}(\\d{4})"
.
toRegex
(),
"$1****$2"
)
}
@Suppress
(
"DEPRECATION"
)
private
fun
checkAccount
(
s
:
String
)
{
if
(
s
.
isEmpty
())
{
...
...
@@ -112,7 +112,7 @@ class LifeAccountCreateActivity : BaseActivity<ActivityLifeAccountCreateBinding>
viewBind
.
vDivider
.
setBackgroundResource
(
R
.
color
.
divider_white
)
return
}
if
(
s
.
length
>
account
MaxLength
)
{
if
(
s
.
length
>
lifeAccountName
MaxLength
)
{
viewBind
.
btnCreateAccount
.
alpha
=
0.32f
viewBind
.
btnCreateAccount
.
isEnabled
=
false
viewBind
.
tvErrorTips
.
isVisible
=
true
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/ui/center/LifeAccountModifyNameActivity.kt
View file @
eaf22524
...
...
@@ -51,7 +51,7 @@ class LifeAccountModifyNameActivity : BaseActivity<ActivityLifeAccountModifyName
private
fun
initView
()
{
// 只允许输入中文并且最长20汉字
viewBind
.
evLifeAccountName
.
setInputFilters
(
InputFilterUtil
.
get
ChineseFilter
(),
InputFilter
.
LengthFilter
(
2
0
))
viewBind
.
evLifeAccountName
.
setInputFilters
(
InputFilterUtil
.
get
LifeAccountNameFilter
(),
InputFilter
.
LengthFilter
(
4
0
))
}
private
fun
initListener
()
{
...
...
Components/newscontent/src/main/java/com/yidian/shenghuoquan/newscontent/utils/InputFilterUtil.kt
View file @
eaf22524
...
...
@@ -11,24 +11,12 @@ import java.util.regex.Pattern
*/
object
InputFilterUtil
{
/**
* 只允许汉字输入
*/
fun
getChineseFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
}
}
/**
* 真实姓名过滤
* 汉字 + ·
*/
fun
getRealNameFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF|·]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
...
...
@@ -41,7 +29,7 @@ object InputFilterUtil {
* 数字 + X
*/
fun
getIDCardNumberFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9|X]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
...
...
@@ -54,7 +42,7 @@ object InputFilterUtil {
* 数字
*/
fun
getPhoneNumberFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
...
...
@@ -67,7 +55,7 @@ object InputFilterUtil {
* 汉字
*/
fun
getRegistrationNameFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
...
...
@@ -80,11 +68,23 @@ object InputFilterUtil {
* 数字 + 大写字母
*/
fun
getRegistrationCodeFilter
():
InputFilter
{
return
InputFilter
{
source
,
start
,
end
,
dest
,
dstart
,
dend
->
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[0-9A-Z]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
}
}
/**
* 生活号名称过滤
*/
fun
getLifeAccountNameFilter
():
InputFilter
{
return
InputFilter
{
source
,
_
,
_
,
_
,
_
,
_
->
val
pattern
=
Pattern
.
compile
(
"[\\u4E00-\\u9FFF]+"
)
val
matcher
=
pattern
.
matcher
(
source
.
toString
())
if
(!
matcher
.
matches
())
return
@InputFilter
""
return
@InputFilter
null
}
}
}
Components/newscontent/src/main/res/layout/activity_life_account_create.xml
View file @
eaf22524
...
...
@@ -61,7 +61,7 @@
android:background=
"@null"
android:gravity=
"center_vertical"
android:hint=
"@string/account_create_tips"
android:
maxLength=
"21
"
android:
singleLine=
"true
"
android:textColor=
"@color/gray_333"
android:textColorHint=
"@color/account_hint"
android:textCursorDrawable=
"@drawable/comment_dialog_cursor"
...
...
Components/newscontent/src/main/res/values/strings.xml
View file @
eaf22524
...
...
@@ -51,7 +51,7 @@
<string
name=
"create_account"
>
确认创建
</string>
<string
name=
"account_create_tips"
>
同企业下生活号名称不可复用
</string>
<string
name=
"account_create_desc"
>
生活号作为企业服务管理载体,请正确使用生活号权益,新申请生活号默认当前申请人作为默认管理员,申请成功 后可在销售APP内进行更改
</string>
<string
name=
"account_error_tips"
>
名称超限,最多
2
0个字符
</string>
<string
name=
"account_error_tips"
>
名称超限,最多
4
0个字符
</string>
<string
name=
"account_manager"
>
管理员
</string>
<string
name=
"account_name"
>
生活号名称
</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