Commit 491d860a authored by stopcovid@lunabee.com's avatar stopcovid@lunabee.com
Browse files

Misc. fixes

parent 323852a8
......@@ -18,7 +18,7 @@ android {
minSdkVersion 21
targetSdkVersion 29
buildConfigField 'String', 'SERVER_PUBLIC_KEY', STOPCOVID_SERVER_PUBLIC_KEY
buildConfigField 'String', 'SERVER_PUBLIC_KEY', '"MFkwEwYHKoZIzj0CAQYIKoZIzj0DAQcDQgAEAc9IDt6qJq453SwyWPB94JaLB2VfTAcL43YVtMr3HhDCd22gKaQXIbX1d+tNhfvaKM51sxeaXziPjntUzbTNiw=="'
}
kotlinOptions.jvmTarget = JavaVersion.VERSION_1_8.toString()
......
......@@ -43,7 +43,6 @@ import com.lunabeestudio.robert.model.RobertException
import com.lunabeestudio.robert.model.RobertResult
import com.lunabeestudio.robert.model.RobertResultData
import com.lunabeestudio.robert.model.RobertUnknownException
import com.lunabeestudio.robert.model.ServerDecryptException
import com.lunabeestudio.robert.model.UnknownException
import com.lunabeestudio.robert.repository.EphemeralBluetoothIdentifierRepository
import com.lunabeestudio.robert.repository.KeystoreRepository
......@@ -53,7 +52,6 @@ import com.lunabeestudio.robert.worker.StatusWorker
import timber.log.Timber
import java.util.Date
import java.util.concurrent.TimeUnit
import javax.crypto.AEADBadTagException
import kotlin.random.Random
class RobertManagerImpl(
......@@ -158,8 +156,8 @@ class RobertManagerImpl(
RobertResult.Success()
} catch (e: Exception) {
clearLocalData(application)
if (e is AEADBadTagException) {
RobertResult.Failure(ServerDecryptException())
if (e is RobertException) {
RobertResult.Failure(e)
} else {
RobertResult.Failure(RobertUnknownException())
}
......
......@@ -15,6 +15,10 @@ object Constants {
const val ON_BOARDING_DONE: String = "On.Boarding.Done"
}
object WorkerNames {
const val NOTIFICATION: String = "StopCovid.Notification.Worker"
}
object ServerConstant {
val ACCEPTED_REPORT_CODE_LENGTH: List<Int> = listOf(6, 36)
}
......
......@@ -18,6 +18,7 @@ import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleObserver
import androidx.lifecycle.OnLifecycleEvent
import androidx.lifecycle.ProcessLifecycleOwner
import androidx.work.ExistingWorkPolicy
import androidx.work.OneTimeWorkRequestBuilder
import androidx.work.WorkManager
import com.lunabeestudio.framework.local.LocalCryptoManager
......@@ -133,7 +134,8 @@ class StopCovid : Application(), LifecycleObserver, RobertApplication {
.build()
}
WorkManager.getInstance(applicationContext).enqueue(statusWorkRequest)
WorkManager.getInstance(applicationContext)
.enqueueUniqueWork(Constants.WorkerNames.NOTIFICATION, ExistingWorkPolicy.KEEP, statusWorkRequest)
}
override fun getAppContext(): Context = this
......
......@@ -66,7 +66,7 @@ class OnBoardingActivity : AppCompatActivity() {
sharedPreferences.isOnBoardingDone() -> {
try {
navController.navigate(OnBoardingWelcomeFragmentDirections.actionOnBoardingWelcomeFragmentToMainActivity())
finish()
finishAndRemoveTask()
} catch (e: IllegalArgumentException) {
Timber.e(e)
}
......
......@@ -70,7 +70,7 @@ class IsSickFragment : AboutMainFragment() {
try {
findNavController()
.navigate(ManageDataFragmentDirections.actionGlobalOnBoardingActivity())
activity?.finish()
activity?.finishAndRemoveTask()
} catch (e: IllegalArgumentException) {
// If user leave the screen before logout is done
}
......
......@@ -18,6 +18,7 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.observe
import androidx.navigation.fragment.findNavController
import androidx.preference.PreferenceManager
import androidx.work.WorkManager
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.lunabeestudio.robert.RobertApplication
import com.lunabeestudio.stopcovid.Constants
......@@ -71,10 +72,11 @@ class ManageDataFragment : MainFragment() {
sharedPreferences.edit {
remove(Constants.SharedPrefs.ON_BOARDING_DONE)
}
WorkManager.getInstance(requireContext().applicationContext).cancelUniqueWork(Constants.WorkerNames.NOTIFICATION)
try {
findNavController()
.navigate(ManageDataFragmentDirections.actionGlobalOnBoardingActivity())
activity?.finish()
activity?.finishAndRemoveTask()
} catch (e: IllegalArgumentException) {
// If user leave the screen before logout is done
}
......
......@@ -33,7 +33,7 @@ class OnBoardingGestureFragment : OnBoardingFragment() {
}
findNavController()
.navigate(OnBoardingGestureFragmentDirections.actionOnBoardingGestureFragmentToMainActivity())
activity?.finish()
activity?.finishAndRemoveTask()
}
override fun getItems(): List<GenericItem> {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment