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
ebf2e9ca
Commit
ebf2e9ca
authored
Dec 21, 2021
by
shohboz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[UPD]
MUS-230
Feature, updated offline rejim
parent
e0450ad2
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
272 additions
and
57 deletions
+272
-57
MainActivity.kt
app/src/main/java/com/mobiuz/app/dev/MainActivity.kt
+35
-28
OfflineActivity.kt
app/src/main/java/com/mobiuz/app/dev/OfflineActivity.kt
+38
-22
AuthActivity.kt
app/src/main/java/com/mobiuz/app/dev/ui/auth/AuthActivity.kt
+17
-7
FullScreenFragment.kt
...n/java/com/mobiuz/app/dev/ui/global/FullScreenFragment.kt
+179
-0
activity_auth.xml
app/src/main/res/layout/activity_auth.xml
+1
-0
activity_main.xml
app/src/main/res/layout/activity_main.xml
+1
-0
activity_offline.xml
app/src/main/res/layout/activity_offline.xml
+1
-0
No files found.
app/src/main/java/com/mobiuz/app/dev/MainActivity.kt
View file @
ebf2e9ca
...
@@ -11,6 +11,7 @@ import androidx.activity.viewModels
...
@@ -11,6 +11,7 @@ import androidx.activity.viewModels
import
androidx.annotation.IdRes
import
androidx.annotation.IdRes
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatDelegate
import
androidx.appcompat.app.AppCompatDelegate
import
androidx.core.os.bundleOf
import
androidx.core.view.GravityCompat
import
androidx.core.view.GravityCompat
import
androidx.core.view.isVisible
import
androidx.core.view.isVisible
import
androidx.drawerlayout.widget.DrawerLayout
import
androidx.drawerlayout.widget.DrawerLayout
...
@@ -63,34 +64,49 @@ class MainActivity : AppCompatActivity() {
...
@@ -63,34 +64,49 @@ class MainActivity : AppCompatActivity() {
super
.
onCreate
(
savedInstanceState
)
super
.
onCreate
(
savedInstanceState
)
_bn
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
_bn
=
ActivityMainBinding
.
inflate
(
layoutInflater
)
setContentView
(
bn
.
root
)
setContentView
(
bn
.
root
)
pref
.
isShowPin
=
false
if
(
savedInstanceState
==
null
)
{
setupBottomNavigationBar
()
}
val
data
=
intent
?.
getStringExtra
(
CONSTANTS
.
FIRST
)
if
(
data
!=
null
&&
data
==
CONSTANTS
.
FIRST
)
{
currentNavController
?.
value
?.
popBackStack
()
currentNavController
?.
value
?.
navigate
(
R
.
id
.
homeFragment
)
}
AppCompatDelegate
.
setDefaultNightMode
(
AppCompatDelegate
.
MODE_NIGHT_NO
)
AppCompatDelegate
.
setDefaultNightMode
(
AppCompatDelegate
.
MODE_NIGHT_NO
)
FirebaseApp
.
initializeApp
(
this
)
FirebaseApp
.
initializeApp
(
this
@MainActivity
)
mFirebaseAnalytics
=
FirebaseAnalytics
.
getInstance
(
this
)
mFirebaseAnalytics
=
FirebaseAnalytics
.
getInstance
(
this
@MainActivity
)
FirebaseMessaging
.
getInstance
().
token
.
addOnCompleteListener
{
FirebaseMessaging
.
getInstance
().
token
.
addOnCompleteListener
{
if
(
it
.
isSuccessful
)
pref
.
deviceToken
=
it
.
result
.
toString
()
if
(
it
.
isSuccessful
)
pref
.
deviceToken
=
it
.
result
.
toString
()
}
}
if
(
savedInstanceState
==
null
)
{
setupBottomNavigationBar
()
}
setUpUI
()
setUpUI
()
collects
()
collects
()
receiver
=
object
:
BroadcastReceiver
()
{
receiver
=
object
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@MainActivity
)
if
(
intent
?.
action
==
CONSTANTS
.
CONNECTIVITY_CHANGE
){
bn
.
btnTryAgain
.
isVisible
=
type
==
0
sendBroadcast
(
Intent
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
))
if
(
type
==
0
)
{
}
showMessage
(
getString
(
R
.
string
.
not_internet_connect
))
if
(
intent
?.
action
==
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
){
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@MainActivity
)
bn
.
btnTryAgain
.
isVisible
=
(
type
==
0
)
&&
(
currentNavController
?.
value
?.
currentDestination
?.
id
!=
R
.
id
.
fullScreenFragment
)
if
(
type
==
0
)
{
showMessage
(
getString
(
R
.
string
.
not_internet_connect
))
}
}
}
}
}
}
}
val
intentFilter
=
IntentFilter
(
"android.net.conn.CONNECTIVITY_CHANGE"
)
val
intentFilter
=
IntentFilter
()
intentFilter
.
addAction
(
CONSTANTS
.
CONNECTIVITY_CHANGE
)
intentFilter
.
addAction
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
)
registerReceiver
(
receiver
,
intentFilter
)
registerReceiver
(
receiver
,
intentFilter
)
registerReceiver
(
receiver
,
intentFilter
)
}
}
...
@@ -99,13 +115,12 @@ class MainActivity : AppCompatActivity() {
...
@@ -99,13 +115,12 @@ class MainActivity : AppCompatActivity() {
bn
.
apply
{
bn
.
apply
{
bn
.
btnTryAgain
.
setOnClickListener
{
bn
.
btnTryAgain
.
setOnClickListener
{
if
(
type
==
0
)
{
if
(
type
==
0
)
{
navigate
()
navigate
ToOffline
()
}
}
}
}
txtVersion
.
text
=
"v ${BuildConfig.VERSION_NAME}"
txtVersion
.
text
=
"v ${BuildConfig.VERSION_NAME}"
header
.
txtUserPhone
.
text
=
pref
.
userPhone
.
customMasketHome
()
header
.
txtUserPhone
.
text
=
pref
.
userPhone
.
customMasketHome
()
customLog
(
"lang:${pref.language}"
)
when
(
pref
.
language
)
{
when
(
pref
.
language
)
{
CONSTANTS
.
UZ
->
txtLanguage
.
text
=
getString
(
R
.
string
.
uzbek
)
CONSTANTS
.
UZ
->
txtLanguage
.
text
=
getString
(
R
.
string
.
uzbek
)
CONSTANTS
.
RU
->
txtLanguage
.
text
=
getString
(
R
.
string
.
russian
)
CONSTANTS
.
RU
->
txtLanguage
.
text
=
getString
(
R
.
string
.
russian
)
...
@@ -160,8 +175,9 @@ class MainActivity : AppCompatActivity() {
...
@@ -160,8 +175,9 @@ class MainActivity : AppCompatActivity() {
}
}
}
}
fun
navigat
e
()
{
private
fun
navigateToOfflin
e
()
{
val
intent
=
Intent
(
this
,
OfflineActivity
::
class
.
java
)
val
intent
=
Intent
(
this
,
OfflineActivity
::
class
.
java
)
intent
.
putExtra
(
CONSTANTS
.
TYPE_SERVICE
,
CONSTANTS
.
FROM_ONLINE
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
Intent
.
FLAG_ACTIVITY_TASK_ON_HOME
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
Intent
.
FLAG_ACTIVITY_TASK_ON_HOME
startActivity
(
intent
)
startActivity
(
intent
)
finish
()
finish
()
...
@@ -193,20 +209,11 @@ class MainActivity : AppCompatActivity() {
...
@@ -193,20 +209,11 @@ class MainActivity : AppCompatActivity() {
}
}
private
fun
showPinCode
()
{
private
fun
showPinCode
()
{
intent
?.
let
{
if
(
pref
.
blockedTime
<
System
.
currentTimeMillis
()
-
CONSTANTS
.
BLOCKED_TIME
){
val
arg
=
it
.
getStringExtra
(
CONSTANTS
.
FIRST
)
?:
""
if
(
currentNavController
?.
value
?.
currentDestination
?.
id
!=
R
.
id
.
fullScreenFragment
){
if
(
arg
.
isEmpty
())
{
bn
.
btnTryAgain
.
isVisible
=
false
showFullScreenDialog
{
currentNavController
?.
value
?.
navigate
(
R
.
id
.
fullScreenFragment
,
bundleOf
(
CONSTANTS
.
TYPE_PIN
to
CONSTANTS
.
TYPE_AFTER
))
finish
()
pref
.
clearUserData
()
val
intent
=
Intent
(
this
,
AuthActivity
::
class
.
java
)
intent
.
putExtra
(
CONSTANTS
.
TYPE_AUTH
,
CONSTANTS
.
LOGIN
)
intent
.
putExtra
(
CONSTANTS
.
PHONE
,
pref
.
userPhone
)
startActivity
(
intent
)
it
.
dismiss
()
}
}
}
it
.
removeExtra
(
CONSTANTS
.
FIRST
)
}
}
}
}
...
...
app/src/main/java/com/mobiuz/app/dev/OfflineActivity.kt
View file @
ebf2e9ca
...
@@ -18,8 +18,6 @@ import com.mobiuz.app.dev.ui.auth.AuthActivity
...
@@ -18,8 +18,6 @@ import com.mobiuz.app.dev.ui.auth.AuthActivity
import
com.mobiuz.app.dev.ui.global.CONSTANTS
import
com.mobiuz.app.dev.ui.global.CONSTANTS
import
com.mobiuz.app.dev.ui.service.ServiceAdapter
import
com.mobiuz.app.dev.ui.service.ServiceAdapter
import
com.mobiuz.app.dev.utils.NetworkUtil
import
com.mobiuz.app.dev.utils.NetworkUtil
import
com.mobiuz.app.dev.utils.extensions.customLog
import
com.mobiuz.app.dev.utils.extensions.showFullScreenDialog
import
com.mobiuz.app.dev.utils.extensions.showMessage
import
com.mobiuz.app.dev.utils.extensions.showMessage
import
dagger.hilt.android.AndroidEntryPoint
import
dagger.hilt.android.AndroidEntryPoint
import
javax.inject.Inject
import
javax.inject.Inject
...
@@ -33,6 +31,7 @@ class OfflineActivity : AppCompatActivity() {
...
@@ -33,6 +31,7 @@ class OfflineActivity : AppCompatActivity() {
private
lateinit
var
adapter
:
ServiceAdapter
private
lateinit
var
adapter
:
ServiceAdapter
private
lateinit
var
navController
:
NavController
private
lateinit
var
navController
:
NavController
private
lateinit
var
receiver
:
BroadcastReceiver
private
lateinit
var
receiver
:
BroadcastReceiver
// if offline type == 0
// if offline type == 0
private
var
type
=
0
private
var
type
=
0
...
@@ -50,31 +49,50 @@ class OfflineActivity : AppCompatActivity() {
...
@@ -50,31 +49,50 @@ class OfflineActivity : AppCompatActivity() {
val
fragment
=
supportFragmentManager
.
findFragmentById
(
R
.
id
.
offline_container
)
as
NavHostFragment
val
fragment
=
supportFragmentManager
.
findFragmentById
(
R
.
id
.
offline_container
)
as
NavHostFragment
navController
=
NavHostFragment
.
findNavController
(
fragment
)
navController
=
NavHostFragment
.
findNavController
(
fragment
)
navController
.
popBackStack
()
intent
?.
let
{
navController
.
navigate
(
R
.
id
.
serviceFragment
,
bundleOf
(
CONSTANTS
.
TYPE_SERVICE
to
CONSTANTS
.
OFFLINE
))
val
type
=
it
.
getStringExtra
(
CONSTANTS
.
TYPE_SERVICE
)
navController
.
popBackStack
()
if
(
pref
.
isRegistered
&&
pref
.
pinCode
.
isNotEmpty
()
&&
type
!=
CONSTANTS
.
FROM_ONLINE
)
{
navController
.
navigate
(
R
.
id
.
fullScreenFragment
,
bundleOf
(
CONSTANTS
.
TYPE_PIN
to
CONSTANTS
.
OFFLINE
))
}
else
{
navController
.
navigate
(
R
.
id
.
serviceFragment
,
bundleOf
(
CONSTANTS
.
TYPE_SERVICE
to
CONSTANTS
.
OFFLINE
))
}
}
receiver
=
object
:
BroadcastReceiver
(){
receiver
=
object
:
BroadcastReceiver
()
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@OfflineActivity
)
if
(
intent
?.
action
==
CONSTANTS
.
CONNECTIVITY_CHANGE
)
{
bn
.
btnTryAgain
.
isVisible
=
type
!=
0
sendBroadcast
(
Intent
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
))
if
(
type
!=
0
){
showMessage
(
getString
(
R
.
string
.
yes_internet_connect
))
}
}
if
(
intent
?.
action
==
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
)
{
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@OfflineActivity
)
bn
.
btnTryAgain
.
isVisible
=
(
type
!=
0
)
&&
(
navController
.
currentDestination
?.
id
!=
R
.
id
.
fullScreenFragment
)
if
(
type
!=
0
)
{
showMessage
(
getString
(
R
.
string
.
yes_internet_connect
))
}
}
}
}
}
}
val
intentFilter
=
IntentFilter
(
"android.net.conn.CONNECTIVITY_CHANGE"
)
val
intentFilter
=
IntentFilter
()
registerReceiver
(
receiver
,
intentFilter
)
intentFilter
.
addAction
(
CONSTANTS
.
CONNECTIVITY_CHANGE
)
intentFilter
.
addAction
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
)
registerReceiver
(
receiver
,
intentFilter
)
bn
.
btnTryAgain
.
setOnClickListener
{
bn
.
btnTryAgain
.
setOnClickListener
{
if
(
type
!=
0
){
if
(
type
!=
0
)
{
navigate
()
navigate
()
}
}
}
}
}
}
override
fun
onResume
()
{
override
fun
onResume
()
{
super
.
onResume
()
super
.
onResume
()
if
(
pref
.
isShowPin
&&
pref
.
pinCode
.
isNotEmpty
())
{
if
(
pref
.
is
Registered
&&
pref
.
is
ShowPin
&&
pref
.
pinCode
.
isNotEmpty
())
{
showPinCode
()
showPinCode
()
}
else
{
}
else
{
pref
.
blockedTime
=
System
.
currentTimeMillis
()
pref
.
blockedTime
=
System
.
currentTimeMillis
()
...
@@ -89,18 +107,16 @@ class OfflineActivity : AppCompatActivity() {
...
@@ -89,18 +107,16 @@ class OfflineActivity : AppCompatActivity() {
private
fun
showPinCode
()
{
private
fun
showPinCode
()
{
showFullScreenDialog
{
if
(
pref
.
blockedTime
<
System
.
currentTimeMillis
()
-
CONSTANTS
.
BLOCKED_TIME
)
{
finish
()
if
(
navController
.
currentDestination
?.
id
!=
R
.
id
.
fullScreenFragment
)
{
pref
.
clearUserData
()
bn
.
btnTryAgain
.
isVisible
=
false
val
intent
=
Intent
(
this
,
AuthActivity
::
class
.
java
)
navController
.
navigate
(
R
.
id
.
fullScreenFragment
,
bundleOf
(
CONSTANTS
.
TYPE_PIN
to
CONSTANTS
.
TYPE_AFTER
))
intent
.
putExtra
(
CONSTANTS
.
TYPE_AUTH
,
CONSTANTS
.
LOGIN
)
}
intent
.
putExtra
(
CONSTANTS
.
PHONE
,
pref
.
userPhone
)
startActivity
(
intent
)
it
.
dismiss
()
}
}
}
}
fun
navigate
(){
fun
navigate
()
{
when
{
when
{
!
pref
.
isRegistered
->
{
!
pref
.
isRegistered
->
{
startActivity
(
Intent
(
this
,
AuthActivity
::
class
.
java
))
startActivity
(
Intent
(
this
,
AuthActivity
::
class
.
java
))
...
...
app/src/main/java/com/mobiuz/app/dev/ui/auth/AuthActivity.kt
View file @
ebf2e9ca
...
@@ -64,11 +64,11 @@ class AuthActivity : AppCompatActivity() {
...
@@ -64,11 +64,11 @@ class AuthActivity : AppCompatActivity() {
when
(
it
.
getStringExtra
(
CONSTANTS
.
TYPE_AUTH
))
{
when
(
it
.
getStringExtra
(
CONSTANTS
.
TYPE_AUTH
))
{
CONSTANTS
.
PIN_CODE
->
{
CONSTANTS
.
PIN_CODE
->
{
navController
.
popBackStack
()
navController
.
popBackStack
()
navController
.
navigate
(
R
.
id
.
pinFragment
,
null
,
Utils
.
navOptions
())
navController
.
navigate
(
R
.
id
.
pinFragment
,
bundleOf
(
CONSTANTS
.
TYPE_PIN
to
CONSTANTS
.
NEW_PIN
)
,
Utils
.
navOptions
())
}
}
CONSTANTS
.
LOGIN
->
{
CONSTANTS
.
LOGIN
->
{
navController
.
popBackStack
()
navController
.
popBackStack
()
navController
.
navigate
(
R
.
id
.
loginFragment
,
bundleOf
(
CONSTANTS
.
PHONE
to
phone
),
Utils
.
navOptions
())
navController
.
navigate
(
R
.
id
.
loginFragment
,
bundleOf
(
CONSTANTS
.
PHONE
to
p
ref
.
userP
hone
),
Utils
.
navOptions
())
}
}
CONSTANTS
.
TYPE_VERIFICATION
->
{
CONSTANTS
.
TYPE_VERIFICATION
->
{
navController
.
popBackStack
()
navController
.
popBackStack
()
...
@@ -84,19 +84,29 @@ class AuthActivity : AppCompatActivity() {
...
@@ -84,19 +84,29 @@ class AuthActivity : AppCompatActivity() {
receiver
=
object
:
BroadcastReceiver
(){
receiver
=
object
:
BroadcastReceiver
(){
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
override
fun
onReceive
(
context
:
Context
?,
intent
:
Intent
?)
{
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@AuthActivity
)
if
(
intent
?.
action
==
CONSTANTS
.
CONNECTIVITY_CHANGE
){
bn
.
btnTryAgain
.
isVisible
=
type
==
0
sendBroadcast
(
Intent
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
))
if
(
type
==
0
){
}
showMessage
(
getString
(
R
.
string
.
not_internet_connect
))
if
(
intent
?.
action
==
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
){
type
=
NetworkUtil
.
getConnectivityStatus
(
this
@AuthActivity
)
bn
.
btnTryAgain
.
isVisible
=
(
type
==
0
)
&&
(
navController
.
currentDestination
?.
id
!=
R
.
id
.
pinFragment
)
&&
(
navController
.
currentDestination
?.
id
!=
R
.
id
.
biometricFragment
)
if
(
type
==
0
){
showMessage
(
getString
(
R
.
string
.
not_internet_connect
))
}
}
}
}
}
}
}
val
intentFilter
=
IntentFilter
(
"android.net.conn.CONNECTIVITY_CHANGE"
)
val
intentFilter
=
IntentFilter
()
intentFilter
.
addAction
(
CONSTANTS
.
CONNECTIVITY_CHANGE
)
intentFilter
.
addAction
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
)
registerReceiver
(
receiver
,
intentFilter
)
registerReceiver
(
receiver
,
intentFilter
)
}
}
fun
navigate
(){
fun
navigate
(){
val
intent
=
Intent
(
this
,
OfflineActivity
::
class
.
java
)
val
intent
=
Intent
(
this
,
OfflineActivity
::
class
.
java
)
intent
.
putExtra
(
CONSTANTS
.
TYPE_SERVICE
,
CONSTANTS
.
FROM_ONLINE
)
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
Intent
.
FLAG_ACTIVITY_TASK_ON_HOME
intent
.
flags
=
Intent
.
FLAG_ACTIVITY_NEW_TASK
or
Intent
.
FLAG_ACTIVITY_TASK_ON_HOME
startActivity
(
intent
)
startActivity
(
intent
)
finish
()
finish
()
...
...
app/src/main/java/com/mobiuz/app/dev/ui/global/FullScreenFragment.kt
0 → 100644
View file @
ebf2e9ca
package
com.mobiuz.app.dev.ui.global
import
android.content.Intent
import
android.os.Bundle
import
android.view.View
import
android.view.animation.AnimationUtils
import
android.widget.TextView
import
androidx.activity.OnBackPressedCallback
import
androidx.core.os.bundleOf
import
androidx.core.view.isVisible
import
androidx.lifecycle.ViewModelProvider
import
androidx.lifecycle.lifecycleScope
import
androidx.navigation.NavController
import
androidx.navigation.fragment.NavHostFragment
import
androidx.recyclerview.widget.LinearLayoutManager
import
co.infinum.goldfinger.Goldfinger
import
com.mobiuz.app.R
import
com.mobiuz.app.databinding.FragmentPinDialogBinding
import
com.mobiuz.app.dev.MainViewModel
import
com.mobiuz.app.dev.model.PinData
import
com.mobiuz.app.dev.model.SharedPref
import
com.mobiuz.app.dev.ui.auth.AuthActivity
import
com.mobiuz.app.dev.ui.auth.pin.PinAdapter
import
com.mobiuz.app.dev.ui.base.BaseFragment
import
com.mobiuz.app.dev.utils.extensions.SingleBlock
import
com.mobiuz.app.dev.utils.extensions.customLog
import
com.mobiuz.app.dev.utils.extensions.vibrate
import
dagger.hilt.android.AndroidEntryPoint
import
kotlinx.coroutines.delay
import
javax.inject.Inject
@AndroidEntryPoint
class
FullScreenFragment
:
BaseFragment
(
R
.
layout
.
fragment_pin_dialog
)
{
@Inject
lateinit
var
pref
:
SharedPref
private
var
_bn
:
FragmentPinDialogBinding
?
=
null
private
val
bn
get
()
=
_bn
?:
throw
NullPointerException
(
"cannot inflate"
)
private
val
data
=
ArrayList
<
PinData
>()
private
val
pinAdapter
=
PinAdapter
()
private
lateinit
var
mainViewModel
:
MainViewModel
private
var
type
=
""
private
var
errorCount
=
3
private
val
navController
:
NavController
by
lazy
(
LazyThreadSafetyMode
.
NONE
)
{
NavHostFragment
.
findNavController
(
this
)
}
override
fun
onCreate
(
savedInstanceState
:
Bundle
?)
{
super
.
onCreate
(
savedInstanceState
)
type
=
arguments
?.
getString
(
CONSTANTS
.
TYPE_PIN
,
""
)
?:
""
mainViewModel
=
ViewModelProvider
(
requireActivity
())[
MainViewModel
::
class
.
java
]
}
override
fun
onViewCreated
(
view
:
View
,
savedInstanceState
:
Bundle
?)
{
_bn
=
FragmentPinDialogBinding
.
bind
(
view
)
val
window
=
requireActivity
().
window
.
decorView
window
.
systemUiVisibility
=
window
.
systemUiVisibility
or
View
.
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
mainViewModel
.
bottomSheet
(
false
)
mainViewModel
.
swipeDrawer
(
false
)
setUpUI
()
if
(
pref
.
isUseFingerPrint
)
loadFingerPrint
()
}
private
fun
loadFingerPrint
()
{
val
golfing
=
Goldfinger
.
Builder
(
requireContext
()).
build
()
if
(
golfing
.
canAuthenticate
())
{
val
params
=
Goldfinger
.
PromptParams
.
Builder
(
this
)
.
title
(
getString
(
R
.
string
.
enter_from_finger_or_face
))
.
negativeButtonText
(
getString
(
R
.
string
.
cancel
))
.
build
()
golfing
.
authenticate
(
params
,
object
:
Goldfinger
.
Callback
{
override
fun
onResult
(
result
:
Goldfinger
.
Result
)
{
if
(
result
.
type
()
==
Goldfinger
.
Type
.
SUCCESS
)
{
navigate
()
}
}
override
fun
onError
(
e
:
Exception
)
{}
})
}
}
override
fun
setUpUI
()
{
bn
.
apply
{
loadData
()
rvPin
.
layoutManager
=
LinearLayoutManager
(
requireContext
(),
LinearLayoutManager
.
HORIZONTAL
,
false
)
rvPin
.
adapter
=
pinAdapter
txtNotPin
.
isVisible
=
false
requireActivity
().
onBackPressedDispatcher
.
addCallback
(
viewLifecycleOwner
,
object
:
OnBackPressedCallback
(
true
){
override
fun
handleOnBackPressed
()
{
requireActivity
().
finish
()
}
})
pinAdapter
.
setOnDoneListener
{
if
(
pref
.
pinCode
==
it
)
{
txtNotPin
.
isVisible
=
false
navigate
()
}
else
{
errorCount
--
if
(
errorCount
==
0
){
loadWithPassword
()
}
vibrate
(
requireContext
())
cardPin
.
startAnimation
(
AnimationUtils
.
loadAnimation
(
context
,
R
.
anim
.
shake
))
txtNotPin
.
isVisible
=
true
}
}
for
(
i
in
0
until
btnViewGroup
.
childCount
)
{
btnViewGroup
.
getChildAt
(
i
).
setOnClickListener
{
when
(
it
.
id
)
{
R
.
id
.
btn_remove
->
{
pinAdapter
.
removeItem
()
txtNotPin
.
isVisible
=
false
}
R
.
id
.
with_password
->
{
loadWithPassword
()
}
R
.
id
.
btn_finger_print
->
{
loadFingerPrint
()
}
else
->
{
val
text
=
it
as
TextView
txtNotPin
.
isVisible
=
false
pinAdapter
.
addItem
(
text
.
text
.
toString
().
toInt
())
}
}
}
}
}
}
private
fun
loadWithPassword
()
{
pref
.
clearUserData
()
val
intent
=
Intent
(
requireContext
(),
AuthActivity
::
class
.
java
)
intent
.
putExtra
(
CONSTANTS
.
TYPE_AUTH
,
CONSTANTS
.
LOGIN
)
startActivity
(
intent
)
requireActivity
().
finish
()
}
private
fun
navigate
()
{
navController
.
popBackStack
()
requireActivity
().
sendBroadcast
(
Intent
(
CONSTANTS
.
MY_CONNECTIVITY_CHANGE
))
if
(
type
==
CONSTANTS
.
OFFLINE
){
navController
.
navigate
(
R
.
id
.
serviceFragment
,
bundleOf
(
CONSTANTS
.
TYPE_SERVICE
to
CONSTANTS
.
OFFLINE
))
}
else
if
(
type
!=
CONSTANTS
.
TYPE_AFTER
)
{
navController
.
navigate
(
R
.
id
.
homeFragment
)
}
}
override
fun
collects
()
{
}
private
fun
loadData
()
{
data
.
clear
()
for
(
i
in
0
..
3
)
{
data
.
add
(
PinData
(-
1
))
}
pinAdapter
.
submitList
(
data
)
}
override
fun
onDestroy
()
{
_bn
=
null
super
.
onDestroy
()
}
}
\ No newline at end of file
app/src/main/res/layout/activity_auth.xml
View file @
ebf2e9ca
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:background=
"@color/white100"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows=
"true"
>
android:fitsSystemWindows=
"true"
>
...
...
app/src/main/res/layout/activity_main.xml
View file @
ebf2e9ca
...
@@ -11,6 +11,7 @@
...
@@ -11,6 +11,7 @@
<LinearLayout
<LinearLayout
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:background=
"@color/white100"
android:orientation=
"vertical"
>
android:orientation=
"vertical"
>
<androidx.fragment.app.FragmentContainerView
<androidx.fragment.app.FragmentContainerView
...
...
app/src/main/res/layout/activity_offline.xml
View file @
ebf2e9ca
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
android:layout_width=
"match_parent"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:layout_height=
"match_parent"
android:orientation=
"vertical"
android:orientation=
"vertical"
android:background=
"@color/white100"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
android:fitsSystemWindows=
"false"
>
android:fitsSystemWindows=
"false"
>
...
...
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