diff --git a/app/k9mail/src/main/AndroidManifest.xml b/app/k9mail/src/main/AndroidManifest.xml index 6c889e67bdb962eb133a65fb224563f8e3369881..ff83a773874d8343233125af215a00ba24538bb0 100644 --- a/app/k9mail/src/main/AndroidManifest.xml +++ b/app/k9mail/src/main/AndroidManifest.xml @@ -75,6 +75,11 @@ android:configChanges="locale" android:label="@string/account_setup_basics_title"/> + + . + */ + +package com.fsck.k9.activity.setup + +import android.app.Activity +import android.content.Intent +import android.os.Bundle +import android.view.MenuItem +import com.fsck.k9.activity.MessageList +import com.fsck.k9.ui.R +import com.fsck.k9.ui.base.K9Activity +import com.fsck.k9.ui.settings.import.SettingsImportResultViewModel +import com.fsck.k9.ui.settings.import.SettingsImportSuccess +import org.koin.androidx.viewmodel.ext.android.viewModel + +/** + * Prompts the user to select a exported settings file + * + */ +class AccountSetupImportSettings : K9Activity() { + + private val resultViewModel: SettingsImportResultViewModel by viewModel() + + public override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + setLayout(R.layout.account_setup_import_settings) + setUpActionBar() + + handleOnSuccessCallback() + } + + private fun handleOnSuccessCallback() { + resultViewModel.settingsImportResult.observe(this) { + if (it == SettingsImportSuccess) { + startActivityClearTop(MessageList::class.java) + } + } + } + + private fun startActivityClearTop(clazz: Class) { + val intent = Intent(this@AccountSetupImportSettings, clazz) + intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK) + startActivity(intent) + finish() + } + + private fun setUpActionBar() { + setTitle(R.string.settings_import_title) + supportActionBar?.setDisplayHomeAsUpEnabled(true) + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + if (item.itemId == android.R.id.home) { + onBackPressed() + return true + } + + return super.onOptionsItemSelected(item) + } + + override fun onBackPressed() { + startActivityClearTop(AccountSetupBasics::class.java) + } +} diff --git a/app/ui/legacy/src/main/res/layout/account_setup_import_settings.xml b/app/ui/legacy/src/main/res/layout/account_setup_import_settings.xml new file mode 100644 index 0000000000000000000000000000000000000000..74eeb9a10f654e81bc484467503e1a9d4fbf5c78 --- /dev/null +++ b/app/ui/legacy/src/main/res/layout/account_setup_import_settings.xml @@ -0,0 +1,33 @@ + + + + + + + + + + diff --git a/app/ui/legacy/src/main/res/layout/wizard_setup.xml b/app/ui/legacy/src/main/res/layout/wizard_setup.xml index 9e651d9f2ad3a7b7af9618e20c7a8008f587776d..570c56ad4122a5783df749bd58955727a9658e30 100644 --- a/app/ui/legacy/src/main/res/layout/wizard_setup.xml +++ b/app/ui/legacy/src/main/res/layout/wizard_setup.xml @@ -22,6 +22,15 @@ android:background="?selectableItemBackground" android:text="@string/account_setup_basics_manual_setup_action" /> +