Skip to content
This repository has been archived by the owner on Jun 20, 2023. It is now read-only.

code smell fixes (EXPOSURAPP-3058) #1330

Merged
merged 14 commits into from
Oct 7, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,7 @@ object RetrieveDiagnosisKeysTransaction : Transaction() {
.asyncRetrieveApplicationConfiguration()
.supportedCountriesList
}

if (CWADebug.isDebugBuildOrMode) {
onKeyFilesDownloadStarted?.invoke()
onKeyFilesDownloadStarted = null
}
invokeSubmissionStartedInDebugOrBuildMode()

val availableKeyFiles = executeFetchKeyFilesFromServer(countries)

Expand All @@ -218,11 +214,7 @@ object RetrieveDiagnosisKeysTransaction : Transaction() {

onKeyFilesDownloadFinished?.invoke(availableKeyFiles.size, totalFileSize)
onKeyFilesDownloadFinished = null
}

if (CWADebug.isDebugBuildOrMode) {
onApiSubmissionStarted?.invoke()
onApiSubmissionStarted = null
invokeSubmissionStartedInDebugOrBuildMode()
}

val isSubmissionSuccessful = executeAPISubmission(
Expand All @@ -231,16 +223,27 @@ object RetrieveDiagnosisKeysTransaction : Transaction() {
token = token
)

if (CWADebug.isDebugBuildOrMode) {
onApiSubmissionFinished?.invoke()
onApiSubmissionFinished = null
}
invokeSubmissionFinishedInDebugOrBuildMode()

if (isSubmissionSuccessful) executeFetchDateUpdate(currentDate)

executeClose()
}

private fun invokeSubmissionStartedInDebugOrBuildMode() {
if (CWADebug.isDebugBuildOrMode) {
onApiSubmissionStarted?.invoke()
onApiSubmissionStarted = null
}
}

private fun invokeSubmissionFinishedInDebugOrBuildMode() {
if (CWADebug.isDebugBuildOrMode) {
onApiSubmissionFinished?.invoke()
onApiSubmissionFinished = null
}
}

override suspend fun rollback() {
super.rollback()
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -156,17 +156,15 @@ class SubmissionQRCodeScanFragment : Fragment(R.layout.fragment_submission_qr_co
permissions: Array<String>,
grantResults: IntArray
) {
if (requestCode == REQUEST_CAMERA_PERMISSION_CODE) {

// permission was denied
if ((grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED)) {
// if permission was denied
if (requestCode == REQUEST_CAMERA_PERMISSION_CODE &&
(grantResults.isNotEmpty() && grantResults[0] == PackageManager.PERMISSION_DENIED)) {
if (shouldShowRequestPermissionRationale(Manifest.permission.CAMERA)) {
showCameraPermissionRationaleDialog()
} else {
// user permanently denied access to the camera
showCameraPermissionDeniedDialog()
}
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ class GoogleAPIVersion @Inject constructor() {
val currentVersion = InternalExposureNotificationClient.getVersion()
currentVersion >= compareVersion
} catch (apiException: ApiException) {
if (apiException.statusCode == CommonStatusCodes.API_NOT_CONNECTED) false
else throw apiException
if (apiException.statusCode != CommonStatusCodes.API_NOT_CONNECTED) throw apiException
else return false
ralfgehrer marked this conversation as resolved.
Show resolved Hide resolved
}
}

Expand Down