Allow back navigation through setup screens
Fixes setup flow and ensures an account is fully setup before being usable
This commit is contained in:
parent
699c8408be
commit
ee6d7afc75
9 changed files with 20 additions and 12 deletions
|
@ -291,6 +291,13 @@ public class Account implements BaseAccount {
|
|||
identities.set(0, newIdentity);
|
||||
}
|
||||
|
||||
/**
|
||||
* an account is only setup when it has a name (as it's the last required step of the setup)
|
||||
*/
|
||||
public synchronized boolean isFinishedSetup() {
|
||||
return getName() != null && !getName().isEmpty();
|
||||
}
|
||||
|
||||
public synchronized boolean getSignatureUse() {
|
||||
return identities.get(0).getSignatureUse();
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import com.fsck.k9.Account.SortType
|
|||
import com.fsck.k9.K9
|
||||
import com.fsck.k9.K9.SplitViewMode
|
||||
import com.fsck.k9.Preferences
|
||||
import com.fsck.k9.account.BackgroundAccountRemover
|
||||
import com.fsck.k9.activity.compose.MessageActions
|
||||
import com.fsck.k9.controller.MessageReference
|
||||
import com.fsck.k9.fragment.MessageListFragment
|
||||
|
@ -77,6 +78,7 @@ open class MessageList :
|
|||
private val preferences: Preferences by inject()
|
||||
private val channelUtils: NotificationChannelManager by inject()
|
||||
private val defaultFolderProvider: DefaultFolderProvider by inject()
|
||||
private val accountRemover: BackgroundAccountRemover by inject()
|
||||
|
||||
private val storageListener: StorageListener = StorageListenerImplementation()
|
||||
private val permissionUiHelper: PermissionUiHelper = K9PermissionUiHelper(this)
|
||||
|
@ -119,7 +121,9 @@ open class MessageList :
|
|||
super.onCreate(savedInstanceState)
|
||||
|
||||
val accounts = preferences.accounts
|
||||
if (accounts.isEmpty()) {
|
||||
deleteIncompleteAccounts(accounts)
|
||||
val hasAccountSetup = accounts.any { it.isFinishedSetup }
|
||||
if (!hasAccountSetup) {
|
||||
OnboardingActivity.launch(this)
|
||||
finish()
|
||||
return
|
||||
|
@ -199,6 +203,12 @@ open class MessageList :
|
|||
displayViews()
|
||||
}
|
||||
|
||||
private fun deleteIncompleteAccounts(accounts: List<Account>) {
|
||||
accounts.filter { !it.isFinishedSetup }.forEach {
|
||||
accountRemover.removeAccountAsync(it.uuid)
|
||||
}
|
||||
}
|
||||
|
||||
private fun findFragments() {
|
||||
val fragmentManager = supportFragmentManager
|
||||
messageListFragment = fragmentManager.findFragmentById(R.id.message_list_container) as MessageListFragment?
|
||||
|
|
|
@ -91,7 +91,6 @@ class AccountSetupAccountType : K9Activity() {
|
|||
|
||||
private fun returnAccountTypeSelectionResult() {
|
||||
AccountSetupIncoming.actionIncomingSettings(this, account, makeDefault)
|
||||
finish()
|
||||
}
|
||||
|
||||
companion object {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.content.Context;
|
|||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.text.Editable;
|
||||
import android.text.InputType;
|
||||
import android.text.TextWatcher;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
|
@ -312,7 +311,6 @@ public class AccountSetupBasics extends K9Activity
|
|||
Preferences.getPreferences(this).saveAccount(mAccount);
|
||||
Core.setServicesEnabled(this);
|
||||
AccountSetupNames.actionSetNames(this, mAccount);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -351,8 +349,6 @@ public class AccountSetupBasics extends K9Activity
|
|||
mAccount.setTransportUri(transportUri);
|
||||
|
||||
AccountSetupAccountType.actionSelectAccountType(this, mAccount, false);
|
||||
|
||||
finish();
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -551,9 +551,7 @@ public class AccountSetupIncoming extends K9Activity implements OnClickListener
|
|||
*/
|
||||
}
|
||||
|
||||
|
||||
AccountSetupOutgoing.actionOutgoingSettings(this, mAccount, mMakeDefault);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -90,8 +90,8 @@ public class AccountSetupNames extends K9Activity implements OnClickListener {
|
|||
}
|
||||
mAccount.setName(mName.getText().toString());
|
||||
Preferences.getPreferences(getApplicationContext()).saveAccount(mAccount);
|
||||
finishAffinity();
|
||||
MessageList.launch(this, mAccount);
|
||||
finish();
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -120,7 +120,6 @@ public class AccountSetupOptions extends K9Activity implements OnClickListener {
|
|||
}
|
||||
Core.setServicesEnabled(this);
|
||||
AccountSetupNames.actionSetNames(this, mAccount);
|
||||
finish();
|
||||
}
|
||||
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -465,7 +465,6 @@ public class AccountSetupOutgoing extends K9Activity implements OnClickListener,
|
|||
finish();
|
||||
} else {
|
||||
AccountSetupOptions.actionOptions(this, mAccount, mMakeDefault);
|
||||
finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -121,7 +121,7 @@ class SettingsListFragment : Fragment() {
|
|||
|
||||
private fun launchOnboarding() {
|
||||
findNavController().navigate(R.id.action_settingsListScreen_to_onboardingScreen)
|
||||
requireActivity().finish()
|
||||
requireActivity().finishAffinity()
|
||||
}
|
||||
|
||||
private fun buildSettingsList(block: SettingsListBuilder.() -> Unit): List<GenericItem> {
|
||||
|
|
Loading…
Reference in a new issue