From 0bf664ffa4b0dd7f950d46da331a6b92ecf42ff3 Mon Sep 17 00:00:00 2001 From: miladsi90 Date: Sun, 28 Jul 2019 15:34:15 +0430 Subject: [PATCH] Add dimention , closed #23 , change showing timer like design , closed #24 --- .../CodeVerificationFragment.kt | 40 ++++++++---- .../res/layout/fragment_codeverification.xml | 62 +++++++++++-------- app/src/main/res/values/dimen.xml | 20 ++++++ app/src/main/res/values/strings.xml | 3 +- 4 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 app/src/main/res/values/dimen.xml diff --git a/app/src/main/java/de/netalic/peacock/ui/registeration/codeverification/CodeVerificationFragment.kt b/app/src/main/java/de/netalic/peacock/ui/registeration/codeverification/CodeVerificationFragment.kt index cc11a1b..0f55191 100644 --- a/app/src/main/java/de/netalic/peacock/ui/registeration/codeverification/CodeVerificationFragment.kt +++ b/app/src/main/java/de/netalic/peacock/ui/registeration/codeverification/CodeVerificationFragment.kt @@ -32,6 +32,8 @@ class CodeVerificationFragment : BaseFragment() { private val mCodeVerificationViewModel: CodeVerificationViewModel by viewModel() + private val mTextViewIn by lazy { textView_codeVerification_in } + private val mTextViewResendCode by lazy { textView_codeVerification_resendTitle } private val mPinEntryEditText by lazy { pinEntryEditText_codeVerification_setPin } private val mButton by lazy { button_codeVerification_continue } private val mTextViewTimer by lazy { textView_codeVerification_resendTime } @@ -45,10 +47,8 @@ class CodeVerificationFragment : BaseFragment() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - setTimer() disableButton() - } @@ -56,16 +56,17 @@ class CodeVerificationFragment : BaseFragment() { mButton.setOnClickListener { bind() } - mTextViewTimer.setOnClickListener { + mTextViewResendCode.setOnClickListener { if (!mIsRunning) { setTimer() + mTextViewTimer.visibility = View.VISIBLE + mTextViewIn.visibility = View.VISIBLE //We have to call claim here } } - mPinEntryEditText.addTextChangedListener(object : TextWatcher { override fun afterTextChanged(p0: Editable?) { @@ -77,7 +78,6 @@ class CodeVerificationFragment : BaseFragment() { override fun onTextChanged(p0: CharSequence?, p1: Int, p2: Int, p3: Int) { - if (p0!!.length == 6) { enableButton() @@ -104,7 +104,16 @@ class CodeVerificationFragment : BaseFragment() { "D89707AC55BAED9E8F23B826FB2A28E96095A190", "salimi", "android", - "eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJSUzI1NiIsICJraWQiOiAiODk0NTkyNzQzMzlkMzNlZmNmNTE3MDc4NGM5ZGU1MjUzMjEyOWVmZiJ9.eyJpc3MiOiAiZmlyZWJhc2UtYWRtaW5zZGstaXp1MTNAYWxwaGEtZDY0ZTQuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCAic3ViIjogImZpcmViYXNlLWFkbWluc2RrLWl6dTEzQGFscGhhLWQ2NGU0LmlhbS5nc2VydmljZWFjY291bnQuY29tIiwgImF1ZCI6ICJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsICJ1aWQiOiAiKzk4OTIxMTQ5OTMwMiIsICJpYXQiOiAxNTYzOTYwNDU3LCAiZXhwIjogMTU2Mzk2NDA1N30.HOUVBzwbmGwsglQHukGwrijlUuSZ241KdN2Eol3Gy80mmd4Kxoc58m3VhL71AWv3WS99eE7uz6xctl--yLPilhN3WJ_z2nxySqkhxiZ9OtaH_U8sTek63SJgfINeTFzJFpWHkT_DlQNPTVoH_AqbXjh0gZwdpVdMyoLmmuJf-WIqx2y7BdwudCTiAqY_RoK7DdDwS8Jf28J-czpWi7Q4neUo1pC0WLi986u9n0mZcfIhWoVB_fV0A2-fWRV6yhT647sfHntC2eSg-OJZKO-MAyBsgKDIZm_ubX7m3LHD6rahpnUHtY8m33eJyD-EfZcKboRWalJkmje69abirvep1A", + "eyJ0eXAiOiAiSldUIiwgImFsZyI6ICJSUzI1NiIsICJraWQiOiAiODk0NTkyNzQzMzlkMzNlZmNmNTE3MDc" + + "4NGM5ZGU1MjUzMjEyOWVmZiJ9.eyJpc3MiOiAiZmlyZWJhc2UtYWRtaW5zZGstaXp1MTNAYWxwaGEtZDY0ZTQuaWFtLmd" + + "zZXJ2aWNlYWNjb3VudC5jb20iLCAic3ViIjogImZpcmViYXNlLWFkbWluc2RrLWl6dTEzQGFscGhhLWQ2NGU0LmlhbS5nc" + + "2VydmljZWFjY291bnQuY29tIiwgImF1ZCI6ICJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGVhcGlzLmNvbS9nb" + + "29nbGUuaWRlbnRpdHkuaWRlbnRpdHl0b29sa2l0LnYxLklkZW50aXR5VG9vbGtpdCIsICJ1aWQiOiAiKzk4OTIxMTQ5OTM" + + "wMiIsICJpYXQiOiAxNTYzOTYwNDU3LCAiZXhwIjogMTU2Mzk2NDA1N30.HOUVBzwbmGwsglQHukGwrijlUuSZ241KdN2Eo" + + "l3Gy80mmd4Kxoc58m3VhL71AWv3WS99eE7uz6xctl--yLPilhN3WJ_z2nxySqkhxiZ9OtaH_U8sTek63SJgfINeTFzJFp" + + "WHkT_DlQNPTVoH_AqbXjh0gZwdpVdMyoLmmuJf-WIqx2y7BdwudCTiAqY_RoK7DdDwS8Jf28J-czpWi7Q4neUo1pC0WLi" + + "986u9n0mZcfIhWoVB_fV0A2-fWRV6yhT647sfHntC2eSg-OJZKO-MAyBsgKDIZm_ubX7m3LHD6rahpnUHtY8m33eJyD-" + + "EfZcKboRWalJkmje69abirvep1A", "082016" ) ) @@ -129,7 +138,6 @@ class CodeVerificationFragment : BaseFragment() { private fun setTimer() { - mCountDownTimer = object : CountDownTimer(sTimer.toLong(), 1000) { override fun onTick(millisUntilFinished: Long) { @@ -138,22 +146,28 @@ class CodeVerificationFragment : BaseFragment() { TimeUnit.MILLISECONDS.toMinutes(millisUntilFinished) ) mTextViewTimer.text = String.format("%02d:%02d ", minuteTimer, secondTimer) - mTextViewTimer.isEnabled = false - mTextViewTimer.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorText)) + mTextViewResendCode.isEnabled = false + mTextViewResendCode.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorText)) } override fun onFinish() { - mTextViewTimer.isEnabled = true + mTextViewResendCode.isEnabled = true mIsRunning = false if (context != null) { - mTextViewTimer.text = getString(R.string.codeVerification_resendCode) - mTextViewTimer.setTextColor(ContextCompat.getColor(requireContext(), R.color.colorTertiaryDark)) + + mTextViewResendCode.setTextColor( + ContextCompat.getColor( + requireContext(), + R.color.colorTertiaryDark + ) + ) + mTextViewIn.visibility = View.GONE + mTextViewTimer.visibility = View.GONE } } }.start() - } private fun disableButton() { diff --git a/app/src/main/res/layout/fragment_codeverification.xml b/app/src/main/res/layout/fragment_codeverification.xml index 7f305e8..a85db95 100644 --- a/app/src/main/res/layout/fragment_codeverification.xml +++ b/app/src/main/res/layout/fragment_codeverification.xml @@ -10,14 +10,14 @@ android:gravity="center" android:layout_width="match_parent" android:layout_height="wrap_content" - android:layout_marginTop="8dp"> + android:layout_marginTop="@dimen/margin_all_8dp"> @@ -47,7 +47,7 @@ android:text="@string/codeVerification_codeVerification" android:layout_below="@+id/imageView_codeVerification_icon" android:gravity="center" - android:layout_marginTop="20dp" + android:layout_marginTop="@dimen/margin_all_20dp" style="@style/TextAppearanceBaseBold"/> + android:layout_marginTop="@dimen/margin_all_20dp" + android:layout_marginStart="@dimen/margin_all_16dp" + android:layout_marginEnd="@dimen/margin_all_16dp"> + android:layout_marginStart="@dimen/margin_all_16dp" + android:layout_marginEnd="@dimen/margin_all_16dp" + android:layout_marginTop="@dimen/margin_all_30dp"/>