Commit f7ccfa3d by YKai

feat:一键登录UI优化,代码优化

parent baf269ab
...@@ -41,6 +41,23 @@ android { ...@@ -41,6 +41,23 @@ android {
} }
} }
//配置签名文件
signingConfigs {
ydl {
storeFile file("keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
xlzx {
storeFile file("keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
}
compileOptions { compileOptions {
sourceCompatibility = '1.8' sourceCompatibility = '1.8'
targetCompatibility = '1.8' targetCompatibility = '1.8'
...@@ -54,6 +71,10 @@ android { ...@@ -54,6 +71,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
} }
debug {
signingConfig signingConfigs.ydl
}
// debug { // debug {
// versionNameSuffix "-debug" // versionNameSuffix "-debug"
// signingConfig null // signingConfig null
...@@ -63,23 +84,6 @@ android { ...@@ -63,23 +84,6 @@ android {
buildToolsVersion = '28.0.3' buildToolsVersion = '28.0.3'
//配置签名文件
signingConfigs {
ydl {
storeFile file("keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
xlzx {
storeFile file("keystore.jks")
storePassword "123456"
keyAlias "ydl"
keyPassword "123456"
}
}
dexOptions { dexOptions {
//使用增量模式构建 //使用增量模式构建
// incremental true//最大堆内存 // incremental true//最大堆内存
......
...@@ -96,7 +96,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -96,7 +96,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
if (!it.isGetTokenSuccess){ if (!it.isGetTokenSuccess){
it.setAuthListener() it.setAuthListener()
} }
oneKeyLoginHelp?.getLoginToken(true) oneKeyLoginHelp?.getLoginToken(false)
} }
} }
...@@ -200,7 +200,13 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>( ...@@ -200,7 +200,13 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
FragmentContainerActivity.start(this, "YdlHomeFragment") FragmentContainerActivity.start(this, "YdlHomeFragment")
} }
bt_to_mine.setOnClickListener { bt_to_mine.setOnClickListener {
FragmentContainerActivity.start(this, "MineFragment") // FragmentContainerActivity.start(this, "MineFragment")
oneKeyLoginHelp?.let {
if (!it.isGetTokenSuccess){
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(true)
}
} }
bt_to_privacy.setOnClickListener { bt_to_privacy.setOnClickListener {
......
...@@ -27,7 +27,8 @@ import com.yidianling.common.tools.RxImageTool ...@@ -27,7 +27,8 @@ import com.yidianling.common.tools.RxImageTool
class OneKeyLoginHelp { class OneKeyLoginHelp {
private var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null private var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null
private var mActivity: BaseActivity? = null private var mActivity: BaseActivity? = null
public var isGetTokenSuccess = true var isGetTokenSuccess = true
private var mAuthType: Int = 1
companion object { companion object {
private const val YDL_USER_APP_KEY = private const val YDL_USER_APP_KEY =
...@@ -49,6 +50,7 @@ class OneKeyLoginHelp { ...@@ -49,6 +50,7 @@ class OneKeyLoginHelp {
*/ */
constructor(activity: BaseActivity, authType: Int, loginType: Int) { constructor(activity: BaseActivity, authType: Int, loginType: Int) {
mActivity = activity mActivity = activity
mAuthType = authType
mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener) mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener)
mPhoneNumberAuthHelper?.let { mPhoneNumberAuthHelper?.let {
// APP是否处于调试状态,使⽤ getReporter.setLoggerEnable(true) 可以关闭此项检测 // APP是否处于调试状态,使⽤ getReporter.setLoggerEnable(true) 可以关闭此项检测
...@@ -68,7 +70,7 @@ class OneKeyLoginHelp { ...@@ -68,7 +70,7 @@ class OneKeyLoginHelp {
* 设置token监听 * 设置token监听
* *
*/ */
fun setAuthListener(){ fun setAuthListener() {
mPhoneNumberAuthHelper?.setAuthListener(mTokenListener) mPhoneNumberAuthHelper?.setAuthListener(mTokenListener)
} }
...@@ -110,32 +112,14 @@ class OneKeyLoginHelp { ...@@ -110,32 +112,14 @@ class OneKeyLoginHelp {
phoneNumberAuthHelper.removeAuthRegisterXmlConfig() phoneNumberAuthHelper.removeAuthRegisterXmlConfig()
phoneNumberAuthHelper.removeAuthRegisterViewConfig() phoneNumberAuthHelper.removeAuthRegisterViewConfig()
//自定义验证码登录按钮
val otherLogin = TextView(mActivity)
val layoutParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RxImageTool.dp2px(50f)
)
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE)
layoutParams.setMargins(
RxImageTool.dp2px(35f),
RxImageTool.dp2px(33f),
RxImageTool.dp2px(35f),
0
)
otherLogin.text = "切换号码"
otherLogin.setTextColor(Color.parseColor("#1DA1F2"))
otherLogin.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
otherLogin.gravity = Gravity.CENTER
otherLogin.layoutParams = layoutParams
//自定义认证商显示控件 //自定义认证商显示控件
val tvAuth = TextView(mActivity) val tvAuth = TextView(mActivity)
val tvAuthParams = RelativeLayout.LayoutParams( val tvAuthParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT,
RxImageTool.dp2px(50f) RelativeLayout.LayoutParams.WRAP_CONTENT
) )
tvAuthParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE) tvAuthParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE)
tvAuthParams.setMargins(0, RxImageTool.dp2px(215f), 0, 0) tvAuthParams.setMargins(0, RxImageTool.dp2px(250f), 0, 0)
when (phoneNumberAuthHelper.currentCarrierName) { when (phoneNumberAuthHelper.currentCarrierName) {
"CUCC" -> { "CUCC" -> {
tvAuth.text = "中国联通提供认证服务" tvAuth.text = "中国联通提供认证服务"
...@@ -151,7 +135,6 @@ class OneKeyLoginHelp { ...@@ -151,7 +135,6 @@ class OneKeyLoginHelp {
tvAuth.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f) tvAuth.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
tvAuth.gravity = Gravity.CENTER tvAuth.gravity = Gravity.CENTER
tvAuth.layoutParams = tvAuthParams tvAuth.layoutParams = tvAuthParams
//一键登录添加自定义控件 //一键登录添加自定义控件
phoneNumberAuthHelper.addAuthRegistViewConfig( phoneNumberAuthHelper.addAuthRegistViewConfig(
"tv_auth", AuthRegisterViewConfig.Builder() "tv_auth", AuthRegisterViewConfig.Builder()
...@@ -160,15 +143,42 @@ class OneKeyLoginHelp { ...@@ -160,15 +143,42 @@ class OneKeyLoginHelp {
.build() .build()
) )
//自定义验证码登录按钮
val otherLogin = TextView(mActivity)
val layoutParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RxImageTool.dp2px(50f)
)
layoutParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, RelativeLayout.TRUE)
layoutParams.setMargins(
RxImageTool.dp2px(40f),
0,
RxImageTool.dp2px(40f),
RxImageTool.dp2px(68f)
)
otherLogin.text = "其他方式登录"
otherLogin.setTextColor(Color.parseColor("#666666"))
otherLogin.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
otherLogin.gravity = Gravity.CENTER
otherLogin.layoutParams = layoutParams
phoneNumberAuthHelper.addAuthRegistViewConfig( phoneNumberAuthHelper.addAuthRegistViewConfig(
"other_login", AuthRegisterViewConfig.Builder() "other_login", AuthRegisterViewConfig.Builder()
.setView(otherLogin) .setView(otherLogin)
.setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY) .setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY)
.setCustomInterface { .setCustomInterface {
phoneNumberAuthHelper.quitLoginPage() phoneNumberAuthHelper.quitLoginPage()
toLoginActivity()
} }
.build() .build()
) )
var loginLogo = "ic_ydl_login_logo"
var loginHeight = 40
var loginWidth = 118
if (mAuthType == YDL_EXPERT_APP) {
loginLogo = "ic_expert_login_logo"
loginHeight = 60
loginWidth = 60
}
phoneNumberAuthHelper.setAuthUIConfig( phoneNumberAuthHelper.setAuthUIConfig(
AuthUIConfig.Builder() AuthUIConfig.Builder()
.setStatusBarColor(Color.TRANSPARENT) .setStatusBarColor(Color.TRANSPARENT)
...@@ -179,20 +189,23 @@ class OneKeyLoginHelp { ...@@ -179,20 +189,23 @@ class OneKeyLoginHelp {
.setWebNavColor(Color.WHITE) .setWebNavColor(Color.WHITE)
.setLightColor(true) //设置状态栏文字颜色,true为黑色 .setLightColor(true) //设置状态栏文字颜色,true为黑色
.setWebNavReturnImgPath("common_ic_back") // 设置协议页返回按钮 .setWebNavReturnImgPath("common_ic_back") // 设置协议页返回按钮
.setLogoImgPath("ic_one_key_login_logo") // 设置登录logo .setLogoImgPath(loginLogo) // 设置登录logo
.setLogoScaleType(ImageView.ScaleType.FIT_CENTER) .setLogoScaleType(ImageView.ScaleType.FIT_CENTER)
.setLogoHeight(118) // 设置登录logo高度 .setLogoHeight(loginHeight) // 设置登录logo高度
.setLogoWidth(40) // 设置登录logo宽度 .setLogoWidth(loginWidth) // 设置登录logo宽度
.setLogoOffsetY(35) // 设置登录logo距离顶部距离 .setLogoOffsetY(35) // 设置登录logo距离顶部距离
.setSloganHidden(true) // 设置slogan是否隐藏 .setSloganHidden(true) // 设置slogan是否隐藏
.setNumberColor(Color.parseColor("#242424")) .setNumberColor(Color.parseColor("#242424"))
.setNumberSize(24) .setNumberSize(24)
.setNumFieldOffsetY(190) .setNumFieldOffsetY(215)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片 .setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮文字颜色 .setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮文字颜色
.setLogBtnTextSize(15) .setLogBtnTextSize(15)
.setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离 .setLogBtnMarginLeftAndRight(40) // 设置登录按钮距离左右距离
.setSwitchAccHidden(true) // 设置自带切换其它登录方式按钮隐藏 .setLogBtnHeight(78)
.setSwitchAccText("切换号码")
.setSwitchAccTextSize(15)
.setSwitchAccTextColor(Color.parseColor("#1DA1F2"))
.setAppPrivacyOne("壹点灵专家使用协议", "") .setAppPrivacyOne("壹点灵专家使用协议", "")
.setAppPrivacyTwo("隐私协议", "") .setAppPrivacyTwo("隐私协议", "")
.setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2")) .setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2"))
...@@ -201,6 +214,8 @@ class OneKeyLoginHelp { ...@@ -201,6 +214,8 @@ class OneKeyLoginHelp {
// .setVendorPrivacyPrefix("《") // .setVendorPrivacyPrefix("《")
// .setVendorPrivacySuffix("》") // .setVendorPrivacySuffix("》")
.setScreenOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) // 设置竖屏 .setScreenOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) // 设置竖屏
.setAuthPageActIn("in_activity", "out_activity")
.setAuthPageActOut("in_activity", "out_activity")
.create() .create()
) )
} }
...@@ -214,35 +229,7 @@ class OneKeyLoginHelp { ...@@ -214,35 +229,7 @@ class OneKeyLoginHelp {
phoneNumberAuthHelper.removeAuthRegisterXmlConfig() phoneNumberAuthHelper.removeAuthRegisterXmlConfig()
phoneNumberAuthHelper.removeAuthRegisterViewConfig() phoneNumberAuthHelper.removeAuthRegisterViewConfig()
//自定义其它方式登录按钮 val dialogHeight = RxImageTool.px2dp((RxDeviceTool.getScreenHeight(mActivity) * 0.45f))
val otherLogin = TextView(mActivity)
val layoutParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.MATCH_PARENT,
RxImageTool.dp2px(50f)
)
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL, RelativeLayout.TRUE)
layoutParams.setMargins(
RxImageTool.dp2px(35f),
RxImageTool.dp2px(33f),
RxImageTool.dp2px(35f),
0
)
otherLogin.text = "其它方式登录"
otherLogin.setTextColor(Color.parseColor("#666666"))
otherLogin.setTextSize(TypedValue.COMPLEX_UNIT_SP, 15f)
otherLogin.gravity = Gravity.CENTER
otherLogin.layoutParams = layoutParams
phoneNumberAuthHelper.addAuthRegistViewConfig(
"other_login", AuthRegisterViewConfig.Builder()
.setView(otherLogin)
.setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY)
.setCustomInterface {
phoneNumberAuthHelper.quitLoginPage()
}
.build()
)
val dialogHeight = (RxDeviceTool.getScreenHeight(mActivity) * 0.45f).toInt()
phoneNumberAuthHelper.setAuthUIConfig( phoneNumberAuthHelper.setAuthUIConfig(
AuthUIConfig.Builder() AuthUIConfig.Builder()
.setStatusBarColor(Color.TRANSPARENT) .setStatusBarColor(Color.TRANSPARENT)
...@@ -258,12 +245,17 @@ class OneKeyLoginHelp { ...@@ -258,12 +245,17 @@ class OneKeyLoginHelp {
.setSloganHidden(true) // 设置slogan是否隐藏 .setSloganHidden(true) // 设置slogan是否隐藏
.setNumberColor(Color.parseColor("#242424")) .setNumberColor(Color.parseColor("#242424"))
.setNumberSize(24) .setNumberSize(24)
.setNumFieldOffsetY(190) .setNumFieldOffsetY(60)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片 .setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮颜色 .setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮颜色
.setLogBtnTextSize(16) .setLogBtnTextSize(16)
.setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离 .setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离
.setSwitchAccHidden(true) // 设置自带切换其它登录方式按钮隐藏 .setLogBtnHeight(78)
.setLogBtnOffsetY(90)
.setSwitchAccText("其它方式登录")
.setSwitchAccTextSize(15)
.setSwitchAccTextColor(Color.parseColor("#666666"))
.setSwitchOffsetY(168)
.setAppPrivacyOne("壹点灵专家使用协议", "") .setAppPrivacyOne("壹点灵专家使用协议", "")
.setAppPrivacyTwo("隐私协议", "") .setAppPrivacyTwo("隐私协议", "")
.setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2")) .setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2"))
...@@ -296,7 +288,7 @@ class OneKeyLoginHelp { ...@@ -296,7 +288,7 @@ class OneKeyLoginHelp {
override fun onTokenFailed(s: String) { override fun onTokenFailed(s: String) {
LogUtil.e(s) LogUtil.e(s)
isGetTokenSuccess=false isGetTokenSuccess = false
val tokenRet = TokenRet.fromJson(s) val tokenRet = TokenRet.fromJson(s)
when (tokenRet.code) { when (tokenRet.code) {
ResultCode.CODE_ERROR_USER_CANCEL -> { // 用户主动取消一键登录 ResultCode.CODE_ERROR_USER_CANCEL -> { // 用户主动取消一键登录
......
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ResourceName">
<alpha
android:duration="0"
/>
</set>
<?xml version="1.0" encoding="utf-8"?>
<set xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="ResourceName">
<alpha
android:duration="0"
/>
</set>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment