|
@@ -0,0 +1,61 @@
|
|
|
+package com.kdanmobile.kdanloginregisterui
|
|
|
+
|
|
|
+import com.kdanmobile.kdanloginregisterui.Utils.toSpannable
|
|
|
+
|
|
|
+import android.support.constraint.ConstraintLayout
|
|
|
+import android.content.Context
|
|
|
+import android.text.method.LinkMovementMethod
|
|
|
+import android.util.AttributeSet
|
|
|
+import android.view.View
|
|
|
+import android.widget.TextView
|
|
|
+
|
|
|
+open abstract class BaseRegisterView @JvmOverloads constructor(
|
|
|
+ context: Context,
|
|
|
+ attrs: AttributeSet? = null,
|
|
|
+ defStyleAttr: Int = 0) : ConstraintLayout(context, attrs, defStyleAttr) {
|
|
|
+
|
|
|
+ abstract val name: String
|
|
|
+ abstract val email: String
|
|
|
+ abstract val pwd: String
|
|
|
+
|
|
|
+ lateinit var onClickEmailRegister: Runnable
|
|
|
+ lateinit var onClickFbRegister: Runnable
|
|
|
+ lateinit var onClickGoogleRegister: Runnable
|
|
|
+ lateinit var onClickTurnOfService: Runnable
|
|
|
+ lateinit var onClickPrivacyPolicy: Runnable
|
|
|
+ lateinit var onClickSwitchToLogin: Runnable
|
|
|
+ lateinit var onClickClose: Runnable
|
|
|
+
|
|
|
+ protected fun setupSwitchTextView(textView: TextView) {
|
|
|
+ val s = textView.text
|
|
|
+ val textColor = resources.getColor(R.color.switch_text)
|
|
|
+ val ss = s.toSpannable(textColor, true, View.OnClickListener { onClickSwitchToLogin.run() })
|
|
|
+ textView.apply {
|
|
|
+ movementMethod = LinkMovementMethod.getInstance()
|
|
|
+ text = ss
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ protected fun setupTosAndPpTextView(textView: TextView) {
|
|
|
+ try {
|
|
|
+ val key = "[d*_*b]"
|
|
|
+ val tos = context.getString(R.string.terms_of_service)
|
|
|
+ val pp = context.getString(R.string.privacy_policy)
|
|
|
+ val pattern = context.getString(R.string.register_tos_and_pp_pattern, key, key)
|
|
|
+ val stringArray = pattern.split(key)
|
|
|
+ val textColor = resources.getColor(R.color.tos_pp_text)
|
|
|
+ val tosSS = tos.toSpannable(textColor, false, View.OnClickListener { onClickTurnOfService.run() })
|
|
|
+ val ppSS = pp.toSpannable(textColor, false, View.OnClickListener { onClickPrivacyPolicy.run() })
|
|
|
+ textView.apply {
|
|
|
+ movementMethod = LinkMovementMethod.getInstance()
|
|
|
+ append(stringArray[0])
|
|
|
+ append(tosSS)
|
|
|
+ append(stringArray[1])
|
|
|
+ append(ppSS)
|
|
|
+ append(stringArray[2])
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ // do nothing, let it go ~
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|