Commit f7ccfa3d by YKai

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

parent baf269ab
......@@ -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 {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
......@@ -54,6 +71,10 @@ android {
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
signingConfig signingConfigs.ydl
}
// debug {
// versionNameSuffix "-debug"
// signingConfig null
......@@ -63,23 +84,6 @@ android {
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 {
//使用增量模式构建
// incremental true//最大堆内存
......
......@@ -96,7 +96,7 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
if (!it.isGetTokenSuccess){
it.setAuthListener()
}
oneKeyLoginHelp?.getLoginToken(true)
oneKeyLoginHelp?.getLoginToken(false)
}
}
......@@ -200,7 +200,13 @@ class MainActivity : BaseLceActivity<DemoContract.View, DemoContract.Presenter>(
FragmentContainerActivity.start(this, "YdlHomeFragment")
}
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 {
......
......@@ -27,7 +27,8 @@ import com.yidianling.common.tools.RxImageTool
class OneKeyLoginHelp {
private var mPhoneNumberAuthHelper: PhoneNumberAuthHelper? = null
private var mActivity: BaseActivity? = null
public var isGetTokenSuccess = true
var isGetTokenSuccess = true
private var mAuthType: Int = 1
companion object {
private const val YDL_USER_APP_KEY =
......@@ -49,6 +50,7 @@ class OneKeyLoginHelp {
*/
constructor(activity: BaseActivity, authType: Int, loginType: Int) {
mActivity = activity
mAuthType = authType
mPhoneNumberAuthHelper = PhoneNumberAuthHelper.getInstance(activity, mTokenListener)
mPhoneNumberAuthHelper?.let {
// APP是否处于调试状态,使⽤ getReporter.setLoggerEnable(true) 可以关闭此项检测
......@@ -68,7 +70,7 @@ class OneKeyLoginHelp {
* 设置token监听
*
*/
fun setAuthListener(){
fun setAuthListener() {
mPhoneNumberAuthHelper?.setAuthListener(mTokenListener)
}
......@@ -110,32 +112,14 @@ class OneKeyLoginHelp {
phoneNumberAuthHelper.removeAuthRegisterXmlConfig()
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 tvAuthParams = RelativeLayout.LayoutParams(
RelativeLayout.LayoutParams.WRAP_CONTENT,
RxImageTool.dp2px(50f)
RelativeLayout.LayoutParams.WRAP_CONTENT
)
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) {
"CUCC" -> {
tvAuth.text = "中国联通提供认证服务"
......@@ -151,7 +135,6 @@ class OneKeyLoginHelp {
tvAuth.setTextSize(TypedValue.COMPLEX_UNIT_SP, 13f)
tvAuth.gravity = Gravity.CENTER
tvAuth.layoutParams = tvAuthParams
//一键登录添加自定义控件
phoneNumberAuthHelper.addAuthRegistViewConfig(
"tv_auth", AuthRegisterViewConfig.Builder()
......@@ -160,15 +143,42 @@ class OneKeyLoginHelp {
.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(
"other_login", AuthRegisterViewConfig.Builder()
.setView(otherLogin)
.setRootViewId(AuthRegisterViewConfig.RootViewId.ROOT_VIEW_ID_BODY)
.setCustomInterface {
phoneNumberAuthHelper.quitLoginPage()
toLoginActivity()
}
.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(
AuthUIConfig.Builder()
.setStatusBarColor(Color.TRANSPARENT)
......@@ -179,20 +189,23 @@ class OneKeyLoginHelp {
.setWebNavColor(Color.WHITE)
.setLightColor(true) //设置状态栏文字颜色,true为黑色
.setWebNavReturnImgPath("common_ic_back") // 设置协议页返回按钮
.setLogoImgPath("ic_one_key_login_logo") // 设置登录logo
.setLogoImgPath(loginLogo) // 设置登录logo
.setLogoScaleType(ImageView.ScaleType.FIT_CENTER)
.setLogoHeight(118) // 设置登录logo高度
.setLogoWidth(40) // 设置登录logo宽度
.setLogoHeight(loginHeight) // 设置登录logo高度
.setLogoWidth(loginWidth) // 设置登录logo宽度
.setLogoOffsetY(35) // 设置登录logo距离顶部距离
.setSloganHidden(true) // 设置slogan是否隐藏
.setNumberColor(Color.parseColor("#242424"))
.setNumberSize(24)
.setNumFieldOffsetY(190)
.setNumFieldOffsetY(215)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮文字颜色
.setLogBtnTextSize(15)
.setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离
.setSwitchAccHidden(true) // 设置自带切换其它登录方式按钮隐藏
.setLogBtnMarginLeftAndRight(40) // 设置登录按钮距离左右距离
.setLogBtnHeight(78)
.setSwitchAccText("切换号码")
.setSwitchAccTextSize(15)
.setSwitchAccTextColor(Color.parseColor("#1DA1F2"))
.setAppPrivacyOne("壹点灵专家使用协议", "")
.setAppPrivacyTwo("隐私协议", "")
.setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2"))
......@@ -201,6 +214,8 @@ class OneKeyLoginHelp {
// .setVendorPrivacyPrefix("《")
// .setVendorPrivacySuffix("》")
.setScreenOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT) // 设置竖屏
.setAuthPageActIn("in_activity", "out_activity")
.setAuthPageActOut("in_activity", "out_activity")
.create()
)
}
......@@ -214,35 +229,7 @@ class OneKeyLoginHelp {
phoneNumberAuthHelper.removeAuthRegisterXmlConfig()
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("#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()
val dialogHeight = RxImageTool.px2dp((RxDeviceTool.getScreenHeight(mActivity) * 0.45f))
phoneNumberAuthHelper.setAuthUIConfig(
AuthUIConfig.Builder()
.setStatusBarColor(Color.TRANSPARENT)
......@@ -258,12 +245,17 @@ class OneKeyLoginHelp {
.setSloganHidden(true) // 设置slogan是否隐藏
.setNumberColor(Color.parseColor("#242424"))
.setNumberSize(24)
.setNumFieldOffsetY(190)
.setNumFieldOffsetY(60)
.setLogBtnBackgroundPath("bg_one_click_login") // 设置登录按钮背景图片
.setLogBtnTextColor(Color.parseColor("#ffffff")) // 设置登录按钮颜色
.setLogBtnTextSize(16)
.setLogBtnMarginLeftAndRight(35) // 设置登录按钮距离左右距离
.setSwitchAccHidden(true) // 设置自带切换其它登录方式按钮隐藏
.setLogBtnHeight(78)
.setLogBtnOffsetY(90)
.setSwitchAccText("其它方式登录")
.setSwitchAccTextSize(15)
.setSwitchAccTextColor(Color.parseColor("#666666"))
.setSwitchOffsetY(168)
.setAppPrivacyOne("壹点灵专家使用协议", "")
.setAppPrivacyTwo("隐私协议", "")
.setAppPrivacyColor(Color.parseColor("#999999"), Color.parseColor("#1da1f2"))
......@@ -296,7 +288,7 @@ class OneKeyLoginHelp {
override fun onTokenFailed(s: String) {
LogUtil.e(s)
isGetTokenSuccess=false
isGetTokenSuccess = false
val tokenRet = TokenRet.fromJson(s)
when (tokenRet.code) {
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