COVIDSafe code from version 2.6 (#50)

This commit is contained in:
COVIDSafe Support 2021-05-12 17:39:37 -07:00 committed by GitHub
parent a63cc33286
commit 2406cc21a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 65 additions and 5 deletions

View file

@ -29,8 +29,8 @@ android {
applicationId "au.gov.health.covidsafe"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 125
versionName "2.5"
versionCode 128
versionName "2.6"
buildConfigField "String", "GITHASH", "\"${getGitHash()}\""
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"

View file

@ -31,6 +31,7 @@ import kotlinx.android.synthetic.main.activity_home.*
private const val TAG = "HomeActivity"
private const val UNAUTHORIZED = "Unauthorized"
private const val UNAUTHENTICATED = "unauthenticated"
private const val CLOUDFRONT = "CloudFront"
class HomeActivity : FragmentActivity(), NetworkConnectionCheck.NetworkConnectionListener, SensorDelegate {
@ -39,6 +40,7 @@ class HomeActivity : FragmentActivity(), NetworkConnectionCheck.NetworkConnectio
var isWindowFocusChangeLiveData = MutableLiveData<Boolean>()
var isJWTCorrupted = MutableLiveData<Boolean>()
var isJWTExpired = MutableLiveData<Boolean>()
var cloudFrontIssue = MutableLiveData<Boolean>()
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@ -117,6 +119,9 @@ class HomeActivity : FragmentActivity(), NetworkConnectionCheck.NetworkConnectio
if (it.errorBodyMessage.equals(UNAUTHORIZED) || it.errorBodyMessage.equals(UNAUTHENTICATED)) {
isJWTCorrupted.postValue(true)
isJWTExpired.postValue(true)
} else if (it.errorBodyMessage.equals(CLOUDFRONT)) {
isJWTExpired.postValue(true)
cloudFrontIssue.postValue(true)
} else {
Log.d("LEE", "Authenticate")
isJWTCorrupted.postValue(false)

View file

@ -6,6 +6,7 @@ import android.app.job.JobScheduler
import android.app.job.JobService
import android.content.ComponentName
import android.content.Context
import android.util.Log
import au.gov.health.covidsafe.BuildConfig
import au.gov.health.covidsafe.app.TracerApp
import au.gov.health.covidsafe.extensions.isBatteryOptimizationDisabled
@ -26,6 +27,7 @@ import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.delay
import kotlinx.coroutines.launch
import okhttp3.internal.toHeaderList
import retrofit2.Call
import retrofit2.Callback
import retrofit2.Response
@ -174,7 +176,6 @@ object GetMessagesScheduler {
messagesCall.enqueue(object : Callback<MessagesResponse> {
override fun onResponse(call: Call<MessagesResponse>, response: Response<MessagesResponse>) {
val responseCode = response.code()
if (responseCode == 200) {
CentralLog.d(TAG, "onResponse() got 200 response.")
@ -188,6 +189,12 @@ object GetMessagesScheduler {
val messageResponse = MessagesResponse(emptyList(), null, false, errorMessage.message)
messagesResponseCallback?.invoke(messageResponse)
}
} else if (responseCode == 403) {
val server = response.headers()["server"]
if (!server.isNullOrEmpty() && server == "CloudFront") {
val messageResponse = MessagesResponse(emptyList(), null, false, "CloudFront")
messagesResponseCallback?.invoke(messageResponse)
}
} else {
CentralLog.w(TAG, "onResponse() got error response code = $responseCode.")
}

View file

@ -73,6 +73,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
private var counter: Int = 0
private var jwtExpired: Boolean = false
private var cloudFront: Boolean = false
private var checkIsInternetConnected = false
private var isAppWithLatestVersion = false
@ -159,6 +160,7 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
isJWTExpired.observe(this@HomeFragment, isJwtExpired)
isAppUpdateAvailableLiveData.observe(this@HomeFragment, latestAppAvailable)
isWindowFocusChangeLiveData.observe(this@HomeFragment, refreshUiObserver)
cloudFrontIssue.observe(this@HomeFragment, isCloudFrontIssue)
}
homeFragmentViewModel.turnCaseNumber.observe(this, Observer { turnOn ->
@ -205,6 +207,15 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
}
permissions_card_subtitle.visibility = GONE
registration_layout.visibility = VISIBLE
if (cloudFront) {
re_register.visibility = GONE
register_body.visibility = GONE
geoblock_error_message.visibility = VISIBLE
} else {
re_register.visibility = VISIBLE
register_body.visibility = VISIBLE
geoblock_error_message.visibility = GONE
}
}
}
})
@ -237,6 +248,10 @@ class HomeFragment : BaseFragment(), EasyPermissions.PermissionCallbacks, Networ
jwtExpired = expired
}
private val isCloudFrontIssue = Observer<Boolean> {
cloudFront = it
}
override fun onResume() {
super.onResume()

View file

@ -3,6 +3,7 @@ package au.gov.health.covidsafe.ui.onboarding.fragment.enternumber
import android.annotation.SuppressLint
import android.app.AlertDialog
import android.content.Intent
import android.net.Uri
import android.os.Bundle
import android.view.KeyEvent
import android.view.LayoutInflater
@ -16,9 +17,9 @@ import androidx.annotation.NavigationRes
import androidx.core.content.ContextCompat
import androidx.core.os.bundleOf
import androidx.core.widget.addTextChangedListener
import au.gov.health.covidsafe.preference.Preference
import au.gov.health.covidsafe.R
import au.gov.health.covidsafe.app.TracerApp
import au.gov.health.covidsafe.preference.Preference
import au.gov.health.covidsafe.talkback.setHeading
import au.gov.health.covidsafe.ui.base.PagerChildFragment
import au.gov.health.covidsafe.ui.base.UploadButtonLayout
@ -157,6 +158,18 @@ class EnterNumberFragment : PagerChildFragment() {
.setPositiveButton(android.R.string.yes, null).show()
}
fun showPhoneNumberWrong() {
alertDialog?.dismiss()
alertDialog = AlertDialog.Builder(activity)
.setMessage(R.string.max_registrations)
.setIcon(android.R.drawable.ic_dialog_alert)
.setNegativeButton(R.string.max_registration_button2, null)
.setPositiveButton(R.string.max_registrations_button1) { _,_ ->
startActivity(Intent(Intent.ACTION_VIEW, Uri.parse("https://covidsafe-form.service.gov.au/")))
}
.show()
}
fun navigateToOTPPage(
session: String,
challengeName: String,

View file

@ -71,9 +71,11 @@ class EnterNumberPresenter(private val enterNumberFragment: EnterNumberFragment)
when {
it is GetOnboardingOtpException.GetOtpInvalidNumberException -> {
enterNumberFragment.showInvalidPhoneNumberPrompt(R.string.invalid_phone_number)
enterNumberFragment.showPhoneNumberWrong()
}
context.isInternetAvailable() -> {
enterNumberFragment.showGenericError()
enterNumberFragment.showPhoneNumberWrong()
// enterNumberFragment.showGenericError()
}
else -> {
enterNumberFragment.showCheckInternetError()

View file

@ -148,6 +148,19 @@
tools:visibility="visible"
android:text="@string/jwt_expired_description" />
<TextView
android:id="@+id/geoblock_error_message"
style="@style/fontRobotoRegular16"
android:layout_width="0dp"
android:paddingEnd="12dp"
android:layout_height="wrap_content"
android:gravity="start"
android:textColor="@color/error_red"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toStartOf="@+id/permission_icon"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/geoblock_error_message" />
</androidx.constraintlayout.widget.ConstraintLayout>
</FrameLayout>

View file

@ -296,6 +296,8 @@
<!-- for production -->
<string name="generic_error">Please try again later</string>
<string name="generic_internet_error">Please check your internet connection</string>
<!-- Error message for when a user tries to signup outside of Australia. -->
<string name="geoblock_error_message">You may be connected using an internet provider from outside Australia. This could happen when using international data roaming on a non-Australian SIM card.\n\nPlease connect to an Australian network or use a local Wi-Fi internet connection to continue.</string>
<string name="global_OK">OK</string>
<string name="heading">Heading</string>
<string name="hide">Hide</string>
@ -398,6 +400,9 @@
<string name="loading_numbers">Loading latest numbers</string>
<string name="locally_acquired">%@ locally acquired</string>
<string name="main_restrictions">Main restrictions</string>
<string name="max_registration_button2">Cancel</string>
<string name="max_registrations">You\'ve reached the limit to register using the same mobile number.\n\nTo use the same mobile number to register again, you must request to delete your current registration information.</string>
<string name="max_registrations_button1">Request deletion</string>
<!-- Splash Screen -->
<string name="migration_in_progress"> COVIDSafe update in progress. \n\n Please make sure you phone is not switched off until the update is complete.</string>
<string name="minute">Minute</string>