Commit aafd69a6 authored by jyx's avatar jyx

添加登录勾选按钮

parent dc9e1cd2
package com.mints.flowbox.ui.activitys package com.mints.flowbox.ui.activitys
import android.Manifest import android.Manifest
import android.os.Bundle
import android.text.TextPaint
import android.text.TextUtils import android.text.TextUtils
import android.text.style.ClickableSpan
import android.view.View import android.view.View
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.hjq.toast.ToastUtils
import com.tbruyelle.rxpermissions.RxPermissions import com.tbruyelle.rxpermissions.RxPermissions
import com.mints.library.utils.nodoubleclick.AntiShake import com.mints.library.utils.nodoubleclick.AntiShake
import com.mints.flowbox.R import com.mints.flowbox.R
import com.mints.flowbox.common.Constant
import com.mints.flowbox.manager.TrackManager import com.mints.flowbox.manager.TrackManager
import com.mints.flowbox.manager.UserManager import com.mints.flowbox.manager.UserManager
import com.mints.flowbox.mvp.presenters.LoginPresenter import com.mints.flowbox.mvp.presenters.LoginPresenter
...@@ -13,7 +20,15 @@ import com.mints.flowbox.mvp.views.LoginView ...@@ -13,7 +20,15 @@ import com.mints.flowbox.mvp.views.LoginView
import com.mints.flowbox.ui.activitys.base.BaseActivity import com.mints.flowbox.ui.activitys.base.BaseActivity
import com.mints.flowbox.utils.BackInputUtil import com.mints.flowbox.utils.BackInputUtil
import com.mints.flowbox.utils.LogUtil import com.mints.flowbox.utils.LogUtil
import com.mints.flowbox.utils.SpanUtils
import kotlinx.android.synthetic.main.activity_bind_mobile.* import kotlinx.android.synthetic.main.activity_bind_mobile.*
import kotlinx.android.synthetic.main.activity_bind_mobile.etLoginCode
import kotlinx.android.synthetic.main.activity_bind_mobile.etLoginMobile
import kotlinx.android.synthetic.main.activity_bind_mobile.tvLoginNext
import kotlinx.android.synthetic.main.activity_bind_mobile.tvLoginSendcode
import kotlinx.android.synthetic.main.activity_mobile_login.*
import kotlinx.android.synthetic.main.activity_mobile_login.tvLoginAgreement
import kotlinx.android.synthetic.main.activity_wx_login.*
import kotlinx.android.synthetic.main.header_layout.* import kotlinx.android.synthetic.main.header_layout.*
/** /**
...@@ -61,6 +76,12 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener { ...@@ -61,6 +76,12 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener {
loginPresenter.sendMobileCode(mobile) loginPresenter.sendMobileCode(mobile)
} }
R.id.tvLoginNext -> { R.id.tvLoginNext -> {
if (!tvLoginAgreement.isChecked) {
ToastUtils.show("请勾选同意《用户注册协议》及《用户隐私协议》")
YoYo.with(Techniques.Shake).duration(1000).repeat(1).playOn(tvLoginAgreement)
return
}
var mobile = etLoginMobile.text.toString().trim() var mobile = etLoginMobile.text.toString().trim()
if (mobile.length < 13) { if (mobile.length < 13) {
showToast("请输入手机号") showToast("请输入手机号")
...@@ -75,17 +96,17 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener { ...@@ -75,17 +96,17 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener {
RxPermissions(this@MobileLoginActivity) RxPermissions(this@MobileLoginActivity)
.request(Manifest.permission.READ_PHONE_STATE) .request(Manifest.permission.READ_PHONE_STATE)
.subscribe { granted: Boolean -> .subscribe { granted: Boolean ->
if (granted) { if (granted) {
mobile = mobile.replace(" ".toRegex(), "") mobile = mobile.replace(" ".toRegex(), "")
// 登录 // 登录
loginPresenter.login(mobile, code) loginPresenter.login(mobile, code)
} else { } else {
showMissingPermissionDialog("设备") showMissingPermissionDialog("设备")
}
} }
}
} }
} }
} }
...@@ -131,6 +152,37 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener { ...@@ -131,6 +152,37 @@ class MobileLoginActivity : BaseActivity(), LoginView, View.OnClickListener {
etLoginMobile.setText(mobile) etLoginMobile.setText(mobile)
etLoginMobile.setSelection(mobile!!.length + 2) etLoginMobile.setSelection(mobile!!.length + 2)
} }
SpanUtils.with(tvLoginAgreement)
.append("《用户注册协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.register_name))
bundle.putString(WebActivity.WEB_URL, Constant.REGISTER_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = resources.getColor(R.color.color_main)
ds.isUnderlineText = false
}
})
.append("、")
.append("《用户隐私协议》").setClickSpan(object : ClickableSpan() {
override fun onClick(widget: View) {
val bundle = Bundle()
bundle.putString(WebActivity.WEB_TITLE, getString(R.string.privacy_name))
bundle.putString(WebActivity.WEB_URL, Constant.PRIVACY_URL)
readyGo(WebActivity::class.java, bundle)
}
override fun updateDrawState(ds: TextPaint) {
ds.color = resources.getColor(R.color.color_main)
ds.isUnderlineText = false
}
})
.append("与您的利益切身相关。请您注册前务必仔细阅读!")
.create()
} }
private fun initListener() { private fun initListener() {
......
...@@ -9,6 +9,9 @@ import android.view.KeyEvent ...@@ -9,6 +9,9 @@ import android.view.KeyEvent
import android.view.View import android.view.View
import cn.sharesdk.framework.ShareSDK import cn.sharesdk.framework.ShareSDK
import cn.sharesdk.wechat.friends.Wechat import cn.sharesdk.wechat.friends.Wechat
import com.daimajia.androidanimations.library.Techniques
import com.daimajia.androidanimations.library.YoYo
import com.hjq.toast.ToastUtils
import com.tbruyelle.rxpermissions.RxPermissions import com.tbruyelle.rxpermissions.RxPermissions
import com.mints.library.utils.CommonUtils import com.mints.library.utils.CommonUtils
import com.mints.library.utils.json.JsonUtil import com.mints.library.utils.json.JsonUtil
...@@ -90,6 +93,12 @@ class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLogin ...@@ -90,6 +93,12 @@ class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLogin
readyGo(MobileLoginActivity::class.java) readyGo(MobileLoginActivity::class.java)
} }
R.id.rlLoginWx -> { R.id.rlLoginWx -> {
if (!tvLoginAgreement.isChecked) {
ToastUtils.show("请勾选同意《用户注册协议》及《用户隐私协议》")
YoYo.with(Techniques.Shake).duration(1000).repeat(1).playOn(tvLoginAgreement)
return
}
val wechat = ShareSDK.getPlatform(Wechat.NAME) val wechat = ShareSDK.getPlatform(Wechat.NAME)
if (!wechat.isClientValid) { if (!wechat.isClientValid) {
showToast("请先安装微信") showToast("请先安装微信")
...@@ -191,7 +200,7 @@ class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLogin ...@@ -191,7 +200,7 @@ class WxLoginActivity : BaseActivity(), LoginView, View.OnClickListener, OnLogin
ds.isUnderlineText = false ds.isUnderlineText = false
} }
}) })
.append("与您的利益切身相关。请您注册前务必仔细阅读!点击登录即表示您同意并愿意遵守协议") .append("与您的利益切身相关。请您注册前务必仔细阅读!")
.create() .create()
} }
......
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:gravity="center" android:gravity="center"
android:text="发送验证码" android:text="发送验证码"
android:textColor="@color/color_FF9837" android:textColor="@color/color_main"
android:textSize="12sp" /> android:textSize="12sp" />
</RelativeLayout> </RelativeLayout>
...@@ -115,6 +115,17 @@ ...@@ -115,6 +115,17 @@
android:textColor="@color/white" android:textColor="@color/white"
android:textSize="14sp" /> android:textSize="14sp" />
<CheckBox
android:id="@+id/tvLoginAgreement"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginLeft="20dp"
android:layout_marginTop="20dp"
android:layout_marginRight="20dp"
android:textColor="@color/color_707A8D"
android:textSize="12sp" />
<TextView <TextView
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -67,7 +67,7 @@ ...@@ -67,7 +67,7 @@
android:textColor="@color/gray" android:textColor="@color/gray"
android:textSize="14sp" /> android:textSize="14sp" />
<TextView <CheckBox
android:id="@+id/tvLoginAgreement" android:id="@+id/tvLoginAgreement"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
<style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar"> <style name="AppTheme.Base" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item> <item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item> <item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/color_main</item>
<item name="colorAccent">@color/color_main</item>
</style> </style>
<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" /> <style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.Dark.ActionBar" />
......
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