Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
MiYaFastCashier
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
jiangjiantao
MiYaFastCashier
Commits
6cc0d15a
Commit
6cc0d15a
authored
Aug 05, 2022
by
赵鹏翔
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改渠道配置
parent
5b4ed42e
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
155 additions
and
169 deletions
+155
-169
build.gradle
app/build.gradle
+1
-5
LoginActivity.kt
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
+15
-9
ChannelManageKit.java
...va/com/miya/fastcashier/util/manage/ChannelManageKit.java
+0
-153
ChannelManageKit.kt
...java/com/miya/fastcashier/util/manage/ChannelManageKit.kt
+138
-0
gradle.properties
gradle.properties
+1
-1
build.gradle
lib_common/build.gradle
+0
-1
No files found.
app/build.gradle
View file @
6cc0d15a
...
@@ -55,7 +55,7 @@ android {
...
@@ -55,7 +55,7 @@ android {
variant
.
outputs
.
all
{
output
->
variant
.
outputs
.
all
{
output
->
outputFileName
=
new
File
(
output
.
outputFile
.
parent
,
outputFileName
=
new
File
(
output
.
outputFile
.
parent
,
"${getAppChannel()}"
+
"
_v"
+
"Miya_FastCashier
_v"
+
variant
.
versionName
+
"_"
+
variant
.
versionName
+
"_"
+
variant
.
versionCode
+
"_"
+
variant
.
versionCode
+
"_"
+
variant
.
buildType
.
name
+
"_"
+
variant
.
buildType
.
name
+
"_"
+
...
@@ -89,8 +89,4 @@ static String buildTime() {
...
@@ -89,8 +89,4 @@ static String buildTime() {
Date
date
=
new
Date
()
Date
date
=
new
Date
()
String
dates
=
date
.
format
(
"yyyyMMddHHmm"
,
TimeZone
.
getTimeZone
(
"Asia/Shanghai"
))
String
dates
=
date
.
format
(
"yyyyMMddHHmm"
,
TimeZone
.
getTimeZone
(
"Asia/Shanghai"
))
return
dates
return
dates
}
String
getAppChannel
()
{
return
project
.
CHANNEL
}
}
\ No newline at end of file
app/src/main/java/com/miya/fastcashier/ui/LoginActivity.kt
View file @
6cc0d15a
...
@@ -157,15 +157,21 @@ class LoginActivity : AppCompatActivity() {
...
@@ -157,15 +157,21 @@ class LoginActivity : AppCompatActivity() {
private
fun
login
()
{
private
fun
login
()
{
binding
.
vLoading
.
visibility
=
View
.
VISIBLE
binding
.
vLoading
.
visibility
=
View
.
VISIBLE
val
userName
=
binding
.
etUsername
.
text
.
toString
()
val
userName
=
binding
.
etUsername
.
text
.
toString
()
if
(
ChannelManageKit
.
containsAccount
(
this
,
userName
))
{
loginViewModel
.
login
(
loginViewModel
.
login
(
userName
,
userName
,
binding
.
etPassword
.
text
.
toString
()
binding
.
etPassword
.
text
.
toString
()
)
)
}
else
{
//暂不加账号过滤
binding
.
vLoading
.
visibility
=
View
.
GONE
// if (ChannelManageKit.containsAccount(this, userName)) {
CenterToasty
.
error
(
this
,
"账号有误,请检查后重试"
).
show
()
// loginViewModel.login(
}
// userName,
// binding.etPassword.text.toString()
// )
// } else {
// binding.vLoading.visibility = View.GONE
// CenterToasty.error(this, "账号有误,请检查后重试").show()
// }
}
}
/**
/**
...
...
app/src/main/java/com/miya/fastcashier/util/manage/ChannelManageKit.java
deleted
100644 → 0
View file @
5b4ed42e
package
com
.
miya
.
fastcashier
.
util
.
manage
;
import
android.content.Context
;
import
android.content.res.AssetManager
;
import
android.text.TextUtils
;
import
com.blankj.utilcode.util.GsonUtils
;
import
com.fastcashier.lib_common.function.account.AccountService
;
import
com.google.gson.reflect.TypeToken
;
import
com.miya.fastcashier.bean.ChannelInfoBean
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.util.ArrayList
;
import
java.util.HashMap
;
import
java.util.List
;
import
java.util.Map
;
/**
* 类说明:渠道管理类(用于处理品牌全局设置,以及换肤所需渠道配置)
* 详细描述:目前通过本地资源文件加载 todo 后期能改成接口返回渠道最好
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
public
class
ChannelManageKit
{
private
static
Map
<
String
,
ChannelInfoBean
>
channelMap
;
//key为账号,value为所属的品牌信息
private
static
final
String
CHANNEL_OFFICIAL_ACCOUNT
=
"-1"
;
private
static
final
String
CHANNEL_OFFICIAL_CHANNELNAME
=
"通用"
;
private
static
final
String
CHANNEL_OFFICIAL_CHANNELNAME_EN
=
"common"
;
/**
* 初始化本地渠道数据
*/
public
static
void
initChannelRes
(
Context
context
)
{
clearChannelResData
();
if
(
null
==
context
)
{
initDefaultChannelRes
();
return
;
}
String
assetsJson
=
getAssetsJson
(
context
,
"channel.json"
);
if
(
TextUtils
.
isEmpty
(
assetsJson
))
{
initDefaultChannelRes
();
return
;
}
ArrayList
<
ChannelInfoBean
>
channelInfoList
=
GsonUtils
.
fromJson
(
assetsJson
,
new
TypeToken
<
List
<
ChannelInfoBean
>>()
{
}.
getType
());
channelMap
=
new
HashMap
<>();
if
(!
channelInfoList
.
isEmpty
())
{
for
(
int
i
=
0
;
i
<
channelInfoList
.
size
();
i
++)
{
ChannelInfoBean
channelInfoBean
=
channelInfoList
.
get
(
i
);
List
<
String
>
channelAccountArray
=
channelInfoBean
.
getChannelAccountArray
();
if
(
channelAccountArray
.
isEmpty
())
{
initDefaultChannelRes
();
continue
;
}
for
(
int
j
=
0
;
j
<
channelAccountArray
.
size
();
j
++)
{
String
account
=
channelAccountArray
.
get
(
j
);
channelMap
.
put
(
account
,
channelInfoBean
);
}
}
}
}
private
static
void
initDefaultChannelRes
()
{
if
(
channelMap
==
null
){
channelMap
=
new
HashMap
<>();
}
ChannelInfoBean
commonChannel
=
new
ChannelInfoBean
();
commonChannel
.
setChannelId
(
"-1"
);
commonChannel
.
setChannelName
(
CHANNEL_OFFICIAL_CHANNELNAME
);
commonChannel
.
setChannelNameEn
(
CHANNEL_OFFICIAL_CHANNELNAME_EN
);
channelMap
.
put
(
CHANNEL_OFFICIAL_ACCOUNT
,
commonChannel
);
}
/**
* 判断本地是否包含本品牌账户,此处暂时用来处理区别大屏和手持账号
*/
public
static
boolean
containsAccount
(
Context
context
,
String
account
)
{
if
(
channelMap
==
null
||
channelMap
.
isEmpty
())
{
initChannelRes
(
context
);
}
return
channelMap
.
containsKey
(
account
);
}
/**
* 获取渠道名称
*/
public
static
String
getAppChannelName
(
Context
context
)
{
if
(
channelMap
==
null
||
channelMap
.
isEmpty
())
{
initChannelRes
(
context
);
}
boolean
containsKey
=
channelMap
.
containsKey
(
AccountService
.
INSTANCE
.
getUserName
());
if
(!
containsKey
)
{
return
CHANNEL_OFFICIAL_CHANNELNAME
;
}
return
channelMap
.
get
(
AccountService
.
INSTANCE
.
getUserName
()).
getChannelName
();
}
/**
* 获取App渠道编号
*/
public
static
String
getAppChannelId
(
Context
context
)
{
if
(
context
==
null
)
{
return
CHANNEL_OFFICIAL_ACCOUNT
;
}
if
(
channelMap
==
null
||
channelMap
.
isEmpty
())
{
initChannelRes
(
context
);
}
if
(!
channelMap
.
containsKey
(
AccountService
.
INSTANCE
.
getUserName
()))
{
return
CHANNEL_OFFICIAL_ACCOUNT
;
}
return
channelMap
.
get
(
AccountService
.
INSTANCE
.
getUserName
()).
getChannelId
();
}
public
static
void
clearChannelResData
()
{
if
(
null
==
channelMap
)
{
return
;
}
channelMap
.
clear
();
channelMap
=
null
;
}
/**
* 读取json文件
*/
private
static
String
getAssetsJson
(
Context
context
,
String
fileName
)
{
StringBuilder
stringBuilder
=
new
StringBuilder
();
AssetManager
assetManager
=
context
.
getAssets
();
try
{
BufferedReader
bf
=
new
BufferedReader
(
new
InputStreamReader
(
assetManager
.
open
(
fileName
),
"UTF-8"
));
String
line
;
while
((
line
=
bf
.
readLine
())
!=
null
)
{
stringBuilder
.
append
(
line
);
}
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
return
stringBuilder
.
toString
();
}
}
app/src/main/java/com/miya/fastcashier/util/manage/ChannelManageKit.kt
0 → 100644
View file @
6cc0d15a
package
com.miya.fastcashier.util.manage
import
android.content.Context
import
android.text.TextUtils
import
com.blankj.utilcode.util.GsonUtils
import
com.fastcashier.lib_common.function.account.AccountService.getUserName
import
com.google.gson.reflect.TypeToken
import
com.miya.fastcashier.bean.ChannelInfoBean
import
java.io.BufferedReader
import
java.io.IOException
import
java.io.InputStreamReader
import
java.util.*
import
kotlin.collections.HashMap
/**
* 类说明:渠道管理类(用于处理品牌全局设置,以及换肤所需渠道配置)
* 详细描述:目前通过本地资源文件加载 todo 后期能改成接口返回渠道最好
* 创建人:zpxiang
* 创建时间:
* 修改人:
* 修改时间:
*/
object
ChannelManageKit
{
private
var
channelMap
:
HashMap
<
String
,
ChannelInfoBean
>?
=
null
//key为账号,value为所属的品牌信息
private
const
val
CHANNEL_OFFICIAL_ACCOUNT
=
"-1"
private
const
val
CHANNEL_OFFICIAL_CHANNELNAME
=
"通用"
private
const
val
CHANNEL_OFFICIAL_CHANNELNAME_EN
=
"common"
/**
* 初始化本地渠道数据
*/
fun
initChannelRes
(
context
:
Context
?)
{
clearChannelResData
()
if
(
null
==
context
)
{
initDefaultChannelRes
()
return
}
val
assetsJson
=
getAssetsJson
(
context
,
"channel.json"
)
if
(
TextUtils
.
isEmpty
(
assetsJson
))
{
initDefaultChannelRes
()
return
}
val
channelInfoList
=
GsonUtils
.
fromJson
<
ArrayList
<
ChannelInfoBean
>>(
assetsJson
,
object
:
TypeToken
<
List
<
ChannelInfoBean
?>?>()
{}.
type
)
channelMap
=
HashMap
()
if
(!
channelInfoList
.
isEmpty
())
{
for
(
i
in
channelInfoList
.
indices
)
{
val
channelInfoBean
=
channelInfoList
[
i
]
val
channelAccountArray
=
channelInfoBean
.
channelAccountArray
if
(
channelAccountArray
.
isEmpty
())
{
initDefaultChannelRes
()
continue
}
for
(
j
in
channelAccountArray
.
indices
)
{
val
account
=
channelAccountArray
[
j
]
channelMap
!!
[
account
]
=
channelInfoBean
}
}
}
}
private
fun
initDefaultChannelRes
()
{
if
(
channelMap
==
null
)
{
channelMap
=
HashMap
()
}
val
commonChannel
=
ChannelInfoBean
()
commonChannel
.
channelId
=
"-1"
commonChannel
.
channelName
=
CHANNEL_OFFICIAL_CHANNELNAME
commonChannel
.
channelNameEn
=
CHANNEL_OFFICIAL_CHANNELNAME_EN
channelMap
!!
[
CHANNEL_OFFICIAL_ACCOUNT
]
=
commonChannel
}
/**
* 判断本地是否包含本品牌账户,此处暂时用来处理区别大屏和手持账号
*/
fun
containsAccount
(
context
:
Context
?,
account
:
String
):
Boolean
{
if
(
channelMap
==
null
||
channelMap
!!
.
isEmpty
())
{
initChannelRes
(
context
)
}
return
channelMap
!!
.
containsKey
(
account
)
}
/**
* 获取渠道名称
*/
fun
getAppChannelName
(
context
:
Context
?):
String
{
if
(
channelMap
==
null
||
channelMap
!!
.
isEmpty
())
{
initChannelRes
(
context
)
}
val
containsKey
=
channelMap
!!
.
containsKey
(
getUserName
())
return
if
(!
containsKey
)
{
CHANNEL_OFFICIAL_CHANNELNAME
}
else
channelMap
!!
[
getUserName
()]
!!
.
channelName
}
/**
* 获取App渠道编号
*/
fun
getAppChannelId
(
context
:
Context
?):
String
{
if
(
context
==
null
)
{
return
CHANNEL_OFFICIAL_ACCOUNT
}
if
(
channelMap
==
null
||
channelMap
!!
.
isEmpty
())
{
initChannelRes
(
context
)
}
return
if
(!
channelMap
!!
.
containsKey
(
getUserName
()))
{
CHANNEL_OFFICIAL_ACCOUNT
}
else
channelMap
!!
[
getUserName
()]
!!
.
channelId
}
fun
clearChannelResData
()
{
if
(
null
==
channelMap
)
{
return
}
channelMap
!!
.
clear
()
channelMap
=
null
}
/**
* 读取json文件
*/
private
fun
getAssetsJson
(
context
:
Context
,
fileName
:
String
):
String
{
val
stringBuilder
=
StringBuilder
()
val
assetManager
=
context
.
assets
try
{
val
bf
=
BufferedReader
(
InputStreamReader
(
assetManager
.
open
(
fileName
),
"UTF-8"
))
var
line
:
String
?
while
(
bf
.
readLine
().
also
{
line
=
it
}
!=
null
)
{
stringBuilder
.
append
(
line
)
}
}
catch
(
e
:
IOException
)
{
e
.
printStackTrace
()
}
return
stringBuilder
.
toString
()
}
}
\ No newline at end of file
gradle.properties
View file @
6cc0d15a
...
@@ -22,6 +22,6 @@ android.jetifier.blacklist=miya-print
...
@@ -22,6 +22,6 @@ android.jetifier.blacklist=miya-print
android.useDeprecatedNdk
=
true
android.useDeprecatedNdk
=
true
#区别品牌
#区别品牌
CHANNEL
=
converse
#
CHANNEL=converse
#区别环境 true:是测试环境,仅供内部人员测试使用;false:非测试包,供外部人员、渠道推广、应用商店等使用
#区别环境 true:是测试环境,仅供内部人员测试使用;false:非测试包,供外部人员、渠道推广、应用商店等使用
ISTEST
=
false
ISTEST
=
false
\ No newline at end of file
lib_common/build.gradle
View file @
6cc0d15a
...
@@ -14,7 +14,6 @@ android {
...
@@ -14,7 +14,6 @@ android {
multiDexEnabled
true
multiDexEnabled
true
consumerProguardFiles
"consumer-rules.pro"
consumerProguardFiles
"consumer-rules.pro"
buildConfigField
'String'
,
"CHANNEL"
,
"\"$CHANNEL\""
buildConfigField
"Boolean"
,
"ISTEST"
,
ISTEST
.
toString
()
buildConfigField
"Boolean"
,
"ISTEST"
,
ISTEST
.
toString
()
buildConfigField
"String"
,
"appType"
,
"\"mpos\""
buildConfigField
"String"
,
"appType"
,
"\"mpos\""
}
}
...
...
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