Skip to content

Commit

Permalink
Merge branch 'release/v1.4.1-13'
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezh committed Jul 23, 2021
2 parents ff1e6b3 + 36a9524 commit 9fb3978
Show file tree
Hide file tree
Showing 17 changed files with 294 additions and 5 deletions.
10 changes: 7 additions & 3 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ android {
applicationId "es.gob.radarcovid"
minSdkVersion 23
targetSdkVersion 29
versionCode 12
versionName "1.4.0"
versionCode 13
versionName "1.4.1"
resConfigs "en", "es", "ro", "ca", "gl", "eu", "fr"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
Expand Down Expand Up @@ -306,7 +306,11 @@ dependencies {
implementation 'com.google.android.gms:play-services-vision:20.1.3'

//CrowdNotifier
implementation 'org.crowdnotifier:crowdnotifier-sdk-android:2.1.0'
implementation ('org.crowdnotifier:crowdnotifier-sdk-android:2.1.0') {
exclude group: 'com.goterl.lazycode', module: 'lazysodium-android'
}

implementation fileTree(include: 'lazysodium-android.aar', dir: 'lazysodium-android-4.2.0')
implementation 'com.google.protobuf:protobuf-lite:3.0.1'

//Biometrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import es.gob.radarcovid.R
import es.gob.radarcovid.common.base.events.BUS
import es.gob.radarcovid.common.base.events.EventExposureStatusChange
import es.gob.radarcovid.common.extensions.default
import es.gob.radarcovid.datamanager.repository.ExposureRecordRepository
import es.gob.radarcovid.datamanager.usecase.ExposureInfoUseCase
import es.gob.radarcovid.datamanager.usecase.GetHealingTimeUseCase
import es.gob.radarcovid.datamanager.utils.LabelManager
Expand All @@ -50,6 +51,9 @@ class ExposureStatusChangeBroadcastReceiver : DaggerBroadcastReceiver() {
@Inject
lateinit var labelManager: LabelManager

@Inject
lateinit var exposureRecordRepository: ExposureRecordRepository

override fun onReceive(context: Context?, intent: Intent?) {
super.onReceive(context, intent)
when (intent?.action) {
Expand All @@ -62,6 +66,7 @@ class ExposureStatusChangeBroadcastReceiver : DaggerBroadcastReceiver() {
getHealingTimeUseCase.getHealingTime().exposureHighMinutes
)
showHighExposureNotification(it)
exposureRecordRepository.addExposure(exposureInfoUseCase.getExposureInfo())
}
}, 2000)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ class RepositoryModule {
@PerApplication
fun providesEncryptedPreferencesRepository(repository: EncryptedPreferencesRepositoryImpl): EncryptedPreferencesRepository = repository

@Provides
@PerApplication
fun providesExposureRecordRepository(repository: ExposureRecordRepositoryImpl): ExposureRecordRepository = repository

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import dagger.android.ContributesAndroidInjector
import es.gob.radarcovid.common.view.*
import es.gob.radarcovid.common.view.adapter.SingleChoiceAdapter
import es.gob.radarcovid.features.home.view.ShareDialog
import es.gob.radarcovid.features.information.view.ExposureRecordDialog
import es.gob.radarcovid.features.information.view.InformationDialog
import es.gob.radarcovid.features.main.view.ExposureHealedDialog
import es.gob.radarcovid.features.stats.view.StatsCountriesDialog
Expand Down Expand Up @@ -67,6 +68,9 @@ abstract class ViewsModule {
@ContributesAndroidInjector
abstract fun bindsInformationDialog(): InformationDialog

@ContributesAndroidInjector
abstract fun bindsExposureRecordDialog(): ExposureRecordDialog

@ContributesAndroidInjector
abstract fun bindsStatsCountriesDialog(): StatsCountriesDialog

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package es.gob.radarcovid.datamanager.repository

import es.gob.radarcovid.models.domain.ExposureInfo

interface ExposureRecordRepository {

fun getExposureRecords() : List<ExposureInfo>
fun addExposure(exposureInfo: ExposureInfo)
fun removeExposures()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package es.gob.radarcovid.datamanager.repository

import es.gob.radarcovid.models.domain.ExposureInfo
import android.content.SharedPreferences
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import es.gob.radarcovid.common.extensions.toJson
import javax.inject.Inject

class ExposureRecordRepositoryImpl @Inject constructor(
private val sharedPreferences: SharedPreferences?
): ExposureRecordRepository {

companion object {
private const val KEY_EXPOSURE_RECORD_LIST = "key_exposure_record_list"
}

private fun saveToPrefs(key: String, data: String) {
sharedPreferences?.edit()?.putString(key, data)?.apply()
}

private fun getFromPreferences(key: String): String? =
sharedPreferences?.getString(key, null)

private fun removeFromPrefs(key: String) {
sharedPreferences?.edit()?.remove(key)?.apply()
}


override fun getExposureRecords(): List<ExposureInfo> {
val list = getFromPreferences(KEY_EXPOSURE_RECORD_LIST)
return if (list != null) {
val itemType = object : TypeToken<List<ExposureInfo>>() {}.type
Gson().fromJson(
list,
itemType
)
} else {
emptyList()
}
}

override fun addExposure(exposureInfo: ExposureInfo) {
var list = getExposureRecords()
list += exposureInfo
saveToPrefs(KEY_EXPOSURE_RECORD_LIST, list.toJson())
}

override fun removeExposures() {
removeFromPrefs(KEY_EXPOSURE_RECORD_LIST)
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@
package es.gob.radarcovid.datamanager.repository

import android.content.Context
import com.google.gson.Gson
import com.google.gson.reflect.TypeToken
import es.gob.radarcovid.common.extensions.toJson
import es.gob.radarcovid.datamanager.mapper.ExposureInfoDataMapper
import es.gob.radarcovid.models.domain.ExposureInfo
import es.gob.radarcovid.models.domain.VenueRecord
import org.dpppt.android.sdk.DP3T
import org.dpppt.android.sdk.internal.AppConfigManager
import org.dpppt.android.sdk.internal.storage.ExposureDayStorage
Expand Down Expand Up @@ -66,4 +70,7 @@ class ExposureStatusRepositoryImpl @Inject constructor(
DP3T.resetExposureDays(context)
preferencesRepository.setExposureAnalyticsCount(0)
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class InformationPresenterImpl @Inject constructor(
router.navigateToMail(text, subject, email)
}

override fun onExposureRecodrClick() {
view.showExposureRecordDialog()
}

private fun updateViews(exposureInfo: ExposureInfo) {
view.showRadarEnabled(exposureRadarUseCase.isRadarEnabled())
view.showBluetoothEnabled()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ interface InformationView {
fun showLastUpdateDate(date: Date, daysElapsed: Int, locale: String)

fun showTerminalData(locale: String)
fun showExposureRecordDialog()
}

interface InformationPresenter {
Expand All @@ -35,6 +36,8 @@ interface InformationPresenter {

fun onSupportMailClick(text: String, subject: String, email: String)

fun onExposureRecodrClick()

}

interface InformationRouter {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
package es.gob.radarcovid.features.information.view

import android.app.AlertDialog
import android.app.Dialog
import android.content.Context
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import dagger.android.HasAndroidInjector
import es.gob.radarcovid.R
import es.gob.radarcovid.common.extensions.toDateFormat
import es.gob.radarcovid.datamanager.repository.ExposureRecordRepository
import es.gob.radarcovid.datamanager.utils.LabelManager
import es.gob.radarcovid.models.domain.ExposureInfo
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.dialog_exposure_record.*
import java.util.*
import javax.inject.Inject

class ExposureRecordDialog(context: Context) : LayoutContainer {

private val dialog: Dialog

override val containerView: View =
LayoutInflater.from(context).inflate(R.layout.dialog_exposure_record, null)

@Inject
lateinit var labelManager: LabelManager

@Inject
lateinit var exposureRecordRepository: ExposureRecordRepository

init {

initializeInjector(context)

dialog = AlertDialog.Builder(context)
.setView(containerView)
.create()
.apply {
window?.setBackgroundDrawable(ColorDrawable(Color.TRANSPARENT))
}

buttonClose.setOnClickListener { dialog.dismiss() }
buttonCancel.setOnClickListener { dialog.dismiss() }

}

private fun loadRecords() {
val records = exposureRecordRepository.getExposureRecords()
var text = ""
if (records.isEmpty()) {
text = labelManager.getText(
"EXPOSURE_RECORDS_NO_DATA",
R.string.exposure_records_no_data
).toString()
} else {
records.forEach {
text += "\u25CF " + it.lastExposureDate.toDateFormat() + "\n"
}
}

recordContent.text = text
}

private fun initializeInjector(context: Context) {
(context.applicationContext as? HasAndroidInjector)?.androidInjector()?.inject(this)
}

fun show() {
dialog.show()
dialog.window?.setLayout(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
loadRecords()
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ class InformationActivity : BaseBackNavigationActivity(), InformationView {
InformationDialog(this).show()
}

override fun showExposureRecordDialog() {
ExposureRecordDialog(this).show()
}

override fun showRadarEnabled(isRadarEnabled: Boolean) {
if (isRadarEnabled) {
val activeText = labelManager.getText(
Expand Down Expand Up @@ -174,6 +178,9 @@ class InformationActivity : BaseBackNavigationActivity(), InformationView {
buttonMaintenance.setSafeOnClickListener {
presenter.onHelpButtonClick()
}
buttonExposureRecord.setSafeOnClickListener {
presenter.onExposureRecodrClick()
}
buttonSupportMail.setSafeOnClickListener {
val mail = labelManager.getText(
"INFO_TECHNICAL_HELP_EMAIL",
Expand Down
17 changes: 16 additions & 1 deletion app/src/main/res/layout/activity_information.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,21 @@
app:labelId="INFO_KEEP_RADAR_ACTIVE"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/textViewBluetoothStatus"/>

<es.gob.radarcovid.common.view.LabelButton
android:id="@+id/buttonExposureRecord"
style="@style/Title18PurpleA7"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="21dp"
android:layout_marginEnd="21dp"
android:background="@android:color/transparent"
android:textAllCaps="false"
android:text="@string/exposure_record_button_title"
android:layout_marginTop="25dp"
app:labelId="EXPOSURE_RECORD_BUTTON_TITLE"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/buttonMaintenance"/>

<View
android:id="@+id/separator1"
Expand All @@ -273,7 +288,7 @@
android:background="@color/gray_BD"
android:layout_marginTop="20dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/buttonMaintenance"/>
app:layout_constraintTop_toBottomOf="@id/buttonExposureRecord"/>

<es.gob.radarcovid.common.view.LabelTextView
android:id="@+id/textViewTitleVersion"
Expand Down
Loading

0 comments on commit 9fb3978

Please sign in to comment.