Commit b735b0ac authored by Harri Kirik's avatar Harri Kirik
Browse files

COVAPP-480: Move to DP-3T SDK 2.3.1.b1-EE-SNAPSHOT-calibration. Add a manual...

COVAPP-480: Move to DP-3T SDK 2.3.1.b1-EE-SNAPSHOT-calibration. Add a manual sync button to the debug menu
parent 2c495781
......@@ -76,7 +76,7 @@ class DebugMenuFragment : MvvmFragment(), ViewBindingHolder<FragmentDebugBinding
requireBinding().buttonBack.setOnClickListener { findNavController().popBackStack() }
setupSdkViews()
setupStateOptions()
setupAppScreens()
setupDebugButtons()
setupLogActions()
initViewModel()
}
......@@ -157,6 +157,7 @@ class DebugMenuFragment : MvvmFragment(), ViewBindingHolder<FragmentDebugBinding
}
}
updateRadioGroup(optionsGroup)
updateButtonStatesBasedOnTheDebugState()
}
private fun updateRadioGroup(optionsGroup: RadioGroup) {
......@@ -169,7 +170,22 @@ class DebugMenuFragment : MvvmFragment(), ViewBindingHolder<FragmentDebugBinding
optionsGroup.check(preSetId)
}
private fun setupAppScreens() {
private fun updateButtonStatesBasedOnTheDebugState() {
when (getDebugAppState()) {
DebugAppState.NONE -> enableButtonDebugDp3tSync(true)
DebugAppState.HEALTHY -> enableButtonDebugDp3tSync(false)
DebugAppState.CONTACT_EXPOSED -> enableButtonDebugDp3tSync(false)
DebugAppState.REPORTED_EXPOSED -> enableButtonDebugDp3tSync(false)
}.exhaustive
}
private fun enableButtonDebugDp3tSync(enabled: Boolean) {
requireBinding {
buttonDebugDp3tSync.isEnabled = enabled
}
}
private fun setupDebugButtons() {
requireBinding {
buttonDebugStateErrorDialog.setOnClickListener { showDebugStateErrorDialog() }
buttonDebugStateContactNotification.setOnClickListener { notifier.createNewContactNotification(requireActivity(), -1) }
......@@ -178,6 +194,7 @@ class DebugMenuFragment : MvvmFragment(), ViewBindingHolder<FragmentDebugBinding
buttonDebugStateShareScreenSuccess.setOnClickListener { showShareSuccessScreen() }
buttonDebugStateOpenSettingsAndScrollToCrossCountry.setOnClickListener { openSettingsAndScrollToCrossCountry() }
buttonDebugStateCrossCountryPopUp.setOnClickListener { openCrossCountryPopUp() }
buttonDebugDp3tSync.setOnClickListener { viewModel.startDP3TSyncCLicked() }
}
}
......@@ -272,6 +289,7 @@ class DebugMenuFragment : MvvmFragment(), ViewBindingHolder<FragmentDebugBinding
private fun setDebugAppState(debugAppState: DebugAppState) {
(tracingViewModel.tracingStatusInterface as TracingStatusWrapper).setDebugAppState(context, debugAppState)
updateButtonStatesBasedOnTheDebugState()
}
private fun openSettingsAndScrollToCrossCountry() {
......
......@@ -2,13 +2,21 @@ package org.dpppt.android.app.debug.debugmenu
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import io.reactivex.rxjava3.disposables.Disposable
import mobi.lab.mvvm.Event
import org.dpppt.android.app.common.util.asLiveData
import org.dpppt.android.app.common.util.backgroundToMain
import org.dpppt.android.app.domain.usecase.dp3t.GaenSyncUseCase
import org.dpppt.android.app.util.dispose
import timber.log.Timber
import javax.inject.Inject
class DebugMenuViewModel @Inject constructor() : ViewModel() {
class DebugMenuViewModel @Inject constructor(
private val syncUseCase: GaenSyncUseCase
) : ViewModel() {
private val _action = MutableLiveData<Event<Action>>()
val action = _action.asLiveData()
private var dp3tSyncDisposable: Disposable? = null
fun postCurrentDevelopmentLogClicked() {
_action.value = Event(Action.PostCurrentDevelopmentLog)
......@@ -22,6 +30,17 @@ class DebugMenuViewModel @Inject constructor() : ViewModel() {
_action.value = Event(Action.ShowLogAccessError(error))
}
fun startDP3TSyncCLicked() {
Timber.d("Sync start called")
dispose(dp3tSyncDisposable)
dp3tSyncDisposable = syncUseCase.execute()
.backgroundToMain()
.subscribe(
{ Timber.d("Sync success") },
{ error -> Timber.e(error, "Sync error") }
)
}
sealed class Action {
object PostCurrentDevelopmentLog : Action()
object ViewAllDevelopmentLogs : Action()
......
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/blue_disabled" android:state_enabled="false"/>
<item android:color="@color/blue"/>
</selector>
......@@ -62,8 +62,7 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/size_16">
android:layout_height="wrap_content">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/guide_start"
......@@ -217,7 +216,23 @@
app:layout_constraintEnd_toEndOf="@id/guide_end"
app:layout_constraintStart_toStartOf="@id/guide_start"
app:layout_constraintTop_toBottomOf="@id/sdk_version_text"
app:layout_constraintBottom_toBottomOf="parent" />
app:layout_constraintBottom_toTopOf="@id/buttonDebugDp3tSync" />
<com.google.android.material.button.MaterialButton
android:id="@+id/buttonDebugDp3tSync"
style="@style/AppTheme.Button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constrainedWidth="true"
android:layout_gravity="center_horizontal"
android:layout_marginTop="@dimen/size_24"
android:layout_marginBottom="@dimen/size_24"
android:text="@string/debug_state_button_dp3t_sync"
app:layout_constraintTop_toBottomOf="@id/sdk_errors"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="@id/guide_end"
app:layout_constraintStart_toStartOf="@id/guide_start" />
</androidx.constraintlayout.widget.ConstraintLayout>
</com.google.android.material.card.MaterialCardView>
......
......@@ -224,4 +224,5 @@ Aitäh, et hoiad lähedasi."</string>
<string name="settings_cross_country_description_blue_part">"Tutvu riikide nimekirja ja tööpõhimõttega siin."</string>
<string name="contacts_detected_text_health_board_thanks_you">"Terviseamet tänab sind panuse eest!"</string>
<string name="debug_state_show_share_screen_success">"Eduka võtmete jagamise ekraan"</string>
</resources>
\ No newline at end of file
<string name="debug_state_button_dp3t_sync">"Sünkroniseeri DP-3Tga"</string>
</resources>
......@@ -14,6 +14,7 @@
<color name="accent">@color/primary</color>
<color name="darkBlue">#00005A</color>
<color name="blue">#003CFF</color>
<color name="blue_disabled">#40003CFF</color>
<color name="background">#F0F1F2</color>
<color name="white">#FFFFFF</color>
<color name="lightYellow">#FCEDC5</color>
......
......@@ -219,4 +219,5 @@ Thank you for keeping people close to you safe."</string>
<string name="settings_cross_country_description_blue_part">"See this for more information and the list of supported countries."</string>
<string name="contacts_detected_text_health_board_thanks_you">"The Estonian Health Board thanks you for your contribution!"</string>
<string name="debug_state_show_share_screen_success">"Share keys success screen"</string>
</resources>
\ No newline at end of file
<string name="debug_state_button_dp3t_sync">"Synchronize with DP-3T"</string>
</resources>
......@@ -263,7 +263,7 @@
<item name="android:paddingStart">@dimen/size_24</item>
<item name="android:paddingEnd">@dimen/size_24</item>
<item name="android:textSize">@dimen/text_size_12</item>
<item name="backgroundTint">@color/blue</item>
<item name="backgroundTint">@color/color_blue_disableable</item>
</style>
<style name="AppTheme.Button.Short">
......
......@@ -9,7 +9,7 @@ ext.androidVersions = [
def versions = [
// DP-3T
// See https://repo.tehik.ee/artifactory/contact-tracing-maven/org/dpppt/dp3t-sdk-android/{VERSION}/dp3t-sdk-android-{VERSION}.pom
dp3tSDKAndroidEE : '2.2.0.b1-EE-PRODUCTION',
dp3tSDKAndroidEE : '2.3.1.b1-EE-SNAPSHOT-calibration',
// BuildScript
kotlin : '1.5.0',
......
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