diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e5bb23367d..210103484f0 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,7 +46,7 @@ The following rule governs documentation contributions: ## Pull Request Checklist -* Branch from the master branch and, if needed, rebase to the current master branch before submitting your pull request. If it doesn't merge cleanly with master, you may be asked to rebase your changes. +* Branch from the dev branch and ensure it is up to date with the current dev branch before submitting your pull request. If it doesn't merge cleanly with dev, you may be asked to resolve the conflicts. Pull requests to master will be closed. * Commits should be as small as possible while ensuring that each commit is correct independently (i.e., each commit should compile and pass tests). diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragment.kt index 247f6a10781..7984e7c41fc 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingNotificationsFragment.kt @@ -6,12 +6,8 @@ import android.view.View import android.view.ViewGroup import androidx.appcompat.app.AlertDialog import androidx.core.app.NotificationManagerCompat -import de.rki.coronawarnapp.R import de.rki.coronawarnapp.databinding.FragmentOnboardingNotificationsBinding -import de.rki.coronawarnapp.storage.SettingsRepository import de.rki.coronawarnapp.ui.BaseFragment -import de.rki.coronawarnapp.util.DialogHelper -import de.rki.coronawarnapp.util.SettingsNavigationHelper /** * This fragment ask the user if he wants to get notifications and finishes the onboarding afterwards. @@ -42,12 +38,6 @@ class OnboardingNotificationsFragment : BaseFragment() { private fun setButtonOnClickListener() { binding.onboardingButtonFinish.setOnClickListener { - finishOrSettings() - } - binding.onboardingButtonDisable.setOnClickListener { - // Set default value for notifications to false - SettingsRepository.toggleNotificationsRiskEnabled() - SettingsRepository.toggleNotificationsTestEnabled() navigateToMain() } binding.onboardingButtonBack.buttonIcon.setOnClickListener { @@ -55,35 +45,7 @@ class OnboardingNotificationsFragment : BaseFragment() { } } - private fun finishOrSettings() { - // If the os notifications settings are enabled the user can finish the onboarding. - // If the user want to get notifications but they are disabled on the os level he can go - // to the notification settings to activate them. - val areNotificationsEnabled = - NotificationManagerCompat.from(requireContext()).areNotificationsEnabled() - if (areNotificationsEnabled) { - navigateToMain() - } else { - showNotificationsDisabledDialog() - } - } - private fun navigateToMain() { (requireActivity() as OnboardingActivity).completeOnboarding() } - - private fun showNotificationsDisabledDialog() { - val dialog = DialogHelper.DialogInstance( - requireActivity(), - R.string.onboarding_notifications_headline, - R.string.onboarding_notifications_dialog_body, - R.string.onboarding_notifications_dialog_button_positive, - R.string.onboarding_notifications_dialog_button_negative, - { - SettingsNavigationHelper.toNotifications(requireContext()) - }, { - navigateToMain() - }) - DialogHelper.showDialog(dialog) - } } diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragment.kt index fe791014e5c..341a61b48ea 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/onboarding/OnboardingTracingFragment.kt @@ -60,7 +60,7 @@ class OnboardingTracingFragment : BaseFragment(), internalExposureNotificationPermissionHelper.requestPermissionToStartTracing() } binding.onboardingButtonDisable.setOnClickListener { - navigate() + showCancelDialog() } binding.onboardingButtonBack.buttonIcon.setOnClickListener { (activity as OnboardingActivity).goBack() @@ -72,7 +72,7 @@ class OnboardingTracingFragment : BaseFragment(), } override fun onFailure(exception: Exception?) { - showCancelDialog() + navigate() } private fun showCancelDialog() { diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/SettingsTracingFragment.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/SettingsTracingFragment.kt index 20055ffcb07..2b88b3c5002 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/SettingsTracingFragment.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/ui/settings/SettingsTracingFragment.kt @@ -107,7 +107,7 @@ class SettingsTracingFragment : BaseFragment(), (activity as MainActivity).goBack() } binding.settingsTracingStatusBluetooth.tracingStatusCardButton.setOnClickListener { - SettingsNavigationHelper.toBluetooth(requireContext()) + SettingsNavigationHelper.toConnections(requireContext()) } binding.settingsTracingStatusConnection.tracingStatusCardButton.setOnClickListener { SettingsNavigationHelper.toConnections(requireContext()) diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/SettingsNavigationHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/SettingsNavigationHelper.kt index 76ac129acd5..d172d0ecd28 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/SettingsNavigationHelper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/SettingsNavigationHelper.kt @@ -11,17 +11,6 @@ import android.provider.Settings */ object SettingsNavigationHelper { - /** - * Navigate the user to the os bluetooth settings. - * - * @param context - */ - fun toBluetooth(context: Context) { - val intent = Intent() - intent.action = Settings.ACTION_BLUETOOTH_SETTINGS - context.startActivity(intent) - } - /** * Navigate the user to the os connection settings. * diff --git a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterSettingsHelper.kt b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterSettingsHelper.kt index 97c84a7daf5..41def653e3c 100644 --- a/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterSettingsHelper.kt +++ b/Corona-Warn-App/src/main/java/de/rki/coronawarnapp/util/formatter/FormatterSettingsHelper.kt @@ -20,16 +20,40 @@ fun formatStatus(value: Boolean): String = formatText( ) /** - * Formats the main text display of tracing status depending on tracing status + * Formats the text display of settings notification status depending on notification values + * + * @param notifications + * @param notificationsRisk + * @param notificationsTest + * @return + */ +fun formatNotificationsStatusText( + notifications: Boolean, + notificationsRisk: Boolean, + notificationsTest: Boolean +): String = + formatStatus((notifications && (notificationsRisk || notificationsTest))) + +/** + * Change the tracing text in the row based on the tracing status. * * @param tracing + * @param bluetooth + * @param connection * @return String */ -fun formatTracingStatusText(tracing: Boolean): String = formatText( - tracing, - R.string.settings_tracing_body_active, - R.string.settings_tracing_body_inactive -) +fun formatTracingStatusText(tracing: Boolean, bluetooth: Boolean, connection: Boolean): String { + val appContext = CoronaWarnApplication.getAppContext() + return when (tracingStatusHelper(tracing, bluetooth, connection)) { + TracingStatusHelper.CONNECTION, TracingStatusHelper.BLUETOOTH -> + appContext.getString(R.string.settings_tracing_status_restricted) + TracingStatusHelper.TRACING_ACTIVE -> + appContext.getString(R.string.settings_tracing_status_active) + TracingStatusHelper.TRACING_INACTIVE -> + appContext.getString(R.string.settings_tracing_status_inactive) + else -> "" + } +} /** * Format the settings tracing description text display depending on tracing status @@ -82,12 +106,12 @@ fun formatNotificationsDescription(notifications: Boolean): String = formatText( * Formats the tracing body depending on the tracing status and the days since last exposure. * * @param tracing - * @param daysSinceLastExposure + * @param activeTracingDaysInRetentionPeriod * @return String */ -fun formatTracingStatusBody(tracing: Boolean, daysSinceLastExposure: Int): String { +fun formatTracingStatusBody(tracing: Boolean, activeTracingDaysInRetentionPeriod: Long): String { val appContext = CoronaWarnApplication.getAppContext() - val daysArg = daysSinceLastExposure.toString() + val daysArg = activeTracingDaysInRetentionPeriod.toString() return if (tracing) { appContext.getString(R.string.settings_tracing_status_body_active) .format(daysArg) @@ -107,6 +131,21 @@ fun formatTracingStatusBody(tracing: Boolean, daysSinceLastExposure: Int): Strin fun formatIconColor(active: Boolean): Int = formatColor(active, R.color.settingsIconActive, R.color.settingsIconInactive) +/** + * Formats the settings icon color for notifications depending on notification values + * + * @param notifications + * @param notificationsRisk + * @param notificationsTest + * @return Int + */ +fun formatIconColor( + notifications: Boolean, + notificationsRisk: Boolean, + notificationsTest: Boolean +): Int = + formatIconColor((notifications && (notificationsRisk || notificationsTest))) + /** * Formats the tracing switch status based on the tracing status * @@ -257,27 +296,6 @@ fun formatTracingStatusVisibilityTracing( ) } -/** - * Change the tracing text in the row based on the tracing status. - * - * @param tracing - * @param bluetooth - * @param connection - * @return String - */ -fun formatTracingStatusText(tracing: Boolean, bluetooth: Boolean, connection: Boolean): String { - val appContext = CoronaWarnApplication.getAppContext() - return when (tracingStatusHelper(tracing, bluetooth, connection)) { - TracingStatusHelper.CONNECTION, TracingStatusHelper.BLUETOOTH -> - appContext.getString(R.string.settings_tracing_status_restricted) - TracingStatusHelper.TRACING_ACTIVE -> - appContext.getString(R.string.settings_tracing_status_active) - TracingStatusHelper.TRACING_INACTIVE -> - appContext.getString(R.string.settings_tracing_status_inactive) - else -> "" - } -} - /** * Formats the settings notifications details illustration depending on notifications status * diff --git a/Corona-Warn-App/src/main/res/layout/fragment_onboarding_notifications.xml b/Corona-Warn-App/src/main/res/layout/fragment_onboarding_notifications.xml index b28518783ed..fbcc6ca2f53 100644 --- a/Corona-Warn-App/src/main/res/layout/fragment_onboarding_notifications.xml +++ b/Corona-Warn-App/src/main/res/layout/fragment_onboarding_notifications.xml @@ -40,17 +40,6 @@ app:layout_constraintStart_toStartOf="@id/guideline_start" app:layout_constraintTop_toBottomOf="@id/guideline_bottom" /> -