From aa45fa2cd6d6720d6106840aed7767792a5856ef Mon Sep 17 00:00:00 2001
From: covidsafe-support <64945427+covidsafe-support@users.noreply.github.com>
Date: Tue, 16 Mar 2021 21:23:24 -0700
Subject: [PATCH] COVIDSafe code from version 2.3
---
app/build.gradle | 2 +-
.../au/gov/health/covidsafe/PeekActivity.kt | 56 ++-
app/src/main/AndroidManifest.xml | 1 +
.../au/gov/health/covidsafe/HomeActivity.kt | 6 +
.../usecase/GetCaseStatisticsUseCase.kt | 4 +-
.../usecase/GetRestrictionUseCase.kt | 4 +-
.../IssueInitialRefreshTokenUseCase.kt | 6 +-
.../interactor/usecase/ReIssueAuth.kt | 10 +-
...ageAndPerformScanWithExponentialBackOff.kt | 2 +
.../interactor/usecase/UploadData.kt | 5 +
.../health/covidsafe/preference/Preference.kt | 13 +-
.../scheduler/GetMessagesScheduler.kt | 76 +--
.../health/covidsafe/ui/home/HelpActivity.kt | 18 +
.../health/covidsafe/ui/home/HelpFragment.kt | 5 +-
.../health/covidsafe/ui/home/HomeFragment.kt | 12 +-
.../ui/home/HomeFragmentViewModel.kt | 26 +-
.../fragment/enterpin/EnterPinPresenter.kt | 1 +
.../ui/restriction/RestrictionDescActivity.kt | 2 +-
.../ui/restriction/RestrictionFragment.kt | 13 +-
.../ui/restriction/RestrictionViewModel.kt | 28 +-
.../ui/restriction/StateActivityAdapter.kt | 8 +-
.../covidsafe/ui/restriction/StateAdapter.kt | 10 +-
.../covidsafe/ui/settings/SettingsFragment.kt | 3 +-
.../ui/settings/SettingsViewModel.kt | 35 +-
app/src/main/res/layout/activity_help.xml | 17 +
app/src/main/res/layout/database_peek.xml | 31 +-
app/src/main/res/layout/fragment_home.xml | 2 +-
.../layout/fragment_home_case_statistics.xml | 4 +-
.../main/res/layout/fragment_restriction.xml | 1 -
app/src/main/res/layout/fragment_settings.xml | 2 +-
.../res/layout/view_home_setup_incomplete.xml | 6 +-
app/src/main/res/values-ar/strings.xml | 32 +-
app/src/main/res/values-el-rGR/strings.xml | 31 +-
app/src/main/res/values-it-rIT/strings.xml | 30 ++
app/src/main/res/values-ko/strings.xml | 126 +++--
app/src/main/res/values-pa-rIN/strings.xml | 436 ++++++++++--------
app/src/main/res/values-tr/strings.xml | 30 ++
app/src/main/res/values-vi/strings.xml | 30 ++
app/src/main/res/values-zh-rCN/strings.xml | 30 ++
app/src/main/res/values-zh-rTW/strings.xml | 30 ++
app/src/main/res/values/strings.xml | 2 +
41 files changed, 837 insertions(+), 349 deletions(-)
create mode 100644 app/src/main/java/au/gov/health/covidsafe/ui/home/HelpActivity.kt
create mode 100644 app/src/main/res/layout/activity_help.xml
diff --git a/app/build.gradle b/app/build.gradle
index fc2e1cc..915d706 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -29,7 +29,7 @@ android {
applicationId "au.gov.health.covidsafe"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
- versionCode 114
+ versionCode 124
versionName "2.4"
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
diff --git a/app/src/debug/java/au/gov/health/covidsafe/PeekActivity.kt b/app/src/debug/java/au/gov/health/covidsafe/PeekActivity.kt
index 40f1d90..5d6e009 100644
--- a/app/src/debug/java/au/gov/health/covidsafe/PeekActivity.kt
+++ b/app/src/debug/java/au/gov/health/covidsafe/PeekActivity.kt
@@ -2,6 +2,7 @@ package au.gov.health.covidsafe
import android.content.Intent
import android.os.Bundle
+import android.util.Log
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AlertDialog
@@ -23,8 +24,10 @@ import io.reactivex.Observable
import io.reactivex.android.schedulers.AndroidSchedulers
import io.reactivex.schedulers.Schedulers
import kotlinx.android.synthetic.main.database_peek.*
-import kotlinx.android.synthetic.main.database_peek.home_push_notification_token
+import org.json.JSONObject
import java.io.File
+import java.text.SimpleDateFormat
+import java.util.*
private const val TAG = "PeekActivity"
@@ -35,6 +38,7 @@ class PeekActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
newPeek()
+ expToken()
}
private fun newPeek() {
@@ -140,6 +144,56 @@ class PeekActivity : AppCompatActivity() {
turnSensor()
}
+ private fun expToken() {
+ val token = Preference.getEncrypterJWTToken(applicationContext)
+ val refreshToken = Preference.getEncryptRefreshToken(applicationContext)
+
+ val tokenSeparate = token?.split(".")
+ var subjectItem: String? = null
+ if (tokenSeparate?.size !=null && tokenSeparate.size >= 3) {
+ subjectItem = tokenSeparate.let {
+ it[1]
+ }
+ }
+
+ var subjectByte: ByteArray? = null
+ subjectItem?.let { subjectByte = android.util.Base64.decode(subjectItem, android.util.Base64.DEFAULT)}
+ val charset = Charsets.UTF_8
+
+ subjectByte?.let {
+ val jsonModel = String(it, charset)
+ val jsonObj = JSONObject(jsonModel)
+
+ val dateObj = Date(jsonObj.get("exp").toString().toLong() * 1000)
+ val subjectId = jsonObj.get("sub").toString()
+
+ val dateString = SimpleDateFormat("dd-MM-yyyy hh:mm:ss a").format(dateObj)
+ token_exp.text = "Token Expire in: $dateString"
+ device_id.text = "Device ID: $subjectId"
+ }
+
+ // Refresh Token
+ val refreshTokenSeparate = refreshToken?.split(".")
+ var item: String? = null
+ if (refreshTokenSeparate?.size !=null && refreshTokenSeparate.size >= 3) {
+ item = refreshTokenSeparate.let {
+ it[1]
+ }
+ }
+
+ refresh_token_exp.text = "Refresh Token Expire in: N/A"
+ var itemByte: ByteArray? = null
+ item?.let { itemByte = android.util.Base64.decode(item, android.util.Base64.DEFAULT)}
+ itemByte?.let {
+ val jsonModel = String(it, charset)
+ val jsonObj = JSONObject(jsonModel)
+
+ val dateObj = Date(jsonObj.get("exp").toString().toLong() * 1000)
+
+ val dateString = SimpleDateFormat("yyyy-MM-dd").format(dateObj)
+ token_exp.text = "Refresh Token Expire in: " + dateString
+ }
+ }
private fun turnSensor() {
switch_sensor.isChecked = !Preference.getAdvertiseStop(this)
switch_sensor.setOnCheckedChangeListener { _, isChecked ->
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index d9c0b10..b818552 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -57,6 +57,7 @@
+
(lifecycle) {
+class GetCaseStatisticsUseCase(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context) : UseCase(lifecycle) {
override suspend fun run(params: String): Either {
val token = Preference.getEncrypterJWTToken(context)
+ val authenticate = Preference.getAuthenticate(context)
+ if (!authenticate) { return Failure(Exception()) }
return token?.let { jwtToken ->
try {
CentralLog.d(TAG, "GetCaseStatisticsUseCase run request")
diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/GetRestrictionUseCase.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/GetRestrictionUseCase.kt
index 9439710..b97f15f 100644
--- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/GetRestrictionUseCase.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/GetRestrictionUseCase.kt
@@ -14,10 +14,12 @@ import au.gov.health.covidsafe.preference.Preference
private const val TAG = "GetCaseStatisticsUseCase"
-class GetRestrictionUseCase(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context?, val state: String) : UseCase(lifecycle) {
+class GetRestrictionUseCase(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context, val state: String) : UseCase(lifecycle) {
override suspend fun run(params: String): Either {
val token = Preference.getEncrypterJWTToken(context)
+ val authenticate = Preference.getAuthenticate(context)
+ if (!authenticate) { return Failure(Exception()) }
return token?.let { jwtToken ->
try {
CentralLog.d(TAG, "GetCaseStatisticsUseCase run request")
diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/IssueInitialRefreshTokenUseCase.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/IssueInitialRefreshTokenUseCase.kt
index 4393fc9..bf91b83 100644
--- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/IssueInitialRefreshTokenUseCase.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/IssueInitialRefreshTokenUseCase.kt
@@ -13,16 +13,14 @@ import au.gov.health.covidsafe.preference.Preference
private const val TAG = "GetCaseStatisticsUseCase"
-class IssueInitialRefreshTokenUseCase(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context?) : UseCase(lifecycle) {
+class IssueInitialRefreshTokenUseCase(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context) : UseCase(lifecycle) {
override suspend fun run(params: String): Either {
val token = Preference.getEncrypterJWTToken(context)
return token?.let { jwtToken ->
try {
CentralLog.d(TAG, "GetCaseStatisticsUseCase run request")
- val response = retryRetrofitCall {
- awsClient.issueInitialRefreshToken("Bearer $jwtToken").execute()
- }
+ val response = awsClient.issueInitialRefreshToken("Bearer $jwtToken").execute()
when {
response?.code() == 200 -> {
diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/ReIssueAuth.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/ReIssueAuth.kt
index 0d73b05..44e4d57 100644
--- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/ReIssueAuth.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/ReIssueAuth.kt
@@ -10,19 +10,15 @@ import au.gov.health.covidsafe.logging.CentralLog
import au.gov.health.covidsafe.networking.request.ReIssueAuthRequest
import au.gov.health.covidsafe.networking.response.IssueInitialRefreshtokenResponse
import au.gov.health.covidsafe.networking.service.AwsClient
-import au.gov.health.covidsafe.preference.Preference
-private const val TAG = "GetCaseStatisticsUseCase"
+private const val TAG = "ReIssueAuth"
-class ReIssueAuth(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context?,
+class ReIssueAuth(private val awsClient: AwsClient, lifecycle: Lifecycle, private val context: Context,
private val subject: String?, private val refreshToken: String?) : UseCase(lifecycle) {
override suspend fun run(params: String): Either {
- val token = Preference.getEncrypterJWTToken(context)
return try {
- val response = retryRetrofitCall {
- awsClient.reIssueAuth(ReIssueAuthRequest(subject, refreshToken)).execute()
- }
+ val response = awsClient.reIssueAuth(ReIssueAuthRequest(subject, refreshToken)).execute()
when {
response?.code() == 200 -> {
diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt
index e9b554c..b616ff9 100644
--- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UpdateBroadcastMessageAndPerformScanWithExponentialBackOff.kt
@@ -25,6 +25,8 @@ class UpdateBroadcastMessageAndPerformScanWithExponentialBackOff(private val aws
override suspend fun run(params: Void?): Either {
val token = Preference.getEncrypterJWTToken(context)
+ val authenticate = Preference.getAuthenticate(context)
+ if (!authenticate) { return Failure(Exception()) }
return token?.let { jwtToken ->
var response = call(jwtToken)
var retryCount = 0
diff --git a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UploadData.kt b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UploadData.kt
index 2227b95..ff81902 100644
--- a/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UploadData.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/interactor/usecase/UploadData.kt
@@ -27,6 +27,11 @@ class UploadData(private val awsClient: AwsClient,
override suspend fun run(params: String): Either {
val token = Preference.getEncrypterJWTToken(context)
+ context?.let {
+ val authenticate = Preference.getAuthenticate(context)
+ // Token is not authenticated
+ if (!authenticate) { return Failure(Exception("005")) }
+ }
return token?.let { jwtToken ->
try {
val initialUploadResponse = retryRetrofitCall {
diff --git a/app/src/main/java/au/gov/health/covidsafe/preference/Preference.kt b/app/src/main/java/au/gov/health/covidsafe/preference/Preference.kt
index 9f1aa9f..b0eaa9d 100644
--- a/app/src/main/java/au/gov/health/covidsafe/preference/Preference.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/preference/Preference.kt
@@ -39,10 +39,11 @@ object Preference {
private const val TURN_CASE_NUMBER = "TURN_CASE_NUMBER"
private const val IS_REREGISTER = "IS_REREGISTER"
private const val SELECTED_STATE = "SELECTED_STATE"
- private const val SELECTED_RESTRICTION_STATE = "SELECTED_STATE"
+ private const val SELECTED_RESTRICTION_STATE = "SELECTED_RESTRICTION_STATE"
private const val SENSOR_START = "SENSOR_START"
private const val ADVERTISE_STOP = "ADVERTISE_STOP"
private const val REFRESH_TOKEN = "REFRESH_TOKEN"
+ private const val AUTHENTICATE = "AUTHENTICATE"
fun putDeviceID(context: Context, value: String) {
context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE)
@@ -398,4 +399,14 @@ object Preference {
return context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE)
.getString(SELECTED_RESTRICTION_STATE, null)
}
+
+ fun setAuthenticate(context: Context, authenticate: Boolean): Boolean {
+ return context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE)
+ .edit().putBoolean(AUTHENTICATE, authenticate).commit()
+ }
+
+ fun getAuthenticate(context: Context): Boolean {
+ return context.getSharedPreferences(PREF_ID, Context.MODE_PRIVATE)
+ .getBoolean(AUTHENTICATE, true)
+ }
}
diff --git a/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt b/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt
index 3ac963f..b4c1e6c 100644
--- a/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/scheduler/GetMessagesScheduler.kt
@@ -13,6 +13,7 @@ import au.gov.health.covidsafe.extensions.isBlueToothEnabled
import au.gov.health.covidsafe.extensions.isLocationEnabledOnDevice
import au.gov.health.covidsafe.extensions.isLocationPermissionAllowed
import au.gov.health.covidsafe.factory.NetworkFactory.Companion.awsClient
+import au.gov.health.covidsafe.interactor.Failure
import au.gov.health.covidsafe.logging.CentralLog
import au.gov.health.covidsafe.networking.response.ErrorMessage
import au.gov.health.covidsafe.networking.response.MessagesResponse
@@ -155,48 +156,55 @@ object GetMessagesScheduler {
CentralLog.d(TAG, "healthCheck = $healthCheck")
val preferredLanguages = Locale.getDefault().language
+ val authenticate = Preference.getAuthenticate(context)
+ if (authenticate)
+ {
+ val messagesCall: Call = awsClient.getMessages(
+ "Bearer $jwtToken",
+ os,
+ appVersion,
+ token,
+ healthCheck,
+ encountersHealth,
+ preferredLanguages
+ )
- val messagesCall: Call = awsClient.getMessages(
- "Bearer $jwtToken",
- os,
- appVersion,
- token,
- healthCheck,
- encountersHealth,
- preferredLanguages
- )
+ CentralLog.d(TAG, "getMessages() to be called with InstanceID = $token")
- CentralLog.d(TAG, "getMessages() to be called with InstanceID = $token")
+ messagesCall.enqueue(object : Callback {
+ override fun onResponse(call: Call, response: Response) {
+ val responseCode = response.code()
- messagesCall.enqueue(object : Callback {
- override fun onResponse(call: Call, response: Response) {
- val responseCode = response.code()
+ if (responseCode == 200) {
+ CentralLog.d(TAG, "onResponse() got 200 response.")
- if (responseCode == 200) {
- CentralLog.d(TAG, "onResponse() got 200 response.")
-
- response.body()?.let {
- CentralLog.d(TAG, "onResponse() MessagesResponse = $it")
- messagesResponseCallback?.invoke(it)
+ response.body()?.let {
+ CentralLog.d(TAG, "onResponse() MessagesResponse = $it")
+ messagesResponseCallback?.invoke(it)
+ }
+ } else if (responseCode == 401) {
+ response.errorBody()?.let {
+ val errorMessage: ErrorMessage = Gson().fromJson(it.string(), ErrorMessage::class.java)
+ val messageResponse = MessagesResponse(emptyList(), null, false, errorMessage.message)
+ messagesResponseCallback?.invoke(messageResponse)
+ }
+ } else {
+ CentralLog.w(TAG, "onResponse() got error response code = $responseCode.")
}
- } else if (responseCode == 401) {
- response.errorBody()?.let {
- val errorMessage: ErrorMessage = Gson().fromJson(it.string(), ErrorMessage::class.java)
- val messageResponse = MessagesResponse(emptyList(), null, false, errorMessage.message)
- messagesResponseCallback?.invoke(messageResponse)
- }
- } else {
- CentralLog.w(TAG, "onResponse() got error response code = $responseCode.")
+
+ jobService?.jobFinished(params, false)
}
- jobService?.jobFinished(params, false)
- }
+ override fun onFailure(call: Call, t: Throwable) {
+ CentralLog.e(TAG, "onResponse() failed $t")
- override fun onFailure(call: Call, t: Throwable) {
- CentralLog.e(TAG, "onResponse() failed $t")
+ jobService?.jobFinished(params, false)
+ }
+ })
+ } else {
+ CentralLog.e(TAG, "onResponse() failed")
- jobService?.jobFinished(params, false)
- }
- })
+ jobService?.jobFinished(params, false)
+ }
}
}
\ No newline at end of file
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpActivity.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpActivity.kt
new file mode 100644
index 0000000..3ed807d
--- /dev/null
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpActivity.kt
@@ -0,0 +1,18 @@
+package au.gov.health.covidsafe.ui.home
+
+import android.os.Bundle
+import android.view.View
+import android.view.WindowManager
+import androidx.appcompat.app.AppCompatActivity
+import androidx.appcompat.widget.Toolbar
+import au.gov.health.covidsafe.R
+import kotlinx.android.synthetic.main.activity_restriction_desc.*
+
+class HelpActivity : AppCompatActivity() {
+
+ override fun onCreate(savedInstanceState: Bundle?) {
+ super.onCreate(savedInstanceState)
+ window.clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN)
+ setContentView(R.layout.activity_help)
+ }
+}
\ No newline at end of file
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt
index 2a41691..732f4ff 100644
--- a/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HelpFragment.kt
@@ -11,7 +11,6 @@ import android.webkit.WebResourceRequest
import android.webkit.WebView
import android.webkit.WebViewClient
import androidx.core.view.isVisible
-import androidx.navigation.fragment.findNavController
import au.gov.health.covidsafe.R
import au.gov.health.covidsafe.links.LinkBuilder
import au.gov.health.covidsafe.ui.base.BaseFragment
@@ -48,7 +47,9 @@ class HelpFragment : BaseFragment() {
reportAnIssue.setOnClickListener {
FeedbackModule.showFeedbackScreen()
}
- toolbar.setNavigationOnClickListener { findNavController().popBackStack() }
+ toolbar.setNavigationOnClickListener {
+ activity?.onBackPressed()
+ }
if (resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL) {
toolbar.navigationIcon =
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt
index c0c5a45..51d3a70 100644
--- a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragment.kt
@@ -51,6 +51,7 @@ import kotlinx.android.synthetic.main.view_home_setup_incomplete.*
import kotlinx.android.synthetic.main.view_national_case_statistics.national_case_layout
import kotlinx.android.synthetic.main.view_state_case_statistics.*
import kotlinx.coroutines.Dispatchers
+import kotlinx.coroutines.ensureActive
import kotlinx.coroutines.launch
import org.json.JSONObject
import pub.devrel.easypermissions.AppSettingsDialog
@@ -77,6 +78,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
private var isAppWithLatestVersion = false
lateinit var staticsLayout: ConstraintLayout
private lateinit var stateListAdapter: StateAdapter
+ private var reIssueFailCounter: Int = 0
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -196,6 +198,11 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
homeFragmentViewModel.reIssueFail.observe(this, Observer {
it?.let {
if (it) {
+ jwtExpired = true
+ if (homeFragmentViewModel.getReissueOnRefreshToken() && reIssueFailCounter <= 1) {
+ reIssueFailCounter++
+ refreshSetupCompleteOrIncompleteUi()
+ }
permissions_card_subtitle.visibility = GONE
registration_layout.visibility = VISIBLE
}
@@ -207,7 +214,6 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
if (it) {
jwtExpired = false
refreshSetupCompleteOrIncompleteUi()
-
}
}
})
@@ -333,14 +339,14 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
private fun initializeHelpTopicsNavigation() {
help_topics_link.setOnClickListener {
HelpFragment.anchor = null
- findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToHelpFragment())
+ startActivity(Intent(requireContext(), HelpActivity::class.java))
}
}
private fun initializeChangeLanguageNavigation() {
change_language_link.setOnClickListener {
HelpFragment.anchor = "#other-languages"
- findNavController().navigate(HomeFragmentDirections.actionHomeFragmentToHelpFragment())
+ startActivity(Intent(requireContext(), HelpActivity::class.java))
}
home_header_picture_setup_complete.setOnClickListener {
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragmentViewModel.kt b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragmentViewModel.kt
index f93eec9..136b98c 100644
--- a/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragmentViewModel.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/home/HomeFragmentViewModel.kt
@@ -2,7 +2,6 @@ package au.gov.health.covidsafe.ui.home
import android.app.Application
import android.content.Context
-import android.util.Log
import androidx.lifecycle.AndroidViewModel
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.MutableLiveData
@@ -25,7 +24,6 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.SupervisorJob
import kotlinx.coroutines.launch
import org.json.JSONObject
-import java.util.*
private const val TAG = "HomeFragmentViewModel"
@@ -56,6 +54,8 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
val isV2Available = MutableLiveData()
val reIssueFail = MutableLiveData(false)
val reIssueSuccess = MutableLiveData(false)
+ val getStatisticSuccessfull = MutableLiveData(false)
+ var reIssueFailOnRefreshToken = false
private val viewModelJob = SupervisorJob()
private val uiScope = CoroutineScope(Dispatchers.Main + viewModelJob)
@@ -64,18 +64,19 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
RetrofitServiceGenerator.createService(AwsClient::class.java)
}
- fun fetchGetCaseStatistics(lifecycle: Lifecycle) {
+ fun fetchGetCaseStatistics(lifecycle: Lifecycle, afterReIssue: Boolean = false) {
isV2Available.value = false
context = getApplication() as Context
titleOfNumber.value = context.getString(R.string.national_numbers)
turnCaseNumber.value = Preference.getTurnCaseNumber(context)
- if(caseNumberDataState.value != CaseNumbersState.LOADING) {
+ if((caseNumberDataState.value != CaseNumbersState.LOADING) || afterReIssue) {
caseNumberDataState.value = CaseNumbersState.LOADING
viewModelScope.launch(Dispatchers.IO) {
GetCaseStatisticsUseCase(awsClient, lifecycle, getApplication()).invoke("",
onSuccess = {
+ getStatisticSuccessfull.value = true
updateOnSuccess(it)
},
onFailure = {
@@ -101,8 +102,14 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
it.token.let {
Preference.putEncrypterJWTToken(context, it)
}
+ fetchGetCaseStatistics(lifecycle, true)
+ Preference.setAuthenticate(context, true)
+ reIssueSuccess.value = true
},
onFailure = {
+ reIssueFailOnRefreshToken = true
+ reIssueFail.value = true
+ Preference.setAuthenticate(context, false)
CentralLog.e(TAG, "On Failure: ${it.message}")
}
)
@@ -110,6 +117,11 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
}
fun getReissueAuth(lifecycle: Lifecycle) {
+ if (!Preference.getAuthenticate(context)) {
+ reIssueFail.value = true
+ return
+ }
+ Preference.setAuthenticate(context, false)
var subject: String? = null
context = getApplication() as Context
@@ -146,9 +158,12 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
it.token.let {
Preference.putEncrypterJWTToken(context, it)
}
+ Preference.setAuthenticate(context, true)
reIssueSuccess.value = true
+ fetchGetCaseStatistics(lifecycle, true)
},
onFailure = {
+ Preference.setAuthenticate(context, false)
reIssueFail.value = true
}
)
@@ -156,6 +171,9 @@ class HomeFragmentViewModel(application: Application) : AndroidViewModel(applica
}
}
+ fun getReissueOnRefreshToken(): Boolean{
+ return reIssueFailOnRefreshToken
+ }
private fun updateOnSuccess(caseStatisticResponse: CaseStatisticResponse) {
viewModelScope.launch {
isRefreshing.value = false
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinPresenter.kt b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinPresenter.kt
index ef6e4da..86e05c9 100644
--- a/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinPresenter.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/onboarding/fragment/enterpin/EnterPinPresenter.kt
@@ -97,6 +97,7 @@ class EnterPinPresenter(private val enterPinFragment: EnterPinFragment,
enterPinFragment.navigateToNextPage()
val context = enterPinFragment.requireContext()
+ Preference.setAuthenticate(context, true)
Preference.putBuildNumber(context, BuildConfig.VERSION_CODE)
} else {
onError()
diff --git a/app/src/main/java/au/gov/health/covidsafe/ui/restriction/RestrictionDescActivity.kt b/app/src/main/java/au/gov/health/covidsafe/ui/restriction/RestrictionDescActivity.kt
index ee9a902..c77aaab 100644
--- a/app/src/main/java/au/gov/health/covidsafe/ui/restriction/RestrictionDescActivity.kt
+++ b/app/src/main/java/au/gov/health/covidsafe/ui/restriction/RestrictionDescActivity.kt
@@ -40,7 +40,7 @@ class RestrictionDescActivity : AppCompatActivity() {
}
val summary = "" +
- "$htmlText."
+ "$htmlText