From 5f527eb8dd65ff469ffce9cbc7d942b8601cc8d0 Mon Sep 17 00:00:00 2001 From: "Nicola M. Cornelio" <80268479+nicola-95@users.noreply.github.com> Date: Mon, 28 Mar 2022 16:26:22 +0200 Subject: [PATCH] feat: remove work mode --- .../verificaC19/ui/FirstActivity.kt | 10 +++++++++- .../verificaC19/ui/ScanModeDialogFragment.kt | 11 ++++------- .../ui/main/codeReader/CodeReaderFragment.kt | 2 +- .../ui/main/verification/VerificationFragment.kt | 2 +- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/FirstActivity.kt b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/FirstActivity.kt index eeaa7f54..26768f0b 100644 --- a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/FirstActivity.kt +++ b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/FirstActivity.kt @@ -88,6 +88,8 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener, super.onCreate(savedInstanceState) binding = ActivityFirstBinding.inflate(layoutInflater) shared = this.getSharedPreferences(PrefKeys.USER_PREF, Context.MODE_PRIVATE) + + disableWorkMode() setContentView(binding.root) setSecureWindowFlags() setOnClickListeners() @@ -95,6 +97,13 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener, observeLiveData() } + private fun disableWorkMode() { + if (viewModel.getScanMode() == ScanMode.WORK) { + viewModel.setScanModeFlag(false) + shared.edit().remove("scanMode").commit() + } + } + private fun observeLiveData() { observeSyncStatus() observeRetryCount() @@ -251,7 +260,6 @@ class FirstActivity : AppCompatActivity(), View.OnClickListener, ScanMode.STANDARD -> getString(R.string.scan_mode_3G_header) ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header) ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header) - ScanMode.WORK -> getString(R.string.scan_mode_work_header) ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header) ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header) else -> getString(R.string.scan_mode_3G_header) diff --git a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/ScanModeDialogFragment.kt b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/ScanModeDialogFragment.kt index 31422348..2f9c48cf 100644 --- a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/ScanModeDialogFragment.kt +++ b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/ScanModeDialogFragment.kt @@ -101,9 +101,8 @@ class ScanModeDialogFragment(private val ruleSet: RuleSet) : DialogFragment(), S 0 -> viewModel.setScanMode(ScanMode.STANDARD) 1 -> viewModel.setScanMode(ScanMode.STRENGTHENED) 2 -> viewModel.setScanMode(ScanMode.BOOSTER) - 3 -> viewModel.setScanMode(ScanMode.WORK) - 4 -> viewModel.setScanMode(ScanMode.ENTRY_ITALY) - 5 -> viewModel.setScanMode(ScanMode.SCHOOL) + 3 -> viewModel.setScanMode(ScanMode.ENTRY_ITALY) + 4 -> viewModel.setScanMode(ScanMode.SCHOOL) } } @@ -112,9 +111,8 @@ class ScanModeDialogFragment(private val ruleSet: RuleSet) : DialogFragment(), S ScanMode.STANDARD -> 0 ScanMode.STRENGTHENED -> 1 ScanMode.BOOSTER -> 2 - ScanMode.WORK -> 3 - ScanMode.ENTRY_ITALY -> 4 - ScanMode.SCHOOL -> 5 + ScanMode.ENTRY_ITALY -> 3 + ScanMode.SCHOOL -> 4 else -> 0 } return chosenScanMode @@ -125,7 +123,6 @@ class ScanModeDialogFragment(private val ruleSet: RuleSet) : DialogFragment(), S ScanModeChoice(getString(R.string.scan_mode_3G_header), ruleSet.getBaseScanModeDescription() ?: ""), ScanModeChoice(getString(R.string.scan_mode_2G_header), ruleSet.getReinforcedScanModeDescription()), ScanModeChoice(getString(R.string.scan_mode_booster_header), ruleSet.getBoosterScanModeDescription()), - ScanModeChoice(getString(R.string.scan_mode_work_header), ruleSet.getWorkScanModeDescription()), ScanModeChoice(getString(R.string.scan_mode_entry_italy_header), ruleSet.getItalyEntryScanModeDescription()), ScanModeChoice(getString(R.string.scan_mode_school_header), ruleSet.getSchoolScanModeDescription()) ) diff --git a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/codeReader/CodeReaderFragment.kt b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/codeReader/CodeReaderFragment.kt index 0af3882b..5f024598 100644 --- a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/codeReader/CodeReaderFragment.kt +++ b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/codeReader/CodeReaderFragment.kt @@ -112,9 +112,9 @@ class CodeReaderFragment : Fragment(), NavController.OnDestinationChangedListene ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header) ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header) ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header) - ScanMode.WORK -> getString(R.string.scan_mode_work_header) ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header) ScanMode.DOUBLE_SCAN -> getString(R.string.scan_mode_booster_header) + else -> getString(R.string.scan_mode_3G_header) } binding.scanModeText.text = chosenScanMode binding.closeButton.setOnClickListener(this) diff --git a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/verification/VerificationFragment.kt b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/verification/VerificationFragment.kt index 421cd335..a13afec5 100644 --- a/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/verification/VerificationFragment.kt +++ b/app/src/main/java/it/ministerodellasalute/verificaC19/ui/main/verification/VerificationFragment.kt @@ -217,9 +217,9 @@ class VerificationFragment : Fragment(), View.OnClickListener { ScanMode.STRENGTHENED -> getString(R.string.scan_mode_2G_header) ScanMode.BOOSTER -> getString(R.string.scan_mode_booster_header) ScanMode.SCHOOL -> getString(R.string.scan_mode_school_header) - ScanMode.WORK -> getString(R.string.scan_mode_work_header) ScanMode.ENTRY_ITALY -> getString(R.string.scan_mode_entry_italy_header) ScanMode.DOUBLE_SCAN -> getString(R.string.scan_mode_booster_header) + else -> getString(R.string.scan_mode_3G_header) } binding.scanModeText.text = chosenScanMode }