Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
shunchaki
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Shohboz Qoraboev
shunchaki
Commits
95a1d1bf
Commit
95a1d1bf
authored
Dec 03, 2021
by
shohboz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ADD]
MUS-127
Feature, add sms verification code api
parent
a9f50c61
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
95 deletions
+97
-95
VerificationFragment.kt
...c/main/java/uz/ssd/mobiuz/ui/auth/VerificationFragment.kt
+58
-59
fragment_verification.xml
app/src/main/res/layout/fragment_verification.xml
+39
-36
No files found.
app/src/main/java/uz/ssd/mobiuz/ui/auth/VerificationFragment.kt
View file @
95a1d1bf
...
...
@@ -18,8 +18,8 @@ import uz.ssd.mobiuz.network.model.UiStateObject
import
uz.ssd.mobiuz.ui.base.BaseFragment
import
uz.ssd.mobiuz.ui.global.TextWatcherWrapper
import
uz.ssd.mobiuz.utils.ButtonClick
import
uz.ssd.mobiuz.utils.CONSTANTS
import
uz.ssd.mobiuz.utils.Utils
import
uz.ssd.mobiuz.utils.extensions.customLog
import
uz.ssd.mobiuz.utils.extensions.hideKeyboard
import
uz.ssd.mobiuz.utils.extensions.showKeyboard
import
uz.ssd.mobiuz.utils.extensions.showMessage
...
...
@@ -31,7 +31,17 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
private
val
bn
get
()
=
_bn
?:
throw
NullPointerException
(
"cannot inflate"
)
private
val
viewModel
:
AuthViewModel
by
viewModels
()
private
val
navController
:
NavController
by
lazy
(
LazyThreadSafetyMode
.
NONE
)
{
NavHostFragment
.
findNavController
(
this
)
}
private
var
code
=
""
private
var
phone
=
""
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
arguments
?.
let
{
phone
=
it
.
getString
(
CONSTANTS
.
PHONE
)
?:
""
}
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
_bn
=
FragmentVerificationBinding
.
bind
(
view
)
setUpUI
()
...
...
@@ -46,15 +56,28 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
navController
.
navigateUp
()
}
loadEdited
()
viewGroup
.
setOnClickListener
(
object
:
ButtonClick
(){
override
fun
onSingleClick
(
v
:
View
?)
{
v
?.
hideKeyboard
()
}
})
frame
.
setOnClickListener
(
object
:
ButtonClick
(){
override
fun
onSingleClick
(
v
:
View
?)
{
clearPins
()
}
})
btnLogin
.
setOnClickListener
(
object
:
ButtonClick
()
{
override
fun
onSingleClick
(
v
:
View
?)
{
viewModel
.
login
(
UserAuth
(
"phone"
,
"password"
))
getLinePinCodes
()
if
(
code
.
length
==
6
){
viewModel
.
verification
(
UserAuth
(
phone
,
null
,
code
))
}
else
{
clearPins
()
}
}
})
...
...
@@ -63,7 +86,6 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
sentCodeAgain
.
setTextColor
(
Color
.
parseColor
(
"#FF9500"
))
sentCodeAgain
.
setOnClickListener
{
// viewModel.login(UserAuth("",""))
count
(
true
)
}
coutdownView
.
setOnCountdownEndListener
{
...
...
@@ -72,27 +94,33 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
}
}
private
fun
loadEdited
()
{
private
fun
getLinePinCodes
()
{
bn
.
apply
{
code
=
""
code
+=
pin1
.
text
.
toString
()
code
+=
pin2
.
text
.
toString
()
code
+=
pin3
.
text
.
toString
()
code
+=
pin4
.
text
.
toString
()
code
+=
pin5
.
text
.
toString
()
code
+=
pin6
.
text
.
toString
()
}
}
toolbar
.
setNavigationOnClickListener
{
navController
.
navigateUp
()
}
viewGroup
.
setOnClickListener
{
it
.
hideKeyboard
()
}
private
fun
clearPins
()
{
bn
.
apply
{
pin1
.
text
?.
clear
()
pin2
.
text
?.
clear
()
pin3
.
text
?.
clear
()
pin4
.
text
?.
clear
()
pin5
.
text
?.
clear
()
pin6
.
text
?.
clear
()
pin1
.
showKeyboard
()
}
}
private
fun
loadEdited
()
{
bn
.
apply
{
frame
.
setOnClickListener
{
pin1
.
text
?.
clear
()
pin2
.
text
?.
clear
()
pin3
.
text
?.
clear
()
pin4
.
text
?.
clear
()
pin5
.
text
?.
clear
()
pin6
.
text
?.
clear
()
pin1
.
showKeyboard
()
}
pin1
.
addTextChangedListener
(
object
:
TextWatcherWrapper
()
{
override
fun
onTextChanged
(
s
:
CharSequence
?,
start
:
Int
,
before
:
Int
,
count
:
Int
)
{
...
...
@@ -171,44 +199,15 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
pin6
.
setBackgroundResource
(
R
.
drawable
.
bgn_ver_unchecked
)
}
}
})
pin1
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
pin2
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
pin3
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
pin4
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
pin5
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
pin6
.
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
for
(
i
in
0
until
pinView
.
childCount
){
pinView
.
getChildAt
(
i
).
setOnKeyListener
{
_
,
keyCode
,
_
->
if
(
keyCode
==
KeyEvent
.
KEYCODE_DEL
)
{
checkFocus
().
requestFocus
()
}
false
}
false
}
}
}
...
...
@@ -246,7 +245,7 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
override
fun
collects
()
{
viewLifecycleOwner
.
lifecycleScope
.
launchWhenStarted
{
viewModel
.
logi
nUiState
.
collect
{
viewModel
.
verificatio
nUiState
.
collect
{
when
(
it
)
{
is
UiStateObject
.
SUCCESS
->
{
showProgressDialog
(
false
)
...
...
@@ -270,7 +269,7 @@ class VerificationFragment : BaseFragment(R.layout.fragment_verification) {
sentCodeAgain
.
isVisible
=
!
status
countWaitText
.
isVisible
=
status
coutdownView
.
isVisible
=
status
if
(
status
)
coutdownView
.
start
(
12
0000
)
if
(
status
)
coutdownView
.
start
(
6
0000
)
}
}
...
...
app/src/main/res/layout/fragment_verification.xml
View file @
95a1d1bf
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:layout_width=
"match_parent"
android:id=
"@+id/view_group"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
>
...
...
@@ -27,59 +27,62 @@
<FrameLayout
android:id=
"@+id/pin_view"
android:id=
"@+id/pin_view
_group
"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_marginTop=
"@dimen/_80sdp"
android:layout_marginHorizontal=
"@dimen/_12sdp"
android:layout_marginTop=
"@dimen/_80sdp"
android:orientation=
"horizontal"
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/txt_enter_phone"
>
<LinearLayout
android:id=
"@+id/pin_view"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_gravity=
"center"
android:gravity=
"center"
android:layout_height=
"match_parent"
>
android:gravity=
"center"
>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_1"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_1"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_2"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_2"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_3"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_3"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_4"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_4"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_5"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_5"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_6"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
/>
<com.google.android.material.textfield.TextInputEditText
android:id=
"@+id/pin_6"
style=
"@style/PinStyle"
android:background=
"@drawable/bgn_ver_unchecked"
android:imeOptions=
"actionDone"
/>
</LinearLayout>
<FrameLayout
android:layout_width=
"match_parent"
android:id=
"@+id/frame"
android:visibility=
"visible"
android:layout_height=
"match_parent"
/>
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:visibility=
"visible"
/>
</FrameLayout>
<TextView
...
...
@@ -93,7 +96,7 @@
app:layout_constraintEnd_toStartOf=
"@id/coutdown_view"
app:layout_constraintHorizontal_chainStyle=
"packed"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/pin_view"
/>
app:layout_constraintTop_toBottomOf=
"@+id/pin_view
_group
"
/>
<TextView
android:id=
"@+id/sent_code_again"
...
...
@@ -108,7 +111,7 @@
app:layout_constraintEnd_toEndOf=
"parent"
app:layout_constraintHorizontal_chainStyle=
"packed"
app:layout_constraintStart_toStartOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@+id/pin_view"
/>
app:layout_constraintTop_toBottomOf=
"@+id/pin_view
_group
"
/>
<cn.iwgang.countdownview.CountdownView
android:id=
"@+id/coutdown_view"
...
...
@@ -151,10 +154,10 @@
android:layout_marginHorizontal=
"@dimen/_16sdp"
android:layout_marginTop=
"@dimen/_24sdp"
android:enabled=
"false"
android:text=
"@string/continuoue
_task
"
android:text=
"@string/continuoue"
android:textSize=
"@dimen/_12sdp"
app:layout_constraintBottom_toBottomOf=
"parent"
app:layout_constraintTop_toBottomOf=
"@id/pin_view"
/>
app:layout_constraintTop_toBottomOf=
"@id/pin_view
_group
"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment